|
|
@@ -1,321 +0,0 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
/** |
|
|
|
Copyright distrib (2018) |
|
|
|
|
|
|
|
contact@opendistrib.net |
|
|
|
|
|
|
|
Ce logiciel est un programme informatique servant à aider les producteurs |
|
|
|
à distribuer leur production en circuits courts. |
|
|
|
|
|
|
|
Ce logiciel est régi par la licence CeCILL soumise au droit français et |
|
|
|
respectant les principes de diffusion des logiciels libres. Vous pouvez |
|
|
|
utiliser, modifier et/ou redistribuer ce programme sous les conditions |
|
|
|
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA |
|
|
|
sur le site "http://www.cecill.info". |
|
|
|
|
|
|
|
En contrepartie de l'accessibilité au code source et des droits de copie, |
|
|
|
de modification et de redistribution accordés par cette licence, il n'est |
|
|
|
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, |
|
|
|
seule une responsabilité restreinte pèse sur l'auteur du programme, le |
|
|
|
titulaire des droits patrimoniaux et les concédants successifs. |
|
|
|
|
|
|
|
A cet égard l'attention de l'utilisateur est attirée sur les risques |
|
|
|
associés au chargement, à l'utilisation, à la modification et/ou au |
|
|
|
développement et à la reproduction du logiciel par l'utilisateur étant |
|
|
|
donné sa spécificité de logiciel libre, qui peut le rendre complexe à |
|
|
|
manipuler et qui le réserve donc à des développeurs et des professionnels |
|
|
|
avertis possédant des connaissances informatiques approfondies. Les |
|
|
|
utilisateurs sont donc invités à charger et tester l'adéquation du |
|
|
|
logiciel à leurs besoins dans des conditions permettant d'assurer la |
|
|
|
sécurité de leurs systèmes et ou de leurs données et, plus généralement, |
|
|
|
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. |
|
|
|
|
|
|
|
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez |
|
|
|
pris connaissance de la licence CeCILL, et que vous en avez accepté les |
|
|
|
termes. |
|
|
|
*/ |
|
|
|
|
|
|
|
use yii\helpers\Html; |
|
|
|
use common\models\Order; |
|
|
|
use common\models\User ; |
|
|
|
use yii\helpers\ArrayHelper ; |
|
|
|
use yii\widgets\ActiveForm; |
|
|
|
|
|
|
|
$this->title = 'Commande'; |
|
|
|
|
|
|
|
?> |
|
|
|
|
|
|
|
<div id="page-order"> |
|
|
|
|
|
|
|
<div class="col-md-3" id="col-left"> |
|
|
|
<div class="panel panel-default"> |
|
|
|
<div class="panel-heading"> |
|
|
|
<h3 class="panel-title">Calendrier</h3> |
|
|
|
</div> |
|
|
|
<div class="panel-body"> |
|
|
|
<?php |
|
|
|
// chargement assets |
|
|
|
common\components\fullcalendar\FullcalendarWidget::widget(); |
|
|
|
// --> lancement du js en manuel (via lechatdesnoisettes.js) |
|
|
|
?> |
|
|
|
<div id="calendar"></div> |
|
|
|
|
|
|
|
<?php if (!$date): ?> |
|
|
|
<br /> |
|
|
|
<div class="alert alert-info"> |
|
|
|
<span class="glyphicon glyphicon-share-alt"></span> Choisissez une date pour initier ou |
|
|
|
éditer un jour de production. |
|
|
|
</div> |
|
|
|
<?php else: ?> |
|
|
|
<a class="btn btn-sm btn-default btn-active-week" href="<?= Yii::$app->urlManager->createUrl(['order/change-state-week', 'date' => $date, 'active' => !$oneDistributionWeekActive, ]); ?>"><span class="glyphicon glyphicon-<?= $oneDistributionWeekActive ? 'remove' : 'ok' ?>"></span> <?= $oneDistributionWeekActive ? 'Désactiver' : 'Activer' ?> cette semaine de production</a> |
|
|
|
<?php endif; ?> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<?php if ($date != ''): ?> |
|
|
|
<div id="bloc-production"> |
|
|
|
<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-heading"> |
|
|
|
<h3 class="panel-title">Distribution du <strong><?php echo date('d/m/Y', strtotime($date)); ?></strong></h3> |
|
|
|
</div> |
|
|
|
<div class="panel-body"> |
|
|
|
<strong>Distribution</strong><br /> |
|
|
|
<div class="btn-group" role="group"> |
|
|
|
<a class="btn btn-default<?php if ($distribution->active): ?> btn-success<?php endif; ?>" href="<?php echo Yii::$app->urlManager->createUrl(['order/change-state', 'date' => $date, 'active' => 1]); ?>">Activé</a> |
|
|
|
<a class="btn btn-default<?php if (!$distribution->active): ?> btn-danger<?php endif; ?>" href="<?php echo Yii::$app->urlManager->createUrl(['order/change-state', 'date' => $date, 'active' => 0]); ?>">Désactivé</a> |
|
|
|
</div> |
|
|
|
<br /> |
|
|
|
<br /> |
|
|
|
|
|
|
|
<?php if (!$distribution->active): ?> |
|
|
|
<div class="alert alert-info"> |
|
|
|
<span class="glyphicon glyphicon-share-alt"></span> Activez ici la distribution pour qu'elle soit visible au client. |
|
|
|
</div> |
|
|
|
<?php endif; ?> |
|
|
|
|
|
|
|
<?php if($distribution->delivery && count($arrayPointsSaleDistribution)): ?> |
|
|
|
<div id="productions-point-vente"> |
|
|
|
<strong>Points de vente : </strong> |
|
|
|
<div class="checkbox-list"> |
|
|
|
<?= Html::activeCheckboxList( |
|
|
|
$pointSaleDistribution, |
|
|
|
'points_sale_distribution', |
|
|
|
$arrayPointsSaleDistribution , |
|
|
|
['encode' => false, 'class' => '']) ?> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<?php endif; ?> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<?php endif; ?> |
|
|
|
|
|
|
|
<?php if ($distribution): ?> |
|
|
|
<div id="bloc-produits"> |
|
|
|
<div class="panel panel-default"> |
|
|
|
<div class="panel-heading"> |
|
|
|
<h3 class="panel-title">Produits</h3> |
|
|
|
</div> |
|
|
|
<div class="panel-body"> |
|
|
|
<!-- produits sélectionnés --> |
|
|
|
<form id="produits-production" action="<?php echo Yii::$app->urlManager->createUrl(['order/index', 'date' => $date]); ?>" method="post"> |
|
|
|
<div class="overflow"> |
|
|
|
<table class="table table-condensed"> |
|
|
|
<thead> |
|
|
|
<tr> |
|
|
|
<th class="td-active">Actif</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> |
|
|
|
</tr> |
|
|
|
</thead> |
|
|
|
<tbody> |
|
|
|
<?php foreach ($arrayProducts as $p): ?> |
|
|
|
<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> |
|
|
|
<?php endforeach; ?> |
|
|
|
</tbody> |
|
|
|
</table> |
|
|
|
</div> |
|
|
|
<input type="submit" name="valider_produit_selec" class="btn btn-default" value="Valider" /> |
|
|
|
</form> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<?php endif; ?> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div class="col-md-9" id="col-right"> |
|
|
|
<input type="hidden" value="<?php echo $date; ?>" id="current-date" /> |
|
|
|
<ul id="jours-production"> |
|
|
|
<?php foreach ($arrayDistributionDays as $distributionDay) : ?> |
|
|
|
<li><?php echo $distributionDay->date; ?></li> |
|
|
|
<?php endforeach; ?> |
|
|
|
</ul> |
|
|
|
<?php if ($date != ''): ?> |
|
|
|
|
|
|
|
<div id="bloc-totaux"> |
|
|
|
<?= $this->render('_total_orders.php',[ |
|
|
|
'arrayProducts' => $arrayProducts, |
|
|
|
'arrayOrders' => $arrayOrders, |
|
|
|
'arrayProductsSelected' => $selectedProducts, |
|
|
|
'revenues' => $revenues, |
|
|
|
'weight' => $weight, |
|
|
|
'potentialTurnover' => $potentialTurnover, |
|
|
|
'totalWeight' => $totalWeight, |
|
|
|
]); ?> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<?php |
|
|
|
$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]; |
|
|
|
?> |
|
|
|
|
|
|
|
<div class="panel panel-default" id="panel-commandes"> |
|
|
|
<div class="panel-heading"> |
|
|
|
<h3 class="panel-title"> |
|
|
|
Commandes |
|
|
|
<?php if (!count($arrayOrders)): ?><span class="label label-danger">0</span> |
|
|
|
<?php else: ?><span class="label label-success"><?= count($arrayOrders) ?></span> |
|
|
|
<?php endif; ?> |
|
|
|
|
|
|
|
<?php if (count($arrayOrders)): ?> |
|
|
|
<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; ?> |
|
|
|
|
|
|
|
<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"> |
|
|
|
<span class="glyphicon glyphicon-repeat"></span> Abonnements <span class="caret"></span> |
|
|
|
</button> |
|
|
|
<ul class="dropdown-menu"> |
|
|
|
<li><a href="<?= Yii::$app->urlManager->createUrl(['order/add-subscriptions', 'date' => $date]); ?>">Importer toutes les commandes</a></li> |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
|
|
|
|
</h3> |
|
|
|
</div> |
|
|
|
<div class="panel-body"> |
|
|
|
|
|
|
|
<div class="col-md-12"> |
|
|
|
|
|
|
|
<div class="alert alert-danger" style="display:none;">Aucun point de vente activé</div> |
|
|
|
|
|
|
|
<!-- Nav tabs --> |
|
|
|
<ul id="tabs-points-vente" class="nav nav-tabs" role="tablist"> |
|
|
|
<?php foreach($arrayPointsSale as $pointSale): ?> |
|
|
|
<li role="presentation" class="<?php if($pointSale->point_production): ?>active<?php endif; ?>"> |
|
|
|
<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> |
|
|
|
<?php endforeach; ?> |
|
|
|
</ul> |
|
|
|
|
|
|
|
<!-- Tab panes --> |
|
|
|
<div class="tab-content" id="commandes-points-vente"> |
|
|
|
<?php foreach($arrayPointsSale as $pointSale): ?> |
|
|
|
<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="alert alert-warning recap-pv <?php if(!count($pointSale->orders)): ?>no-order<?php endif; ?>"> |
|
|
|
<?php if(count($pointSale->orders)): ?> |
|
|
|
<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: ?> |
|
|
|
<strong class="commandes">Aucune commande</strong> |
|
|
|
<span class="recettes"></span> |
|
|
|
<?php endif; ?> |
|
|
|
</div> |
|
|
|
|
|
|
|
<ul class="liste-commandes btn-group-vertical<?php if(!count($pointSale->orders)): ?> no-order<?php endif; ?>"> |
|
|
|
<?php foreach($pointSale->orders as $order): ?> |
|
|
|
<li> |
|
|
|
<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)); ?> € |
|
|
|
<?php if($order->paid_amount - $order->amount > 0.01): ?><span class="glyphicon glyphicon-warning-sign"></span><?php endif; ?> |
|
|
|
</span> |
|
|
|
<span class="user"> |
|
|
|
<?php if($order->origin): ?> |
|
|
|
<?php if($order->origin == Order::ORIGIN_ADMIN): ?> |
|
|
|
<span class="label label-warning">vous</span> |
|
|
|
<?php elseif($order->origin == Order::ORIGIN_AUTO): ?> |
|
|
|
<span class="label label-default">auto</span> |
|
|
|
<?php elseif($order->origin == Order::ORIGIN_USER): ?> |
|
|
|
<span class="label label-success">client</span> |
|
|
|
<?php endif; ?> |
|
|
|
<?php endif; ?> |
|
|
|
<?php if(isset($order->user)): ?> |
|
|
|
<?= Html::encode($order->user->lastname.' '.$order->user->name); ?> |
|
|
|
<?php else: ?> |
|
|
|
<?= Html::encode($order->username); ?> |
|
|
|
<?php endif; ?> |
|
|
|
|
|
|
|
<?php if(!is_null($order->date_delete)): ?> |
|
|
|
(<span class="glyphicon glyphicon-remove"></span> Annulée) |
|
|
|
<?php endif; ?> |
|
|
|
|
|
|
|
</span> |
|
|
|
<?php if (strlen($order->comment)): ?> |
|
|
|
<span class="glyphicon glyphicon-comment"></span> |
|
|
|
<?php endif; ?> |
|
|
|
</a> |
|
|
|
</li> |
|
|
|
<?php endforeach; ?> |
|
|
|
</ul> |
|
|
|
<?= 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 class="col-md-12 bloc-commande"> |
|
|
|
<h2 class="title-user"> |
|
|
|
<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-pencil"></span> Modifier', 'javascript:void(0);', ['class' => 'btn btn-default btn-edit']) ?> |
|
|
|
</span> |
|
|
|
<span class="buttons-save-cancel"> |
|
|
|
<?= Html::a('<span class="glyphicon glyphicon-ok"></span> Sauvegarder', 'javascript:void(0);', ['class' => 'btn btn-primary btn-save']) ?> |
|
|
|
<?= Html::a('<span class="glyphicon glyphicon-remove"></span> Annuler', 'javascript:void(0);', ['class' => 'btn btn-default btn-cancel']) ?> |
|
|
|
</span> |
|
|
|
<span class="the-title"></span> |
|
|
|
<span class="choix-user"> |
|
|
|
<?= Html::activeDropDownList(new User, 'id', ArrayHelper::map(User::find()->joinWith('userProducer')->where('user_producer.id_producer = '.Producer::getId())->andWhere('user_producer.active = 1')->orderBy('user.lastname ASC, user.name ASC')->all(), 'id', function($model, $defaultValue) { |
|
|
|
return $model['lastname'].' '.$model['name']; |
|
|
|
}), ['prompt' => '--','class' => 'form-control user-id']) ?> |
|
|
|
OU <input type="text" class="form-control username" placeholder="Choisissez un nom" /> |
|
|
|
</span> |
|
|
|
</h2> |
|
|
|
<div class="commentaire alert alert-info"> |
|
|
|
</div> |
|
|
|
<textarea name="comment" class="form-control textarea-commentaire" placeholder="Commentaire"></textarea> |
|
|
|
<table class="table table-bordered table-condensed tab-content table-produits"> |
|
|
|
<tbody> |
|
|
|
<?php foreach ($arrayProducts as $p): ?> |
|
|
|
<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> |
|
|
|
<?php endforeach; ?> |
|
|
|
<tr class="tr-total"> |
|
|
|
<td class="td-total"></td> |
|
|
|
<td class="td-paiement"></td> |
|
|
|
</tr> |
|
|
|
</tbody> |
|
|
|
</table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<?php endforeach; ?> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<?php endif; ?> |
|
|
|
</div> |
|
|
|
</div> |