$idProducer = Producer::getId() ; | $idProducer = Producer::getId() ; | ||||
} | } | ||||
$arrayOrders = Order::searchAll([ | |||||
'date' => $date, | |||||
'date_delete' => 'NULL' | |||||
$ordersArray = Order::searchAll([ | |||||
'distribution.date' => $date, | |||||
], | ], | ||||
[ | [ | ||||
'orderby' => 'comment_point_sale ASC, user.name ASC' | |||||
'orderby' => 'comment_point_sale ASC, user.name ASC', | |||||
'conditions' => 'date_delete IS NULL' | |||||
]) ; | ]) ; | ||||
$distribution = Distribution::searchOne([],[ | $distribution = Distribution::searchOne([],[ | ||||
]) ; | ]) ; | ||||
if ($distribution) { | if ($distribution) { | ||||
$arraySelectedProducts = ProductDistribution::searchProducts($distribution->id) ; | |||||
$arrayPointsSale = PointSale::searchAll() ; | |||||
$selectedProductsArray = ProductDistribution::searchByDistribution($distribution->id) ; | |||||
$pointsSaleArray = PointSale::searchAll() ; | |||||
foreach ($arrayPointsSale as $pointSale) { | |||||
$pointSale->initOrders($orders) ; | |||||
foreach ($pointsSaleArray as $pointSale) { | |||||
$pointSale->initOrders($ordersArray) ; | |||||
} | } | ||||
// produits | // produits | ||||
$arrayProducts = Product::searchAll() ; | |||||
$productsArray = Product::searchAll() ; | |||||
// get your HTML raw content without any layouts or scripts | // get your HTML raw content without any layouts or scripts | ||||
$content = $this->renderPartial('report', [ | $content = $this->renderPartial('report', [ | ||||
'distribution' => $distribution, | |||||
'date' => $date, | 'date' => $date, | ||||
'arraySelectedProducts' => $arraySelectedProducts, | |||||
'arrayPointsSale' => $arrayPointsSale, | |||||
'arrayProducts' => $arrayProducts, | |||||
'arrayOrders' => $arrayOrders | |||||
'distribution' => $distribution, | |||||
'selectedProductsArray' => $selectedProductsArray, | |||||
'pointsSaleArray' => $pointsSaleArray, | |||||
'productsArray' => $productsArray, | |||||
'ordersArray' => $ordersArray | |||||
]); | ]); | ||||
$dateStr = date('d/m/Y', strtotime($date)); | $dateStr = date('d/m/Y', strtotime($date)); | ||||
'orientation' => Pdf::ORIENT_PORTRAIT, | 'orientation' => Pdf::ORIENT_PORTRAIT, | ||||
// stream to browser inline | // stream to browser inline | ||||
'destination' => $destination, | 'destination' => $destination, | ||||
'filename' => Yii::getAlias('@app/web/pdf/Commandes-' . $date . '-' . $idProducert . '.pdf'), | |||||
'filename' => Yii::getAlias('@app/web/pdf/Commandes-' . $date . '-' . $idProducer . '.pdf'), | |||||
// your html content input | // your html content input | ||||
'content' => $content, | 'content' => $content, | ||||
// format content from your own css file if needed or use the | // format content from your own css file if needed or use the | ||||
/** | /** | ||||
* Traite le formulaire d'ajout/modification de commande. | * Traite le formulaire d'ajout/modification de commande. | ||||
* | * | ||||
* @param Production $production | |||||
* @param Distribution $distribution | |||||
* @param string $date | * @param string $date | ||||
* @param array $points_vente | * @param array $points_vente | ||||
* @param array $produits | * @param array $produits | ||||
if ($date != '') { | if ($date != '') { | ||||
// commandes | // commandes | ||||
$orders = Order::searchAll([ | $orders = Order::searchAll([ | ||||
'production.date' => $date | |||||
'distribution.date' => $date | |||||
]) ; | ]) ; | ||||
foreach ($pointsSale as $point) { | foreach ($pointsSale as $point) { | ||||
$point->initOrder($orders); | |||||
$point->initOrders($orders); | |||||
if (isset($_POST['submit_pv']) && $_POST['submit_pv']) { | if (isset($_POST['submit_pv']) && $_POST['submit_pv']) { | ||||
// modifs | // modifs | ||||
$this->processOrderForm($distribution, $date, $arrayPointsSale, $arrayProducts, $users); | $this->processOrderForm($distribution, $date, $arrayPointsSale, $arrayProducts, $users); | ||||
// commandes | // commandes | ||||
$arrayOrders = Commande::searchAll([ | |||||
'date' => $date, | |||||
'date_delete' => 'NULL' | |||||
$arrayOrders = Order::searchAll([ | |||||
'distribution.date' => $date, | |||||
], [ | |||||
'conditions' => 'date_delete IS NULL' | |||||
]); | ]); | ||||
$revenues = 0; | $revenues = 0; | ||||
$weight = 0 ; | $weight = 0 ; | ||||
$revenuesDelivered = 0; | $revenuesDelivered = 0; | ||||
foreach ($arrayOrders as $order) { | |||||
if(is_null($order->date_delete)) { | |||||
$revenues += $order->amount; | |||||
if ($order->id_point_sale != 1) { | |||||
$revenuesDelivered += $order->amount; | |||||
if($arrayOrders) { | |||||
foreach ($arrayOrders as $order) { | |||||
if(is_null($order->date_delete)) { | |||||
$revenues += $order->amount; | |||||
if ($order->id_point_sale != 1) { | |||||
$revenuesDelivered += $order->amount; | |||||
} | |||||
$weight += $order->weight; | |||||
} | } | ||||
$weight += $order->weight; | |||||
} | } | ||||
} | } | ||||
$revenues = number_format($revenues, 2); | $revenues = number_format($revenues, 2); | ||||
// init commandes point de vente | // init commandes point de vente | ||||
$dataOptionsOrders = []; | $dataOptionsOrders = []; | ||||
foreach ($pointSale->orders as $order) { | foreach ($pointSale->orders as $order) { | ||||
if ($order->user) { | if ($order->user) { | ||||
$dataSelectOrders[$order->id] = $order->user->name . ' ' . $c->user->lastname; | |||||
$dataSelectOrders[$order->id] = $order->user->name . ' ' . $order->user->lastname; | |||||
} else { | } else { | ||||
$dataSelectOrders[$order->id] = $order->username; | $dataSelectOrders[$order->id] = $order->username; | ||||
} | } | ||||
$dataOptionsOrders[$order->id] = []; | $dataOptionsOrders[$order->id] = []; | ||||
$arrayOptions = []; | $arrayOptions = []; | ||||
$arrayOptions[$order->id]['amount'] = $c->montant; | |||||
$arrayOptions[$order->id]['str_amount'] = number_format($c->montant, 2, ',', '') . ' €'; | |||||
$arrayOptions[$order->id]['amount_paid'] = $c->montant_paye; | |||||
$arrayOptions[$order->id]['amount'] = $order->amount; | |||||
$arrayOptions[$order->id]['str_amount'] = number_format($order->amount, 2, ',', '') . ' €'; | |||||
$arrayOptions[$order->id]['paid_amount'] = $order->paid_amount; | |||||
$arrayOptions[$order->id]['products'] = []; | $arrayOptions[$order->id]['products'] = []; | ||||
$arrayOptions[$order->id]['comment'] = Html::encode($c->commentaire); | |||||
$arrayOptions[$order->id]['comment'] = Html::encode($order->comment); | |||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
$arrayOptions[$order->id]['products'][$productOrder->id_product] = $productOrder->quantity; | $arrayOptions[$order->id]['products'][$productOrder->id_product] = $productOrder->quantity; | ||||
} | } | ||||
$dataOptionsOrders[$order->id]['data-commande'] = json_encode($arrayOptions[$order->id]); | |||||
$dataOptionsOrders[$order->id]['data-order'] = json_encode($arrayOptions[$order->id]); | |||||
$dataOptionsOrders[$order->id]['value'] = $order->id; | $dataOptionsOrders[$order->id]['value'] = $order->id; | ||||
} | } | ||||
$pointSale->data_select_orders = $dataSelectOrders ; | $pointSale->data_select_orders = $dataSelectOrders ; | ||||
} | } | ||||
// gestion produits selec | // gestion produits selec | ||||
if (isset($_POST['validate_product_selec'])) { | |||||
if (isset($_POST['valider_produit_selec'])) { | |||||
if (isset($_POST['Product'])) { | if (isset($_POST['Product'])) { | ||||
$oointsSaleDistribution = []; | $oointsSaleDistribution = []; | ||||
if ($distribution) { | if ($distribution) { | ||||
$oointsSaleDistribution = PointSaleDistribution::searchAll() ; | |||||
$pointsSaleDistribution = PointSaleDistribution::searchAll([ | |||||
'id_distribution' => $distribution->id | |||||
]) ; | |||||
} | } | ||||
$arrayPointsSaleDistribution = []; | $arrayPointsSaleDistribution = []; | ||||
foreach ($arrayPointsSaleDistribution as $pointSaleDistribution) { | |||||
$key = $pointSaleDistribution->id_distribution . '-' . $pointSaleDistribution->id_point_sale; | |||||
if ($pointSaleDistribution->delivery == 1) { | |||||
$pointSaleDistribution->points_sale_distribution[] = $key; | |||||
} | |||||
if(isset($pointSaleDistribution->pointSale) && strlen($pointSaleDistribution->pointSale->name)) { | |||||
$arrayPointsSaleDistribution[$key] = Html::encode($pointSaleDistribution->pointSale->name); | |||||
if(isset($pointsSaleDistribution)) { | |||||
foreach ($pointsSaleDistribution as $pointSaleDistrib) { | |||||
$key = $pointSaleDistrib->id_distribution . '-' . $pointSaleDistrib->id_point_sale; | |||||
if ($pointSaleDistrib->delivery == 1) { | |||||
$pointSaleDistribution->points_sale_distribution[] = $key; | |||||
} | |||||
if(isset($pointSaleDistrib->pointSale) && strlen($pointSaleDistrib->pointSale->name)) { | |||||
$arrayPointsSaleDistribution[$key] = Html::encode($pointSaleDistrib->pointSale->name); | |||||
} | |||||
} | } | ||||
} | } | ||||
if($weekDistribution) { | if($weekDistribution) { | ||||
$oneDistributionWeekActive = true ; | $oneDistributionWeekActive = true ; | ||||
} | } | ||||
$datas = [ | $datas = [ | ||||
'arrayProducts' => $arrayProducts, | 'arrayProducts' => $arrayProducts, | ||||
'arrayPointsSale' => $arrayPointsSale, | 'arrayPointsSale' => $arrayPointsSale, | ||||
'oneDistributionWeekActive' => $oneDistributionWeekActive | 'oneDistributionWeekActive' => $oneDistributionWeekActive | ||||
]; | ]; | ||||
if ($return_data) { | |||||
if ($returnData) { | |||||
return $datas; | return $datas; | ||||
} else { | } else { | ||||
return $this->render('index', $datas); | return $this->render('index', $datas); | ||||
* | * | ||||
* @see OrderController::actionDownload() | * @see OrderController::actionDownload() | ||||
* @param string $date | * @param string $date | ||||
* @param array $produits | |||||
* @param array $points_vente | |||||
* @param array $commandes | |||||
* @param array $products | |||||
* @param array $pointsSale | |||||
* @param array $orders | |||||
* @return array | * @return array | ||||
*/ | */ | ||||
public function contentRecapCSV($date, $products, $pointsSale, $orders) | public function contentRecapCSV($date, $products, $pointsSale, $orders) | ||||
$order->distribution->id_producer == Producer::getId()) { | $order->distribution->id_producer == Producer::getId()) { | ||||
$products = json_decode($products); | $products = json_decode($products); | ||||
foreach ($produits as $key => $quantity) { | |||||
foreach ($products as $key => $quantity) { | |||||
$productOrder = ProductOrder::findOne([ | $productOrder = ProductOrder::findOne([ | ||||
'id_order' => $idOrder, | 'id_order' => $idOrder, | ||||
'id_product' => $key | 'id_product' => $key | ||||
if ($order) { | if ($order) { | ||||
// remboursement si l'utilisateur a payé pour cette commande | // remboursement si l'utilisateur a payé pour cette commande | ||||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | $amountPaid = $order->getAmount(Order::AMOUNT_PAID); | ||||
if ($montantPaid > 0.01) { | |||||
if ($amountPaid > 0.01) { | |||||
$order->saveCreditHistory( | $order->saveCreditHistory( | ||||
CreditHistory::TYPE_REFUND, | CreditHistory::TYPE_REFUND, | ||||
$montantPaid, | |||||
$amountPaid, | |||||
Producer::getId(), | Producer::getId(), | ||||
$order->id_user, | $order->id_user, | ||||
User::getCurrentId() | User::getCurrentId() | ||||
$order->date = date('Y-m-d H:i:s', strtotime($date . ' ' . date('H:i:s'))); | $order->date = date('Y-m-d H:i:s', strtotime($date . ' ' . date('H:i:s'))); | ||||
$order->id_point_sale = $idPointSale; | $order->id_point_sale = $idPointSale; | ||||
$order->id_distribution = $distribution->id; | $order->id_distribution = $distribution->id; | ||||
$order->type = Order::ORIGIN_ADMIN; | |||||
$order->origin = Order::ORIGIN_ADMIN; | |||||
$order->comment = $comment; | $order->comment = $comment; | ||||
if ($idUser) { | if ($idUser) { | ||||
$order->id_user = 0; | $order->id_user = 0; | ||||
} | } | ||||
$commande->save(); | |||||
$order->save(); | |||||
foreach ($products as $key => $quantity) { | foreach ($products as $key => $quantity) { | ||||
$product = Product::findOne($key); | $product = Product::findOne($key); | ||||
$productOrder->id_order = $order->id; | $productOrder->id_order = $order->id; | ||||
$productOrder->id_product = $key; | $productOrder->id_product = $key; | ||||
$productOrder->quantity = $quantity; | $productOrder->quantity = $quantity; | ||||
$productOrder->price = $produit->price; | |||||
$productOrder->price = $product->price; | |||||
$productOrder->save(); | $productOrder->save(); | ||||
} | } | ||||
} | } | ||||
$strComment = ' <span class="glyphicon glyphicon-comment"></span>'; | $strComment = ' <span class="glyphicon glyphicon-comment"></span>'; | ||||
} | } | ||||
$strLabelOrderType = ''; | |||||
if ($order->type) { | |||||
$strLabelOrderType = ' <span class="label label-warning">vous</span>'; | |||||
$strLabelOrderOrigin = ''; | |||||
if ($order->origin) { | |||||
$strLabelOrderOrigin = ' <span class="label label-warning">vous</span>'; | |||||
} | } | ||||
echo json_encode([ | echo json_encode([ | ||||
'id_order' => $order->id, | 'id_order' => $order->id, | ||||
'total_point_sale' => number_format($point_sale->revenues, 2) . ' €', | |||||
'total_point_sale' => number_format($pointSale->revenues, 2) . ' €', | |||||
'order' => '<li>' | 'order' => '<li>' | ||||
. '<a class="btn btn-default" href="javascript:void(0);" ' | . '<a class="btn btn-default" href="javascript:void(0);" ' | ||||
. 'data-point-sale-id="' . $id_point_sale . '" ' | |||||
. 'data-id-order="' . $order->id . '" ' | |||||
. 'data-order=\'' . $jsonOrder. '\' ' | |||||
. 'data-pv-id="' . $idPointSale . '" ' | |||||
. 'data-id-commande="' . $order->id . '" ' | |||||
. 'data-commande=\'' . $jsonOrder. '\' ' | |||||
. 'data-date="' . date('d/m H:i', strtotime($order->date)) . '">' | . 'data-date="' . date('d/m H:i', strtotime($order->date)) . '">' | ||||
. '<span class="amount">' . number_format($order->amount, 2) . ' €</span>' | |||||
. '<span class="user">' . $strLabelOrderType . ' ' . $str_user . '</span>' | |||||
. '<span class="montant">' . number_format($order->amount, 2) . ' €</span>' | |||||
. '<span class="user">' . $strLabelOrderOrigin . ' ' . $strUser . '</span>' | |||||
. $strComment | . $strComment | ||||
. '</a></li>', | . '</a></li>', | ||||
]); | ]); | ||||
if ($distribution) { | if ($distribution) { | ||||
// produits | // produits | ||||
$products = Product::searchOne() ; | |||||
$products = Product::searchAll() ; | |||||
// commandes | // commandes | ||||
$orders = Order::searchAll([ | $orders = Order::searchAll([ | ||||
if ($selectedProduct['active']) { | if ($selectedProduct['active']) { | ||||
foreach ($products as $product) { | foreach ($products as $product) { | ||||
if ($product->id == $idSelectedProduct) { | if ($product->id == $idSelectedProduct) { | ||||
$potentialTurnover += $slectedProduct['quantity_max'] * $product->price; | |||||
$potentialTurnover += $selectedProduct['quantity_max'] * $product->price; | |||||
$totalWeight += $selectedProduct['quantity_max'] * $product->weight / 1000; | $totalWeight += $selectedProduct['quantity_max'] * $product->weight / 1000; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$htmlTotals = $this->renderPartial('_total_orders.php', [ | $htmlTotals = $this->renderPartial('_total_orders.php', [ | ||||
'products' => $products, | |||||
'orders' => $orders, | |||||
'selectedProducts' => $selectedProducts, | |||||
'arrayProducts' => $products, | |||||
'arrayOrders' => $orders, | |||||
'arrayProductsSelected' => $selectedProducts, | |||||
'revenues' => $revenues, | 'revenues' => $revenues, | ||||
'totalWeight' => $totalWeight, | 'totalWeight' => $totalWeight, | ||||
'potentialTurnover' => $potentialTurnover, | 'potentialTurnover' => $potentialTurnover, | ||||
/** | /** | ||||
* Retourne l'état du paiement (historique, crédit) d'une commande donnée. | * Retourne l'état du paiement (historique, crédit) d'une commande donnée. | ||||
* | * | ||||
* @param integer $id_commande | |||||
* @param integer $idOrder | |||||
*/ | */ | ||||
public function actionPaymentStatus($idOrder) | public function actionPaymentStatus($idOrder) | ||||
{ | { | ||||
$order = Order::searchOne(['id' => $idOrder]) ; | $order = Order::searchOne(['id' => $idOrder]) ; | ||||
if ($order) { | if ($order) { | ||||
$html = ''; | $html = ''; | ||||
if ($order->id_user) { | if ($order->id_user) { | ||||
$userProducer = UserProducer::find() | $userProducer = UserProducer::find() | ||||
->where([ | |||||
'id_user' => $order->id_user, | |||||
'id_producer' => $order->distribution->id_producer | |||||
]) | |||||
->one(); | |||||
->where([ | |||||
'id_user' => $order->id_user, | |||||
'id_producer' => $order->distribution->id_producer | |||||
]) | |||||
->one(); | |||||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | $amountPaid = $order->getAmount(Order::AMOUNT_PAID); | ||||
if (abs($order->amount - $amountPaid) < 0.0001) { | if (abs($order->amount - $amountPaid) < 0.0001) { | ||||
$html .= '<span class="label label-success">Payé</span>'; | $html .= '<span class="label label-success">Payé</span>'; | ||||
$buttonsCredit = Html::a('Rembourser ' . $order->getAmount(Order::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs refund', 'data-amount' => $order->amount, 'data-type' => 'refund']); | |||||
$buttonsCredit = Html::a('Rembourser ' . $order->getAmount(Order::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $order->amount, 'data-type' => 'refund']); | |||||
} elseif ($order->amount > $amountPaid) { | } elseif ($order->amount > $amountPaid) { | ||||
$amountToPay = $order->amount - $amountPaid; | $amountToPay = $order->amount - $amountPaid; | ||||
$html .= '<span class="label label-danger">Non payé</span> reste <strong>' . number_format($amountToPay, 2) . ' €</strong> à payer'; | $html .= '<span class="label label-danger">Non payé</span> reste <strong>' . number_format($amountToPay, 2) . ' €</strong> à payer'; | ||||
$buttonsCredit = Html::a('Payer ' . number_format($amountToPay, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs pay', 'data-amount' => $amountToPay, 'data-type' => 'payment']); | |||||
$buttonsCredit = Html::a('Payer ' . number_format($amountToPay, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs payer', 'data-montant' => $amountToPay, 'data-type' => 'payment']); | |||||
} elseif ($order->amount < $amountPaid) { | } elseif ($order->amount < $amountPaid) { | ||||
$amountToRefund = $amountPaid - $order->amount; | $amountToRefund = $amountPaid - $order->amount; | ||||
$html .= ' <span class="label label-success">Payé</span> <strong>' . number_format($amountToRefund, 2) . ' €</strong> à rembourser'; | $html .= ' <span class="label label-success">Payé</span> <strong>' . number_format($amountToRefund, 2) . ' €</strong> à rembourser'; | ||||
$buttonsCredit = Html::a('Rembourser ' . number_format($amountToRefund, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs refund', 'data-aùount' => $amountToRefund, 'data-type' => 'refund']); | |||||
$buttonsCredit = Html::a('Rembourser ' . number_format($amountToRefund, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $amountToRefund, 'data-type' => 'refund']); | |||||
} | } | ||||
$html .= '<span class="buttons-credit">' | $html .= '<span class="buttons-credit">' | ||||
$html .= '<tr>' | $html .= '<tr>' | ||||
. '<td>' . date('d/m/Y H:i:s', strtotime($h->date)) . '</td>' | . '<td>' . date('d/m/Y H:i:s', strtotime($h->date)) . '</td>' | ||||
. '<td>' . Html::encode($h->strUserAction()) . '</td>' | . '<td>' . Html::encode($h->strUserAction()) . '</td>' | ||||
. '<td>' . $h->getStrLibelle() . '</td>' | |||||
. '<td>' . $h->getStrWording() . '</td>' | |||||
. '<td>' . ($h->isTypeDebit() ? '- '.$h->getAmount(Order::AMOUNT_TOTAL,true) : '') . '</td>' | . '<td>' . ($h->isTypeDebit() ? '- '.$h->getAmount(Order::AMOUNT_TOTAL,true) : '') . '</td>' | ||||
. '<td>' . ($h->isTypeCredit() ? '+ '.$h->getAmount(Order::AMOUNT_TOTAL,true) : '') . '</td>' | . '<td>' . ($h->isTypeCredit() ? '+ '.$h->getAmount(Order::AMOUNT_TOTAL,true) : '') . '</td>' | ||||
. '</tr>'; | . '</tr>'; | ||||
} | } | ||||
echo json_encode([ | echo json_encode([ | ||||
'html_statut_paiement' => $html, | |||||
'json_commande' => $commande->getDataJson() | |||||
'html_payment_status' => $html, | |||||
'json_order' => $order->getDataJson() | |||||
]); | ]); | ||||
} | } | ||||
/** | /** | ||||
* UserController implements the CRUD actions for User model. | * UserController implements the CRUD actions for User model. | ||||
*/ | */ | ||||
class EtablissementAdminController extends BackendController | |||||
class ProducerAdminController extends BackendController | |||||
{ | { | ||||
public function behaviors() | public function behaviors() | ||||
{ | { | ||||
$dataProviderProducer = new ActiveDataProvider([ | $dataProviderProducer = new ActiveDataProvider([ | ||||
'query' => Producer::find() | 'query' => Producer::find() | ||||
->with('userEtablissement', 'user') | |||||
->with('userProducer', 'user') | |||||
->orderBy('date_creation DESC'), | ->orderBy('date_creation DESC'), | ||||
'pagination' => [ | 'pagination' => [ | ||||
'pageSize' => 1000, | 'pageSize' => 1000, |
// dernières commandes | // dernières commandes | ||||
$ordersArray = Order::searchAll([],[ | $ordersArray = Order::searchAll([],[ | ||||
'orderby' => 'date DESC', | 'orderby' => 'date DESC', | ||||
'conditions' => 'distribution.date > :date AND (origin = \'' . Order::ORIGIN_USER . '\' OR type = \'' . Order::ORIGIN_ADMIN . '\' OR (type = \'' . Order::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))', | |||||
'conditions' => 'distribution.date > :date AND (origin = \'' . Order::ORIGIN_USER . '\' OR origin = \'' . Order::ORIGIN_ADMIN . '\' OR (origin = \'' . Order::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR date_delete IS NOT NULL)))', | |||||
'params' => [':date' => date('Y-m-d 00:00:00')], | 'params' => [':date' => date('Y-m-d 00:00:00')], | ||||
]); | ]); | ||||
$userProducer->save() ; | $userProducer->save() ; | ||||
} | } | ||||
else { | else { | ||||
throw new \yii\web\NotFoundHttpException('L\'enregistrement UserEtablissement est introuvable', 404) ; | |||||
throw new \yii\web\NotFoundHttpException('L\'enregistrement UserProducer est introuvable', 404) ; | |||||
} | } | ||||
$params = Yii::$app->getRequest()->getQueryParams() ; | $params = Yii::$app->getRequest()->getQueryParams() ; |
<?php | <?php | ||||
foreach ($arrayProducts as $p) { | foreach ($arrayProducts as $p) { | ||||
if ((isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']) || | if ((isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']) || | ||||
(!$arrayProductsSelected[$p->id]['active'] && Commande::getQuantiteProduit($p->id, $arrayOrders))) | |||||
(!$arrayProductsSelected[$p->id]['active'] && Order::getProductQuantity($p->id, $arrayOrders))) | |||||
{ | { | ||||
(!$arrayProductsSelected[$p->id]['active']) ? $class_disabled = 'disabled' : $class_disabled = '' ; | (!$arrayProductsSelected[$p->id]['active']) ? $class_disabled = 'disabled' : $class_disabled = '' ; | ||||
echo '<th class="rotate-45 '.$class_disabled.'"><div><span>'.Html::encode($p->getLibelleAdmin()).'</span></div></th>' ; | |||||
echo '<th class="rotate-45 '.$class_disabled.'"><div><span>'.Html::encode($p->getStrWordingAdmin()).'</span></div></th>' ; | |||||
} | } | ||||
} | } | ||||
?> | ?> | ||||
<tr> | <tr> | ||||
<?php | <?php | ||||
foreach ($arrayProducts as $p) { | foreach ($arrayProducts as $p) { | ||||
$quantity = Commande::getQuantiteProduit($p->id, $arrayOrders); | |||||
$quantity = Order::getProductQuantity($p->id, $arrayOrders); | |||||
if ((isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']) || $quantity) | if ((isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']) || $quantity) | ||||
{ | { | ||||
$strQuantity = ''; | $strQuantity = ''; | ||||
} | } | ||||
$class = 'total'; | $class = 'total'; | ||||
if ($strQuantity > $arrayProductsSelected[$p->id]['quantity_max'] && !$arrayProductsSelected[$p->id]['vrac']) | |||||
if ($strQuantity > $arrayProductsSelected[$p->id]['quantity_max']) | |||||
{ | { | ||||
$class .= ' depasse'; | $class .= ' depasse'; | ||||
} | } |
<?php if ($date != ''): ?> | <?php if ($date != ''): ?> | ||||
<div id="bloc-production"> | <div id="bloc-production"> | ||||
<input type="hidden" id="date-distribution" value="<?= $date ?>" /> | |||||
<input type="hidden" id="id-distribution" value="<?= $distribution->id ?>" /> | |||||
<input type="hidden" id="date-production" value="<?= $date ?>" /> | |||||
<input type="hidden" id="id-production" value="<?= $distribution->id ?>" /> | |||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-heading"> | <div class="panel-heading"> | ||||
<h3 class="panel-title">Distribution du <strong><?php echo date('d/m/Y', strtotime($date)); ?></strong></h3> | <h3 class="panel-title">Distribution du <strong><?php echo date('d/m/Y', strtotime($date)); ?></strong></h3> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if($distribution->delivery && count($arrayPointsSaleDistribution)): ?> | <?php if($distribution->delivery && count($arrayPointsSaleDistribution)): ?> | ||||
<div id="distribution-points-sale"> | |||||
<div id="productions-point-vente"> | |||||
<strong>Points de vente : </strong> | <strong>Points de vente : </strong> | ||||
<div class="checkbox-list"> | <div class="checkbox-list"> | ||||
<?= Html::activeCheckboxList( | <?= Html::activeCheckboxList( | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if ($distribution): ?> | <?php if ($distribution): ?> | ||||
<div id="block-products"> | |||||
<div id="bloc-produits"> | |||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-heading"> | <div class="panel-heading"> | ||||
<h3 class="panel-title">Produits</h3> | <h3 class="panel-title">Produits</h3> | ||||
</div> | </div> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<!-- produits sélectionnés --> | <!-- produits sélectionnés --> | ||||
<form id="products-distribution" action="<?php echo Yii::$app->urlManager->createUrl(['order/index', 'date' => $date]); ?>" method="post"> | |||||
<form id="produits-production" action="<?php echo Yii::$app->urlManager->createUrl(['order/index', 'date' => $date]); ?>" method="post"> | |||||
<div class="overflow"> | <div class="overflow"> | ||||
<table class="table table-condensed"> | <table class="table table-condensed"> | ||||
<thead> | <thead> | ||||
<tr> | <tr> | ||||
<th class="td-active">Actif</th> | <th class="td-active">Actif</th> | ||||
<th class="td-product">Produit</th> | |||||
<th class="td-produit">Produit</th> | |||||
<th class="td-max">Max. <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="top" data-original-title="Quantité disponible à la commande. Laisser vide si vous ne souhaitez pas avoir de limite de commande. La valeur par défaut est configurable dans vos produits."></span></th> | <th class="td-max">Max. <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="top" data-original-title="Quantité disponible à la commande. Laisser vide si vous ne souhaitez pas avoir de limite de commande. La valeur par défaut est configurable dans vos produits."></span></th> | ||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<?php foreach ($arrayProducts as $p): ?> | <?php foreach ($arrayProducts as $p): ?> | ||||
<tr<?php if ($p->vrac): ?> style="display:none;"<?php endif; ?> <?php if (isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']): ?>class="active"<?php endif; ?>> | |||||
<td class="td-active"><input id="product-<?php echo $p->id; ?>" name="Product[<?php echo $p->id; ?>][active]" type="checkbox" <?php if (isset($arrayProductsSelected[$p->id]['active']) && $arrayProductsSelected[$p->id]['active']): ?>checked="checked"<?php endif; ?> /></td> | |||||
<td class="td-product"><label for="product-<?php echo $p->id; ?>"><?= Html::encode($p->name) ?></label></td> | |||||
<td class="td-max"><input class="quantity-max" name="Product[<?php echo $p->id; ?>][quantity_max]" type="text" value="<?php if (isset($arrayProductsSelected[$p->id])) echo $arrayProductsSelected[$p->id]['quantity_max']; ?>" /></td> | |||||
<tr <?php if (isset($selectedProducts[$p->id]['active']) && $selectedProducts[$p->id]['active']): ?>class="active"<?php endif; ?>> | |||||
<td class="td-active"><input id="product-<?php echo $p->id; ?>" name="Product[<?php echo $p->id; ?>][active]" type="checkbox" <?php if (isset($selectedProducts[$p->id]['active']) && $selectedProducts[$p->id]['active']): ?>checked="checked"<?php endif; ?> /></td> | |||||
<td class="td-produit"><label for="product-<?php echo $p->id; ?>"><?= Html::encode($p->name) ?></label></td> | |||||
<td class="td-max"><input class="quantity-max" name="Product[<?php echo $p->id; ?>][quantity_max]" type="text" value="<?php if (isset($selectedProducts[$p->id])) echo $selectedProducts[$p->id]['quantity_max']; ?>" /></td> | |||||
</tr> | </tr> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
</tbody> | </tbody> | ||||
</table> | </table> | ||||
</div> | </div> | ||||
<input type="submit" name="valider_product_selec" class="btn btn-default" value="Valider" /> | |||||
<input type="submit" name="valider_produit_selec" class="btn btn-default" value="Valider" /> | |||||
</form> | </form> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="col-md-9" id="col-right"> | <div class="col-md-9" id="col-right"> | ||||
<input type="hidden" value="<?php echo $date; ?>" id="current-date" /> | <input type="hidden" value="<?php echo $date; ?>" id="current-date" /> | ||||
<ul id="distribution-days"> | |||||
<ul id="jours-production"> | |||||
<?php foreach ($arrayDistributionDays as $distributionDay) : ?> | <?php foreach ($arrayDistributionDays as $distributionDay) : ?> | ||||
<li><?php echo $distributionDay->date; ?></li> | <li><?php echo $distributionDay->date; ?></li> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<div id="bloc-totaux"> | <div id="bloc-totaux"> | ||||
<?= $this->render('_total_orders.php',[ | <?= $this->render('_total_orders.php',[ | ||||
'arrayPoducts' => $arrayProducts, | |||||
'arrayProducts' => $arrayProducts, | |||||
'arrayOrders' => $arrayOrders, | 'arrayOrders' => $arrayOrders, | ||||
'arraySelectedProducts' => $arrayProductsSelected, | |||||
'arrayProductsSelected' => $selectedProducts, | |||||
'revenues' => $revenues, | 'revenues' => $revenues, | ||||
'weight' => $weight, | 'weight' => $weight, | ||||
'potentialTurnover' => $potentialTurnover, | 'potentialTurnover' => $potentialTurnover, | ||||
$champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine]; | $champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine]; | ||||
?> | ?> | ||||
<div class="panel panel-default" id="panel-orders"> | |||||
<div class="panel panel-default" id="panel-commandes"> | |||||
<div class="panel-heading"> | <div class="panel-heading"> | ||||
<h3 class="panel-title"> | <h3 class="panel-title"> | ||||
Commandes | Commandes | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if (count($arrayOrders)): ?> | <?php if (count($arrayOrders)): ?> | ||||
<a id="btn-export-orders" class="btn btn-primary" href="<?php echo Yii::$app->urlManager->createUrl(['order/report', 'date' => $date, 'idPointSale' => 0, 'global' => 1]); ?>"><span class="glyphicon glyphicon-download-alt"></span> Exporter</a> | |||||
<a id="btn-export-commandes" class="btn btn-primary" href="<?php echo Yii::$app->urlManager->createUrl(['order/report', 'date' => $date, 'idPointSale' => 0, 'global' => 1]); ?>"><span class="glyphicon glyphicon-download-alt"></span> Exporter</a> | |||||
<?php endif; ?> | <?php endif; ?> | ||||
<div id="btn-subscription" class="btn-group"> | |||||
<div id="btn-commandes-auto" class="btn-group"> | |||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||||
<span class="glyphicon glyphicon-repeat"></span> Abonnements <span class="caret"></span> | <span class="glyphicon glyphicon-repeat"></span> Abonnements <span class="caret"></span> | ||||
</button> | </button> | ||||
<!-- Nav tabs --> | <!-- Nav tabs --> | ||||
<ul id="tabs-points-vente" class="nav nav-tabs" role="tablist"> | <ul id="tabs-points-vente" class="nav nav-tabs" role="tablist"> | ||||
<?php foreach($arrayPointsSaleDistribution as $pointSale): ?> | |||||
<?php foreach($arrayPointsSale as $pointSale): ?> | |||||
<li role="presentation" class="<?php if($pointSale->point_production): ?>active<?php endif; ?>"> | <li role="presentation" class="<?php if($pointSale->point_production): ?>active<?php endif; ?>"> | ||||
<a href="#point-vente-<?= $pointSale->id ?>" id="btn-point-sale-<?= $pointSale->id ?>" aria-controls="point-sale-<?= $pointSale->id ?>" role="tab" data-toggle="tab"><?= Html::encode($pointSale->name) ?> <span class="badge badge-<?php if(count($pointSale->orders)): ?>success<?php else: ?>danger<?php endif; ?>"><?php echo count($pointSale->orders); ?></span></a> | |||||
<a href="#point-vente-<?= $pointSale->id ?>" id="btn-point-vente-<?= $pointSale->id ?>" aria-controls="point-sale-<?= $pointSale->id ?>" role="tab" data-toggle="tab"><?= Html::encode($pointSale->name) ?> <span class="badge badge-<?php if(count($pointSale->orders)): ?>success<?php else: ?>danger<?php endif; ?>"><?php echo count($pointSale->orders); ?></span></a> | |||||
</li> | </li> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
</ul> | </ul> | ||||
<!-- Tab panes --> | <!-- Tab panes --> | ||||
<div class="tab-content" id="orders-points-sale"> | |||||
<div class="tab-content" id="commandes-points-vente"> | |||||
<?php foreach($arrayPointsSale as $pointSale): ?> | <?php foreach($arrayPointsSale as $pointSale): ?> | ||||
<div role="tabpanel" data-id-pv="<?= $pointSale->id ?>" class="bloc-point-sale tab-pane <?php if($pointSale->point_production): ?> active<?php endif; ?>" id="point-sale-<?= $pointSale->id ?>"> | |||||
<div role="tabpanel" data-id-pv="<?= $pointSale->id ?>" class="bloc-point-vente tab-pane <?php if($pointSale->point_production): ?> active<?php endif; ?>" id="point-vente-<?= $pointSale->id ?>"> | |||||
<div class="col-md-12"> | <div class="col-md-12"> | ||||
<div class="alert alert-warning recap-point-sale <?php if(!count($pointSale->orders)): ?>no-order<?php endif; ?>"> | |||||
<div class="alert alert-warning recap-pv <?php if(!count($pointSale->orders)): ?>no-order<?php endif; ?>"> | |||||
<?php if(count($pointSale->orders)): ?> | <?php if(count($pointSale->orders)): ?> | ||||
<strong class="orders"><?= count($pointSale->orders) ?> commande<?php if(count($pointSale->orders) > 1): ?>s<?php endif; ?></strong> | |||||
<span class="revenues"><?= number_format($pointSale->revenues, 2) ?> €</span> | |||||
<strong class="commandes"><?= count($pointSale->orders) ?> commande<?php if(count($pointSale->orders) > 1): ?>s<?php endif; ?></strong> | |||||
<span class="recettes"><?= number_format($pointSale->revenues, 2) ?> €</span> | |||||
<?php else: ?> | <?php else: ?> | ||||
<strong class="orders">Aucune commande</strong> | |||||
<span class="revenues"></span> | |||||
<strong class="commandes">Aucune commande</strong> | |||||
<span class="recettes"></span> | |||||
<?php endif; ?> | <?php endif; ?> | ||||
</div> | </div> | ||||
<ul class="liste-orders btn-group-vertical<?php if(!count($pointSale->orders)): ?> no-order<?php endif; ?>"> | |||||
<ul class="liste-commandes btn-group-vertical<?php if(!count($pointSale->orders)): ?> no-order<?php endif; ?>"> | |||||
<?php foreach($pointSale->orders as $order): ?> | <?php foreach($pointSale->orders as $order): ?> | ||||
<li> | <li> | ||||
<a href="javascript:void(0);" class="btn btn-default" data-point-sale-id="<?= $pointSale->id ?>" data-id-order="<?= $order->id ?>" data-order='<?= $pointSale->data_options_orders[$order->id]['data-order'] ?>' data-comment="<?= Html::encode($order->comment) ?>" data-date="<?= date('d/m à H:i',strtotime($order->date)); ?>"> | |||||
<span class="amount <?php if(number_format($order->paid_amount,2) >= number_format($order->amount,2)): ?>paid<?php endif; ?>"> | |||||
<a href="javascript:void(0);" class="btn btn-default" data-pv-id="<?= $pointSale->id ?>" data-id-commande="<?= $order->id ?>" data-commande='<?= $pointSale->data_options_orders[$order->id]['data-order'] ?>' data-commentaire="<?= Html::encode($order->comment) ?>" data-date="<?= date('d/m à H:i',strtotime($order->date)); ?>"> | |||||
<span class="montant <?php if(number_format($order->paid_amount,2) >= number_format($order->amount,2)): ?>paye<?php endif; ?>"> | |||||
<?= Html::encode(number_format($order->amount, 2)); ?> € | <?= Html::encode(number_format($order->amount, 2)); ?> € | ||||
<?php if($order->paid_amount - $order->amount > 0.01): ?><span class="glyphicon glyphicon-warning-sign"></span><?php endif; ?> | <?php if($order->paid_amount - $order->amount > 0.01): ?><span class="glyphicon glyphicon-warning-sign"></span><?php endif; ?> | ||||
</span> | </span> | ||||
<span class="user"> | <span class="user"> | ||||
<?php if($order->type): ?> | |||||
<?php if($order->type == Order::ORIGIN_ADMIN): ?> | |||||
<?php if($order->origin): ?> | |||||
<?php if($order->origin == Order::ORIGIN_ADMIN): ?> | |||||
<span class="label label-warning">vous</span> | <span class="label label-warning">vous</span> | ||||
<?php elseif($order->type == Order::ORIGIN_AUTO): ?> | |||||
<?php elseif($order->origin == Order::ORIGIN_AUTO): ?> | |||||
<span class="label label-default">auto</span> | <span class="label label-default">auto</span> | ||||
<?php elseif($order->type == Order::ORIGIN_USER): ?> | |||||
<?php elseif($order->origin == Order::ORIGIN_USER): ?> | |||||
<span class="label label-success">client</span> | <span class="label label-success">client</span> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
</li> | </li> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
</ul> | </ul> | ||||
<?= Html::a('<span class="glyphicon glyphicon-plus"></span> Créer une commande', 'javascript:void(0);', ['class' => 'btn btn-default create-corder', 'data-point-sale-id' => $pointSale->id]) ?> | |||||
<?= Html::a('<span class="glyphicon glyphicon-plus"></span> Créer une commande', 'javascript:void(0);', ['class' => 'btn btn-default creer-commande', 'data-pv-id' => $pointSale->id]) ?> | |||||
</div> | </div> | ||||
<div class="col-md-12 block-order"> | |||||
<div class="col-md-12 bloc-commande"> | |||||
<h2 class="title-user"> | <h2 class="title-user"> | ||||
<span class="buttons-edit-remove"> | <span class="buttons-edit-remove"> | ||||
<?= Html::a('<span class="glyphicon glyphicon-trash"></span> Supprimer', 'javascript:void(0);', ['class' => 'btn btn-default btn-remove']) ?> | <?= Html::a('<span class="glyphicon glyphicon-trash"></span> Supprimer', 'javascript:void(0);', ['class' => 'btn btn-default btn-remove']) ?> | ||||
</h2> | </h2> | ||||
<div class="commentaire alert alert-info"> | <div class="commentaire alert alert-info"> | ||||
</div> | </div> | ||||
<textarea name="comment" class="form-control textarea-comment" placeholder="Commentaire"></textarea> | |||||
<table class="table table-bordered table-condensed tab-content table-products"> | |||||
<textarea name="comment" class="form-control textarea-commentaire" placeholder="Commentaire"></textarea> | |||||
<table class="table table-bordered table-condensed tab-content table-produits"> | |||||
<tbody> | <tbody> | ||||
<?php foreach ($arrayProducts as $p): ?> | <?php foreach ($arrayProducts as $p): ?> | ||||
<tr class="product-<?= $p->id ?> <?php if(!$arrayProductsSelected[$p->id]['active']): ?> disabled<?php endif; ?>" data-id-product="<?= $p->id ?>"> | |||||
<td class="td-order"></td> | |||||
<td class="td-product"><?php echo Html::encode($p->getLibelleAdmin()); ?></td> | |||||
<tr class="produit-<?= $p->id ?> <?php if(!$selectedProducts[$p->id]['active']): ?> disabled<?php endif; ?>" data-id-produit="<?= $p->id ?>"> | |||||
<td class="td-commande"></td> | |||||
<td class="td-produit"><?php echo Html::encode($p->getStrWordingAdmin()); ?></td> | |||||
</tr> | </tr> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<tr class="tr-total"> | <tr class="tr-total"> |
use common\models\Order ; | use common\models\Order ; | ||||
$num_jour_semaine = date('w', strtotime($date)); | |||||
$arr_jour_semaine = [0 => 'dimanche', 1 => 'lundi', 2 => 'mardi', 3 => 'mercredi', 4 => 'jeudi', 5 => 'vendredi', 6 => 'samedi']; | |||||
$champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine]; | |||||
$dayWeek = date('w', strtotime($date)); | |||||
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saterday']; | |||||
$fieldInfosPointSale = 'infos_' . $dayWeekArray[$dayWeek]; | |||||
$html = '' ; | $html = '' ; | ||||
// par point de vente | // par point de vente | ||||
foreach ($points_vente as $pv) { | |||||
if (count($pv->order) && strlen($pv->$champs_horaires_point_vente)) { | |||||
foreach ($pointsSaleArray as $pointSale) { | |||||
if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale)) { | |||||
$html .= '<h3>'.$pv->name.'</h3>' ; | |||||
$col_credit_pain = '' ; | |||||
if($pv->credit) { | |||||
$col_credit = '<th>Rappel crédit</th>' ; | |||||
} | |||||
$html .= '<h3>'.$pointSale->name.'</h3>' ; | |||||
$colCredit = ($pointSale->credit) ? '<th>Rappel crédit</th>' : '' ; | |||||
$html .= '<table class="table table-bordered">' | $html .= '<table class="table table-bordered">' | ||||
. '<thead>' | . '<thead>' | ||||
. '<th>Client</th>' | . '<th>Client</th>' | ||||
. '<th>Produits</th>' | . '<th>Produits</th>' | ||||
. '<th>Commentaire</th>' | . '<th>Commentaire</th>' | ||||
. $col_credit | |||||
. $colCredit | |||||
. '<th>Montant</th>' | . '<th>Montant</th>' | ||||
. '</tr>' | . '</tr>' | ||||
. '<tbody>'; | . '<tbody>'; | ||||
foreach ($pv->orders as $c) { | |||||
foreach ($pointSale->orders as $order) { | |||||
$html .= '<tr>' ; | $html .= '<tr>' ; | ||||
$str_user = ''; | |||||
$strUser = ''; | |||||
// username | // username | ||||
if ($c->user) { | |||||
$str_user = $c->user->name . " " . $c->user->lastname; | |||||
if ($order->user) { | |||||
$strUser = $order->user->name . " " . $order->user->lastname; | |||||
} else { | } else { | ||||
$str_user = $c->username; | |||||
$strUser = $order->username; | |||||
} | } | ||||
if(strlen($c->comment_point_sale)) | |||||
if(strlen($order->comment_point_sale)) | |||||
{ | { | ||||
$str_user .= '<br /><em>'.$c->comment_point_sale.'</em>' ; | |||||
$strUser .= '<br /><em>'.$order->comment_point_sale.'</em>' ; | |||||
} | } | ||||
// téléphone | // téléphone | ||||
if (isset($c->user) && strlen($c->user->phone)) { | |||||
$str_user .= '<br />' . $c->user->phone . ''; | |||||
if (isset($order->user) && strlen($order->user->phone)) { | |||||
$strUser .= '<br />' . $order->user->phone . ''; | |||||
} | } | ||||
$html .= '<td>'.$str_user.'</td>'; | |||||
$html .= '<td>'.$strUser.'</td>'; | |||||
// produits | // produits | ||||
$str_produits = ''; | |||||
foreach ($produits as $p) { | |||||
$strProducts = ''; | |||||
foreach ($productsArray as $product) { | |||||
$add = false; | $add = false; | ||||
foreach ($c->productOrder as $cp) { | |||||
if ($p->id == $cp->id_product) { | |||||
$str_produits .= $cp->quantity . ' ' . $p->name . ', '; | |||||
foreach ($order->productOrder as $productOrder) { | |||||
if ($product->id == $productOrder->id_product) { | |||||
$strProducts .= $productOrder->quantity . ' ' . $product->name . ', '; | |||||
$add = true; | $add = true; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$html .= '<td>'.substr($str_produits, 0, strlen($str_produits) - 2).'</td>'; | |||||
$html .= '<td>'.$c->comment.'</td>'; | |||||
$html .= '<td>'.substr($strProducts, 0, strlen($strProducts) - 2).'</td>'; | |||||
$html .= '<td>'.$order->comment.'</td>'; | |||||
if($pv->credit) { | |||||
if($pointSale->credit) { | |||||
$credit = '' ; | $credit = '' ; | ||||
if(isset($c->user) && isset($c->user->userProducer)) { | |||||
$credit = number_format($c->user->userProducer[0]->credit,2).' €' ; | |||||
if(isset($order->user) && isset($order->user->userProducer)) { | |||||
$credit = number_format($order->user->userProducer[0]->credit,2).' €' ; | |||||
} | } | ||||
$html .= '<td>'.$credit.'</td>' ; | $html .= '<td>'.$credit.'</td>' ; | ||||
} | } | ||||
$html .= '<td><strong>'.number_format($c->amount, 2) . ' € '; | |||||
$html .= '<td><strong>'.number_format($order->amount, 2) . ' € '; | |||||
if($c->getStatusPayment() == Order::PAYMENT_PAID) | |||||
if($order->getPaymentStatus() == Order::PAYMENT_PAID) | |||||
{ | { | ||||
$html .= '(payé)' ; | $html .= '(payé)' ; | ||||
} | } | ||||
elseif($c->getStatusPayment() == Order::PAYMENT_UNPAID && $c->getAmount(Order::AMOUNT_PAID)) | |||||
elseif($order->getPaymentStatus() == Order::PAYMENT_UNPAID && $order->getAmount(Order::AMOUNT_PAID)) | |||||
{ | { | ||||
$html .= '(reste '.$c->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ; | |||||
$html .= '(reste '.$order->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ; | |||||
} | } | ||||
elseif($c->getStatusPayment() == Order::PAYMENT_SURPLUS) | |||||
elseif($order->getPaymentStatus() == Order::PAYMENT_SURPLUS) | |||||
{ | { | ||||
$html .= '(surplus : '.$c->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||||
$html .= '(surplus : '.$order->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||||
} | } | ||||
$html .= '</strong></td>' ; | $html .= '</strong></td>' ; | ||||
$html .= '<tr><td><strong>Total</strong></td>' ; | $html .= '<tr><td><strong>Total</strong></td>' ; | ||||
$str_produits = ''; | |||||
foreach ($produits as $p) { | |||||
$quantite = Order::getProductQuantity($p->id, $pv->orders); | |||||
$str_quantite = ''; | |||||
if ($quantite) { | |||||
$str_quantite = $quantite; | |||||
$str_produits .= $str_quantite .' '. $p->name . ', '; | |||||
$strProducts = ''; | |||||
foreach ($productsArray as $product) { | |||||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders); | |||||
$strQuantity = ''; | |||||
if ($quantity) { | |||||
$strQuantity = $quantity; | |||||
$strProducts .= $strQuantity .' '. $product->name . ', '; | |||||
} | } | ||||
} | } | ||||
$str_produits = substr($str_produits, 0, strlen($str_produits) - 2) ; | |||||
$strProducts = substr($strProducts, 0, strlen($strProducts) - 2) ; | |||||
$html .= '<td>'.$str_produits.'</td><td></td>' ; | |||||
if($pv->credit) { | |||||
$html .= '<td>'.$strProducts.'</td><td></td>' ; | |||||
if($pointSale->credit) { | |||||
$html .= '<td></td>' ; | $html .= '<td></td>' ; | ||||
} | } | ||||
$html .= '<td><strong>'.number_format($pv->revenues, 2) . ' €</strong></td>'; | |||||
$html .= '<td><strong>'.number_format($pointSale->revenues, 2) . ' €</strong></td>'; | |||||
$html .= '</tbody></table><pagebreak>' ; | $html .= '</tbody></table><pagebreak>' ; | ||||
} | } | ||||
. '</tr>' | . '</tr>' | ||||
. '<tbody>'; | . '<tbody>'; | ||||
$recettes = 0 ; | |||||
foreach ($points_vente as $pv) | |||||
$revenues = 0 ; | |||||
foreach ($pointsSaleArray as $pointSale) | |||||
{ | { | ||||
if (count($pv->orders) && strlen($pv->$champs_horaires_point_vente)) | |||||
if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale)) | |||||
{ | { | ||||
$html .= '<tr><td>'.$pv->name.'</td><td>' ; | |||||
foreach ($produits as $p) { | |||||
$quantite = Order::getProductQuantity($p->id, $pv->orders); | |||||
$str_quantite = ''; | |||||
if ($quantite) { | |||||
$str_quantite = $quantite; | |||||
} | |||||
$html .= '<tr><td>'.$pointSale->name.'</td><td>' ; | |||||
foreach ($productsArray as $product) { | |||||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders); | |||||
$strQuantity = ($quantity) ? $quantity : '' ; | |||||
if(strlen($str_quantite)) { | |||||
$html .= $str_quantite . ' '.$p->name.', ' ; | |||||
if(strlen($strQuantity)) { | |||||
$html .= $strQuantity . ' '.$product->name.', ' ; | |||||
} | } | ||||
} | } | ||||
$html = substr($html, 0, strlen($html) - 2) ; | $html = substr($html, 0, strlen($html) - 2) ; | ||||
$html .= '</td><td>'.number_format($pv->revenues, 2).' €</td></tr>' ; | |||||
$recettes += $pv->revenues ; | |||||
$html .= '</td><td>'.number_format($pointSale->revenues, 2).' €</td></tr>' ; | |||||
$revenues += $pointSale->revenues ; | |||||
} | } | ||||
} | } | ||||
// total | // total | ||||
$html .= '<tr><td><strong>Total</strong></td><td>' ; | $html .= '<tr><td><strong>Total</strong></td><td>' ; | ||||
foreach ($produits as $p) { | |||||
$quantite = Order::getProductQuantity($p->id, $orders); | |||||
if($quantite) { | |||||
$html .= $quantite . ' '.$p->name.', ' ; | |||||
foreach ($productsArray as $product) { | |||||
$quantity = Order::getProductQuantity($product->id, $ordersArray); | |||||
if($quantity) { | |||||
$html .= $quantity . ' '.$product->name.', ' ; | |||||
} | } | ||||
} | } | ||||
$html = substr($html, 0, strlen($html) - 2) ; | $html = substr($html, 0, strlen($html) - 2) ; | ||||
$html .= '</td><td><strong>'.number_format($recettes, 2).' €</strong></td></tr>' ; | |||||
$html .= '</td><td><strong>'.number_format($revenues, 2).' €</strong></td></tr>' ; | |||||
$html .= '</tbody></table>' ; | $html .= '</tbody></table>' ; | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>Délai de commande</td> | <td>Délai de commande</td> | ||||
<td><?= $producer->prder_delay ?> jour<?php if($producer->order_delay > 1): ?>s<?php endif; ?></td> | |||||
<td><?= $producer->order_delay ?> jour<?php if($producer->order_delay > 1): ?>s<?php endif; ?></td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>Heure limite de commande</td> | <td>Heure limite de commande</td> | ||||
<tbody> | <tbody> | ||||
<?php foreach($ordersArray as $order): ?> | <?php foreach($ordersArray as $order): ?> | ||||
<tr class="<?= $order->getClassHistory() ; ?>"> | <tr class="<?= $order->getClassHistory() ; ?>"> | ||||
<td class="infos"><?= $order->getStrType(true); ?></td> | |||||
<td class="infos"><?= $order->getStrOrigin(true); ?></td> | |||||
<td class="date"> | <td class="date"> | ||||
<div class="block-date"> | <div class="block-date"> | ||||
<div class="day"><?= strftime('%A', strtotime($order->distribution->date)) ?></div> | <div class="day"><?= strftime('%A', strtotime($order->distribution->date)) ?></div> |
padding-left: 20px; | padding-left: 20px; | ||||
} | } | ||||
/* line 432, ../sass/screen.scss */ | /* line 432, ../sass/screen.scss */ | ||||
#page-order #distribution-days { | |||||
#page-order #jours-production { | |||||
display: none; | display: none; | ||||
} | } | ||||
/* line 437, ../sass/screen.scss */ | /* line 437, ../sass/screen.scss */ | ||||
margin-top: 10px; | margin-top: 10px; | ||||
} | } | ||||
/* line 488, ../sass/screen.scss */ | /* line 488, ../sass/screen.scss */ | ||||
#page-order #block-distribution .label { | |||||
#page-order #bloc-production .label { | |||||
float: right; | float: right; | ||||
font-size: 13px; | font-size: 13px; | ||||
} | } | ||||
/* line 493, ../sass/screen.scss */ | /* line 493, ../sass/screen.scss */ | ||||
#page-order #block-distribution .btn-success { | |||||
#page-order #bloc-production .btn-success { | |||||
background-color: #5cb85c; | background-color: #5cb85c; | ||||
border-color: #4cae4c; | border-color: #4cae4c; | ||||
} | } | ||||
/* line 498, ../sass/screen.scss */ | /* line 498, ../sass/screen.scss */ | ||||
#page-order #block-distribution #distributions-points-sale { | |||||
#page-order #bloc-production #productions-point-vente { | |||||
margin-top: 15px; | margin-top: 15px; | ||||
padding: 10px; | padding: 10px; | ||||
border: solid 1px #e0e0e0; | border: solid 1px #e0e0e0; | ||||
border-radius: 5px; | border-radius: 5px; | ||||
} | } | ||||
/* line 504, ../sass/screen.scss */ | /* line 504, ../sass/screen.scss */ | ||||
#page-order #block-distribution #distributions-points-sale label { | |||||
#page-order #bloc-production #productions-point-vente label { | |||||
display: block; | display: block; | ||||
font-weight: normal; | font-weight: normal; | ||||
} | } | ||||
/* line 509, ../sass/screen.scss */ | /* line 509, ../sass/screen.scss */ | ||||
#page-order #block-distribution #distributions-points-sale .checkbox-list { | |||||
#page-order #bloc-production #productions-point-vente .checkbox-list { | |||||
margin-left: 10px; | margin-left: 10px; | ||||
margin-top: 10px; | margin-top: 10px; | ||||
} | } | ||||
/* line 520, ../sass/screen.scss */ | /* line 520, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow table { | |||||
#page-order #produits-production .overflow table { | |||||
width: 100%; | width: 100%; | ||||
} | } | ||||
/* line 524, ../sass/screen.scss */ | /* line 524, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow thead, #page-order #products-distribution .overflow tbody, #page-order #products-distribution .overflow tr, #page-order #products-distribution .overflow td, #page-order #products-distribution .overflow th { | |||||
#page-order #produits-production .overflow thead, #page-order #produits-production .overflow tbody, #page-order #produits-production .overflow tr, #page-order #produits-production .overflow td, #page-order #produits-production .overflow th { | |||||
display: block; | display: block; | ||||
} | } | ||||
/* line 526, ../sass/screen.scss */ | /* line 526, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow tr:after { | |||||
#page-order #produits-production .overflow tr:after { | |||||
content: ' '; | content: ' '; | ||||
display: block; | display: block; | ||||
visibility: hidden; | visibility: hidden; | ||||
clear: both; | clear: both; | ||||
} | } | ||||
/* line 533, ../sass/screen.scss */ | /* line 533, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow thead th { | |||||
#page-order #produits-production .overflow thead th { | |||||
height: 30px; | height: 30px; | ||||
} | } | ||||
/* line 538, ../sass/screen.scss */ | /* line 538, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow tbody { | |||||
#page-order #produits-production .overflow tbody { | |||||
height: 500px; | height: 500px; | ||||
overflow-y: auto; | overflow-y: auto; | ||||
} | } | ||||
/* line 546, ../sass/screen.scss */ | /* line 546, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow thead th { | |||||
#page-order #produits-production .overflow thead th { | |||||
width: 32%; | width: 32%; | ||||
float: left; | float: left; | ||||
} | } | ||||
/* line 551, ../sass/screen.scss */ | /* line 551, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow tbody td { | |||||
#page-order #produits-production .overflow tbody td { | |||||
width: 33%; | width: 33%; | ||||
float: left; | float: left; | ||||
} | } | ||||
/* line 556, ../sass/screen.scss */ | /* line 556, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow .td-product { | |||||
#page-order #produits-production .overflow .td-produit { | |||||
width: 60%; | width: 60%; | ||||
} | } | ||||
/* line 559, ../sass/screen.scss */ | /* line 559, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow .td-active, #page-order #products-distribution .overflow .td-max { | |||||
#page-order #produits-production .overflow .td-active, #page-order #produits-production .overflow .td-max { | |||||
width: 20%; | width: 20%; | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 565, ../sass/screen.scss */ | /* line 565, ../sass/screen.scss */ | ||||
#page-order #products-distribution .overflow thead .td-product { | |||||
#page-order #produits-production .overflow thead .td-product { | |||||
width: 57%; | width: 57%; | ||||
} | } | ||||
/* line 571, ../sass/screen.scss */ | /* line 571, ../sass/screen.scss */ | ||||
#page-order #products-distribution input.quantity-max { | |||||
#page-order #produits-production input.quantity-max { | |||||
background-color: white; | background-color: white; | ||||
border: 1px solid #e0e0e0; | border: 1px solid #e0e0e0; | ||||
text-align: center; | text-align: center; | ||||
width: 50px; | width: 50px; | ||||
} | } | ||||
/* line 579, ../sass/screen.scss */ | /* line 579, ../sass/screen.scss */ | ||||
#page-order #products-distribution td label { | |||||
#page-order #produits-production td label { | |||||
font-weight: normal; | font-weight: normal; | ||||
} | } | ||||
/* line 585, ../sass/screen.scss */ | /* line 585, ../sass/screen.scss */ | ||||
#page-order #btn-export-orders, | |||||
#page-order #btn-subscription { | |||||
#page-order #btn-export-commandes, | |||||
#page-order #btn-commandes-auto { | |||||
float: right; | float: right; | ||||
position: relative; | position: relative; | ||||
top: -5px; | top: -5px; | ||||
padding: 2px 5px; | padding: 2px 5px; | ||||
} | } | ||||
/* line 594, ../sass/screen.scss */ | /* line 594, ../sass/screen.scss */ | ||||
#page-order #btn-export-orders, | |||||
#page-order #btn-subscription { | |||||
#page-order #btn-export-commandes, | |||||
#page-order #btn-commandes-auto { | |||||
color: white; | color: white; | ||||
margin-left: 10px; | margin-left: 10px; | ||||
padding: 1px 5px; | padding: 1px 5px; | ||||
} | } | ||||
/* line 601, ../sass/screen.scss */ | /* line 601, ../sass/screen.scss */ | ||||
#page-order #btn-subscription { | |||||
#page-order #btn-commandes-auto { | |||||
top: -7px; | top: -7px; | ||||
} | } | ||||
/* line 603, ../sass/screen.scss */ | /* line 603, ../sass/screen.scss */ | ||||
#page-order #btn-subscription .btn { | |||||
#page-order #btn-commandes-auto .btn { | |||||
padding: 2px 5px; | padding: 2px 5px; | ||||
} | } | ||||
/* line 605, ../sass/screen.scss */ | /* line 605, ../sass/screen.scss */ | ||||
#page-order #btn-subscription .btn span { | |||||
#page-order #btn-commandes-auto .btn span { | |||||
top: 2px; | top: 2px; | ||||
} | } | ||||
/* line 613, ../sass/screen.scss */ | /* line 613, ../sass/screen.scss */ | ||||
#page-order #block-totals .table-products .depasse { | |||||
#page-order #bloc-totaux .table-products .depasse { | |||||
color: #b32815; | color: #b32815; | ||||
} | } | ||||
/* line 617, ../sass/screen.scss */ | /* line 617, ../sass/screen.scss */ | ||||
#page-order #block-totals .table-products .total strong span { | |||||
#page-order #bloc-totaux .table-products .total strong span { | |||||
font-weight: normal; | font-weight: normal; | ||||
font-size: 13px; | font-size: 13px; | ||||
} | } | ||||
/* line 626, ../sass/screen.scss */ | /* line 626, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .tab-pane { | |||||
#page-order #commandes-points-vente .tab-pane { | |||||
padding-top: 20px; | padding-top: 20px; | ||||
} | } | ||||
/* line 633, ../sass/screen.scss */ | /* line 633, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .recap-point-sale.no-order .revenues { | |||||
#page-order #commandes-points-vente .recap-pv.no-commande .recettes { | |||||
display: none; | display: none; | ||||
} | } | ||||
/* line 638, ../sass/screen.scss */ | /* line 638, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .recap-point-sale .revenues { | |||||
#page-order #commandes-points-vente .recap-pv .recettes { | |||||
float: right; | float: right; | ||||
color: #BB8757; | color: #BB8757; | ||||
border: solid 1px #BB8757; | border: solid 1px #BB8757; | ||||
top: -3px; | top: -3px; | ||||
} | } | ||||
/* line 650, ../sass/screen.scss */ | /* line 650, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .alert.comment { | |||||
#page-order #commandes-points-vente .alert.comment { | |||||
display: none; | display: none; | ||||
} | } | ||||
/* line 654, ../sass/screen.scss */ | /* line 654, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale ul.liste-orders { | |||||
#page-order #commandes-points-vente ul.liste-commandes { | |||||
margin-top: 10px; | margin-top: 10px; | ||||
list-style-type: none; | list-style-type: none; | ||||
height: 100%; | height: 100%; | ||||
overflow-y: scroll; | overflow-y: scroll; | ||||
} | } | ||||
/* line 665, ../sass/screen.scss */ | /* line 665, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale ul.liste-orders.no-order { | |||||
#page-order #commandes-points-vente ul.liste-commandes.no-commande { | |||||
display: none; | display: none; | ||||
} | } | ||||
/* line 669, ../sass/screen.scss */ | /* line 669, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale ul.liste-orders li { | |||||
#page-order #commandes-points-vente ul.liste-commandes li { | |||||
padding: 0; | padding: 0; | ||||
margin: 0; | margin: 0; | ||||
} | } | ||||
/* line 672, ../sass/screen.scss */ | /* line 672, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale ul.liste-orders li a { | |||||
#page-order #commandes-points-vente ul.liste-commandes li a { | |||||
text-align: left; | text-align: left; | ||||
-moz-border-radius: 0px; | -moz-border-radius: 0px; | ||||
-webkit-border-radius: 0px; | -webkit-border-radius: 0px; | ||||
color: #333; | color: #333; | ||||
} | } | ||||
/* line 679, ../sass/screen.scss */ | /* line 679, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale ul.liste-orders li a .amount { | |||||
#page-order #commandes-points-vente ul.liste-commandes li a .montant { | |||||
float: right; | float: right; | ||||
color: #BB8757; | color: #BB8757; | ||||
font-weight: bold; | font-weight: bold; | ||||
} | } | ||||
/* line 684, ../sass/screen.scss */ | /* line 684, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale ul.liste-orders li a .amount.paid { | |||||
#page-order #commandes-points-vente ul.liste-commandes li a .montant.paye { | |||||
color: #5cb85c; | color: #5cb85c; | ||||
color: #519951; | color: #519951; | ||||
} | } | ||||
/* line 690, ../sass/screen.scss */ | /* line 690, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale ul.liste-orders li a .glyphicon-comment { | |||||
#page-order #commandes-points-vente ul.liste-commandes li a .glyphicon-comment { | |||||
color: #BB8757; | color: #BB8757; | ||||
} | } | ||||
/* line 694, ../sass/screen.scss */ | /* line 694, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale ul.liste-orders li a:hover, #page-order #orders-points-sale ul.liste-orders li a:active, #page-order #orders-points-sale ul.liste-orders li a.active { | |||||
#page-order #commandes-points-vente ul.liste-commandes li a:hover, #page-order #commandes-points-vente ul.liste-commandes li a:active, #page-order #commandes-points-vente ul.liste-commandes li a.active { | |||||
text-decoration: none; | text-decoration: none; | ||||
background-color: #FCF8E3; | background-color: #FCF8E3; | ||||
outline: none; | outline: none; | ||||
transition: all 0.1s; | transition: all 0.1s; | ||||
} | } | ||||
/* line 705, ../sass/screen.scss */ | /* line 705, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .create-order, | |||||
#page-order #orders-points-sale .subscriptions { | |||||
#page-order #commandes-points-vente .creer-commande, | |||||
#page-order #commandes-points-vente .commandes-auto { | |||||
width: 100%; | width: 100%; | ||||
margin-bottom: 10px; | margin-bottom: 10px; | ||||
} | } | ||||
/* line 711, ../sass/screen.scss */ | /* line 711, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .block-order { | |||||
#page-order #commandes-points-vente .bloc-commande { | |||||
padding-top: 20px; | padding-top: 20px; | ||||
margin-top: 20px; | margin-top: 20px; | ||||
display: none; | display: none; | ||||
} | } | ||||
/* line 717, ../sass/screen.scss */ | /* line 717, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .title-user { | |||||
#page-order #commandes-points-vente .title-user { | |||||
display: none; | display: none; | ||||
font-size: 19px; | font-size: 19px; | ||||
margin-top: 0px; | margin-top: 0px; | ||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | ||||
} | } | ||||
/* line 723, ../sass/screen.scss */ | /* line 723, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .title-user .btn-edit, #page-order #orders-points-sale .title-user .btn-remove, | |||||
#page-order #orders-points-sale .title-user .btn-cancel, #page-order #orders-points-sale .title-user .btn-save { | |||||
#page-order #commandes-points-vente .title-user .btn-edit, #page-order #commandes-points-vente .title-user .btn-remove, | |||||
#page-order #commandes-points-vente .title-user .btn-cancel, #page-order #commandes-points-vente .title-user .btn-save { | |||||
float: right; | float: right; | ||||
position: relative; | position: relative; | ||||
top: -6px; | top: -6px; | ||||
} | } | ||||
/* line 730, ../sass/screen.scss */ | /* line 730, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .title-user .btn-edit, #page-order #orders-points-sale .title-user .btn-cancel { | |||||
#page-order #commandes-points-vente .title-user .btn-edit, #page-order #commandes-points-vente .title-user .btn-cancel { | |||||
margin-right: 10px; | margin-right: 10px; | ||||
} | } | ||||
/* line 734, ../sass/screen.scss */ | /* line 734, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .title-user .buttons-save-cancel { | |||||
#page-order #commandes-points-vente .title-user .buttons-save-cancel { | |||||
display: none; | display: none; | ||||
} | } | ||||
/* line 738, ../sass/screen.scss */ | /* line 738, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .title-user .choice-user { | |||||
#page-order #commandes-points-vente .title-user .choix-user { | |||||
display: none; | display: none; | ||||
} | } | ||||
/* line 741, ../sass/screen.scss */ | /* line 741, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .title-user .choice-user .form-control { | |||||
#page-order #commandes-points-vente .title-user .choix-user .form-control { | |||||
width: 200px; | width: 200px; | ||||
display: inline; | display: inline; | ||||
} | } | ||||
/* line 749, ../sass/screen.scss */ | /* line 749, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale table.table-products .td-order { | |||||
#page-order #commandes-points-vente table.table-produits .td-order { | |||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 752, ../sass/screen.scss */ | /* line 752, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale table.table-products input.form-control { | |||||
#page-order #commandes-points-vente table.table-produits input.form-control { | |||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 757, ../sass/screen.scss */ | /* line 757, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale table.table-products tr.disabled .td-product { | |||||
#page-order #commandes-points-vente table.table-produits tr.disabled .td-product { | |||||
color: gray; | color: gray; | ||||
} | } | ||||
/* line 763, ../sass/screen.scss */ | /* line 763, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .td-product, | |||||
#page-order #orders-points-sale .th-product { | |||||
#page-order #commandes-points-vente .td-produit, | |||||
#page-order #commandes-points-vente .th-produit { | |||||
width: 70%; | width: 70%; | ||||
} | } | ||||
/* line 768, ../sass/screen.scss */ | /* line 768, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .td-order, | |||||
#page-order #orders-points-sale .th-order { | |||||
#page-order #commandes-points-vente .td-commande, | |||||
#page-order #commandes-points-vente .th-commande { | |||||
width: 30%; | width: 30%; | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 774, ../sass/screen.scss */ | /* line 774, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .td-product { | |||||
#page-order #commandes-points-vente .td-produit { | |||||
text-transform: uppercase; | text-transform: uppercase; | ||||
} | } | ||||
/* line 778, ../sass/screen.scss */ | /* line 778, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .td-order { | |||||
#page-order #commandes-points-vente .td-commande { | |||||
font-weight: bold; | font-weight: bold; | ||||
} | } | ||||
/* line 782, ../sass/screen.scss */ | /* line 782, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .td-total { | |||||
#page-order #commandes-points-vente .td-total { | |||||
font-size: 18px; | font-size: 18px; | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 786, ../sass/screen.scss */ | /* line 786, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .td-total span { | |||||
#page-order #commandes-points-vente .td-total span { | |||||
padding: 2px 10px; | padding: 2px 10px; | ||||
background-color: #BB8757; | background-color: #BB8757; | ||||
color: white; | color: white; | ||||
border-radius: 8px; | border-radius: 8px; | ||||
} | } | ||||
/* line 796, ../sass/screen.scss */ | /* line 796, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .td-payment .buttons-credit { | |||||
#page-order #commandes-points-vente .td-paiement .buttons-credit { | |||||
float: right; | float: right; | ||||
} | } | ||||
/* line 802, ../sass/screen.scss */ | /* line 802, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .panel-order-auto .field-subscriptionform-id_user, | |||||
#page-order #orders-points-sale .panel-order-auto .field-subscriptionform-id_producer { | |||||
#page-order #commandes-points-vente .panel-commande-auto .field-subscriptionform-id_user, | |||||
#page-order #commandes-points-vente .panel-commande-auto .field-subscriptionform-id_producer { | |||||
display: none; | display: none; | ||||
} | } | ||||
/* line 809, ../sass/screen.scss */ | /* line 809, ../sass/screen.scss */ | ||||
#page-order #orders-points-sale .panel-order-auto .days .form-group { | |||||
#page-order #commandes-points-vente .panel-commande-auto .days .form-group { | |||||
float: left; | float: left; | ||||
margin-right: 10px; | margin-right: 10px; | ||||
} | } | ||||
/* line 818, ../sass/screen.scss */ | /* line 818, ../sass/screen.scss */ | ||||
#page-order #old-orders { | |||||
#page-order #old-commandes { | |||||
display: none; | display: none; | ||||
} | } | ||||
/* line 822, ../sass/screen.scss */ | /* line 822, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale { | |||||
#page-order .form-commandes-point-vente { | |||||
margin-top: 20px; | margin-top: 20px; | ||||
} | } | ||||
/* line 826, ../sass/screen.scss */ | /* line 826, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale table { | |||||
#page-order .form-commandes-point-vente table { | |||||
border-bottom: solid 1px #e0e0e0; | border-bottom: solid 1px #e0e0e0; | ||||
} | } | ||||
/* line 830, ../sass/screen.scss */ | /* line 830, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .title-point-sale { | |||||
#page-order .form-commandes-point-vente .title-point-sale { | |||||
background-color: #fff8e2; | background-color: #fff8e2; | ||||
border-left: solid 3px #BB8757; | border-left: solid 3px #BB8757; | ||||
font-weight: bold; | font-weight: bold; | ||||
padding: 10px; | padding: 10px; | ||||
} | } | ||||
/* line 838, ../sass/screen.scss */ | /* line 838, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .title-totals { | |||||
#page-order .form-commandes-point-vente .title-totals { | |||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 842, ../sass/screen.scss */ | /* line 842, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .border-left { | |||||
#page-order .form-commandes-point-vente .border-left { | |||||
border-left: solid 1px #e0e0e0; | border-left: solid 1px #e0e0e0; | ||||
} | } | ||||
/* line 846, ../sass/screen.scss */ | /* line 846, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .border-right { | |||||
#page-order .form-commandes-point-vente .border-right { | |||||
border-right: solid 1px #e0e0e0; | border-right: solid 1px #e0e0e0; | ||||
} | } | ||||
/* line 850, ../sass/screen.scss */ | /* line 850, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale input.quantity { | |||||
#page-order .form-commandes-point-vente input.quantity { | |||||
width: 30px; | width: 30px; | ||||
background-color: white; | background-color: white; | ||||
border: solid 1px #e0e0e0; | border: solid 1px #e0e0e0; | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 857, ../sass/screen.scss */ | /* line 857, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .td-product { | |||||
#page-order .form-commandes-point-vente .td-product { | |||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 861, ../sass/screen.scss */ | /* line 861, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .submit-point-sale { | |||||
#page-order .form-commandes-point-vente .submit-point-sale { | |||||
float: right; | float: right; | ||||
} | } | ||||
/* line 865, ../sass/screen.scss */ | /* line 865, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .select-user { | |||||
#page-order .form-commandes-point-vente .select-user { | |||||
background-color: #F9F9F9; | background-color: #F9F9F9; | ||||
border: solid 1px #e0e0e0; | border: solid 1px #e0e0e0; | ||||
} | } | ||||
/* line 870, ../sass/screen.scss */ | /* line 870, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .date-order { | |||||
#page-order .form-commandes-point-vente .date-order { | |||||
font-size: 12px; | font-size: 12px; | ||||
} | } | ||||
/* line 874, ../sass/screen.scss */ | /* line 874, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .datepicker, #page-order .form-orders-point-sale .text { | |||||
#page-order .form-commandes-point-vente .datepicker, #page-order .form-commandes-point-vente .text { | |||||
background-color: white; | background-color: white; | ||||
border: solid 1px #e0e0e0; | border: solid 1px #e0e0e0; | ||||
margin-top: 3px; | margin-top: 3px; | ||||
width: 100px; | width: 100px; | ||||
} | } | ||||
/* line 882, ../sass/screen.scss */ | /* line 882, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale td.center { | |||||
#page-order .form-commandes-point-vente td.center { | |||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 886, ../sass/screen.scss */ | /* line 886, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .depasse { | |||||
#page-order .form-commandes-point-vente .depasse { | |||||
color: #b32815; | color: #b32815; | ||||
} | } | ||||
/* line 890, ../sass/screen.scss */ | /* line 890, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale .total strong span { | |||||
#page-order .form-commandes-point-vente .total strong span { | |||||
font-weight: normal; | font-weight: normal; | ||||
font-size: 13px; | font-size: 13px; | ||||
} | } | ||||
/* line 895, ../sass/screen.scss */ | /* line 895, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale td.user { | |||||
#page-order .form-commandes-point-vente td.user { | |||||
text-align: left; | text-align: left; | ||||
padding: 3px; | padding: 3px; | ||||
} | } | ||||
/* line 898, ../sass/screen.scss */ | /* line 898, ../sass/screen.scss */ | ||||
#page-order .form-orders-point-sale td.user .date-order { | |||||
#page-order .form-commandes-point-vente td.user .date-order { | |||||
color: gray; | color: gray; | ||||
} | } | ||||
/* line 905, ../sass/screen.scss */ | /* line 905, ../sass/screen.scss */ |
function chat_index_commandes_points_vente_livraison() { | function chat_index_commandes_points_vente_livraison() { | ||||
$('#productionpointvente-productions_point_vente input[type=checkbox]').change(function() { | |||||
$('#pointsaledistribution-points_sale_distribution input[type=checkbox]').change(function() { | |||||
var nb = $('#productionpointvente-productions_point_vente input[type=checkbox]:checked').size() ; | |||||
var nb = $('#pointsaledistribution-points_sale_distribution input[type=checkbox]:checked').size() ; | |||||
if(nb == 0) { | if(nb == 0) { | ||||
$(this).prop('checked',true) ; | $(this).prop('checked',true) ; | ||||
if($(this).prop('checked')) | if($(this).prop('checked')) | ||||
livraison = 1 ; | livraison = 1 ; | ||||
$.get(UrlManager.getBaseUrl()+'commande/ajax-point-vente-livraison',{ | |||||
id_production: arr_val[0], | |||||
id_point_vente: arr_val[1], | |||||
bool_livraison: livraison | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-point-sale-delivery',{ | |||||
idDistribution: arr_val[0], | |||||
idPointSale: arr_val[1], | |||||
boolDelivery: livraison | |||||
}, function(data) { | }, function(data) { | ||||
chat_alert('success','Point de vente modifié') ; | chat_alert('success','Point de vente modifié') ; | ||||
}) ; | }) ; | ||||
function chat_index_commandes_maj_points_vente() { | function chat_index_commandes_maj_points_vente() { | ||||
if($('#productions-point-vente').size()) { | if($('#productions-point-vente').size()) { | ||||
var nb = $('#productionpointvente-productions_point_vente input[type=checkbox]:checked').size() ; | |||||
var nb = $('#pointsaledistribution-points_sale_distribution input[type=checkbox]:checked').size() ; | |||||
if(nb == 0) | if(nb == 0) | ||||
{ | { | ||||
$('#panel-commandes #tabs-points-vente, #panel-commandes #commandes-points-vente').hide() ; | $('#panel-commandes #tabs-points-vente, #panel-commandes #commandes-points-vente').hide() ; | ||||
var id_production = $('#id-production').val() ; | var id_production = $('#id-production').val() ; | ||||
if(id_production) { | if(id_production) { | ||||
$('#tabs-points-vente li').each(function() { | $('#tabs-points-vente li').each(function() { | ||||
var id_point_vente = $(this).find('a').attr('id').replace('btn-point-vente-','') ; | var id_point_vente = $(this).find('a').attr('id').replace('btn-point-vente-','') ; | ||||
var nb_commandes = parseInt($(this).find('.badge-success').html()) ; | var nb_commandes = parseInt($(this).find('.badge-success').html()) ; | ||||
var checked = $('#productionpointvente-productions_point_vente input[value='+id_production+'-'+id_point_vente+']').prop('checked') ; | |||||
var checked = $('#pointsaledistribution-points_sale_distribution input[value='+id_production+'-'+id_point_vente+']').prop('checked') ; | |||||
if(checked || nb_commandes > 0) | if(checked || nb_commandes > 0) | ||||
{ | { | ||||
$(this).show() ; | $(this).show() ; | ||||
function chat_select_etablissement() { | function chat_select_etablissement() { | ||||
$('select[name="select_etablissement"]').change(function() { | $('select[name="select_etablissement"]').change(function() { | ||||
window.location.href = UrlManager.getBaseUrlAbsolute()+'/site/change-etablissement?id='+$(this).val() ; | |||||
window.location.href = UrlManager.getBaseUrlAbsolute()+'/site/change-producer?id='+$(this).val() ; | |||||
}) ; | }) ; | ||||
} | } | ||||
var id_commande = $(this).data('id-commande') ; | var id_commande = $(this).data('id-commande') ; | ||||
$(this).attr('disabled', 'disabled') ; | $(this).attr('disabled', 'disabled') ; | ||||
$.get(UrlManager.getBaseUrl()+'commande/ajax-delete',{ | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-delete',{ | |||||
date: $('#date-production').val(), | date: $('#date-production').val(), | ||||
id_commande: id_commande | |||||
idOrder: id_commande | |||||
}, function(data) { | }, function(data) { | ||||
$('#point-vente-'+id_pv+' .btn-remove').removeAttr('disabled') ; | $('#point-vente-'+id_pv+' .btn-remove').removeAttr('disabled') ; | ||||
$('#point-vente-'+id_pv+' .creer-commande').trigger('click') ; | $('#point-vente-'+id_pv+' .creer-commande').trigger('click') ; | ||||
} | } | ||||
} | } | ||||
chat_index_commandes_maj_recap_pv(id_pv, data.total_pv) ; | |||||
chat_index_commandes_maj_recap_pv(id_pv, data.total_point_sale) ; | |||||
chat_index_commandes_maj_total_commandes() ; | chat_index_commandes_maj_total_commandes() ; | ||||
chat_alert('success','Commande supprimée') ; | chat_alert('success','Commande supprimée') ; | ||||
}, 'json') ; | }, 'json') ; | ||||
$(this).attr('disabled', 'disabled') ; | $(this).attr('disabled', 'disabled') ; | ||||
$.get(UrlManager.getBaseUrl()+'commande/ajax-create',{ | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-create',{ | |||||
date: $('#date-production').val(), | date: $('#date-production').val(), | ||||
id_pv: id_pv, | |||||
id_user: $('#point-vente-'+id_pv+' .user-id').val(), | |||||
idPointSale: id_pv, | |||||
idUser: $('#point-vente-'+id_pv+' .user-id').val(), | |||||
username: $('#point-vente-'+id_pv+' .username').val(), | username: $('#point-vente-'+id_pv+' .username').val(), | ||||
produits: JSON.stringify(tab_produits), | |||||
commentaire: $('#point-vente-'+id_pv+' .textarea-commentaire').val() | |||||
products: JSON.stringify(tab_produits), | |||||
comment: $('#point-vente-'+id_pv+' .textarea-commentaire').val() | |||||
}, function(data) { | }, function(data) { | ||||
$('#point-vente-'+id_pv+' .btn-save').removeAttr('disabled') ; | $('#point-vente-'+id_pv+' .btn-save').removeAttr('disabled') ; | ||||
$('#point-vente-'+id_pv+' .btn-save').removeClass('is-create') ; | $('#point-vente-'+id_pv+' .btn-save').removeClass('is-create') ; | ||||
$('#point-vente-'+id_pv+' .liste-commandes').append(data.commande) ; | |||||
$('#point-vente-'+id_pv+' .liste-commandes').append(data.order) ; | |||||
chat_index_commandes_points_vente() ; | chat_index_commandes_points_vente() ; | ||||
chat_index_commandes_maj_recap_pv(id_pv, data.total_pv) ; | |||||
chat_index_commandes_maj_recap_pv(id_pv, data.total_point_sale) ; | |||||
$('#point-vente-'+id_pv+' .buttons-edit-remove').show() ; | $('#point-vente-'+id_pv+' .buttons-edit-remove').show() ; | ||||
$('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ; | $('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ; | ||||
var id_commande = $(this).data('id-commande') ; | var id_commande = $(this).data('id-commande') ; | ||||
$(this).attr('disabled', 'disabled') ; | $(this).attr('disabled', 'disabled') ; | ||||
$.get(UrlManager.getBaseUrl()+'commande/ajax-update',{ | |||||
id_commande: id_commande, | |||||
produits: JSON.stringify(tab_produits), | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-update',{ | |||||
idOrder: id_commande, | |||||
products: JSON.stringify(tab_produits), | |||||
date: $('#date-production').val(), | date: $('#date-production').val(), | ||||
commentaire: $('#point-vente-'+id_pv+' .textarea-commentaire').val() | |||||
comment: $('#point-vente-'+id_pv+' .textarea-commentaire').val() | |||||
}, function(data) { | }, function(data) { | ||||
$('#point-vente-'+id_pv+' .btn-save').removeAttr('disabled') ; | $('#point-vente-'+id_pv+' .btn-save').removeAttr('disabled') ; | ||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_commande); | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(data.json_commande.str_montant) ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_order); | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(data.json_order.str_amount) ; | |||||
chat_index_commandes_affiche_commande(id_pv, id_commande) ; | chat_index_commandes_affiche_commande(id_pv, id_commande) ; | ||||
chat_index_commandes_maj_recap_pv(id_pv, data.total_pv) ; | |||||
chat_index_commandes_maj_recap_pv(id_pv, data.total_point_sale) ; | |||||
$('#point-vente-'+id_pv+' .buttons-edit-remove').show() ; | $('#point-vente-'+id_pv+' .buttons-edit-remove').show() ; | ||||
$('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ; | $('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ; | ||||
// create | // create | ||||
$('.creer-commande').unbind('click').click(function() { | $('.creer-commande').unbind('click').click(function() { | ||||
var id_pv = $(this).data('pv-id') ; | var id_pv = $(this).data('pv-id') ; | ||||
$('#point-vente-'+id_pv+' .bloc-commande').fadeIn() ; | $('#point-vente-'+id_pv+' .bloc-commande').fadeIn() ; | ||||
$('#point-vente-'+id_pv+' .liste-commandes a.active').removeClass('active') ; | $('#point-vente-'+id_pv+' .liste-commandes a.active').removeClass('active') ; | ||||
$('#point-vente-'+id_pv+' .choix-user .username').val('') ; | $('#point-vente-'+id_pv+' .choix-user .username').val('') ; | ||||
$('#point-vente-'+id_pv+' .commentaire').hide() ; | $('#point-vente-'+id_pv+' .commentaire').hide() ; | ||||
$('#point-vente-'+id_pv+' .btn-save').addClass('is-create'); | $('#point-vente-'+id_pv+' .btn-save').addClass('is-create'); | ||||
/*if(!$('#point-vente-'+id_pv+' .btn-cancel').data('id-commande') && | |||||
$('#point-vente-'+id_pv+' .liste-commandes li').size()) { | |||||
$('#point-vente-'+id_pv+' .btn-cancel').data('id-commande',$('#point-vente-'+id_pv+' .liste-commandes li:first a').data('id-commande')) ; | |||||
}*/ | |||||
$('#point-vente-'+id_pv+' .btn-save').data('id-commande',0) ; | $('#point-vente-'+id_pv+' .btn-save').data('id-commande',0) ; | ||||
chat_index_commandes_inputs_commande(id_pv, false) ; | chat_index_commandes_inputs_commande(id_pv, false) ; | ||||
} | } | ||||
function chat_index_commandes_maj_total_commandes() { | function chat_index_commandes_maj_total_commandes() { | ||||
$.get(UrlManager.getBaseUrl()+'commande/ajax-total-commandes',{ | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-total-orders',{ | |||||
date: $('#date-production').val() | date: $('#date-production').val() | ||||
}, function(data) { | }, function(data) { | ||||
$('#bloc-totaux').html(data.html_totaux) ; | |||||
$('#bloc-totaux').html(data.html_totals) ; | |||||
}, 'json') ; | }, 'json') ; | ||||
} | } | ||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant .glyphicon').remove() ; | $('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant .glyphicon').remove() ; | ||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html() ; | $('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html() ; | ||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(commande.str_montant) ; | |||||
if(commande.montant_paye >= commande.montant) { | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(commande.str_amount) ; | |||||
if(commande.paid_amount >= commande.amount) { | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').addClass('paye') ; | $('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').addClass('paye') ; | ||||
if(commande.montant_paye > commande.montant) { | |||||
if(commande.paid_amount > commande.amount) { | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').append(' <span class="glyphicon glyphicon-warning-sign"></span>') ; | $('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').append(' <span class="glyphicon glyphicon-warning-sign"></span>') ; | ||||
} | } | ||||
} | } | ||||
// commentaire | // commentaire | ||||
if(commande.commentaire && commande.commentaire.length) { | |||||
if(commande.comment && commande.comment.length) { | |||||
if(!$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .glyphicon-comment').size()) { | if(!$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .glyphicon-comment').size()) { | ||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').append(' <span class="glyphicon glyphicon-comment"></span>') ; | $('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').append(' <span class="glyphicon glyphicon-comment"></span>') ; | ||||
} | } | ||||
console.log(id_pv+' '+commande.commentaire) ; | |||||
$('#point-vente-'+id_pv+' .commentaire').html(chat_nl2br(commande.commentaire)).show() ; | |||||
$('#point-vente-'+id_pv+' .commentaire').html(chat_nl2br(commande.comment)).show() ; | |||||
} | } | ||||
else { | else { | ||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .glyphicon-comment').remove() ; | $('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .glyphicon-comment').remove() ; | ||||
$('#point-vente-'+id_pv+' .td-total').html('') ; | $('#point-vente-'+id_pv+' .td-total').html('') ; | ||||
$('#point-vente-'+id_pv+' tr').removeClass('active') ; | $('#point-vente-'+id_pv+' tr').removeClass('active') ; | ||||
$.each(commande.produits, function(i, item) { | |||||
$.each(commande.products, function(i, item) { | |||||
$('#point-vente-'+id_pv+' .produit-'+i+' .td-commande').html(item) ; | $('#point-vente-'+id_pv+' .produit-'+i+' .td-commande').html(item) ; | ||||
$('#point-vente-'+id_pv+' .produit-'+i).addClass('active') ; | $('#point-vente-'+id_pv+' .produit-'+i).addClass('active') ; | ||||
}) ; | }) ; | ||||
$('#point-vente-'+id_pv+' .td-total').html('<span>'+commande.str_montant+'</span>') ; | |||||
$('#point-vente-'+id_pv+' .td-total').html('<span>'+commande.str_amount+'</span>') ; | |||||
$('#point-vente-'+id_pv+' .tr-total').show() ; | $('#point-vente-'+id_pv+' .tr-total').show() ; | ||||
/*var commentaire = link.data('commentaire') ; | |||||
if(commentaire) { | |||||
$('#point-vente-'+id_pv+' .commentaire').html(commentaire).show() ; | |||||
} | |||||
else { | |||||
$('#point-vente-'+id_pv+' .commentaire').hide() ; | |||||
}*/ | |||||
$('#point-vente-'+id_pv+' .title-user span.the-title').html(link.find('.user').html()+" <small>"+link.data('date')+"</small>") ; | $('#point-vente-'+id_pv+' .title-user span.the-title').html(link.find('.user').html()+" <small>"+link.data('date')+"</small>") ; | ||||
$('#point-vente-'+id_pv+' .bloc-commande').fadeIn() ; | $('#point-vente-'+id_pv+' .bloc-commande').fadeIn() ; | ||||
$('#point-vente-'+id_pv+' .tr-total').show() ; | $('#point-vente-'+id_pv+' .tr-total').show() ; | ||||
// paiement | // paiement | ||||
$.get(UrlManager.getBaseUrl()+'commande/statut-paiement',{ | |||||
id_commande: id_commande | |||||
$.get(UrlManager.getBaseUrl()+'order/payment-status',{ | |||||
idOrder: id_commande | |||||
}, function(data) { | }, function(data) { | ||||
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_statut_paiement) ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_commande) ; | |||||
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_payment_status) ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_order) ; | |||||
chat_index_commandes_boutons_paiement(id_pv, id_commande) ; | chat_index_commandes_boutons_paiement(id_pv, id_commande) ; | ||||
},'json') ; | },'json') ; | ||||
} | } | ||||
function chat_index_commandes_boutons_paiement(id_pv, id_commande) { | function chat_index_commandes_boutons_paiement(id_pv, id_commande) { | ||||
// boutons paiement/remboursement | // boutons paiement/remboursement | ||||
$('#point-vente-'+id_pv+' .payer, #point-vente-'+id_pv+' .rembourser').click(function() { | $('#point-vente-'+id_pv+' .payer, #point-vente-'+id_pv+' .rembourser').click(function() { | ||||
$.get(UrlManager.getBaseUrl()+'commande/paiement',{ | |||||
id_commande: id_commande, | |||||
$.get(UrlManager.getBaseUrl()+'order/payment',{ | |||||
idOrder: id_commande, | |||||
type: $(this).data('type'), | type: $(this).data('type'), | ||||
montant: $(this).data('montant') | |||||
amount: $(this).data('montant') | |||||
}, function(data) { | }, function(data) { | ||||
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_statut_paiement) ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_commande) ; | |||||
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_payment_status) ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_order) ; | |||||
chat_index_commandes_affiche_commande(id_pv, id_commande) ; | chat_index_commandes_affiche_commande(id_pv, id_commande) ; | ||||
chat_index_commandes_boutons_paiement(id_pv, id_commande) ; | chat_index_commandes_boutons_paiement(id_pv, id_commande) ; | ||||
}, 'json') ; | }, 'json') ; | ||||
function chat_calendar() { | function chat_calendar() { | ||||
if($('#page-commande').size()) { | |||||
if($('#page-order').size()) { | |||||
var events = new Array ; | var events = new Array ; | ||||
$('ul#jours-production li').each(function() { | $('ul#jours-production li').each(function() { | ||||
var date = $(this).html() ; | var date = $(this).html() ; |
} | } | ||||
h1 { | h1 { | ||||
.btn-group { | |||||
float: right ; | |||||
} | |||||
.btn-group { | |||||
float: right ; | |||||
} | |||||
} | } | ||||
#col-left, #col-right { | #col-left, #col-right { | ||||
padding-left: 20px ; | padding-left: 20px ; | ||||
} | } | ||||
#distribution-days { | |||||
#jours-production { | |||||
display: none ; | display: none ; | ||||
} | } | ||||
margin-top: 10px ; | margin-top: 10px ; | ||||
} | } | ||||
#block-distribution { | |||||
#bloc-production { | |||||
.label { | .label { | ||||
float: right ; | float: right ; | ||||
border-color: #4cae4c ; | border-color: #4cae4c ; | ||||
} | } | ||||
#distributions-points-sale { | |||||
#productions-point-vente { | |||||
margin-top: 15px ; | margin-top: 15px ; | ||||
padding: 10px ; | padding: 10px ; | ||||
border: solid 1px #e0e0e0 ; | border: solid 1px #e0e0e0 ; | ||||
} | } | ||||
} | } | ||||
#products-distribution { | |||||
#produits-production { | |||||
.overflow { | .overflow { | ||||
float: left; | float: left; | ||||
} | } | ||||
.td-product { | |||||
.td-produit { | |||||
width: 60% ; | width: 60% ; | ||||
} | } | ||||
.td-active, .td-max { | .td-active, .td-max { | ||||
} | } | ||||
} | } | ||||
#btn-export-orders, | |||||
#btn-subscription { | |||||
#btn-export-commandes, | |||||
#btn-commandes-auto { | |||||
float: right ; | float: right ; | ||||
position: relative; | position: relative; | ||||
top: -5px ; | top: -5px ; | ||||
padding: 2px 5px ; | padding: 2px 5px ; | ||||
} | } | ||||
#btn-export-orders, | |||||
#btn-subscription { | |||||
#btn-export-commandes, | |||||
#btn-commandes-auto { | |||||
color: white ; | color: white ; | ||||
margin-left: 10px ; | margin-left: 10px ; | ||||
padding: 1px 5px ; | padding: 1px 5px ; | ||||
} | } | ||||
#btn-subscription { | |||||
#btn-commandes-auto { | |||||
top: -7px ; | top: -7px ; | ||||
.btn { | .btn { | ||||
padding: 2px 5px; | padding: 2px 5px; | ||||
} | } | ||||
} | } | ||||
#block-totals { | |||||
#bloc-totaux { | |||||
.table-products { | .table-products { | ||||
.depasse { | .depasse { | ||||
color: #b32815 ; | color: #b32815 ; | ||||
} | } | ||||
} | } | ||||
#orders-points-sale { | |||||
#commandes-points-vente { | |||||
.tab-pane { | .tab-pane { | ||||
padding-top: 20px ; | padding-top: 20px ; | ||||
} | } | ||||
.recap-point-sale { | |||||
.recap-pv { | |||||
&.no-order { | |||||
.revenues { | |||||
&.no-commande { | |||||
.recettes { | |||||
display: none; | display: none; | ||||
} | } | ||||
} | } | ||||
.revenues { | |||||
.recettes { | |||||
float: right ; | float: right ; | ||||
color: $color1 ; | color: $color1 ; | ||||
border: solid 1px $color1 ; | border: solid 1px $color1 ; | ||||
display: none ; | display: none ; | ||||
} | } | ||||
ul.liste-orders { | |||||
ul.liste-commandes { | |||||
margin-top: 10px ; | margin-top: 10px ; | ||||
list-style-type: none ; | list-style-type: none ; | ||||
height: 100% ; | height: 100% ; | ||||
width: 100% ; | width: 100% ; | ||||
overflow-y: scroll ; | overflow-y: scroll ; | ||||
&.no-order { | |||||
&.no-commande { | |||||
display: none ; | display: none ; | ||||
} | } | ||||
padding: 7px ; | padding: 7px ; | ||||
color: #333 ; | color: #333 ; | ||||
.amount { | |||||
.montant { | |||||
float: right ; | float: right ; | ||||
color: $color1 ; | color: $color1 ; | ||||
font-weight: bold ; | font-weight: bold ; | ||||
&.paid { | |||||
&.paye { | |||||
color: #5cb85c ; | color: #5cb85c ; | ||||
color: #519951 ; | color: #519951 ; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
.create-order, | |||||
.subscriptions { | |||||
.creer-commande, | |||||
.commandes-auto { | |||||
width: 100% ; | width: 100% ; | ||||
margin-bottom: 10px ; | margin-bottom: 10px ; | ||||
} | } | ||||
.block-order { | |||||
.bloc-commande { | |||||
padding-top: 20px ; | padding-top: 20px ; | ||||
margin-top: 20px ; | margin-top: 20px ; | ||||
display: none ; | display: none ; | ||||
display: none ; | display: none ; | ||||
} | } | ||||
.choice-user { | |||||
.choix-user { | |||||
display: none ; | display: none ; | ||||
.form-control { | .form-control { | ||||
} | } | ||||
} | } | ||||
table.table-products { | |||||
table.table-produits { | |||||
.td-order { | .td-order { | ||||
text-align: center ; | text-align: center ; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
.td-product, | |||||
.th-product { | |||||
.td-produit, | |||||
.th-produit { | |||||
width: 70% ; | width: 70% ; | ||||
} | } | ||||
.td-order, | |||||
.th-order { | |||||
.td-commande, | |||||
.th-commande { | |||||
width: 30% ; | width: 30% ; | ||||
text-align: center ; | text-align: center ; | ||||
} | } | ||||
.td-product { | |||||
.td-produit { | |||||
text-transform: uppercase ; | text-transform: uppercase ; | ||||
} | } | ||||
.td-order { | |||||
.td-commande { | |||||
font-weight: bold ; | font-weight: bold ; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
.td-payment { | |||||
.td-paiement { | |||||
.buttons-credit { | .buttons-credit { | ||||
float: right ; | float: right ; | ||||
} | } | ||||
} | } | ||||
.panel-order-auto { | |||||
.panel-commande-auto { | |||||
.field-subscriptionform-id_user, | .field-subscriptionform-id_user, | ||||
.field-subscriptionform-id_producer | .field-subscriptionform-id_producer | ||||
{ | { | ||||
} | } | ||||
#old-orders { | |||||
#old-commandes { | |||||
display: none ; | display: none ; | ||||
} | } | ||||
.form-orders-point-sale { | |||||
.form-commandes-point-vente { | |||||
margin-top: 20px ; | margin-top: 20px ; | ||||
} | } | ||||
} | } | ||||
// Params | |||||
if(isset($options['params']) && is_array($options['params']) && count($options['params'])) { | |||||
$records = $records->params($options['params']) ; | |||||
} | |||||
// Paramètres | // Paramètres | ||||
if(is_array($params) && count($params)) { | if(is_array($params) && count($params)) { | ||||
foreach($params as $key => $val) { | foreach($params as $key => $val) { | ||||
if($record) { | if($record) { | ||||
return $record ; | return $record ; | ||||
} | } | ||||
else { | |||||
throw new NotFoundHttpException( | |||||
'Le modèle '.$class.' #'.((int) $params[$pk]).' n\'a pas été trouvé.'); | |||||
} | |||||
} | } | ||||
elseif($options['type_search'] == self::SEARCH_COUNT) { | elseif($options['type_search'] == self::SEARCH_COUNT) { | ||||
return $records->count() ; | return $records->count() ; | ||||
} | } | ||||
return false ; | |||||
} | } | ||||
/** | /** |
parent::save($runValidation, $attributeNames); | parent::save($runValidation, $attributeNames); | ||||
// mise à jour du crédit au niveau de UserEtablissement | |||||
// mise à jour du crédit au niveau de UserProducer | |||||
$userProducer = UserProducer::searchOne([ | $userProducer = UserProducer::searchOne([ | ||||
'id_user' => $this->id_user, | 'id_user' => $this->id_user, | ||||
'id_producer' => $this->id_producer | 'id_producer' => $this->id_producer |
{ | { | ||||
$distribution = null ; | $distribution = null ; | ||||
if ($date != '') { | if ($date != '') { | ||||
$distribution = Distribution::searchOne(['date' => $date]) ; | |||||
$distribution = Distribution::find() | |||||
->where(['date' => $date]) | |||||
->one() ; | |||||
if (!$distribution) { | if (!$distribution) { | ||||
$distribution = new Distribution; | $distribution = new Distribution; | ||||
$distribution->date = $date; | $distribution->date = $date; | ||||
$productDistribution->id_distribution = $distribution->id; | $productDistribution->id_distribution = $distribution->id; | ||||
$productDistribution->id_product = $product->id; | $productDistribution->id_product = $product->id; | ||||
$productDistribution->actif = 0; | |||||
if ($product->actif && $dayDistribution == 1 && $product->monday) { | |||||
$productDistribution->active = 0; | |||||
if ($product->active && $dayDistribution == 1 && $product->monday) { | |||||
$productDistribution->active = 1; | $productDistribution->active = 1; | ||||
} | } | ||||
if ($product->actif && $dayDistribution == 2 && $product->tuesday) { | |||||
if ($product->active && $dayDistribution == 2 && $product->tuesday) { | |||||
$productDistribution->active = 1; | $productDistribution->active = 1; | ||||
} | } | ||||
if ($product->actif && $dayDistribution == 3 && $product->wednesday) { | |||||
if ($product->active && $dayDistribution == 3 && $product->wednesday) { | |||||
$productDistribution->active = 1; | $productDistribution->active = 1; | ||||
} | } | ||||
if ($product->actif && $dayDistribution == 4 && $product->thursday) { | |||||
if ($product->active && $dayDistribution == 4 && $product->thursday) { | |||||
$productDistribution->active = 1; | $productDistribution->active = 1; | ||||
} | } | ||||
if ($product->actif && $dayDistribution == 5 && $product->friday) { | |||||
if ($product->active && $dayDistribution == 5 && $product->friday) { | |||||
$productDistribution->active = 1; | $productDistribution->active = 1; | ||||
} | } | ||||
if ($product->actif && $dayDistribution == 6 && $product->saterday) { | |||||
if ($product->active && $dayDistribution == 6 && $product->saterday) { | |||||
$productDistribution->active = 1; | $productDistribution->active = 1; | ||||
} | } | ||||
if ($product->actif && $dayDistribution == 7 && $product->sunday) { | |||||
if ($product->active && $dayDistribution == 7 && $product->sunday) { | |||||
$productDistribution->active = 1; | $productDistribution->active = 1; | ||||
} | } | ||||
const STATE_OPEN = 'open'; | const STATE_OPEN = 'open'; | ||||
const STATE_PREPARATION = 'preparation'; | const STATE_PREPARATION = 'preparation'; | ||||
const STATE_DELIVERED = 'livree'; | |||||
const STATE_DELIVERED = 'delivered'; | |||||
/** | /** | ||||
* @inheritdoc | * @inheritdoc | ||||
'products' => [], | 'products' => [], | ||||
'amount' => $order->amount, | 'amount' => $order->amount, | ||||
'str_amount' => $order->getAmount(self::AMOUNT_TOTAL, true), | 'str_amount' => $order->getAmount(self::AMOUNT_TOTAL, true), | ||||
'paid_amount' => $order->getPaidAmount(self::AMOUNT_PAID), | |||||
'paid_amount' => $order->getAmount(self::AMOUNT_PAID), | |||||
'comment' => $order->comment, | 'comment' => $order->comment, | ||||
]; | ]; | ||||
} | } | ||||
/** | /** | ||||
* Enregistre un modèle de type CreditHistorique. | |||||
* Enregistre un modèle de type CreditHistory. | |||||
* | * | ||||
* @param string $type | * @param string $type | ||||
* @param float $montant | * @param float $montant | ||||
* @param integer $id_producer | |||||
* @param integer $id_user | |||||
* @param integer $id_user_action | |||||
* @param integer $idProducer | |||||
* @param integer $idUser | |||||
* @param integer $idUserAction | |||||
*/ | */ | ||||
public function saveCreditHistory($type, $amount, $idProducer, $idUser, $idUserAction) | public function saveCreditHistory($type, $amount, $idProducer, $idUser, $idUserAction) | ||||
{ | { | ||||
$classLabel = ''; | $classLabel = ''; | ||||
$str = ''; | $str = ''; | ||||
if ($this->type == self::ORIGIN_USER) { | |||||
if ($this->origin == self::ORIGIN_USER) { | |||||
$classLabel = 'success'; | $classLabel = 'success'; | ||||
$str = 'Client'; | $str = 'Client'; | ||||
} | } | ||||
elseif ($this->type == self::ORIGIN_AUTO) { | |||||
elseif ($this->origin == self::ORIGIN_AUTO) { | |||||
$classLabel = 'default'; | $classLabel = 'default'; | ||||
$str = 'Auto'; | $str = 'Auto'; | ||||
} | } | ||||
elseif ($this->type == self::ORIGIN_ADMIN) { | |||||
elseif ($this->origin == self::ORIGIN_ADMIN) { | |||||
$classLabel = 'warning'; | $classLabel = 'warning'; | ||||
$str = 'Vous'; | $str = 'Vous'; | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
$order = $orders ; | $order = $orders ; | ||||
return $order->init() ; | |||||
if(is_a($order, 'common\models\Order')) { | |||||
return $order->init() ; | |||||
} | |||||
// count | |||||
else { | |||||
return $order ; | |||||
} | |||||
} | } | ||||
return false ; | return false ; |
/** | /** | ||||
* Initialise les commandes liées au point de vente. | * Initialise les commandes liées au point de vente. | ||||
* | * | ||||
* @param array $commandes | |||||
* @param array $ordersArray | |||||
*/ | */ | ||||
public function initOrders($orders) | |||||
public function initOrders($ordersArray) | |||||
{ | { | ||||
$this->orders = []; | $this->orders = []; | ||||
$this->revenues = 0; | $this->revenues = 0; | ||||
foreach ($orders as $o) { | |||||
if ($this->id == $c->id_point_sale) { | |||||
$this->orders[] = $o; | |||||
if($ordersArray) { | |||||
foreach ($ordersArray as $order) { | |||||
if ($this->id == $order->id_point_sale) { | |||||
$this->orders[] = $order; | |||||
if(is_null($o->date_delete)) { | |||||
$this->revenues += (float) $o->amount; | |||||
if(is_null($order->date_delete)) { | |||||
$this->revenues += (float) $order->amount; | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |
*/ | */ | ||||
public static function setAll($idDistribution, $boolDelivery) | public static function setAll($idDistribution, $boolDelivery) | ||||
{ | { | ||||
$countPointSaleDistribution = Distribution::searchCount([ | |||||
$countPointSaleDistribution = self::searchCount([ | |||||
'id_distribution' => $idDistribution | 'id_distribution' => $idDistribution | ||||
]) ; | ]) ; | ||||
} | } | ||||
} | } | ||||
$distribution = Distribution::findOne($idProduction); | |||||
$distribution = Distribution::findOne($idDistribution); | |||||
if ($distribution) { | if ($distribution) { | ||||
$day = date('N', strtotime($distribution->date)); | $day = date('N', strtotime($distribution->date)); |
'with' => [], | 'with' => [], | ||||
'join_with' => [], | 'join_with' => [], | ||||
'orderby' => 'order ASC', | 'orderby' => 'order ASC', | ||||
'attribute_id_producer' => 'order.id_producer' | |||||
'attribute_id_producer' => 'product.id_producer' | |||||
] ; | ] ; | ||||
} | } | ||||
* @property integer $id | * @property integer $id | ||||
* @property integer $id_distribution | * @property integer $id_distribution | ||||
* @property integer $id_product | * @property integer $id_product | ||||
* @property integer $actif | |||||
* @property integer $active | |||||
*/ | */ | ||||
class ProductDistribution extends ActiveRecordCommon | class ProductDistribution extends ActiveRecordCommon | ||||
{ | { |
*/ | */ | ||||
public function add($date) | public function add($date) | ||||
{ | { | ||||
// production | |||||
$production = Production::searchOne([ | |||||
'production.date' => date('Y-m-d', strtotime($date)) | |||||
// distribution | |||||
$distribution = Distribution::searchOne([ | |||||
'distribution.date' => date('Y-m-d', strtotime($date)) | |||||
]) ; | ]) ; | ||||
if ($production && count($this->productSubscription)) { | |||||
if ($distribution && count($this->productSubscription)) { | |||||
// commande | // commande | ||||
$order = new Order; | $order = new Order; | ||||
if (strlen($this->username)) { | if (strlen($this->username)) { | ||||
$order->date = date('Y-m-d H:i:s'); | $order->date = date('Y-m-d H:i:s'); | ||||
$order->origin = Order::ORIGIN_AUTO; | $order->origin = Order::ORIGIN_AUTO; | ||||
$order->id_point_sale = $this->id_point_sale; | $order->id_point_sale = $this->id_point_sale; | ||||
$order->id_production = $production->id; | |||||
$order->id_distribution = $distribution->id; | |||||
$order->auto_payment = $this->auto_payment ; | $order->auto_payment = $this->auto_payment ; | ||||
$userPointSale = UserPointSale::searchOne([ | $userPointSale = UserPointSale::searchOne([ | ||||
$productsAdd = true; | $productsAdd = true; | ||||
} | } | ||||
if (!$products_add) { | |||||
if (!$productsAdd) { | |||||
$order->delete(); | $order->delete(); | ||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
public static function addAll($date, $force = false) | public static function addAll($date, $force = false) | ||||
{ | { | ||||
$production = Production::searchOne([ | |||||
$distribution = Distribution::searchOne([ | |||||
'date' => date('Y-m-d', strtotime($date)) | 'date' => date('Y-m-d', strtotime($date)) | ||||
]) ; | ]) ; | ||||
if ($production) { | |||||
if ($distribution) { | |||||
$countOrdersProd = Order::searchCount([ | $countOrdersProd = Order::searchCount([ | ||||
Order::tableName().'.id_production' => $production->id | |||||
Order::tableName().'.id_distribution' => $distribution->id | |||||
]) ; | ]) ; | ||||
if (!$countOrdersProd || $force) { | if (!$countOrdersProd || $force) { | ||||
{ | { | ||||
// périodicite | // périodicite | ||||
$nbDays = (strtotime($date) - strtotime($s->date_begin)) / (24 * 60 * 60); | $nbDays = (strtotime($date) - strtotime($s->date_begin)) / (24 * 60 * 60); | ||||
if ($nbDays % ($c->week_frequency * 7) < 7) { | |||||
if ($nbDays % ($s->week_frequency * 7) < 7) { | |||||
// jour de la semaine | // jour de la semaine | ||||
$day = date('N', strtotime($date)); | $day = date('N', strtotime($date)); | ||||
switch ($day) { | switch ($day) { |
public static function defaultOptionsSearch() { | public static function defaultOptionsSearch() { | ||||
return [ | return [ | ||||
'with' => [], | 'with' => [], | ||||
'join_with' => ['userEtablissement'], | |||||
'join_with' => ['userProducer'], | |||||
'orderby' => 'user.name ASC, user.lastname ASC', | 'orderby' => 'user.name ASC, user.lastname ASC', | ||||
'attribute_id_producer' => '' | 'attribute_id_producer' => '' | ||||
] ; | ] ; |
<?php | |||||
use yii\db\Migration; | |||||
class m181224_161347_change_column_order_type extends Migration { | |||||
public function up() { | |||||
$this->renameColumn('order', 'type', 'origin'); | |||||
} | |||||
public function down() { | |||||
$this->renameColumn('order', 'origin', 'type'); | |||||
} | |||||
} |
<?php | |||||
use yii\db\Migration; | |||||
class m181226_100720_rename_column_subscription_date_begin extends Migration | |||||
{ | |||||
public function up() | |||||
{ | |||||
$this->renameColumn('subscription', 'date_debin', 'date_begin'); | |||||
} | |||||
public function down() | |||||
{ | |||||
$this->renameColumn('subscription', 'date_begin', 'date_debin') ; | |||||
} | |||||
} |