'selectedProductsArray' => $selectedProductsArray, | 'selectedProductsArray' => $selectedProductsArray, | ||||
'pointsSaleArray' => $pointsSaleArray, | 'pointsSaleArray' => $pointsSaleArray, | ||||
'productsArray' => $productsArray, | 'productsArray' => $productsArray, | ||||
'ordersArray' => $ordersArray | |||||
'ordersArray' => $ordersArray, | |||||
'producer' => Producer::searchOne(['id' => $idProducer]) | |||||
]); | ]); | ||||
$dateStr = date('d/m/Y', strtotime($date)); | $dateStr = date('d/m/Y', strtotime($date)); |
$productOrder->save(); | $productOrder->save(); | ||||
} | } | ||||
} | } | ||||
$order->initReference() ; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if($order) { | if($order) { | ||||
$order->initReference() ; | |||||
$order->setTillerSynchronization() ; | $order->setTillerSynchronization() ; | ||||
} | } | ||||
$strUser = ''; | $strUser = ''; | ||||
// username | // username | ||||
$strUser = $order->getStrUser() ; | |||||
$strUser .= $order->getStrUser() ; | |||||
if(strlen($order->comment_point_sale)) | if(strlen($order->comment_point_sale)) | ||||
{ | { | ||||
$strUser .= '<br />' . $order->user->phone . ''; | $strUser .= '<br />' . $order->user->phone . ''; | ||||
} | } | ||||
// référence | |||||
if($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) { | |||||
$strUser .= '<br />'.$order->reference ; | |||||
} | |||||
$html .= '<td>'.$strUser.'</td>'; | $html .= '<td>'.$strUser.'</td>'; | ||||
// produits | // produits |
0 => 'Non', | 0 => 'Non', | ||||
1 => 'Oui' | 1 => 'Oui' | ||||
], []); ?> | ], []); ?> | ||||
<?= $form->field($model, 'option_order_reference_type') | |||||
->dropDownList([ | |||||
Producer::ORDER_REFERENCE_TYPE_NONE => '--', | |||||
Producer::ORDER_REFERENCE_TYPE_YEARLY => 'Annuelle', | |||||
], []) ; ?> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<p>Bonjour <?= Html::encode($user->name); ?>,</p> | <p>Bonjour <?= Html::encode($user->name); ?>,</p> | ||||
<p>Votre commande d'une valeur de <strong><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?></strong> a bien été prise en compte.</p> | |||||
<p>Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? 'N°'.$order->reference : '' ?> d'une valeur de <strong><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?></strong> a bien été prise en compte.</p> | |||||
<p>Récapitulatif des produits commandés :</p> | <p>Récapitulatif des produits commandés :</p> | ||||
<p><?= $order->getCartSummary() ?></p> | <p><?= $order->getCartSummary() ?></p> |
Bonjour <?= $user->name; ?>, | Bonjour <?= $user->name; ?>, | ||||
Votre commande d'une valeur de <?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?> a bien été prise en compte. | |||||
Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? '<strong>N°'.$order->reference.'</strong>' : '' ?> d'une valeur de <?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?> a bien été prise en compte. | |||||
Récapitulatif des produits commandés : | Récapitulatif des produits commandés : | ||||
<?= $order->getCartSummary(false) ?> | <?= $order->getCartSummary(false) ?> |
[['id_user', 'date', 'status'], 'required', 'message' => ''], | [['id_user', 'date', 'status'], 'required', 'message' => ''], | ||||
[['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'], | [['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'], | ||||
[['auto_payment', 'tiller_synchronization'], 'boolean'], | [['auto_payment', 'tiller_synchronization'], 'boolean'], | ||||
[['status'], 'string'], | |||||
[['status', 'reference'], 'string'], | |||||
[['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe'] | [['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe'] | ||||
]; | ]; | ||||
} | } | ||||
'status' => 'Statut', | 'status' => 'Statut', | ||||
'id_invoice' => 'Facture', | 'id_invoice' => 'Facture', | ||||
'id_quotation' => 'Devis', | 'id_quotation' => 'Devis', | ||||
'id_delivery_note' => 'Bon de livraison' | |||||
'id_delivery_note' => 'Bon de livraison', | |||||
'reference' => 'Référence' | |||||
]; | ]; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public function initReference() | |||||
{ | |||||
$producer = GlobalParam::getCurrentProducer() ; | |||||
if($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY) | |||||
{ | |||||
$lastOrder = Order::find()->innerJoinWith('distribution', true) | |||||
->where(['>=', 'distribution.date', date('Y').'-01-01']) | |||||
->andWhere([ | |||||
'distribution.id_producer' => $producer->id | |||||
]) | |||||
->andWhere(['not', ['order.reference' => null]]) | |||||
->orderBy('order.id DESC') | |||||
->one() ; | |||||
if($lastOrder && $lastOrder->reference && strlen($lastOrder->reference) > 0) { | |||||
$pattern = '#A([0-9]+)C([0-9]+)#'; | |||||
preg_match($pattern, $lastOrder->reference, $matches, PREG_OFFSET_CAPTURE); | |||||
$sizeNumReference = strlen($matches[2][0]); | |||||
$numReference = ((int)$matches[2][0]) + 1; | |||||
$numReference = str_pad($numReference, $sizeNumReference, '0', STR_PAD_LEFT); | |||||
$this->reference = 'A'.$matches[1][0].'C'.$numReference ; | |||||
} | |||||
else { | |||||
$this->reference = 'A'.date('y').'C0001' ; | |||||
} | |||||
$this->save() ; | |||||
} | |||||
} | |||||
} | } |
const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR = 'calendar' ; | const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR = 'calendar' ; | ||||
const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST = 'list' ; | const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST = 'list' ; | ||||
const ORDER_REFERENCE_TYPE_NONE = '' ; | |||||
const ORDER_REFERENCE_TYPE_YEARLY = 'yearly' ; | |||||
var $secret_key_payplug; | var $secret_key_payplug; | ||||
/** | /** | ||||
} | } | ||||
}], | }], | ||||
[['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status', | [['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status', | ||||
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note', 'address', 'behavior_home_point_sale_day_list', 'behavior_order_select_distribution', 'option_payment_info'], 'string'], | |||||
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note', 'address', 'behavior_home_point_sale_day_list', 'behavior_order_select_distribution', 'option_payment_info', 'option_order_reference_type'], 'string'], | |||||
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note', 'document_display_prices_delivery_note', 'option_email_confirm', 'option_email_confirm_producer', 'option_csv_export_all_products', 'option_csv_export_by_piece'], 'boolean'], | [['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note', 'document_display_prices_delivery_note', 'option_email_confirm', 'option_email_confirm_producer', 'option_csv_export_all_products', 'option_csv_export_by_piece'], 'boolean'], | ||||
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code', 'type', 'credit_functioning', 'option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255], | [['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code', 'type', 'credit_functioning', 'option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255], | ||||
[['free_price', 'credit_limit_reminder', 'credit_limit'], 'double'], | [['free_price', 'credit_limit_reminder', 'credit_limit'], 'double'], | ||||
'option_dashboard_date_end' => 'Date de fin', | 'option_dashboard_date_end' => 'Date de fin', | ||||
'option_csv_export_all_products' => 'Exporter tous les produits dans le fichier récapitulatif (CSV)', | 'option_csv_export_all_products' => 'Exporter tous les produits dans le fichier récapitulatif (CSV)', | ||||
'option_csv_export_by_piece' => 'Exporter les produits par pièce dans le fichier récapitulatif (CSV)', | 'option_csv_export_by_piece' => 'Exporter les produits par pièce dans le fichier récapitulatif (CSV)', | ||||
'option_order_reference_type' => 'Type de référence', | |||||
]; | ]; | ||||
} | } | ||||
if (!$productsAdd) { | if (!$productsAdd) { | ||||
$order->delete(); | $order->delete(); | ||||
} | } | ||||
$order->initReference() ; | |||||
} | } | ||||
} | } | ||||
} | } |
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
class m210317_120805_reference_order extends Migration | |||||
{ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('order', 'reference', Schema::TYPE_STRING) ; | |||||
} | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('order', 'reference') ; | |||||
} | |||||
} |
<?php | |||||
use yii\db\Migration; | |||||
class m210317_122616_option_order_reference_type extends Migration | |||||
{ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'option_order_reference_type', Schema::TYPE_STRING); | |||||
} | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'option_order_reference_type'); | |||||
} | |||||
} |
} | } | ||||
$order->setTillerSynchronization() ; | $order->setTillerSynchronization() ; | ||||
$order->initReference() ; | |||||
} | } | ||||