getProducerModule();
$this->setTitle('Producteurs') ;
$this->addBreadcrumb($this->getTitle()) ;
$this->addButton(['label' => 'Nouveau producteur ', 'url' => 'producer-admin/create', 'class' => 'btn btn-primary']) ;
?>
= 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 .= '
' ;
}
if($model->is_new) {
$html .= '
Nouveau' ;
}
if(!$model->agree_contact_about_software_development) {
$html .= '
Développement';
}
return $html ;
}
],
[
'attribute' => 'name',
'format' => 'raw',
'value' => function($model) {
$html = Html::encode($model->name);
return $html;
}
],
[
'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) ;
}
}
}
}
],
[
'label' => 'Facturation',
'format' => 'raw',
'value' => function($producer) use ($producerModule) {
$str = '';
$str .= '
';
$isBillingFrequencyMonthly = $producerModule->isBillingFrequencyMonthly($producer);
$summaryMonthly = $producerModule->getSummaryAmountsToBeBilled($producer, 'Mois dernier', 1);
$isBillingFrequencyQuaterly = $producerModule->isBillingFrequencyQuarterly($producer);
$summaryQuaterly = $producerModule->getSummaryAmountsToBeBilled($producer, '3 derniers mois', 3);
$isBillingFrequencyBiannual = $producerModule->isBillingFrequencyBiannual($producer);
$summaryBiannual = $producerModule->getSummaryAmountsToBeBilled($producer, '6 derniers mois', 6);
$isBilled = false;
if(($isBillingFrequencyMonthly && $summaryMonthly)
|| ($isBillingFrequencyQuaterly && $summaryQuaterly)
|| ($isBillingFrequencyBiannual && $summaryBiannual)) {
$isBilled = true;
$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 .= ' ';
if(!$isBillingFrequencyMonthly) {
$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 .= '
';
if($isBilled && $producerModule->getSolver()->isFreeBillingPeriodSponsorship($producer)) {
$str .= "
Pas de facturation, offre de parrainage jusqu'au ".$producerModule->getSolver()->getDateEndFreeBillingPeriodSponsorship($producer)->format('d/m/Y')."
";
if(!$producer->getSponsorshipSponsorReward()) {
$str .= '
Créer un avoir de 30€ pour le parrain '.Html::encode($producer->getSponsoredBy()->getName()).' sur Dolibarr et valider la récompense parrain.
';
}
}
return $str;
}
],
[
'attribute' => 'admin_comment',
'label' => 'Commentaire',
'format' => 'raw',
'value' => function($producer) {
$html = '';
if($producer->admin_comment) {
$html .= $producer->admin_comment;
}
if($producer->active && (!$producer->latitude || !$producer->longitude)) {
$html .= '
Latitude/longitude à saisir
';
}
return $html;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {switch} {create-ticket} {billing} {dolibarr} {alwaysdata}',
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'update' => function ($url, $model) {
return Html::a(
'
',
$url,
[
'title' => 'Modifier',
'class' => 'btn btn-default'
]
);
},
'switch' => function ($url, $model) {
return Html::a(
'
',
Yii::$app->urlManager->createUrl(['site/switch-producer', 'id' => $model->id]),
[
'title' => 'Aller sur le compte de ce producteur',
'class' => 'btn btn-default'
]
);
},
'create-ticket' => function ($url, $model) {
return Html::a(
'',
Yii::$app->urlManager->createUrl(['site/switch-producer', 'id' => $model->id, 'createTicket' => true]),
[
'title' => 'Créer un ticket',
'class' => 'btn btn-default'
]
);
},
'dolibarr' => function ($url, $model) {
return Html::a(
'
',
$url,
[
'title' => 'Générer la facture sur Dolibarr',
'class' => 'btn btn-default btn-dolibarr'
]
);
},
'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 btn-alwaysdata'
]
);
},
],
],
],
]); ?>