Merge pull request #11914 from fmarcet/develop

Fix: Load invoices only if showed
This commit is contained in:
Laurent Destailleur 2019-09-27 14:34:16 +02:00 committed by GitHub
commit f5c839217a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 105 additions and 115 deletions

View File

@ -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';

View File

@ -1277,7 +1277,7 @@ class ExtraFields
// Several field into label (eq table:code|libelle:rowid)
$notrans = false;
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
if (is_array($fields_label) && count($fields_label) > 1) {
$notrans = true;
foreach ($fields_label as $field_toshow) {
$labeltoshow .= $obj->$field_toshow . ' ';
@ -1291,27 +1291,16 @@ class ExtraFields
if (!$notrans) {
foreach ($fields_label as $field_toshow) {
$translabel = $langs->trans($obj->$field_toshow);
if ($translabel != $obj->$field_toshow) {
$labeltoshow = dol_trunc($translabel, 18) . ' ';
} else {
$labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' ';
}
$labeltoshow = dol_trunc($translabel, 18) . ' ';
}
}
$out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';
} else {
if (!$notrans) {
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
if ($translabel != $obj->{$InfoFieldList[1]}) {
$labeltoshow = dol_trunc($translabel, 18);
} else {
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
}
$labeltoshow = dol_trunc($translabel, 18);
}
if (empty($labeltoshow)) $labeltoshow = '(not defined)';
if ($value == $obj->rowid) {
$out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';
}
if (!empty($InfoFieldList[3]) && $parentField) {
$parent = $parentName . ':' . $obj->{$parentField};

View File

@ -10,6 +10,7 @@
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@open-dsi.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
* 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>';
// 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 '<div class="tagtable">' . "\n";
@ -1860,6 +1818,23 @@ if ($action == 'create')
// 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 '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_replacement" value="1"' . (GETPOST('type') == 1 ? ' checked' : '');
@ -1908,6 +1883,32 @@ if ($action == 'create')
// 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">';
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
if (! $optionsav) $tmp.=' disabled';

View File

@ -96,7 +96,7 @@ ALTER TABLE llx_adherent ADD gender VARCHAR(10);
ALTER TABLE llx_adherent_type ADD morphy VARCHAR(3);
ALTER TABLE llx_subscription ADD fk_type integer;
UPDATE llx_subscription as s SET fk_type = (SELECT fk_adherent_type FROM llx_adherent as a where a.rowid = s.fk_adherent) where fk_type IS NULL;
UPDATE llx_subscription as s SET fk_type = (SELECT fk_adherent_type FROM llx_adherent as a where a.rowid = s.fk_adherent) where fk_type IS NULL;
-- Add url_id into unique index of bank_url
ALTER TABLE llx_bank_url DROP INDEX uk_bank_url;
@ -219,17 +219,17 @@ CREATE TABLE llx_bom_bom(
description text,
note_public text,
note_private text,
fk_product integer,
fk_product integer,
qty double(24,8),
efficiency double(8,4),
date_creation datetime NOT NULL,
tms timestamp,
date_creation datetime NOT NULL,
tms timestamp,
date_valid datetime,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
fk_user_valid integer,
import_key varchar(14),
status integer NOT NULL
status integer NOT NULL
-- END MODULEBUILDER FIELDS
) ENGINE=innodb;
@ -248,12 +248,12 @@ create table llx_bom_bom_extrafields
CREATE TABLE llx_bom_bomline(
-- BEGIN MODULEBUILDER FIELDS
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
fk_bom integer NOT NULL,
fk_bom integer NOT NULL,
fk_product integer NOT NULL,
fk_bom_child integer NULL,
description text,
fk_bom_child integer NULL,
description text,
import_key varchar(14),
qty double(24,8) NOT NULL,
qty double(24,8) NOT NULL,
efficiency double(8,4) NOT NULL DEFAULT 1,
position integer NOT NULL
-- END MODULEBUILDER FIELDS
@ -337,23 +337,23 @@ create table llx_reception
entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_soc integer NOT NULL,
fk_projet integer DEFAULT NULL,
ref_ext varchar(30), -- reference into an external system (not used by dolibarr)
ref_int varchar(30), -- reference into an internal system (used by dolibarr to store extern id like paypal info)
ref_supplier varchar(30), -- customer number
date_creation datetime, -- date de creation
fk_user_author integer, -- author of creation
fk_user_modif integer, -- author of last change
date_valid datetime, -- date de validation
fk_user_valid integer, -- valideur
date_delivery datetime DEFAULT NULL, -- date planned of delivery
date_reception datetime,
date_reception datetime,
fk_shipping_method integer,
tracking_number varchar(50),
fk_statut smallint DEFAULT 0, -- 0 = draft, 1 = validated, 2 = billed or closed depending on WORKFLOW_BILL_ON_SHIPMENT option
billed smallint DEFAULT 0,
height float, -- height
width float, -- with
size_units integer, -- unit of all sizes (height, width, depth)
@ -365,7 +365,7 @@ create table llx_reception
model_pdf varchar(255),
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
import_key varchar(14),
extraparams varchar(255) -- for other parameters with json format
)ENGINE=innodb;