core/api/modules/a_edit_cat/class.php

73 lines
2.6 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
class main extends MySQL{
/* ----------------------------------------------------------------------
23.08.2022
Добавляем товар и выдаем ИД
04.08.2022
Добавлен элемент $a['public']
---------------------------------------------------------------------- */
function addCat( $massiv ){
//echo 'test';
$a['parent'] = ( $massiv['parent'] ) ? $massiv['parent'] : 0;
$a['txt'] = $massiv['txt'];
$a['t'] = time();
$a['tip'] = 'tovarCat';
$a['user_id'] = $_SESSION['user_id'];
$a['public'] = ($massiv['public'] == 'on' ) ? 1 : 0;
$a['opisanie'] = $this -> json_prepare( $massiv['opisanie'] );
return $this -> add( 'pages', $a );
}
/* ----------------------------------------------------------------------
07.09.2022
Редактирование товара
17.09.2022
Сохранение описания в json
---------------------------------------------------------------------- */
function editCat( $massiv, $id ){
$this -> debug = 1;
//Получаем данные json и суваем в массив
unset($a);
$a['opisanie']=$this->json_prepare($massiv['opisanie']);
$a['parent'] = ( $massiv['parent'] ) ? $massiv['parent'] : 0;
$a['txt'] = $massiv['txt'];
$a['t'] = time();
$a['tip'] = 'tovarCat';
$a['user_id'] = $_SESSION['user_id'];
$a['public'] = ( $massiv['public'] == 'on' ) ? 1 : 0;
$this -> update( 'pages', $id, $a );
//header ( 'Location: /a_edit_cat/' . $id );
}
/* ----------------------------------------------------------------------
23.08.2022
Получаем данные о товаре
---------------------------------------------------------------------- */
function getCat($id){
$this -> debug = 1;
$a['id'] = $id;
$a['tip'] = 'tovarCat';
$massiv = $this -> get_massiv( 'pages', $a, '', 1 );
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' );
}
}
?>