Example #1
0
/**
 * Tarkistetaan tilausrivin tiedot ja echotetaan ruudulle lisätyt tuotteet
 */
function tarkista_tilausrivi()
{
    global $tee, $ostoskori, $tilkpl, $kukarow, $toim_kutsu, $yhtiorow, $toim, $tiltuoteno, $tilsarjatunnus, $verkkokauppa, $verkkokauppa_saldotsk, $myyntierahuom, $lisatty_tun;
    pupemaster_start();
    if (($tee == 'TI' or is_numeric($ostoskori)) and isset($tilkpl)) {
        if (is_numeric($ostoskori)) {
            $kori = check_ostoskori($ostoskori, $kukarow["oletus_asiakas"]);
            $kukarow["kesken"] = $kori["tunnus"];
        }
        // haetaan avoimen tilauksen otsikko
        if ($kukarow["kesken"] != 0) {
            $query = "SELECT * from lasku where yhtio='{$kukarow['yhtio']}' and tunnus='{$kukarow['kesken']}'";
            $laskures = pupe_query($query);
        } else {
            // Luodaan uusi myyntitilausotsikko
            if ($kukarow["extranet"] == "") {
                require_once "tilauskasittely/luo_myyntitilausotsikko.inc";
                if ($toim_kutsu != "") {
                    $lmyytoim = $toim_kutsu;
                } else {
                    $lmyytoim = "RIVISYOTTO";
                }
                $tilausnumero = luo_myyntitilausotsikko($lmyytoim, 0);
                $kukarow["kesken"] = $tilausnumero;
                $kaytiin_otsikolla = "NOJOO!";
            } else {
                require_once "luo_myyntitilausotsikko.inc";
                $tilausnumero = luo_myyntitilausotsikko("EXTRANET", $kukarow["oletus_asiakas"]);
                $kukarow["kesken"] = $tilausnumero;
                $kaytiin_otsikolla = "NOJOO!";
            }
            // haetaan avoimen tilauksen otsikko
            $query = "SELECT * from lasku where yhtio='{$kukarow['yhtio']}' and tunnus='{$kukarow['kesken']}'";
            $laskures = pupe_query($query);
        }
        if ($kukarow["kesken"] != 0 and $laskures != '') {
            // tilauksen tiedot
            $laskurow = mysql_fetch_assoc($laskures);
        }
        if (is_numeric($ostoskori)) {
            echo "<font class='message'>" . t("Lisätään tuotteita ostoskoriin") . " {$ostoskori}.</font><br>";
        } else {
            echo "<font class='message'>" . t("Lisätään tuotteita tilaukselle") . " {$kukarow['kesken']}.</font><br>";
        }
        // Käydään läpi formin kaikki rivit
        foreach ($tilkpl as $yht_i => $kpl) {
            $kpl = str_replace(',', '.', $kpl);
            if ((double) $kpl > 0 or $kukarow["extranet"] == "" and (double) $kpl < 0 or $yhtiorow['reklamaation_kasittely'] == 'U' and $toim == 'EXTRANET_REKLAMAATIO' and (double) $kpl != 0) {
                if ($yhtiorow['reklamaation_kasittely'] == 'U' and $toim == 'EXTRANET_REKLAMAATIO') {
                    $kpl = abs($kpl) * -1;
                }
                // haetaan tuotteen tiedot
                $query = "SELECT * from tuote where yhtio='{$kukarow['yhtio']}' and tuoteno='{$tiltuoteno[$yht_i]}'";
                $tuoteres = pupe_query($query);
                if (mysql_num_rows($tuoteres) == 0) {
                    echo "<font class='error'>" . t("Tuotetta %s ei löydy", "", $tiltuoteno[$yht_i]) . "!</font><br>";
                } else {
                    // tuote löytyi ok, lisätään rivi
                    $trow = mysql_fetch_assoc($tuoteres);
                    $ytunnus = $laskurow["ytunnus"];
                    $kpl = (double) $kpl;
                    $kpl_echo = (double) $kpl;
                    $tuoteno = $trow["tuoteno"];
                    $yllapita_toim_stash = $toim;
                    if ($toim_kutsu != "YLLAPITO") {
                        $toimaika = $laskurow["toimaika"];
                        $kerayspvm = $laskurow["kerayspvm"];
                        $toim = "RIVISYOTTO";
                    } else {
                        $toim = "YLLAPITO";
                        $toimaika = "";
                        $kerayspvm = "";
                    }
                    $hinta = "";
                    $netto = "";
                    for ($alepostfix = 1; $alepostfix <= $yhtiorow['myynnin_alekentat']; $alepostfix++) {
                        ${'ale' . $alepostfix} = "";
                    }
                    $alv = "";
                    $var = "";
                    $varasto = $laskurow["varasto"];
                    $rivitunnus = "";
                    $korvaavakielto = "";
                    $jtkielto = $laskurow['jtkielto'];
                    $varataan_saldoa = "";
                    $myy_sarjatunnus = $tilsarjatunnus[$yht_i];
                    $paikka = "";
                    // Ennakkotilaukset, Tarjoukset, Ylläpitosopimukset ja Valmistukset eivät tee saldotsekkiä
                    if ($verkkokauppa != "" and $verkkokauppa_saldotsk === false or $laskurow["tilaustyyppi"] == "E" or $laskurow["tila"] == "T" or $laskurow["tilaustyyppi"] == "0" or $laskurow["tila"] == "V") {
                        $varataan_saldoa = "EI";
                    }
                    // jos meillä on ostoskori muuttujassa numero, niin halutaan lisätä tuotteita siihen ostoskoriin
                    if (is_numeric($ostoskori)) {
                        lisaa_ostoskoriin($ostoskori, $laskurow["liitostunnus"], $tuoteno, $kpl);
                        $kukarow["kesken"] = "";
                    } elseif (file_exists("../tilauskasittely/lisaarivi.inc")) {
                        require "../tilauskasittely/lisaarivi.inc";
                    } else {
                        require "lisaarivi.inc";
                    }
                    $toim = $yllapita_toim_stash;
                    echo "<font class='message'>" . t("Lisättiin") . " {$kpl_echo} " . t_avainsana("Y", "", " and avainsana.selite='{$trow['yksikko']}'", "", "", "selite") . " " . t("tuotetta") . " {$tiltuoteno[$yht_i]}.</font><br>";
                    if (isset($myyntierahuom) and count($myyntierahuom) > 0) {
                        $mimyhuom = "HUOM: Rivin määrä on pyöristetty";
                        if ($trow["minimi_era"] > 0) {
                            $mimyhuom .= " minimierään";
                        }
                        if ($trow['myynti_era'] > 0 and $yhtiorow['myyntiera_pyoristys'] == 'K') {
                            if ($trow["minimi_era"] > 0) {
                                $mimyhuom .= " tai";
                            }
                            $mimyhuom .= " täyteen myyntierään";
                        }
                        // Käännetään teksti
                        $mimyhuom = t($mimyhuom) . "!";
                        if ($trow['myynti_era'] > 0) {
                            $mimyhuom .= " " . t("Myyntierä on") . ": {$trow['myynti_era']}";
                        }
                        if ($trow["minimi_era"] > 0) {
                            $mimyhuom .= " " . t("Minimierä on") . ": {$trow['minimi_era']}";
                        }
                        echo "<font class='error'>" . $mimyhuom . "</font><br>";
                    }
                    //Hanskataan sarjanumerollisten tuotteiden lisävarusteet
                    if ($tilsarjatunnus[$yht_i] > 0 and $lisatty_tun > 0) {
                        require "sarjanumeron_lisavarlisays.inc";
                        lisavarlisays($tilsarjatunnus[$yht_i], $lisatty_tun);
                    }
                }
                // tuote ok else
            }
            // end kpl > 0
        }
        // end foreach
        echo "<br>";
        $trow = "";
        $ytunnus = "";
        $kpl = "";
        $tuoteno = "";
        $toimaika = "";
        $kerayspvm = "";
        $hinta = "";
        $netto = "";
        $alv = "";
        $var = "";
        $varasto = "";
        $rivitunnus = "";
        $korvaavakielto = "";
        $varataan_saldoa = "";
        $myy_sarjatunnus = "";
        $paikka = "";
        $tee = "";
        for ($alepostfix = 1; $alepostfix <= $yhtiorow['myynnin_alekentat']; $alepostfix++) {
            ${'ale' . $alepostfix} = '';
        }
    }
    pupemaster_stop();
}
Example #2
0
if (($row["tila"] == "L" or $row["tila"] == "N") and isset($row["mapvm"]) and $row["mapvm"] != '0000-00-00' and $row["mapvm"] != '') {
    $button_disabled = "disabled";
}
if (empty($oikeurow['paivitys'])) {
    $button_disabled = "disabled";
}
if (($toim == "TARJOUS" or $toim == "TARJOUSSUPER") and $tee == '' and $tilausnumero != "") {
    pupemaster_start();
    $query_tarjous = "UPDATE lasku\n                    SET alatila = tila,\n                    tila        = 'D',\n                    muutospvm   = now(),\n                    comments    = CONCAT(comments, ' {$kukarow['nimi']} ({$kukarow['kuka']}) " . t("mitätöi tilauksen ohjelmassa muokkaatilaus.php") . " 2')\n                    WHERE yhtio = '{$kukarow['yhtio']}'\n                    AND tunnus  = {$tilausnumero}";
    pupe_query($query_tarjous);
    $query = "UPDATE tilausrivi\n            SET tyyppi = 'D'\n            WHERE yhtio = '{$kukarow['yhtio']}'\n            AND tyyppi  = 'T'\n            AND tunnus  = {$tilausnumero}";
    pupe_query($query);
    //Nollataan sarjanumerolinkit
    vapauta_sarjanumerot("", $tilausnumero);
    echo "<font class='message'>" . t("Mitätöitiin tilaus") . ": {$tilausnumero}</font><br><br>";
    pupemaster_stop();
}
if (strpos($_SERVER['SCRIPT_NAME'], "muokkaatilaus.php") !== FALSE) {
    if ($toim == "VASTAANOTA_REKLAMAATIO") {
        $otsikkoteksti = t("Vastaanota");
    } else {
        $otsikkoteksti = t("Muokkaa");
    }
    echo "<font class='head'>" . $otsikkoteksti . " " . $otsikko . "<hr></font>";
    // Tehdään popup käyttäjän lepäämässä olevista tilauksista
    if ($toim == "SIIRTOLISTA" or $toim == "SIIRTOLISTASUPER" or $toim == "MYYNTITILI" or $toim == "MYYNTITILISUPER") {
        $query = "SELECT *\n              FROM lasku use index (tila_index)\n              WHERE yhtio = '{$kukarow['yhtio']}' and (laatija='{$kukarow['kuka']}' or tunnus='{$kukarow['kesken']}')  and alatila='' and tila = 'G'";
        $eresult = pupe_query($query);
    } elseif ($toim == "SIIRTOTYOMAARAYS" or $toim == "SIIRTOTYOMAARAYSSUPER") {
        $query = "SELECT *\n              FROM lasku use index (tila_index)\n              WHERE yhtio = '{$kukarow['yhtio']}' and (laatija='{$kukarow['kuka']}' or tunnus='{$kukarow['kesken']}')  and alatila='' and tila = 'S'";
        $eresult = pupe_query($query);