$currentCartRef = Cart::getRefs($data['products']);
$data = Order::fillData($currentCartRef,$data,$productsInfosBase);
+ $company = array_values(array_filter(json_decode($data['addresses'], true), function($n) {
+ return intval($n['delivery_address']);
+ }))[0]['company'];
+
+ $data['company'] = $company;
+ $data['email'] = Client::getClientConnected()->email;
+ $data['request_date'] = Carbon::now('Europe/Paris');
+ $data['products'] = json_encode(array_map(function($n){
+ $exp = explode('|',$n['ref']);
+ array_shift($exp);
+ $n['ref'] = sizeof($exp) > 1 ? implode('|', $exp) : $exp;
+ return $n;
+ }, json_decode($data['products'],true)));
+ $data['user'] = Client::getClientConnected()->email;
if($data) {
$order = Order::create($data);
return Auth::guard('web-clients')->user();
}
+ public static function getEmailsClientsApproved() {
+ return self::all()->where('status',1)->pluck('email');
+ }
+
public static function getCategory() {
return self::getClientConnected()->discount ?? 'A';
}
$discount_array = array_combine($discount_array_save_keys,$discount_array);
- dump($categoryProduct);
-
if(!in_array($categoryProduct, $discount_array)) {
$categoryProduct = 'A';
}
[
'name' => 'user_id',
'label' => 'user_id',
- 'type' => 'Text',
- 'column' => true
+ 'type' => 'Hidden',
+ 'column' => false
],
[
'name' => 'addresses',
- 'label' => 'Adresses',
- 'type' => 'Text',
- 'column' => true
+ 'label' => 'Adresse',
+ 'type' => 'BunchOfFieldsMultiple',
+ 'bunch' => 'App\SubForms\Address',
+ 'column' => false,
+ 'tab' => 'Informations',
+ 'edit_label' => 'Éditer « %city »'
],
[
'name' => 'products',
'label' => 'Produits',
- 'type' => 'Text',
- 'column' => true
+ 'type' => 'Hidden',
+ 'column' => false
],
[
'name' => 'total',
- 'type' => 'Text'
- ]
+ 'label' => 'Total TTC',
+ 'type' => 'Text',
+ 'column' => true
+ ],
];
*/
foreach ($currentCartRef as $keyRefs => $refs) {
$index = $data['products'][$keyRefs]['id'];
+ $explodeRef = explode("|", $refs);
if($productsInfosBase[$index][0]['json']) {
$options = json_decode($productsInfosBase[$index][0]['json'], true);
- foreach (explode("/", $refs) as $key => $ref) {
+ foreach ($explodeRef as $key => $ref) {
$key -= 1;
if ($key > -1) {
$options_ = $options[$key]['options'];
{
parent::setFields();
- foreach ($this->fields as $fields) {
- $fields['tab'] = 'Informations';
- $this->addField($fields);
- }
+ $tabOrder = 'Commande';
+
+ $this->addField(['name' => 'user',
+ 'label' => 'Utilisateur',
+ 'type' => 'SelectFromArray',
+ 'options' => Client::getEmailsClientsApproved(),
+ 'tab' => 'Informations'
+ ]);
+
+ $this->addField(['name' => 'company',
+ 'label' => 'Société',
+ 'type' => 'Text',
+ 'column' => true,
+ 'tab' => 'Informations'
+ ]);
+
+ $this->addField(['name' => 'email',
+ 'label' => 'Email',
+ 'type' => 'Text',
+ 'column' => true,
+ 'tab' => 'Informations'
+ ]);
$this->addField(['name' => 'status',
- 'label' => 'Statut',
+ 'label' => 'Status',
'type' => 'SelectFromArray',
'column' => true,
'options' => self::$_optionsForSelect,
'default' => 'new',
- 'tab' => 'Informations'
+ 'tab' => $tabOrder
]);
$this->addField(['name' => 'complete_status',
- 'label' => 'Indication du statut',
+ 'label' => 'Indication du status',
'type' => 'Text',
- 'tab' => 'Informations'
+ 'tab' => $tabOrder
]);
+
+ $this->addField(['name' => 'request_date',
+ 'label' => 'Date',
+ 'type' => 'Datetime',
+ 'column' => true,
+ 'tab' => $tabOrder]);
+
+ foreach ($this->fields as $fields) {
+ if ($fields['name'] === 'products') {
+ $fields = ['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];
+ }
+ if ($fields['name'] === 'total') {
+ $fields['tab'] = $tabOrder;
+ }
+ $this->addField($fields);
+ }
}
public static function getOptionValue($key) {
<div class="flex justify-between">
<div>
<p class="no-m">{{ __('Date de commande') }}</p>
- <p class="no-m text-navy">{{ \Carbon\Carbon::parse($item['created_at'])->isoFormat("D/MM/Y") }}</p>
+ <p class="no-m text-navy">{{ \Carbon\Carbon::parse($item['created_at'])->isoFormat("DD/MM/Y") }}</p>
</div>
<div class="text-right">
<p class="no-m">{{ __('Numéro de commande') }}</p>
</div>
<div class="product-infos flex justify-between items-center">
<div>
- <p class="no-m">{{ $product['ref'] }}</p>
+ <p class="no-m">{{ $product['reference'].'|'.$product['ref'] }}</p>
<p class="no-m text-navy">{{ $product['name'] }}</p>
@if(isset($product['discount']) && $product['discount'] !== 0)
@if(floatval($product['basic_selling_price']))
@if($item['total'])
<div class="text-right pb-6">
<p class="no-m">{{ __('Montant Total') }}</p>
- <p class="no-m">{{ $item['total'] }}€ HT</p>
+ <p class="no-m">{{ $item['total'] }}€ TTC</p>
</div>
@endif
</div>
@php
- $now = \Carbon\Carbon::now('Europe/Paris')->isoFormat('D/MM/Y');
+ $now = \Carbon\Carbon::now('Europe/Paris')->isoFormat('DD/MM/Y');
@endphp
@prepend('stylesheets')