2025-06-16 18:28:08 +05:00

196 lines
7.0 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
ini_set('display_errors', 0);
$test['Без ФН'] = 1;
$test['Фискальный накопитель 15 месяцев'] = 2;
$test['Фискальный накопитель 36 месяцев'] = 3;
$mainMassiv['price'] = $test;
//print_r($mainMassiv);
$j = \json::to_j($mainMassiv);
//echo $j;
class modClass
{
static function getTovarHars()
{
$har = \DB::getAll("SELECT * FROM `tovar_har` WHERE `tovar_id`=?", $_GET['id']);
$c = count($har);
for ($i = 0; $i < $c; $i++)
$har[$i]['opt'] = \DB::getValue("SELECT `txt` FROM `tovar_har_sp` WHERE `id`=? LIMIT 1", $har[$i]['tovar_har_sp_id']);
return $har;
}
}
$smarty->assign('hars', modClass::getTovarHars());
class moduleClass
{
/* ----------------------------------------------------------------------
10.11.2023
Получаем цены на характеристики
---------------------------------------------------------------------- */
static function getPrice()
{
$json = \DB::getValue('SELECT `json` FROM `tovar` WHERE `id`=?', $_GET['id']);
$massiv = \json::from_j($json)['price'];
$i = 0;
foreach ($massiv as $key => $value) {
$har[$i] = $key;
$val[$i] = $value;
$i++;
}
$res[0] = $har;
$res[1] = $val;
//print_r($har);
//print_r($val);
return $res;
}
}
$smarty->assign('price', moduleClass::getPrice());
//проверяем авторизацию
if ($_SESSION['dostup'] !== 'a' && $_SESSION['dostup'] !== 'e')
header('Location: /403/');
/* ----------------------------------------------------------------------
20.03.2023
Сохраняем товар
---------------------------------------------------------------------- */
if (@$_POST['ok']) {
$_POST['status'] = ($_POST['status'] == 'on') ? 1 : 0;
$_POST['zakazEnable'] = ($_POST['zakazEnable'] == 'on') ? 1 : 0;
if ($_GET['id']) {//Обновляем
\DB::set(
"UPDATE `tovar` SET `title`=?, `cena`=?, `keywords`=?, `description`=?, `artikul`=?, `category`=?, `zakazEnable`=?, `status`=?, `alias`=?, `txt`=?, `site`=?, `support`=?, `donor`=? WHERE `id`=?",
array(
$_POST['title'],
$_POST['cena'],
$_POST['keywords'],
$_POST['description'],
$_POST['artikul'],
$_POST['category'],
$_POST['zakazEnable'],
$_POST['status'],
$_POST['alias'],
$_POST['txt'],
$_SERVER['SERVER_NAME'],
$_POST['support'],
$_POST['donor'],
$_GET['id']
)
);
\DB::set("UPDATE `tovar_barcode` SET `barcode`=? WHERE `tovar_id`=?", array($_POST['barcode'], $_GET['id']));
} else {//Добавляем
$inser_id = \DB::add("INSERT INTO `tovar` (`title`, `cena`, `keywords`, `description` , `artikul`, `category`, `zakazEnable`, `status`, `alias`, `txt`, `site`, `support`, `donor`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(
$_POST['title'],
$_POST['cena'],
$_POST['keywords'],
$_POST['description'],
$_POST['artikul'],
$_POST['category'],
$_POST['zakazEnable'],
$_POST['status'],
$_POST['alias'],
$_POST['txt'],
$_SERVER['SERVER_NAME'],
$_POST['support'],
$_POST['donor']
)
);
if ($_POST['barcode'])
\DB::add("INSERT INTO `tovar_barcode` (`tovar_id`, `barcode`) VALUES (?, ?)", array($inser_id, $_POST['barcode']));
header('Location: /a_new_tovar/' . $inser_id);
}
}
/* ----------------------------------------------------------------------
14.12.2022
Получаем инфу о пользователе
---------------------------------------------------------------------- */
$smarty->assign('userInfo', \core::getUserInfo($_SESSION['user_id']));
/* ----------------------------------------------------------------------
06.09.2022
Сессия для загрузки картинок
---------------------------------------------------------------------- */
$_SESSION['tovar_id'] = $_GET['id'];
/* ----------------------------------------------------------------------
21.08.2022
Получаем список категорий
---------------------------------------------------------------------- */
$cats = \DB::getAll("SELECT * FROM `tovar_category` WHERE `status`=1 ORDER BY `title`");
$smarty->assign('cats', $cats);
/* ----------------------------------------------------------------------
23.08.2022
Получаем данные о товаре
05.09.2022
Получаем картинки
08.09.2022
Получаем характеристики
---------------------------------------------------------------------- */
if (@$_GET['id']) {
$tovar = \DB::getAll("SELECT * FROM `tovar` WHERE `id`=? LIMIT 1", $_GET['id']);
$smarty->assign('tovar', $tovar);
$imgs = \DB::getAll("SELECT * FROM `tovar_img` WHERE `tovar_id`=?", $_GET['id']);
$smarty->assign('imgs', $imgs);
//print_r($imgs);
//$har=\DB::getAll("SELECT * FROM `tovar_img` WHERE `tovar_id`=?", $_GET['id']);
//$smarty -> assign ( 'har', $mod -> getHar( ID ) );
if (!$tovar[0]['sezon']) {
$tmp[1] = 0;
$tmp[2] = 0;
$tmp[3] = 0;
$tmp[4] = 0;
$tmp[5] = 0;
$tmp[6] = 0;
$tmp[7] = 0;
$tmp[8] = 0;
$tmp[9] = 0;
$tmp[10] = 0;
$tmp[11] = 0;
$tmp[12] = 0;
$json_sezon = \json::to_j($tmp);
\DB::set("UPDATE `tovar` SET `sezon`=? WHERE `id`=?", array($json_sezon, $_GET['id']));
} else {
$smarty->assign('sezon', \json::from_j($tovar[0]['sezon']));
}
}
/* ----------------------------------------------------------------------
05.09.2022
Сохраняем товар и открываем его сохраненную карточку
!!! Сохранение описания в json
---------------------------------------------------------------------- */
//if ( $_POST['act'] == 'addTovar' ) header ( 'Location: /a_new_tovar/' . $mod -> addTovar( $_POST ) );
/* ----------------------------------------------------------------------
06.09.2022
Редактируем товар
!!! Сохранение описания в json
---------------------------------------------------------------------- */
//if ( $_POST['act'] == 'editTovar' && ID ) $mod -> editTovar( $_POST, ID );
/* ----------------------------------------------------------------------
---------------------------------------------------------------------- */
?>