Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?
        require_once "connect2.php";
        //mysql_query("use pluemacher_de");
        
        session_start();
        if (!$_SESSION[Language]) {$_SESSION[Language] = "DE";}
        
        if ($action)
        {
                switch($action)
                {
                        case "delete": // Löschen einer Kombination
                                        $query="DELETE FROM Versandart_to_Bezahlweise.* WHERE Versandart=$Versandart AND Bezahlweise=$Bezahlweise and Language='".$_SESSION[Language]."'";
                                        mysql_query($query) or die(mysql_error()."<hr>$query<hr>");
                                break;

                        case "SYNC": // Synchronisierung der Kombinationen mit der Artikeltabelle
                                        $query="
                                                SELECT
                                                        Versandart_to_Bezahlweise.artikel as ID,
                                                        Versandart_to_Bezahlweise.Language,
                                                        -3 as Father,
                                                        concat(Versandart.Name,' ',Bezahlweise.Name) as kurzbezeichnung,
                                                        Versandart_to_Bezahlweise.Preis as preis1,
                                                        Versandart_to_Bezahlweise.Preis as preis2,
                                                        Versandart_to_Bezahlweise.Preis as preis3,
                                                        Versandart_to_Bezahlweise.Preis as preis4,
                                                        Versandart_to_Bezahlweise.Preis as preis5,
                                                        Versandart_to_Bezahlweise.Preis as preis6,
                                                        Versandart_to_Bezahlweise.Lieferstatus,
                                                        0 as Status,
                                                        Versandart_to_Bezahlweise.Eigenschaft_1,
                                                        Versandart_to_Bezahlweise.Eigenschaft_2,
                                                        Versandart_to_Bezahlweise.Eigenschaft_3,
                                                        Versandart_to_Bezahlweise.Eigenschaft_4,
                                                        Versandart_to_Bezahlweise.Eigenschaft_5,
                                                        Versandart_to_Bezahlweise.Versandart,
                                                        Versandart_to_Bezahlweise.Bezahlweise
                                                FROM
                                                        Versandart,
                                                        Bezahlweise,
                                                        Versandart_to_Bezahlweise 
                                                WHERE
                                                        Versandart_to_Bezahlweise.Versandart=Versandart.ID
                                                AND
                                                        Versandart_to_Bezahlweise.Bezahlweise=Bezahlweise.ID
                                                AND
                                                        Versandart.Language=Versandart_to_Bezahlweise.Language
                                        ";
                                        $result=mysql_query($query) or die(mysql_error()."<hr>$query<hr>");
                                        while($syncData=mysql_fetch_assoc($result))
                                        {
                                                $Bezahlweise=array_pop($syncData);
                                                $Versandart=array_pop($syncData);
                                        
                                                $syncCallQuery="
                                                        REPLACE INTO
                                                                artikel
                                                                (".implode(", ",array_keys($syncData)).")
                                                        VALUES
                                                                ('".implode("', '",$syncData)."')
                                                ";
                                                $resultSyncCall=mysql_query($syncCallQuery) or die(mysql_error()."<hr>$syncCallQuery<hr>");
                                                $syncCallQuery2="
                                                        UPDATE 
                                                                Versandart_to_Bezahlweise
                                                        SET
                                                                artikel = ".mysql_insert_id()."
                                                        WHERE
                                                                Versandart_to_Bezahlweise.Versandart=$Versandart
                                                        AND
                                                                Versandart_to_Bezahlweise.Bezahlweise=$Bezahlweise
                                                ";
                                                mysql_query($syncCallQuery2) or die(mysql_error()."<hr>$syncCallQuery2<hr>");
                                        }
                                break;

                        default: // Änderungen durchführen
                                        unset($_POST[action]);
                                        if ($_POST[Lieferstatus])
                                        {
                                                $_POST[Lieferstatus]=array_sum($_POST[Lieferstatus]);
                                        }
                        
                                        $names="".implode(",",array_keys($_POST))."";
                                        $values="'".implode("','",$_POST)."'";

                                        $query="replace into Versandart_to_Bezahlweise ($names) values ($values)";
                                        mysql_query($query) or die(mysql_error()."<hr>$query<hr>");
                                break;
                }
        }
?>
<html>
<head>
<title>Versandart und Bestellweise einrichten</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.td {  font-family: Arial, Helvetica, sans-serif; font-size: 14px; background-color: #DDDDDD;}
.small { font-family: Arial, Helvetica, sans-serif; font-size: 10px; background-color: #DDDDDD; }
-->
</style>

<script language="Javascript">
function killkomma(w)
{
 return w.replace(/,/,'.');
}
</script>

</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form action="<? echo $self ?>" method="post">
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr> 
      <td valign="top"> 
        <table border="0" width="100%" cellspacing="3" cellpadding="2">
          <tr align="center"> 
            <td nowrap class="td" colspan="3">Eingetragene Kombinationen:</td>
          </tr>
          <?
        $result=mysql_query(
        "
                SELECT
                        Versandart.Name as VersandartName,
                        Bezahlweise.Name as BezahlweiseName,
                        Versandart_to_Bezahlweise.Versandart as VersandartID,
                        Versandart_to_Bezahlweise.Bezahlweise as BezahlweiseID,
                        Versandart_to_Bezahlweise.Preis
                FROM
                        Versandart,
                        Bezahlweise,
                        Versandart_to_Bezahlweise
                WHERE
                        Versandart.Language='DE'
                AND
                        Versandart_to_Bezahlweise.Versandart = Versandart.ID
                AND
                        Versandart_to_Bezahlweise.Bezahlweise = Bezahlweise.ID
                ORDER BY 1
        "
        ) or die(mysql_error());
        while($zeile=mysql_fetch_assoc($result))
        {
?>
          <tr> 
            <td nowrap class="small" width="100%"><a href="<? echo $self ?>?Versandart=<? echo $zeile[VersandartID]; ?>&Bezahlweise=<? echo $zeile[BezahlweiseID]; ?>"> 
              <? echo $zeile[VersandartName]; ?>
              <? echo $zeile[BezahlweiseName]; ?>
              </a></td>
            <td nowrap class="small" align="right">
              <? echo $zeile[Preis]; ?>
            </td>
            <td nowrap class="small" width="12"><a href="<? echo $self ?>?Versandart=<? echo $zeile[VersandartID]; ?>&Bezahlweise=<? echo $zeile[BezahlweiseID]; ?>&action=delete" onClick="return confirm('Kombination\n&quot;<? echo $zeile[VersandartName]; ?> <? echo $zeile[BezahlweiseName]; ?>&quot;\nwirklich löschen');"><img src="../images/Icons/delete.gif" width="12" height="12" border="0" alt="Kombination &quot;<? echo $zeile[VersandartName]; ?> <? echo $zeile[BezahlweiseName]; ?>&quot; löschen"></a></td>
          </tr>
          <?
        }
?>
        </table>
            </td>
      <td class="td"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</td>
      <td width="75%" align="center" valign="top"> 
        <table border="0" width="100%" cellspacing="3" cellpadding="2">
          <tr align="center"> 
            <td class="td">Versandart </td>
            <td class="td">Bezahlweise </td>
            <td class="td">vorhanden</td>
            <td class="td">Artikel ID</td>
          </tr>
          <tr align="center"> 
            <td class="td"> 
              <select name="Versandart" onChange="document.location.href='<? echo $self ?>?Versandart='+this.form.Versandart.value+'&Bezahlweise='+this.form.Bezahlweise.value">
                <option></option>
                <?
        $result=mysql_query("select * from Versandart where Language='DE' order by Name") or die(mysql_error());
        while($zeile=mysql_fetch_array($result))
        {
?>
                <option value="<? echo $zeile[ID]; ?>"<? if ($Versandart == $zeile[ID]) { echo " selected"; } ?>> 
                <? echo $zeile[Name]; ?>
                </option>
                <?
        }
?>
              </select>
            </td>
            <td class="td"> 
              <select name="Bezahlweise" onChange="document.location.href='<? echo $self ?>?Versandart='+this.form.Versandart.value+'&Bezahlweise='+this.form.Bezahlweise.value">
                <option></option>
                <?
        $result=mysql_query("select * from Bezahlweise where Language='DE' order by Name") or die(mysql_error());
        while($zeile=mysql_fetch_array($result))
        {
?>
                <option value="<? echo $zeile[ID]; ?>"<? if ($Bezahlweise == $zeile[ID]) { echo " selected"; } ?>> 
                <? echo $zeile[Name]; ?>
                </option>
                <?
        }
?>
              </select>
            </td>
            <td class="td"> 
              <?
                $result=mysql_query("select * from Versandart_to_Bezahlweise where Versandart=$Versandart and Bezahlweise=$Bezahlweise and Language='DE'");
                if ($result)
                {
                        if ($DATA=mysql_fetch_assoc($result))
                        {
                                echo "JA";
                        }
                        else
                        {
                                echo "NEIN";
                        }
                }
          ?>
            </td>
            <td class="td"> 
              <? if ($DATA[artikel]) { ?>
              <input type="text" name="artikel" size="3" value="<? echo $DATA[artikel] ?>">
              <? } else { ?>-<? } ?>
            </td>
          </tr>
          <tr align="center"> 
            <td colspan="4" class="td">Preis: 
              <input type="text" name="Preis" value="<? echo $DATA[Preis] ?>" onChange="this.value=killkomma(this.value);">
            </td>
          </tr>
          <tr align="center"> 
            <td colspan="4" class="small">Diese Kombination als Option anzeigen, 
              wenn alle Artikel im Warenkorb zusammengenommen die folgenden Bedingungen 
              erf&uuml;llen:</td>
          </tr>
        </table>
        <br>
        <table border="0" cellspacing="3" cellpadding="2"  width="70%">
          <tr> 
            <td width="50%" class="td" align="center">Sprache des Shops:</td>
            <td colspan="2" class="td" align="center"> 
              <? echo $_SESSION[Language]; ?>
              <input type="hidden" name="Language" value="<? echo $_SESSION[Language]; ?>">
            </td>
          </tr>
        </table>
        <br>
        <table border="0" cellspacing="3" cellpadding="2"  width="70%">
          <tr> 
            <td width="50%" class="td">&nbsp;</td>
            <td class="small" width="25%" align="center">JA</td>
            <td class="small" align="center">Nein/Egal</td>
          </tr>
          <?
        for ($Eigenschaft_nr=1; $Eigenschaft_nr<=5; $Eigenschaft_nr++)
        {
?>
          <tr> 
            <td width="50%" class="td"> 
              <?
                $Feld="Eigenschaft_".$Eigenschaft_nr;
                if (isset($user_rechte[online_shop][artikel][$Feld]))
                {
                        if ($web_rechte[online_shop][artikel][$Feld]) 
                        {
                                echo $web_rechte[online_shop][artikel][$Feld]; 
                        }
                        else
                        {
                                echo "Eigenschaft ".$Eigenschaft_nr;
                        }
                }
?>
            </td>
            <td class="td" align="center"> 
              <input type="radio" name="<? echo $Feld ?>" value="1" <? if ($DATA[$Feld] == 1) {echo " checked";} ?>>
            </td>
            <td class="td" align="center"> 
              <input type="radio" name="<? echo $Feld ?>" value="0" <? if ($DATA[$Feld] != 1) {echo " checked";} ?>>
            </td>
          </tr>
          <?
        }
?>
        </table>
        <br>
        <table border="0" cellspacing="3" cellpadding="2"  width="70%">
          <tr> 
            <td class="small" align="center">L&auml;nder, f&uuml;r die diese Versand- 
              Bezahlvariante gilt:</td>
          </tr>
          <tr> 
            <td class="td"> 
              <table width="90%" border="0" cellspacing="0" cellpadding="0">
                <?
        $Laender=array('Deutschland','Niederlande','Österreich','Belgien','Luxemburg','Dänemark','Schweiz','Frankreich','Großbritannien','Italien','Spanien','Portugal','Schweden','Finnland','Norwegen');
        for ($bit=0; $bit<15; $bit++)
        {
?>
                <tr align="center"> 
                  <td width="75%" class="td"> 
                    <? echo $Laender[$bit] ?>
                  </td>
                  <td width="25%" class="td"> 
                    <input type="checkbox" name="Lieferstatus[]" value="<? echo 1 << $bit ?>"<? if ($DATA[Lieferstatus] & (1 << $bit)) {echo " checked";} ?>>
                  </td>
                </tr>
                <?
        }
?>
              </table>
            </td>
          </tr>
        </table>
        <br>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td align="right" class="td">&nbsp;</td>
            <td align="center" class="td" width="50%" valign="middle"> 
              <input type="submit" name="action" value="Abschicken">
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
</body>
</html>