-<?
-include_once("startup.php");
-include_once("inc/db.php");
+<?php
+include_once(dirname(__DIR__, 2) . "/startup.php");
+include_once(dirname(__DIR__, 2) . "/inc/db.php");
$id=(int)$_REQUEST["id"];
$product_id=htmlentities($_REQUEST["product_id"]);
//echo"$name_eng=$value $product_id $store_id";
if(!empty($store_id)) {
global $dependent_fields;
-$data=$db::getRows("SELECT id, dependent_fields, name_eng FROM store_orders_fields WHERE 1");
+$data=$db::getRows("SELECT id, dependent_fields, name_eng FROM store_orders_fields WHERE 1=1");
+
foreach($data as $row) {
$dependent_fields[$row["id"]]=explode(",",$row["dependent_fields"]);
$fieldRows[$row["id"]]=$row["name_eng"];
global $arrayp;
function recurs_depended($fieldId) {
- global $dependent_fields,$arrayp;
- $arrayp .=",".implode(",",$dependent_fields[$fieldId]);
- foreach($dependent_fields[$fieldId] as $fieldId2) recurs_depended($fieldId2);
- return $arrayp;
+ global $dependent_fields,$arrayp;
+ if (isset($dependent_fields[$fieldId])) {
+ $arrayp .=",".implode(",",$dependent_fields[$fieldId]);
+
+ foreach($dependent_fields[$fieldId] as $fieldId2) {
+ if (!empty($fieldId2)) {
+ recurs_depended($fieldId2);
+ }
+ }
+ }
+ return $arrayp;
}
-if(1) {
-$arrayp=recurs_depended($fieldId);
+if(1) {
+ if (!empty($fieldId)) {
+ $arrayp=recurs_depended($fieldId);
+ }
$arrayp = array_unique(explode(",",$arrayp));
}
//$db::sql("DELETE FROM store_orders_fields_data WHERE product_id=? AND order_id=? AND store_id=? AND field_name=? AND field_id=? AND color=?",[$product_id,$id,$store_id,$name_eng,$fieldId,$color]);
- //echo"удаление пустой записи";
-
+ //echo"удаление пустой записи";
+
+$upFields = "product_id, order_id, store_id, field_name, field_id, color, date_update, hand, value, title";
+$valuesFields= "'$product_id', '$id', '$store_id', '$name_eng', '$fieldId', '$color', NOW(), 1, 0, 0";
-
$value_old=$db::getValue("SELECT $pole FROM store_orders_fields_data WHERE product_id=? AND order_id=?
-AND store_id=? AND field_name=? AND field_id=? AND color=? LIMIT 1",[$product_id,$id,$store_id,$name_eng,$fieldId,$color]);
-$value_old=str_replace('.000','',$value_old);
-$sql="INSERT IGNORE INTO store_orders_fields_data SET ";
- $up2 =" $pole='$value'";
- $up .= ",".$up2;
-$sql .="$up ON DUPLICATE KEY UPDATE $up2";
+AND store_id=? AND field_name=? AND field_id=? AND color=? LIMIT 1",[$product_id,$id,$store_id,$name_eng,$fieldId,$color]);
+$value_old=str_replace('.000','',$value_old);
+$sql="INSERT INTO store_orders_fields_data ($upFields) VALUES ($valuesFields) ON CONFLICT (order_id, product_id, store_id, field_id, field_name, color) DO UPDATE SET $pole='$value'";
+
$db::sql($sql);
//echo'сохранили '.$name_eng.' store_id='.$store_id.' '.$name_eng.' color='.$color.' value='.$value.' ';
//echo"Считаем Заивисимые поля";
//print_r($arrayp);
- $orderId=(int)$id;
-include_once("modul/shipment/functionsShipment.php");
+ $orderId=(int)$id;
+include_once(__DIR__ . "/functionsShipment.php");
foreach($arrayp as $key => $Field) {
$f="modul/shipment/fields/$Field.php";
function ajaxEditFieldValue(name_eng,product_id,color)
{
+
+ const param3 = $("meta[name=csrf-param]").attr("content");
+ const token3 = $("meta[name=csrf-token]").attr("content");
$.ajax({
- url: \'/shipment/ajaxField/\',
+ url: \'/shipment/ajax-field/\',
method: \'post\',
dataType: \'html\',
- data: { id: '.$orderId.', name_eng: \'\'+name_eng+\'\', store_id:\'\'+$(\'#store_id_id\').val()+\'\', product_id:\'\'+product_id+\'\', color: \'\'+color+\'\', value:\'\'+$(\'#\'+name_eng+\'\'+product_id+\'\').val()+\'\' },
+ data: { id: '.$orderId.', name_eng: \'\'+name_eng+\'\', store_id:\'\'+$(\'#store_id_id\').val()+\'\', product_id:\'\'+product_id+\'\', color: \'\'+color+\'\', value:\'\'+$(\'#\'+name_eng+\'\'+product_id+\'\').val()+\'\', [param3]:token3 },
success: function(data){
$(\'#edit_div\').html(data);
function ajaxEditFieldColorValue(name_eng,product_id,color,colormd5)
{
-
+ const param3 = $("meta[name=csrf-param]").attr("content");
+ const token3 = $("meta[name=csrf-token]").attr("content");
$.ajax({
- url: \'/shipment/ajaxField/\',
+ url: \'/shipment/ajax-field/\',
method: \'post\',
dataType: \'html\',
- data: { id: '.$orderId.', name_eng: \'\'+name_eng+\'\', store_id:\'\'+$(\'#store_id_id\').val()+\'\', product_id:\'\'+product_id+\'\', color: \'\'+color+\'\', value:\'\'+$(\'#\'+name_eng+\'\'+product_id+\'\'+colormd5+\'\').val()+\'\' },
+ data: { id: '.$orderId.', name_eng: \'\'+name_eng+\'\', store_id:\'\'+$(\'#store_id_id\').val()+\'\', product_id:\'\'+product_id+\'\', color: \'\'+color+\'\', value:\'\'+$(\'#\'+name_eng+\'\'+product_id+\'\'+colormd5+\'\').val()+\'\' , [param3]:token3},
success: function(data){
$(\'#edit_div\').html(data);
}});