<?php include "models/function.php"; IncludeClass::inc(array("Product")); if (isset($_POST["go"])) { $nn = DB::selectAI("price"); $attr = AttrValue::conbine($_POST["attr"], $_POST["val"]); if (isset($_POST["related"]) and $_POST["related"]) { $related = array_slice($_POST["related"], 0, 3); $data_related = serialize($related); } else { $data_related = ""; } $arrText = array("section" => $_POST['section'], "collection" => $_POST['collection'], "exclusive" => $_POST['exclusive'], "name" => $_POST['name'], "nomer" => $_POST['nomer'], "code" => $_POST['code'], "size" => $_POST['size'], "material" => $_POST['material'], "proba" => $_POST['proba'], "vstavki" => $_POST['vstavki'], "weight" => $_POST['weight'], "price" => $_POST['price'], "price_old" => $_POST['price_old'], "attr" => $attr, "related" => $data_related, "title" => $_POST['title'], "description" => $_POST['description'], "keywords" => $_POST['keywords']); if ($_POST["go"] == "save") { $arrText += array('nn' => $nn, 'sk40' => 0, 'sk50' => 0); if (isset($arrText['related']) && !empty($arrText['related'])) { //$next_sql = " AND NOT id="; $proverka = DB::selectParam('price', 'nomer', $arrText['nomer'], false, false, false, false); $arr_prov = array("related" => $arrText['related']); if ($proverka != false && empty($proverka['related'])) { foreach ($proverka as $prov) { DB::update(DB::updateSql("price", $arr_prov), $arr_prov, $prov['id']); } } } $lastId = DB::insert(DB::insertSql("price", $arrText), $arrText); } else { $lastId = $_POST["go"]; if (isset($arrText['related']) && !empty($arrText['related'])) { $next_sql = " AND NOT id=" . $lastId;
$fileBody = $_POST['tmpPhoto']; if ($fileBody) { $fileName = $dir . uniqid(); preg_match('#data:image\\/(png|jpg|jpeg|gif);#', $fileBody, $fileTypeMatch); $fileType = $fileTypeMatch[1]; $fileBody = preg_replace('#^data.*?base64,#', '', $fileBody); $fileBody = base64_decode($fileBody); $nameFile = $fileName . '.' . $fileType; file_put_contents($nameFile, $fileBody); $photo = str_replace('../', '', $nameFile); } else { $photo = ""; } $array = array("section" => $_POST["section"], "name" => $_POST["name"], "img" => $photo); if ($_POST["product"] == "save") { $array += array("nn" => DB::selectAI("price")); DB::insert(DB::insertSql("price", $array), $array); header("Location: production.php?id=" . $_POST["section"] . "&table=catalog"); } else { DB::update(DB::updateSql("price", $array), $array, $_POST['go']); header("Location: " . $_SERVER['REQUEST_URI']); } } if (isset($_GET["delete"])) { DB::del($_GET["title"], $_GET["delete"]); if (isset($_GET["act"]) and $_GET["act"]) { header("Location: production.php?id=" . $_GET["act"] . "&table=catalog"); } else { header("Location: production.php"); } }
$fileBody = $_POST['tmpPhoto']; if ($fileBody) { $fileName = $dir . uniqid(); preg_match('#data:image\\/(png|jpg|jpeg|gif);#', $fileBody, $fileTypeMatch); $fileType = $fileTypeMatch[1]; $fileBody = preg_replace('#^data.*?base64,#', '', $fileBody); $fileBody = base64_decode($fileBody); $nameFile = $fileName . '.' . $fileType; file_put_contents($nameFile, $fileBody); $photo = str_replace('../', '', $nameFile); } else { $photo = ""; } $array = array("section" => $_POST["section"], "name" => $_POST["name"], "nomer" => $_POST["nomer"], "brand" => $_POST["brand"], "viscous" => $_POST["viscous"], "type" => $_POST["type"], "volume" => $_POST["volume"], "kol" => $_POST["kol"], "price" => $_POST["price"], "text" => $_POST["text"], "related" => $data_related, "attr" => $data_attr, "title" => $_POST['title'], "description" => $_POST['description'], "keywords" => $_POST['keywords'], "img" => $photo, "img_title" => $_POST['img_title'], "img_alt" => $_POST['img_alt']); if ($_POST["go"] == "save") { $array += array("nn" => DB::selectAI("price"), "best" => 0, "hide" => 0); DB::insert(DB::insertSql("price", $array), $array); header("Location: production.php?id=" . $_POST["section"] . "&table=catalog"); } else { $photoNow = DB::selectID("price", $_POST['go'])[0]["img"]; if ($photoNow) { if (file_exists("../" . $photoNow)) { unlink("../" . $photoNow); } } DB::update(DB::updateSql("price", $array), $array, $_POST['go']); header("Location: production.php?id=" . $_POST["section"] . "&table=catalog"); } } $record = false; if (isset($_GET["edit"])) {
<?php include "controller/function.php"; $table = "catalog"; $title = "Каталог продукции"; $records = false; if (isset($_POST["go"])) { if ($_POST["name_en"]) { $url = Rename::replace($_POST["name_en"]); } else { $url = Rename::replace($_POST["name_ru"]); } $save = array("parent" => $_POST["section"], "name_ru" => $_POST["name_ru"], "name_en" => $url, "title" => $_POST['title'], "desc" => $_POST['desc'], "keywords" => $_POST['keywords']); if ($_POST["go"] == "save") { $save += array("nn" => DB::selectAI($table)); DB::insert(DB::insertSql($table, $save), $save); header("Location: " . $_SERVER['REQUEST_URI']); } else { DB::update(DB::updateSql($table, $save), $save, $_POST['go']); header("Location: " . $_SERVER['REQUEST_URI']); } } if (isset($_GET["delete"])) { DB::del($_GET["title"], $_GET["delete"]); if (isset($_GET["act"]) and $_GET["act"]) { header("Location: production.php?id=" . $_GET["act"] . "&table=catalog"); } else { header("Location: production.php"); } } if (isset($_GET["id"])) {
<?php include "models/function.php"; IncludeClass::inc(array("Catalog")); $param = "catalog"; $record = false; if (isset($_POST["go"])) { if (!$_POST["name_en"]) { $_POST["name_en"] = Rename::replace($_POST["name_ru"]); } else { $_POST["name_en"] = Rename::replace($_POST["name_en"]); } if ($_POST["go"] == "save") { array_pop($_POST); $_POST['nn'] = DB::selectAI($param); DB::insert(DB::insertSql($param, $_POST), $_POST); header("Location: " . $_SERVER['REQUEST_URI']); } else { $id = array_pop($_POST); DB::update(DB::updateSql($param, $_POST), $_POST, $id); header("Location: " . $_SERVER['REQUEST_URI']); } } if (isset($_GET["delete"])) { Delete::del($_GET["title"], $_GET["delete"]); header("Location: production.php"); } if (isset($_GET["id"])) { $record = DB::selectParam('price', 'section', $_GET["id"], 'nn|ASC', false); } require_once 'view/tpl_top.php';