]> _ Git - pmi.git/commitdiff
wait #6361 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Oct 2023 07:55:08 +0000 (09:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Oct 2023 07:55:08 +0000 (09:55 +0200)
app/Models/Order.php

index 6dd88971994e1710731cc66a93177d4319848701..aabdfe3ed3a9bfd0f366b828261d8994c76265da 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace App\Models;
 
 use App\Events\OrderOperation;
@@ -40,20 +41,24 @@ class Order extends ECommerceCommon
             'column' => true,
         ]);
 
-        foreach ($this->fields as $fields) {
-            if ($fields['name'] === 'products') {
-                $fields = ['name' => 'products',
+        foreach ($this->fields as $field) {
+            if ($field['name'] === 'products') {
+                $field = ['name' => 'products',
                     'label' => 'Produits',
                     'type' => 'Table',
                     'columns' => ['id' => '#', 'ref' => 'Référence options', 'reference' => 'Référence produit', 'name' => 'Nom de produit', 'quantity' => 'Quantité'],
                     'tab' => $tabOrder];
-                $this->addField($fields);
-            }
-
-            if ($fields['name'] === 'total') {
-                $fields['tab'] = $tabOrder;
-                $this->addField($fields);
-            }
+                $this->addField($field);
+            } else if ($field['name'] === 'user_id') {
+                $field['label'] = 'Utilisateur';
+                $field['tab'] = 'Infos client';
+                $field['type'] = 'SelectFromArray';
+                $field['options'] = $this->userOptions();
+            } else
+                if ($field['name'] === 'total') {
+                    $field['tab'] = $tabOrder;
+                    $this->addField($field);
+                }
         }
 
         $this->addField(['name' => 'status',
@@ -76,37 +81,32 @@ class Order extends ECommerceCommon
             'type' => 'Datetime',
             'column' => true,
             'tab' => $tabOrder]);
+    }
 
-        foreach ($this->fields as $fields) {
-            if ($fields['name'] === 'user_id') {
-                $fields['label'] = 'Utilisateur';
-                $fields['tab'] = 'Infos client';
-                $fields['type'] = 'SelectFromArray';
-                $fields['options'] = $this->userOptions();
-            }
-
-            $this->addField($fields);
-        }
-
-        $this->addField(['name' => 'id',
-            'label' => 'Commande #',
-            'type' => 'Noteditable',
-
-        ]);
+    public function postSetFields()
+    {
+        parent::postSetFields();
+//        $this->getField('id')->setAttribute('label','Commande #');
+//        $this->getField('id')->setAttribute('type','Noteditable');
     }
 
-    public static function getOptionValue($key) {
-        if($key)
+    public static function getOptionValue($key)
+    {
+        if ($key)
             return self::$_optionsForSelect[$key];
 
         return false;
     }
-    public function userOptions() {
+
+    public function userOptions()
+    {
         $infos = Client::getClientsApproved();
         foreach ($infos as $info) {
-            $this->_optionsForUserInfo[$info['id']][] = $info['firstname'].' '.$info['lastname'].' ('.$info['company'].')';
+            $this->_optionsForUserInfo[$info['id']][] = $info['firstname'] . ' ' . $info['lastname'] . ' (' . $info['company'] . ')';
         }
 
-        return array_map(function($n) { return $n[0]; }, $this->_optionsForUserInfo);
+        return array_map(function ($n) {
+            return $n[0];
+        }, $this->_optionsForUserInfo);
     }
 }