Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?
    require_once  "../connect2.php";
    require_once  "../../Warenwirtschaft/includes/statistik/system.php";
    require_once  "system.php";

    if ( $_REQUEST["filter"] )
    {
        $_SESSION["onlineshop"]["individual"]["filter"] = $_REQUEST["filter"];
    }
    $filter = $_SESSION["onlineshop"]["individual"]["filter"];
    if ( empty( $filter["gueltig"] ) )
    {
        $filter["gueltig"] = "neu";
    }

    if ( $_REQUEST["mailSend"] )
    {
        $sql = "
            SELECT 
                * 
            FROM 
                web_settings 
            WHERE 
                id=11 
            AND 
                shops_ID=" . $_REQUEST["shops_ID"] . "
        ";
        $res = mysql_query( $sql );
        $row = mysql_fetch_assoc( $res );
        $email_from = $row["Inhalt"];
        require_once  "../../Warenwirtschaft/MailClient/mail_func.php";
        $extra["headers"] = array( "From" => $email_from );
        $extra["shops_ID"] = $_REQUEST["shops_ID"];
        if ( $_POST["url"] )
        {
            //            mail("niewerth@weban.de", "Übergabe an Pixelconsult (Preisanfrage)", $_POST["url"], "From: info@$site");
            $url = $_POST["url"];
            require_once  $url;
        }
        send_email( $_REQUEST["mailTo"], $_REQUEST["mailSubject"],
            stripslashes( $_REQUEST["mailText"] ), $extra );
    }
    if ( $_REQUEST["updateOK"] || $_REQUEST["updateNO"] )
    {
        $_GET["edit"] = $_REQUEST["ID"];
        $_REQUEST["update"] = true;

        if ( $_REQUEST["updateOK"] )
        {
            if ( $_REQUEST["erstellt_von"] == "Artikelanfrage" )
            {
                $id_subject_ok = 105;
                $id_body_ok = 106;
            }
            else
            {
                $id_subject_ok = 101;
                $id_body_ok = 102;
            }
            $sql = "
                SELECT 
                    * 
                FROM 
                    web_settings 
                WHERE 
                    id=$id_subject_ok 
                AND 
                    shops_ID=" . $_REQUEST["shops_ID"] . "
            ";
            $res = mysql_query( $sql );
            $row = mysql_fetch_assoc( $res );
            $mailSubject = $row["Inhalt"];
            $sql = "
                SELECT 
                    * 
                FROM 
                    web_settings 
                WHERE 
                    id=$id_body_ok 
                AND 
                    shops_ID=" . $_REQUEST["shops_ID"] . "
            ";
            $res = mysql_query( $sql );
            $row = mysql_fetch_assoc( $res );
            $mailText = $row["Inhalt"];
        }

        if ( $_REQUEST["updateNO"] )
        {
            if ( $_REQUEST["erstellt_von"] == "Artikelanfrage" )
            {
                $id_subject_no = 107;
                $id_body_no = 108;
            }
            else
            {
                $id_subject_no = 103;
                $id_body_no = 104;
            }
            $sql = "
                SELECT 
                    * 
                FROM 
                    web_settings 
                WHERE 
                    id=$id_subject_no 
                AND 
                    shops_ID=" . $_REQUEST["shops_ID"] . "
            ";
            $res = mysql_query( $sql );
            $row = mysql_fetch_assoc( $res );
            $mailSubject = $row["Inhalt"];
            $sql = "SELECT 
                    * 
                FROM 
                    web_settings 
                WHERE 
                    id=$id_body_no 
                AND 
                    shops_ID=" . $_REQUEST["shops_ID"] . "
            ";
            $res = mysql_query( $sql );
            $row = mysql_fetch_assoc( $res );
            $mailText = $row["Inhalt"];
        }

    }

    $a_id = checkItem( $_REQUEST["itemAdd"]["artikel_ID"], $_REQUEST["shops_ID"] );
    if ( $a_id )
    {
        sonderPreisSetItem( $_REQUEST["ID"], $a_id, "", $_REQUEST["itemAdd"]["preis"] );
    }

    if ( $_REQUEST["update"] )
    {
        foreach ( $_REQUEST["value"]["preis"] as $ID => $preis )
        {
            $query = "
                                update
                                        sonderPreisArtikel
                                set
                                        preis='" . $preis . "',
                                        inBasket='" . $_REQUEST["value"]["inBasket"][$ID] . "',
                                        letzte_Aenderung_von = '$PHP_AUTH_USER'
                                where
                                        ID = '" . $ID . "'
                                ";
            mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error
                () . pre( $query, true ) );
        }

        $query = "
                        update
                                sonderPreis
                        set
                                gueltigVon = '" . implode( "-", array_reverse( explode( ".", $gueltigVon ) ) ) .
            " 00:00:00',
                                gueltigBis = '" . implode( "-", array_reverse( explode( ".", $gueltigBis ) ) ) .
            " 23:59:59',                                
                                letzte_Aenderung_von = '$PHP_AUTH_USER'
                        where
                                ID = '" . $_REQUEST["ID"] . "'
                        ";
        mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
            pre( $query, true ) );

    }

    if ( $_REQUEST["deleteAnfrage"] )
    {
        if ( is_array( $_REQUEST["deleteAnfrage"] ) )
        {
            foreach ( $_REQUEST["deleteAnfrage"] as $anfrageID )
            {
                $query = "delete from sonderPreis where ID = '$anfrageID'";
                mysql_query( $query ) or die( mysql_errno() . ": " .
                    mysql_error() . pre( $query, true ) );

                $query =
                    "delete from sonderPreisArtikel where sonderPreis_ID = '$anfrageID'";
                mysql_query( $query ) or die( mysql_errno() . ": " .
                    mysql_error() . pre( $query, true ) );
            }
        }
        else
        {
            $query = "delete from sonderPreis where ID = '" . $_REQUEST["deleteAnfrage"] .
                "'";
            mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error
                () . pre( $query, true ) );

            $query =
                "delete from sonderPreisArtikel where sonderPreis_ID = '" .
                $_REQUEST["deleteAnfrage"] . "'";
            mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error
                () . pre( $query, true ) );
        }
    }


    if ( $_REQUEST["deleteItem"] )
    {
        $query = "delete from sonderPreisArtikel where ID = '" . $_REQUEST["deleteItem"] .
            "'";
        mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
            pre( $query, true ) );
    } ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sonder-Preis</title>
<link rel="stylesheet" type="text/css" href="../redaktion.css">
<style>
        td { vertical-align:top; }
        ul { margin:0px; }
        td.delete {text-align:center; }
        input.button { width:100px; float:right; }
        input.terminButton { width:100px; }
</style>
<style media="print">
    .noprint
    {
        display:none;
    }
</style>
<script language="javascript">
        function formatTime(timeobj)
        {
                //with (timeobj) { return getFullYear()+"-"+(getMonth()+1)+"-"+getDate()+" "+getHours()+":"+getMinutes()+":"+getSeconds(); }
                with (timeobj) { return getDate()+"."+(getMonth()+1)+"."+getFullYear(); }               
        }
        function artikel_suche(lang)
        {
           open('artikelsuche.php?lang='+lang,'artikelsuche');
        }
        function setZeitraum(formobj, intervall)
        {
                var oneDaymilliseconds = 1000*60*60*24;
                var Jetzt = new Date();
                var Dann = new Date(Jetzt.getTime() + oneDaymilliseconds * intervall);

                with (formobj)
                {
                        gueltigVon.value = formatTime(Jetzt);
                        gueltigBis.value = formatTime(Dann);
                }
        }
        
        function killkomma(w)
        {
                return w.replace(/,/,'.');
        }
    
    function check_all()
    {
        with (document.forms[0]) 
        {
            for (i=0; i < elements.length; i++) 
            {
                if (elements[i].type == "checkbox") 
                {
                    elements[i].checked=true;
                }
            }
        }
    }
    
    function uncheck_all()
    {
        with (document.forms[0]) 
        {
            for (i=0; i < elements.length; i++) 
            {
                if (elements[i].type == "checkbox") 
                {
                    elements[i].checked=false;
                }
            }
        }
    }
</script>
</head>
<body>
<?
    $gueltigOptionen = array( array( "ID" => "neu", "Name" => "neu" ), array
        ( "ID" => "aktuell", "Name" => "aktuell" ), array( "ID" =>
        "abgelaufen", "Name" => "abgelaufen" ), array( "ID" => "kommend",
        "Name" => "kommend" ) ); ?>
<form action="<?= $self; ?>" method="post" name="individualpreis">
    <table border="1" cellspacing="0" cellpadding="2" style="width:700px" class="noprint">
        <tr>
            <td class="links">SonderPreis &Uuml;bersicht: </td>
        </tr>
        <tr>
            <td class="rechts">
                <table border="0" cellspacing="0" cellpadding="2">
                    <tr class="rechts">
                        <td>Shop</td>
                        <td>
                            <? select( "filter[shop]", getShops(), "ID",
    "Name", $filter["shop"], false ); ?>
                        </td>
                        <td>Name</td>
                        <td>
                            <input type="text" name="filter[name]" value="<?= $filter["name"]; ?>" />
                        </td>
                        <td>G&uuml;ltigkeit</td>
                        <td>
                            <? select( "filter[gueltig]", $gueltigOptionen,
    "ID", "Name", $filter["gueltig"], false ); ?>
                        </td>
                        <td>
                            <input type="submit" value="OK" class="button" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <br />
<?
    if ( !$_GET["edit"] )
    { ?>
    <table border="1" cellspacing="0" cellpadding="5" style="width:100%;">
                <tr class="links" bgcolor="#<? echo $webs[bgcolor_links] ?>">
                        <td class="headline">Anfrage-<br>datum</td>
                        <td class="headline">Kunde</td>
                        <td class="headline">eventueller Gültigkeitszeitraum / <br />Artikelliste</td>
                        <td class="headline" width="150">L&ouml;schen <br>
                <a onclick="check_all();return false;" style="cursor:pointer">alle wählen</a>
                <br>
                <a onclick="uncheck_all();return false;" style="cursor:pointer">alle abwählen</a> 
            </td>
                </tr>
                <?

        $anfragen = getSonderPreisAnfragen( $filter["shop"], $filter["name"],
            $filter["gueltig"] );
        /*$anz=getAnzSonderPreisAnfragen();
        echo $anz;*/
        foreach ( $anfragen as $anfrage )
        {
            $sql = "
                SELECT 
                    * 
                FROM 
                    shops 
                WHERE 
                    ID=" . $anfrage["shops_ID"] . "
            ";
            $res = mysql_query( $sql );
            $row = mysql_fetch_assoc( $res );
            $shopName = $row["Name"];
            $shopLang = $row["Language"]; ?>
        <tr class="rechts" bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
                <td><a href="<?= $self; ?>?edit=<?= $anfrage["ID"]; ?>"><?= $anfrage["erstellt_am"]; ?></a></td>
                <td><a href="<?= $self; ?>?edit=<?= $anfrage["ID"]; ?>"><?= $anfrage["kundeName"]; ?></a><br>aus <?=
            $anfrage["kundePLZ"] . " " . $anfrage["kundeOrt"]; ?></td>
                <td>
                        <div>
                        <?php
            if ( $anfrage["fremd_link"] )
            {
                $url = parse_url( $anfrage["fremd_link"] );
                $link = $url["scheme"] . "://" . $url["host"] .
                    "/shopping_cart.php?" . $url["query"];
            }
            else
            {
                $link = "http://www." . $shopName . "/";
                $link .= ( $shopLang != "DE" ) ? "specialprice" :
                    "sonderpreis";
                $link .= "/" . $anfrage["chksum"] . ".htm";
                $link .= ( $shopLang != "DE" ) ? "?stop=no" : "";
            } ?>
            <a href="<?= $link ?>" target="_blank"><? if ( $anfrage["gueltigVon"] )
            {
                echo "[" . $anfrage["gueltigVon"] . " - " . $anfrage["gueltigBis"] .
                    "]";
            } ?></a></div>
                        <a href="<?= $self; ?>?edit=<?= $anfrage["ID"]; ?>"><ul><?

            foreach ( sonderPreisGetItems( $anfrage["ID"] ) as $sonderPreisItem )
            { ?><li><?= $sonderPreisItem["itemName"]; ?><br /><?= $sonderPreisItem["kundeNachricht"]; ?></li><?
            } ?></ul></a></td><td class="delete"><!--<a href="<?= $self; ?>?deleteAnfrage=<?= $anfrage["ID"]; ?>">[X]</a>--><input type="checkbox" name="deleteAnfrage[]" value="<?= $anfrage["ID"]; ?>"></td>
</tr>
<?
        } ?>
        <tr bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
                <td colspan="3">&nbsp;</td><td><input type="submit" value="L&ouml;schen" /></td>
        </tr>
  </table>
<?
    }
    else
    {
        $id = $_GET["edit"];

        $kundenDaten = sonderPreisGetKundenDaten( $id );
        if ( $kundenDaten["fremd_link"] )
        {
            $url = parse_url( $kundenDaten["fremd_link"] );
            $link = $url["scheme"] . "://" . $url["host"] .
                "/shopping_cart.php?" . $url["query"];
            $kundenDaten["link"] = $link;
            $vdat = implode( "-", array_reverse( explode( ".", $gueltigVon ) ) );
            $bdat = implode( "-", array_reverse( explode( ".", $gueltigBis ) ) );
            $gueltigVon_tstamp = strtotime( $vdat );
            $gueltigBis_tstamp = strtotime( $bdat );
            $url = $kundenDaten["fremd_link"] . "&gueltigVon=" . $gueltigVon_tstamp .
                "&gueltigBis=" . $gueltigBis_tstamp;
        }
        else
        {
            $url = "";
            $link = "http://www." . $kundenDaten["shop_Name"] .
                "/sonderpreis/" . $kundenDaten["chksum"] . ".htm";
        }
        $sql = "
            SELECT 
                * 
            FROM 
                shops 
            WHERE 
                ID=" . $kundenDaten["shops_ID"] . "                
        ";
        $res = mysql_query( $sql );
        $row = mysql_fetch_assoc( $res );
        $shopName = $row["Name"];
        $shopLang = $row["Language"];
        extract( $kundenDaten );

        $items = array();
        $cnt = 0;
        foreach ( sonderPreisGetItems( $id ) as $item )
        {
            if ( $url )
            {
                $url .= "&anfrage[$cnt][products_id]=" . $item["artikel_ID"] .
                    "&anfrage[$cnt][products_price]=" . $item["preis"];
                $cnt++;
            }
            $items[] = str_pad( "  " . $item[itemName], 61, " " ) . "|" .
                str_pad( $item[preis] . " Euro ", 18, " ", STR_PAD_LEFT );
        }
        $kundenDaten["items"] = implode( "\n", $items );

        $mailText = templateContent( $kundenDaten, $mailText, $display = false );
        $mailSubject = templateContent( $kundenDaten, $mailSubject, $display = false ); ?>
<table border="1" cellspacing="0" cellpadding="5">
  <tr>
    <td colspan="3" class="links"><div style="float:right"><?= $erstellt_am; ?></div>Preisanfrage: <?= $shopName; ?> - <a href="mailto:<?= $kundeMail; ?>"><?= $kundeName; ?></a> aus <?= $kundePLZ .
        " " . $kundeOrt; ?></td>
    </tr>
  <tr class="rechts">
    <td>L&ouml;schen</td>
    <td>Artikel / Shop-Preis<br />
      Bemerkung</td>
    <td width="100">In Warenkorb legen / Preis</td>     
  </tr>
<? foreach ( sonderPreisGetItems( $id ) as $item )
        { 
            ?>
  <tr>
    <td class="delete"><a href="<?= $self; ?>?deleteItem=<?= $item["ID"]; ?>&edit=<?= $ID; ?>">[X]</a></td>
    <td>
        <div style="float:right;"><?= $item["shopPreis"]; ?></div>
        <u><?= $item["itemName"]; ?></u>
        (
            <a href="/Online-Shop/artikel.php?action=edit&ID=<?= $item["artikel_ID"] ?>" target="_blank" class="noprint">?</a>
            <?php
            if ( $row["domain"] )
            { ?>
            &nbsp;|&nbsp;
            <a href="http://www.<?= $row["domain"] ?>/index.php?item=<?= $item["artikel_ID"] ?>" target="_blank">S</a>
            <?php
            } ?>
            )
        <br /><?= $item["kundeNachricht"]; ?>
    </td>
    <td>
                <input type="hidden"    name="value[inBasket][<?= $item["ID"]; ?>]"             value="0" />
                <input type="checkbox"  name="value[inBasket][<?= $item["ID"]; ?>]"             value="1" <? if ( $item["inBasket"] ==
            "1" )
            {
                echo "checked";
            } ?> />
                <input type="text"              name="value[preis][<?= $item["ID"]; ?>]"        value="<?= $item["preis"]; ?>" size="5" onchange="this.value=killkomma(this.value);" />
                <? //pre($item); ?>     </td>
  </tr>
<? } ?>
  <tr class="rechts">
    <td>&nbsp;<input type="hidden" name="itemAdd[sonderPreis_ID]" /></td>
    <td>
        <input type="text" name="itemAdd[artikel_ID]" id="artikel_id" readonly="readonly" />
        <input type="button" onclick="javascript:artikel_suche('<?= $shopLang; ?>');" value="Artikelsuche">
    </td>
    <td>
                <input type="hidden"    name="itemAdd[inBasket]"        value="0" />
                <input type="checkbox"  name="itemAdd[inBasket]"        value="1" />
                <input type="text"              name="itemAdd[preis]" size="8" onchange="this.value=killkomma(this.value);" />  </td>
  </tr>
  <tr class="rechts">
    <td>Angebot gültig</td>
    <td colspan="2">
                <table border="0" cellspacing="0" cellpadding="3">
          <tr>
            <td>von:</td>
            <td><input type="text" name="gueltigVon" value="<?= $gueltigVon; ?>" /></td>
            <td><input type="button" class="button" value="1 Tag" onclick="setZeitraum(this.form,1)" /></td>
          </tr>
          <tr>
            <td>bis:</td>
            <td><input type="text" name="gueltigBis" value="<?= $gueltigBis; ?>" /></td>
            <td><input type="button" class="button" value="3 Tage" onclick="setZeitraum(this.form,3)" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td><input type="button" class="button" value="7 Tage" onclick="setZeitraum(this.form,7)" /></td>
          </tr>
        </table>        </td>
  </tr>
  <tr class="links noprint">
        <td colspan="3">
<?
        $buttons = array( array( "name" => "updateOK", "value" =>
            "Speichern und OK - Mail", "style" => "width:330px; float:left;" ),
            array( "name" => "updateNO", "value" =>
            "Speichern und Nein - Mail", "style" => "width:330px;" ) );

        foreach ( $buttons as $button )
        { ?><input type="submit" name="<? if ( $_REQUEST[$button['name']] )
            {
                echo "mailSend";
            }
            else
            {
                echo $button['name'];
            } ?>" value="<?= $button['value'];
            if ( $_REQUEST[$button['name']] )
            {
                echo " versenden";
            }
            else
            {
                echo " zeigen";
            } ?>" class="button" style="<?= $button['style']; ?>" /><?
        } ?>    </td>
  </tr>
  <tr class="links noprint">
    <td>
                Empfänger:     </td>
    <td colspan="2"><input type="text" name="mailTo" style="width:500px;" value="<?= $kundeMail; ?>" /></td>
    </tr>
  <tr class="links noprint">
    <td>
                Betreff:        </td>
    <td colspan="2"><input type="text" name="mailSubject" style="width:500px;" value="<?= $mailSubject; ?>" /></td>
    </tr>
  <tr class="links noprint">
    <td colspan="3">
                <textarea name="mailText" style="width:680px; height:400px;"><?= $mailText ?></textarea>        </td>
  </tr>
  <tr class="links">
    <td colspan="3">
                <input type="hidden" name="ID" value="<?= $ID; ?>" />
                <input type="hidden" name="shops_ID" value="<?= $shops_ID ?>" />                
                <input type="hidden" name="erstellt_von" value="<?= $erstellt_von; ?>">
                <input type="hidden" name="url" value="<?= $url; ?>">
                letzte &Auml;nderung: <?= $letzte_Aenderung_von; ?> (<?= $letzte_Aenderung_am; ?>)
                <input type="submit" name="update" value="Speichern" class="button noprint" />
    </td>
  </tr>
</table>
<?
    } ?>
</form>
</body>
</html>