From: Vincent Vanwaelscappel Date: Fri, 6 Oct 2023 07:55:08 +0000 (+0200) Subject: wait #6361 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9a454b9bcc4f913959e293af616183127f51aba6;p=pmi.git wait #6361 @0.5 --- diff --git a/app/Models/Order.php b/app/Models/Order.php index 6dd8897..aabdfe3 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -1,4 +1,5 @@ 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); } }