From: Aleksey Filippov Date: Mon, 22 Apr 2024 11:19:08 +0000 (+0300) Subject: правки по автозаказу фикс редактирования полей ajax X-Git-Tag: 1.1~115^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=c5a57d430b70af9d77fe26d85ef31e5719f994e8;p=erp24_rep%2Fyii-erp24%2F.git правки по автозаказу фикс редактирования полей ajax --- diff --git a/erp24/controllers/ShipmentController.php b/erp24/controllers/ShipmentController.php index efc3e9cb..d1b2cd31 100755 --- a/erp24/controllers/ShipmentController.php +++ b/erp24/controllers/ShipmentController.php @@ -22,4 +22,5 @@ class ShipmentController extends Controller public function actionAjaxDivisionAutoHandStart() { return $this->renderPartial('ajax-division-auto-hand-start'); } public function actionStoreProductsFact() { return $this->render('store-products-fact'); } public function actionStoreProductsFactEdit() { return $this->renderPartial('store-products-fact-edit'); } + public function actionAjaxField() { return $this->renderPartial('ajax-field'); } } \ No newline at end of file diff --git a/erp24/modul/shipment/ajaxField.php b/erp24/modul/shipment/ajaxField.php index 29294ec5..14991f3e 100644 --- a/erp24/modul/shipment/ajaxField.php +++ b/erp24/modul/shipment/ajaxField.php @@ -1,6 +1,6 @@ -"товар"]; //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"]; @@ -39,10 +40,17 @@ foreach($data as $row) { 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; } @@ -55,8 +63,10 @@ if(is_array($row)) { -if(1) { -$arrayp=recurs_depended($fieldId); +if(1) { + if (!empty($fieldId)) { + $arrayp=recurs_depended($fieldId); + } $arrayp = array_unique(explode(",",$arrayp)); @@ -114,17 +124,16 @@ if($name_eng=="quantity_zakup_new") { } //$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.' '; @@ -139,8 +148,8 @@ VALUES(?,?,?,?,?, ?, ?, NOW(), ?)", [$product_id,$fieldId,$id,$store_id,$color,$ //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"; diff --git a/erp24/modul/shipment/shipment.php b/erp24/modul/shipment/shipment.php index 8e2d3842..443e2024 100644 --- a/erp24/modul/shipment/shipment.php +++ b/erp24/modul/shipment/shipment.php @@ -443,11 +443,14 @@ $(\'#\'+id+\'\').val(\'\'+uname+\'\'); 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); @@ -462,12 +465,13 @@ $.ajax({ 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); }}); diff --git a/erp24/views/shipment/ajax-field.php b/erp24/views/shipment/ajax-field.php new file mode 100644 index 00000000..7a32710d --- /dev/null +++ b/erp24/views/shipment/ajax-field.php @@ -0,0 +1,5 @@ +