<?php
+
namespace App\Models;
use App\Events\OrderOperation;
'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',
'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);
}
}