use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper ; | use yii\helpers\ArrayHelper ; | ||||
use common\models\User ; | use common\models\User ; | ||||
use common\models\PointVente ; | |||||
use common\models\PointSale ; | |||||
?> | ?> | ||||
<div class="commandeauto-form"> | |||||
<div class="subscription-form"> | |||||
<?php $form = ActiveForm::begin(['enableClientValidation' => false]); ?> | <?php $form = ActiveForm::begin(['enableClientValidation' => false]); ?> | ||||
<div class="col-md-5" id="bloc-select-user"> | <div class="col-md-5" id="bloc-select-user"> | ||||
<?= $form->field($model, 'id_user')->dropDownList( ArrayHelper::map(User::find()->joinWith('userEtablissement')->where('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement)->andWhere('user_etablissement.actif = 1')->orderBy('nom ASC, prenom ASC')->all(), 'id', function($model, $defaultValue) { | |||||
return $model['nom'].' '.$model['prenom']; | |||||
<?= $form->field($model, 'id_user')->dropDownList( ArrayHelper::map(User::find()->joinWith('userProducer')->where('user_producer.id_producer = '.Producer::getId())->andWhere('user_producer.active = 1')->orderBy('lastname ASC, name ASC')->all(), 'id', function($model, $defaultValue) { | |||||
return $model['lastname'].' '.$model['name']; | |||||
}), ['prompt' => '--','class' => 'form-control user-id', ]) ?> | }), ['prompt' => '--','class' => 'form-control user-id', ]) ?> | ||||
</div> | </div> | ||||
<div class="col-md-1" id="or-user"> | <div class="col-md-1" id="or-user"> | ||||
</div> | </div> | ||||
<div class="clr"></div> | <div class="clr"></div> | ||||
<?= $form->field($model, 'id_etablissement')->hiddenInput() ?> | |||||
<?= $form->field($model, 'id_point_vente')->dropDownList( ArrayHelper::map(PointVente::find()->where('id_etablissement = '.Yii::$app->user->identity->id_etablissement)->all(), 'id', function($model, $defaultValue) { | |||||
return $model['nom']; | |||||
<?= $form->field($model, 'id_producer')->hiddenInput() ?> | |||||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map(PointSale::find()->where('id_producer = '.Producer::getId())->all(), 'id', function($model, $defaultValue) { | |||||
return $model['name']; | |||||
}), ['prompt' => '--','class' => 'form-control user-id']) ?> | }), ['prompt' => '--','class' => 'form-control user-id']) ?> | ||||
<?= $form->field($model, 'date_debut') ?> | |||||
<?= $form->field($model, 'date_fin')->hint('Laisser vide pour une durée indéterminée') ?> | |||||
<div class="jours"> | |||||
<?= $form->field($model, 'date_begin') ?> | |||||
<?= $form->field($model, 'date_end')->hint('Laisser vide pour une durée indéterminée') ?> | |||||
<div class="days"> | |||||
<h2>Jours</h2> | <h2>Jours</h2> | ||||
<?= $form->field($model, 'lundi')->checkbox() ?> | |||||
<?= $form->field($model, 'mardi')->checkbox() ?> | |||||
<?= $form->field($model, 'mercredi')->checkbox() ?> | |||||
<?= $form->field($model, 'jeudi')->checkbox() ?> | |||||
<?= $form->field($model, 'vendredi')->checkbox() ?> | |||||
<?= $form->field($model, 'samedi')->checkbox() ?> | |||||
<?= $form->field($model, 'dimanche')->checkbox() ?> | |||||
<?= $form->field($model, 'monday')->checkbox() ?> | |||||
<?= $form->field($model, 'tuesday')->checkbox() ?> | |||||
<?= $form->field($model, 'wednesday')->checkbox() ?> | |||||
<?= $form->field($model, 'thursday')->checkbox() ?> | |||||
<?= $form->field($model, 'friday')->checkbox() ?> | |||||
<?= $form->field($model, 'saterday')->checkbox() ?> | |||||
<?= $form->field($model, 'sunday')->checkbox() ?> | |||||
</div> | </div> | ||||
<div class="clr"></div> | <div class="clr"></div> | ||||
<?= $form->field($model, 'periodicite_semaine')->dropDownList([1=>1, 2=>2, 3=>3, 4=>4]) ?> | |||||
<?= $form->field($model, 'week_frequency')->dropDownList([1=>1, 2=>2, 3=>3, 4=>4]) ?> | |||||
<?= $form->field($model, 'paiement_automatique') | |||||
<?= $form->field($model, 'auto_payment') | |||||
->checkbox() | ->checkbox() | ||||
->hint('Cochez cette case si vous souhaitez que le crédit pain du client soit automatiquement débité lors de la création de la commande.<br />' | ->hint('Cochez cette case si vous souhaitez que le crédit pain du client soit automatiquement débité lors de la création de la commande.<br />' | ||||
. 'Attention, un compte client existant doit être spécifié en haut de ce formulaire.') ?> | . 'Attention, un compte client existant doit être spécifié en haut de ce formulaire.') ?> | ||||
<div class="produits"> | |||||
<div class="products"> | |||||
<h2>Produits</h2> | <h2>Produits</h2> | ||||
<?php if(isset($model->errors['produits']) && count($model->errors['produits'])) | |||||
<?php if(isset($model->errors['products']) && count($model->errors['products'])) | |||||
{ | { | ||||
echo '<div class="alert alert-danger">'.$model->errors['produits'][0].'</div>' ; | |||||
echo '<div class="alert alert-danger">'.$model->errors['products'][0].'</div>' ; | |||||
} | } | ||||
?> | ?> | ||||
<table class="table table-bordered table-condensed table-hover"> | <table class="table table-bordered table-condensed table-hover"> | ||||
<?php foreach ($produits as $p) : ?> | |||||
<?php foreach ($productsArray as $p) : ?> | |||||
<tr> | <tr> | ||||
<td><?= Html::encode($p->nom) ?></td> | |||||
<td><?= Html::encode($p->name) ?></td> | |||||
<td> | <td> | ||||
<div class="input-group"> | <div class="input-group"> | ||||
<span class="input-group-btn"> | <span class="input-group-btn"> | ||||
<button class="btn btn-default btn-moins" type="button"><span class="glyphicon glyphicon-minus"></span></button> | |||||
<button class="btn btn-default btn-minus" type="button"><span class="glyphicon glyphicon-minus"></span></button> | |||||
</span> | </span> | ||||
<?= Html::input('text', 'CommandeAutoForm[produits][produit_'.$p->id.']', (isset($model->produits['produit_'.$p->id])) ? $model->produits['produit_'.$p->id] : '', ['class' => 'form-control quantite']) ?> | |||||
<?= Html::input('text', 'SubscriptionForm[products][product_'.$p->id.']', (isset($model->products['product_'.$p->id])) ? $model->products['product_'.$p->id] : '', ['class' => 'form-control quantity']) ?> | |||||
<span class="input-group-btn"> | <span class="input-group-btn"> | ||||
<button class="btn btn-default btn-plus" type="button"><span class="glyphicon glyphicon-plus"></span></button> | |||||
<button class="btn btn-default btn-more" type="button"><span class="glyphicon glyphicon-plus"></span></button> | |||||
</span> | </span> | ||||
</div> | </div> | ||||
</td> | </td> |
/* @var $this yii\web\View */ | /* @var $this yii\web\View */ | ||||
/* @var $model app\models\Produit */ | /* @var $model app\models\Produit */ | ||||
$this->title = 'Ajouter une commande automatique'; | |||||
$this->params['breadcrumbs'][] = ['label' => 'Commandes automatiques', 'url' => ['index']]; | |||||
$this->title = 'Ajouter un abonnement'; | |||||
$this->params['breadcrumbs'][] = ['label' => 'Abonnements', 'url' => ['index']]; | |||||
$this->params['breadcrumbs'][] = 'Ajouter'; | $this->params['breadcrumbs'][] = 'Ajouter'; | ||||
?> | ?> | ||||
<div class="commandeauto-create"> | |||||
<div class="subscription-create"> | |||||
<h1><?= Html::encode($this->title) ?></h1> | <h1><?= Html::encode($this->title) ?></h1> | ||||
<?= $this->render('_form', [ | <?= $this->render('_form', [ | ||||
'model' => $model, | 'model' => $model, | ||||
'produits' => $produits | |||||
'productsArray' => $productsArray | |||||
]) ?> | ]) ?> | ||||
</div> | </div> |
/* @var $this yii\web\View */ | /* @var $this yii\web\View */ | ||||
/* @var $dataProvider yii\data\ActiveDataProvider */ | /* @var $dataProvider yii\data\ActiveDataProvider */ | ||||
$this->title = 'Commandes récurrentes'; | |||||
$this->title = 'Abonnements'; | |||||
$this->params['breadcrumbs'][] = $this->title; | $this->params['breadcrumbs'][] = $this->title; | ||||
?> | ?> | ||||
<div class="commande-auto-index"> | |||||
<div class="subscription-index"> | |||||
<h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1> | <h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1> | ||||
return Html::encode($model->username) ; | return Html::encode($model->username) ; | ||||
} | } | ||||
else { | else { | ||||
if(isset($model->user)) | |||||
return Html::encode($model->user->nom.' '.$model->user->prenom) ; | |||||
if(isset($model->user)) { | |||||
return Html::encode($model->user->lastname.' '.$model->user->name) ; | |||||
} | |||||
} | } | ||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'id_point_vente', | |||||
'attribute' => 'id_point_sale', | |||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
return Html::encode($model->pointVente->nom) ; | |||||
return Html::encode($model->pointSale->name) ; | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'produits', | |||||
'attribute' => 'products', | |||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
$html = '' ; | $html = '' ; | ||||
foreach($model->commandeAutoProduit as $commande_produit) | |||||
foreach($model->productSubscription as $productSubscription) | |||||
{ | { | ||||
$html .= $commande_produit->quantite . ' x '.Html::encode($commande_produit->produit->nom).'<br />' ; | |||||
$html .= $productSubscription->quantity . ' x '.Html::encode($productSubscription->product->name).'<br />' ; | |||||
} | } | ||||
// aucun produit | // aucun produit | ||||
if(!count($model->commandeAutoProduit)) | |||||
if(!count($model->productSubscription)) | |||||
{ | { | ||||
$html .= '<span class="glyphicon glyphicon-warning-sign"></span> Aucun produit' ; | $html .= '<span class="glyphicon glyphicon-warning-sign"></span> Aucun produit' ; | ||||
} | } | ||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'date_debut', | |||||
'attribute' => 'date_begin', | |||||
'value' => function($model) { | 'value' => function($model) { | ||||
return date('d/m/Y',strtotime($model->date_debut)) ; | |||||
return date('d/m/Y',strtotime($model->date_begin)) ; | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'date_fin', | |||||
'attribute' => 'date_end', | |||||
'value' => function($model) { | 'value' => function($model) { | ||||
if($model->date_fin) | |||||
return date('d/m/Y',strtotime($model->date_fin)) ; | |||||
if($model->date_end) | |||||
return date('d/m/Y',strtotime($model->date_end)) ; | |||||
else | else | ||||
return 'indéterminée' ; | return 'indéterminée' ; | ||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'lundi', | |||||
'attribute' => 'monday', | |||||
'label' => 'Jours', | 'label' => 'Jours', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
$html = '' ; | $html = '' ; | ||||
if($model->lundi) | |||||
if($model->monday) | |||||
$html .= 'lundi, ' ; | $html .= 'lundi, ' ; | ||||
if($model->mardi) | |||||
if($model->tuesday) | |||||
$html .= 'mardi, ' ; | $html .= 'mardi, ' ; | ||||
if($model->mercredi) | |||||
if($model->wednesday) | |||||
$html .= 'mercredi, ' ; | $html .= 'mercredi, ' ; | ||||
if($model->jeudi) | |||||
if($model->thursday) | |||||
$html .= 'jeudi, ' ; | $html .= 'jeudi, ' ; | ||||
if($model->vendredi) | |||||
if($model->friday) | |||||
$html .= 'vendredi, ' ; | $html .= 'vendredi, ' ; | ||||
if($model->samedi) | |||||
if($model->saterday) | |||||
$html .= 'samedi, ' ; | $html .= 'samedi, ' ; | ||||
if($model->dimanche) | |||||
if($model->sunday) | |||||
$html .= 'dimanche, ' ; | $html .= 'dimanche, ' ; | ||||
if(strlen($html)) | if(strlen($html)) | ||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'periodicite_semaine', | |||||
'attribute' => 'week_frequency', | |||||
'value' => function($model) { | 'value' => function($model) { | ||||
if($model->periodicite_semaine == 1) | |||||
if($model->week_frequency == 1) | |||||
return 'Toutes les semaines' ; | return 'Toutes les semaines' ; | ||||
else | else | ||||
return 'Toutes les '.$model->periodicite_semaine.' semaines' ; | |||||
return 'Toutes les '.$model->week_frequency.' semaines' ; | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'paiement_automatique', | |||||
'attribute' => 'auto_payment', | |||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
if($model->paiement_automatique) | |||||
if($model->auto_payment) | |||||
return '<span class="label label-success">Oui</span>' ; | return '<span class="label label-success">Oui</span>' ; | ||||
else | else | ||||
return '<span class="label label-danger">Non</span>' ; | return '<span class="label label-danger">Non</span>' ; |
/* @var $this yii\web\View */ | /* @var $this yii\web\View */ | ||||
/* @var $model app\models\Produit */ | /* @var $model app\models\Produit */ | ||||
$this->title = 'Modifier une commande récurrente'; | |||||
$this->params['breadcrumbs'][] = ['label' => 'Commandes récurrentes', 'url' => ['index']]; | |||||
$this->title = 'Modifier un abonnement'; | |||||
$this->params['breadcrumbs'][] = ['label' => 'Abonnements', 'url' => ['index']]; | |||||
$this->params['breadcrumbs'][] = 'Modifier'; | $this->params['breadcrumbs'][] = 'Modifier'; | ||||
?> | ?> | ||||
<div class="commandeauto-update"> | |||||
<div class="subscription-update"> | |||||
<h1><?= Html::encode($this->title) ?></h1> | <h1><?= Html::encode($this->title) ?></h1> | ||||
<?= $this->render('_form', [ | <?= $this->render('_form', [ | ||||
'model' => $model, | 'model' => $model, | ||||
'produits' => $produits | |||||
'productsArray' => $productsArray | |||||
]) ?> | ]) ?> | ||||
</div> | </div> |