Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?php

    /**
     * @package   Content-management
     * @author    Webagentur Niewerth <tiefland@weban.de>
     * @copyright 2011 Webagentur Niewerth
     * @license   propietary http://www.weban.de
     * @version   $Rev: 768 $
     * @filesource
     * 
     */

    /**
     * 
     * @package   Content-management
     * @author    Webagentur Niewerth <tiefland@weban.de>
     * @copyright 2011 Webagentur Niewerth
     */

    // SVN: $Id: preisstaffel.php 768 2011-10-28 06:34:37Z tiefland $

    require_once "../toolbox/common.php";
    if ( isset( $_GET["id"] ) )
    {
        $id = Weban_Utils::clean_global_input( "id", "get", "int" );
        $sql = "SELECT
                preis
            FROM
                preise_to_login pl
            WHERE
                id=" . $id . "
        ";
        $res = mysql_query( $sql );
        while ( $row = mysql_fetch_assoc( $res ) )
        {
            $row["preis"] = unserialize( $row["preis"] );
            $daten = $row["preis"];
        }
        $GLOBALS["ui"]->assign( "preis", $daten );
        $GLOBALS["ui"]->assign( "i", 1 );
        $GLOBALS["ui"]->assign( "id", $id );
        $GLOBALS["ui"]->display( "preisstaffel.tpl" );
    } elseif ( isset( $_POST["mode"] ) )
    {
        foreach ( $_POST["staffel"][1]["preis"] as $p_ind => $preis )
        {
            if ( stristr( $preis, "%" ) )
            {
                $_POST["staffel"][1]["preis"][$p_ind] = $preis * -1;
            }
        }
        $staffel = serialize( $_POST["staffel"][1] );
        $id = Weban_Utils::clean_global_input( "id", "post", "int" );
        $mode = Weban_Utils::clean_global_input( "mode" );
        $login_id = Weban_Utils::clean_global_input( "login_id", "post", "int" );
        if ( $id )
        {
            if ( $mode == "save" )
            {
                $sql = "
                    UPDATE
                        preise_to_login
                    SET
                        preis='" . $staffel . "',
                        letzte_aenderung_von='" . $_SERVER["PHP_AUTH_USER"] . "'
                    WHERE
                        id=" . $id . "
                ";
            } elseif ( $mode == "delete" )
            {
                $sql = "
                    DELETE FROM
                        preise_to_login
                    WHERE
                        id=" . $id . "
                ";
            }
        }
        else
        {
            $sql = "
                INSERT INTO
                    preise_to_login
                SET
                    preis='" . $staffel . "',
                    shop_id=" . $shop_id . ",
                    artikel_id=" . $artikel_id . ",
                    login_id=" . $login_id . ",
                    erstellt_von='" . $_SERVER["PHP_AUTH_USER"] . "',
                    erstellt_am=NOW(),
                    letzte_aenderung_von='" . $_SERVER["PHP_AUTH_USER"] . "'
            ";
        }
        echo $sql;
        $res = mysql_query( $sql );
        if ( !$res )
        {
            echo mysql_error() . "\n$sql";
        }
    }
?>