]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix shipment add
authorAlexander Smirnov <fredeom@mail.ru>
Fri, 3 May 2024 08:30:11 +0000 (11:30 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Fri, 3 May 2024 08:30:11 +0000 (11:30 +0300)
erp24/actions/shipment/AddAction.php
erp24/modul/shipment/functionsShipment.php
erp24/records/StoreOrders.php
erp24/views/shipment/add.php

index def46e5cf07be5d6f09af911e821fe918862e913..5cbc8f37b8b5d6fb688c5c5ea18d37e69350f8a4 100644 (file)
@@ -11,15 +11,26 @@ use yii_app\records\UniversalCatalogItem;
 
 class AddAction extends Action
 {
-    public function run($id) {
-        $model = StoreOrders::find()->where(['id' => $id])->one();
+    public function run($id = null) {
+        if (!$id) {
+            $model = new StoreOrders;
+        } else {
+            $model = StoreOrders::find()->where(['id' => $id])->one();
+        }
+        if (!$model) {
+            throw new \Exception('не могу найти закуп с id='. $id);
+        }
         /** @var $model StoreOrders */
         $model->getProviders();
         if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post())) {
             $model->setProviders();
-            $model->price_logistic = 0;
             if ($model->validate()) {
                 $model->save();
+            } else {
+                echo "<pre>";
+                var_dump($model->getErrors());
+                echo "</pre>";
+                die;
             }
         }
 
index 6c048c1540f6a62fc3738ad6c918b5efefcceb3d..681a934112224511e01430c94cf03ea48eeb3ad2 100644 (file)
@@ -332,7 +332,11 @@ $orderStoresArrayRelation_in .=")";
 //показываем магазины если статус закупки подразумевает разбивку данных по магазинам
 if($statuses_stores_show[$status_order_id] ?? false)  {
 
-$stores_arr=$db::mapping("SELECT name,id FROM products_1c WHERE tip='city_store' AND view='1' AND id $orderStoresArrayRelation_in  order by name ASC");
+if (strlen($orderStoresArrayRelation_in) > strlen(' IN ()')) {
+    $stores_arr = $db::mapping("SELECT name,id FROM products_1c WHERE tip='city_store' AND view='1' AND id $orderStoresArrayRelation_in  order by name ASC");
+} else {
+    $stores_arr = [];
+}
 
 //print_r($stores_arr);
 $stores_cnt=count($stores_arr);
index 6403dab8634b79f27d12cec181386645fe248c8b..fcc739a751ee5769cf7ac3363d2a957ac39f3ef1 100644 (file)
@@ -25,6 +25,7 @@ use Yii;
  * @property string $status_logi
  * @property string $date_update Дата и врепмя обновления информации в таблице храннеия data
  * @property string $update_html HTML блок расчета по формулам
+ * @property int $city_id номер города в universal_catalog_item
  */
 class StoreOrders extends \yii\db\ActiveRecord
 {
@@ -45,7 +46,7 @@ class StoreOrders extends \yii\db\ActiveRecord
     public function rules()
     {
         return [
-            [['name', 'parent_id', 'date_start', 'date_end', 'delivery_date', 'division_date', 'division_hours', 'delivery_date_fact', 'price_logistic', 'comments', 'admin_id', 'date_add', 'providers_arr', 'status_logi', 'date_update', 'update_html'], 'required'],
+            [['name', 'parent_id', 'date_start', 'city_id', /*'date_end',*/ 'delivery_date', 'division_date', /*'division_hours', */'delivery_date_fact', /* 'price_logistic', */ 'comments', /*'admin_id', */'date_add', 'providers_arr' /*, 'status_logi', 'date_update', 'update_html'*/], 'required'],
             [['parent_id', 'division_hours', 'price_logistic', 'admin_id', 'status'], 'integer'],
             [['date_start', 'date_end', 'delivery_date', 'division_date', 'delivery_date_fact', 'date_add', 'date_update'], 'safe'],
             [['comments', 'status_logi', 'update_html'], 'string'],
@@ -83,11 +84,15 @@ class StoreOrders extends \yii\db\ActiveRecord
 
     public function setProviders()
     {
-        $this->providers_arr = implode(',', $this->providers);
+        if (empty($this->providers)) {
+            $this->providers_arr = '';
+        } else {
+            $this->providers_arr = implode(',', $this->providers);
+        }
     }
 
     public function getProviders()
     {
-        $this->providers = explode(',', $this->providers_arr);
+        $this->providers = explode(',', $this->providers_arr ?? '');
     }
 }
index eb91af1d189b4251626a3dd35dcdfd31172eb601..d3591c1f867dd1709c2383474339e539917a23af 100644 (file)
@@ -23,6 +23,8 @@ use yii_app\helpers\PrintBlockHelper;
 
     <?php $form = ActiveForm::begin() ?>
 
+    <?= $form->field($model, 'id')->hiddenInput() ?>
+
     <?php PrintBlockHelper::printBlock('Город', $form->field($model, 'city_id')->widget(Select2::class, [
         'data' => $cities,
         'language' => 'ru',