diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c00a01717ac5f..25d9dcffaa3fb 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -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')); diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index fcaeb49505d3c..e7b5b10182800 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -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] .= ''.$nbFacture.''; + } $head[$h][2] = 'generated'; $h++;