use Yii;
use yii\helpers\ArrayHelper;
-use yii\helpers\Html;
use yii\web\Controller;
use yii_app\records\ExportImportTable;
use yii_app\records\Prices;
class ProductsController extends Controller
{
- public function actionProducts1c() {
-
+ public function actionProducts1c()
+ {
$id = Yii::$app->request->get('id', null);
if (!empty($id)) {
- $id = (int) $id;
+ $id = (int)$id;
}
-
-
$productsClassData = ProductsClass::find()->all();
$products_class_row = [];
foreach ($productsClassData as $row) {
-
$products_class_row[$row->category_id][] = $row->tip;
}
-
$pricesData = Prices::find()->all();
$prices = [];
foreach ($pricesData as $row) {
-
$prices[$row->product_id] = $row->price;
}
-
$groupsData = Products1c::find()
->select(['id', 'name', 'parent_id'])
->where(['tip' => 'products_group'])
$groups = [];
$groups_arr = [];
foreach ($groupsData as $row) {
-
$groups[$row->id] = $row->name;
-
$groups_arr[$row->parent_id][$row->id] = $row;
}
-
return $this->render('products-1c', [
'id' => $id,
'products_class_row' => $products_class_row,
'groups' => $groups,
'groups_arr' => $groups_arr,
]);
-
-
}
// Старый функционал
//TODO Просмотр опций - кнопку убрал
- public function actionAjaxProductProvider()
- {
- $id = Yii::$app->request->post('id');
- if (!empty($id)) {
- $id = htmlentities($id);
-
-
- $providers = ShipmentProviders::find()
- ->select(['id', 'name'])
- ->indexBy('id')
- // ->asArray()
- ->all();
- $providers = ArrayHelper::map($providers, 'id', 'name');
-
-
- $data = Products1cOptions::find()
- ->where(['id' => $id])
- ->one();
-
-
- $view = Products1c::find()
- ->select('view')
- ->where(['id' => $id])
- ->scalar();
-
-
- $productColorsArray = explode(';', $data->colors ?? '');
-
-
- $productGroups = [
- "1" => "Голландия/Израиль",
- 2 => "Кения",
- 3 => "Эквадор/Колумбия",
- 4 => "Россия",
- 5 => "Горшечка",
- 6 => "Сопутка",
- 7 => "Фейерверки",
- 10 => "Матрица"
- ];
-
-
-
- $dataResponse = '<div id=result_prov></div><form method=post class="row" action="">';
- $dataResponse .= '<div class="col-6 text-right">Поставщик</div>
- <div class="col-6"><select class="form-control" id=provider_id name=provider_id>';
- foreach($providers as $idv =>$name) {
- $dataResponse .= "<option value=".$idv."";
- if(($data['provider_id'] ??'')==$idv) $dataResponse .= " selected"; $dataResponse .= ">".$name."</option>";
+ public function actionAjaxProductProvider()
+ {
+ $id = Yii::$app->request->post('id');
+ if (!empty($id)) {
+ $id = htmlentities($id);
+ $providers = ShipmentProviders::find()
+ ->select(['id', 'name'])
+ ->indexBy('id')
+ // ->asArray()
+ ->all();
+ $providers = ArrayHelper::map($providers, 'id', 'name');
+ $data = Products1cOptions::find()
+ ->where(['id' => $id])
+ ->one();
+
+ $view = Products1c::find()
+ ->select('view')
+ ->where(['id' => $id])
+ ->scalar();
+
+ $productColorsArray = explode(';', $data->colors ?? '');
+
+ $productGroups = [
+ "1" => "Голландия/Израиль",
+ 2 => "Кения",
+ 3 => "Эквадор/Колумбия",
+ 4 => "Россия",
+ 5 => "Горшечка",
+ 6 => "Сопутка",
+ 7 => "Фейерверки",
+ 10 => "Матрица"
+ ];
+
+ $dataResponse = '<div id=result_prov></div><form method=post class="row" action="">';
+ $dataResponse .= '<div class="col-6 text-right">Поставщик</div>
+ <div class="col-6"><select class="form-control" id=provider_id name=provider_id>';
+ foreach ($providers as $idv => $name) {
+ $dataResponse .= "<option value=" . $idv . "";
+ if (($data['provider_id'] ?? '') == $idv) {
+ $dataResponse .= " selected";
}
+ $dataResponse .= ">" . $name . "</option>";
+ }
- $dataResponse .= "<option value=dell ";
- if(($data['provider_id']??'')=="dell") $dataResponse .= " selected";
-
- $dataResponse .= ">удалить поставщика</option></select></div>";
-
-
- $dataResponse .= '<div class="col-6 text-right">Группа</div>
- <div class="col-6"><select class="form-control" id=group_id name=group_id><option value=0 ';
- if(empty($data['group_id'])) $dataResponse .= " selected"; $dataResponse .= '>-без группы-</option>';
- foreach($productGroups as $idv =>$name) {
- $dataResponse .= "<option value=".$idv."";
- if(($data['group_id']??'')==$idv) {
- $dataResponse .= " selected";
- $dataResponse .= ">".$name."</option>";
- }
+ $dataResponse .= "<option value=dell ";
+ if (($data['provider_id'] ?? '') == "dell") {
+ $dataResponse .= " selected";
+ }
+ $dataResponse .= ">удалить поставщика</option></select></div>";
+ $dataResponse .= '<div class="col-6 text-right">Группа</div>
+ <div class="col-6"><select class="form-control" id=group_id name=group_id>
+ <option value=0 ';
+ if (empty($data['group_id'])) {
+ $dataResponse .= " selected";
+ }
+ $dataResponse .= '>-без группы-</option>';
+ foreach ($productGroups as $idv => $name) {
+ $dataResponse .= "<option value=" . $idv . "";
+ if (($data['group_id'] ?? '') == $idv) {
+ $dataResponse .= " selected";
+ $dataResponse .= ">" . $name . "</option>";
}
- $dataResponse .= "</select></div>";
-
-
- $dataResponse .= '<div class="col-6 text-right">Основной товар?</div>
+ }
+ $dataResponse .= "</select></div>";
+ $dataResponse .= '<div class="col-6 text-right">Основной товар?</div>
<div class="col-6">
<select class="form-control" id=main name=main>
<option value=0 ';
- if(empty($data['main'])) {
- $dataResponse .= " selected";
- $dataResponse .= '>нет</option><option value=1 ';
- }
- if(!empty($data['main'])) {
- $dataResponse .= " selected";
- $dataResponse .= '>да</option>';
- $dataResponse .= "</select></div>";
- }
-
-
- $dataResponse .= '<div class="col-6 text-right">срок хранения в днях</div><div class="col-6"> <input type=number style="width:70px;" name=expiration_days id=expiration_days class="form-control" value="'. ($data['expiration_days']??'') .'"></div>
-<div class="col-6 text-right">минимальный лот деления в шт. (кол-во шт в месте)</div><div class="col-6"> <input type=number style="width:70px;" name=min_lot id=min_lot class="form-control" value="'. ($data['min_lot']??'') .'"></div>
-<div class="col-6 text-right">минимальный заказ в шт.</div>
-<div class="col-6">
- <input type=number style="width:70px;" name=min_order id=min_order class="form-control" value="'. ($data['min_order']??'') .'">
- </div>
-<div class="col-6 text-right">Цена закупки в долл. или евро (зависит от поставщика) пример 1.25</div>
-<div class="col-6">
-<input type=number style="width:70px;" name=price_zakup id=price_zakup class="form-control" value="'. ($data['price_zakup']??'') .'">
-</div>
-<div class="col-12">Цвета разделитель ;
-<textarea row=2 name=colors id=colors class="form-control">'. ($data['colors']??'') .'</textarea>
-</div>
-<div class="col-12">Опции
-<textarea row=2 name=options id=options class="form-control">'. ($data['options']??'') .'</textarea>
-</div>
-<div class="col-12">
-Сорта по цветам';
-
- foreach($productColorsArray as $color) {
- $color=trim($color);
- if(!empty($color)) {
- $dataResponse .= "<br><span class=\"btn btn-sm btn-info me-1\">$color</span>";
- }
+ if (empty($data['main'])) {
+ $dataResponse .= " selected";
+ $dataResponse .= '>нет</option><option value=1 ';
+ }
+ if (!empty($data['main'])) {
+ $dataResponse .= " selected";
+ $dataResponse .= '>да</option>';
+ $dataResponse .= "</select></div>";
+ }
+ $dataResponse .= '<div class="col-6 text-right">срок хранения в днях</div>
+ <div class="col-6">
+ <input type=number style="width:70px;" name=expiration_days
+ id=expiration_days class="form-control" value="'
+ . ($data['expiration_days'] ?? '') . '">
+ </div>
+ <div class="col-6 text-right">минимальный лот деления в шт. (кол-во шт в месте)</div>
+ <div class="col-6">
+ <input type=number style="width:70px;" name=min_lot id=min_lot class="form-control" value="'
+ . ($data['min_lot'] ?? '') . '"></div>
+ <div class="col-6 text-right">минимальный заказ в шт.</div>
+ <div class="col-6">
+ <input type=number style="width:70px;" name=min_order id=min_order class="form-control" value="'
+ . ($data['min_order'] ?? '') . '">
+ </div>
+ <div class="col-6 text-right">Цена закупки в долл. или евро (зависит от поставщика) пример 1.25</div>
+ <div class="col-6">
+ <input type=number style="width:70px;" name=price_zakup id=price_zakup class="form-control" value="'
+ . ($data['price_zakup'] ?? '') . '">
+ </div>
+ <div class="col-12">Цвета разделитель ;
+ <textarea row=2 name=colors id=colors class="form-control">' . ($data['colors'] ?? '') . '</textarea>
+ </div>
+ <div class="col-12">Опции
+ <textarea row=2 name=options id=options class="form-control">' . ($data['options'] ?? '') . '</textarea>
+ </div>
+ <div class="col-12">Сорта по цветам';
+
+ foreach ($productColorsArray as $color) {
+ $color = trim($color);
+ if (!empty($color)) {
+ $dataResponse .= "<br><span class=\"btn btn-sm btn-info me-1\">$color</span>";
}
- $dataResponse .= '</div><div class="col-12">';
- $dataResponse .= "<input type=checkbox name=view id=view ";
- if($view==1) $dataResponse .= ' value=2 checked';
- else $dataResponse .= " valiue=0";
- $dataResponse .= '> показыввать товар в автозаказе';
-
- $dataResponse .= '</div>
- <div class="col-12">
- <span class="btn btn-lg btn-success m-2" onclick="save_providerder();return false" name=sv value=1>сохранить</span></div></form>';
-
- return $dataResponse;
}
+ $dataResponse .= '</div><div class="col-12">';
+ $dataResponse .= "<input type=checkbox name=view id=view ";
+ if ($view == 1) {
+ $dataResponse .= ' value=2 checked';
+ } else {
+ $dataResponse .= " valiue=0";
+ }
+ $dataResponse .= '> показыввать товар в автозаказе';
+ $dataResponse .= '</div>
+ <div class="col-12">
+ <span class="btn btn-lg btn-success m-2" onclick="save_providerder();return false" name="sv" value="1" >сохранить</span>
+ </div>
+ </form>';
-
- return '';
+ return $dataResponse;
}
-
+ return '';
+ }
public function actionAjaxProductCharacteristics()
{
->asArray()
->all();
-
if (empty($characteristics)) {
return $this->asJson(['error' => 'Нет свойств для данного товара']);
}
-
$properties = Products1cPropType::find()
->select(['id', 'name'])
->all();
$properties = ArrayHelper::map($properties, 'id', 'name');
-
$result = [];
foreach ($characteristics as $characteristic) {
$propertyName = $properties[$characteristic['property_id']] ?? 'Неизвестное свойство';
'value' => $characteristic['value'],
];
}
-
return $this->asJson(['characteristics' => $result]);
}
-
return $this->asJson(['error' => 'Некорректный запрос']);
}
- public function actionAjaxGroupConfig() {
-
+ public function actionAjaxGroupConfig()
+ {
if (Yii::$app->request->isAjax) {
$id = Yii::$app->request->post('id');
if (!empty($id)) {
$data = ProductsClass::find()->where(['category_id' => $id])->all();
$data2 = [];
+
foreach ($data as $row) {
$data2[$row->tip] = $id;
}
-
$hints = ProductsClass::getHints();
-
return $this->asJson([
'id' => $id,
'data2' => $data2,
}
- public function actionAjaxProductsInGroup() {
-
+ public function actionAjaxProductsInGroup()
+ {
if (Yii::$app->request->isAjax) {
$parent_id = Yii::$app->request->post('parent_id');
if (!empty($parent_id)) {
->alias('p')
->select(['p.id', 'p.name', 'alias.entity_id', 'p.view'])
->leftJoin(['alias' => ExportImportTable::find()
- ->select(['export_id', 'export_val', 'entity', 'entity_id' ])],
+ ->select(['export_id', 'export_val', 'entity', 'entity_id'])],
"alias.export_id::text = p.id AND alias.export_val = '1' AND alias.entity = 'products'")
->where(['p.tip' => 'products', 'p.parent_id' => $parent_id])
->orderBy(['p.name' => SORT_ASC])
->asArray()
->all();
-
$prices = Prices::find()
->select(['product_id', 'price'])
->indexBy('product_id')
->column();
-
$providers = ShipmentProviders::find()
->select(['id', 'name'])
->indexBy('id')
->column();
-
$optionsData = Products1cOptions::find()
->select(['id', 'colors'])
->all();
$colorsProducts[$option->id] = explode(';', $option->colors);
}
-
$varietiesData = ProductsVarieties::find()
->select(['product_id', 'color', 'name'])
->orderBy(['posit' => SORT_DESC])
->all();
- $dataResponse = '';
+
$products_varieties = [];
foreach ($varietiesData as $variety) {
$products_varieties[$variety->product_id][$variety->color][] = $variety->name;
}
-
return $this->asJson([
'data' => $data,
'prices' => $prices,
$tip = Yii::$app->request->post('tip', 'wrap');
if (!empty($parent_id)) {
-
$productClass = ProductsClass::findOne(['category_id' => $parent_id]);
if (!$productClass) {
-
$productClass = new ProductsClass();
$productClass->category_id = $parent_id;
}
-
$productClass->tip = $tip;
if ($productClass->save()) {
return "ok";
} else {
-
return "Ошибка сохранения: " . implode(', ', $productClass->getFirstErrors());
}
}
$tip = Yii::$app->request->post('tip');
if (!empty($id) && !empty($tip)) {
-
$productClass = ProductsClass::findOne(['category_id' => $id, 'tip' => $tip]);
-
if ($productClass) {
if ($productClass->delete()) {
return "ok";
// Старый функционал
//TODO Удалить
- public function actionAjaxAddProduct() { return $this->renderPartial('ajax-add-product'); }
+ public function actionAjaxAddProduct()
+ {
+ return $this->renderPartial('ajax-add-product');
+ }
// Старый функционал
//TODO Удалить
- public function actionAjaxRemoveProduct() { return $this->renderPartial('ajax-remove-product'); }
+ public function actionAjaxRemoveProduct()
+ {
+ return $this->renderPartial('ajax-remove-product');
+ }
// Старый функционал
//TODO Удалить
- public function actionAjaxRemoveExport() { return $this->renderPartial('ajax-remove-export'); }
+ public function actionAjaxRemoveExport()
+ {
+ return $this->renderPartial('ajax-remove-export');
+ }
// Старый функционал
//TODO Добавление поставщиков - кнопку убрал
$view = Yii::$app->request->post('view') === 'on' ? 1 : 0;
if (!empty($id)) {
-
$product = Products1c::findOne(['id' => $id]);
if ($product) {
$product->view = $view;
$product->save();
}
-
$productOption = Products1cOptions::findOne(['id' => $id]);
if (!$productOption) {
$productOption = new Products1cOptions();
$productOption->id = $id;
}
-
$productOption->options = $options;
$productOption->provider_id = $provider_id;
$productOption->expiration_days = $expiration_days;
$productOption->group_id = $group_id;
$productOption->main = $main;
- // var_dump($productOption); die();
if ($productOption->save(false)) {
return "Запись сохранена";
} else {
$errors = $productOption->getErrors();
-
-
$errorMessages = [];
foreach ($errors as $attribute => $messages) {
foreach ($messages as $message) {
}
}
-
return implode("\n", $errorMessages);
}
}
return "Некорректный запрос.";
}
-
-
-
}
{
return [
- [['id', 'options', 'provider_id', 'expiration_days', 'min_lot', 'colors', 'price_zakup', 'min_order', 'group_id', 'main'], 'safe'],
- [['id'], 'required'],
+ [['id', 'options', 'provider_id', 'expiration_days', 'min_lot',
+ 'colors', 'price_zakup', 'min_order', 'group_id', 'main'], 'required'],
[['options', 'colors'], 'string'],
[['provider_id', 'expiration_days', 'min_lot', 'min_order', 'group_id', 'main'], 'integer'],
[['price_zakup'], 'number'],
//document.addEventListener('DOMContentLoaded', function () {
+/* jshint esversion: 6 */
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
- function ajax_product_provider(id) {
- $('#modal-7').modal('show', {backdrop: 'static'});
- $('#modal-7 .modal-title').text('Поставщики');
-
- const param3 = $('meta[name=csrf-param]').attr('content');
- const token3 = $('meta[name=csrf-token]').attr('content');
-
- $.ajax({
- url: '/products/ajax-product-provider/',
- method: 'post',
- dataType: 'html',
- data: {id: '' + id + '', [param3]: token3},
- success: function(data) {
- $('#modal-7 .modal-body').html(data);
- }
- });
- }
+
+function ajax_product_provider(id){
+ $('#modal-7').modal('show', {backdrop: 'static'});
+ $('#modal-7 .modal-title').text('Поставщики');
+
+ const param3 = $('meta[name=csrf-param]').attr('content');
+ const token3 = $('meta[name=csrf-token]').attr('content');
+
+ $.ajax({
+ url: '/products/ajax-product-provider/',
+ method: 'post',
+ dataType: 'html',
+ data: {id: '' + id + '', [param3]: token3},
+ success: function (data) {
+ $('#modal-7 .modal-body').html(data);
+ }
+ });
+}
function ajax_product_characteristics(id) {
- $('#modal-7').modal('show', { backdrop: 'static' });
+ $('#modal-7').modal('show', {backdrop: 'static'});
$('#modal-7 .modal-title').text('Характеристики товара');
const param3 = $('meta[name=csrf-param]').attr('content');
url: '/products/ajax-product-characteristics/',
method: 'post',
dataType: 'json',
- data: { id: id, [param3]: token3 },
- success: function(response) {
+ data: {id: id, [param3]: token3},
+ success: function (response) {
if (response.error) {
$('#modal-7 .modal-body').html(`<p class="text-danger">${response.error}</p>`);
return;
}
-
const characteristics = response.characteristics;
let tableHtml = `
<table class="table table-sm table-hover table-borderless">
tableHtml += '</tbody></table>';
$('#modal-7 .modal-body').html(tableHtml);
},
- error: function() {
+ error: function () {
$('#modal-7 .modal-body').html('<p class="text-danger">Ошибка при выполнении запроса.</p>');
}
});
}
function ajax_group_config(id) {
- $('#modal-7').modal('show', { backdrop: 'static' });
+ $('#modal-7').modal('show', {backdrop: 'static'});
$('#modal-7 .modal-title').text('Настройка категории');
const param3 = $('meta[name=csrf-param]').attr('content');
url: '/products/ajax-group-config/',
method: 'post',
dataType: 'json',
- data: { id: id, [param3]: token3 },
- success: function(response) {
+ data: {id: id, [param3]: token3},
+ success: function (response) {
if (response.error) {
$('#modal-7 .modal-body').html('<p class="text-danger">Ошибка: ' + response.error + '</p>');
return;
}
-
let html = '<div class="d-flex flex-column">';
const classes = response.classes;
const data2 = response.data2;
-
for (const [key, name] of Object.entries(classes)) {
html += `
<div class="d-flex flex-row align-items-center justify-content-between mb-2 border-bottom pb-2">
html += '</div>';
-
-
$('#modal-7 .modal-body').html(html);
},
- error: function() {
+ error: function () {
$('#modal-7 .modal-body').html('<p class="text-danger">Ошибка при выполнении запроса.</p>');
}
});
}
- function ajax_products_in_group(parent_id) {
- const param3 = $('meta[name=csrf-param]').attr('content');
- const token3 = $('meta[name=csrf-token]').attr('content');
-
- $.ajax({
- url: '/products/ajax-products-in-group/',
- method: 'post',
- dataType: 'json',
- data: {parent_id: parent_id, [param3]: token3},
- success: function(response) {
- if (response.error) {
- alert(response.error);
- return;
- }
+function ajax_products_in_group(parent_id){
+ const param3 = $('meta[name=csrf-param]').attr('content');
+ const token3 = $('meta[name=csrf-token]').attr('content');
- const { data, prices, providers, colorsProducts, productsVarieties } = response;
+ $.ajax({
+ url: '/products/ajax-products-in-group/',
+ method: 'post',
+ dataType: 'json',
+ data: {parent_id: parent_id, [param3]: token3},
+ success: function (response) {
+ if (response.error) {
+ alert(response.error);
+ return;
+ }
+
+ const {data, prices, providers, colorsProducts, productsVarieties} = response;
- let tableHtml = '<table class="table table-sm table-hover"><tbody>';
+ let tableHtml = '<table class="table table-sm table-hover"><tbody>';
- data.forEach((row) => {
- const isHidden = row.view === 0 ? '<span class="btn btn-sm btn-danger">скрыто</span>' : '';
- /*const providerButton = `<div id="provider_${row.id}" class="btn btn-sm btn-warning"
- onclick="ajax_product_provider('${row.id}');">
- + поставщика ${providers[row.id] ? providers[row.id] : ''}</div>`;*/
- const addCharButton = `<div id="provider_${row.id}" class="btn btn-sm btn-warning"
+ data.forEach((row) => {
+ const isHidden = row.view === 0 ? '<span class="btn btn-sm btn-danger">скрыто</span>' : '';
+ /*const providerButton = `<div id="provider_${row.id}" class="btn btn-sm btn-warning"
+ onclick="ajax_product_provider('${row.id}');">
+ + поставщика ${providers[row.id] ? providers[row.id] : ''}</div>`;*/
+ const addCharButton = `<div id="provider_${row.id}" class="btn btn-sm btn-warning"
onclick="ajax_product_characteristics('${row.id}');">
Доп. характеристики </div>`;
- let colorsHtml = '';
- if (colorsProducts[row.id]) {
- colorsProducts[row.id].forEach((color) => {
- color = color.trim();
- if (color) {
- colorsHtml += `<span class="btn btn-sm btn-info me-1 mt-1 mb-1">${color}</span>`;
- if (productsVarieties[row.id] && productsVarieties[row.id][color]) {
- productsVarieties[row.id][color].forEach((variety) => {
- colorsHtml += `<span class="btn btn-sm btn-warning me-2">${variety}</span>`;
- });
- }
+ let colorsHtml = '';
+ if (colorsProducts[row.id]) {
+ colorsProducts[row.id].forEach((color) => {
+ color = color.trim();
+ if (color) {
+ colorsHtml += `<span class="btn btn-sm btn-info me-1 mt-1 mb-1">${color}</span>`;
+ if (productsVarieties[row.id] && productsVarieties[row.id][color]) {
+ productsVarieties[row.id][color].forEach((variety) => {
+ colorsHtml += `<span class="btn btn-sm btn-warning me-2">${variety}</span>`;
+ });
}
- });
-
- if (colorsHtml) {
- colorsHtml += `<a href="/products/productVarieties/?id=${row.id}" target="_new" class="btn btn-info btn-sm">+ добавить сорта</a>`;
}
+ });
+
+ if (colorsHtml) {
+ colorsHtml += `<a href="/products/productVarieties/?id=${row.id}" target="_new" class="btn btn-info btn-sm">+ добавить сорта</a>`;
}
+ }
- tableHtml += `
+ tableHtml += `
<tr class="${row.entity_id ? '' : 'bg-gray-500'}">
<td>
${row.name} ${isHidden}
</td>
</tr>`;
- });
-
- tableHtml += '</tbody></table>';
- $(`#tr_${parent_id}`).after(`<tr id="trr_${parent_id}"><td colspan="2">${tableHtml}</td></tr>`);
- },
- error: function() {
- alert('Ошибка при выполнении запроса.');
- },
- });
- }
-
-function ajax_class_group(parent_id, tip) {
+ });
+
+ tableHtml += '</tbody></table>';
+ $(`#tr_${parent_id}`).after(`<tr id="trr_${parent_id}"><td colspan="2">${tableHtml}</td></tr>`);
+ },
+ error: function () {
+ alert('Ошибка при выполнении запроса.');
+ },
+ });
+}
+
+function ajax_class_group(parent_id, tip){
const param3 = $('meta[name=csrf-param]').attr('content');
const token3 = $('meta[name=csrf-token]').attr('content');
url: '/products/ajax-class-group/',
method: 'post',
dataType: 'html',
- data: { parent_id: parent_id, tip: tip, [param3]: token3 },
+ data: {parent_id: parent_id, tip: tip, [param3]: token3},
success: function (data) {
if (data === 'ok') {
const button = $(`.dd${parent_id}${tip}`);
}
-function ajax_class_group_remove(id, tip) {
+function ajax_class_group_remove(id, tip){
const param3 = $('meta[name=csrf-param]').attr('content');
const token3 = $('meta[name=csrf-token]').attr('content');
url: '/products/ajax-class-group-remove/',
method: 'post',
dataType: 'html',
- data: { id: id, tip: tip, [param3]: token3 },
+ data: {id: id, tip: tip, [param3]: token3},
success: function (data) {
if (data === 'ok') {
const button = $(`.dd${id}${tip}`);
});
}
- function save_providerder(){
-
- const param3 = $('meta[name=csrf-param]').attr('content');
- const token3 = $('meta[name=csrf-token]').attr('content');
+function save_providerder(){
- $.ajax({
- url: '/products/ajax-product-provider-add/',
- method: 'post',
- dataType: 'html',
- data: {id: '<?=$id?>',
- provider_id: $('#provider_id').val(),
- options: $('#options').val(),
- expiration_days: $('#expiration_days').val(),
- min_lot: $('#min_lot').val(),
- colors: $('#colors').val(),
- min_order: $('#min_order').val(),
- price_zakup: $('#price_zakup').val(),
- group_id: $('#group_id').val() ,
- main: $('#main').val() , view: $('#view').val(), [param3]:token3 },
- success: function(data){
- $('#result_prov').html(data);
- }});
- }
+ const param3 = $('meta[name=csrf-param]').attr('content');
+ const token3 = $('meta[name=csrf-token]').attr('content');
+ $.ajax({
+ url: '/products/ajax-product-provider-add/',
+ method: 'post',
+ dataType: 'html',
+ data: {
+ id: '<?=$id?>',
+ provider_id: $('#provider_id').val(),
+ options: $('#options').val(),
+ expiration_days: $('#expiration_days').val(),
+ min_lot: $('#min_lot').val(),
+ colors: $('#colors').val(),
+ min_order: $('#min_order').val(),
+ price_zakup: $('#price_zakup').val(),
+ group_id: $('#group_id').val(),
+ main: $('#main').val(), view: $('#view').val(), [param3]: token3
+ },
+ success: function (data) {
+ $('#result_prov').html(data);
+ }
+ });
+}
- function ajax_add_product(id,parent_id,name,price){
- const param3 = $('meta[name=csrf-param]').attr('content');
- const token3 = $('meta[name=csrf-token]').attr('content');
+function ajax_add_product(id, parent_id, name, price) {
- $.ajax({
- url: '/products/ajax-add-product/',
- method: 'post',
- dataType: 'html',
- data: {id: ''+id+'', name: ''+name+'',parent_id: ''+parent_id+'',price: ''+price+'', [param3]:token3},
- success: function(data){
- $('#diver_'+id+'').html(data);
+ const param3 = $('meta[name=csrf-param]').attr('content');
+ const token3 = $('meta[name=csrf-token]').attr('content');
- }});
- }
- function ajax_remove_product(id){
+ $.ajax({
+ url: '/products/ajax-add-product/',
+ method: 'post',
+ dataType: 'html',
+ data: {
+ id: '' + id + '',
+ name: '' + name + '',
+ parent_id: '' + parent_id + '',
+ price: '' + price + '',
+ [param3]: token3
+ },
+ success: function (data) {
+ $('#diver_' + id + '').html(data);
- const param3 = $('meta[name=csrf-param]').attr('content');
- const token3 = $('meta[name=csrf-token]').attr('content');
+ }
+ });
+}
- $.ajax({
- url: '/products/ajax-remove-product/',
- method: 'post',
- dataType: 'html',
- data: {id: ''+id+'', [param3]:token3},
- success: function(data){
- $('#diver_'+id+'').html(data);
+function ajax_remove_product(id) {
- }});
- }
+ const param3 = $('meta[name=csrf-param]').attr('content');
+ const token3 = $('meta[name=csrf-token]').attr('content');
+ $.ajax({
+ url: '/products/ajax-remove-product/',
+ method: 'post',
+ dataType: 'html',
+ data: {id: '' + id + '', [param3]: token3},
+ success: function (data) {
+ $('#diver_' + id + '').html(data);
- function ajaxRemoveExport(id){
+ }
+ });
+}
- const param3 = $('meta[name=csrf-param]').attr('content');
- const token3 = $('meta[name=csrf-token]').attr('content');
- $.ajax({
- url: '/products/ajax-remove-export/',
- method: 'post',
- dataType: 'html',
- data: {id: ''+id+'', [param3]:token3},
- success: function(data){
- $('#diver2_'+id+'').html(data);
+function ajaxRemoveExport(id) {
- }});
- }
+ const param3 = $('meta[name=csrf-param]').attr('content');
+ const token3 = $('meta[name=csrf-token]').attr('content');
+ $.ajax({
+ url: '/products/ajax-remove-export/',
+ method: 'post',
+ dataType: 'html',
+ data: {id: '' + id + '', [param3]: token3},
+ success: function (data) {
+ $('#diver2_' + id + '').html(data);
+ }
+ });
+}
-//});
\ No newline at end of file
+//});