New: Load invoices only if showed
This commit is contained in:
parent
e4984492b3
commit
3f25a8d8d5
@ -12,7 +12,7 @@
|
||||
* Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2014-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2014-2019 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
@ -2862,49 +2862,6 @@ if ($action == 'create')
|
||||
}
|
||||
}
|
||||
|
||||
// Type de facture
|
||||
$facids = $facturestatic->list_replacable_invoices($soc->id);
|
||||
if ($facids < 0) {
|
||||
dol_print_error($db, $facturestatic);
|
||||
exit();
|
||||
}
|
||||
$options = "";
|
||||
foreach ($facids as $facparam)
|
||||
{
|
||||
$options .= '<option value="' . $facparam ['id'] . '"';
|
||||
if ($facparam ['id'] == $_POST['fac_replacement'])
|
||||
$options .= ' selected';
|
||||
$options .= '>' . $facparam ['ref'];
|
||||
$options .= ' (' . $facturestatic->LibStatut(0, $facparam ['status']) . ')';
|
||||
$options .= '</option>';
|
||||
}
|
||||
|
||||
// Show link for credit note
|
||||
$facids=$facturestatic->list_qualified_avoir_invoices($soc->id);
|
||||
if ($facids < 0)
|
||||
{
|
||||
dol_print_error($db, $facturestatic);
|
||||
exit;
|
||||
}
|
||||
$optionsav = "";
|
||||
$newinvoice_static = new Facture($db);
|
||||
foreach ($facids as $key => $valarray)
|
||||
{
|
||||
$newinvoice_static->id = $key;
|
||||
$newinvoice_static->ref = $valarray ['ref'];
|
||||
$newinvoice_static->statut = $valarray ['status'];
|
||||
$newinvoice_static->type = $valarray ['type'];
|
||||
$newinvoice_static->paye = $valarray ['paye'];
|
||||
|
||||
$optionsav .= '<option value="' . $key . '"';
|
||||
if ($key == GETPOST('fac_avoir'))
|
||||
$optionsav .= ' selected';
|
||||
$optionsav .= '>';
|
||||
$optionsav .= $newinvoice_static->ref;
|
||||
$optionsav .= ' (' . $newinvoice_static->getLibStatut(1, $valarray ['paymentornot']) . ')';
|
||||
$optionsav .= '</option>';
|
||||
}
|
||||
|
||||
print '<tr><td class="tdtop fieldrequired">' . $langs->trans('Type') . '</td><td colspan="2">';
|
||||
|
||||
print '<div class="tagtable">' . "\n";
|
||||
@ -2981,6 +2938,23 @@ if ($action == 'create')
|
||||
// Replacement
|
||||
if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT))
|
||||
{
|
||||
// Type de facture
|
||||
$facids = $facturestatic->list_replacable_invoices($soc->id);
|
||||
if ($facids < 0) {
|
||||
dol_print_error($db, $facturestatic);
|
||||
exit();
|
||||
}
|
||||
$options = "";
|
||||
foreach ($facids as $facparam)
|
||||
{
|
||||
$options .= '<option value="' . $facparam ['id'] . '"';
|
||||
if ($facparam ['id'] == $_POST['fac_replacement'])
|
||||
$options .= ' selected';
|
||||
$options .= '>' . $facparam ['ref'];
|
||||
$options .= ' (' . $facturestatic->LibStatut(0, $facparam ['status']) . ')';
|
||||
$options .= '</option>';
|
||||
}
|
||||
|
||||
print '<!-- replacement line -->';
|
||||
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
||||
$tmp='<input type="radio" name="type" id="radio_replacement" value="1"' . (GETPOST('type') == 1 ? ' checked' : '');
|
||||
@ -3048,6 +3022,32 @@ if ($action == 'create')
|
||||
// Credit note
|
||||
if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
|
||||
{
|
||||
// Show link for credit note
|
||||
$facids=$facturestatic->list_qualified_avoir_invoices($soc->id);
|
||||
if ($facids < 0)
|
||||
{
|
||||
dol_print_error($db, $facturestatic);
|
||||
exit;
|
||||
}
|
||||
$optionsav = "";
|
||||
$newinvoice_static = new Facture($db);
|
||||
foreach ($facids as $key => $valarray)
|
||||
{
|
||||
$newinvoice_static->id = $key;
|
||||
$newinvoice_static->ref = $valarray ['ref'];
|
||||
$newinvoice_static->statut = $valarray ['status'];
|
||||
$newinvoice_static->type = $valarray ['type'];
|
||||
$newinvoice_static->paye = $valarray ['paye'];
|
||||
|
||||
$optionsav .= '<option value="' . $key . '"';
|
||||
if ($key == GETPOST('fac_avoir'))
|
||||
$optionsav .= ' selected';
|
||||
$optionsav .= '>';
|
||||
$optionsav .= $newinvoice_static->ref;
|
||||
$optionsav .= ' (' . $newinvoice_static->getLibStatut(1, $valarray ['paymentornot']) . ')';
|
||||
$optionsav .= '</option>';
|
||||
}
|
||||
|
||||
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
||||
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
|
||||
if (! $optionsav) $tmp.=' disabled';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user