Просмотр исходного кода

[Administration] Mes factures : label en rouge avec nombre de factures impayées

feature/souke
Guillaume Bourgeois 9 месяцев назад
Родитель
Сommit
7472ae8974
2 измененных файлов: 22 добавлений и 0 удалений
  1. +9
    -0
      backend/views/layouts/left.php
  2. +13
    -0
      common/logic/Producer/Producer/Service/DolibarrProducerUtils.php

+ 9
- 0
backend/views/layouts/left.php Просмотреть файл

@@ -113,6 +113,14 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
$countUsersOnlineLabel .= '</span>';
}

$countProducerInvoicesUnpaidLabel = '';
$countProducerInvoicesUnpaid = $this->getProducerModule()->getDolibarrUtils()
->countDolibarrProducerInvoicesUnpaid($producer);
if($countProducerInvoicesUnpaid > 1) {
$countProducerInvoicesUnpaidLabelColor = ($countProducerInvoicesUnpaid > 2) ? 'red' : 'orange';
$countProducerInvoicesUnpaidLabel = '<span class="pull-right-container"><small class="label pull-right bg-'.$countProducerInvoicesUnpaidLabelColor.'">' . $countProducerInvoicesUnpaid . '</small></span>';
}

?>

<?= dmstr\widgets\Menu::widget(
@@ -200,6 +208,7 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
'url' => ['/producer-invoice/index'],
'visible' => $isUserCurrentGrantedAsProducer && Yii::$app->parameterBag->get('dolibarrApiKey'),
'active' => Yii::$app->controller->id == 'producer-invoice',
'template' => '<a href="{url}">{icon} {label}' . $countProducerInvoicesUnpaidLabel . '</a>'
],
['label' => 'Tarifs & modules', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $isUserCurrentGrantedAsProducer],
[

+ 13
- 0
common/logic/Producer/Producer/Service/DolibarrProducerUtils.php Просмотреть файл

@@ -32,6 +32,19 @@ class DolibarrProducerUtils extends AbstractManager
return $invoicesArray;
}

public function countDolibarrProducerInvoicesUnpaid(Producer $producer): int
{
$count = 0;
$invoicesArray = $this->getDolibarrProducerInvoices($producer);
foreach($invoicesArray as $invoice) {
if($invoice['remaintopay'] > 0) {
$count ++;
}
}

return $count;
}

public function generateDolibarrProducerInvoice(Producer $producer)
{
$idProduct = $this->getDolibarrProductId($producer);

Загрузка…
Отмена
Сохранить