], | ], | ||||
[ | [ | ||||
'attribute' => 'reference', | 'attribute' => 'reference', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
return (strlen($model->reference) > 0) ? $model->reference : ''; | return (strlen($model->reference) > 0) ? $model->reference : ''; | ||||
} | } | ||||
'attribute' => 'date_distribution', | 'attribute' => 'date_distribution', | ||||
'options' => ['class' => 'form-control'] | 'options' => ['class' => 'form-control'] | ||||
]), | ]), | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($model) use ($deliveryNoteManager) { | 'value' => function ($model) use ($deliveryNoteManager) { | ||||
$distribution = $deliveryNoteManager->getDistribution($model); | $distribution = $deliveryNoteManager->getDistribution($model); | ||||
return $distribution ? date('d/m/Y', strtotime($distribution->date)) : ''; | return $distribution ? date('d/m/Y', strtotime($distribution->date)) : ''; | ||||
'header' => 'Point de vente', | 'header' => 'Point de vente', | ||||
'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array' => true]), 'id', 'name'), | 'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array' => true]), 'id', 'name'), | ||||
'format' => 'html', | 'format' => 'html', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($model) use ($deliveryNoteManager) { | 'value' => function ($model) use ($deliveryNoteManager) { | ||||
$pointSale = $deliveryNoteManager->getPointSale($model); | $pointSale = $deliveryNoteManager->getPointSale($model); | ||||
return $pointSale ? Html::encode($pointSale->name) : ''; | return $pointSale ? Html::encode($pointSale->name) : ''; |
], | ], | ||||
[ | [ | ||||
'attribute' => 'reference', | 'attribute' => 'reference', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($invoice) { | 'value' => function ($invoice) { | ||||
return (strlen($invoice->reference) > 0) ? $invoice->reference : ''; | return (strlen($invoice->reference) > 0) ? $invoice->reference : ''; | ||||
} | } | ||||
[ | [ | ||||
'attribute' => 'username', | 'attribute' => 'username', | ||||
'header' => 'Utilisateur', | 'header' => 'Utilisateur', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($invoice) use ($userManager) { | 'value' => function ($invoice) use ($userManager) { | ||||
return $userManager->getUsername($invoice->user); | return $userManager->getUsername($invoice->user); | ||||
} | } | ||||
[ | [ | ||||
'attribute' => 'date', | 'attribute' => 'date', | ||||
'header' => 'Date', | 'header' => 'Date', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($invoice) { | 'value' => function ($invoice) { | ||||
return date('d/m/Y', strtotime($invoice->date)); | return date('d/m/Y', strtotime($invoice->date)); | ||||
} | } | ||||
'attribute' => 'is_sent', | 'attribute' => 'is_sent', | ||||
'header' => 'Envoyé', | 'header' => 'Envoyé', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
if ($model->is_sent) { | if ($model->is_sent) { | ||||
return '<span class="label label-success">Oui</span>'; | return '<span class="label label-success">Oui</span>'; |
$this->setTitle('Points de vente'); | $this->setTitle('Points de vente'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
$this->addButton( | $this->addButton( | ||||
[ | |||||
'label' => 'Nouveau point de vente <span class="glyphicon glyphicon-plus"></span>', | |||||
'url' => 'point-sale/create', | |||||
'class' => 'btn btn-primary' | |||||
] | |||||
[ | |||||
'label' => 'Nouveau point de vente <span class="glyphicon glyphicon-plus"></span>', | |||||
'url' => 'point-sale/create', | |||||
'class' => 'btn btn-primary' | |||||
] | |||||
); | ); | ||||
?> | ?> | ||||
<div class="point-sale-index"> | <div class="point-sale-index"> | ||||
<?= GridView::widget([ | <?= GridView::widget([ | ||||
'filterModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'name', | |||||
'label' => 'Nom', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
$html = ''; | |||||
$html .= $model->name; | |||||
if ($model->is_bread_box) { | |||||
$html .= ' <span class="label label-default">Boîte à pain</span> '; | |||||
} | |||||
'filterModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'name', | |||||
'label' => 'Nom', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
$html = ''; | |||||
$html .= $model->name; | |||||
if ($model->is_bread_box) { | |||||
$html .= ' <span class="label label-default">Boîte à pain</span> '; | |||||
} | |||||
return $html; | |||||
} | |||||
], | |||||
'locality', | |||||
[ | |||||
'attribute' => 'delivery', | |||||
'label' => 'Livraison', | |||||
'filter' => [ | |||||
'monday' => 'Lundi', | |||||
'tuesday' => 'Mardi', | |||||
'wednesday' => 'Mercredi', | |||||
'thursday' => 'Jeudi', | |||||
'friday' => 'Vendredi', | |||||
'saterday' => 'Samedi', | |||||
'sunday' => 'Dimanche', | |||||
], | |||||
'value' => function ($model) use ($pointSaleManager) { | |||||
return $pointSaleManager->getStrDeliveryDays($model); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'access_type', | |||||
'label' => 'Accès', | |||||
'filter' => [ | |||||
'open' => 'Ouvert', | |||||
'code' => 'Code', | |||||
'restricted_access' => 'Accès restreint' | |||||
], | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
$count = UserPointSale::find()->where( | |||||
['id_point_sale' => $model->id] | |||||
)->count(); | |||||
$html = ''; | |||||
if ($model->restricted_access) { | |||||
$html .= '<span class="glyphicon glyphicon-lock"></span> '; | |||||
if ($count == 1) { | |||||
$html .= '1 utilisateur'; | |||||
} else { | |||||
$html .= $count . ' utilisateurs'; | |||||
} | |||||
} | |||||
return $html; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'locality', | |||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
], | |||||
[ | |||||
'attribute' => 'delivery', | |||||
'label' => 'Livraison', | |||||
'filter' => [ | |||||
'monday' => 'Lundi', | |||||
'tuesday' => 'Mardi', | |||||
'wednesday' => 'Mercredi', | |||||
'thursday' => 'Jeudi', | |||||
'friday' => 'Vendredi', | |||||
'saterday' => 'Samedi', | |||||
'sunday' => 'Dimanche', | |||||
], | |||||
'value' => function ($model) use ($pointSaleManager) { | |||||
return $pointSaleManager->getStrDeliveryDays($model); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'access_type', | |||||
'label' => 'Accès', | |||||
'filter' => [ | |||||
'open' => 'Ouvert', | |||||
'code' => 'Code', | |||||
'restricted_access' => 'Accès restreint' | |||||
], | |||||
'format' => 'raw', | |||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($model) { | |||||
$count = UserPointSale::find()->where( | |||||
['id_point_sale' => $model->id] | |||||
)->count(); | |||||
$html = ''; | |||||
if ($model->restricted_access) { | |||||
$html .= '<span class="glyphicon glyphicon-lock"></span> '; | |||||
if ($count == 1) { | |||||
$html .= '1 utilisateur'; | |||||
} else { | |||||
$html .= $count . ' utilisateurs'; | |||||
} | |||||
} | |||||
if (strlen($model->code)) { | |||||
if (strlen($html)) { | |||||
$html .= '<br />'; | |||||
} | |||||
$html .= 'Code : <strong>' . Html::encode( | |||||
$model->code | |||||
) . '</strong>'; | |||||
} | |||||
if (strlen($model->code)) { | |||||
if (strlen($html)) { | |||||
$html .= '<br />'; | |||||
} | |||||
$html .= 'Code : <strong>' . Html::encode( | |||||
$model->code | |||||
) . '</strong>'; | |||||
} | |||||
return $html; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'credit', | |||||
'label' => 'Crédit', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
if ($model->credit && isset(Producer::$creditFunctioningArray[$model->credit_functioning])) { | |||||
return '<span class="glyphicon glyphicon-euro"></span> ' . Producer::$creditFunctioningArray[$model->credit_functioning]; | |||||
} | |||||
return $html; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'credit', | |||||
'label' => 'Crédit', | |||||
'format' => 'raw', | |||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($model) { | |||||
if ($model->credit && isset(Producer::$creditFunctioningArray[$model->credit_functioning])) { | |||||
return '<span class="glyphicon glyphicon-euro"></span> ' . Producer::$creditFunctioningArray[$model->credit_functioning]; | |||||
} | |||||
return ''; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'default', | |||||
'label' => 'Par défaut', | |||||
'format' => 'raw', | |||||
'contentOptions' => ['class' => 'td-default'], | |||||
'value' => function ($model) { | |||||
if ($model->default) { | |||||
return Html::a( | |||||
'<span class="glyphicon glyphicon-star"></span>', | |||||
['point-sale/default', 'id' => $model->id], | |||||
[ | |||||
'title' => 'Point de vente par défaut', | |||||
'class' => 'btn btn-default' | |||||
] | |||||
); | |||||
} else { | |||||
return Html::a( | |||||
'<span class="glyphicon glyphicon-star-empty"></span>', | |||||
['point-sale/default', 'id' => $model->id], | |||||
[ | |||||
'title' => 'Point de vente par défaut', | |||||
'class' => 'btn btn-default' | |||||
] | |||||
); | |||||
} | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{update} {delete}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'update' => function ($url, $model) { | |||||
return Html::a( | |||||
'<span class="glyphicon glyphicon-pencil"></span>', | |||||
$url, | |||||
[ | |||||
'title' => 'Modifier', | |||||
'class' => 'btn btn-default' | |||||
] | |||||
); | |||||
}, | |||||
'delete' => function ($url, $model) { | |||||
return Html::a( | |||||
'<span class="glyphicon glyphicon-trash"></span>', | |||||
$url, | |||||
[ | |||||
'title' => 'Supprimer', | |||||
'class' => 'btn btn-default' | |||||
] | |||||
); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]); ?> | |||||
return ''; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'default', | |||||
'label' => 'Par défaut', | |||||
'format' => 'raw', | |||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'td-default column-hide-on-mobile'], | |||||
'value' => function ($model) { | |||||
if ($model->default) { | |||||
return Html::a( | |||||
'<span class="glyphicon glyphicon-star"></span>', | |||||
['point-sale/default', 'id' => $model->id], | |||||
[ | |||||
'title' => 'Point de vente par défaut', | |||||
'class' => 'btn btn-default' | |||||
] | |||||
); | |||||
} else { | |||||
return Html::a( | |||||
'<span class="glyphicon glyphicon-star-empty"></span>', | |||||
['point-sale/default', 'id' => $model->id], | |||||
[ | |||||
'title' => 'Point de vente par défaut', | |||||
'class' => 'btn btn-default' | |||||
] | |||||
); | |||||
} | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{update} {delete}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'update' => function ($url, $model) { | |||||
return Html::a( | |||||
'<span class="glyphicon glyphicon-pencil"></span>', | |||||
$url, | |||||
[ | |||||
'title' => 'Modifier', | |||||
'class' => 'btn btn-default' | |||||
] | |||||
); | |||||
}, | |||||
'delete' => function ($url, $model) { | |||||
return Html::a( | |||||
'<span class="glyphicon glyphicon-trash"></span>', | |||||
$url, | |||||
[ | |||||
'title' => 'Supprimer', | |||||
'class' => 'btn btn-default' | |||||
] | |||||
); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]); ?> | |||||
</div> | </div> |
], | ], | ||||
[ | [ | ||||
'attribute' => 'reference', | 'attribute' => 'reference', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
return (strlen($model->reference) > 0) ? $model->reference : ''; | return (strlen($model->reference) > 0) ? $model->reference : ''; | ||||
} | } | ||||
[ | [ | ||||
'attribute' => 'id_user', | 'attribute' => 'id_user', | ||||
'header' => 'Utilisateur', | 'header' => 'Utilisateur', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($quotation) use ($userManager) { | 'value' => function ($quotation) use ($userManager) { | ||||
return $userManager->getUsername($quotation->user); | return $userManager->getUsername($quotation->user); | ||||
} | } | ||||
[ | [ | ||||
'attribute' => 'date', | 'attribute' => 'date', | ||||
'header' => 'Date', | 'header' => 'Date', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($quotation) { | 'value' => function ($quotation) { | ||||
return date('d/m/Y', strtotime($quotation->date)); | return date('d/m/Y', strtotime($quotation->date)); | ||||
} | } |
'attribute' => 'product_name', | 'attribute' => 'product_name', | ||||
'label' => 'Produits', | 'label' => 'Produits', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function($model) { | 'value' => function($model) { | ||||
$productManager = ProductManager::getInstance(); | $productManager = ProductManager::getInstance(); | ||||
$html = '' ; | $html = '' ; | ||||
'attribute' => 'date_begin', | 'attribute' => 'date_begin', | ||||
'label' => 'Période', | 'label' => 'Période', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function($model) { | 'value' => function($model) { | ||||
$html = '<small>' ; | $html = '<small>' ; | ||||
if($model->date_end) { | if($model->date_end) { | ||||
'saterday' => 'Samedi', | 'saterday' => 'Samedi', | ||||
'sunday' => 'Dimanche', | 'sunday' => 'Dimanche', | ||||
], | ], | ||||
'contentOptions' => ['class' => 'text-small'], | |||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'text-small column-hide-on-mobile'], | |||||
'value' => function($model) { | 'value' => function($model) { | ||||
$html = '' ; | $html = '' ; | ||||
if($model->monday) { | if($model->monday) { | ||||
1 => 'Toutes les semaines', | 1 => 'Toutes les semaines', | ||||
2 => 'Toutes les 2 semaines', | 2 => 'Toutes les 2 semaines', | ||||
3 => 'Toutes les 3 semaines', | 3 => 'Toutes les 3 semaines', | ||||
4 => 'Tous les mois'], | |||||
4 => 'Tous les mois' | |||||
], | |||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function($model) { | 'value' => function($model) { | ||||
if($model->week_frequency == 1) { | if($model->week_frequency == 1) { | ||||
return 'Toutes les semaines' ; | return 'Toutes les semaines' ; | ||||
'attribute' => 'auto_payment', | 'attribute' => 'auto_payment', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'label' => 'Paiement automatique', | 'label' => 'Paiement automatique', | ||||
'headerOptions' => ['class' => 'column-auto-payment'], | |||||
'contentOptions' => ['class' => 'column-auto-payment'], | |||||
'headerOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'], | |||||
'filter' => [0 => 'Non', 1 => 'Oui'], | 'filter' => [0 => 'Non', 1 => 'Oui'], | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
if($model->auto_payment) { | if($model->auto_payment) { |
[ | [ | ||||
'attribute' => 'type', | 'attribute' => 'type', | ||||
'label' => 'Type', | 'label' => 'Type', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
$userManager = UserManager::getInstance(); | $userManager = UserManager::getInstance(); | ||||
$typeArray = $userManager->getTypeChoicesArray(); | $typeArray = $userManager->getTypeChoicesArray(); | ||||
'attribute' => 'contacts', | 'attribute' => 'contacts', | ||||
'header' => 'Contacts', | 'header' => 'Contacts', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'headerOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
$html = ''; | $html = ''; | ||||
if (strlen($model['phone'])) { | if (strlen($model['phone'])) { | ||||
'class' => 'yii\grid\ActionColumn', | 'class' => 'yii\grid\ActionColumn', | ||||
'header' => 'Commandes', | 'header' => 'Commandes', | ||||
'template' => '{orders}', | 'template' => '{orders}', | ||||
'headerOptions' => ['class' => 'actions'], | |||||
'headerOptions' => ['class' => 'actions column-hide-on-mobile'], | |||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'contentOptions' => ['class' => 'column-hide-on-mobile'], | |||||
'buttons' => [ | 'buttons' => [ | ||||
'orders' => function ($url, $model) { | 'orders' => function ($url, $model) { | ||||
$url = Yii::$app->urlManager->createUrl(['user/orders', 'id' => $model['id']]); | $url = Yii::$app->urlManager->createUrl(['user/orders', 'id' => $model['id']]); |