105 lines
3.8 KiB
PHP
105 lines
3.8 KiB
PHP
<?php
|
||
class main extends MySQL{
|
||
var $id;
|
||
var $mod_settings;
|
||
|
||
|
||
|
||
/* ----------------------------------------------------------------------
|
||
23.08.2022
|
||
Добавляем товар и выдаем ИД
|
||
04.08.2022
|
||
Добавлен элемент $a['public']
|
||
08.09.2022
|
||
Сохранение описания в json - исправлено
|
||
17.09.2022
|
||
Добавлен zakazEnable
|
||
---------------------------------------------------------------------- */
|
||
|
||
function addTovar( $massiv ){
|
||
//echo 'test';
|
||
$a['parent'] = $massiv['parent'];
|
||
$a['txt'] = $massiv['txt'];
|
||
$a['t'] = time();
|
||
$a['tip'] = 'tovar';
|
||
$a['user_id'] = $_SESSION['user_id'];
|
||
$a['artikul'] = $massiv['artikul'];
|
||
$a['barcode'] = $massiv['barcode'];
|
||
$a['public'] = ($massiv['public'] == 'on' ) ? 1 : 0;
|
||
$a['zakazEnable'] = ( $massiv['zakazEnable'] == 'on' ) ? 1 : 0;
|
||
unset( $b );
|
||
$a['opisanie'] = $this -> json_prepare( $massiv['opisanie'] );
|
||
return $this -> add( 'pages', $a );
|
||
}
|
||
|
||
/* ----------------------------------------------------------------------
|
||
07.09.2022
|
||
Редактирование товара
|
||
17.09.2022
|
||
Сохранение описания в json
|
||
---------------------------------------------------------------------- */
|
||
|
||
function editTovar( $massiv, $id ){
|
||
$this -> debug = 1;
|
||
//Получаем данные json и суваем в массив
|
||
unset($a);
|
||
$a['opisanie']=$this->json_prepare($massiv['opisanie']);
|
||
$a['parent'] = $massiv['parent'];
|
||
$a['txt'] = $this->json_prepare($massiv['txt']);
|
||
$a['t'] = time();
|
||
$a['tip'] = 'tovar';
|
||
$a['user_id'] = $_SESSION['user_id'];
|
||
$a['artikul'] = $massiv['artikul'];
|
||
$a['barcode'] = $massiv['barcode'];
|
||
$a['public'] = ( $massiv['public'] == 'on' ) ? 1 : 0;
|
||
$a['zakazEnable'] = ($massiv['zakazEnable']=='on') ? 1 : 0;
|
||
$this -> update( 'pages', $id, $a );
|
||
header ( 'Location: /a_new_tovar/' . $id );
|
||
}
|
||
|
||
|
||
/* ----------------------------------------------------------------------
|
||
23.08.2022
|
||
Получаем данные о товаре
|
||
---------------------------------------------------------------------- */
|
||
|
||
function getTovar($id){
|
||
$this -> debug = 1;
|
||
$a['id'] = $id;
|
||
$massiv = $this -> get_massiv( 'pages', $a, '', 1 );
|
||
// $opisanie = $this -> from_j ( $this -> json_fix ( $massiv[0]['json'] ) );
|
||
// $massiv[0]['opisanie'] = $opisanie['opisanie'];
|
||
//print_r($massiv);
|
||
return $massiv;
|
||
}
|
||
|
||
/* ----------------------------------------------------------------------
|
||
21.08.2022
|
||
Получаем список категорий
|
||
---------------------------------------------------------------------- */
|
||
function get_tovar_cats(){
|
||
//$a['parent'] = ($id) ? $id : 0; // Если есть ИД ищем по паренту иначе - корень - 0
|
||
$a['tip'] = 'tovarCat';
|
||
$a['public'] = '1';
|
||
return $this -> get_massiv( 'pages', $a, 'txt' );
|
||
}
|
||
|
||
/* ----------------------------------------------------------------------
|
||
08.09.2022
|
||
Получаем характеристики товара
|
||
---------------------------------------------------------------------- */
|
||
|
||
function getHar($id){
|
||
$this -> debug = 1;
|
||
$a['pages_id'] = $id;
|
||
$massiv = $this -> get_massiv( 'har', $a);
|
||
$count=count($massiv);
|
||
for ($i=0; $i<$count; $i++){
|
||
unset($a);
|
||
$a['id']=$massiv[$i]['sp_har_id'];
|
||
$massiv[$i]['har']=$this->get_val('sp_har', $a, 'txt');
|
||
}
|
||
return $massiv;
|
||
}
|
||
}
|
||
?>
|