Skip to content

Commit

Permalink
Merge pull request #527 from ATM-Consulting/new/127/17.0_koesio/backp…
Browse files Browse the repository at this point in the history
…ort_generated_recurring_invoice_tab

Backport de la PR Dolibarr#31463
  • Loading branch information
atm-lena authored Oct 23, 2024
2 parents e44db16 + 5d71e0c commit b32b8af
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ChangeLog_Koesio.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
## Backported from 17.0 :
- Backport 21.0 PR #31463 : Tab to see generated invoices on recurring
supplier or customer invoice cards - *2024-10-23*
- Backport 17.0 PR #31445 : Follow ExtraFields between model invoice and classic invoice - *2024-10-18*
17 changes: 17 additions & 0 deletions htdocs/compta/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
$search_categ_cus = GETPOST("search_categ_cus", 'int');
$search_product_category = GETPOST('search_product_category', 'int');
$search_fac_rec_source_title = GETPOST("search_fac_rec_source_title", 'alpha');
$search_fk_fac_rec_source = GETPOST('search_fk_fac_rec_source', 'int'); // backport 21.0 #31463
$search_btn = GETPOST('button_search', 'alpha');
$search_remove_btn = GETPOST('button_removefilter', 'alpha');

Expand Down Expand Up @@ -818,6 +819,10 @@
if (!empty($search_fac_rec_source_title)) {
$sql .= natural_search('facrec.titre', $search_fac_rec_source_title);
}
// backport 21.0 #31463
if ($search_fk_fac_rec_source) {
$sql .= ' AND f.fk_fac_rec_source = ' . (int) $search_fk_fac_rec_source;
}
// Search for tag/category ($searchCategoryProductList is an array of ID)
$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
$searchCategoryProductOperator = 0;
Expand Down Expand Up @@ -979,6 +984,14 @@
}
}

// backport 21.0 #31463
if ($search_fk_fac_rec_source) {
$object = new FactureRec($db);
$object->id = (int) $search_fk_fac_rec_source;
$head = invoice_rec_prepare_head($object);
print dol_get_fiche_head($head, 'generated', $langs->trans('InvoicesGeneratedFromRec'), -1, 'bill'); // Add a div
}

$param = '&socid='.urlencode($socid);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
Expand Down Expand Up @@ -1151,6 +1164,10 @@
if (!empty($search_fac_rec_source_title)) {
$param .= '&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title);
}
// backport 21.0 #31463
if ($search_fk_fac_rec_source) {
$param .= '&search_fk_fac_rec_source=' . (int) $search_fk_fac_rec_source;
}

// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
Expand Down
14 changes: 13 additions & 1 deletion htdocs/core/lib/invoice.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ function invoice_rec_prepare_head($object)
$head[$h][2] = 'card';
$h++;

// backport 21.0 #31463
$head[$h][0] = DOL_URL_ROOT . '/compta/facture/list.php?search_fk_fac_rec_source=' . $object->id;
$head[$h][1] = $langs->trans('InvoicesGeneratedFromRec');
$head[$h][2] = 'generated';
$h++;

// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
Expand All @@ -245,7 +251,7 @@ function invoice_rec_prepare_head($object)
/**
* Return array head with list of tabs to view object informations.
*
* @param Facture $object Invoice object
* @param FactureFournisseurRec $object Invoice object
* @return array head array with tabs
*/
function supplier_invoice_rec_prepare_head($object)
Expand All @@ -260,6 +266,12 @@ function supplier_invoice_rec_prepare_head($object)
$head[$h][2] = 'card';
$h++;

// backport 21.0 #31463
$head[$h][0] = DOL_URL_ROOT . '/fourn/facture/list.php?search_fk_fac_rec_source=' . $object->id;
$head[$h][1] = $langs->trans('InvoicesGeneratedFromRec');
$head[$h][2] = 'generated';
$h++;

// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
Expand Down
19 changes: 19 additions & 0 deletions htdocs/fourn/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
$search_remove_btn = GETPOST('button_removefilter', 'alpha');
$search_categ_sup = trim(GETPOST("search_categ_sup", 'int'));
$search_product_category = GETPOST('search_product_category', 'int');
$search_fk_fac_rec_source = GETPOST('search_fk_fac_rec_source', 'int'); // backport 21.0 #31463

$option = GETPOST('search_option');
if ($option == 'late') {
Expand Down Expand Up @@ -594,6 +595,10 @@
if ($search_label) {
$sql .= natural_search('f.libelle', $search_label);
}
// backport 21.0 #31463
if ($search_fk_fac_rec_source) {
$sql .= " AND f.fk_fac_rec_source = ".(int) $search_fk_fac_rec_source;
}
$searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array();
$searchCategorySupplierOperator = 0;
// Search for tag/category ($searchCategorySupplierList is an array of ID)
Expand Down Expand Up @@ -756,6 +761,16 @@

llxHeader('', $langs->trans("SuppliersInvoices"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores');

// backport 21.0 #31463
if ($search_fk_fac_rec_source) {
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
$object = new FactureFournisseurRec($db);
$object->id = (int) $search_fk_fac_rec_source;
$head = supplier_invoice_rec_prepare_head($object);
print dol_get_fiche_head($head, 'generated', $langs->trans('InvoicesGeneratedFromRec'), -1, 'bill'); // Add a div
}

if ($socid) {
$soc = new Societe($db);
$soc->fetch($socid);
Expand Down Expand Up @@ -892,6 +907,10 @@
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
$param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
}
// backport 21.0 #31463
if ($search_fk_fac_rec_source) {
$param .= '&search_fk_fac_rec_source=' . (int) $search_fk_fac_rec_source;
}

// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/bills.lang
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ BillFrom=From
BillTo=To
ShippingTo=Shipping to
ActionsOnBill=Actions on invoice
InvoicesGeneratedFromRec=Generated invoices
RecurringInvoiceTemplate=Template / Recurring invoice
NoQualifiedRecurringInvoiceTemplateFound=No recurring template invoice qualified for generation.
FoundXQualifiedRecurringInvoiceTemplate=Found %s recurring template invoice(s) qualified for generation.
Expand Down

0 comments on commit b32b8af

Please sign in to comment.