Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?php

    require_once "mail_func.php";
    error_reporting( E_ALL & ~ E_NOTICE );
    ini_set( "register_globals", "On" );

    define( "Range", 100 );
    define( "modul_name", "Warenwirtschaft" );
    define( "tool_name", "bestellung" );
    require_once "/web/apache/content-management/Online-Shop/connect2.php";

    $time = microtime_float();

    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/bestellungen/system/getBestellungLieferscheinStatus.php";
    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/bestellungen/system/getBestellungRechnungStatus.php";
    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/bestellungen/system/getBestellungStatus.php";
    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/bestellungen/system/getBestellungSumme.php";
    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/bestellungen/system/mysql_query_logged.php";
    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/bestellungen/system/artikelDatabase.php";
    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/bestellungen/system/bestellung_puffern.php";
    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/bestellungen/system/getVersandItems.php";
    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/best_manu/system/getShops.php";
    require_once
        "/web/apache/content-management/Warenwirtschaft/includes/bestellungen/createOrderText.php"; // Ma

    $self = basename( $PHP_SELF );
    $action = $_GET['action'];

    $Felddaten = explode( ";", $web_rechte["Warenwirtschaft"]["bestellung"]["mail_client"] );


    $pos = array_search( "websettingid", $Felddaten );
    if ( isset( $_GET["id"] ) )
    {
        if ( $pos !== false )
        {
            $adminMail = rawurldecode( $_SESSION['mailData'][$_GET["Bestellung"]][$_GET['id']]['mailfrom'] );
        }
        else
        {
            $adminMail = $Felddaten[0];
        }
    }
    else
    {
        $adminMail = $_POST["adminMail"];
    }

    $pos = array_search( "noconfirm", $Felddaten );
    $noconfirm = false;
    if ( $pos !== false )
    {
        $noconfirm = true;
    }

    $pos = array_search( "nocopy", $Felddaten );
    $nocopy = false;
    if ( $pos !== false )
    {
        $nocopy = true;
    }

    if ( $_POST['update']['list'] )
    {
        $art = $_POST["button"];
        $art = str_replace( "ä", "ae", $art );
        $art = str_replace( "ö", "oe", $art );
        $art = str_replace( "ü", "ue", $art );
        $art = str_replace( "ß", "ss", $art );
        $art = str_replace( "Ä", "Ae", $art );
        $art = str_replace( "Ö", "Oe", $art );
        $art = str_replace( "Ü", "Ue", $art );

        $body = stripslashes( $_POST['body'] ) . "\n\n";


        $extra = array( "shops_ID" => $_POST["shops_ID"], "bestellung" => $_POST["Bestellung"],
            "headers" => array( "From" => $adminMail ) );
        if ( !$nocopy )
        {
            $mail[] = send_email( $adminMail, $_POST['subject'], $body, $extra );
        }
        else
        {
            $mail[] = true;
        }
        $mail[] = send_email( $_POST['mailto'], $_POST['subject'], $body, $extra );
        /*weban_debug( "E-Mail an Kunden:" );
        weban_debug( $mail[1] );
        weban_debug( "E-Mail an Admin:" );
        weban_debug( $mail[0] );*/

        $vorlage = false;
        if ( !PEAR::isError( $mail[0] ) && !PEAR::isError( $mail[1] ) )
        {
            $_GET['message'] = "Die Mail wurde gesendet an: " . $_POST['mailto'];
            $_GET['message'] .= ( !$nocopy ) ? " & $adminMail" : "";
            $_GET['send'] = true;
            $ln = generate_LN( $_POST["Bestellung"], $art );

            $besteallart_id = ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["bestellart"] ) ) ?
                1 : null;
            $vorlage = checkHTMLVorlage( $_POST["shops_ID"], $bestellart_id );
            if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["html_emails"] ) &&
                $vorlage )
            {
                create_html_pdf( $_POST["Bestellung"], $adminMail, $_POST["mailto"],
                    $body, $art, $ln );
            }
            else
            {
                create_pdf( $_POST["Bestellung"], $adminMail, $_POST["mailto"],
                    $body, $art, $ln );
            }

        } elseif ( $mail[0]===true && PEAR::isError( $mail[1] ) )
        {
            $_GET["message"] = "Fehler beim versenden an: " . $_POST["mailto"] .
                "\n";
            $_GET["message"] .= "Die E-Mail wurde erfolgreich an $adminMail verschickt";

        } elseif ( $mail[1] ===true && PEAR::isError( $mail[0] ))
        {
            $_GET['message'] = "Die Mail wurde gesendet an: " . $_POST['mailto'];
            if ( !$nocopy )
            {
                $_GET["message"] .= "\n";
                $_GET["message"] .= "Fehler beim Versenden an: " . $adminMail;
            }
            $_GET['send'] = true;
            $ln = generate_LN( $_POST["Bestellung"], $art );

            $besteallart_id = ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["bestellart"] ) ) ?
                1 : null;
            $vorlage = checkHTMLVorlage( $_POST["shops_ID"], $bestellart_id );
            if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["html_emails"] ) &&
                $vorlage )
            {
                create_html_pdf( $_POST["Bestellung"], $adminMail, $_POST["mailto"],
                    $body, $art, $ln );
            }
            else
            {
                create_pdf( $_POST["Bestellung"], $adminMail, $_POST["mailto"],
                    $body, $art, $ln );
            }
        }
        else
        {
            $_GET['message'] = "Fehler beim versenden an: " . $_POST['mailto'] .
                " & $adminMail";
            $_GET['send'] = false;
        }
        //weban_debug( $_GET["message"] );
    }

    if ( $_GET["Bestellung"] )
    { //Dokumente ausgeben, die dieser Bestellung hinzugefügt worden sind (z. B. Rechnungen)
        $sql = "
        SELECT
            document
        FROM
            dokumente
        WHERE
            data_foreign=" . $_GET["Bestellung"] . "
        AND
            table_foreign='Bestellung'
    ";
        $res = mysql_query( $sql );
        while ( $row = mysql_fetch_assoc( $res ) )
        {
            $dateien[] = array( "name" => $row["document"], "url" =>
                "images/dokumente" );
        }

        //Dokumente ausgeben, die im Verzeichnis '/images/vorlagen' liegen

        if ( file_exists( $webs["verzeichnis"] . "/images/vorlagen/" ) )
        {
            require_once "File/Find.php";
            $files = File_Find::glob( "/.*/", $webs["verzeichnis"] .
                "/images/vorlagen/", "perl" );
            if ( is_array( $files ) )
            {
                foreach ( $files as $file )
                {
                    $dateien[] = array( "name" => $file, "url" =>
                        "images/vorlagen" );
                }
            }
        }
        require_once "Weban_Smarty.class.php";
        $GLOBALS["ui"] = new Weban_Smarty();
        $besteallart_id = ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["bestellart"] ) ) ?
            1 : null;
        $vorlage = checkHTMLVorlage( $_GET["shop"], $bestellart_id );
        $GLOBALS["ui"]->assign( "vorlage", $vorlage );
        $GLOBALS["ui"]->compile_dir = $_SERVER["DOCUMENT_ROOT"] . "/templates_c/";
        $GLOBALS["ui"]->compile_id = "Warenwirtschaft|MailClient";
        $GLOBALS["ui"]->assign( "adminMail", $adminMail );
        $GLOBALS["ui"]->assign( "dateien", $dateien );
        $GLOBALS["ui"]->assign( "nocopy", $nocopy );
        $GLOBALS["ui"]->assign( "noconfirm", $noconfirm );
        $GLOBALS["ui"]->assign( "webs", $webs );
        $GLOBALS["ui"]->assign( "web_rechte", $web_rechte );
        $GLOBALS["ui"]->assign( "user_rechte", $user_rechte );
        $GLOBALS["ui"]->display( "index.tpl" );
    }
?>