Пример #1
0
    echo "<td class=\"revizia\">";
    if (empty($product["revizia"]["id_zakaznik"])) {
        $odberatel = $product["revizia"]["meno"];
        if (empty($product["revizia"]["doruc_mesto"])) {
            $odberatel .= !empty($product["revizia"]["mesto"]) ? ", " . $product["revizia"]["mesto"] : "";
        } else {
            $odberatel .= ", " . $product["revizia"]["doruc_mesto"];
        }
    } else {
        $query = "SELECT meno, mesto, doruc_mesto from uzivatel \r\n                                WHERE id = {$product["revizia"]["id_zakaznik"]}\r\n                                ";
        $uzivatel = sql_query($query)[0];
        $odberatel = $uzivatel["meno"];
        if (empty($uzivatel["doruc_mesto"])) {
            $odberatel .= !empty($uzivatel["mesto"]) ? ", " . $uzivatel["mesto"] : "";
        } else {
            $odberatel .= ", " . $uzivatel["doruc_mesto"];
        }
    }
    echo "<span class=\"bold\">{$odberatel}</span>\r\n                    obj. č. {$product["revizia"]["c_obj"]}/" . dateYear($product["revizia"]["datum"]) . " z " . dateDate($product["revizia"]["datum"]) . "\r\n                ";
    echo "</td>";
    echo "</tr>";
    //var_dump($objednavka);
}
echo "</tbody></table>";
//var_dump($_SESSION);
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = $endtime - $starttime;
//echo "<div class=\"Etimer\">".$totaltime." seconds</div>";
Пример #2
0
function print_revision_cp_vyrobny_plan($cp, $revision)
{
    $data = sql_query("SELECT id_vyrobny_plan, DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum\r\n                                    FROM revizia_vyrobny_plan \r\n                                    WHERE id={$revision} \r\n                                    LIMIT 1")[0];
    $data_row = sql_query("SELECT vyr.*, obr.*, rev.meno, rev.mesto, rev.doruc_mesto, rev.email, \r\n                                    rev.komentar, rev.komentar_private, rev.vlastne_cislo_obj, obj.id_zakaznik, obj.c_obj, obj.datum \r\n                            FROM vyrobny_plan_row vyr\r\n                            INNER JOIN objednavka_row obr\r\n                            ON vyr.id_objednavka_row = obr.id\r\n                            INNER JOIN revizia rev\r\n                            ON obr.id_revizia = rev.id\r\n                            INNER JOIN objednavka obj\r\n                            ON rev.id_obj = obj.id\r\n                            WHERE id_revizia_vyrobny_plan = " . $revision . "\r\n                                AND vyr.vymaz = 0;\r\n                            ");
    foreach ($data_row as $key => $row) {
        $data_row_option = sql_query("SELECT id_product_atribute, id_product_atribute_option \r\n                                    FROM objednavka_row_atribute \r\n                                    WHERE id_revizia=\"{$row['id_revizia']}\" AND id_objednavka_row=\"{$row[id]}\"");
        //var_dump($data_row_option);
        foreach ($data_row_option as $option) {
            $data_row[$key]["product_atribute_options_all"][$option["id_product_atribute"]] = $option["id_product_atribute_option"];
        }
        if ($row["id_zakaznik"] == 0) {
            $data_zak[$row["id_zakaznik"]][$row["id_revizia"]][] = $data_row[$key];
        } else {
            $data_zak[$row["id_zakaznik"]][] = $data_row[$key];
        }
    }
    //var_dump($data_zak);
    $data_obj = sql_query("SELECT id, meno, popis, DATE_FORMAT(datum_vyvozu, '%d. %m. %Y') AS datum, \r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM vyrobny_plan \r\n                                    WHERE id=" . $data["id_vyrobny_plan"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    $message = "";
    $message .= "<h1>Cenová ponuka <br> Výrobný Plán č. " . $data_obj["id"] . "/" . $data_obj["rok"] . " - " . $data_obj["meno"] . " </h1>";
    $message .= "<h5>Dátum vývozu: " . $data_obj["datum"] . "</h5>";
    $message .= !empty($data_obj["popis"]) ? "<h5>Popis: " . $data_obj["popis"] . "</h5>" : "";
    /*
    $data_row = sql_query("SELECT * 
                        FROM vyrobny_plan_row vyr
                        INNER JOIN objednavka_row obr
                        ON vyr.id_objednavka_row = obr.id
                        WHERE id_revizia_vyrobny_plan = ".$revision."
                        ");       
    */
    $message .= "<div class=\"print_hlavicka3\">\r\n            <table>\r\n               <tr>\r\n                              \r\n               <th style=\"width: 460px;\">produkt</th>                             \r\n               <th style=\"width: 90px;\">j.cena</th>               \r\n               <th style=\"width: 100px;\">zľava % / j.cena po</th>\r\n               <th style=\"width: 80px;\">Spolu</th>\r\n               <th style=\"width: 80px;\"></th>\r\n               <th style=\"width: 100px;\">komentár</th>\r\n               </tr>";
    foreach ($data_zak as $key => $zakaznik) {
        //var_dump($key);
        $data_z = array();
        if ($key > 0) {
            if ($sum_zakaznik > 0) {
                $message .= "<tr>";
                $message .= "<td colspan=3 class=\"right\">Spolu pre zákazníka / objednávku</td>";
                $message .= "<td colspan=3 class=\"bold\">{$sum_zakaznik} €</td>";
                $message .= "</tr>";
            }
            $sum_zakaznik = 0;
            $message .= "<tr class=\"silver\">";
            $query = "SELECT meno, mesto, doruc_mesto, email FROM uzivatel WHERE id=" . $key . " LIMIT 1";
            $zakaz = sql_query($query)[0];
            //dd($zakaz);
            $data_z["meno"] = $zakaz["meno"];
            $data_z["doruc_mesto"] = $zakaz["doruc_mesto"];
            $data_z["mesto"] = $zakaz["mesto"];
            $data_z["email"] = $zakaz["email"];
            $odberatel = $data_z["meno"];
            if (empty($data_z["doruc_mesto"])) {
                $odberatel .= empty($data_z["mesto"]) ? "" : ", " . $data_z["mesto"];
            } else {
                $odberatel .= ", " . $data_z["doruc_mesto"];
            }
            $odberatel = "<span class=\"bold\">" . $odberatel . "</span>" . (!empty($data_z["email"]) ? " (" . $data_z["email"] . ")" : "") . "";
            $message .= "<td  colspan=6>{$odberatel}</td>";
            $message .= "</tr>";
        }
        //var_dump($zakaznik);
        foreach ($zakaznik as $keyer => $riadok) {
            //var_dump($riadok);
            //var_dump($sum_zakaznik);
            if ($key > 0) {
                $message .= "<tr>";
                $product_type = sql_query("SELECT meno FROM product_type WHERE id=" . sec_sql(sec_input($riadok["id_product_type"])) . " LIMIT 1");
                $product_type = $product_type[0];
                $product = sql_query("SELECT id, meno FROM product WHERE id=" . sec_sql(sec_input($riadok["id_product"])) . " LIMIT 1")[0];
                $options_str = array();
                //var_dump($data);
                if (!isset($riadok["product_atribute_options_all"]) or empty($riadok["product_atribute_options_all"])) {
                    $riadok["product_atribute_options_all"] = array();
                }
                foreach ($riadok["product_atribute_options_all"] as $option) {
                    //var_dump($option);
                    $options_str[] = sql_query("SELECT meno FROM product_atribute_option WHERE id=" . sec_sql(sec_input($option)) . " LIMIT 1")[0]["meno"];
                }
                $vlastne_cislo_obj = "";
                if (!empty($riadok["vlastne_cislo_obj"])) {
                    $vlastne_cislo_obj = " (" . $riadok["vlastne_cislo_obj"] . ") ";
                }
                $options_str = empty($options_str) ? "" : " (" . join(", ", $options_str) . ")";
                //var_dump($options_str);
                $message .= "<td class=\"form_nazov_siroky\"><span class=\"bold\">" . sec_input($riadok["ks"]) . "x</span> " . $product_type["meno"] . " <span class=\"bold\">" . $product["meno"] . "</span>\r\n                                            " . $options_str . "\r\n                                            <span class=\"smaller\"><br>obj. č. {$riadok["c_obj"]}/" . dateYear($riadok["datum"]) . " {$vlastne_cislo_obj} z " . dateDate($riadok["datum"]) . "</span>\r\n                                            " . (empty($riadok["atyp_text"]) ? "" : "<br>Atyp: " . sec_input($riadok["atyp_text"])) . "\r\n                                            " . (empty($riadok["komentar"]) ? "" : "<br>- " . sec_input($riadok["komentar"])) . "\r\n                                            " . (empty($riadok["komentar_private"]) ? "" : "<br>- " . sec_input($riadok["komentar_private"])) . "</td>";
                $ks_sum = $ks_sum + $riadok["ks"];
                $query = "SELECT * from cp_vyrobny_plan_row WHERE id_cp_vyrobny_plan=" . sec_input(sec_sql($_GET["cp"])) . " AND id_objednavka_row=" . $riadok[id] . "";
                $cp_row = sql_query($query)[0];
                //var_dump($cp_row);
                $cena = $cp_row[cena];
                $zlava = $cp_row[zlava];
                $black = $cp_row[black];
                $ppd = $cp_row[ppd];
                $komis = $cp_row[komis];
                $koment = $cp_row[koment];
                $id_cp_product = $cp_row[id_cp_product];
                if (!isset($riadok["product_atribute_options_all"]) or empty($riadok["product_atribute_options_all"])) {
                    $riadok["product_atribute_options_all"] = array();
                }
                $option_c_hladina = 1;
                $options_str = array();
                foreach ($riadok["product_atribute_options_all"] as $option) {
                    //var_dump($option);
                    $options = sql_query("SELECT id, meno, id_c_hladina FROM product_atribute_option WHERE id=" . sec_sql(sec_input($option)) . " LIMIT 1");
                    $options_str[] = $options[0]["meno"];
                    if ($options[0]["id_c_hladina"] > $option_c_hladina) {
                        $option_c_hladina = $options[0]["id_c_hladina"];
                    }
                    //$options["price"] = sql_query("SELECT id, cena FROM product_atribute_option WHERE id=".sec_sql(sec_input($option))." LIMIT 1");
                }
                $product_prices = sql_query("SELECT id, cena FROM cp_product WHERE id=" . $id_cp_product . " AND id_product=" . $product["id"] . " ORDER BY id DESC LIMIT 1")[0];
                $regular_price = $product_prices[cena] . " €";
                if (empty($cena)) {
                    $product_price = $product_prices[cena];
                } else {
                    $product_price = $cena;
                }
                $product_ks_sum = $product_ks_sum + sec_input($riadok["ks"]);
                $product_price_sum = $product_price * sec_input($riadok["ks"]);
                // spocitanie ceny spolu za vsetky produkty
                $products_prices_sums = $products_prices_sums + $product_price_sum;
                $zlava_J = $product_price * $zlava / 100;
                $zlava_E = $zlava_J * sec_input($riadok["ks"]);
                $po_zlave_J = $product_price - $zlava_J;
                $po_zlave = $product_price_sum - $zlava_E;
                $po_zlave_sum = $po_zlave_sum + $po_zlave;
                $sum_zakaznik = $sum_zakaznik + $po_zlave;
                $product_price = $product_price . " €";
                $message .= "<td class=\"form_nazov ali-center product-price bold\">" . $product_price . "</td>";
                $message .= "<td class=\"form_nazov ali-center\">" . ($zlava > 0 ? "<span class=\"zlava-E bold\">" . $zlava . "%</span> <span class=\"smaller\">(" . $po_zlave_J . "€)</span>" : "") . "</span></td>";
                $po_zlave = $po_zlave . " €";
                $extra = array();
                if ($ppd == 1) {
                    $extra[] = "PPD";
                }
                if ($black == 1) {
                    $extra[] = "DL";
                }
                if ($komis == 1) {
                    $extra[] = "KMS";
                }
                $message .= "<td class=\"form_nazov ali-center po-zlave-sum\">" . $po_zlave . "</td>";
                $message .= "<td class=\"\">" . join(", ", $extra) . "</td>";
                $message .= "<td><span class=\"smaller\">{$koment}</span></td>";
                $message .= "</tr>";
            } else {
                if ($sum_zakaznik > 0) {
                    $message .= "<tr>";
                    $message .= "<td colspan=3 class=\"right\">Spolu pre zákazníka / objednávku</td>";
                    $message .= "<td colspan=3 class=\"bold\">{$sum_zakaznik} €</td>";
                    $message .= "</tr>";
                }
                $sum_zakaznik = 0;
                $message .= "<tr class=\"silver\">";
                $data_z["meno"] = $riadok[0]["meno"];
                $data_z["doruc_mesto"] = $riadok[0]["doruc_mesto"];
                $data_z["mesto"] = $riadok[0]["mesto"];
                $data_z["email"] = $riadok[0]["email"];
                $odberatel = $data_z["meno"];
                if (empty($data_z["doruc_mesto"])) {
                    $odberatel .= empty($data_z["mesto"]) ? "" : ", " . $data_z["mesto"];
                } else {
                    $odberatel .= ", " . $data_z["doruc_mesto"];
                }
                $odberatel = "<span class=\"bold\">" . $odberatel . "</span>" . (!empty($data_z["email"]) ? " (" . $data_z["email"] . ")" : "") . "";
                $message .= "<td colspan=6>{$odberatel}</td>";
                $message .= "</tr>";
                foreach ($riadok as $riadok_without) {
                    $message .= "<tr>";
                    $product_type = sql_query("SELECT meno FROM product_type WHERE id=" . sec_sql(sec_input($riadok_without["id_product_type"])) . " LIMIT 1");
                    $product_type = $product_type[0];
                    $product = sql_query("SELECT id, meno FROM product WHERE id=" . sec_sql(sec_input($riadok_without["id_product"])) . " LIMIT 1")[0];
                    $options_str = array();
                    //var_dump($data);
                    if (!isset($riadok_without["product_atribute_options_all"]) or empty($riadok_without["product_atribute_options_all"])) {
                        $riadok_without["product_atribute_options_all"] = array();
                    }
                    foreach ($riadok_without["product_atribute_options_all"] as $option) {
                        //var_dump($option);
                        $options_str[] = sql_query("SELECT meno FROM product_atribute_option WHERE id=" . sec_sql(sec_input($option)) . " LIMIT 1")[0]["meno"];
                    }
                    $vlastne_cislo_obj = "";
                    if (!empty($riadok_without["vlastne_cislo_obj"])) {
                        $vlastne_cislo_obj = " (" . $riadok_without["vlastne_cislo_obj"] . ") ";
                    }
                    $options_str = empty($options_str) ? "" : " (" . join(", ", $options_str) . ")";
                    //var_dump($options_str);
                    $message .= "<td class=\"form_nazov_siroky\"><span class=\"bold\">" . sec_input($riadok_without["ks"]) . "x</span> " . $product_type["meno"] . " <span class=\"bold\">" . $product["meno"] . "</span>\r\n                                                " . $options_str . "\r\n                                                <span class=\"smaller\"><br>obj. č. {$riadok_without["c_obj"]}/" . dateYear($riadok_without["datum"]) . " {$vlastne_cislo_obj} z " . dateDate($riadok_without["datum"]) . "</span>\r\n                                                " . (empty($riadok_without["atyp_text"]) ? "" : "<br>Atyp: " . sec_input($riadok_without["atyp_text"])) . "\r\n                                                " . (empty($riadok_without["komentar"]) ? "" : "<br>- " . sec_input($riadok_without["komentar"])) . "\r\n                                                " . (empty($riadok_without["komentar_private"]) ? "" : "<br>- " . sec_input($riadok_without["komentar_private"])) . "</td>";
                    $ks_sum = $ks_sum + $riadok_without["ks"];
                    $query = "SELECT * from cp_vyrobny_plan_row WHERE id_cp_vyrobny_plan=" . sec_input(sec_sql($_GET["cp"])) . " AND id_objednavka_row=" . $riadok_without[id] . "";
                    //echo $query;
                    $cp_row = sql_query($query)[0];
                    //var_dump($cp_row);
                    $cena = $cp_row[cena];
                    $zlava = $cp_row[zlava];
                    $black = $cp_row[black];
                    $ppd = $cp_row[ppd];
                    $komis = $cp_row[komis];
                    $koment = $cp_row[koment];
                    $id_cp_product = $cp_row[id_cp_product];
                    $option_c_hladina = 1;
                    $options_str = array();
                    foreach ($riadok_without["product_atribute_options_all"] as $option) {
                        //var_dump($option);
                        $options = sql_query("SELECT id, meno, id_c_hladina FROM product_atribute_option WHERE id=" . sec_sql(sec_input($option)) . " LIMIT 1");
                        $options_str[] = $options[0]["meno"];
                        if ($options[0]["id_c_hladina"] > $option_c_hladina) {
                            $option_c_hladina = $options[0]["id_c_hladina"];
                        }
                        //$options["price"] = sql_query("SELECT id, cena FROM product_atribute_option WHERE id=".sec_sql(sec_input($option))." LIMIT 1");
                    }
                    //echo "SELECT id, cena FROM cp_product WHERE id=".$id_cp_product." AND id_product=".$product["id"]." ORDER BY id DESC LIMIT 1<br>";
                    $product_prices = sql_query("SELECT id, cena FROM cp_product WHERE id=" . $id_cp_product . " AND id_product=" . $product["id"] . " ORDER BY id DESC LIMIT 1")[0];
                    $regular_price = $product_prices[cena] . " €";
                    if (empty($cena)) {
                        $product_price = $product_prices[cena];
                    } else {
                        $product_price = $cena;
                    }
                    $product_ks_sum = $product_ks_sum + sec_input($riadok_without["ks"]);
                    $product_price_sum = $product_price * sec_input($riadok_without["ks"]);
                    // spocitanie ceny spolu za vsetky produkty
                    $products_prices_sums = $products_prices_sums + $product_price_sum;
                    $zlava_J = $product_price * $zlava / 100;
                    $zlava_E = $zlava_J * sec_input($riadok["ks"]);
                    $po_zlave_J = $product_price - $zlava_J;
                    $po_zlave = $product_price_sum - $zlava_E;
                    $po_zlave_sum = $po_zlave_sum + $po_zlave;
                    $sum_zakaznik = $sum_zakaznik + $po_zlave;
                    $product_price = $product_price . " €";
                    $message .= "<td class=\"form_nazov ali-center product-price bold\">" . $product_price . "</td>";
                    $message .= "<td class=\"form_nazov ali-center\">" . ($zlava > 0 ? "<span class=\"zlava-E bold\">" . $zlava . "%</span> <span class=\"smaller\">(" . $po_zlave_J . "€)</span>" : "") . "</span></td>";
                    $po_zlave = $po_zlave . " €";
                    $extra = array();
                    if ($ppd == 1) {
                        $extra[] = "PPD";
                    }
                    if ($black == 1) {
                        $extra[] = "DL";
                    }
                    if ($komis == 1) {
                        $extra[] = "KMS";
                    }
                    $message .= "<td class=\"form_nazov ali-center po-zlave-sum\">" . $po_zlave . "</td>";
                    $message .= "<td class=\"\">" . join(", ", $extra) . "</td>";
                    $message .= "<td><span class=\"smaller\">{$koment}</span></td>";
                    $message .= "</tr>";
                }
            }
        }
    }
    if ($sum_zakaznik > 0) {
        $message .= "<tr>";
        $message .= "<td colspan=3 class=\"right\">Spolu pre zákazníka / objednávku</td>";
        $message .= "<td colspan=3 class=\"bold\">{$sum_zakaznik} €</td>";
        $message .= "</tr>";
    }
    $message .= "<tr class=\"cp_spolu bold\">\r\n                            \r\n                            <td>Spolu: " . $product_ks_sum . " ks</td>                            \r\n                            <td></td>                            \r\n                            <td></td>\r\n                            <td class=\"ali-center po-zlave-sum-all\">" . $po_zlave_sum . " €</td>\r\n                            <td></td>\r\n                            <td></td>\r\n                    <tr>";
    $message .= "</table></div>";
    /// koniec riadkov cenovej ponuky
    $message .= "</table>";
    $message .= "dokument vytvorený: " . date("j. n. Y - H:i") . "<br><br>";
    return $message;
}
Пример #3
0
     }
     $opt = empty($opt) ? "" : " (" . join(", ", $opt) . ")";
     $cls = "";
     $vp_detail = "";
     if ($row["vyrobny_plan"] > 0) {
         $vp = sql_query("SELECT vp.id, vp.meno, vp.datum_vyvozu, vp.status, vpst.meno status_meno \r\n                                        FROM vyrobny_plan vp\r\n                                        INNER JOIN vyrobny_plan_status vpst\r\n                                        ON vp.status = vpst.id\r\n                                        WHERE vp.id=" . $row["vyrobny_plan"] . " LIMIT 1")[0];
         if ($vp["status"] == 1) {
             $cls = "class=\"with_vp_vyroba\"";
         } elseif ($vp["status"] == 5) {
             $cls = "class=\"with_vp_complet\"";
         } elseif ($vp["status"] == 6) {
             $cls = "class=\"with_vp_expedovane\"";
         } else {
             $cls = "class=\"with_vp\"";
         }
         $vp_detail = "<br>(Výrobný plán " . $vp["status_meno"] . ": " . $vp["meno"] . " č. " . $vp["id"] . " / vývoz: " . dateDate($vp["datum_vyvozu"]) . " )";
     }
     $material_sub[] = "<li {$cls}>" . mb_strimwidth($row[ks] . " x " . $row[product_type] . " " . $row[product] . "" . $opt, 0, 70, "...", "utf-8") . " {$vp_detail}</li>";
     //echo $material_sub;
 }
 echo join("\n", $material_sub);
 echo "</ul>";
 //echo mb_strimwidth($material_sub, 0, 100, "...", "utf-8");
 //if (strlen($material_sub)>45) echo "...";
 $query_vyroba_sql = "SELECT status FROM revizia_vyroba WHERE id_obj=" . $obj[id] . " AND vymaz=0 ORDER BY id DESC LIMIT 1";
 //echo $query_vyroba;
 $vyroba2 = sql_query($query_vyroba_sql);
 $vyroba2 = $vyroba2[0][status];
 //var_dump($vyroba2);
 echo "</td> \r\n           <td>\r\n            " . ($obj["delivery"] == 1 ? "<img src=\"assets/images/48.png\" title=\"Objednávka do 48 hod.\">" : "<img src=\"assets/images/48_no.png\" title=\"štandardná objednávka\">") . "\r\n            " . ($obj["id_zakaznik"] > 0 ? "<img src=\"assets/images/user.png\" title=\"Objednávka priradená zákazníkovi\">" : "<img src=\"assets/images/user_no.png\" title=\"Objednávka bez zákazníka\">") . "    \r\n            ";
 echo " \r\n            </td>  \r\n\r\n        </tr>\r\n        ";
Пример #4
0
function display($id, $revision = 0, $vyber = "vyrobny_plan")
{
    if (empty($revision)) {
        $query = "SELECT id \r\n                    FROM revizia_vyrobny_plan                \r\n                    WHERE id_vyrobny_plan = {$id}\r\n                    ORDER BY id DESC limit 1\r\n                    ";
        $revision = sql_query($query)[0]["id"];
    }
    $upravil = $_SESSION[username];
    //var_dump($revision);
    $query = "SELECT r.id, r.ks, r.atyp_text, r.id_revizia, pt.meno product_type, p.meno product, vpr.vymaz\r\n                FROM objednavka_row r\r\n                INNER JOIN product p\r\n                ON r.id_product = p.id\r\n                INNER JOIN product_type pt\r\n                ON r.id_product_type = pt.id\r\n                INNER JOIN vyrobny_plan_row vpr\r\n                ON r.id = vpr.id_objednavka_row\r\n                WHERE vpr.id_vyrobny_plan = {$id} AND\r\n                      vpr.id_revizia_vyrobny_plan = {$revision} \r\n                ORDER BY r.id DESC";
    //print_r($query);
    $products = sql_query($query);
    //var_dump($products);
    foreach ($products as $key => $product) {
        $query = "SELECT * from revizia r\r\n                    INNER JOIN objednavka o\r\n                    ON r.id_obj = o.id\r\n                WHERE r.id = {$product["id_revizia"]}\r\n                limit 1";
        $products[$key]["revizia"] = sql_query($query)[0];
        $products[$key]["options"] = sql_query("\r\n                                        SELECT o.meno\r\n                                        FROM objednavka_row_atribute as a \r\n                                        INNER JOIN product_atribute_option as o\r\n                                        ON a.id_product_atribute_option = o.id                            \r\n                                        WHERE a.id_revizia = {$product["id_revizia"]}\r\n                                            AND a.id_objednavka_row = {$product["id"]}\r\n                                        ORDER BY a.id_product_atribute\r\n                                        ");
    }
    if ($_POST[submit]) {
        $meno = sec_sql(sec_input($_POST["meno"]));
        $popis = sec_sql(sec_input($_POST["popis"]));
        $delivery = sec_sql(sec_input($_POST["delivery"]));
        $datum_vyvozu = sec_sql(sec_input($_POST["datum_vyvozu"]));
        if (strlen($meno) > 30 or strlen($meno) < 2) {
            $error_msg[] = "Meno môže mať od 4 do 30 znakov";
        }
        if (strlen($datum_vyvozu) > 30 or strlen($datum_vyvozu) < 10) {
            $error_msg[] = "Dátum vývozu je povinný údaj a môže mať od 10 do 30 znakov";
        }
        if (empty($error_msg)) {
            $query = "UPDATE vyrobny_plan SET\r\n                            meno = \"{$meno}\", popis = \"{$popis}\", delivery = \"{$delivery}\", \r\n                            datum_vyvozu = \"{$datum_vyvozu}\", vytvoril = \"{$upravil}\"\r\n                           WHERE id={$id}\r\n                          ";
            sql_insert($query);
        } else {
            echo "<div id=error_message>" . implode("<br>", $error_msg) . "</div>";
        }
    }
    $query = "SELECT * FROM vyrobny_plan \r\n                      WHERE id = {$id}\r\n                      ";
    $vyrobny_plan = sql_query($query)[0];
    $meno = $vyrobny_plan["meno"];
    $popis = $vyrobny_plan["popis"];
    $datum = $vyrobny_plan["datum"];
    $delivery = $vyrobny_plan["delivery"];
    $datum_vyvozu = $vyrobny_plan["datum_vyvozu"];
    $status = $vyrobny_plan["status"];
    $komplet = $vyrobny_plan["komplet"];
    //var_dump($products);
    echo "<h1>Výrobný plán č. {$id}-{$revision}/" . dateYear($datum) . " - {$meno}</h1>";
    echo "<h3>dátum vývozu: " . dateDate($datum_vyvozu) . "</h3>";
    echo "<h3>popis: " . $popis . "</h3>";
    echo "<table class=\"vyr_plan_detail\">";
    echo "<tbody>";
    $poradie = 0;
    foreach ($products as $product) {
        $poradie = $poradie + 1;
        $removed = "";
        if ($product["vymaz"] > 0) {
            $removed = "class=\"removed\"";
        }
        echo "<tr {$removed}>";
        $opt = array();
        foreach ($product["options"] as $option) {
            //var_dump($option[name]);
            $opt[] = $option[meno];
        }
        $opt = empty($opt) ? "" : " (" . join(", ", $opt) . ")";
        echo "<td class=\"product\"><span class=\"bold\">{$product["ks"]}x {$product["product_type"]} {$product["product"]}{$opt}</span>\r\n                            " . (!empty($product["atyp_text"]) ? "<br>- " . $product["atyp_text"] : "") . "</td>";
        echo "<td class=\"revizia\">";
        if (empty($product["revizia"]["id_zakaznik"])) {
            $odberatel = $product["revizia"]["meno"];
            if (empty($product["revizia"]["doruc_mesto"])) {
                $odberatel .= !empty($product["revizia"]["mesto"]) ? ", " . $product["revizia"]["mesto"] : "";
            } else {
                $odberatel .= ", " . $product["revizia"]["doruc_mesto"];
            }
        } else {
            $query = "SELECT meno, mesto, doruc_mesto from uzivatel \r\n                                WHERE id = {$product["revizia"]["id_zakaznik"]}\r\n                                ";
            $uzivatel = sql_query($query)[0];
            $odberatel = $uzivatel["meno"];
            if (empty($uzivatel["doruc_mesto"])) {
                $odberatel .= !empty($uzivatel["mesto"]) ? ", " . $uzivatel["mesto"] : "";
            } else {
                $odberatel .= ", " . $uzivatel["doruc_mesto"];
            }
        }
        echo "<span class=\"bold\">{$odberatel}</span>\r\n                    obj. č. {$product["revizia"]["c_obj"]}/" . dateYear($product["revizia"]["datum"]) . " z " . dateDate($product["revizia"]["datum"]) . "\r\n                ";
        echo "</td>";
        echo "</tr>";
        //var_dump($objednavka);
    }
    echo "</tbody></table>";
    echo "<div class=\"edit_buttons\">";
    echo "<a href=\"?vyber={$vyber}&action=edit&id={$id}&revision={$revision}\" class=\"button\">upraviť</a>";
    echo "<a href=\"?vyber=print&revision={$revision}&action=vyrobny_plan&cp=" . $id . "\" target=\"_blank\" class=\"button\">vytlačiť priebežne</a>";
    echo "<a href=\"?vyber=print&revision={$revision}&action=vp_stitky&cp=" . $id . "\" target=\"_blank\" class=\"button\">štítky</a>";
    echo "<a href=\"?vyber=print&revision={$revision}&action=vyrobny_plan&cp=" . $id . "&sub=close\" target=\"_blank\" class=\"button\">vytlačiť pre VÝROBU</a>";
    echo "</div>";
    echo "<div class=\"vyrobny_plan_bottom_row\">";
    echo "<div class=\"all_revisions\">";
    $query = "SELECT id, datum, vytvoril\r\n                FROM revizia_vyrobny_plan\r\n                WHERE id_vyrobny_plan = {$id}\r\n                ORDER BY datum DESC";
    $all_revisions = sql_query($query);
    $poradie = 0;
    foreach ($all_revisions as $rev) {
        $selected = "";
        if (empty($revision)) {
            if ($poradie == 0) {
                $selected = "selected";
            }
        } else {
            if ($rev["id"] == $revision) {
                $selected = "selected";
            }
        }
        echo "<div class=\"all_revisions_row {$selected}\">";
        echo "<a href=\"?vyber={$vyber}&action=display&id={$id}&revision={$rev["id"]}\" class=\"\">revízia č. {$rev["id"]} z dňa " . dateFull($rev["datum"]) . "</a>";
        echo "</div>";
        $poradie = $poradie + 1;
    }
    if ($status > 1) {
        echo "<div id=\"add_csv_button\" class=\"add_csv_button_vyr_plan\">";
        $cp_exists = count(sql_query("SELECT id FROM cp_vyrobny_plan where id_vyrobny_plan=\"{$id}\" LIMIT 1"));
        if ($cp_exists > 0) {
            echo "<a href=\"?vyber=cp_vyrobny_plan&order={$id}&revision={$revision}&action=display_all\">Zobraz Cenové ponuky</a><br>";
        }
        echo "<a href=\"?vyber=cp_vyrobny_plan&order={$id}&revision={$revision}&action=create\">Vytvor Cenovú ponuku</a>";
        echo "</div>";
        echo "</div>";
    }
    echo "<div class=\"vyrobny_plan_edit\">";
    echo "<form method=\"POST\">";
    echo textfield("meno", $meno, "Meno plánu *", 40, 20);
    echo textfield("datum_vyvozu", $datum_vyvozu, "Dátum vývozu *", 40, 20);
    $zobraz_vo = array(0 => "štandard", 1 => "48 hodín");
    echo select("delivery", "typ dopravy", "", $delivery, "", "", "", "NO", $zobraz_vo);
    echo textarea("popis", $popis, "Popis", 25, 3, "popis", "");
    echo submit("submit", "Odoslať");
    echo "</form>";
    echo "<div>" . ($komplet == 0 ? "<a href=\"?vyber=vyrobny_plan&id={$id}&action=close\" class=\"button\">VP Vyrobený</a>" : "<a href=\"?vyber=vyrobny_plan&id={$id}&action=open\" class=\"button\">Otvoriť VP</a>") . " </div>";
    echo "<form method=\"POST\" class=\"status_form\">";
    echo select("status", "Stav VP:", "SELECT id, meno FROM vyrobny_plan_status WHERE vymaz=0 ORDER BY id", $status, "", "", "", "NO");
    echo submit("save_status", "Uložiť stav VP");
    echo "</form>";
    echo "</div>";
    echo "</div>";
    echo "</div>";
}
Пример #5
0
function formular_cp($order, $revision = 0, $fieldsets_c = 1, $form_data = "", $page = "")
{
    if (isset($_GET["cp"])) {
        $cp = sec_input($_GET["cp"]);
    }
    if (!empty($form_data)) {
        foreach ($form_data as $key => $value) {
            ${$key} = $value;
        }
    }
    $data = sql_query("SELECT id, id_vyrobny_plan, DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum\r\n                                    FROM revizia_vyrobny_plan r                                     \r\n                                    WHERE r.id={$revision} \r\n                                    LIMIT 1");
    $data = $data[0];
    //var_dump($data);
    $data_obj = sql_query("SELECT id, meno, popis, DATE_FORMAT(datum_vyvozu, '%d. %m. %Y') AS datum, datum AS rok\r\n                                    FROM vyrobny_plan \r\n                                    WHERE id=" . $data["id_vyrobny_plan"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    //var_dump($data);
    $message = "";
    $message .= "<h1>Cenová ponuka <br> Výrobný Plán č. " . $data_obj["id"] . "/" . dateYear($data_obj["rok"]) . " - " . $data_obj["meno"] . " </h1>";
    $message .= "<h5>Dátum vývozu: " . $data_obj["datum"] . "</h5>";
    $message .= !empty($data_obj["popis"]) ? "<h5>Popis: " . $data_obj["popis"] . "</h5>" : "";
    //var_dump($dekor);
    echo "<div class=\"print\">";
    echo $message;
    echo "</div>";
    echo "<div id=\"content\" class=\"print_hlavicka4\">";
    if (empty($page) or $page == 1) {
        //dd($_POST);
        if ($_POST["submit_page1"]) {
            //dd($_POST);
            $fieldsets_c = count($_POST["id"]);
            for ($i = 0; $i < $fieldsets_c; $i++) {
                $id_objednavka_row[] = sec_input(sec_sql($_POST["id"][$i]));
                $zlava[] = str_replace(',', '.', sec_input(sec_sql($_POST["zlava"][$i])));
                $black[] = isset($_POST["black"][$i]) && $_POST["black"][$i] == 1 ? "1" : "0";
                $ppd[] = isset($_POST["ppd"][$i]) && $_POST["ppd"][$i] == 1 ? "1" : "0";
                $komis[] = isset($_POST["komis"][$i]) && $_POST["komis"][$i] == 1 ? "1" : "0";
                $product_price[] = str_replace(',', '.', sec_input(sec_sql($_POST["product_price"][$i])));
                $id_cp_product[] = sec_input(sec_sql($_POST["id_cp_product"][$i]));
                $ks[] = sec_input(sec_sql($_POST["ks"][$i]));
                $koment[] = sec_input(sec_sql($_POST["koment"][$i]));
            }
            $form_data[id_objednavka_row] = $id_objednavka_row;
            $form_data[id_cp_product] = $id_cp_product;
            $form_data[ks] = $ks;
            $form_data[zlava] = $zlava;
            $form_data[black] = $black;
            $form_data[ppd] = $ppd;
            $form_data[komis] = $komis;
            $form_data[product_price] = $product_price;
            $form_data[koment] = $koment;
            //var_dump($order);
            //var_dump($revision);
            if (empty($error_msg)) {
                $query = "INSERT INTO cp_vyrobny_plan ( id_vyrobny_plan, id_revizia_vyrobny_plan, vytvoril )\r\n                    VALUES ( {$order}, {$revision}, {$_SESSION['username']} )\r\n                    ";
                //print_r($query);
                //die();
                mysql_query("BEGIN");
                $sql_cp = sql_insert($query);
                $cp_id = $sql_cp["inserted_id"];
                //dd($form_data);
                for ($i = 0; $i < count($form_data[id_objednavka_row]); $i++) {
                    // ak je vacsi rovny nule
                    if (empty($form_data[product_price][$i])) {
                        if (!empty($form_data[id_cp_product][$i]) and $form_data[id_cp_product][$i] > 0) {
                            $product_price = sql_query("SELECT cena FROM cp_product WHERE id=" . $form_data[id_cp_product][$i] . " ORDER BY id DESC LIMIT 1")[0]["cena"];
                        } else {
                            $product_price = 0;
                        }
                    } else {
                        $product_price = $form_data[product_price][$i];
                    }
                    //echo $product_price."<br>";
                    //$product_ks_sum = $product_ks_sum + sec_input($form_data["ks"][$i]);
                    $product_price_sum = $product_price * sec_input($form_data["ks"][$i]);
                    $products_prices_sums = $products_prices_sums + $product_price_sum;
                    $zlava_E = $product_price_sum * $form_data["zlava"][$i] / 100;
                    $po_zlave = $product_price_sum - $zlava_E;
                    $po_zlave_sum = $po_zlave_sum + $po_zlave;
                    $query_cp_row = "INSERT into cp_vyrobny_plan_row (id_cp_vyrobny_plan, id_objednavka_row, id_cp_product, \r\n                                                            ks, cena, zlava, sum, black, ppd, komis, koment)\r\n                                        VALUES ({$cp_id},\r\n                                        {$form_data[id_objednavka_row][$i]}, \r\n                                        \"{$form_data[id_cp_product][$i]}\", \r\n                                        {$form_data[ks][$i]},\r\n                                        \"{$form_data[product_price][$i]}\",\r\n                                        \"{$form_data[zlava][$i]}\",\r\n                                        \"{$po_zlave}\",\r\n                                        \"{$form_data[black][$i]}\",\r\n                                        \"{$form_data[ppd][$i]}\",\r\n                                        \"{$form_data[komis][$i]}\",\r\n                                        \"{$form_data[koment][$i]}\"\r\n                                        )";
                    //echo $query_cp_row."<br>";
                    sql_insert($query_cp_row);
                    //var_dump($query_poznamka);
                }
                sql_update("UPDATE cp_vyrobny_plan SET all_sum={$po_zlave_sum} WHERE id={$cp_id}");
                mysql_query("COMMIT");
                //dd($form_data);
                //$_SESSION["posted_form_from_cp"]=$form_data;
                header("location: ?vyber=cp_vyrobny_plan&order={$order}&revision={$revision}&action=display_all");
            } else {
                echo "<div id=error_message>" . implode("<br>", $error_msg) . "</div>";
            }
        }
        echo "<form method=\"POST\" id=\"formular\" enctype=\"multipart/form-data\">";
        echo "<fieldset id=\"cp_rows\">";
        // pre editaciu cenovej ponuky....
        //=========================================
        $data_row = sql_query("SELECT vyr.*, obr.*, rev.meno, rev.mesto, rev.doruc_mesto, obj.id_zakaznik,\r\n                                rev.komentar, rev.komentar_private, rev.email, obj.c_obj c_obj, obj.datum datum_obj\r\n                            FROM vyrobny_plan_row vyr\r\n                            INNER JOIN objednavka_row obr\r\n                            ON vyr.id_objednavka_row = obr.id\r\n                            INNER JOIN revizia rev\r\n                            ON obr.id_revizia = rev.id\r\n                            INNER JOIN objednavka obj\r\n                            ON rev.id_obj = obj.id\r\n                            WHERE vyr.id_revizia_vyrobny_plan = " . $revision . "\r\n                                AND vyr.vymaz = 0\r\n                            ");
        //var_dump($data_row);
        foreach ($data_row as $key => $row) {
            $data_row_option = sql_query("SELECT id_product_atribute, id_product_atribute_option \r\n                                    FROM objednavka_row_atribute \r\n                                    WHERE id_revizia=\"{$row['id_revizia']}\" AND id_objednavka_row=\"{$row[id]}\"");
            //var_dump($data_row_option);
            foreach ($data_row_option as $option) {
                $data_row[$key]["product_atribute_options_all"][$option["id_product_atribute"]] = $option["id_product_atribute_option"];
            }
            if (isset($_GET["cp"]) and !empty($_GET["cp"])) {
                $query = "SELECT * from cp_vyrobny_plan_row WHERE id_cp_vyrobny_plan=" . sec_input(sec_sql($_GET["cp"])) . " AND id_objednavka_row=" . $row[id] . "";
                $cp_row = sql_query($query)[0];
                $data_row[$key]["cena"] = $cp_row[cena];
                $data_row[$key]["zlava"] = $cp_row[zlava];
                $data_row[$key]["black"] = $cp_row[black];
                $data_row[$key]["ppd"] = $cp_row[ppd];
                $data_row[$key]["komis"] = $cp_row[komis];
                $data_row[$key]["koment"] = $cp_row[koment];
                //var_dump($cp_row);
            }
            if ($row["id_zakaznik"] > 0) {
                $query = "SELECT meno, mesto, doruc_mesto FROM uzivatel WHERE id=" . $row["id_zakaznik"] . " LIMIT 1";
                $zakaznik = sql_query($query)[0];
                $data_row[$key]["meno"] = $zakaznik["meno"];
                $data_row[$key]["doruc_mesto"] = $zakaznik["doruc_mesto"];
                $data_row[$key]["mesto"] = $zakaznik["mesto"];
            }
            if ($row["id_zakaznik"] == 0) {
                $data_zak[$row["id_zakaznik"]][$row["id_revizia"]][] = $data_row[$key];
            } else {
                $data_zak[$row["id_zakaznik"]][] = $data_row[$key];
            }
        }
        //var_dump($data_row);
        $message = "<div class=\"print_hlavicka3\">\r\n            <table>\r\n               <tr>                              \r\n               <th style=\"width: 380px;\">produkt</th>                            \r\n               <th style=\"width: 50px;\">j.cena</th>                 \r\n               <th style=\"width: 120px;\">zľava % / j.cena po</th>\r\n               <th style=\"width: 50px;\">vl.cena</th>\r\n               <th style=\"width: 60px;\">Spolu bez DPH</th>\r\n               <th>DL</th>\r\n               <th>PPD</th>\r\n               <th>KMS</th>\r\n               <th style=\"width: 135px;\">komentár</th>\r\n               </tr>";
        $count = 0;
        foreach ($data_zak as $key => $zakaznik) {
            $data_z = array();
            if ($key > 0) {
                $message .= "<tr class=\"silver\">";
                $query = "SELECT meno, mesto, doruc_mesto, email FROM uzivatel WHERE id=" . $key . " LIMIT 1";
                $zakaz = sql_query($query)[0];
                //dd($zakaz);
                $data_z["meno"] = $zakaz["meno"];
                $data_z["doruc_mesto"] = $zakaz["doruc_mesto"];
                $data_z["mesto"] = $zakaz["mesto"];
                $data_z["email"] = $zakaz["email"];
                $odberatel = $data_z["meno"];
                if (empty($data_z["doruc_mesto"])) {
                    $odberatel .= empty($data_z["mesto"]) ? "" : ", " . $data_z["mesto"];
                } else {
                    $odberatel .= ", " . $data_z["doruc_mesto"];
                }
                $odberatel = "<span class=\"bold\">" . $odberatel . "</span>" . (!empty($data_z["email"]) ? " (" . $data_z["email"] . ")" : "") . "";
                $message .= "<td  colspan=9>{$odberatel}</td>";
                $message .= "</tr>";
            }
            foreach ($zakaznik as $keyer => $riadok) {
                if ($key > 0) {
                    $at_text = "";
                    if (!empty($riadok["atyp_text"])) {
                        $at_text = "atp";
                    }
                    $cls = "class=\"{$count} {$at_text}\"";
                    $message .= "<tr {$cls}>\r\n\r\n                                 ";
                    $product_type = sql_query("SELECT meno FROM product_type WHERE id=" . sec_sql(sec_input($riadok["id_product_type"])) . " LIMIT 1");
                    $product_type = $product_type[0];
                    $product = sql_query("SELECT id, meno FROM product WHERE id=" . sec_sql(sec_input($riadok["id_product"])) . " LIMIT 1")[0];
                    $options_str = array();
                    //var_dump($data);
                    if (!isset($riadok["product_atribute_options_all"]) or empty($riadok["product_atribute_options_all"])) {
                        $riadok["product_atribute_options_all"] = array();
                    }
                    $option_c_hladina = 1;
                    foreach ($riadok["product_atribute_options_all"] as $option) {
                        //var_dump($option);
                        $options = sql_query("SELECT id, meno, id_c_hladina FROM product_atribute_option WHERE id=" . sec_sql(sec_input($option)) . " LIMIT 1");
                        $options_str[] = $options[0]["meno"];
                        if ($options[0]["id_c_hladina"] > $option_c_hladina) {
                            $option_c_hladina = $options[0]["id_c_hladina"];
                        }
                        //$options["price"] = sql_query("SELECT id, cena FROM product_atribute_option WHERE id=".sec_sql(sec_input($option))." LIMIT 1");
                    }
                    $options_str = empty($options_str) ? "" : " (" . join(", ", $options_str) . ")";
                    //var_dump($option_c_hladina);
                    /*
                    $odberatel = $riadok["meno"];
                    
                    if(empty($riadok["doruc_mesto"])) {
                        $odberatel .= ( empty($riadok["mesto"]) ? "" : ", ".$riadok["mesto"] );
                    } else {
                        $odberatel .= ", ".$riadok["doruc_mesto"];
                    }                         
                    */
                    $odberatel = " (obj č. " . $riadok["c_obj"] . "/" . dateYear($riadok["datum_obj"]) . ") z " . dateDate($riadok["datum_obj"]) . "";
                    $odberatel = "<br>" . $odberatel . "";
                    $message .= "<td class=\"form_nazov_siroky\">" . sec_input($riadok["ks"]) . "x " . $product_type["meno"] . " <span class=\"bold\">" . $product["meno"] . "" . $options_str . "</span>\r\n                                        " . (empty($riadok["atyp_text"]) ? "" : "<br>Atyp: " . sec_input($riadok["atyp_text"])) . "\r\n                                        {$odberatel}\r\n                                        " . (empty($riadok["komentar"]) ? "" : "<br>- " . sec_input($riadok["komentar"])) . "\r\n                                        " . (empty($riadok["komentar_private"]) ? "" : "<br>- " . sec_input($riadok["komentar_private"])) . "\r\n                                            " . hidden("ks[]", $riadok["ks"], "ks") . "\r\n                                            " . hidden("id[]", $riadok["id"]) . "</td>";
                    $product_prices = sql_query("SELECT id, cena FROM cp_product WHERE id_c_hladina=" . $option_c_hladina . " AND id_product=" . $product["id"] . " ORDER BY id DESC LIMIT 1")[0];
                    $regular_price = $product_prices[cena] . " €";
                    //echo "$i<br>";
                    //var_dump(count($data[product_price_all][$i]));
                    //var_dump($data[product_price_all]);
                    if ($riadok[cena] == 0) {
                        //echo "hej";
                        if (!empty($riadok[vlastna_cena])) {
                            $cena_final = $riadok[vlastna_cena];
                            $product_price = $riadok[vlastna_cena];
                        } else {
                            $cena_final = 0;
                            $product_price = $product_prices[cena];
                        }
                    } else {
                        $product_price = $riadok[cena];
                        $cena_final = $riadok[cena];
                    }
                    $product_ks_sum = $product_ks_sum + sec_input($riadok["ks"]);
                    $product_price_sum = $product_price * sec_input($riadok["ks"]);
                    // spocitanie ceny spolu za vsetky produkty
                    $products_prices_sums = $products_prices_sums + $product_price_sum;
                    $zlava_E = $product_price_sum * $riadok["zlava"] / 100;
                    $zlava_J = $product_price * $riadok["zlava"] / 100;
                    $zlava_J = $product_price - $zlava_J;
                    $po_zlave = $product_price_sum - $zlava_E;
                    $po_zlave_sum = $po_zlave_sum + $po_zlave;
                    $message .= "<td class=\"form_nazov ali-center product-price regular-price bold bigger\">" . $regular_price . "" . hidden("id_cp_product[]", $product_prices[id]) . " </td>";
                    $message .= "<td class=\"form_nazov bold bigger\">" . textfield("zlava[]", empty($riadok[zlava]) ? "0" : $riadok[zlava], "", 4, 2, "zlava") . "<span class=\"zlava-E\">" . ($riadok["zlava"] > 0 ? "" . $zlava_J . " €" : "") . "</span></td>";
                    $message .= "<td class=\"form_nazov ali-center product-price\">" . textfield("product_price[{$i}]", $cena_final, "", 5, 3, "product_price") . "</td>";
                    //$message .= "<td class=\"form_nazov ali-center bold\"><span class=\"cena-spolu-product\">".$product_price_sum ."</span> €</td>";
                    $message .= "<td class=\"form_nazov ali-center po-zlave-sum\">" . $po_zlave . " €</td>";
                    $checked = "";
                    if ($riadok[black] == 1) {
                        $checked = "checked";
                    }
                    $checked_ppd = "";
                    if ($riadok[ppd] == 1) {
                        $checked_ppd = "checked";
                    }
                    $checked_komis = "";
                    if ($riadok[komis] == 1) {
                        $checked_komis = "checked";
                    }
                    $message .= "<td><input type=\"checkbox\" name=\"black[{$count}]\" value=\"1\" {$checked}></td>";
                    $message .= "<td><input type=\"checkbox\" name=\"ppd[{$count}]\" value=\"1\" {$checked_ppd}></td>";
                    $message .= "<td><input type=\"checkbox\" name=\"komis[{$count}]\" value=\"1\" {$checked_komis}></td>";
                    $message .= "<td>" . textarea("koment[]", $riadok[koment], "", 16, 1, "koment") . "</td>";
                    $message .= "</tr>";
                    $count = $count + 1;
                } else {
                    $message .= "<tr class=\"silver\">";
                    $data_z["meno"] = $riadok[0]["meno"];
                    $data_z["doruc_mesto"] = $riadok[0]["doruc_mesto"];
                    $data_z["mesto"] = $riadok[0]["mesto"];
                    $data_z["email"] = $riadok[0]["email"];
                    $odberatel = $data_z["meno"];
                    if (empty($data_z["doruc_mesto"])) {
                        $odberatel .= empty($data_z["mesto"]) ? "" : ", " . $data_z["mesto"];
                    } else {
                        $odberatel .= ", " . $data_z["doruc_mesto"];
                    }
                    $odberatel = "<span class=\"bold\">" . $odberatel . "</span>" . (!empty($data_z["email"]) ? " (" . $data_z["email"] . ")" : "") . "";
                    $message .= "<td colspan=9>{$odberatel}</td>";
                    $message .= "</tr>";
                    foreach ($riadok as $riadok_without) {
                        $cls = "class=\"{$count}\"";
                        $message .= "<tr {$cls}>";
                        $product_type = sql_query("SELECT meno FROM product_type WHERE id=" . sec_sql(sec_input($riadok_without["id_product_type"])) . " LIMIT 1");
                        $product_type = $product_type[0];
                        $product = sql_query("SELECT id, meno FROM product WHERE id=" . sec_sql(sec_input($riadok_without["id_product"])) . " LIMIT 1")[0];
                        $options_str = array();
                        //var_dump($data);
                        if (!isset($riadok_without["product_atribute_options_all"]) or empty($riadok_without["product_atribute_options_all"])) {
                            $riadok_without["product_atribute_options_all"] = array();
                        }
                        $option_c_hladina = 1;
                        foreach ($riadok_without["product_atribute_options_all"] as $option) {
                            //var_dump($option);
                            $options = sql_query("SELECT id, meno, id_c_hladina FROM product_atribute_option WHERE id=" . sec_sql(sec_input($option)) . " LIMIT 1");
                            $options_str[] = $options[0]["meno"];
                            if ($options[0]["id_c_hladina"] > $option_c_hladina) {
                                $option_c_hladina = $options[0]["id_c_hladina"];
                            }
                            //$options["price"] = sql_query("SELECT id, cena FROM product_atribute_option WHERE id=".sec_sql(sec_input($option))." LIMIT 1");
                        }
                        $options_str = empty($options_str) ? "" : " (" . join(", ", $options_str) . ")";
                        //var_dump($option_c_hladina);
                        /*
                        $odberatel = $riadok_without["meno"];
                        
                        if(empty($riadok_without["doruc_mesto"])) {
                            $odberatel .= ( empty($riadok_without["mesto"]) ? "" : ", ".$riadok_without["mesto"] );
                        } else {
                            $odberatel .= ", ".$riadok_without["doruc_mesto"];
                        }                         
                        */
                        $odberatel = " (obj č. " . $riadok_without["c_obj"] . "/" . dateYear($riadok_without["datum_obj"]) . ") z " . dateDate($riadok_without["datum_obj"]) . "";
                        $odberatel = "<br>" . $odberatel . "";
                        $message .= "<td class=\"form_nazov_siroky\">" . sec_input($riadok_without["ks"]) . "x " . $product_type["meno"] . " <span class=\"bold\">" . $product["meno"] . "" . $options_str . "</span>\r\n                                                " . (empty($riadok_without["atyp_text"]) ? "" : "<br>Atyp: " . sec_input($riadok_without["atyp_text"])) . "\r\n                                                {$odberatel}\r\n                                                " . (empty($riadok_without["komentar"]) ? "" : "<br>- " . sec_input($riadok_without["komentar"])) . "\r\n                                                " . (empty($riadok_without["komentar_private"]) ? "" : "<br>- " . sec_input($riadok_without["komentar_private"])) . "\r\n                                                    " . hidden("ks[]", $riadok_without["ks"], "ks") . "\r\n                                                    " . hidden("id[]", $riadok_without["id"]) . "</td>";
                        $product_prices = sql_query("SELECT id, cena FROM cp_product WHERE id_c_hladina=" . $option_c_hladina . " AND id_product=" . $product["id"] . " ORDER BY id DESC LIMIT 1")[0];
                        $regular_price = $product_prices[cena] . " €";
                        //echo "$i<br>";
                        //var_dump(count($data[product_price_all][$i]));
                        //var_dump($data[product_price_all]);
                        if ($riadok_without[cena] == 0) {
                            //echo "hej";
                            if (!empty($riadok_without[vlastna_cena])) {
                                $cena_final = $riadok_without[vlastna_cena];
                                $product_price = $riadok_without[vlastna_cena];
                            } else {
                                $cena_final = 0;
                                $product_price = $product_prices[cena];
                            }
                        } else {
                            $product_price = $riadok_without[cena];
                            $cena_final = $riadok_without[cena];
                        }
                        $product_ks_sum = $product_ks_sum + sec_input($riadok_without["ks"]);
                        $product_price_sum = $product_price * sec_input($riadok_without["ks"]);
                        // spocitanie ceny spolu za vsetky produkty
                        $products_prices_sums = $products_prices_sums + $product_price_sum;
                        $zlava_E = $product_price_sum * $riadok_without[zlava] / 100;
                        $zlava_J = $product_price * $riadok["zlava"] / 100;
                        $zlava_J = $product_price - $zlava_J;
                        $po_zlave = $product_price_sum - $zlava_E;
                        $po_zlave_sum = $po_zlave_sum + $po_zlave;
                        $message .= "<td class=\"form_nazov ali-center product-price regular-price bold bigger\">" . $regular_price . "" . hidden("id_cp_product[]", $product_prices[id]) . " </td>";
                        $message .= "<td class=\"form_nazov bold bigger\">" . textfield("zlava[]", empty($riadok_without[zlava]) ? "0" : $riadok_without[zlava], "", 4, 2, "zlava") . "<span class=\"zlava-E\">" . ($riadok["zlava"] > 0 ? "-" . $zlava_J . " €" : "") . "</span></td>";
                        $message .= "<td class=\"form_nazov ali-center product-price\">" . textfield("product_price[{$i}]", $cena_final, "", 5, 3, "product_price") . "</td>";
                        //$message .= "<td class=\"form_nazov ali-center bold\"><span class=\"cena-spolu-product\">".$product_price_sum ."</span> €</td>";
                        $message .= "<td class=\"form_nazov ali-center po-zlave-sum\">" . $po_zlave . " €</td>";
                        $checked = "";
                        $checked_ppd = "";
                        $checked_komis = "";
                        if ($riadok_without[black] == 1) {
                            $checked = "checked";
                        }
                        $checked_ppd = "";
                        if ($riadok_without[ppd] == 1) {
                            $checked_ppd = "checked";
                        }
                        $checked_komis = "";
                        if ($riadok_without[komis] == 1) {
                            $checked_komis = "checked";
                        }
                        $message .= "<td><input type=\"checkbox\" name=\"black[{$count}]\" value=\"1\" {$checked}></td>";
                        $message .= "<td><input type=\"checkbox\" name=\"ppd[{$count}]\" value=\"1\" {$checked_ppd}></td>";
                        $message .= "<td><input type=\"checkbox\" name=\"komis[{$count}]\" value=\"1\" {$checked_komis}></td>";
                        $message .= "<td>" . textarea("koment[]", $riadok_without[koment], "", 16, 1, "koment") . "</td>";
                        $message .= "</tr>";
                        $count = $count + 1;
                    }
                }
            }
        }
        $message .= "<tr class=\"cp_spolu bold\">\r\n                            <td>Spolu: " . $product_ks_sum . " ks</td>\r\n                            <td></td>\r\n                            <td></td>\r\n                            <td></td>\r\n                            <td class=\"ali-center po-zlave-sum-all\">" . $po_zlave_sum . " €</td>\r\n                            <td></td>\r\n                            <td></td>\r\n                            <td></td>\r\n                            <td></td>\r\n                            \r\n                    <tr>";
        $message .= "</table></div>";
        echo $message;
        echo "</fieldset>";
        echo submit("submit_page1", "Pokračovať");
    }
    echo "</form>";
}
                $obj[meno] = "vyfaktúrované";
                // kompletná objednávka
                $obj[nastavenie] = "komplet";
            }
            $all_sum = sql_query("SELECT all_sum\r\n                            FROM cp_vyrobny_plan\r\n                            WHERE id_vyrobny_plan=" . $obj[id] . " ORDER by id DESC\r\n                                limit 1\r\n                            ")[0][all_sum];
        }
        $acko = "<a href=\"?vyber=vyrobny_plan&action=display&id=" . $obj[id] . "\">\r\n                " . $obj[vyrobny_plan] . "</a>";
        if ($vyber == "fakturacia") {
            if ($all_sum > 0) {
                $all_sum = "({$all_sum} €)";
            } else {
                $all_sum = "";
            }
            $acko = "<a href=\"?vyber=cp_vyrobny_plan&action=display_all&order=" . $obj[id] . "\">\r\n                " . $obj[vyrobny_plan] . " {$all_sum}</a>";
        }
        echo "\r\n        <tr class=\"obj_" . $obj[nastavenie] . "\">\r\n            <td class=\"obj_cislo\">" . $obj[id] . "</td>\r\n            \r\n            <td class=\"obj_meno bold\">\r\n                {$acko}                    \r\n            </td>\r\n            <td class=\"obj_datum\">\r\n                " . dateDate($obj["datum_vyvozu"]) . "</td>\r\n            <td class=\"obj_datum\">" . (!empty($obj["datum_vyroby"]) ? dateDate($obj["datum_vyroby"]) : "") . "";
        //var_dump($vyroba2);
        if ($obj["delivery"] == 1) {
            $delivery = "48 hodín";
        } else {
            $delivery = "štandard";
        }
        echo "</td>\r\n            <td class=\"obj_delivery\">{$delivery}</td>\r\n            <td class=\"obj_status\">" . $obj[meno] . "</td> \r\n                \r\n            ";
        echo " \r\n            </tr>\r\n            ";
    }
}
echo "</tbody></table>";
echo "<div class=\"pager\">Strany: " . implode(" | ", $pager[pages]) . "</div>";
//var_dump($_SESSION);
$mtime = microtime();
$mtime = explode(" ", $mtime);
Пример #7
0
    echo "<div class=\"tasker_username\">" . $task["meno"] . "</div>";
    if ($task["komplet"] == 0) {
        echo checker("task_complete", $task["id"], "");
        echo "<div class=\"task_text datum\">" . dateDate($task["datum"]) . "</div>";
    } else {
        echo "<div class=\"check\"></div>";
        echo "<div class=\"task_text datum\">" . dateDate($task["datum_komplet"]) . "</div>";
    }
    echo "<div class=\"task_text\">" . $task["task"] . "</div>";
    echo "</div>";
}
echo "</div>";
echo "<div class=\"tasks_for\">Odoslané správy";
$tasks = sql_query("SELECT t.*, u.meno from task t\r\n                        INNER JOIN uzivatel u\r\n                        ON t.for_uzivatel_id = u.id\r\n                        WHERE t.uzivatel_id = " . $_SESSION["username"] . "                            \r\n                            AND (t.komplet=0 OR (t.komplet=1 AND t.datum_komplet >= DATE_SUB(CURDATE(), INTERVAL 1 DAY)))\r\n                            AND t.vymaz = 0\r\n                        ORDER BY t.komplet ASC, t.datum");
foreach ($tasks as $task) {
    echo "<div class=\"tasker_task_for\">";
    echo "<div class=\"tasker_username\">" . $task["meno"] . "</div>";
    if ($task["komplet"] > 0) {
        echo "<div class=\"check\"></div>";
        echo "<div class=\"task_text datum\">" . dateDate($task["datum_komplet"]) . "</div>";
    } else {
        echo "<div class=\"task_text datum\">" . dateDate($task["datum"]) . "</div>";
    }
    echo "<div class=\"task_text\">" . $task["task"] . "</div>";
    echo "<div class=\"remove\" data-task=\"" . $task["id"] . "\"></div>";
    echo "</div>";
}
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";