Skip to content

Commit

Permalink
Add badge for generate invoice client tab
Browse files Browse the repository at this point in the history
  • Loading branch information
lamrani002 committed Oct 25, 2024
1 parent b2d7a13 commit 3981368
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions htdocs/compta/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -1251,8 +1251,11 @@
$newcardbutton = '';
if ($contextpage != 'poslist') {
$url = DOL_URL_ROOT.'/compta/facture/card.php?action=create';
if (!empty($socid)) {
$url .= '&socid='.$socid;
if (!empty($object->socid)) {
$url .= '&socid='.$object->socid;
}
if (!empty($object->id)) {
$url .= '&fac_rec='.$object->id;
}
$newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
Expand Down
15 changes: 15 additions & 0 deletions htdocs/core/lib/invoice.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,21 @@ function invoice_rec_prepare_head($object)

$head[$h][0] = DOL_URL_ROOT . '/compta/facture/list.php?search_fk_fac_rec_source=' . $object->id;
$head[$h][1] = $langs->trans('InvoicesGeneratedFromRec');
//count facture rec
$nbFacture = 0;
$sql = "SELECT COUNT(rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE fk_fac_rec_source = ".((int) $object->id);
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$nbFacture = $obj->nb;
} else {
dol_syslog('Failed to count facture with facture_rec '.$db->lasterror(), LOG_ERR);
}
if ($nbFacture > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbFacture.'</span>';
}
$head[$h][2] = 'generated';
$h++;

Expand Down

0 comments on commit 3981368

Please sign in to comment.