2022-12-11 13:55:49 +05:00
|
|
|
|
<?php
|
2022-12-17 18:15:09 +05:00
|
|
|
|
ini_set( 'display_errors', 0 );
|
|
|
|
|
|
|
|
|
|
function convert_ligat($tovar_id_1c, $id){
|
|
|
|
|
|
|
|
|
|
$check_id = \DB::getValue("SELECT `id` FROM `tovar_har` WHERE `tovar_id`=? LIMIT 1", $id);
|
|
|
|
|
if (!$check_id){
|
|
|
|
|
$oldId=\DB::getValue("SELECT `id` FROM `pages` WHERE `tovar_id`=?", $tovar_id_1c);
|
|
|
|
|
//Ищем характеристики в старой таблице, кладем в новую
|
|
|
|
|
$hars=\DB::getAll( "SELECT `sp_har_id`, `txt` FROM `har` WHERE `tovar_id`=?", $oldId );
|
|
|
|
|
for ($i=0; $i<count($hars); $i++) $insert_id = \DB::add( "INSERT INTO `tovar_har` (`tovar_har_sp_id`, `tovar_id`, `txt`) VALUES(?, ?, ?)", array( $hars[$i]['sp_har_id'], $id, $hars[$i]['txt'] ) );
|
2022-12-11 13:55:49 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-17 18:15:09 +05:00
|
|
|
|
function get_artikul( $txt, $id ){
|
|
|
|
|
$space=mb_substr( $txt, 6, 1 );
|
|
|
|
|
if ($space==" "){
|
|
|
|
|
$artikul=mb_substr( $txt, 0, 6 );
|
|
|
|
|
\DB::set( "UPDATE `tovar` SET `artikul`=? WHERE `id`=? LIMIT 1", array( $artikul, $id ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
2022-12-17 18:15:09 +05:00
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
17.12.2022
|
|
|
|
|
Получаем данные о товаре
|
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
$page = \DB::getAll( "SELECT * FROM `tovar` WHERE `id`=?", $_GET['id'] );
|
|
|
|
|
$page[0]['date'] = date( 'd.m.Y', @$page[0]['t'] );
|
2022-12-24 21:12:23 +05:00
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
17.12.2022
|
|
|
|
|
Получаем данные о последней цене на товар
|
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
$page[0]['cena']= \DB::getValue ( "SELECT `cena` FROM `tovar_price_history` WHERE `status`=1 AND `tovar_id`=? ORDER BY `t` DESC", $_GET['id']);
|
|
|
|
|
|
|
|
|
|
|
2022-12-17 18:15:09 +05:00
|
|
|
|
$smarty -> assign( 'page', $page );
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
2022-12-17 18:15:09 +05:00
|
|
|
|
if ( $page[0]['tovar_id_1c'] ) convert_ligat( $page[0]['tovar_id_1c'], $_GET['id'] );
|
|
|
|
|
if ( !$page[0]['artikul'] ) get_artikul( $page[0]['title'], $_GET['id'] );
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
2022-12-17 18:15:09 +05:00
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
17.12.2022
|
|
|
|
|
Получаем картинки
|
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
$imagesTovar = \DB::getAll( "SELECT * FROM `tovar_img` WHERE `tovar_id`=?", $_GET['id'] );
|
|
|
|
|
$smarty -> assign( 'imagesTovar', $imagesTovar );
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
17.12.2022
|
|
|
|
|
Получаем характеристики из БД
|
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
$har = \DB::getAll( "SELECT * FROM `tovar_har` WHERE `tovar_id`=?", $_GET['id'] );
|
|
|
|
|
for ( $i=0; $i < count( $har ); $i++ ) $har[$i]['opt']=\DB::getValue("SELECT `txt` FROM `sp_har` WHERE `id`=?", $har[$i]['tovar_har_sp_id']);
|
|
|
|
|
$smarty -> assign( 'har', $har );
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
17.12.2022
|
|
|
|
|
Пишем историю
|
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
$session_id = ( $_SESSION['user_id'] ) ? $_SESSION['user_id'] : session_id();
|
|
|
|
|
unset($id);
|
|
|
|
|
$id=\DB::getValue("SELECT `id` FROM `tovar_history` WHERE `tovar_id`=? AND `session_id`=?", array( $_GET['id'], $session_id ) );
|
|
|
|
|
if (!$id) \DB::add( "INSERT INTO `tovar_history` (`tovar_id`, `session_id`, `t`) VALUES (?, ?, ?)", array( $_GET['id'], $session_id, time() ) );
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
2022-12-17 18:15:09 +05:00
|
|
|
|
|
|
|
|
|
/*
|
2022-12-11 13:55:49 +05:00
|
|
|
|
//ищем картинки
|
|
|
|
|
unset($a);
|
|
|
|
|
$a['page_id']=ID;
|
|
|
|
|
$imagesTovar=$db->get_massiv('img', $a);
|
|
|
|
|
|
2022-12-17 18:15:09 +05:00
|
|
|
|
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
|
|
|
|
/* tk-ligat.ru */
|
2022-12-17 18:15:09 +05:00
|
|
|
|
/*if ($_SERVER['SERVER_NAME']=='tk-ligat.ru')require_once MYDIR . '/api/modules/tovar_show/tk-ligat.php';
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* проверяем, есть ли товар в корзине */
|
2022-12-17 18:15:09 +05:00
|
|
|
|
/*unset($a);
|
2022-12-11 13:55:49 +05:00
|
|
|
|
$a['pages_id']=ID;
|
|
|
|
|
if ($_SESSION['user_id'])$a['user_id']=$_SESSION['user_id'];else $a['user_id']=session_id();
|
|
|
|
|
$kolvo_in_cart=$db->get_val('cart', $a, 'kolvo');
|
|
|
|
|
|
|
|
|
|
if(@$kolvo_in_cart)$page[0]['kolvo_in_cart']=$kolvo_in_cart;
|
|
|
|
|
|
2022-12-17 18:15:09 +05:00
|
|
|
|
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
|
|
|
|
//Получаем данные о категории
|
|
|
|
|
if ( $page[0]['parent'] !=0 ) $cat_info = $mod -> get_cat_info ( $page[0]['parent'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
31.05.2022
|
|
|
|
|
Берем рандомный список товаров из этой же категории - с картинками!
|
|
|
|
|
---------------------------------------------------------------------- */
|
2022-12-17 18:15:09 +05:00
|
|
|
|
/*$smarty->assign('rndTovar', $mod->get_random_tovar(8, $page[0]['parent']));
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
01.06.2022
|
|
|
|
|
Пишем в историю просмотров что смотрели, чтоб навящиво выводить
|
|
|
|
|
---------------------------------------------------------------------- */
|
2022-12-17 18:15:09 +05:00
|
|
|
|
//$mod -> to_history();
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
01.06.2022
|
|
|
|
|
Читаем историю просмотров
|
|
|
|
|
---------------------------------------------------------------------- */
|
2022-12-17 18:15:09 +05:00
|
|
|
|
//$smarty -> assign( 'tovarFromHistory', $mod -> from_history( 8 ) );
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
10.06.2022
|
|
|
|
|
Получаем характеристики из БД
|
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
|
2022-12-17 18:15:09 +05:00
|
|
|
|
//$smarty -> assign( 'har', $mod -> get_harakteriskika() );
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
|
|
|
|
?>
|