Merge pull request #11914 from fmarcet/develop
Fix: Load invoices only if showed
This commit is contained in:
commit
f5c839217a
@ -12,7 +12,7 @@
|
|||||||
* Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.fr>
|
* Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.fr>
|
||||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
* 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) 2015-2016 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
* 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 '<tr><td class="tdtop fieldrequired">' . $langs->trans('Type') . '</td><td colspan="2">';
|
||||||
|
|
||||||
print '<div class="tagtable">' . "\n";
|
print '<div class="tagtable">' . "\n";
|
||||||
@ -2981,6 +2938,23 @@ if ($action == 'create')
|
|||||||
// Replacement
|
// Replacement
|
||||||
if (empty($conf->global->INVOICE_DISABLE_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 '<!-- replacement line -->';
|
||||||
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
||||||
$tmp='<input type="radio" name="type" id="radio_replacement" value="1"' . (GETPOST('type') == 1 ? ' checked' : '');
|
$tmp='<input type="radio" name="type" id="radio_replacement" value="1"' . (GETPOST('type') == 1 ? ' checked' : '');
|
||||||
@ -3048,6 +3022,32 @@ if ($action == 'create')
|
|||||||
// Credit note
|
// Credit note
|
||||||
if (empty($conf->global->INVOICE_DISABLE_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">';
|
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
||||||
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
|
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
|
||||||
if (! $optionsav) $tmp.=' disabled';
|
if (! $optionsav) $tmp.=' disabled';
|
||||||
|
|||||||
@ -1277,7 +1277,7 @@ class ExtraFields
|
|||||||
// Several field into label (eq table:code|libelle:rowid)
|
// Several field into label (eq table:code|libelle:rowid)
|
||||||
$notrans = false;
|
$notrans = false;
|
||||||
$fields_label = explode('|', $InfoFieldList[1]);
|
$fields_label = explode('|', $InfoFieldList[1]);
|
||||||
if (is_array($fields_label)) {
|
if (is_array($fields_label) && count($fields_label) > 1) {
|
||||||
$notrans = true;
|
$notrans = true;
|
||||||
foreach ($fields_label as $field_toshow) {
|
foreach ($fields_label as $field_toshow) {
|
||||||
$labeltoshow .= $obj->$field_toshow . ' ';
|
$labeltoshow .= $obj->$field_toshow . ' ';
|
||||||
@ -1291,27 +1291,16 @@ class ExtraFields
|
|||||||
if (!$notrans) {
|
if (!$notrans) {
|
||||||
foreach ($fields_label as $field_toshow) {
|
foreach ($fields_label as $field_toshow) {
|
||||||
$translabel = $langs->trans($obj->$field_toshow);
|
$translabel = $langs->trans($obj->$field_toshow);
|
||||||
if ($translabel != $obj->$field_toshow) {
|
$labeltoshow = dol_trunc($translabel, 18) . ' ';
|
||||||
$labeltoshow = dol_trunc($translabel, 18) . ' ';
|
|
||||||
} else {
|
|
||||||
$labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' ';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';
|
$out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';
|
||||||
} else {
|
} else {
|
||||||
if (!$notrans) {
|
if (!$notrans) {
|
||||||
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
||||||
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
$labeltoshow = dol_trunc($translabel, 18);
|
||||||
$labeltoshow = dol_trunc($translabel, 18);
|
|
||||||
} else {
|
|
||||||
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (empty($labeltoshow)) $labeltoshow = '(not defined)';
|
if (empty($labeltoshow)) $labeltoshow = '(not defined)';
|
||||||
if ($value == $obj->rowid) {
|
|
||||||
$out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($InfoFieldList[3]) && $parentField) {
|
if (!empty($InfoFieldList[3]) && $parentField) {
|
||||||
$parent = $parentName . ':' . $obj->{$parentField};
|
$parent = $parentName . ':' . $obj->{$parentField};
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||||
|
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -1765,49 +1766,6 @@ if ($action == 'create')
|
|||||||
print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.(isset($_POST['ref_supplier'])?$_POST['ref_supplier']:$objectsrc->ref_supplier).'" type="text"></td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.(isset($_POST['ref_supplier'])?$_POST['ref_supplier']:$objectsrc->ref_supplier).'" type="text"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Type invoice
|
|
||||||
$facids = $facturestatic->list_replacable_supplier_invoices($societe->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_supplier_invoices($societe->id);
|
|
||||||
if ($facids < 0)
|
|
||||||
{
|
|
||||||
dol_print_error($db, $facturestatic);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$optionsav = "";
|
|
||||||
$newinvoice_static = new FactureFournisseur($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', 'int'))
|
|
||||||
$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>';
|
print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Type').'</td><td>';
|
||||||
|
|
||||||
print '<div class="tagtable">' . "\n";
|
print '<div class="tagtable">' . "\n";
|
||||||
@ -1860,6 +1818,23 @@ if ($action == 'create')
|
|||||||
// Replacement
|
// Replacement
|
||||||
if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT))
|
if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT))
|
||||||
{
|
{
|
||||||
|
// Type invoice
|
||||||
|
$facids = $facturestatic->list_replacable_supplier_invoices($societe->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 '<!-- replacement line -->';
|
||||||
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
||||||
$tmp='<input type="radio" name="type" id="radio_replacement" value="1"' . (GETPOST('type') == 1 ? ' checked' : '');
|
$tmp='<input type="radio" name="type" id="radio_replacement" value="1"' . (GETPOST('type') == 1 ? ' checked' : '');
|
||||||
@ -1908,6 +1883,32 @@ if ($action == 'create')
|
|||||||
// Credit note
|
// Credit note
|
||||||
if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
|
if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
|
||||||
{
|
{
|
||||||
|
// Show link for credit note
|
||||||
|
$facids=$facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
|
||||||
|
if ($facids < 0)
|
||||||
|
{
|
||||||
|
dol_print_error($db, $facturestatic);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$optionsav = "";
|
||||||
|
$newinvoice_static = new FactureFournisseur($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', 'int'))
|
||||||
|
$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">';
|
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
||||||
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
|
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
|
||||||
if (! $optionsav) $tmp.=' disabled';
|
if (! $optionsav) $tmp.=' disabled';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user