예제 #1
0
function print_revision_cp($cp, $revision)
{
    $data = sql_query("SELECT id_obj, meno, adresa, mesto, psc, ico, dic, telefon, email, vystavil, vlastne_cislo_obj,\r\n                                    komentar, doruc_meno, doruc_adresa, doruc_mesto, doruc_psc,\r\n                                    DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum\r\n                                    FROM revizia \r\n                                    WHERE id={$revision} \r\n                                    LIMIT 1");
    $data_row = sql_query("SELECT * \r\n                            FROM objednavka_row\r\n                            WHERE id_revizia = " . $revision . "\r\n                            ");
    $data = $data[0];
    $fieldsets_c = count($data_row);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_row[$i][ks];
        $product_type[$i] = $data_row[$i][id_product_type];
        $product[$i] = $data_row[$i][id_product];
        $product_delivery[$i] = $data_row[$i][id_product_delivery];
        $atyp_text[$i] = $data_row[$i][atyp_text];
        $data_row_option = sql_query("SELECT id_product_atribute, id_product_atribute_option \r\n                                    FROM objednavka_row_atribute \r\n                                    WHERE id_revizia=\"{$revision}\" AND id_objednavka_row=\"{$data_row[$i][id]}\"");
        //dd($form_data_row_option);
        foreach ($data_row_option as $option) {
            $data_rows[$i][$option["id_product_atribute"]] = $option["id_product_atribute_option"];
        }
    }
    $data[ks_all] = $ks;
    $data[product_type_all] = $product_type;
    $data[product_all] = $product;
    $data[product_delivery_all] = $product_delivery;
    $data[atyp_text_all] = $atyp_text;
    $data[product_atribute_options_all] = $data_rows;
    $files = sql_query("SELECT meno, meno_old, pripona \r\n                                FROM subor\r\n                                WHERE id_obj=" . $data["id_obj"] . "");
    //var_dump($files);
    $data_obj = sql_query("SELECT DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, c_obj, id_zakaznik,\r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM objednavka \r\n                                    WHERE id=" . $data["id_obj"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    $message = "";
    $message .= "<h1>Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . "</h1>";
    $message .= "<h5>zo dňa: " . $data_obj["datum"] . "</h5>";
    $message .= "<div class=\"print_hlavicka\">";
    $message .= "<table class=\"print_dodavatel\"><tr><td></td><td><strong>Dodávateľ</strong></td></tr>";
    $message .= "<tr><td></td><td>" . def_value("default_firma", "hodnota") . "</td></tr>";
    $message .= "<tr><td></td><td>" . def_value("default_adresa", "hodnota") . "</td></tr>";
    $message .= "<tr><td></td><td>" . def_value("default_mesto", "hodnota") . "</td></tr>";
    $message .= "<tr><td>IČO:</td><td>" . def_value("default_ico", "hodnota") . "</td></tr>";
    $message .= "<tr><td>DIČ:</td><td>" . def_value("default_dic", "hodnota") . "</td></tr>";
    $message .= "<tr><td>tel.:</td><td>" . def_value("default_telefon", "hodnota") . "</td></tr>";
    $message .= "<tr><td>mobil:</td><td>" . def_value("default_mobil", "hodnota") . "</td></tr>";
    $message .= "<tr><td>email:</td><td>" . def_value("default_email", "hodnota") . "<br> " . def_value("default_email_2", "hodnota") . "</td></tr>";
    $message .= "</table>";
    if ($data_obj[id_zakaznik] > 0) {
        $meno_zakaznika = sql_query("SELECT meno, adresa, ico, telefon, email FROM uzivatel WHERE id={$data_obj['id_zakaznik']} LIMIT 1");
        $meno_zakaznika = $meno_zakaznika[0];
        $data[meno] = $meno_zakaznika[meno];
        $data[adresa] = $meno_zakaznika[adresa];
        $data[ico] = $meno_zakaznika[ico];
        $data[telefon] = $meno_zakaznika[telefon];
        $data[email] = $meno_zakaznika[email];
    }
    $message .= "<div class=\"print_odberatel\"><table class=\"print_odberatel\"><tr><td></td><td>Objednávateľ:</td></tr>";
    $message .= "<tr><td></td><td class=\"print_bigger\">" . $data["meno"] . "</td></tr>";
    $message .= "<tr><td></td><td>" . $data["adresa"] . "</td></tr>";
    $message .= "<tr><td></td><td>" . $data["psc"] . " " . $data["mesto"] . "</td></tr>";
    $message .= "<tr><td>IČO:</td><td>" . $data["ico"] . "</td></tr>";
    $message .= "<tr><td>DIČ:</td><td>" . $data["dic"] . "</td></tr>";
    $message .= "<tr><td>tel.:</td><td>" . $data["telefon"] . "</td></tr>";
    $message .= "<tr><td>email:</td><td>" . $data["email"] . "</td></tr>";
    $message .= "</table>";
    $message .= "</div>\r\n                    <div style=\"clear: both\"></div>\r\n                    </div>";
    $data_row = sql_query("SELECT * \r\n                            FROM objednavka_row\r\n                            WHERE id_revizia = " . $revision . "\r\n                            ");
    //var_dump($data_row);
    $fieldsets_c = count($data_row);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_row[$i][ks];
        $id[$i] = $data_row[$i][id];
        $product_type[$i] = $data_row[$i][id_product_type];
        $product[$i] = $data_row[$i][id_product];
        $product_delivery[$i] = $data_row[$i][id_product_delivery];
        $atyp_text[$i] = $data_row[$i][atyp_text];
        $data_row_option = sql_query("SELECT id_product_atribute, id_product_atribute_option \r\n                                    FROM objednavka_row_atribute \r\n                                    WHERE id_revizia=\"{$revision}\" AND id_objednavka_row=\"{$data_row[$i][id]}\"");
        //dd($form_data_row_option);
        foreach ($data_row_option as $option) {
            $data_rows[$i][$option["id_product_atribute"]] = $option["id_product_atribute_option"];
        }
        $query = "SELECT * from cp_row WHERE id_cp=" . sec_input(sec_sql($_GET["cp"])) . " AND id_objednavka_row=" . $data_row[$i][id] . "";
        $cp_row = sql_query($query)[0];
        $cena[$i] = $cp_row[cena];
        $zlava[$i] = $cp_row[zlava];
        //var_dump($cp_row);
    }
    $data[id_all] = $id;
    $data[ks_all] = $ks;
    $data[product_type_all] = $product_type;
    $data[product_all] = $product;
    $data[product_delivery_all] = $product_delivery;
    $data[atyp_text_all] = $atyp_text;
    $data[product_atribute_options_all] = $data_rows;
    $data[product_price_all] = $cena;
    $data[zlava_all] = $zlava;
    /// riadky cenovej ponuky
    $message .= "<div class=\"print_hlavicka3\">\r\n            <table>\r\n               <tr>\r\n                              \r\n               <th style=\"width: 450px;\">produkt</th>               \r\n               <th style=\"width: 100px;\">doprava</th>              \r\n               <th style=\"width: 50px;\">j.cena</th>\r\n               <th style=\"width: 50px;\">Spolu</th>\r\n               <th style=\"width: 120px;\">zľava %</th>\r\n               <th style=\"width: 80px;\">po zľave</th>\r\n               </tr>";
    //echo hidden("name", "value");
    //var_dump($data);
    $fieldsets_c = count($data["ks_all"]);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $poradie = 0;
        $poradie = $i + 1;
        $message .= "<tr>\r\n                     \r\n                     ";
        $product_type = sql_query("SELECT meno FROM product_type WHERE id=" . sec_sql(sec_input($data["product_type_all"][$i])) . " LIMIT 1");
        $product_type = $product_type[0];
        $product = sql_query("SELECT id, meno FROM product WHERE id=" . sec_sql(sec_input($data["product_all"][$i])) . " LIMIT 1")[0];
        $message .= hidden("id[]", $data["id_all"][$i]);
        $options_str = array();
        //var_dump($data);
        if (!isset($data["product_atribute_options_all"][$i]) or empty($data["product_atribute_options_all"][$i])) {
            $data["product_atribute_options_all"][$i] = array();
        }
        $option_c_hladina = 1;
        foreach ($data["product_atribute_options_all"][$i] 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) . ")";
        $message .= "<td class=\"form_nazov_siroky\">" . sec_input($data["ks_all"][$i]) . "x " . $product_type["meno"] . " " . $product["meno"] . "" . $options_str . "" . (empty($data["atyp_text_all"][$i]) ? "" : "<br>Atyp: " . sec_input($data["atyp_text_all"][$i])) . "</td>";
        $product_delivery = sql_query("SELECT meno FROM product_delivery WHERE id=" . sec_sql(sec_input($data["product_delivery_all"][$i])) . " LIMIT 1");
        $product_delivery = $product_delivery[0];
        $message .= "<td class=\"form_hrana\">" . $product_delivery["meno"] . "</td>";
        $message .= hidden("ks[]", $data["ks_all"][$i]);
        if (empty($data[product_price_all][$i])) {
            $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];
            $product_price = $product_prices[cena];
        } else {
            $product_price = $data[product_price_all][$i];
        }
        $product_ks_sum = $product_ks_sum + sec_input($data["ks_all"][$i]);
        $product_price_sum = $product_price * sec_input($data["ks_all"][$i]);
        $message .= hidden("id_cp_product[]", $product_prices[id]);
        // spocitanie ceny spolu za vsetky produkty
        $products_prices_sums = $products_prices_sums + $product_price_sum;
        $zlava_E = $product_price_sum * $data[zlava_all][$i] / 100;
        $po_zlave = $product_price_sum - $zlava_E;
        $po_zlave_sum = $po_zlave_sum + $po_zlave;
        if (!empty($data["atyp_text_all"][$i])) {
            $product_price = $data[product_price_all][$i] . " €";
        } else {
            $product_price = $product_price . " €";
        }
        $message .= "<td class=\"form_nazov ali-center product-price\">" . $product_price . "</td>";
        $message .= "<td class=\"form_nazov ali-center\"><span class=\"cena-spolu-product\">" . $product_price_sum . "</span> €</td>";
        $message .= "<td class=\"form_nazov ali-center\"><span class=\"zlava-E bold\">" . ($zlava_E > 0 ? "-" . $zlava_E . " €" : "") . "</span>" . ($data[zlava_all][$i] > 0 ? " (" . $data[zlava_all][$i] . "%)" : "") . "</td>";
        $message .= "<td class=\"form_nazov ali-center po-zlave-sum bold\">" . $po_zlave . " €</td>";
        $message .= "</tr>";
    }
    $message .= "<tr class=\"cp_spolu bold\">\r\n                            \r\n                            <td>Spolu:</td>\r\n                            <td class=\"ali-center\">" . $product_ks_sum . " ks</td>\r\n                            <td></td>\r\n                            <td class=\"ali-center\">" . $products_prices_sums . " €</td>\r\n                            <td></td>\r\n                            <td class=\"ali-center po-zlave-sum-all\">" . $po_zlave_sum . " €</td>\r\n                            \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;
}
<?php

session_start();
$safe = "U,,5Enc!";
$root = $_SERVER['DOCUMENT_ROOT'];
include_once "config/datab.php";
// subor s nastaveniami databaz
include_once "config/fnc.php";
// vloženie hlavičky stránky
if (isset($_GET["select_material"])) {
    $material = sec_sql(sec_input($_GET["select_material"]));
    $query = "SELECT count(id) as counter from hrubka WHERE id_material={$material}";
    $has_hrubka = sql_query($query);
    $skryt_zakaznikom = "AND skryt_zakaznikom=0";
    if ($_SESSION["logged"] == 1) {
        $skryt_zakaznikom = "";
    }
    if ($has_hrubka[0]["counter"] > 0) {
        $where = "AND id_material={$material}";
    } else {
        $where = "AND id_material=0";
    }
    echo select("hrubka[]", "Hrúbka", "SELECT id, hodnota, meno FROM hrubka WHERE vymaz=0 {$where} {$skryt_zakaznikom} ORDER BY hodnota", def_value("default_hrubka", "hodnota"), "", "hrubka", "", "NO");
}
예제 #3
0
파일: cp.php 프로젝트: jozefvasko/benap-app
function send_email_revision_cp($revision, $cp)
{
    require_once 'include/PHPMailer/PHPMailerAutoload.php';
    $email_to_default = def_value("default_email", "hodnota");
    mysql_query("BEGIN");
    $data = sql_query("SELECT id_obj, meno, adresa, mesto, psc, ico, dic, telefon, email, komentar,\r\n                                vystavil, vlastne_cislo_obj, doruc_meno, doruc_adresa, doruc_mesto, \r\n                                doruc_psc,\r\n                                    DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum\r\n                                    FROM revizia \r\n                                    WHERE id={$revision} \r\n                                    LIMIT 1");
    $data_row = sql_query("SELECT id, ks, id_product_type, id_product, id_product_delivery, atyp_text\r\n                                    FROM objednavka_row \r\n                                    WHERE id_revizia={$revision}");
    $data = $data[0];
    $fieldsets_c = count($data_row);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_row[$i][ks];
        $product_type[$i] = $data_row[$i][id_product_type];
        $product[$i] = $data_row[$i][id_product];
        $product_delivery[$i] = $data_row[$i][id_product_delivery];
        $atyp_text[$i] = $data_row[$i][atyp_text];
        $data_row_option = sql_query("SELECT id_product_atribute, id_product_atribute_option \r\n                                    FROM objednavka_row_atribute \r\n                                    WHERE id_revizia=\"{$revision}\" AND id_objednavka_row=\"{$data_row[$i][id]}\"");
        //dd($form_data_row_option);
        foreach ($data_row_option as $option) {
            $data_rows[$i][$option["id_product_atribute"]] = $option["id_product_atribute_option"];
        }
    }
    $data[ks_all] = $ks;
    $data[product_type_all] = $product_type;
    $data[product_all] = $product;
    $data[product_delivery_all] = $product_delivery;
    $data[atyp_text_all] = $atyp_text;
    $data[product_atribute_options_all] = $data_rows;
    $files = sql_query("SELECT meno, meno_old, pripona \r\n                                FROM subor\r\n                                WHERE id_obj=" . $data["id_obj"] . "");
    //var_dump($data);
    $data_obj = sql_query("SELECT DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, c_obj, status,\r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM objednavka \r\n                                    WHERE id=" . $data["id_obj"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    $secure_key = sql_query("SELECT secure_key\r\n                                    FROM objednavka_secure\r\n                                    WHERE id_obj=" . $data["id_obj"] . " AND \r\n                                          id_revizia={$revision} LIMIT 1");
    $secure_key = $secure_key[0][secure_key];
    $message = "<html>";
    $message .= "<head>";
    $message .= "<style>\r\n                    table.items {\r\n                        border-collapse: collapse;\r\n                        border-spacing: 0;\r\n                    }\r\n                    table.items td {\r\n                         border: 1px solid #c1c1c1;\r\n                    }\r\n                    </style>";
    $message .= "</head>";
    $message .= "<body>";
    $message .= "<img src=\"http://" . $_SERVER['HTTP_HOST'] . "/assets/images/logo.jpg\">";
    $message .= "<h1>Cenová ponuka k objednávke č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . "</h1>";
    if (!empty($data["vlastne_cislo_obj"])) {
        $message .= "Vaše číslo objednávky: " . $data["vlastne_cislo_obj"] . "<br>";
    }
    $message .= "zo dňa: " . $data_obj["datum"] . "<br><br>";
    $message .= "<table><tr>";
    $message .= "<td style=\"width: 400px;\"><strong>Dodávateľ</strong><br>";
    $message .= "<table><tr><td>" . def_value("default_firma", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_adresa", "hodnota") . "<br>" . def_value("default_mesto", "hodnota") . "</td></tr>";
    $message .= "<tr><td>IČO: " . def_value("default_ico", "hodnota") . "<br> DIČ: " . def_value("default_dic", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_telefon", "hodnota") . "<br> " . def_value("default_mobil", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_email", "hodnota") . "<br> " . def_value("default_email_2", "hodnota") . "</td></tr>";
    $message .= "</table><br><br></td>";
    $message .= "<td style=\"width: 50%;\"><strong>Objednávateľ:</strong>";
    $message .= "<table><tr><td></td><td>" . $data["meno"] . "</td></tr>";
    $message .= "<tr><td></td><td>" . $data["adresa"] . "</td></tr>";
    $message .= "<tr><td></td><td>" . $data["psc"] . " " . $data["mesto"] . "</td></tr>";
    $message .= "<tr><td>IČO</td><td>" . $data["ico"] . "</td></tr>";
    $message .= "<tr><td>DIČ</td><td>" . $data["dic"] . "</td></tr>";
    $message .= "<tr><td>tel.</td><td>" . $data["telefon"] . "</td></tr>";
    $message .= "<tr><td>email:</td><td>" . $data["email"] . "</td></tr>";
    $message .= "<tr><td>vystavil:</td><td>" . $data["vystavil"] . "</td></tr>";
    $message .= "</table><br><strong>Adresa doručenia:</strong>";
    $message .= "<table><tr><td>" . $data["doruc_meno"] . "</td></tr>";
    $message .= "<tr><td>" . $data["doruc_adresa"] . "</td></tr>";
    $message .= "<tr><td>" . $data["doruc_psc"] . " " . $data["doruc_mesto"] . "</td></tr>";
    $message .= "</table><br></td>";
    $message .= "</tr></table><br><br>";
    $fieldsets_c = count($data_row);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_row[$i][ks];
        $id[$i] = $data_row[$i][id];
        $product_type[$i] = $data_row[$i][id_product_type];
        $product[$i] = $data_row[$i][id_product];
        $product_delivery[$i] = $data_row[$i][id_product_delivery];
        $atyp_text[$i] = $data_row[$i][atyp_text];
        $data_row_option = sql_query("SELECT id_product_atribute, id_product_atribute_option \r\n                                    FROM objednavka_row_atribute \r\n                                    WHERE id_revizia=\"{$revision}\" AND id_objednavka_row=\"{$data_row[$i][id]}\"");
        //dd($form_data_row_option);
        foreach ($data_row_option as $option) {
            $data_rows[$i][$option["id_product_atribute"]] = $option["id_product_atribute_option"];
        }
        $query = "SELECT * from cp_row WHERE id_cp=" . sec_input(sec_sql($_GET["cp"])) . " AND id_objednavka_row=" . $data_row[$i][id] . "";
        $cp_row = sql_query($query)[0];
        $cena[$i] = $cp_row[cena];
        $zlava[$i] = $cp_row[zlava];
        //var_dump($cp_row);
    }
    $data[id_all] = $id;
    $data[ks_all] = $ks;
    $data[product_type_all] = $product_type;
    $data[product_all] = $product;
    $data[product_delivery_all] = $product_delivery;
    $data[atyp_text_all] = $atyp_text;
    $data[product_atribute_options_all] = $data_rows;
    $data[product_price_all] = $cena;
    $data[zlava_all] = $zlava;
    $message .= "<div class=\"print_hlavicka3\">\r\n            <table style=\"font-size: 80%;\" class=\"items\">\r\n               <tr style=\"background-color: #efefef; font-size: 9pt;\">\r\n               <th></th>\r\n               <th style=\"width: 380px;\">produkt</th>\r\n               <th style=\"width: 40px;\">množstvo</th>\r\n               <th style=\"width: 100px;\">doprava</th>              \r\n               <th style=\"width: 50px;\">j.cena</th>\r\n               <th style=\"width: 50px;\">Spolu</th>\r\n               <th style=\"width: 100px;\">zľava %</th>\r\n               <th style=\"width: 80px;\">po zľave</th>\r\n               </tr>";
    //var_dump(sql_query("SELECT * from cp WHERE id=$cp"));
    //var_dump($data);
    $fieldsets_c = count($data["ks_all"]);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $poradie = 0;
        $poradie = $i + 1;
        $message .= "<tr>\r\n                     <td class=\"form_poradie\">{$poradie}. </td>\r\n                     ";
        $product_type = sql_query("SELECT meno FROM product_type WHERE id=" . sec_sql(sec_input($data["product_type_all"][$i])) . " LIMIT 1");
        $product_type = $product_type[0];
        $product = sql_query("SELECT id, meno FROM product WHERE id=" . sec_sql(sec_input($data["product_all"][$i])) . " LIMIT 1")[0];
        $message .= hidden("id[]", $data["id_all"][$i]);
        $options_str = array();
        //var_dump($data);
        if (!isset($data["product_atribute_options_all"][$i]) or empty($data["product_atribute_options_all"][$i])) {
            $data["product_atribute_options_all"][$i] = array();
        }
        $option_c_hladina = 1;
        foreach ($data["product_atribute_options_all"][$i] 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) . ")";
        $message .= "<td class=\"form_nazov_siroky\">" . $product_type["meno"] . " " . $product["meno"] . "" . $options_str . "" . (empty($data["atyp_text_all"][$i]) ? "" : "<br>Atyp: " . sec_input($data["atyp_text_all"][$i])) . "</td>";
        $product_delivery = sql_query("SELECT meno FROM product_delivery WHERE id=" . sec_sql(sec_input($data["product_delivery_all"][$i])) . " LIMIT 1");
        $product_delivery = $product_delivery[0];
        $message .= "<td class=\"form_ks\">" . sec_input($data["ks_all"][$i]) . " ks</td>";
        $message .= "<td class=\"form_hrana\">" . $product_delivery["meno"] . "</td>";
        $message .= hidden("ks[]", $data["ks_all"][$i]);
        if (empty($data[product_price_all][$i])) {
            $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];
            $product_price = $product_prices[cena];
        } else {
            $product_price = $data[product_price_all][$i];
        }
        $product_ks_sum = $product_ks_sum + sec_input($data["ks_all"][$i]);
        $product_price_sum = $product_price * sec_input($data["ks_all"][$i]);
        $message .= hidden("id_cp_product[]", $product_prices[id]);
        // spocitanie ceny spolu za vsetky produkty
        $products_prices_sums = $products_prices_sums + $product_price_sum;
        $zlava_E = $product_price_sum * $data[zlava_all][$i] / 100;
        $po_zlave = $product_price_sum - $zlava_E;
        $po_zlave_sum = $po_zlave_sum + $po_zlave;
        if (!empty($data["atyp_text_all"][$i])) {
            $product_price = $data[product_price_all][$i] . " €";
        } else {
            $product_price = $product_price . " €";
        }
        $message .= "<td class=\"form_nazov ali-center product-price\">" . $product_price . "</td>";
        $message .= "<td class=\"form_nazov ali-center\"><span class=\"cena-spolu-product\">" . $product_price_sum . "</span> €</td>";
        $message .= "<td class=\"form_nazov ali-center\"><span class=\"zlava-E bold\">" . ($zlava_E > 0 ? "-" . $zlava_E . " €" : "") . "</span>" . ($data[zlava_all][$i] > 0 ? " (" . $data[zlava_all][$i] . "%)" : "") . "</td>";
        $message .= "<td class=\"form_nazov ali-center po-zlave-sum bold\">" . $po_zlave . " €</td>";
        $message .= "</tr>";
    }
    $message .= "<tr class=\"cp_spolu bold\">\r\n                            <td></td>\r\n                            <td>Spolu:</td>\r\n                            <td class=\"ali-center\">" . $product_ks_sum . " ks</td>\r\n                            <td></td>\r\n                            <td></td>\r\n                            <td class=\"ali-center\">" . $products_prices_sums . " €</td>\r\n                            <td></td>\r\n                            <td class=\"ali-center po-zlave-sum-all\">" . $po_zlave_sum . " €</td>\r\n                            \r\n                    <tr>";
    $message .= "</table></div>";
    $message .= "</table><br><br>";
    $message .= "email vytvorený: " . date("j. n. Y - H:i") . "<br>";
    $message .= "</body></html>";
    mysql_query("COMMIT");
    //echo $message;
    //dd("");
    if ($data["email"] != $email_to) {
        $email_to = $data["email"];
        $email_subject = "Cenová ponuka k objednávke č. " . $data_obj["c_obj"] . " / " . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
        $headers = "From: \"" . def_value("default_firma", "hodnota") . "\" <" . def_value("default_email", "hodnota") . ">\r\n";
        $headers .= "Reply-To: " . def_value("default_email", "hodnota") . "\r\n";
        //$headers .= "CC: scooti@stonline.sk\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->CharSet = "UTF-8";
        $mail->SMTPDebug = 0;
        $mail->SMTPAuth = true;
        //$mail->SMTPSecure = 'ssl';
        $mail->Host = def_value("default_email_host", "hodnota");
        $mail->Port = def_value("default_email_port", "hodnota");
        $mail->Username = def_value("default_email_username", "hodnota");
        $mail->Password = def_value("default_email_password", "hodnota");
        $mail->isHTML(true);
        $mail->setLanguage('sk', 'language/');
        $mail->SetFrom(def_value("default_email", "hodnota"), def_value("default_firma", "hodnota"));
        $mail->Subject = $email_subject;
        $mail->Body = $message;
        $mail->AddAddress($email_to);
        $mail->Send();
        //mail($email_to, $email_subject, $message, $headers);
        //var_dump($email_to);
        //var_dump($data["email"]);
    }
    echo "Email bol úspešne odoslaný na adresu: {$email_to}";
}
예제 #4
0
function edit($table, $vyber, $sub, $id, $page = 1)
{
    $error_msg = array();
    if ($_POST[submit]) {
        //var_dump($_POST);
        //exit();
        $meno = sec_sql(sec_input($_POST["meno"]));
        $adresa = sec_sql(sec_input($_POST["adresa"]));
        $mesto = sec_sql(sec_input($_POST["mesto"]));
        $psc = sec_sql(sec_input($_POST["psc"]));
        $ico = sec_sql(sec_input($_POST["ico"]));
        $dic = sec_sql(sec_input($_POST["dic"]));
        $doruc_meno = sec_sql(sec_input($_POST["doruc_meno"]));
        $doruc_adresa = sec_sql(sec_input($_POST["doruc_adresa"]));
        $doruc_mesto = sec_sql(sec_input($_POST["doruc_mesto"]));
        $doruc_psc = sec_sql(sec_input($_POST["doruc_psc"]));
        $doruc_telefon = sec_sql(sec_input($_POST["doruc_telefon"]));
        $telefon = sec_sql(sec_input($_POST["telefon"]));
        $skupina = sec_sql(sec_input($_POST["skupina"]));
        $id_perm_uroven = sec_sql(sec_input($_POST["id_perm_uroven"]));
        $email = sec_sql(sec_input($_POST["email"]));
        $email2 = sec_sql(sec_input($_POST["email2"]));
        $old_password = sec_sql(sec_input($_POST["old_password"]));
        $password = sec_sql(sec_input($_POST["password"]));
        $password_confirm = sec_sql(sec_input($_POST["password_confirm"]));
        $id_product_type = sec_sql(sec_input($_POST["product_type"]));
        $id_product = sec_sql(sec_input($_POST["product"]));
        $montazny_balik = sec_sql(sec_input($_POST["montazny_balik"]));
        $ean = sec_sql(sec_input($_POST["ean"]));
        $id_product_atribute = sec_sql(sec_input($_POST["product_atribute"]));
        $c_hladina = sec_sql(sec_input($_POST["c_hladina"]));
        if (isset($_POST["product_types"])) {
            foreach ($_POST["product_types"] as $product_t) {
                $product_types[] = sec_sql(sec_input($product_t));
            }
        }
        if (isset($_POST["product_packages"])) {
            foreach ($_POST["product_packages"] as $product_p) {
                $product_packages[] = sec_sql(sec_input($product_p));
            }
        }
        $id = sec_sql(sec_input($_POST["id"]));
        $zobraz_vo_formulari = intval(sec_sql(sec_input($_POST["zobraz_vo_formulari"])));
        $skryt_zakaznikom = intval(sec_sql(sec_input($_POST["skryt_zakaznikom"])));
        $skryt_prihlasenym = intval(sec_sql(sec_input($_POST["skryt_prihlasenym"])));
        $def = intval(sec_sql(sec_input($_POST["def"])));
        $skryt_atributy = intval(sec_sql(sec_input($_POST["skryt_atributy"])));
        //var_dump($_POST);
        //exit();
        if ($table != "ean") {
            if (strlen($meno) > 30 or strlen($meno) < 1) {
                $error_msg[] = "Meno môže mať od 1 do 30 znakov";
            }
        }
        if ($table == "ean") {
            if (strlen($ean) > 13 or strlen($ean) < 13) {
                $error_msg[] = "EAN kód môže mať iba 13 znakov";
            }
            $code = "2-" . $id_product . "-" . $id_product_atribute;
            $before = sql_query("SELECT code from {$table} WHERE id=" . $id)[0]["code"];
            $exist = 0;
            if ($code == $before) {
                $exist = 0;
            } else {
                $exists = sql_query("SELECT id from {$table} WHERE code=\"{$code}\"");
                if (count($exists) > 0) {
                    $exist = 1;
                }
            }
            //dd($exists);
            if ($exist == 1) {
                $error_msg[] = "Tento produkt sa už nachádza v databáze";
            }
        }
        if ($table == "hrana") {
            //var_dump($zobraz_vo_formulari);
            if ($zobraz_vo_formulari < 0) {
                $error_msg[] = "Zobraz vo formulari ma nesprávnu hodnotu";
            }
            if (strlen($hodnota_csv) > 5 or strlen($hodnota_csv) < 1) {
                $error_msg[] = "hodnota pre csv je povinný údaj a môže mať 5 znakov";
            }
        }
        if ($table == "dekor") {
            if ($_FILES["subor"]["name"]) {
                $file_c = count($_FILES["subor"]["name"]);
                if (!empty($_FILES["subor"]["name"]) and strlen($_FILES["subor"]["name"]) > 4) {
                    //echo "ok<br>";
                    $data[file_ext] = strtolower(end(explode(".", $_FILES["subor"]["name"])));
                    $data[file_name] = $id;
                    $data[file_name_old] = $_FILES["subor"]["name"];
                    $data[file_tmp_name] = $_FILES["subor"]["tmp_name"];
                    $data[file_size] = $_FILES["subor"]["size"];
                    //echo "ok<br>";
                }
                $form_data_file = array("file_name" => $data[file_name], "file_ext" => $data[file_ext], "file_size" => $data[file_size]);
                $file_validate = dekor_img_validate($form_data_file);
            }
            if (count($file_validate) > 0) {
                foreach ($file_validate as $message) {
                    $error_msg[] = $message;
                }
            }
        }
        if ($table == "uzivatel") {
            //var_dump($skupina);
            if (!is_numeric($skupina) or empty($skupina)) {
                $error_msg[] = "skupina ma nesprávnu hodnotu";
            }
            //if(!is_numeric($id_c_hladina) or empty($id_c_hladina)) $error_msg[] = "cenova hladina ma nesprávnu hodnotu";
            if ($skupina == 2) {
                if (strlen($email) > 50 or strlen($email) < 8) {
                    $error_msg[] = "email je povinný údaj a môže mať od 8 do 50 znakov";
                }
                if (strlen($adresa) > 40 or strlen($adresa) < 6) {
                    $error_msg[] = "adresa je povinný údaj a môže mať od 8 do 50 znakov";
                }
                if (strlen($telefon) > 20 or strlen($telefon) < 5) {
                    $error_msg[] = "telefon je povinný údaj a môže mať od 8 do 50 znakov";
                }
                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                    $error_msg[] = "email je v nesprávnom tvare";
                }
            }
            if (!is_numeric($id) or empty($id)) {
                $error_msg[] = "ID ma nesprávnu hodnotu";
            }
            if (!empty($password) and !empty($old_password) and !empty($password_confirm)) {
                $old_password_original = sql_query("SELECT heslo FROM {$table} WHERE id={$id} AND heslo=\"" . md5($old_password) . "\" LIMIT 1");
                if (count($old_password_original) < 1) {
                    $error_msg[] = "Staré heslo nie je správne";
                }
                if (strlen($password) < 4 or strlen($password) > 30) {
                    $error_msg[] = "Heslo môže mať od 5 do 30 znakov";
                }
                if ($password != $password_confirm) {
                    $error_msg[] = "Heslá nie sú identické";
                }
            }
        }
        //var_dump($error_msg);
        if (empty($error_msg)) {
            $query = "UPDATE {$table}\r\n                      SET meno = \"{$meno}\" \r\n                      WHERE id = {$id}";
            if ($table == "product_type") {
                $query = "UPDATE {$table}\r\n                      SET meno = \"{$meno}\", skryt_zakaznikom=\"{$skryt_zakaznikom}\", def=\"{$def}\"\r\n                      WHERE id = {$id}";
            }
            if ($table == "product") {
                $query = "UPDATE {$table}\r\n                      SET meno = \"{$meno}\", id_product_type=\"{$id_product_type}\", montazny_balik = \"{$montazny_balik}\",\r\n                          skryt_zakaznikom=\"{$skryt_zakaznikom}\", skryt_prihlasenym=\"{$skryt_prihlasenym}\", skryt_atributy = \"{$skryt_atributy}\", def=\"{$def}\"\r\n                      WHERE id = {$id}";
            }
            if ($table == "product_delivery") {
                $query = "UPDATE {$table}\r\n                      SET meno = \"{$meno}\", skryt_zakaznikom=\"{$skryt_zakaznikom}\", def=\"{$def}\"\r\n                      WHERE id = {$id}";
            }
            if ($table == "product_atribute") {
                $query = "UPDATE {$table}\r\n                      SET meno = \"{$meno}\", skryt_zakaznikom=\"{$skryt_zakaznikom}\", def=\"{$def}\"\r\n                      WHERE id = {$id}";
            }
            if ($table == "ean") {
                $query = "UPDATE {$table}\r\n                      SET code = \"{$code}\", ean=\"{$ean}\"\r\n                      WHERE id = {$id}";
            }
            if ($table == "product_atribute_option") {
                $query = "UPDATE {$table}\r\n                      SET meno = \"{$meno}\", id_product_atribute=\"{$id_product_atribute}\",\r\n                          id_c_hladina = \"{$c_hladina}\", skryt_zakaznikom=\"{$skryt_zakaznikom}\", def=\"{$def}\"\r\n                      WHERE id = {$id}";
            }
            if ($table == "cp_abs_vyrobca") {
                $query = "UPDATE {$table}\r\n                      SET meno = \"{$meno}\"\r\n                      WHERE id = {$id}";
            }
            if ($table == "dekor") {
                if (empty($stvorakov) or $stvorakov <= 0) {
                    $stvorakov = def_value("default_stvorak", "hodnota");
                }
                $hodnota = rep_dia($hodnota, 1);
                $query = "UPDATE {$table}\r\n                      SET meno = \"{$meno}\", hodnota = \"{$hodnota}\", id_material=\"{$id_material}\", id_vyrobca=\"{$id_vyrobca}\",\r\n                          stvorakov=\"{$stvorakov}\", kubikov=\"{$kubikov}\", skryt_zakaznikom=\"{$skryt_zakaznikom}\"\r\n                      WHERE id = {$id}";
                if ($data) {
                    $directory = "assets/images/dekor/";
                    if (!file_exists($directory)) {
                        mkdir($directory, 0777, true);
                    }
                    $filename = $data["file_tmp_name"];
                    $max_size = 250;
                    // percentage of resize
                    // Content type
                    //header('Content-type: image/jpeg');
                    // Get new dimensions
                    list($width, $height) = getimagesize($filename);
                    if ($width > $height) {
                        $percent = $max_size / $width;
                        $new_width = $max_size;
                        $new_height = $height * $percent;
                    } else {
                        $percent = $max_size / $height;
                        $new_height = $max_size;
                        $new_width = $width * $percent;
                    }
                    // Resample
                    $image_p = imagecreatetruecolor($new_width, $new_height);
                    $image = imagecreatefromjpeg($filename);
                    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
                    // Output
                    imagejpeg($image_p, $directory . "/" . $data["file_name"] . "." . $data["file_ext"], 100);
                    move_uploaded_file($data["file_tmp_name"], $directory . "/orig_" . $data["file_name"] . "." . $data["file_ext"]);
                    //exit();
                }
            }
            if ($table == "uzivatel") {
                if (empty($password) or empty($old_password) or empty($password_confirm)) {
                    $query = "UPDATE {$table}\r\n                          SET meno = \"{$meno}\", adresa = \"{$adresa}\", mesto = \"{$mesto}\", ico = \"{$ico}\", \r\n                              psc = \"{$psc}\", dic = \"{$dic}\", doruc_meno = \"{$doruc_meno}\",  \r\n                              doruc_adresa = \"{$doruc_adresa}\", doruc_mesto = \"{$doruc_mesto}\",\r\n                              doruc_psc = \"{$doruc_psc}\", doruc_telefon = \"{$doruc_telefon}\",\r\n                              email = \"{$email}\", email2 = \"{$email2}\", telefon = \"{$telefon}\", skupina = \"{$skupina}\",\r\n                              perm_uroven_id = \"{$id_perm_uroven}\"\r\n                          WHERE id = {$id}";
                } else {
                    $password = md5($password);
                    $query = "UPDATE {$table}\r\n                          SET meno = \"{$meno}\", adresa = \"{$adresa}\", mesto = \"{$mesto}\", ico = \"{$ico}\", \r\n                              psc = \"{$psc}\", dic = \"{$dic}\", doruc_meno = \"{$doruc_meno}\",  \r\n                              doruc_adresa = \"{$doruc_adresa}\", doruc_mesto = \"{$doruc_mesto}\",\r\n                              doruc_psc = \"{$doruc_psc}\", doruc_telefon = \"{$doruc_telefon}\",\r\n                              email = \"{$email}\", email2 = \"{$email2}\", telefon = \"{$telefon}\", skupina = \"{$skupina}\",\r\n                              perm_uroven_id = \"{$id_perm_uroven}\" heslo = \"{$password}\"\r\n                          WHERE id = {$id}";
                }
            }
            sql_update($query);
            if ($table == "product_atribute") {
                $exists = sql_delete("DELETE from product_atribute_product_types\r\n                                WHERE id_product_atribute = {$id} \r\n                                ");
                foreach ($product_types as $product_type) {
                    sql_insert("INSERT INTO product_atribute_product_types \r\n                                (id_product_atribute, id_product_type)\r\n                                VALUES\r\n                                ({$id}, {$product_type})\r\n                                ");
                }
            }
            if ($table == "product_delivery") {
                $exists = sql_delete("DELETE from product_delivery_product_types\r\n                                WHERE id_product_delivery = {$id} \r\n                                ");
                foreach ($product_types as $product_type) {
                    sql_insert("INSERT INTO product_delivery_product_types \r\n                                (id_product_delivery, id_product_type)\r\n                                VALUES\r\n                                ({$id}, {$product_type})\r\n                                ");
                }
            }
            if ($table == "product") {
                $exists = sql_delete("DELETE from product_packages\r\n                                WHERE id_product = {$id} \r\n                                ");
                foreach ($product_packages as $package) {
                    sql_insert("INSERT INTO product_packages \r\n                                (id_product, meno)\r\n                                VALUES\r\n                                ({$id}, \"{$package}\")\r\n                                ");
                }
            }
            //echo $id_perm_uroven;
            header("location: index.php?vyber=nastavenia&sub={$table}&page={$page}");
            exit;
        } else {
            echo "<div id=error_message>" . implode("<br>", $error_msg) . "</div>";
        }
    }
    $id = sec_sql($id);
    $query = "Select id, meno from " . PREFIX . "{$table} WHERE id={$id}";
    if ($table == "product_type") {
        $query = "Select id, meno, skryt_zakaznikom, def from {$table} WHERE id={$id}";
    }
    if ($table == "product") {
        $query = "Select id, id_product_type, meno, montazny_balik, skryt_zakaznikom, skryt_prihlasenym, skryt_atributy, def from {$table} WHERE id={$id}";
    }
    if ($table == "ean") {
        $query = "Select id, code, ean from {$table} WHERE id={$id}";
    }
    if ($table == "product_delivery") {
        $query = "Select id, meno, skryt_zakaznikom, def from {$table} WHERE id={$id}";
    }
    if ($table == "product_atribute") {
        $query = "Select id, meno, skryt_zakaznikom, def from {$table} WHERE id={$id}";
    }
    if ($table == "product_atribute_option") {
        $query = "Select id, id_product_atribute, id_c_hladina, meno, skryt_zakaznikom, def from {$table} WHERE id={$id}";
    }
    if ($table == "cp_abs_vyrobca") {
        $query = "Select id, meno from {$table} WHERE id={$id}";
    }
    if ($table == "dekor") {
        $query = "Select id, id_material, id_vyrobca, hodnota, meno, stvorakov, kubikov, skryt_zakaznikom from {$table} WHERE id={$id}";
    }
    if ($table == "hrana") {
        $query = "Select id, hodnota, hodnota_csv, meno, zobraz_vo_formulari from {$table} WHERE id={$id}";
    }
    if ($table == "hrubka") {
        $query = "Select id, hodnota, meno, id_material from {$table} WHERE id={$id}";
    }
    if ($table == "uzivatel") {
        $query = "Select id, meno, adresa, mesto, psc, ico, dic, telefon, email, email2,\r\n            doruc_meno, doruc_adresa, doruc_mesto, doruc_psc, doruc_telefon, skupina, perm_uroven_id \r\n            FROM {$table} WHERE id={$id}";
    }
    $value = sql_query($query);
    $value = $value[0];
    echo "<form method=\"POST\" enctype=\"multipart/form-data\" class=\"nastavenia_form\">";
    echo hidden("id", $value[id]);
    if ($table != "ean") {
        echo textfield("meno", $value[meno], "Meno", 50, 30);
    }
    if ($table == "product_type") {
        $zorad = array(1 => "navrchu", 0 => "normálne");
        echo select("def", "poradie", "", $value[def], "", "", "", "NO", $zorad);
        $zobraz_vo = array(1 => "skryť", 0 => "zobraz");
        echo select("skryt_zakaznikom", "zobraz zákazníkom", "", $value[skryt_zakaznikom], "", "", "", "NO", $zobraz_vo);
    }
    if ($table == "ean") {
        $arr = explode("-", $value["code"]);
        echo select("product", "Produkt", "SELECT id, meno FROM product WHERE vymaz=0 AND id_product_type=2 ORDER BY meno ASC", $arr[1], "-vyberte si-", "", "", "NO");
        echo select("product_atribute", "rozmer", "SELECT id, meno FROM product_atribute_option WHERE id_product_atribute=2 AND vymaz=0 ORDER BY def DESC, meno ASC", $arr[2], "-vyberte si-", "", "", "NO");
        echo textfield("ean", $value["ean"], "EAN *", 13, 16);
    }
    if ($table == "product") {
        echo select("product_type", "Typ produktu", "SELECT id, meno FROM product_type WHERE vymaz=0", $value[id_product_type]);
        $zorad = array(1 => "navrchu", 0 => "normálne");
        echo select("def", "poradie", "", $value[def], "", "", "", "NO", $zorad);
    }
    if ($table == "product") {
        $zobraz_vo = array(1 => "skryť", 0 => "zobraz");
        echo select("skryt_zakaznikom", "zobraz zákazníkom", "", $value[skryt_zakaznikom], "", "", "", "NO", $zobraz_vo);
        echo select("skryt_prihlasenym", "zobraz prihláseným", "", $value[skryt_prihlasenym], "", "", "", "NO", $zobraz_vo);
        echo select("skryt_atributy", "zobraz atribúty", "", $value[skryt_atributy], "", "", "", "NO", $zobraz_vo);
        echo textfield("montazny_balik", $value[montazny_balik], "Mont. balík", 20, 15);
        $product_packages = sql_query("SELECT id, meno FROM product_packages WHERE id_product={$id}");
        echo '<div class="input_fields_wrap">';
        $count = 1;
        //var_dump($product_packages);
        if (count($product_packages) > 0) {
            foreach ($product_packages as $package) {
                echo "<div><label>Balenie</label><input type=\"text\" name=\"product_packages[]\" size=15 maxlength=25 value=\"{$package["meno"]}\"><a href=\"#\" class=\"remove_field\">X</a></div>";
                $count = $count + 1;
            }
        } else {
            echo '<div><label>Balenie</label><input type="text" name="product_packages[]" size=15 maxlength=25><a href="#" class="remove_field">X</a></div>';
        }
        echo "</div>";
        echo '<button class="add_field_button">Vlož ďalšie balenie</button>';
    }
    if ($table == "product_atribute") {
        //echo select("product_type", "Typ produktu", "SELECT id, meno FROM product_type WHERE vymaz=0", $value[id_product_type]);
        $zorad = array(1 => "navrchu", 0 => "normálne");
        echo select("def", "poradie", "", $value[def], "", "", "", "NO", $zorad);
        $selected = sql_query("SELECT id_product_type from product_atribute_product_types\r\n                                WHERE id_product_atribute = {$id}\r\n                                ");
        foreach ($selected as $select) {
            $sel[] = $select[id_product_type];
        }
        $product_types = sql_query("SELECT id, meno FROM product_type WHERE vymaz=0");
        foreach ($product_types as $product_type) {
            $checked = in_array($product_type["id"], $sel) ? "checked" : "";
            echo "<input type=\"checkbox\" name=\"product_types[]\" value=\"{$product_type["id"]}\" {$checked}>{$product_type["meno"]}<br>";
        }
    }
    if ($table == "product_delivery") {
        //echo select("product_type", "Typ produktu", "SELECT id, meno FROM product_type WHERE vymaz=0", $value[id_product_type]);
        $zorad = array(1 => "navrchu", 0 => "normálne");
        echo select("def", "poradie", "", $value[def], "", "", "", "NO", $zorad);
        $selected = sql_query("SELECT id_product_type from product_delivery_product_types\r\n                                WHERE id_product_delivery = {$id}\r\n                                ");
        foreach ($selected as $select) {
            $sel[] = $select[id_product_type];
        }
        $product_types = sql_query("SELECT id, meno FROM product_type WHERE vymaz=0");
        foreach ($product_types as $product_type) {
            $checked = in_array($product_type["id"], $sel) ? "checked" : "";
            echo "<input type=\"checkbox\" name=\"product_types[]\" value=\"{$product_type["id"]}\" {$checked}>{$product_type["meno"]}<br>";
        }
    }
    if ($table == "product_atribute_option") {
        echo select("product_atribute", "Filtruj Atribút", "SELECT a.id as id, a.meno as meno \r\n                       FROM product_atribute as a                       \r\n                    WHERE a.vymaz=0 ORDER BY a.meno", $value[id_product_atribute]);
        echo select("c_hladina", "Cen. hladina", "SELECT id, meno FROM c_hladina WHERE vymaz=0", $value[id_c_hladina], "", "", "", "NO");
        $zorad = array(1 => "navrchu", 0 => "normálne");
        echo select("def", "poradie", "", $value[def], "", "", "", "NO", $zorad);
    }
    if ($table == "vyrobca") {
        $zobraz_vo = array(1 => "skryť", 0 => "zobraz");
        echo select("skryt_zakaznikom", "zobraz zákaznikom", "", $value[skryt_zakaznikom], "", "", "", "NO", $zobraz_vo);
    }
    if ($table == "dekor") {
        echo select("id_material", "Materiál", "SELECT id, hodnota, meno FROM material WHERE vymaz=0", $value[id_material]);
        echo select("vyrobca", "Výrobca", "SELECT id, hodnota, meno FROM vyrobca WHERE vymaz=0", $value[id_vyrobca]);
        $zobraz_vo = array(1 => "skryť", 0 => "zobraz");
        echo select("skryt_zakaznikom", "zobraz zákaznikom", "", $value[skryt_zakaznikom], "", "", "", "NO", $zobraz_vo);
        file_upload("subor", "subor", "Príloha");
        if (isset($_GET["rotate"])) {
            $rotate = sec_input($_GET["rotate"]);
        }
        if ($rotate == 1) {
            $rotateFilename = "assets/images/dekor/{$value[id]}.jpg";
            // PATH
            if (file_exists($rotateFilename)) {
                $degrees = 90;
                //header('Content-type: image/jpeg');
                $source = imagecreatefromjpeg($rotateFilename);
                // Rotate
                $rotate = imagerotate($source, $degrees, 0);
                imagejpeg($rotate, $rotateFilename, 100);
                imagedestroy($source);
                imagedestroy($rotate);
                //echo "ok";
            }
        }
        if (file_exists("assets/images/dekor/{$value[id]}.jpg")) {
            echo "<img src=\"assets/images/dekor/{$value[id]}.jpg?rand=" . microtime() . "\">";
            echo "<br><a href=\"?vyber={$vyber}&sub={$sub}&action=edit&id={$id}&page={$page}&rotate=1\">Otočiť obrázok o 90st doprava</a>";
        }
    }
    if ($table == "uzivatel") {
        if ($id == 1) {
            echo "<strong>Nie je možné upravovať hlavného administrátora!</strong>";
            die;
        }
        echo textfield("adresa", $value[adresa], "adresa", 40, 20);
        echo textfield("mesto", $value[mesto], "Mesto", 50, 20);
        echo textfield("psc", $value[psc], "PSČ", 50, 20);
        echo textfield("ico", $value[ico], "IČO", 15, 20);
        echo textfield("dic", $value[dic], "DIČ", 15, 20);
        echo textfield("doruc_meno", $value[doruc_meno], "Meno doručenia", 40, 20);
        echo textfield("doruc_adresa", $value[doruc_adresa], "Adresa doručenia", 50, 20);
        echo textfield("doruc_mesto", $value[doruc_mesto], "Mesto doručenia", 50, 20);
        echo textfield("doruc_psc", $value[doruc_psc], "PSČ doručenia", 50, 20);
        echo textfield("doruc_telefon", $value[doruc_telefon], "Telefon doručenia", 50, 20);
        echo textfield("telefon", $value[telefon], "telefón", 40, 20);
        echo textfield("email", $value[email], "email", 40, 20);
        echo textfield("email2", $value[email2], "email2", 40, 20);
        echo select("skupina", "Skupina", "SELECT id, meno FROM uzivatel_skupina WHERE vymaz=0", $value[skupina], "", "", "", "NO");
        echo select("id_perm_uroven", "Úroveň zabezp.", "SELECT id, meno FROM perm_uroven WHERE vymaz=0", $value[perm_uroven_id]);
        echo textfield("old_password", $value[password], "Staré heslo", 40, 20);
        echo textfield("password", $value[password], "Nové heslo", 40, 20);
        echo textfield("password_confirm", "", "zopakujte heslo", 40, 20);
    }
    echo submit("submit", "Odoslať");
    echo "<a href=\"?vyber={$vyber}&sub={$sub}\">Späť</a>";
    echo "</form>";
}
예제 #5
0
function display_all_revisions($order)
{
    $objednavka = sql_query("SELECT id, DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, c_obj, id_zakaznik, komplet, vymaz, status, komentar_private \r\n                                 FROM objednavka \r\n                                 WHERE id=\"{$order}\" LIMIT 1");
    $objednavka = $objednavka[0];
    echo "<h1>Objednávka č. {$objednavka['c_obj']} " . (def_value("default_obj_status_spracovana", "hodnota") == $objednavka["status"] ? "<span class=\"red_text paddet\">SPRACOVANÁ</span>" : "") . "</h1>";
    echo "<div class=\"main_box_33\">";
    $access = check_access_true("objednavka_edit");
    if ($access == TRUE) {
        echo "<form method=\"POST\">";
        echo select("zakaznik", "Priradená zákazníkovi", "SELECT id, meno FROM uzivatel WHERE vymaz=0 AND skupina=2 ORDER BY meno", $objednavka[id_zakaznik], "---", "", "");
        echo submit("save_zakaznik", "Priradiť");
        echo "</form>";
    }
    echo "</div>";
    echo "<table id=\"all_revisions\">";
    $revizia = sql_query("\r\n                            SELECT revizia.id, revizia.meno, revizia.adresa, material.meno AS mat_meno,\r\n                                   DATE_FORMAT(revizia.datum, '%d. %m. %Y, %H:%i') AS dat_upr,\r\n                                   vyrobca.meno as vyr_meno, dekor.meno as dek_meno, revizia.dekor_vlastny,\r\n                                   uzivatel.meno as uziv_meno\r\n                            FROM revizia\r\n                            LEFT JOIN material\r\n                            ON revizia.id_material=material.id \r\n                            LEFT JOIN vyrobca\r\n                            ON revizia.id_vyrobca=vyrobca.id\r\n                            LEFT JOIN dekor\r\n                            ON revizia.id_dekor=dekor.id\r\n                            LEFT JOIN uzivatel\r\n                            ON revizia.upravil=uzivatel.id\r\n                            WHERE revizia.id_obj = \"" . $order . "\"\r\n                            ORDER BY revizia.datum DESC\r\n                            ");
    //var_dump($revizia);
    foreach ($revizia as $rev) {
        $is_cp = sql_query("SELECT count(id) as count FROM cp \r\n                            WHERE id_revizia = \"" . $rev[id] . "\"");
        $is_cp = $is_cp[0][count];
        $email_cp = sql_query("SELECT DATE_FORMAT(datum_email, '%d. %m. %Y, %H:%i') AS datum_email_upr FROM cp \r\n                                        WHERE id_revizia = \"" . $rev[id] . "\" AND datum_email <>0 LIMIT 1");
        //$email_cp = count($email_cp);
        //var_dump($email_cp);
        $query_vyroba = "SELECT count(status) status FROM revizia_vyroba WHERE id_obj=" . $order . " AND id_revizia=\"" . $rev[id] . "\" AND status>0";
        $query_vyroba = sql_query($query_vyroba);
        $display_rev = 1;
        if ($access == TRUE) {
            $adressto = "objednavky";
        } else {
            $adressto = "vyroba";
            $filename = "files/csv_new/obj-{$order}/rev-{$rev[id]}/*.csv";
            //var_dump(glob($filename));
            if (glob($filename) != false) {
                $display_rev = 1;
            } else {
                $display_rev = 0;
            }
        }
        //echo $display_rev;
        if ($display_rev > 0) {
            echo "\r\n        <tr>\r\n            <td class=\"obj_cislo\">" . $rev[id] . "</td>\r\n            <td class=\"obj_datum\">\r\n                " . $rev["dat_upr"] . "</td>\r\n            <td class=\"obj_meno\">\r\n                <a href=\"?vyber={$adressto}&order=" . $order . "&revision=" . $rev[id] . "\">\r\n                " . $rev[meno] . "" . (!empty($rev[adresa]) ? ", " . $rev[adresa] : "") . "</a>\r\n            </td>\r\n            <td class=\"obj_material\">\r\n                " . $rev[mat_meno] . "" . (!empty($rev[vyr_meno]) ? ", " . $rev[vyr_meno] : "") . "" . (!empty($rev[dek_meno]) ? ", " . $rev[dek_meno] : "") . "" . (!empty($rev[dekor_vlastny]) ? ", " . $rev[dekor_vlastny] : "") . "</td>\r\n            <td class=\"obj_icons\">" . ($is_cp > 0 ? "<a href=\"?vyber=cp&order={$order}&revision=" . $rev[id] . "&action=display_all\"><img src=\"assets/images/euro.png\" title=\"Objednávka má vypracované Cenové Ponuky: {$is_cp}\"></a>" : "<img src=\"assets/images/euro_no.png\" title=\"Objednávka bez Cenových ponúk\">") . "\r\n             " . (count($email_cp) > 0 ? "<img src=\"assets/images/checked.png\" title=\"CP odoslaná: " . $email_cp[0]["datum_email_upr"] . "\">" : "") . "  \r\n                 <a href=\"?vyber=vyroba&order={$order}&revision=" . $rev[id] . "\">" . ($query_vyroba[0]["status"] > 0 ? "<img src=\"assets/images/vyroba.png\" title=\"Objednávka vo výrobe\">" : "<img src=\"assets/images/vyroba_no.png\" title=\"Bez výroby\">") . "</a>\r\n             " . (!empty($rev["uziv_meno"]) ? "<span class=\"upravil\">" . $rev["uziv_meno"] . "</span>" : "") . "     \r\n            </td>  \r\n                 \r\n        </tr>\r\n        ";
        }
    }
    echo "</table>";
    // zobrazenie detailov objednávky
    echo "<div class=\"new_task_form_poznamka\">";
    echo "<form method=\"POST\" id=\"do_objednavka_poznamka\" action=\"?vyber=objednavky&order={$order}&action=komentar_private\">";
    echo textarea("komentar_private", $objednavka["komentar_private"], "Súkromný komentár k objednávke (nezveréjnene zákazníkom)", 50, 3, "komentar_private");
    echo submit("submit_poznamka", "Odoslať");
    echo "</form>";
    echo "</div>";
    echo "<div class=\"order_details\">\r\n        <div>Objednávka prijatá: {$objednavka['datum']}</div>";
    if ($access == TRUE) {
        echo "<div>" . ($objednavka[komplet] == 0 ? "Objednávka neuzavretá - <a href=\"?vyber=objednavky&order={$order}&action=close\">Uzavrieť</a>" : "Objednávka je kompletná - <a href=\"?vyber=objednavky&order={$order}&action=open\">Otvoriť</a>") . " </div>";
        echo "<div class=\"main_box_33\">";
        echo "<form method=\"POST\">";
        echo select("status", "Stav objednávky:", "SELECT id, meno FROM objednavka_status ORDER BY id", $objednavka[status], "", "", "", "NO");
        echo submit("save_status", "Uložiť stav objednávky");
        echo "</form>";
        echo "</div>";
        echo "<div>" . ($objednavka[vymaz] == 0 ? "<a href=\"?vyber=objednavky&order={$order}&action=delete\">Úplne vymazať objednávku</a>" : "<a href=\"?vyber=objednavky&order={$order}&action=delete\">Zrušiť vymazanie objednávky</a>") . "</div>       \r\n";
    }
    // zobrazenie pridaných súborov
    $files = sql_query("SELECT id_revizia, meno, meno_old, pripona, DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum \r\n                                FROM subor\r\n                                WHERE id_obj=\"{$order}\"");
    echo "<div id=\"added_files\"" . (count($files) > 0 ? " class=\"attatch_exists\"" : "") . ">\r\n                <h2>Všetky nahraté súbory</h2>";
    //var_dump($files);
    for ($i = 0; $i < count($files); $i++) {
        $directory = "files/obj-{$order}/rev-{$files[$i][id_revizia]}";
        echo "revízia č. {$files[$i][id_revizia]} <a href=\"{$directory}/" . $files[$i]["meno"] . "." . $files[$i]["pripona"] . "\" target=\"_blank\">" . $files[$i]["meno_old"] . "</a><br>";
    }
    echo "</div>\r\n                \r\n            ";
    echo "</div>";
}
예제 #6
0
function print_revision_skrine($order, $revision)
{
    $data = sql_query("SELECT meno, adresa, ico_icdph, telefon, email, id_obj,\r\n                                    sirka, vyska, dvere_ks, madlo, farba, hrubka_skrine, svg, komentar\r\n                                    FROM revizia_skrine \r\n                                    WHERE id_obj=\"{$order}\" AND id=\"{$revision}\" \r\n                                    LIMIT 1")[0];
    $data_narez = sql_query("SELECT dvere, predel, sirka, vyska, zrkadlo, lakobel,\r\n                                            vyrobca, dekor, iny_dekor, vertikalne\r\n                                    FROM skrine \r\n                                    WHERE id_revizia=\"{$revision}\"");
    $data["svg"] = base64_decode($data["svg"]);
    //var_dump($data);
    $predel = 1;
    foreach ($data_narez as $row) {
        $data["dvere" . $row["dvere"]]["sirka"] = $row["sirka"];
        $data["dvere" . $row["dvere"]]["predel"][$predel] = ["predel" => $row["predel"], "sirka" => $row["sirka"], "vyska" => $row["vyska"], "zrkadlo" => $row["zrkadlo"], "lakobel" => $row["lakobel"], "vyrobca" => $row["vyrobca"], "dekor" => $row["dekor"], "iny_dekor" => $row["iny_dekor"], "vertikalne" => $row["vertikalne"]];
        $predel = $predel + 1;
    }
    //var_dump($files);
    $data_obj = sql_query("SELECT DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, c_obj, id_zakaznik,\r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM objednavka_skrine \r\n                                    WHERE id=" . $data["id_obj"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    $message = "";
    $message .= "<h1>Objednávka skrine č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . "</h1>";
    $message .= "<h5>zo dňa: " . $data_obj["datum"] . "</h5>";
    $message .= "<div class=\"print_hlavicka\">";
    $message .= "<table class=\"print_dodavatel\"><tr><td></td><td><strong>Dodávateľ</strong></td></tr>";
    $message .= "<tr><td></td><td>" . def_value("default_firma", "hodnota") . "</td></tr>";
    $message .= "<tr><td></td><td>" . def_value("default_adresa", "hodnota") . "</td></tr>";
    $message .= "<tr><td></td><td>" . def_value("default_mesto", "hodnota") . "</td></tr>";
    $message .= "<tr><td>IČO:</td><td>" . def_value("default_ico", "hodnota") . "</td></tr>";
    $message .= "<tr><td>DIČ:</td><td>" . def_value("default_dic", "hodnota") . "</td></tr>";
    $message .= "<tr><td>tel.:</td><td>" . def_value("default_telefon", "hodnota") . "</td></tr>";
    $message .= "<tr><td>mobil:</td><td>" . def_value("default_mobil", "hodnota") . "</td></tr>";
    $message .= "<tr><td>email:</td><td>" . def_value("default_email", "hodnota") . ", " . def_value("default_email_2", "hodnota") . "</td></tr>";
    $message .= "</table>";
    if ($data_obj[id_zakaznik] > 0) {
        $meno_zakaznika = sql_query("SELECT meno, adresa, ico_icdph, telefon, email FROM uzivatel WHERE id={$data_obj['id_zakaznik']} LIMIT 1");
        $meno_zakaznika = $meno_zakaznika[0];
        $data[meno] = $meno_zakaznika[meno];
        $data[adresa] = $meno_zakaznika[adresa];
        $data[ico_icdph] = $meno_zakaznika[ico_icdph];
        $data[telefon] = $meno_zakaznika[telefon];
        $data[email] = $meno_zakaznika[email];
    }
    $message .= "<div class=\"print_odberatel\"><table class=\"print_odberatel\"><tr><td></td><td>Objednávateľ:</td></tr>";
    $message .= "<tr><td></td><td class=\"print_bigger\">" . $data["meno"] . "</td></tr>";
    $message .= "<tr><td></td><td>" . $data["adresa"] . "</td></tr>";
    $message .= "<tr><td>IČO:</td><td>" . $data["ico_icdph"] . "</td></tr>";
    $message .= "<tr><td>tel.:</td><td>" . $data["telefon"] . "</td></tr>";
    $message .= "<tr><td>email:</td><td>" . $data["email"] . "</td></tr>";
    $message .= "</table>";
    $message .= "</div>\r\n                    </div>";
    $message .= "<div class=\"print_hlavicka2\">";
    $message .= "<table>\r\n                     <tr><td>rozmer:</td><td class=\"print_bigger\">" . sec_input($data["sirka"]) . " x " . sec_input($data["vyska"]) . " mm</td></tr>\r\n                     <tr><td>hrúbka:</td><td class=\"print_bigger\">" . sec_input($data["hrubka_skrine"]) . " mm</td></tr>";
    $message .= "<tr><td>počet dverí:</td><td>" . $data["dvere_ks"] . "</td></tr>";
    $madlo = sql_query("SELECT meno, dvere, orez FROM madlo WHERE id=" . sec_sql(sec_input($data["madlo"])) . " LIMIT 1")[0];
    $farba = sql_query("SELECT meno FROM farba WHERE id=" . sec_sql(sec_input($data["farba"])) . " LIMIT 1")[0];
    $message .= "<tr><td>madlo:</td><td class=\"\">" . $madlo["meno"] . " " . $farba["meno"] . "</td></tr>";
    $message .= "</table><br></div>";
    $message .= "<div id=\"snap_skrine_display\">";
    $message .= "" . $data["svg"] . "";
    $message .= "</div>";
    $message .= "<div class=\"print_hlavicka3 print_skrine_vyroba\">";
    $message .= "<table id=\"form_data_table\">";
    $message .= "<tr>\r\n                                <td colspan=2 class=\"print_bigger\">Kusovník pre výrobu</td>                                \r\n                            </tr>";
    for ($i = 1; $i <= $data["dvere_ks"]; $i++) {
        //var_dump($data["dvere".$i]);
        //echo $dvere_rozdiel;
        if ($data["dvere_ks"] > 1) {
            $zmensenie = ($data["sirka"] + $madlo["dvere"] + ($data["dvere_ks"] - 2) * $madlo["orez"]) / $data["dvere_ks"];
            $zmensenie = round($zmensenie, 0);
            //echo "(".$data["sirka"] ." + ". $madlo["dvere"] ." + (". ($data["dvere_ks"]-2) ."*". $madlo["orez"] ."))/".$data["dvere_ks"]."<br>";
        }
        $message .= "<tr>\r\n                     <td class=\"skrine_middle\">{$i}. dvere </td>                \r\n                     <td class=\"form_dvere\">";
        $message .= "<table class=\"predel\">";
        $pr = 1;
        //echo count($data["dvere".$i]["predel"]);
        $dvere_st = round($data["sirka"] / $data["dvere_ks"], 0);
        foreach ($data["dvere" . $i]["predel"] as $key => $predel) {
            $dvere_rozdiel = $dvere_st - $predel["sirka"];
            //echo $dvere_rozdiel;
            $zmensenie = $zmensenie - $dvere_rozdiel;
            $message .= "<tr>";
            $message .= "<td class=\"predel_ks\">" . $predel["predel"] . ". </td>";
            $sirka = $zmensenie;
            if (!empty($predel["zrkadlo"])) {
                $sirka = $zmensenie + 15;
            }
            if (!empty($predel["lakobel"])) {
                $sirka = $zmensenie + 10;
            }
            $rozmer = $predel["vyska"] . " x {$sirka}";
            if ($predel["vertikalne"] > 0) {
                $rozmer = "{$sirka} x " . $predel["vyska"];
            }
            $message .= "<td class=\"predel_middle\"><span class=\"bold\">{$rozmer} mm</span> </td>";
            $message .= "<td class=\"\">";
            if (!empty($predel["zrkadlo"])) {
                $message .= "podkladový materiál / rozmer zrkadla: <span class=\"bold\">" . ($predel["vyska"] - 2) . " x " . ($sirka - 2) . " mm</span>";
            }
            if (!empty($predel["lakobel"])) {
                $message .= "lakobel";
            }
            $dekor_text = array();
            if (!empty($predel["vyrobca"])) {
                $vyrobca = sql_query("SELECT meno FROM vyrobca WHERE id=\"" . sec_sql(sec_input($predel["vyrobca"])) . "\" LIMIT 1")[0];
                $dekor_text[] = $vyrobca["meno"];
            }
            if (!empty($predel["dekor"])) {
                $dekor = sql_query("SELECT meno FROM dekor WHERE id=" . sec_sql(sec_input($predel["dekor"])) . " LIMIT 1")[0];
                $dekor_text[] = $dekor["meno"];
            }
            if (!empty($predel["iny_dekor"])) {
                $dekor_text[] = $predel["iny_dekor"];
            }
            if (!empty($predel["vertikalne"])) {
                $dekor_text[] = "horizontálne";
            }
            $message .= implode(", ", $dekor_text);
            $message .= "</td>";
            $message .= "</tr>";
            $pr = $pr + 1;
        }
        $message .= "</table>";
        $message .= "</td>";
        $message .= "</tr>";
    }
    $message .= "</table>";
    $message .= "</div>";
    $message .= "<div class=\"form_vypocet_sum\">" . ($vypocet_sum > 0 ? "Spolu: " . round($vypocet_sum, 2) . " m2" : "") . "</div>";
    $message .= "<div class=\"form_vypocet_sum\">";
    if (!empty($vypocet_paska_normal_sum)) {
        foreach ($vypocet_paska_normal_sum as $key => $paska_view) {
            $message .= "{$key} opáskovanie: " . round($paska_view, 2) . " m<br>";
        }
    }
    $message .= "</div>";
    $message .= "<div class=\"form_vypocet_sum_duplak\">" . ($vypocet_duplak_sum > 0 ? "Duplák spracovanie: " . round($vypocet_duplak_sum, 2) . " m2" : "") . "<br>\r\n                                                                " . ($vypocet_paska_sum > 0 ? "Duplák opaskovanie: " . round($vypocet_paska_sum, 2) . " m" : "") . "</div>";
    if (!empty($data["komentar"])) {
        $message .= "<div class=\"print_komentar\">\r\n                    <strong class=\"print_bigger\">Poznámka:</strong><br><br>\r\n                    " . $data["komentar"] . "</div><br><br>";
    }
    if (count($files) > 0) {
        $message .= "<div class=\"print_subory\">\r\n               Počet príloh objednávky: " . count($files) . "<br>";
        for ($i = 0; $i < count($files); $i++) {
            $message .= " - " . $files[$i]["meno_old"] . "<br>";
        }
        $message .= "</div><br><br>";
    }
    $message .= "dokument vytvorený: " . date("j. n. Y - H:i") . "<br><br>";
    return $message;
}
session_start();
$safe = "U,,5Enc!";
$root = $_SERVER['DOCUMENT_ROOT'];
include_once "config/datab.php";
// subor s nastaveniami databaz
include_once "config/fnc.php";
// vloženie hlavičky stránky
if (isset($_GET["select_product_type"])) {
    $skryt_zakaznikom = "AND skryt_zakaznikom=0";
    if ($_SESSION["logged"] == 1) {
        $skryt_zakaznikom = "";
    }
    $product_atribute = sec_sql(sec_input($_GET["select_product_type"]));
    $product = sec_sql(sec_input($_GET["product"]));
    $query = "SELECT pa.id, pa.meno FROM `product_atribute` pa INNER JOIN product_atribute_product_types pt ON pt.id_product_atribute = pa.id\r\n                   WHERE pa.vymaz=0 AND id_product_type=" . (empty($product_atribute) ? def_value("default_product_type", "hodnota") : $product_atribute) . "\r\n                    ORDER BY pa.def DESC, pa.meno";
    $atributes = sql_query($query);
    $key = sec_sql(sec_input($_GET["key"]));
    $query = "SELECT id FROM product \r\n                   WHERE id = {$product} AND skryt_atributy = \"1\" \r\n                    ";
    $producter = sql_query($query);
    //print_r($query);
    if (empty($producter)) {
        foreach ($atributes as $atribute) {
            echo "<div class=\"atribute-row\">";
            echo hidden("product_atribute[]", $atribute[id]);
            echo select("product_atribute_option[{$key}][{$atribute['id']}]", $atribute[meno], "SELECT id, meno FROM product_atribute_option WHERE id_product_atribute=" . $atribute[id] . " AND vymaz=0 ORDER BY def DESC, def DESC, meno ASC", $product_type_all[$i], "-vyberte si-", "product_atribute_option_v", "", "NO");
            echo "</div>";
        }
    }
    //var_dump($_SESSION);
}
예제 #8
0
 //var_dump($id_zakaznik_row);
 //var_dump($id_zakaznik);
 //die();
 $query = "SELECT max(c_obj) c_obj FROM objednavka";
 $c_obj = sql_query($query);
 $c_obj = $c_obj[0]["c_obj"] + 1;
 if (!empty($data["secure_key"])) {
     $obj_id = sql_query("SELECT id_obj FROM objednavka_secure where secure_key=\"" . $data["secure_key"] . "\" LIMIT 1");
     if (count($obj_id) < 1) {
         die("objednavká s týmto kľúčom neexistuje");
     }
     $obj_id = $obj_id[0][id_obj];
     $obj_st = sql_query("SELECT status, DATE_FORMAT(datum, '%Y') AS datum, komplet \r\n                                         FROM objednavka where id=\"{$obj_id}\" LIMIT 1");
     $obj_st = $obj_st[0];
     //var_dump($obj_st);
     if ($obj_st[komplet] == 0 and ($obj_st[status] == 0 or $obj_st[status] == def_value("default_obj_status_rozpracovana", "hodnota"))) {
         if ($status_cp == "") {
             $status_cp = 0;
         }
         sql_update("UPDATE objednavka SET status=\"{$status_cp}\", datum=NOW(), id_zakaznik={$zakaznik_exists['id']}\r\n                            " . ($obj_st[datum] != $rok ? ", c_obj={$c_obj}" : "") . "\r\n                                    WHERE id=\"{$obj_id}\"");
     } else {
         // ak objednávka je uzavretá
         // alebo ak status nie je 0 a rozpracovana
         echo "Vaša objednávka už bola spracovaná / uzavretá a nie je možné ju už upravovať.";
         die;
     }
 } else {
     $query = "INSERT INTO objednavka (datum, c_obj, status {$id_zakaznik_row})\r\n                            VALUES (now(), {$c_obj}, \"{$status_cp}\" {$id_zakaznik})";
     //var_dump($query);
     $sql_objednavka = sql_insert($query);
     $obj_id = $sql_objednavka["inserted_id"];
예제 #9
0
 require_once 'include/PHPMailer/PHPMailerAutoload.php';
 $mail = new PHPMailer();
 //$mail->IsSMTP();
 $mail->CharSet = "UTF-8";
 $mail->SMTPDebug = 0;
 $mail->SMTPAuth = true;
 //$mail->SMTPSecure = 'ssl';
 $mail->Host = def_value("default_email_host", "hodnota");
 $mail->Port = def_value("default_email_port", "hodnota");
 $mail->Username = def_value("default_email_username", "hodnota");
 $mail->Password = def_value("default_email_password", "hodnota");
 $mail->isHTML(true);
 $mail->setLanguage('sk', 'language/');
 $mail->SetFrom(empty($odosielatel) ? def_value("default_email", "hodnota") : $odosielatel["email"], def_value("default_firma", "hodnota"));
 $email_to = $dodavatel["email"];
 $email_subject = "Objednávka od " . def_value("default_firma", "hodnota") . "";
 //$headers = "From: \"".def_value("default_firma", "hodnota")."\" <".def_value("default_email", "hodnota").">\r\n";
 //$headers .= "Reply-To: ".def_value("default_email", "hodnota")."\r\n";
 //$headers .= "CC: scooti@stonline.sk\r\n";
 //$headers .= "MIME-Version: 1.0\r\n";
 //$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
 $mail->Subject = $email_subject;
 $mail->Body = $message;
 $mail->AddAddress($email_to);
 $mail->AddCC($odosielatel["email"]);
 $error = 0;
 if (!$mail->Send()) {
     $error = 1;
     log_email($email_subject, $email_to, "error", $message . "\n" . $mail->ErrorInfo);
 } else {
     log_email($email_subject, $email_to);
예제 #10
0
function send_email_revision_($revision, $only_kraf = "", $status = "")
{
    //var_dump($revision);
    // die();
    require_once 'include/PHPMailer/PHPMailerAutoload.php';
    $email_to_kraf = def_value("default_email", "hodnota");
    mysql_query("BEGIN");
    $data = sql_query("SELECT id_obj, meno, adresa, ico_icdph, telefon, email, id_material as material,\r\n                                    id_vyrobca as vyrobca, id_dekor as dekor, dekor_vlastny, komentar,\r\n                                    DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum\r\n                                    FROM revizia \r\n                                    WHERE id={$revision} \r\n                                    LIMIT 1");
    $data_narez = sql_query("SELECT ks, dlzka, sirka, nazov, poznamka, hrubka, orientacia,\r\n                                    hrana1, hrana2, hrana3, hrana4\r\n                                    FROM porez \r\n                                    WHERE id_revizia={$revision}");
    $data = $data[0];
    $fieldsets_c = count($data_narez);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_narez[$i][ks];
        $dlzka[$i] = $data_narez[$i][dlzka];
        $sirka[$i] = $data_narez[$i][sirka];
        $nazov[$i] = $data_narez[$i][nazov];
        $poznamka[$i] = $data_narez[$i][poznamka];
        $hrubka[$i] = $data_narez[$i][hrubka];
        $orientacia[$i] = $data_narez[$i][orientacia];
        $hrana1[$i] = $data_narez[$i][hrana1];
        $hrana2[$i] = $data_narez[$i][hrana2];
        $hrana3[$i] = $data_narez[$i][hrana3];
        $hrana4[$i] = $data_narez[$i][hrana4];
    }
    $data[ks_all] = $ks;
    $data[dlzka_all] = $dlzka;
    $data[sirka_all] = $sirka;
    $data[nazov_all] = $nazov;
    $data[poznamka_all] = $poznamka;
    $data[hrubka_all] = $hrubka;
    $data[orientacia_all] = $orientacia;
    $data[hrana1_all] = $hrana1;
    $data[hrana2_all] = $hrana2;
    $data[hrana3_all] = $hrana3;
    $data[hrana4_all] = $hrana4;
    //var_dump($data);
    $files = sql_query("SELECT meno, meno_old, pripona \r\n                                FROM subor\r\n                                WHERE id_obj=" . $data["id_obj"] . "");
    //var_dump($data);
    $data_obj = sql_query("SELECT DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, c_obj, status,\r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM objednavka \r\n                                    WHERE id=" . $data["id_obj"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    $secure_key = sql_query("SELECT secure_key\r\n                                    FROM objednavka_secure\r\n                                    WHERE id_obj=" . $data["id_obj"] . " AND \r\n                                          id_revizia={$revision} LIMIT 1");
    $secure_key = $secure_key[0][secure_key];
    $message = "<html><body>";
    $message .= "<img src=\"http://" . def_value("default_url", "hodnota") . "/assets/images/logo.jpg\">";
    $message .= "<h1>Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . "</h1>";
    $message .= "zo dňa: " . $data_obj["datum"] . "<br><br>";
    $message .= "<table><tr>";
    $message .= "<td style=\"width: 400px;\"><strong>Dodávateľ</strong><br>";
    $message .= "<table><tr><td>" . def_value("default_firma", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_adresa", "hodnota") . "<br>" . def_value("default_mesto", "hodnota") . "</td></tr>";
    $message .= "<tr><td>IČO: " . def_value("default_ico", "hodnota") . "<br> DIČ: " . def_value("default_dic", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_telefon", "hodnota") . "<br> " . def_value("default_mobil", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_email", "hodnota") . "<br> " . def_value("default_email_2", "hodnota") . "</td></tr>";
    $message .= "</table><br><br></td>";
    $message .= "<td style=\"width: 50%;\"><strong>Objednávateľ:</strong>";
    $message .= "<table><tr><td>" . $data["meno"] . "</td></tr>";
    $message .= "<tr><td>" . $data["adresa"] . "</td></tr>";
    $message .= "<tr><td>" . $data["ico_icdph"] . "</td></tr>";
    $message .= "<tr><td>" . $data["telefon"] . "</td></tr>";
    $message .= "<tr><td>" . $data["email"] . "</td></tr>";
    $message .= "</table><br><br></td>";
    $message .= "</tr></table>";
    $message .= "<strong>Materiál:</strong>";
    $material = sql_query("SELECT meno FROM material WHERE id=" . sec_sql(sec_input($data["material"])) . " LIMIT 1");
    $material = $material[0];
    $message .= "<table><tr><td>" . $material["meno"] . "</td></tr>";
    $vyrobca = sql_query("SELECT meno FROM vyrobca WHERE id=\"" . sec_sql(sec_input($data["vyrobca"])) . "\" LIMIT 1");
    $vyrobca = $vyrobca[0];
    $dekor = sql_query("SELECT meno FROM dekor WHERE id=" . sec_sql(sec_input($data["dekor"])) . " LIMIT 1");
    $dekor = $dekor[0];
    $message .= "<tr><td>" . $vyrobca["meno"] . " " . $dekor["meno"] . "</td></tr>";
    $message .= "<tr><td>" . $data["dekor_vlastny"] . "</td></tr>";
    $message .= "</table><br><br>";
    $message .= "<table style=\"font-size: 10pt;\">\r\n               <tr style=\"border-bottom: solid 1px darkslategrey ;\">\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\"></th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 40px;\">ks</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 180px;\">rozmer</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 150px;\">Názov</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 150px;\">Poznámka</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 50px;\">hrúbka</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 50px;\">orient.</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\">dolná</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\">pravá</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\">horná</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\">ľava</th>\r\n               </tr>";
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $poradie = 0;
        $poradie = $i + 1;
        $message .= "<tr>\r\n                    <td class=\"form_poradie\">{$poradie}. </td>\r\n                    <td class=\"form_ks\">" . sec_input($data["ks_all"][$i]) . "</td>\r\n                    <td class=\"form_rozmer\">" . sec_input($data["dlzka_all"][$i]) . " x " . $data["sirka_all"][$i] . " mm</td>\r\n                    <td class=\"form_nazov\">" . sec_input($data["nazov_all"][$i]) . "</td>\r\n                    <td class=\"form_nazov\">" . sec_input($data["poznamka_all"][$i]) . "</td>";
        $hrubka = sql_query("SELECT meno FROM hrubka WHERE id=" . sec_sql(sec_input($data["hrubka_all"][$i])) . " LIMIT 1");
        $hrubka = $hrubka[0];
        $message .= "\r\n                    <td class=\"form_hrana\">" . $hrubka["meno"] . "</td>";
        $orientacia = sql_query("SELECT meno FROM orientacia WHERE id=" . sec_sql(sec_input($data["orientacia_all"][$i])) . " LIMIT 1");
        $orientacia = $orientacia[0];
        $message .= "\r\n                    <td class=\"form_hrana\">" . $orientacia["meno"] . "</td>";
        $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana1_all"][$i])) . " LIMIT 1");
        $hrana = $hrana[0];
        $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
        $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana2_all"][$i])) . " LIMIT 1");
        $hrana = $hrana[0];
        $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
        $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana3_all"][$i])) . " LIMIT 1");
        $hrana = $hrana[0];
        $message .= "\r\n                    <td class=\"form_hrana\">" . $hrana[meno] . "</td>";
        $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana4_all"][$i])) . " LIMIT 1");
        $hrana = $hrana[0];
        $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
        $vypocet = $data["dlzka_all"][$i] * $data["sirka_all"][$i] / 1000000;
        $vypocet = $vypocet * $data["ks_all"][$i];
        if (is_duplak($data["hrubka_all"][$i])) {
            $paska = 0;
            if ($data[hrana1_all][$i] > 0) {
                $paska = $paska + $data[dlzka_all][$i];
            }
            if ($data[hrana3_all][$i] > 0) {
                $paska = $paska + $data[dlzka_all][$i];
            }
            if ($data[hrana2_all][$i] > 0) {
                $paska = $paska + $data[sirka_all][$i];
            }
            if ($data[hrana4_all][$i] > 0) {
                $paska = $paska + $data[sirka_all][$i];
            }
            $vypocet_duplak = $data["dlzka_all"][$i] * $data["sirka_all"][$i] / 1000000;
            $vypocet_duplak = $vypocet_duplak * $data["ks_all"][$i];
            $vypocet = ($data["dlzka_all"][$i] + 30) * ($data["sirka_all"][$i] + 30) / 1000000;
            $vypocet = $vypocet * ($data["ks_all"][$i] * 2);
            $vypocet_duplak_sum = $vypocet_duplak_sum + $vypocet_duplak;
            $vypocet_paska_sum = $vypocet_paska_sum + $paska * $data["ks_all"][$i] / 1000;
        } else {
            $hrany = sql_query("SELECT id, meno FROM hrana where vymaz=0 and zobraz_vo_formulari=1");
            //var_dump($hrany);
            foreach ($hrany as $hrana) {
                $paska_normal[$hrana["meno"]] = 0;
                if ($data[hrana1_all][$i] > 0 and $data[hrana1_all][$i] == $hrana["id"]) {
                    $paska_normal[$hrana["meno"]] = $paska_normal[$hrana["meno"]] + $data[dlzka_all][$i];
                }
                if ($data[hrana3_all][$i] > 0 and $data[hrana3_all][$i] == $hrana["id"]) {
                    $paska_normal[$hrana["meno"]] = $paska_normal[$hrana["meno"]] + $data[dlzka_all][$i];
                }
                if ($data[hrana2_all][$i] > 0 and $data[hrana2_all][$i] == $hrana["id"]) {
                    $paska_normal[$hrana["meno"]] = $paska_normal[$hrana["meno"]] + $data[sirka_all][$i];
                }
                if ($data[hrana4_all][$i] > 0 and $data[hrana4_all][$i] == $hrana["id"]) {
                    $paska_normal[$hrana["meno"]] = $paska_normal[$hrana["meno"]] + $data[sirka_all][$i];
                }
                $vypocet_paska_normal_sum[$hrana["meno"]] = $vypocet_paska_normal_sum[$hrana["meno"]] + $paska_normal[$hrana["meno"]] * $data["ks_all"][$i] / 1000;
                //var_dump($paska_normal);
                //var_dump($vypocet_paska_normal_sum);
            }
        }
        $vypocet_sum = $vypocet_sum + $vypocet;
        $vypocet_final = round($vypocet, 2) . " m2";
        //var_dump($vypocet_paska_sum);
        //$message .= "<td class=\"td_vypocet\">".($vypocet>0 ? $vypocet_final : "" )."</td>";
        $message .= "</tr>";
    }
    $message .= "</table><br>";
    $message .= "<div class=\"form_vypocet_sum\">" . ($vypocet_sum > 0 ? "Spolu: " . round($vypocet_sum, 2) . " m2" : "") . "</div>";
    $message .= "<div class=\"form_vypocet_sum\">";
    if (!empty($vypocet_paska_normal_sum)) {
        foreach ($vypocet_paska_normal_sum as $key => $paska_view) {
            $message .= "{$key} opáskovanie: " . round($paska_view, 2) . " m<br>";
        }
    }
    $message .= "</div>";
    $message .= "<div class=\"form_vypocet_sum_duplak\">" . ($vypocet_duplak_sum > 0 ? "Duplák spracovanie: " . round($vypocet_duplak_sum, 2) . " m2" : "") . "<br>\r\n                                                                " . ($vypocet_paska_sum > 0 ? "Duplák opaskovanie: " . round($vypocet_paska_sum, 2) . " m" : "") . "</div>";
    $message .= "<br>" . $data["komentar"] . "<br><br>";
    if (count($files) > 0) {
        $message .= "<div class=\"print_subory\">\r\n               Počet príloh objednávky: " . count($files) . "<br>";
        for ($i = 0; $i < count($files); $i++) {
            $message .= " - " . $files[$i]["meno_old"] . "<br>";
        }
        $message .= "</div><br><br>";
    }
    if ($data_obj["status"] == def_value("default_obj_status_rozpracovana", "hodnota")) {
        $message .= "<h2>Objednávka je uložená a ešte nebola Vami potvrdená.</h2>\r\n                                Pre potvrdenie objednávky, alebo jej ďalšie úpravy kliknite na túto adresu:\r\n                                ";
    } else {
        $message .= "Pre dodatočnú úpravu objednávky použite prosím túto adresu:";
    }
    $message .= "<br><a href=\"http://" . def_value("default_url", "hodnota") . "/?vyber=formular&secure_key={$secure_key}\">\r\n                                    http://" . def_value("default_url", "hodnota") . "/?vyber=formular&secure_key={$secure_key}\r\n                                </a>";
    $message .= "<br>Ak sme už Vašu objednávku spracovali a je v procese výroby, jej úpravy už nie su možné.<br>\r\n                         <br><br>";
    $message .= "email vytvorený: " . date("j. n. Y - H:i") . "<br>";
    $message .= "</body></html>";
    mysql_query("COMMIT");
    $headers = "From: \"" . $data["meno"] . "\" <" . $data["email"] . ">\r\n";
    $headers .= "Reply-To: " . $data["email"] . "\r\n";
    //$headers .= "CC: scooti@stonline.sk\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    $mail = new PHPMailer();
    //$mail->IsSMTP();
    $mail->CharSet = "UTF-8";
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    //$mail->SMTPSecure = 'ssl';
    $mail->Host = def_value("default_email_host", "hodnota");
    $mail->Port = def_value("default_email_port", "hodnota");
    $mail->Username = def_value("default_email_username", "hodnota");
    $mail->Password = def_value("default_email_password", "hodnota");
    $mail->isHTML(true);
    $mail->setLanguage('sk', 'language/');
    $mail->SetFrom(def_value("default_email", "hodnota"), def_value("default_firma", "hodnota"));
    if (!empty($status) and $status == "rozpracovana") {
        $email_to = $data["email"];
        $email_subject = "Rozpracovaná Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
        $headers = "From: \"" . def_value("default_firma", "hodnota") . "\" <" . def_value("default_email", "hodnota") . ">\r\n";
        $headers .= "Reply-To: " . def_value("default_email", "hodnota") . "\r\n";
        //$headers .= "CC: scooti@stonline.sk\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
        $mail->Subject = $email_subject;
        $mail->Body = $message;
        $mail->AddAddress($email_to);
        $mail->Send();
        //mail($email_to, $email_subject, $message, $headers);
    } else {
        $email_to = $email_to_kraf;
        $email_subject = "Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " od " . $data["meno"] . " - " . def_value("default_firma", "hodnota") . "";
        if (!empty($status) and $status == "cp") {
            $email_subject = "Žiadosť o Cenovú ponuku pre objednávku č. " . $data_obj["c_obj"] . " od " . $data["meno"] . " - " . def_value("default_firma", "hodnota") . "";
        }
        $mail->Subject = $email_subject;
        $mail->Body = $message;
        $mail->AddAddress($email_to);
        $mail->Send();
        //mail($email_to, $email_subject, $message, $headers);
        //var_dump($email_to);
        //var_dump($data["email"]);
        if ($only_kraf != 1 and $data["email"] != $email_to) {
            $email_to = $data["email"];
            $email_subject = "Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
            if (!empty($status) and $status == "cp") {
                $email_subject = "Žiadosť o Cenovú ponuku pre objednávku č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
            }
            $headers = "From: \"" . def_value("default_firma", "hodnota") . "\" <" . def_value("default_email", "hodnota") . ">\r\n";
            $headers .= "Reply-To: " . def_value("default_email", "hodnota") . "\r\n";
            //$headers .= "CC: scooti@stonline.sk\r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
            //mail($email_to, $email_subject, $message, $headers);
            $mail->clearAddresses();
            $mail->Subject = $email_subject;
            $mail->Body = $message;
            $mail->AddAddress($email_to);
            $mail->Send();
            //var_dump($email_to);
            //var_dump($data["email"]);
        }
    }
    echo "Email bol úspešne odoslaný na adresu: {$email_to}";
}
예제 #11
0
$vyrobca = sql_query("SELECT meno FROM vyrobca WHERE id=\"" . sec_sql(sec_input($data["vyrobca"])) . "\" LIMIT 1");
$vyrobca = $vyrobca[0];
$dekor = sql_query("SELECT meno FROM dekor WHERE id=" . sec_sql(sec_input($data["dekor"])) . " LIMIT 1");
$dekor = $dekor[0];
$message .= "<tr><td>dekor:</td><td class=\"print_bigger\">" . $vyrobca["meno"] . " " . $dekor["meno"] . "</td></tr>";
$message .= "<tr><td>vlastný dekor:</td><td>" . $data["dekor_vlastny"] . "</td></tr>";
$message .= "</table><br></div>";
$message .= "<div class=\"print_hlavicka3\">\r\n            <table>\r\n               <tr>\r\n               <th></th>\r\n               <th style=\"width: 40px;\">ks</th>\r\n               <th style=\"width: 180px;\">rozmer</th>\r\n               <th style=\"width: 270px;\">Názov</th>\r\n               <th style=\"width: 270px;\">Poznámka</th>\r\n               <th style=\"width: 50px;\">hrúbka</th>\r\n               <th style=\"width: 50px;\">orient.</th>\r\n               <th style=\"width: 20px;\">dolná</th>\r\n               <th style=\"width: 20px;\">pravá</th>\r\n               <th style=\"width: 20px;\">horná</th>\r\n               <th style=\"width: 20px;\">ľavá</th>\r\n               <th></th>\r\n               </tr>";
if ($data["dlzka_all"][$i] > def_value("max_dlzka", "hodnota") - 20 or $data["sirka_all"][$i] > def_value("max_sirka", "hodnota") - 20) {
    $poznamka[$i] = "<strong>POZOR!!</strong> " . $poznamka[$i];
}
//var_dump($data);
for ($i = 0; $i < $fieldsets_c; $i++) {
    $poradie = 0;
    $poradie = $i + 1;
    $message .= "<tr>\r\n                    <td class=\"form_poradie\">{$poradie}. </td>\r\n                    <td class=\"form_ks\">" . sec_input($data["ks_all"][$i]) . "</td>\r\n                    <td class=\"form_rozmer\">" . sec_input($data["dlzka_all"][$i]) . " x " . $data["sirka_all"][$i] . " mm</td>\r\n                    <td class=\"form_nazov\">" . sec_input($data["nazov_all"][$i]) . "</td>\r\n                    <td class=\"form_nazov\">\r\n                    " . (($data["dlzka_all"][$i] > def_value("max_dlzka", "hodnota") - 20 or $data["sirka_all"][$i] > def_value("max_sirka", "hodnota") - 20) ? "" . sec_input($data["poznamka_all"][$i]) . " <strong>POZOR ROZMER!!</strong>" : "" . sec_input($data["poznamka_all"][$i]) . "") . "\r\n                        </td>";
    $hrubka = sql_query("SELECT meno FROM hrubka WHERE id=" . sec_sql(sec_input($data["hrubka_all"][$i])) . " LIMIT 1");
    $hrubka = $hrubka[0];
    $message .= "\r\n                    <td class=\"form_hrana\">" . $hrubka["meno"] . "</td>";
    $orientacia = sql_query("SELECT meno, hodnota FROM orientacia WHERE id=" . sec_sql(sec_input($data["orientacia_all"][$i])) . " LIMIT 1");
    $orientacia = $orientacia[0];
    $message .= "\r\n                    <td class=\"form_hrana\">" . $orientacia["meno"] . "</td>";
    $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana1_all"][$i])) . " LIMIT 1");
    $hrana = $hrana[0];
    $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
    $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana2_all"][$i])) . " LIMIT 1");
    $hrana = $hrana[0];
    $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
    $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana3_all"][$i])) . " LIMIT 1");
    $hrana = $hrana[0];
    $message .= "\r\n                    <td class=\"form_hrana\">" . $hrana[meno] . "</td>";
예제 #12
0
// prvá stránka formulára - koniec
if ($page == 2) {
    //var_dump($_SESSION["posted_form"]);
    if ($_POST[submit_confirm] or $_POST[submit_save]) {
        $data = $_SESSION["posted_form"];
        if (empty($error_msg)) {
            if (empty($_SESSION["posted_form"]) || !isset($_SESSION["posted_form"])) {
                die("nie su žiadne údaje na nahrávanie");
            }
            // vlozenie do objednávaok
            mysql_query("BEGIN");
            if ($_POST[submit_save]) {
                $status_cp = def_value("default_obj_status_rozpracovana", "hodnota");
            }
            if ($sub == "cp") {
                $status_cp = def_value("default_obj_status_cp", "hodnota");
            }
            if (!empty($data["secure_key"])) {
            } else {
                $query = "INSERT INTO velkoobchod (datum, datum_vlastny, status)\n                            VALUES (now(), \"" . sec_input(sec_sql($data["datum"])) . "\", \"{$status_cp}\")";
                //var_dump($query);
                //die();
                $sql_objednavka = sql_insert($query);
                $obj_id = $sql_objednavka["inserted_id"];
            }
            $upravil = $_SESSION[username];
            if (empty($upravil)) {
                $upravil = 0;
            }
            // vlozenie do revizii
            $query = "INSERT INTO revizia_velkoobchod \n                          (id_velkoobchod, datum_vlastny, komentar, datum, upravil)\n                          VALUES \n                          ({$obj_id},\n                              \"" . sec_input(sec_sql($data["datum"])) . "\",\n                              \"" . sec_input(sec_sql($data["komentar"])) . "\",\n                              now(), {$upravil}) ";
예제 #13
0
function edit($table, $vyber, $sub, $id, $page = 1)
{
    $error_msg = array();
    if ($_POST[submit]) {
        $meno = sec_sql(sec_input($_POST["meno"]));
        $adresa = sec_sql(sec_input($_POST["adresa"]));
        $ico_icdph = sec_sql(sec_input($_POST["ico_icdph"]));
        $telefon = sec_sql(sec_input($_POST["telefon"]));
        $skupina = sec_sql(sec_input($_POST["skupina"]));
        $id_c_hladina = sec_sql(sec_input($_POST["id_c_hladina"]));
        $id_perm_uroven = sec_sql(sec_input($_POST["id_perm_uroven"]));
        $hodnota = sec_sql(sec_input($_POST["hodnota"]));
        $email = sec_sql(sec_input($_POST["email"]));
        $email2 = sec_sql(sec_input($_POST["email2"]));
        $old_password = sec_sql(sec_input($_POST["old_password"]));
        $password = sec_sql(sec_input($_POST["password"]));
        $password_confirm = sec_sql(sec_input($_POST["password_confirm"]));
        $id_material = sec_sql(sec_input($_POST["id_material"]));
        $id_vyrobca = sec_sql(sec_input($_POST["id_vyrobca"]));
        $stvorakov = sec_sql(sec_input($_POST["stvorakov"]));
        $stvorakov = str_replace(',', '.', $stvorakov);
        $hodnota_csv = sec_sql(sec_input($_POST["hodnota_csv"]));
        $id = sec_sql(sec_input($_POST["id"]));
        $zobraz_vo_formulari = intval(sec_sql(sec_input($_POST["zobraz_vo_formulari"])));
        $skryt_zakaznikom = intval(sec_sql(sec_input($_POST["skryt_zakaznikom"])));
        if (strlen($meno) > 30 or strlen($meno) < 1) {
            $error_msg[] = "Meno môže mať od 1 do 30 znakov";
        }
        if ($table == "vyrobca") {
            if (strlen($hodnota) > 30 or strlen($hodnota) < 1) {
                $error_msg[] = "Hodnota môže mať od 1 do 30 znakov";
            }
        }
        if ($table == "hrana") {
            //var_dump($zobraz_vo_formulari);
            if ($zobraz_vo_formulari < 0) {
                $error_msg[] = "Zobraz vo formulari ma nesprávnu hodnotu";
            }
            if (strlen($hodnota_csv) > 5 or strlen($hodnota_csv) < 1) {
                $error_msg[] = "hodnota pre csv je povinný údaj a môže mať 5 znakov";
            }
        }
        if ($table == "dekor") {
            if ($_FILES["subor"]["name"]) {
                $file_c = count($_FILES["subor"]["name"]);
                if (!empty($_FILES["subor"]["name"]) and strlen($_FILES["subor"]["name"]) > 4) {
                    //echo "ok<br>";
                    $data[file_ext] = strtolower(end(explode(".", $_FILES["subor"]["name"])));
                    $data[file_name] = $id;
                    $data[file_name_old] = $_FILES["subor"]["name"];
                    $data[file_tmp_name] = $_FILES["subor"]["tmp_name"];
                    $data[file_size] = $_FILES["subor"]["size"];
                    //echo "ok<br>";
                }
                $form_data_file = array("file_name" => $data[file_name], "file_ext" => $data[file_ext], "file_size" => $data[file_size]);
                $file_validate = dekor_img_validate($form_data_file);
            }
            if (count($file_validate) > 0) {
                foreach ($file_validate as $message) {
                    $error_msg[] = $message;
                }
            }
        }
        if ($table == "uzivatel") {
            //var_dump($skupina);
            if (!is_numeric($skupina) or empty($skupina)) {
                $error_msg[] = "skupina ma nesprávnu hodnotu";
            }
            //if(!is_numeric($id_c_hladina) or empty($id_c_hladina)) $error_msg[] = "cenova hladina ma nesprávnu hodnotu";
            if ($skupina == 2) {
                if (strlen($email) > 50 or strlen($email) < 8) {
                    $error_msg[] = "email je povinný údaj a môže mať od 8 do 50 znakov";
                }
                if (strlen($adresa) > 40 or strlen($adresa) < 6) {
                    $error_msg[] = "adresa je povinný údaj a môže mať od 8 do 50 znakov";
                }
                if (strlen($telefon) > 20 or strlen($telefon) < 5) {
                    $error_msg[] = "telefon je povinný údaj a môže mať od 8 do 50 znakov";
                }
                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                    $error_msg[] = "email je v nesprávnom tvare";
                }
            }
            if (!is_numeric($id) or empty($id)) {
                $error_msg[] = "ID ma nesprávnu hodnotu";
            }
            if (!empty($password) and !empty($old_password) and !empty($password_confirm)) {
                $old_password_original = sql_query("SELECT heslo FROM {$table} WHERE id={$id} AND heslo=\"" . md5($old_password) . "\" LIMIT 1");
                if (count($old_password_original) < 1) {
                    $error_msg[] = "Staré heslo nie je správne";
                }
                if (strlen($password) < 4 or strlen($password) > 30) {
                    $error_msg[] = "Heslo môže mať od 5 do 30 znakov";
                }
                if ($password != $password_confirm) {
                    $error_msg[] = "Heslá nie sú identické";
                }
            }
        }
        //var_dump($error_msg);
        if (empty($error_msg)) {
            $query = "UPDATE {$table}\n                      SET meno = \"{$meno}\", hodnota = \"{$hodnota}\"\n                      WHERE id = {$id}";
            if ($table == "vyrobca") {
                $query = "UPDATE {$table}\n                      SET meno = \"{$meno}\", hodnota = \"{$hodnota}\", id_material=\"{$id_material}\",\n                          skryt_zakaznikom=\"{$skryt_zakaznikom}\"\n                      WHERE id = {$id}";
            }
            if ($table == "cp_abs_vyrobca") {
                $query = "UPDATE {$table}\n                      SET meno = \"{$meno}\"\n                      WHERE id = {$id}";
            }
            if ($table == "dekor") {
                if (empty($stvorakov) or $stvorakov <= 0) {
                    $stvorakov = def_value("default_stvorak", "hodnota");
                }
                $hodnota = rep_dia($hodnota, 1);
                $query = "UPDATE {$table}\n                      SET meno = \"{$meno}\", hodnota = \"{$hodnota}\", id_material=\"{$id_material}\", id_vyrobca=\"{$id_vyrobca}\",\n                          stvorakov=\"{$stvorakov}\", skryt_zakaznikom=\"{$skryt_zakaznikom}\"\n                      WHERE id = {$id}";
                if ($data) {
                    $directory = "assets/images/dekor/";
                    if (!file_exists($directory)) {
                        mkdir($directory, 0777, true);
                    }
                    $filename = $data["file_tmp_name"];
                    $max_size = 250;
                    // percentage of resize
                    // Content type
                    //header('Content-type: image/jpeg');
                    // Get new dimensions
                    list($width, $height) = getimagesize($filename);
                    if ($width > $height) {
                        $percent = $max_size / $width;
                        $new_width = $max_size;
                        $new_height = $height * $percent;
                    } else {
                        $percent = $max_size / $height;
                        $new_height = $max_size;
                        $new_width = $width * $percent;
                    }
                    // Resample
                    $image_p = imagecreatetruecolor($new_width, $new_height);
                    $image = imagecreatefromjpeg($filename);
                    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
                    // Output
                    imagejpeg($image_p, $directory . "/" . $data["file_name"] . "." . $data["file_ext"], 100);
                    move_uploaded_file($data["file_tmp_name"], $directory . "/orig_" . $data["file_name"] . "." . $data["file_ext"]);
                    //exit();
                }
            }
            if ($table == "hrana") {
                $query = "UPDATE {$table}\n                      SET meno = \"{$meno}\", hodnota = \"{$hodnota}\", hodnota_csv=\"{$hodnota_csv}\",\n                          zobraz_vo_formulari = \"{$zobraz_vo_formulari}\"\n                      WHERE id = {$id}";
            }
            if ($table == "hrubka") {
                $query = "UPDATE {$table}\n                      SET meno = \"{$meno}\", hodnota = \"{$hodnota}\", id_material=\"{$id_material}\"\n                      WHERE id = {$id}";
            }
            if ($table == "uzivatel") {
                if (empty($password) or empty($old_password) or empty($password_confirm)) {
                    $query = "UPDATE {$table}\n                          SET meno = \"{$meno}\", adresa = \"{$adresa}\", ico_icdph = \"{$ico_icdph}\", \n                              email = \"{$email}\", email2 = \"{$email2}\", telefon = \"{$telefon}\", skupina = \"{$skupina}\",\n                              id_c_hladina = \"{$id_c_hladina}\", perm_uroven_id = \"{$id_perm_uroven}\"\n                          WHERE id = {$id}";
                } else {
                    $password = md5($password);
                    $query = "UPDATE {$table}\n                          SET meno = \"{$meno}\", email = \"{$email}\", heslo = \"{$password}\"\n                          WHERE id = {$id}";
                }
            }
            sql_update($query);
            //echo $id_perm_uroven;
            header("location: index.php?vyber=nastavenia&sub={$table}&page={$page}");
            exit;
        } else {
            echo "<div id=error_message>" . implode("<br>", $error_msg) . "</div>";
        }
    }
    $id = sec_sql($id);
    $query = "Select id, hodnota, meno from " . PREFIX . "{$table} WHERE id={$id}";
    if ($table == "vyrobca") {
        $query = "Select id, id_material, hodnota, meno, skryt_zakaznikom from {$table} WHERE id={$id}";
    }
    if ($table == "cp_abs_vyrobca") {
        $query = "Select id, meno from {$table} WHERE id={$id}";
    }
    if ($table == "dekor") {
        $query = "Select id, id_material, id_vyrobca, hodnota, meno, stvorakov, skryt_zakaznikom from {$table} WHERE id={$id}";
    }
    if ($table == "hrana") {
        $query = "Select id, hodnota, hodnota_csv, meno, zobraz_vo_formulari from {$table} WHERE id={$id}";
    }
    if ($table == "hrubka") {
        $query = "Select id, hodnota, meno, id_material from {$table} WHERE id={$id}";
    }
    if ($table == "uzivatel") {
        $query = "Select id, meno, adresa, ico_icdph, telefon, email, email2, skupina, id_c_hladina, perm_uroven_id from {$table} WHERE id={$id}";
    }
    $value = sql_query($query);
    $value = $value[0];
    echo "<form method=\"POST\" enctype=\"multipart/form-data\">";
    hidden("id", $value[id]);
    echo textfield("meno", $value[meno], "Meno", 50, 30);
    if ($table != "uzivatel" and $table != "cp_abs_vyrobca") {
        echo textfield("hodnota", $value[hodnota], "Hodnota", 50, 30);
        //echo "hej";
    }
    if ($table == "vyrobca" or $table == "hrubka") {
        echo select("id_material", "Materiál", "SELECT id, hodnota, meno FROM material WHERE vymaz=0", $value[id_material]);
    }
    if ($table == "vyrobca") {
        $zobraz_vo = array(1 => "skryť", 0 => "zobraz");
        echo select("skryt_zakaznikom", "zobraz zákaznikom", "", $value[skryt_zakaznikom], "", "", "", "NO", $zobraz_vo);
    }
    if ($table == "dekor") {
        echo select("id_material", "Materiál", "SELECT id, hodnota, meno FROM material WHERE vymaz=0", $value[id_material]);
        echo select("id_vyrobca", "Výrobca", "SELECT id, hodnota, meno FROM vyrobca WHERE vymaz=0", $value[id_vyrobca]);
        $zobraz_vo = array(1 => "skryť", 0 => "zobraz");
        echo select("skryt_zakaznikom", "zobraz zákaznikom", "", $value[skryt_zakaznikom], "", "", "", "NO", $zobraz_vo);
        echo textfield("stvorakov", $value[stvorakov], "stvorakov v tab.", 20, 10);
        file_upload("subor", "subor", "Príloha");
        if (isset($_GET["rotate"])) {
            $rotate = sec_input($_GET["rotate"]);
        }
        if ($rotate == 1) {
            $rotateFilename = "assets/images/dekor/{$value[id]}.jpg";
            // PATH
            if (file_exists($rotateFilename)) {
                $degrees = 90;
                //header('Content-type: image/jpeg');
                $source = imagecreatefromjpeg($rotateFilename);
                // Rotate
                $rotate = imagerotate($source, $degrees, 0);
                imagejpeg($rotate, $rotateFilename, 100);
                imagedestroy($source);
                imagedestroy($rotate);
                //echo "ok";
            }
        }
        if (file_exists("assets/images/dekor/{$value[id]}.jpg")) {
            echo "<img src=\"assets/images/dekor/{$value[id]}.jpg?rand=" . microtime() . "\">";
            echo "<br><a href=\"?vyber={$vyber}&sub={$sub}&action=edit&id={$id}&page={$page}&rotate=1\">Otočiť obrázok o 90st doprava</a>";
        }
    }
    if ($table == "hrana") {
        //var_dump($value);
        $zobraz_vo = array(1 => "zobraz", 0 => "nezobrazuj");
        echo textfield("hodnota_csv", $value[hodnota_csv], "Hodnota pre CSV", 40, 20);
        echo select("zobraz_vo_formulari", "vo formulári", "", $value[zobraz_vo_formulari], "", "", "", "NO", $zobraz_vo);
    }
    if ($table == "uzivatel") {
        if ($id == 1) {
            echo "<strong>Nie je možné upravovať hlavného administrátora!</strong>";
            die;
        }
        echo textfield("adresa", $value[adresa], "adresa", 40, 20);
        echo textfield("ico_icdph", $value[ico_icdph], "ičo / ičdph", 40, 20);
        echo textfield("telefon", $value[telefon], "telefón", 40, 20);
        echo textfield("email", $value[email], "email", 40, 20);
        echo textfield("email2", $value[email2], "email2", 40, 20);
        echo select("skupina", "Skupina", "SELECT id, meno FROM uzivatel_skupina WHERE vymaz=0", $value[skupina], "", "", "", "NO");
        echo select("id_c_hladina", "Cen.hladina", "SELECT id, meno FROM c_hladina WHERE vymaz=0", $value[id_c_hladina]);
        echo select("id_perm_uroven", "Úroveň zabezp.", "SELECT id, meno FROM perm_uroven WHERE vymaz=0", $value[perm_uroven_id]);
        echo textfield("old_password", $value[password], "Staré heslo", 40, 20);
        echo textfield("password", $value[password], "Nové heslo", 40, 20);
        echo textfield("password_confirm", "", "zopakujte heslo", 40, 20);
    }
    echo submit("submit", "Odoslať");
    echo "<a href=\"?vyber={$vyber}&sub={$sub}\">Späť</a>";
    echo "</form>";
}
예제 #14
0
파일: cp.php 프로젝트: jozefvasko/kraf-app
function send_email_revision_cp($revision, $cp)
{
    require_once 'include/PHPMailer/PHPMailerAutoload.php';
    $email_to_kraf = def_value("default_email", "hodnota");
    mysql_query("BEGIN");
    $data = sql_query("SELECT id_obj, meno, adresa, ico_icdph, telefon, email, id_material as material,\r\n                                    id_vyrobca as vyrobca, id_dekor as dekor, dekor_vlastny, komentar,\r\n                                    DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum\r\n                                    FROM revizia \r\n                                    WHERE id={$revision} \r\n                                    LIMIT 1");
    $data_narez = sql_query("SELECT ks, dlzka, sirka, nazov, poznamka, hrubka, orientacia,\r\n                                    hrana1, hrana2, hrana3, hrana4\r\n                                    FROM porez \r\n                                    WHERE id_revizia={$revision}");
    $data = $data[0];
    $fieldsets_c = count($data_narez);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_narez[$i][ks];
        $dlzka[$i] = $data_narez[$i][dlzka];
        $sirka[$i] = $data_narez[$i][sirka];
        $nazov[$i] = $data_narez[$i][nazov];
        $poznamka[$i] = $data_narez[$i][poznamka];
        $hrubka[$i] = $data_narez[$i][hrubka];
        $orientacia[$i] = $data_narez[$i][orientacia];
        $hrana1[$i] = $data_narez[$i][hrana1];
        $hrana2[$i] = $data_narez[$i][hrana2];
        $hrana3[$i] = $data_narez[$i][hrana3];
        $hrana4[$i] = $data_narez[$i][hrana4];
    }
    $data[ks_all] = $ks;
    $data[dlzka_all] = $dlzka;
    $data[sirka_all] = $sirka;
    $data[nazov_all] = $nazov;
    $data[poznamka_all] = $poznamka;
    $data[hrubka_all] = $hrubka;
    $data[orientacia_all] = $orientacia;
    $data[hrana1_all] = $hrana1;
    $data[hrana2_all] = $hrana2;
    $data[hrana3_all] = $hrana3;
    $data[hrana4_all] = $hrana4;
    $files = sql_query("SELECT meno, meno_old, pripona \r\n                                FROM subor\r\n                                WHERE id_obj=" . $data["id_obj"] . "");
    //var_dump($data);
    $data_obj = sql_query("SELECT DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, c_obj,\r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM objednavka \r\n                                    WHERE id=" . $data["id_obj"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    $message = "<html><body>";
    $message .= "<img src=\"http://" . def_value("default_url", "hodnota") . "/assets/images/logo.jpg\">";
    $message .= "<h1>Cenová ponuka k objednávke č. " . $data_obj["c_obj"] . " / " . $data_obj["rok"] . "</h1>";
    $message .= "zo dňa: " . $data_obj["datum"] . "<br><br>";
    $message .= "<table><tr>";
    $message .= "<td style=\"width: 400px;\"><strong>Dodávateľ</strong><br>";
    $message .= "<table><tr><td>" . def_value("default_firma", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_adresa", "hodnota") . "<br>" . def_value("default_mesto", "hodnota") . "</td></tr>";
    $message .= "<tr><td>IČO: " . def_value("default_ico", "hodnota") . "<br> DIČ: " . def_value("default_dic", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_telefon", "hodnota") . "<br> " . def_value("default_mobil", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_email", "hodnota") . "<br> " . def_value("default_email_2", "hodnota") . "</td></tr>";
    $message .= "</table><br><br></td>";
    $message .= "<td style=\"width: 50%;\"><strong>Objednávateľ:</strong>";
    $message .= "<table><tr><td>" . $data["meno"] . "</td></tr>";
    $message .= "<tr><td>" . $data["adresa"] . "</td></tr>";
    $message .= "<tr><td>" . $data["ico_icdph"] . "</td></tr>";
    $message .= "<tr><td>" . $data["telefon"] . "</td></tr>";
    $message .= "<tr><td>" . $data["email"] . "</td></tr>";
    $message .= "</table><br><br></td>";
    $message .= "</tr></table>";
    $message .= "<strong>Materiál:</strong>";
    $material = sql_query("SELECT meno FROM material WHERE id=" . sec_sql(sec_input($data["material"])) . " LIMIT 1");
    $material = $material[0];
    $message .= "<table><tr><td>" . $material["meno"] . "</td></tr>";
    $vyrobca = sql_query("SELECT meno FROM vyrobca WHERE id=" . sec_sql(sec_input($data["vyrobca"])) . " LIMIT 1");
    $vyrobca = $vyrobca[0];
    $dekor = sql_query("SELECT meno FROM dekor WHERE id=" . sec_sql(sec_input($data["dekor"])) . " LIMIT 1");
    $dekor = $dekor[0];
    $message .= "<tr><td>" . $vyrobca["meno"] . " " . $dekor["meno"] . "</td></tr>";
    $message .= "<tr><td>" . $data["dekor_vlastny"] . "</td></tr>";
    $message .= "</table><br><br>";
    $message .= "<div class=\"print_hlavicka3\">\r\n            <table style=\"font-size: 100%;\">\r\n               <tr style=\"background-color: #efefef; font-size: 9pt;\">\r\n               \r\n               <th style=\"width: 350px;\">položka</th>\r\n               <th style=\"width: 80px;\">množstvo</th>\r\n               <th style=\"width: 80px;\">jedn. cena</th>\r\n               <th style=\"width: 80px;\">Celkom</th>\r\n               </tr>";
    //var_dump(sql_query("SELECT * from cp WHERE id=$cp"));
    $data_narez = sql_query("SELECT c.vlastna_cena, c.dekor_ks, d.cena dekor_ks_cena, c.dekor_ks_sum,\r\n                                        c.dekor_m2, c.dekor_m2_jedn dekor_m2_cena, c.dekor_m2_sum,\r\n                                        c.porez, p.cena porez_cena, c.porez_sum,\r\n                                        c.lepenie, l.cena lepenie_cena, round(lepenie_sum, 2) lepenie_sum,\r\n                                        c.cnc_priprava, c1.cena cnc_priprava_cena, c.cnc_priprava_sum,\r\n                                        c.cnc_praca, c2.cena cnc_praca_cena, c.cnc_praca_sum,\r\n                                        c.olep_obluk, o.cena olep_obluk_cena, c.olep_obluk_sum\r\n                                    FROM cp c\r\n                                    LEFT JOIN cp_dekor_ks d ON c.id_dekor_ks = d.id \r\n                                    LEFT JOIN cp_porez p ON c.id_porez = p.id\r\n                                    LEFT JOIN cp_lepenie l ON c.id_lepenie = l.id\r\n                                    LEFT JOIN cp_cnc_opracovanie c1 ON c.id_cnc_priprava = c1.id\r\n                                    LEFT JOIN cp_cnc_praca c2 ON c.id_cnc_praca = c2.id\r\n                                    LEFT JOIN cp_olep_obluk o ON c.id_olep_obluk = o.id\r\n                                    \r\n                                    WHERE c.id={$cp} LIMIT 1");
    $data_narez = $data_narez[0];
    $fieldsets_c = count($data_narez);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_narez[$i][ks];
        $dlzka[$i] = $data_narez[$i][dlzka];
        $sirka[$i] = $data_narez[$i][sirka];
    }
    $data[ks_all] = $ks;
    $data[dlzka_all] = $dlzka;
    //var_dump($data_narez);
    if ($data_narez[dekor_ks_cena] <= 0) {
        $data_narez[dekor_ks_cena] = $data_narez[vlastna_cena];
    }
    $full_sum = 0;
    $message .= riadok_print_cp($data_narez[dekor_ks], $data_narez[dekor_ks_cena], $data_narez[dekor_ks_sum], "Material ks");
    $full_sum += $data_narez[dekor_ks_sum];
    $message .= riadok_print_cp($data_narez[dekor_m2], $data_narez[dekor_m2_cena], $data_narez[dekor_m2_sum], "Material m2");
    $full_sum += $data_narez[dekor_m2_sum];
    $message .= riadok_print_cp($data_narez[porez], $data_narez[porez_cena], $data_narez[porez_sum], "Porez");
    $full_sum += $data_narez[porez_sum];
    $num_hrana = sql_query("SELECT id, hodnota FROM hrana WHERE vymaz=0 ORDER BY id");
    foreach ($num_hrana as $hrana) {
        $hrana_abs = sql_query("SELECT a.cena abs, b.cena, a.sum, c.hodnota from cp_hrana a \r\n                                LEFT JOIN cp_abs b\r\n                                ON a.id_abs = b.id\r\n                                LEFT JOIN hrana c\r\n                                ON b.id_hrana = c.id\r\n                                WHERE a.id_cp={$cp} AND c.id={$hrana['id']}");
        $hrana_abs = $hrana_abs[0];
        //var_dump($hrana);
        if (!empty($hrana_abs[hodnota])) {
            $message .= riadok_print_cp($hrana_abs[abs], $hrana_abs[cena], $hrana_abs[sum], $hrana_abs[hodnota]);
            $full_sum += $hrana_abs[sum];
        }
        $hrana_sluzba = sql_query("SELECT a.cena abs, b.cena, a.sum, c.hodnota from cp_hrana_sluzba a \r\n                                LEFT JOIN cp_abs_sluzba b\r\n                                ON a.id_abs = b.id\r\n                                LEFT JOIN hrana c\r\n                                ON b.id_hrana = c.id\r\n                                WHERE a.id_cp={$cp} AND c.id={$hrana['id']}");
        $hrana_sluzba = $hrana_sluzba[0];
        //var_dump($hrana);
        if (!empty($hrana_sluzba[hodnota])) {
            $message .= riadok_print_cp($hrana_sluzba[abs], $hrana_sluzba[cena], $hrana_sluzba[sum], "- olepenie " . $hrana_sluzba[hodnota]);
            $full_sum += $hrana_sluzba[sum];
        }
    }
    $message .= riadok_print_cp($data_narez[lepenie], $data_narez[lepenie_cena], $data_narez[lepenie_sum], "Lepenie");
    $full_sum += $data_narez[lepenie_sum];
    $message .= riadok_print_cp($data_narez[cnc_priprava], $data_narez[cnc_priprava_cena], $data_narez[cnc_priprava_sum], "CNC programovanie");
    $full_sum += $data_narez[cnc_priprava_sum];
    $message .= riadok_print_cp($data_narez[cnc_praca], $data_narez[cnc_praca_cena], $data_narez[cnc_praca_sum], "CNC práca");
    $full_sum += $data_narez[cnc_praca_sum];
    $message .= riadok_print_cp($data_narez[olep_obluk], $data_narez[olep_obluk_cena], $data_narez[olep_obluk_sum], "Olep oblúkov");
    $full_sum += $data_narez[olep_obluk_sum];
    $num_sluzba = sql_query("SELECT popis, hodnota, cena, sum FROM cp_sluzba WHERE id_cp={$cp} ORDER BY id");
    foreach ($num_sluzba as $sluzba) {
        //var_dump($sluzba);
        if (!empty($sluzba[popis])) {
            $message .= riadok_print_cp($sluzba[hodnota], $sluzba[cena], $sluzba[sum], $sluzba[popis]);
            //var_dump($hrana[sum]);
            $full_sum = $full_sum + $sluzba[sum];
        }
    }
    $full_sum = ceil($full_sum * 100) / 100;
    $message .= "</table><br><br>";
    $message .= "<div style=\"margin: 1em; font-size: 130%;\"><strong>Cena spolu: </strong>{$full_sum} €</div><br><br>";
    $message .= "email vytvorený: " . date("j. n. Y - H:i") . "<br>";
    $message .= "</body></html>";
    mysql_query("COMMIT");
    //echo $message;
    if ($data["email"] != $email_to) {
        $email_to = $data["email"];
        $email_subject = "Cenová ponuka k objednávke č. " . $data_obj["c_obj"] . " / " . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
        $headers = "From: \"" . def_value("default_firma", "hodnota") . "\" <" . def_value("default_email", "hodnota") . ">\r\n";
        $headers .= "Reply-To: " . def_value("default_email", "hodnota") . "\r\n";
        //$headers .= "CC: scooti@stonline.sk\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
        $mail = new PHPMailer();
        //$mail->IsSMTP();
        $mail->CharSet = "UTF-8";
        $mail->SMTPDebug = 0;
        $mail->SMTPAuth = true;
        //$mail->SMTPSecure = 'ssl';
        $mail->Host = def_value("default_email_host", "hodnota");
        $mail->Port = def_value("default_email_port", "hodnota");
        $mail->Username = def_value("default_email_username", "hodnota");
        $mail->Password = def_value("default_email_password", "hodnota");
        $mail->isHTML(true);
        $mail->setLanguage('sk', 'language/');
        $mail->SetFrom(def_value("default_email", "hodnota"), def_value("default_firma", "hodnota"));
        $mail->Subject = $email_subject;
        $mail->Body = $message;
        $mail->AddAddress($email_to);
        $mail->Send();
        //mail($email_to, $email_subject, $message, $headers);
        //var_dump($email_to);
        //var_dump($data["email"]);
    }
    echo "Email bol úspešne odoslaný na adresu: {$email_to}";
}
예제 #15
0
function generate_csv_new($order, $revision, $sub = "")
{
    mysql_query("BEGIN");
    $rev = empty($revision) ? 0 : $revision;
    sql_insert("INSERT INTO revizia_aktivita (uzivatel_id, revizia, status) \r\n                    VALUES ({$_SESSION[username]}, {$rev}, \"vytvorenie CSV\")");
    $obj = sql_query("SELECT id, DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, status, c_obj\r\n                      FROM objednavka \r\n                      WHERE id=\"{$order}\"\r\n                      LIMIT 1");
    $obj = $obj[0];
    $rev = sql_query("SELECT DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum,\r\n                        meno, adresa, ico_icdph, telefon, email, id_material, id_vyrobca, id_hrubka, id_dekor,\r\n                        dekor_vlastny, komentar\r\n                      FROM revizia \r\n                      WHERE id_obj=\"{$order}\" AND id=\"{$revision}\"\r\n                      LIMIT 1");
    $rev = $rev[0];
    $c_obj = $obj["c_obj"];
    $material = sql_query("SELECT meno, max_dlzka, max_sirka\r\n                            FROM material \r\n                            WHERE id=\"" . $rev["id_material"] . "\" \r\n                            LIMIT 1")[0];
    $hrubka = sql_query("SELECT id, hodnota\r\n                            FROM hrubka \r\n                            WHERE id=\"" . $rev["id_hrubka"] . "\" \r\n                            LIMIT 1")[0];
    if (is_duplak($hrubka["id"])) {
        $hrubka["hodnota"] = "18";
    }
    $meno_csv = sec_input(rep_dia($rev[meno]));
    $meno_csv = str_replace('/', "", $meno_csv);
    $meno_csv = str_replace(" ", "", $meno_csv);
    $meno_csv = str_replace(".", "", $meno_csv);
    //$material[meno] = str_replace(" ", "", $material[meno]);
    $vyrobca[meno] = str_replace(" ", "", $vyrobca[meno]);
    if (strlen($meno_csv) > 10) {
        $meno_csv = substr($meno_csv, 0, 10);
    }
    $directory = "files/csv_new/obj-{$order}/rev-{$revision}";
    if (!file_exists($directory)) {
        mkdir($directory, 0777, true);
    }
    if (!empty($sub) && $sub == "pasy") {
        $meno_csv = $meno_csv . "-pasy";
    }
    $fp = fopen("{$directory}/{$c_obj}-{$meno_csv}.csv", "w+");
    $rev[meno] = rep_dia($rev[meno]);
    $rev[meno] = str_replace(" ", "_", $rev[meno]);
    $meno_suboru = $rev[meno] . "" . (strlen($dekor[hodnota]) > 1 ? "_{$dekor['hodnota']}" : "") . "";
    $meno_suboru = mb_substr($meno_suboru, 0, 20, "UTF-8");
    //$rev[meno] = str_replace("/", "", $rev[meno]);
    /*
        $hlavicka = "0;".rep_dia($material["meno"]).";2800;2070;18;*;10;10;10;10;1
    ";   */
    $hlavicka = "";
    $hlavicka2 = "";
    $nar = sql_query("SELECT ks, dlzka, sirka, nazov, poznamka, duplak, hrubka, orientacia,\r\n                         hrana1, hrana2, hrana3, hrana4, duplak_paska\r\n                      FROM porez \r\n                      WHERE id_revizia=\"{$revision}\"\r\n                      ");
    $hrana = sql_query("SELECT id, hodnota, hodnota_csv, meno\r\n                      FROM hrana \r\n                      ");
    if (empty($material["max_dlzka"])) {
        $max_dlzka = def_value("max_dlzka", "hodnota");
    } else {
        $max_dlzka = $material["max_dlzka"];
    }
    if (empty($material["max_sirka"])) {
        $max_sirka = def_value("max_sirka", "hodnota");
    } else {
        $max_sirka = $material["max_sirka"];
    }
    //dd($material);
    foreach ($nar as $value) {
        //var_dump($value);
        $value[nazov] = str_replace(" ", "_", rep_dia($value[nazov]));
        $value[poznamka] = str_replace(" ", "_", rep_dia($value[poznamka]));
        $value[nazov] = preg_replace("/[^A-Z0-9a-z\\w ]/u", '', $value[nazov]);
        $value[poznamka] = preg_replace("/[^A-Z0-9a-z\\w ]/u", '', $value[poznamka]);
        //if ($value[orientacia]==0) $value[orientacia] = "";
        /*
        if (!empty($value[nazov])) {
            $value[nazov] = $value[nazov];
            
        } else {
            $value[nazov] = $rev[meno];
        }
        if (!empty($value[poznamka])) {
            $value[poznamka] = $value[poznamka];
            
        } else {
            $value[poznamka] = $rev[meno];
        }
        */
        if (strlen($value[nazov]) > 30) {
            $value[nazov] = substr($value[nazov], 0, 30);
        }
        if (strlen($value[poznamka]) > 40) {
            $value[poznamka] = substr($value[poznamka], 0, 40);
        }
        //var_dump($value[nazov]);
        foreach ($hrana as $value_hrana) {
            //var_dump($value_hrana);
            for ($i = 1; $i < 5; $i++) {
                if ($value_hrana[id] == $value["hrana" . $i]) {
                    $value["hrana" . $i] = $value_hrana[meno];
                    $value["hrana" . $i . "_hodnota"] = $value_hrana[hodnota];
                }
                if ($value["hrana" . $i] == "0") {
                    $value["hrana" . $i] = "";
                }
                if ($value["hrana" . $i] != "" and is_duplak($value[hrubka]) or $value["hrana" . $i] != "" and $value[duplak_paska] == 1) {
                    $value["hrana" . $i] = "42/2";
                }
            }
        }
        /*
        $orientacia = sql_query("SELECT meno, hodnota FROM orientacia WHERE id=\"$value[orientacia]\" LIMIT 1");
        $orientacia = $orientacia[0][hodnota];    
        */
        $orientacia = $value["orientacia"];
        if ($orientacia == 3) {
            $orientacia = 0;
        } else {
            $orientacia = 1;
        }
        // nastavenie pre duplak
        // ak hrubka je totozna s prednastavenou hodnotou pre duplak,
        // automaticky zmeni pocet kusov * 2,
        // dlzku a sirku predlzi o 20 a znovu ich prevedie na string
        //var_dump(def_value("default_duplak", "hodnota"));
        //dd($value["hrubka"]);
        if (is_duplak($value[hrubka])) {
            $value[ks] = $value[ks] * 2;
            $value[ks] = "{$value['ks']}";
            $value[poznamka] = $value[poznamka] . " Dup " . $value[dlzka] . "x" . $value[sirka] . " (rez " . ($value[dlzka] + 15) . "x" . ($value[sirka] + 15) . ")";
            $value[dlzka] = $value[dlzka] + 30;
            $value[dlzka] = "{$value['dlzka']}";
            $value[sirka] = $value[sirka] + 30;
            $value[sirka] = "{$value['sirka']}";
        }
        $meno_materialu = rep_dia($material["meno"] . $hrubka["hodnota"]);
        if (!empty($sub) && $sub == "pasy") {
            $meno_materialu = "NaPasy" . $hrubka["hodnota"];
        } else {
            if ($value[dlzka] > $max_dlzka - 20) {
                $value[dlzka] = $max_dlzka - 20;
            }
            if ($value[sirka] > $max_sirka - 20) {
                $value[sirka] = $max_sirka - 20;
            }
        }
        //if (count($value[hrana1_hodnota])<1) $value[hrana1_hodnota] = "   ";
        //dd($value);
        $narezovka[] = array("ks" => $value[ks], "dlzka" => $value[dlzka], "sirka" => $value[sirka], "nazov" => $value[nazov] . "", "poznamka" => "{$value['poznamka']}", "orientacia" => "{$orientacia}", "{$value['hrana1']}", "{$value['hrana2']}", "{$value['hrana3']}", "{$value['hrana4']}", $meno_materialu);
    }
    //var_dump($narezovka);
    //die();
    if ($fp) {
        fwrite($fp, $hlavicka);
        //fputcsv($fp, array_values($row), ";");
        //fwrite($fp, $hlavicka2);
        foreach ($narezovka as $fields) {
            fputcsv($fp, $fields, ";");
        }
    }
    $status_obj = def_value("default_obj_status_spracovana", "hodnota");
    if ($obj["status"] == def_value("default_obj_status_cp", "hodnota")) {
        $status_obj = def_value("default_obj_status_cp_spracovana", "hodnota");
    }
    $query = "UPDATE objednavka\r\n                  SET status={$status_obj}\r\n                  WHERE id=\"{$order}\"";
    sql_update($query);
    mysql_query("COMMIT");
    ob_end_clean();
    header('Content-Type: application/download');
    header('Content-Disposition: attachment; filename="' . $c_obj . '-' . $meno_csv . '.csv"');
    //header("Content-Length: " . filesize("{$c_obj}-{$meno_csv}.csv"));
    header('Pragma: no-cache');
    readfile("{$directory}/{$c_obj}-{$meno_csv}.csv");
    //header("location: {$directory}/{$c_obj}-{$meno_csv}.csv");
    exit;
}
예제 #16
0
 $message .= "\r\n                    <td class=\"form_hrana\">" . $orientacia["meno"] . "</td>";
 $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana1_all"][$i])) . " LIMIT 1");
 $hrana = $hrana[0];
 $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
 $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana2_all"][$i])) . " LIMIT 1");
 $hrana = $hrana[0];
 $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
 $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana3_all"][$i])) . " LIMIT 1");
 $hrana = $hrana[0];
 $message .= "\r\n                    <td class=\"form_hrana\">" . $hrana[meno] . "</td>";
 $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana4_all"][$i])) . " LIMIT 1");
 $hrana = $hrana[0];
 $message .= "\r\n                    <td class=\"form_hrana\">" . $hrana[meno] . "</td>";
 $vypocet = $data["dlzka_all"][$i] * $data["sirka_all"][$i] / 1000000;
 $vypocet = $vypocet * $data["ks_all"][$i];
 if ($data["hrubka_all"][$i] == def_value("default_duplak", "hodnota")) {
     $paska = 0;
     if ($data[hrana1_all][$i] > 0) {
         $paska = $paska + $data[dlzka_all][$i];
     }
     if ($data[hrana3_all][$i] > 0) {
         $paska = $paska + $data[dlzka_all][$i];
     }
     if ($data[hrana2_all][$i] > 0) {
         $paska = $paska + $data[sirka_all][$i];
     }
     if ($data[hrana4_all][$i] > 0) {
         $paska = $paska + $data[sirka_all][$i];
     }
     $vypocet_duplak = $data["dlzka_all"][$i] * $data["sirka_all"][$i] / 1000000;
     $vypocet_duplak = $vypocet_duplak * $data["ks_all"][$i];
예제 #17
0
    }
    if ($search_status == "iba_prijate") {
        $where[] = "status=\"0\" and komplet<>1";
        $where[] = "o.vymaz=0  AND archiv=0";
    }
    if ($search_status == "iba_rozpracovane") {
        $where[] = "status=" . def_value("default_obj_status_rozpracovana", "hodnota") . "";
        $where[] = "datum >= DATE_SUB(CURDATE(), INTERVAL {$day_limit} DAY)";
        $where[] = "o.vymaz=0  AND archiv=0";
    }
} else {
    $access = check_access_true("objednavka_edit");
    if ($access == TRUE) {
        $where[] = "status<>" . def_value("default_obj_status_rozpracovana", "hodnota") . "";
    } else {
        $where[] = "status=" . def_value("default_obj_status_spracovana", "hodnota") . "";
    }
    $where[] = "o.vymaz=0 AND archiv=0";
    $where[] = "datum >= DATE_SUB(CURDATE(), INTERVAL {$day_limit} DAY)";
}
if (!empty($search_name)) {
    /*echo "search = SELECT DISTINCT id_obj
                  FROM revizia_search
                  WHERE MATCH (meno) AGAINST ('*{$search_name}*' IN BOOLEAN MODE)<br>";
      */
    $idecka = sql_query("SELECT DISTINCT id_obj\r\n                    FROM revizia_skrine_search\r\n                    WHERE meno LIKE '%{$search_name}%'");
    foreach ($idecka as $idecko) {
        $idecka_all[] = $idecko[id_obj];
    }
    //var_dump($idecka_all);
    $where[] = "o.id IN (                    \r\n                    " . (count($idecka_all) > 0 ? implode(",", $idecka_all) : "NULL") . "\r\n                    )";
예제 #18
0
function print_revision_vp_stitky($revision, $sub = "")
{
    $default_firma = def_value("default_firma", "hodnota");
    $default_adresa = def_value("default_adresa", "hodnota");
    $default_mesto = def_value("default_mesto", "hodnota");
    $default_ico = def_value("default_ico", "hodnota");
    $default_dic = def_value("default_dic", "hodnota");
    $default_telefon = def_value("default_telefon", "hodnota");
    $default_email = def_value("default_email", "hodnota");
    $default_web = def_value("default_web", "hodnota");
    $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\n                                    WHERE id={$revision} \r\n                                    LIMIT 1")[0];
    $data_row = sql_query("SELECT vyr.*, obr.*, rev.meno, rev.adresa, rev.psc, rev.mesto, rev.ico, rev.dic,\r\n                                            rev.telefon, rev.email, rev.doruc_meno, rev.doruc_adresa, rev.doruc_mesto, \r\n                                            rev.doruc_psc, rev.doruc_telefon,\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 AND obr.id_product_type <> 14                            \r\n                                ORDER BY obj.id_zakaznik DESC\r\n                            ");
    $message = "";
    //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($row);
        //dd($data_row_option);
        $options = array();
        $options_id = array();
        foreach ($data_row_option as $option) {
            $option = sql_query("SELECT id, meno FROM product_atribute_option WHERE id=" . $option["id_product_atribute_option"] . " LIMIT 1")[0];
            $options[] = $option["meno"];
            $options_id[] = $option["id"];
        }
        $options_str = empty($options) ? "" : join(" / ", $options);
        $options_id_str = $row["id_product_type"] . "-" . $row["id_product"] . "-" . join("-", $options_id);
        if (!empty($row["atyp_text"])) {
            $options_str .= " / " . $row["atyp_text"];
        }
        $required = array("meno", "adresa", "mesto", "psc", "ico", "dic");
        if ($row["id_zakaznik"] > 0) {
            $query = "SELECT meno, adresa, mesto, psc, ico, dic, \r\n                                doruc_meno, doruc_adresa, doruc_psc, doruc_mesto, doruc_telefon \r\n                                FROM uzivatel WHERE id=" . $row["id_zakaznik"] . " LIMIT 1";
            $zakaz = sql_query($query)[0];
            //var_dump($zakaz);
            foreach ($zakaz as $k => $zak) {
                if (in_array($k, $required)) {
                    $row[$k] = $zak;
                } else {
                }
            }
        }
        $product_type = sql_query("SELECT meno FROM product_type WHERE id=" . $row["id_product_type"] . " LIMIT 1")[0]["meno"];
        $product = sql_query("SELECT meno, montazny_balik FROM product WHERE id=" . $row["id_product"] . " LIMIT 1")[0];
        $product_balenie = sql_query("SELECT meno FROM product_packages WHERE id_product=" . $row["id_product"] . "");
        //var_dump(count($product_balenie));
        if (count($product_balenie) == 0) {
            $product_balenie = array(0 => array("meno" => ""));
        }
        $ean = sql_query("SELECT ean FROM ean WHERE code=\"" . $options_id_str . "\" LIMIT 1")[0]["ean"];
        for ($i = 1; $i <= $row["ks"]; $i++) {
            $count = 1;
            foreach ($product_balenie as $balenie) {
                $barcode = "BEN" . $product["meno"] . "" . str_replace("/", "", $options_str);
                $barcode = str_replace('.', '', $barcode);
                $barcode = str_replace(' ', '', $barcode);
                $barcode = strtoupper(rep_dia($barcode));
                $barcode = substr($barcode, 0, 45);
                $img = "<img src=\"barcode.php?codetype=Code128&size=40&text={$barcode}\" />";
                if (!empty($ean)) {
                    $barcode = $ean;
                    $img = "<img src=\"barcode/barcode.php?scale=2&code={$barcode}\" />";
                }
                $message .= "\r\n                    <div class=\"print_hlavicka_vp\">\r\n                        <table class=\"stitky\" >\r\n                        <tr>\r\n                            <td class=\"logo\" rowspan=4>\r\n                                <img src=\"assets/images/vp_stitok_logo.jpg\" width=200 style=\"margin: 15px auto;\">\r\n                            </td>\r\n                            <td colspan=3 class=\"nazov\" style=\"height: 2.4cm;\">\r\n                                <table class=\"inner_table\">\r\n                                    <tr>\r\n                                        <td class=\"titulka\">Názov produktu:</td>\r\n                                        <td class=\"barcode\" align=\"right\" rowspan=2>                                              \r\n                                            {$img}\r\n                                        </td>\r\n                                    </tr>\r\n                                    <tr>\r\n                                        <td class=\"product_type\">{$product_type}</td>\r\n                                    </tr>\r\n                                    <tr>\r\n                                        <td class=\"product\" colspan=2>{$product["meno"]}</td>\r\n                                    </tr>\r\n                                </table>\r\n\r\n                            </td>                \r\n                        </tr>\r\n                        <tr>\r\n                            <td colspan=2 rowspan=3>\r\n                                <table class=\"inner_table\">\r\n                                    <tr>\r\n                                        <td class=\"titulka\">Špecifikácia:</td>\r\n                                    </tr>\r\n                                    <tr>\r\n                                        <td class=\"product\" style=\"font-size: " . (strlen($options_str) > 27 ? "18" : "24") . "px;\">{$options_str}</td>\r\n                                    </tr>\r\n                                </table>\r\n                            </td>\r\n                            <td class=\"c_obj\" style=\"width: 4cm;\">č.obj {$row["c_obj"]}/" . dateYear($row["datum"]) . "</td>\r\n                        </tr>\r\n                        <tr>                    \r\n                            <td class=\"c_obj\" style=\"font-size: 13px;\">{$row["vlastne_cislo_obj"]}</td>\r\n                        </tr>\r\n                        <tr>                    \r\n                            <td style=\"padding: 0px 5px; height: 15px;\">dátum výroby: " . date("j. n. Y") . "</td>\r\n                        </tr>\r\n                        <tr>\r\n                            <td style=\"height: 4.4cm; vertical-align: top;\">\r\n                                <table class=\"inner_table adresy\"  style=\"font-size: 105%;\">\r\n                                    <tr>\r\n                                        <td style=\"font-size: 8px;\">Výrobca:</td>\r\n                                    </tr>\r\n                                    <tr>\r\n                                        <td style=\"\">{$default_firma}, {$default_adresa}</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"\">{$default_mesto}, SLOVENSKO</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"\">IČO: {$default_ico}, DIČ: {$default_dic}</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"\">tel. {$default_telefon}, email: {$default_email}</td>\r\n                                    </tr>                                \r\n                                    <tr>      \r\n                                        <td style=\"\">web: {$default_web}</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"padding-top: 10px;\">Výstupná kontrola: Ľubomír Kredatus</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"\"><img src=\"assets/images/qr1455130356.png\" width=45 style=\"margin: 0px;\"></td>\r\n                                    </tr>\r\n\r\n                                </table>\r\n                            </td>\r\n                            <td style=\"vertical-align: top;\">\r\n                                <table class=\"inner_table adresy\"  style=\"font-size: 110%;\">\r\n                                    <tr>\r\n                                        <td style=\"width: 22%; font-size: 8px; vertical-align: top;\" rowspan=5>Odberateľ:</td>\r\n                                        <td style=\"font-weight: bold; font-size: " . (strlen($row["meno"]) > 24 ? "170" : "193") . "%;\">{$row["meno"]}</td>\r\n                                    </tr>\r\n                                    <tr>\r\n                                        <td style=\"\">{$row["adresa"]}</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"\">{$row["mesto"]} {$row["psc"]}</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"\">IČO: {$row["ico"]}</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"\">IČDPH: {$row["dic"]}</td>\r\n                                    </tr>\r\n\r\n                                </table>\r\n                                <table class=\"inner_table adresy\" style=\"font-size: 110%;\">\r\n                                    <tr>\r\n                                        <td style=\"width: 22%; font-size: 8px; vertical-align: top;\" rowspan=5>Adresa dodania:</td>\r\n                                        <td style=\"font-weight: bold;\">{$row["doruc_meno"]}</td>\r\n                                    </tr>\r\n                                    <tr>\r\n                                        <td style=\"\">{$row["doruc_adresa"]}</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"\">{$row["doruc_mesto"]} {$row["doruc_psc"]}</td>\r\n                                    </tr>\r\n                                    <tr>      \r\n                                        <td style=\"\">tel: {$row["doruc_telefon"]}</td>\r\n                                    </tr>                                \r\n\r\n                                </table>\r\n                            </td>\r\n                            <td colspan=2 style=\"vertical-align: top;\">\r\n                                <table class=\"inner_table\">\r\n                                    <tr>\r\n                                        <td class=\"titulka\">Balenie:</td>\r\n                                    </tr>\r\n                                    <tr>\r\n                                        <td class=\"balenie\">{$count}/" . count($product_balenie) . "</td>\r\n                                    </tr>\r\n                                    <tr>\r\n                                        <td class=\"balenie_popis\">{$balenie["meno"]}</td>\r\n                                    </tr>\r\n                                    <tr>\r\n                                        <td class=\"balenie_montazny_balik\">{$product["montazny_balik"]}</td>\r\n                                    </tr>\r\n                                </table>\r\n                            </td>\r\n                        </tr>\r\n                        </table>\r\n                    </div>\r\n                    ";
                $count = $count + 1;
            }
        }
    }
    return $message;
}
예제 #19
0
function send_email_revision_velkoobchod($revision)
{
    //var_dump($revision);
    //die();
    require_once 'include/PHPMailer/PHPMailerAutoload.php';
    $email_to_kraf = def_value("default_email", "hodnota");
    mysql_query("BEGIN");
    $data = sql_query("SELECT id_velkoobchod, komentar, sum,\r\n                                    DATE_FORMAT(datum_vlastny, '%d. %m. %Y') AS datum\r\n                                    FROM revizia_velkoobchod \r\n                                    WHERE id={$revision} \r\n                                    LIMIT 1");
    $data_narez = sql_query("SELECT id_revizia as revizia, id_material as material, id_vyrobca as vyrobca, \r\n                                    id_dekor as dekor, id_dekor_cena as dekor_cena, m2, m3, sum\r\n                                    FROM porez_velkoobchod \r\n                                    WHERE id_revizia={$revision}");
    $data = $data[0];
    $fieldsets_c = count($data_narez);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $m2[$i] = $data_narez[$i][m2];
        $m3[$i] = $data_narez[$i][m3];
        $material[$i] = $data_narez[$i][material];
        $vyrobca[$i] = $data_narez[$i][vyrobca];
        $dekor[$i] = $data_narez[$i][dekor];
        $dekor_cena[$i] = $data_narez[$i][dekor_cena];
        $sum[$i] = $data_narez[$i][sum];
    }
    $data[m2_all] = $m2;
    $data[m3_all] = $m3;
    $data[material_all] = $material;
    $data[vyrobca_all] = $vyrobca;
    $data[dekor_all] = $dekor;
    $data[dekor_cena_all] = $dekor_cena;
    $data[sum_all] = $sum;
    //var_dump($data);
    $data_obj = sql_query("SELECT id, DATE_FORMAT(datum_vlastny, '%d. %m. %Y') AS datum,\r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM velkoobchod \r\n                                    WHERE id=" . $data["id_velkoobchod"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    //var_dump($data_obj); die();
    $message = "<html><body>";
    $message .= "<img src=\"http://" . def_value("default_url", "hodnota") . "/assets/images/logo.jpg\">";
    $message .= "<h1>Objednávka č. " . $data_obj["id"] . "/" . $data_obj["rok"] . "</h1>";
    $message .= "zo dňa: " . $data_obj["datum"] . "<br><br>";
    $message .= "<table style=\"font-size: 10pt;\">\r\n               <tr style=\"border-bottom: solid 1px darkslategrey ;\">\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\"></th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 130px;\">materiál</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 150px;\">výrobca</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 200px;\">dekor</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 40px;\">ks</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 40px;\">m3</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 60px;\">j.cena</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 50px;\">spolu</th>\r\n               \r\n               </tr>";
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $poradie = 0;
        $poradie = $i + 1;
        $message .= "<tr>\r\n                    <td class=\"form_poradie\">{$poradie}. </td>";
        $material = sql_query("SELECT meno FROM material WHERE id=" . sec_sql(sec_input($data["material_all"][$i])) . " LIMIT 1");
        $material = $material[0];
        $message .= "\r\n                    <td class=\"form_nazov\">" . $material["meno"] . "</td>";
        $vyrobca = sql_query("SELECT meno FROM vyrobca WHERE id=" . sec_sql(sec_input($data["vyrobca_all"][$i])) . " LIMIT 1");
        $vyrobca = $vyrobca[0];
        $message .= "\r\n                    <td class=\"form_nazov\">" . $vyrobca["meno"] . "</td>";
        $dekor = sql_query("SELECT meno FROM dekor WHERE id=" . sec_sql(sec_input($data["dekor_all"][$i])) . " LIMIT 1");
        $dekor = $dekor[0];
        $message .= "<td class=\"form_nazov\">" . $dekor[meno] . "</td>";
        $message .= "\r\n                    <td class=\"form_hrana\">" . sec_input($data["m2_all"][$i]) . "</td>\r\n                    <td class=\"form_hrana\">" . sec_input($data["m3_all"][$i]) . "</td>";
        $dekor_cena = sql_query("SELECT cena FROM cp_dekor_ks WHERE id=" . sec_sql(sec_input($data["dekor_cena_all"][$i])) . " LIMIT 1");
        $dekor_cena = $dekor_cena[0];
        $message .= "<td class=\"form_hrana\">" . round($dekor_cena[cena], 2) . "</td>";
        $message .= "<td class=\"form_data_material\">" . round(sec_input($data["sum_all"][$i]), 2) . "</td>";
        //var_dump($vypocet_paska_sum);
        //$message .= "<td class=\"td_vypocet\">".($vypocet>0 ? $vypocet_final : "" )."</td>";
        $message .= "</tr>";
    }
    $message .= "</table><br>";
    $message .= "<div class=\"form_vypocet_sum\">Spolu: " . round($data["sum"], 2) . " </div>";
    $message .= "<br>" . $data["komentar"] . "<br><br>";
    $message .= "email vytvorený: " . date("j. n. Y - H:i") . "<br>";
    $message .= "</body></html>";
    mysql_query("COMMIT");
    $headers = "From: \"KRaF - Veľkoobchod\" <" . $email_to_kraf . ">\r\n";
    $headers .= "Reply-To: " . $email_to_kraf . "\r\n";
    //$headers .= "CC: scooti@stonline.sk\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    //print_r($message);
    //exit();
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->CharSet = "UTF-8";
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    //$mail->SMTPSecure = 'ssl';
    $mail->Host = def_value("default_email_host", "hodnota");
    $mail->Port = def_value("default_email_port", "hodnota");
    $mail->Username = def_value("default_email_username", "hodnota");
    $mail->Password = def_value("default_email_password", "hodnota");
    $mail->isHTML(true);
    $mail->setLanguage('sk', 'language/');
    $mail->SetFrom(def_value("default_email", "hodnota"), def_value("default_firma", "hodnota"));
    $email_to = $email_to_kraf;
    $email_subject = "Velkoobchod č. " . $data_obj["id"] . "/" . $data_obj["rok"] . " zo dňa " . $data_obj["datum"] . "";
    $mail->Subject = $email_subject;
    $mail->Body = $message;
    $mail->AddAddress($email_to);
    $mail->Send();
    //mail($email_to, $email_subject, $message, $headers);
    //var_dump($email_to);
    //var_dump($data["email"]);
    //echo "Email bol úspešne odoslaný na adresu: $email_to";
}
예제 #20
0
<?php

if ($safe != "U,,5Enc!") {
    die("nepovoleny prístup k súboru!!");
}
//if (!$lng) $lng="sk";  // pre nastavanie jazyka uvodnej stranky, v pripade ze nie je premenna lng, nastavi uvodnu stranku na vybrany jazyk
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="author" content="scooti" />
  <title>Nárezovka <?php 
echo def_value("default_firma", "hodnota");
?>
</title>
  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script>
  <script src="assets/addons/tiptip/jquery.tipTip.js" type="text/javascript"></script>
  
  <script src="assets/script/scripts.js?<?php 
echo filemtime("assets/script/scripts.js");
?>
" type="text/javascript"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <script src="assets/addons/raphael/raphael.min.js" type="text/javascript"></script>
  <script src="assets/addons/chosen/chosen.jquery.js" type="text/javascript"></script>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/smoothness/jquery-ui.css" />
예제 #21
0
    }
}
if (sec_input($_GET[logout]) == "logout") {
    if (!empty($_SESSION[username])) {
        sql_insert("INSERT INTO uzivatel_aktivita (uzivatel_id, status) \r\n                    VALUES ({$_SESSION[username]}, 0)");
    }
    session_destroy();
    header("location: index.php");
}
if ($_POST[filter_for_print]) {
    $vyber = "print";
    $action = "do_objednavka";
}
include_once "config/vrch.php";
// vloženie hlavičky stránky
echo "<img src=\"http://" . def_value("default_url", "hodnota") . "/assets/images/logo.jpg\" class=\"logo\">";
if ($_SESSION["logged"] == 1) {
    if (empty($_SESSION["perm_uroven"])) {
        $_SESSION["perm_uroven"] = 0;
    }
    echo "<div class=\"user\">\r\n            Prihlásený: <strong>" . $_SESSION["name"] . "</strong> / <a href=\"?logout=logout\">Odhlásiť sa</a><br>\r\n            <a href=\"?vyber=edit_profile\">Upraviť profil</a>\r\n        </div>";
    echo "<div class=\"menu\">\r\n        <ul class=\"topmenu\">\n";
    if ($vyber == "formular") {
        $class = " class=\"selected\"";
    } else {
        $class = "";
    }
    echo "<li><a href=\"?vyber=formular\"{$class}>Objednávka Porez</a></li>\n";
    if ($vyber == "objednavky") {
        $class = " class=\"selected\"";
    } else {
예제 #22
0
<?php

$safe = "U,,5Enc!";
$root = $_SERVER['DOCUMENT_ROOT'];
include_once "config/datab.php";
// subor s nastaveniami databaz
include_once "config/fnc.php";
// vloženie hlavičky stránky
if (isset($_GET["select_material"])) {
    $material = sec_sql(sec_input($_GET["select_material"]));
    $def_hrana_duplak = def_value("default_duplak_hrana_value", "hodnota");
    echo select("hrana", "Hrúbka", "SELECT id, hodnota, meno FROM hrana WHERE vymaz=0 {$where} ORDER BY hodnota", def_value("default_hrubka", "hodnota"), "", "hrubka", "", "NO");
}
예제 #23
0
function print_revision_cp($cp, $revision)
{
    $data = sql_query("SELECT id_obj, meno, adresa, ico_icdph, telefon, email, id_material as material,\r\n                                    id_vyrobca as vyrobca, id_dekor as dekor, dekor_vlastny, komentar,\r\n                                    DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum\r\n                                    FROM revizia \r\n                                    WHERE id={$revision} \r\n                                    LIMIT 1");
    //var_dump($data);
    $data = $data[0];
    $data_obj = sql_query("SELECT DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, c_obj, id_zakaznik,\r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM objednavka \r\n                                    WHERE id=" . $data["id_obj"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    $message = "";
    $message .= "<h1>Cenová ponuka k obj č. " . $data_obj["c_obj"] . " / " . $data_obj["rok"] . " rev. " . $revision . " </h1>";
    $message .= "<h5>zo dňa: " . $data_obj["datum"] . "</h5>";
    $message .= "<div class=\"print_hlavicka\">";
    $message .= "<table class=\"print_dodavatel\"><tr><td></td><td><strong>Dodávateľ</strong></td></tr>";
    $message .= "<tr><td></td><td>" . def_value("default_firma", "hodnota") . "</td></tr>";
    $message .= "<tr><td></td><td>" . def_value("default_adresa", "hodnota") . "</td></tr>";
    $message .= "<tr><td></td><td>" . def_value("default_mesto", "hodnota") . "</td></tr>";
    $message .= "<tr><td>IČO:</td><td>" . def_value("default_ico", "hodnota") . "</td></tr>";
    $message .= "<tr><td>DIČ:</td><td>" . def_value("default_dic", "hodnota") . "</td></tr>";
    $message .= "<tr><td>tel.:</td><td>" . def_value("default_telefon", "hodnota") . "</td></tr>";
    $message .= "<tr><td>mobil:</td><td>" . def_value("default_mobil", "hodnota") . "</td></tr>";
    $message .= "<tr><td>email:</td><td>" . def_value("default_email", "hodnota") . ", " . def_value("default_email_2", "hodnota") . "</td></tr>";
    $message .= "</table>";
    if ($data_obj[id_zakaznik] > 0) {
        $meno_zakaznika = sql_query("SELECT meno, adresa, ico_icdph, telefon, email FROM uzivatel WHERE id={$data_obj['id_zakaznik']} LIMIT 1");
        $meno_zakaznika = $meno_zakaznika[0];
        $data[meno] = $meno_zakaznika[meno];
        $data[adresa] = $meno_zakaznika[adresa];
        $data[ico_icdph] = $meno_zakaznika[ico_icdph];
        $data[telefon] = $meno_zakaznika[telefon];
        $data[email] = $meno_zakaznika[email];
    }
    $message .= "<div class=\"print_odberatel\"><table class=\"print_odberatel\"><tr><td></td><td>Objednávateľ:</td></tr>";
    $message .= "<tr><td></td><td class=\"print_bigger\">" . $data["meno"] . "</td></tr>";
    $message .= "<tr><td></td><td>" . $data["adresa"] . "</td></tr>";
    $message .= "<tr><td>IČO:</td><td>" . $data["ico_icdph"] . "</td></tr>";
    $message .= "<tr><td>tel.:</td><td>" . $data["telefon"] . "</td></tr>";
    $message .= "<tr><td>email:</td><td>" . $data["email"] . "</td></tr>";
    $message .= "</table>";
    $message .= "</div>";
    $message .= "<div class=\"print_hlavicka2\">";
    $material = sql_query("SELECT meno FROM material WHERE id=" . sec_sql(sec_input($data["material"])) . " LIMIT 1");
    $material = $material[0];
    $message .= "<table><tr><td>materiál:</td><td class=\"print_bigger\">" . $material["meno"] . "</td></tr>";
    $vyrobca = sql_query("SELECT meno FROM vyrobca WHERE id=\"" . sec_sql(sec_input($data["vyrobca"])) . "\" LIMIT 1");
    $vyrobca = $vyrobca[0];
    $dekor = sql_query("SELECT meno FROM dekor WHERE id=" . sec_sql(sec_input($data["dekor"])) . " LIMIT 1");
    $dekor = $dekor[0];
    $message .= "<tr><td>dekor:</td><td class=\"print_bigger\">" . $vyrobca["meno"] . " " . $dekor["meno"] . "</td></tr>";
    $message .= "<tr><td>vlastný dekor:</td><td>" . $data["dekor_vlastny"] . "</td></tr>";
    $message .= "</table><br></div>";
    $message .= "<div class=\"print_hlavicka3\">\r\n            <table class=\"c_ponuka\">\r\n               <tr>\r\n               \r\n               <th style=\"width: 270px;\">položka CP</th>\r\n               <th style=\"width: 60px;\">množstvo</th>\r\n               <th style=\"width: 70px;\">jedn. cena</th>\r\n               <th style=\"width: 70px;\">Celkom</th>\r\n               </tr>";
    //var_dump(sql_query("SELECT * from cp WHERE id=$cp"));
    $data_narez = sql_query("SELECT c.vlastna_cena, c.dekor_ks, d.cena dekor_ks_cena, c.dekor_ks_sum,\r\n                                        c.dekor_m2, c.dekor_m2_jedn dekor_m2_cena, c.dekor_m2_sum,\r\n                                        c.porez, p.cena porez_cena, c.porez_sum,\r\n                                        c.lepenie, l.cena lepenie_cena, c.lepenie_sum,\r\n                                        c.cnc_priprava, c1.cena cnc_priprava_cena, c.cnc_priprava_sum,\r\n                                        c.cnc_praca, c2.cena cnc_praca_cena, c.cnc_praca_sum,\r\n                                        c.olep_obluk, o.cena olep_obluk_cena, c.olep_obluk_sum\r\n                                    FROM cp c\r\n                                    LEFT JOIN cp_dekor_ks d ON c.id_dekor_ks = d.id \r\n                                    LEFT JOIN cp_porez p ON c.id_porez = p.id\r\n                                    LEFT JOIN cp_lepenie l ON c.id_lepenie = l.id\r\n                                    LEFT JOIN cp_cnc_opracovanie c1 ON c.id_cnc_priprava = c1.id\r\n                                    LEFT JOIN cp_cnc_praca c2 ON c.id_cnc_praca = c2.id\r\n                                    LEFT JOIN cp_olep_obluk o ON c.id_olep_obluk = o.id\r\n                                    \r\n                                    WHERE c.id={$cp} LIMIT 1");
    $data_narez = $data_narez[0];
    $fieldsets_c = count($data_narez);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_narez[$i][ks];
        $dlzka[$i] = $data_narez[$i][dlzka];
        $sirka[$i] = $data_narez[$i][sirka];
    }
    $data[ks_all] = $ks;
    $data[dlzka_all] = $dlzka;
    //var_dump($data_narez);
    if ($data_narez[dekor_ks_cena] <= 0) {
        $data_narez[dekor_ks_cena] = $data_narez[vlastna_cena];
    }
    $full_sum = 0;
    $message .= riadok_print_cp($data_narez[dekor_ks], $data_narez[dekor_ks_cena], $data_narez[dekor_ks_sum], "Material ks");
    $full_sum += $data_narez[dekor_ks_sum];
    $message .= riadok_print_cp($data_narez[dekor_m2], $data_narez[dekor_m2_cena], $data_narez[dekor_m2_sum], "Material m2");
    $full_sum += $data_narez[dekor_m2_sum];
    $message .= riadok_print_cp($data_narez[porez], $data_narez[porez_cena], $data_narez[porez_sum], "Porez");
    $full_sum += $data_narez[porez_sum];
    $num_hrana = sql_query("SELECT id, hodnota FROM hrana WHERE vymaz=0 ORDER BY id");
    foreach ($num_hrana as $hrana) {
        $hrana_abs = sql_query("SELECT a.cena abs, b.cena, a.sum, c.hodnota from cp_hrana a \r\n                                LEFT JOIN cp_abs b\r\n                                ON a.id_abs = b.id\r\n                                LEFT JOIN hrana c\r\n                                ON b.id_hrana = c.id\r\n                                WHERE a.id_cp={$cp} AND c.id={$hrana['id']}");
        $hrana_abs = $hrana_abs[0];
        //var_dump($hrana);
        if (!empty($hrana_abs[hodnota])) {
            $message .= riadok_print_cp($hrana_abs[abs], $hrana_abs[cena], $hrana_abs[sum], $hrana_abs[hodnota]);
            $full_sum += $hrana_abs[sum];
        }
        $hrana_sluzba = sql_query("SELECT a.cena abs, b.cena, a.sum, c.hodnota from cp_hrana_sluzba a \r\n                                LEFT JOIN cp_abs_sluzba b\r\n                                ON a.id_abs = b.id\r\n                                LEFT JOIN hrana c\r\n                                ON b.id_hrana = c.id\r\n                                WHERE a.id_cp={$cp} AND c.id={$hrana['id']}");
        $hrana_sluzba = $hrana_sluzba[0];
        //var_dump($hrana);
        if (!empty($hrana_sluzba[hodnota])) {
            $message .= riadok_print_cp($hrana_sluzba[abs], $hrana_sluzba[cena], $hrana_sluzba[sum], "- olepenie " . $hrana_sluzba[hodnota]);
            $full_sum += $hrana_sluzba[sum];
        }
    }
    $message .= riadok_print_cp($data_narez[lepenie], $data_narez[lepenie_cena], $data_narez[lepenie_sum], "Lepenie");
    $full_sum += $data_narez[lepenie_sum];
    $message .= riadok_print_cp($data_narez[cnc_priprava], $data_narez[cnc_priprava_cena], $data_narez[cnc_priprava_sum], "CNC programovanie");
    $full_sum += $data_narez[cnc_priprava_sum];
    $message .= riadok_print_cp($data_narez[cnc_praca], $data_narez[cnc_praca_cena], $data_narez[cnc_praca_sum], "CNC práca");
    $full_sum += $data_narez[cnc_praca_sum];
    $message .= riadok_print_cp($data_narez[olep_obluk], $data_narez[olep_obluk_cena], $data_narez[olep_obluk_sum], "Olep oblúkov");
    $full_sum += $data_narez[olep_obluk_sum];
    $num_sluzba = sql_query("SELECT popis, hodnota, cena, sum FROM cp_sluzba WHERE id_cp={$cp} ORDER BY id");
    foreach ($num_sluzba as $sluzba) {
        //var_dump($sluzba);
        if (!empty($sluzba[popis])) {
            $message .= riadok_print_cp($sluzba[hodnota], $sluzba[cena], $sluzba[sum], $sluzba[popis]);
            //var_dump($hrana[sum]);
            $full_sum = $full_sum + $sluzba[sum];
        }
    }
    $full_sum = ceil(($full_sum + $full_sum * 0.2) * 100) / 100;
    $message .= "</table>";
    $message .= "<div class=\"cp_spolu\"><strong>Cena spolu: </strong>{$full_sum} €</div>";
    $message .= "dokument vytvorený: " . date("j. n. Y - H:i") . "<br>\r\n                        Ceny sú uvádzané s DPH<br>";
    return $message;
}
예제 #24
0
// vloženie hlavičky stránky
mysql_query("BEGIN");
$query = "SELECT id FROM `uzivatel` where vymaz=0 AND\r\n                        skupina=2 \r\n                        ORDER BY id";
$uzivatel = sql_query($query);
foreach ($uzivatel as $uzivatel_item) {
    //var_dump($uzivatel_item);
    for ($i = $mesiac_pred; $i <= $mesiac_present; $i++) {
        $ij = $i;
        $rok = date("Y");
        if ($i < 1) {
            $ij = 12 + $i;
            $rok = $rok - 1;
        }
        $cp_sum_all = 0;
        //echo $i. "<br>";
        $query = "SELECT max(id) id from revizia WHERE id_obj IN (\r\n                        SELECT id FROM `objednavka` where vymaz=0 AND\r\n                        status<>" . def_value("default_obj_status_rozpracovana", "hodnota") . " AND \r\n                         status<>" . def_value("default_obj_status_cp", "hodnota") . " AND\r\n                        (datum between \"{$rok}-{$ij}-01 00:00:00\" AND \"{$rok}-{$ij}-31 23:59:59\")\r\n                            AND id_zakaznik={$uzivatel_item[id]}\r\n                       )\r\n                GROUP BY id_obj\r\n                ";
        //die();
        $last_revision = sql_query($query);
        //var_dump($last_revision);
        //echo $i ."-".$uzivatel_item[id]. " - ". $last_revision[id] ."<br>";
        // ====== statistiky pre stvoraky =============
        //=============================================
        foreach ($last_revision as $rev_id) {
            $query = "SELECT all_sum dlzka from cp \r\n                        WHERE id_revizia=\"{$rev_id["id"]}\" ORDER BY id DESC LIMIT 1";
            $all_sum = sql_query($query);
            //var_dump($all_sum);
            $cp_sum_all = $cp_sum_all + $all_sum[0][dlzka];
            //var_dump($stvorak_sum);
            //$hrana_sum[$ij][$hrana["id"]] = $hrana_sum[$ij][$hrana["id"]] / 1000;
            $cp_sum_all = round($cp_sum_all, 2);
            $stats_exists = sql_query("SELECT id from stats_uzivatel_cp\r\n                                        WHERE rok={$rok} AND mesiac={$ij} AND id_uzivatel=\"{$uzivatel_item[id]}\" LIMIT 1");
예제 #25
0
$rok = 2013;
for ($i = 1; $i <= 12; $i++) {
    $query = "SELECT count(id) pocet FROM `objednavka` where vymaz=0 AND\n                        status<>" . def_value("default_obj_status_rozpracovana", "hodnota") . " AND\n                        datum between \"2013-{$i}-01\" AND last_day(\"2013-{$i}-01\")\n                        ORDER BY datum DESC";
    $mesiac = sql_query($query);
    $mesiac = $mesiac[0][pocet];
    $stats_exists = sql_query("SELECT id from stats_objednavka\n                                    WHERE rok={$rok} AND mesiac={$i} LIMIT 1");
    if (count($stats_exists) == 1) {
        //echo "existuje<br>";
        sql_update("UPDATE stats_objednavka SET\n                        hodnota={$mesiac} WHERE rok=\"{$rok}\" AND mesiac=\"{$i}\" ");
    } else {
        //echo "neexistuje<br>";
        sql_insert("INSERT into stats_objednavka (rok, mesiac, hodnota)\n                        VALUES ({$rok}, {$i}, {$mesiac})");
    }
}
for ($i = 1; $i <= 12; $i++) {
    $query = "SELECT max(id) id from revizia WHERE id_obj IN (\n                        SELECT id FROM `objednavka` where vymaz=0 AND\n                        status<>" . def_value("default_obj_status_rozpracovana", "hodnota") . " AND\n                        datum between \"2013-{$i}-01\" AND last_day(\"2013-{$i}-01\")\n                       )\n                GROUP BY id_obj\n                ";
    //print_r($query);
    //die();
    $mesiac_stvorak = sql_query($query);
    $stvorak_sum = 0;
    foreach ($mesiac_stvorak as $value) {
        $query = "SELECT sum(stvorak) stvorak from porez WHERE id_revizia=\"{$value["id"]}\"";
        $stvorak = sql_query($query);
        $stvorak_sum = $stvorak_sum + $stvorak[0][stvorak];
        //var_dump($stvorak_sum);
    }
    $stvorak_sum = round($stvorak_sum, 2);
    //var_dump($mesiac_stvorak);
    $stats_exists = sql_query("SELECT id from stats_stvorak\n                                    WHERE rok={$rok} AND mesiac={$i} LIMIT 1");
    if (count($stats_exists) == 1) {
        //echo "existuje<br>";