Browse Source

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

feature/souke
Guillaume Bourgeois 10 months ago
parent
commit
7472ae8974
2 changed files with 22 additions and 0 deletions
  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 View File

@@ -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 View File

@@ -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);

Loading…
Cancel
Save