getProducerManager();
$this->setTitle('Producteurs') ;
$this->addBreadcrumb($this->getTitle()) ;
$this->addButton(['label' => 'Nouveau producteur ', 'url' => 'producer-admin/create', 'class' => 'btn btn-primary']) ;
?>
Facturé le mois dernier : = $sumPrices ?> €
= GridView::widget([
'dataProvider' => $dataProviderProducer,
'columns' => [
[
'attribute' => 'active',
'format' => 'raw',
'value' => function($model) {
$html = '' ;
if($model->active) {
$html .= 'En ligne' ;
}
else {
$html .= 'Hors-ligne' ;
}
if(strlen($model->code))
{
$html .= ' ' ;
}
return $html ;
}
],
'name',
/*[
'attribute' => 'date_creation',
'format' => 'raw',
'value' => function($model) {
return date('d/m/Y', strtotime($model->date_creation)) ;
}
],*/
/*[
'attribute' => 'Lieu',
'format' => 'raw',
'value' => function($model) {
return Html::encode($model->city.' ('.$model->postcode.')') ;
}
],*/
/*[
'attribute' => 'Utilisateurs',
'format' => 'raw',
'value' => function($model) {
if(!$model->userProducer || !count($model->userProducer))
{
return 'Aucun utilisateur' ;
}
else {
$users = count($model->userProducer).' client' ;
if(count($model->userProducer) > 1) {
$users .= 's' ;
}
return $users ;
}
}
],*/
[
'attribute' => 'Contact',
'format' => 'raw',
'value' => function($model) {
if(!isset($model->user) || (isset($model->user) && count($model->user) == 0))
{
return 'Aucun contact' ;
}
else {
foreach($model->user as $u)
{
if($u->status == User::STATUS_PRODUCER)
{
return Html::encode($u->lastname.' '.$u->name)
.'
'.Html::encode($u->email)
.'
'.Html::encode($u->phone) ;
}
}
}
}
],
/*[
'attribute' => 'Prix libre',
'label' => 'Prix libre',
'format' => 'raw',
'value' => function($model) {
if(is_null($model->free_price)) {
return '' ;
}
else {
$str = '';
if($model->isBillingTypeFreePrice()) {
$str .= '';
}
$str .= $model->getFreePrice();
if($model->isBillingTypeFreePrice()) {
$str .= '';
}
return $str;
}
}
],*/
[
'label' => 'Facturation',
'format' => 'raw',
'value' => function($producer) use ($producerManager) {
$str = '';
$str .= '';
$isBillingFrequencyMonthly = $producerManager->isBillingFrequencyMonthly($producer);
$summaryMonthly = $producerManager->getSummaryAmountsToBeBilled($producer, 'Mois dernier', 1);
$isBillingFrequencyQuaterly = $producerManager->isBillingFrequencyQuarterly($producer);
$summaryQuaterly = $producerManager->getSummaryAmountsToBeBilled($producer, '3 derniers mois', 3);
$isBillingFrequencyBiannual = $producerManager->isBillingFrequencyBiannual($producer);
$summaryBiannual = $producerManager->getSummaryAmountsToBeBilled($producer, '6 derniers mois', 6);
if(($isBillingFrequencyMonthly && $summaryMonthly)
|| ($isBillingFrequencyQuaterly && $summaryQuaterly)
|| ($isBillingFrequencyBiannual && $summaryBiannual)) {
$str .= '- ';
if ($isBillingFrequencyMonthly && $summaryMonthly) {
$str .= $summaryMonthly;
} elseif ($isBillingFrequencyQuaterly && $summaryQuaterly) {
$str .= $summaryQuaterly;
} elseif ($isBillingFrequencyBiannual && $summaryBiannual) {
$str .= $summaryBiannual;
}
if ($producer->option_billing_reduction && strlen($str)) {
$str .= '
Avec réduction : ';
if ($producer->option_billing_reduction_percentage) {
$str .= ' ' . $producer->option_billing_reduction_percentage . ' %';
}
}
$str .= ' ';
$str .= '- Facturation '.strtolower(Producer::$billingFrequencyArray[$producer->option_billing_frequency]).'
';
}
if($producer->option_billing_permanent_transfer) {
$str .= '- Virement permanent : '.Price::format($producer->option_billing_permanent_transfer_amount).'
';
}
$str .= '
';
return $str;
}
],
[
'attribute' => 'admin_comment',
'label' => 'Commentaire',
'format' => 'raw',
'value' => function($producer) {
if($producer->admin_comment) {
return $producer->admin_comment;
}
return '';
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {billing} {alwaysdata}',
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'update' => function ($url, $model) {
return Html::a(
'',
$url,
[
'title' => 'Modifier',
'class' => 'btn btn-default'
]
);
},
'billing' => function ($url, $model) {
return Html::a(
'',
$url,
[
'title' => 'Facturation',
'class' => 'btn btn-default'
]
);
},
'alwaysdata' => function ($url, $model) {
return Html::a(
'',
$url,
[
'title' => 'Redirections Alwaysdata (email et url courte)',
'class' => 'btn btn-default'
]
);
},
],
],
],
]); ?>