From fc8daef78db6455f8318a308f2abcf2e533db9ca Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Mon, 6 Jul 2015 17:46:36 +0200 Subject: [PATCH 01/55] =?UTF-8?q?increase=20size=20of=20libell=C3=A9=20if?= =?UTF-8?q?=20we=20use=20paypal=20and=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in case of long email the field is to small --- htdocs/install/mysql/tables/llx_c_paiement.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_c_paiement.sql b/htdocs/install/mysql/tables/llx_c_paiement.sql index 090dc2c47be..fd9d301921d 100644 --- a/htdocs/install/mysql/tables/llx_c_paiement.sql +++ b/htdocs/install/mysql/tables/llx_c_paiement.sql @@ -22,7 +22,7 @@ create table llx_c_paiement ( id integer PRIMARY KEY, code varchar(6) NOT NULL, - libelle varchar(30), + libelle varchar(62), type smallint, -- 0: input money, 1: output money, 2: input and output, 3: other active tinyint DEFAULT 1 NOT NULL, accountancy_code varchar(32) NULL, From b7e148d183791b804dcfe24fd624b90d092fc20c Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Tue, 14 Jul 2015 02:49:58 +0200 Subject: [PATCH 02/55] Update 3.7.0-3.8.0.sql --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 3bd8c282c38..c1c436e7eaf 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -729,3 +729,4 @@ INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES ( DELETE FROM llx_c_action_trigger where code = 'PROPAL_CLASSIFYBILLED'; DELETE FROM llx_c_action_trigger where code = 'FICHINTER_CLASSIFYBILLED'; +ALTER TABLE llx_c_paiement MODIFY COLUMN libelle varchar(62); From 4649cf72105f646ab76e5fa2a626399a742dbf17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 18 Jul 2015 19:37:58 +0200 Subject: [PATCH 03/55] Fix: [ bug #3206 ] PropaleLigne, OrderLine and FactureLigne given to triggers through update function does not contain all the information Close #3206 --- ChangeLog | 1 + htdocs/comm/propal/class/propal.class.php | 13 +++++++------ htdocs/commande/class/commande.class.php | 13 +++++++------ htdocs/compta/facture/class/facture.class.php | 13 +++++++------ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab5fa93f635..94ef071cfea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,7 @@ Fix: [ bug #2861 ] Undefined variable $res when migrating Fix: [ bug #2837 ] Product list table column header does not match column body Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order Fix: [ bug #2814 ] JPEG photos are not displayed in Product photos page +Fix: [ bug #3206 ] PropaleLigne, OrderLine and FactureLigne given to triggers through update function does not contain all the information ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 507a9dce633..29480acd60d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -528,13 +528,14 @@ class Propal extends CommonObject $price = $pu - $remise; } - // Update line - $this->line=new PropaleLigne($this->db); + //Fetch current line from the database and then clone the object and set it in $oldline property + $line = new PropaleLigne($this->db); + $line->fetch($rowid); - // Stock previous line records - $staticline=new PropaleLigne($this->db); - $staticline->fetch($rowid); - $this->line->oldline = $staticline; + $staticline = clone $line; + + $line->oldline = $staticline; + $this->line = $line; // Reorder if fk_parent_line change if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d1a776d3d24..78a5a89047a 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2349,13 +2349,14 @@ class Commande extends CommonOrder $price = ($pu - $remise); } - // Update line - $this->line=new OrderLine($this->db); + //Fetch current line from the database and then clone the object and set it in $oldline property + $line = new OrderLine($this->db); + $line->fetch($rowid); - // Stock previous line records - $staticline=new OrderLine($this->db); - $staticline->fetch($rowid); - $this->line->oldline = $staticline; + $staticline = clone $line; + + $line->oldline = $staticline; + $this->line = $line; // Reorder if fk_parent_line change if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0d91d7944b8..eaa4c183a29 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2224,13 +2224,14 @@ class Facture extends CommonInvoice } $price = price2num($price); - // Update line into database - $this->line=new FactureLigne($this->db); + //Fetch current line from the database and then clone the object and set it in $oldline property + $line = new FactureLigne($this->db); + $line->fetch($rowid); - // Stock previous line records - $staticline=new FactureLigne($this->db); - $staticline->fetch($rowid); - $this->line->oldline = $staticline; + $staticline = clone $line; + + $line->oldline = $staticline; + $this->line = $line; // Reorder if fk_parent_line change if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) From f18c983ba5ed89f91e0e7c3ece3ac197f7890954 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Tue, 21 Jul 2015 10:24:54 +0200 Subject: [PATCH 04/55] NEW : print event type on third party card tab agenda list (only if AGENDA_USE_EVENT_TYPE = 1) Conflicts: htdocs/core/lib/company.lib.php --- htdocs/core/lib/company.lib.php | 52 ++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 92b5676746c..c979f734b5e 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -897,7 +897,7 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='') */ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) { - global $bc,$user; + global $bc,$user,$conf; // Check parameters if (! is_object($object)) dol_print_error('','BadParameter'); @@ -915,12 +915,22 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) $out.="\n"; $out.=''; $out.=''; - $out.=''; - $out.=''; + $out.=''; $out.=''; @@ -965,7 +975,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) $var = !$var; $obj = $db->fetch_object($result); - + $actionstatic->fetch($obj->id); $datep=$db->jdate($obj->dp); $datep2=$db->jdate($obj->dp2); @@ -999,8 +1009,13 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) // Title of event //$out.=''; - $out.=''; - + $out.=''; + + if($conf->global->AGENDA_USE_EVENT_TYPE) { + $out.= ''; + } // Contact pour cette action if (empty($objcon->id) && $obj->fk_contact > 0) { @@ -1063,7 +1078,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) */ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) { - global $bc,$user; + global $bc,$user,$conf; // Check parameters if (! is_object($object)) dol_print_error('','BadParameter'); @@ -1202,12 +1217,22 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) $out.="\n"; $out.='
'; + if($conf->global->AGENDA_USE_EVENT_TYPE) $out.=''; + else $out.=''; if (get_class($object) == 'Societe') $out.=''; $out.=$langs->trans("ActionsToDoShort"); if (get_class($object) == 'Societe') $out.=''; $out.=''; + + if($conf->global->AGENDA_USE_EVENT_TYPE) { + $out.=''; + $out.=$langs->trans("Type"); + $out.=''; + } else { + $out.=''; + } + $out.='
'.dol_trunc($obj->label,40).''.$actionstatic->getNomUrl(1,120).''.$actionstatic->getNomUrl(1,120).''; + $out.=$actionstatic->type; + $out.='
'; $out.=''; - $out.=''; - $out.=''; + $out.=''; $out.=''; @@ -1215,7 +1240,7 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) { $var=!$var; $out.=""; - + $actionstatic->fetch($histo[$key]['id']); // Champ date $out.=''; - + + if($conf->global->AGENDA_USE_EVENT_TYPE) { + $out.=''; + } // Title of event //$out.=''; From 977b12fac0423d821afdf8102dd616d0ea57cf65 Mon Sep 17 00:00:00 2001 From: Darkjeff Date: Tue, 28 Jul 2015 19:26:46 +0200 Subject: [PATCH 05/55] clean code customer and supplier accountancy celan code add VAT research --- htdocs/accountancy/customer/lines.php | 29 +++++---- htdocs/accountancy/supplier/lines.php | 49 ++++++++++++--- htdocs/accountancy/supplier/list.php | 89 +++++++++++++++++---------- 3 files changed, 112 insertions(+), 55 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index d00296ed2b9..d49b5b3dcf7 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent @@ -27,10 +27,13 @@ */ require '../../main.inc.php'; + +// Class require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +// Langs $langs->load("bills"); $langs->load("compta"); $langs->load("main"); @@ -38,23 +41,23 @@ $langs->load("accountancy"); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); +//Search Getpost $search_ref = GETPOST('search_ref','alpha'); $search_invoice = GETPOST('search_invoice','alpha'); $search_label = GETPOST('search_label','alpha'); $search_desc = GETPOST('search_desc','alpha'); $search_amount = GETPOST('search_amount','alpha'); $search_account = GETPOST('search_account','alpha'); +$search_vat = GETPOST('search_vat','alpha'); +//Getpost Order and column and limit page $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); - -//if ($page == -1) { $page = 0; } if ($page < 0) $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; -//$limit = $conf->liste_limit; if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { @@ -62,19 +65,11 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { } else { $limit = $conf->liste_limit; } -//$offset = $conf->liste_limit * $page; $offset = $limit * $page; -// TODO : remove comment -//elarifr we can not use only -//$sql .= " ORDER BY l.rowid"; -// f.datef will order like FA08 FA09 FA10 FA05 FA06 FA07 FA04... -// f.facnumber will not order properly invoice / avoir / accompte you can have All AC then All AV and all FA -// l.rowid when an invoice is edited rowid are added at end of table & facturedet.rowid are not ordered -//if (! $sortfield) $sortfield="f.facnumber"; + if (! $sortfield) $sortfield="f.datef, f.facnumber, l.rowid"; -//if (! $sortorder) $sortorder="DESC"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = " DESC "; @@ -98,6 +93,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_desc=''; $search_amount=''; $search_account=''; + $search_vat=''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -181,6 +177,10 @@ if (strlen(trim($search_amount))) { if (strlen(trim($search_account))) { $sql .= " AND aa.account_number like '%" . $search_account . "%'"; } +if (strlen(trim($search_vat))) +{ + $sql .= " AND (l.tva_tx like '" . $search_vat . "%')"; +} if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")"; } @@ -210,6 +210,7 @@ if ($result) { print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"],"l.total_ht","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"],"l.tva_tx","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"],"aa.account_number","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); print_liste_field_titre(''); @@ -222,6 +223,7 @@ if ($result) { print ''; print ''; print ''; + print ''; print ''; print ''; print ''; print ''; print ''; + print ''; print ''; print ''; print ''; print ''; print ''; + print ''; print ''; print ''; - print '\n"; + print "\n"; $facturefournisseur_static = new FactureFournisseur($db); $product_static = new Product($db); @@ -234,6 +262,7 @@ if ($result) { print ''; print ''; print ''; + print ''; print ''; print ''; print ' '; - print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"p.rowid","",$param,'',$sortfield,$sortorder); - print '  '; +print ''; +print ''; +print ''; + +print '
'; + if($conf->global->AGENDA_USE_EVENT_TYPE) $out.=''; + else $out.=''; if (get_class($object) == 'Societe') $out.=''; $out.=$langs->trans("ActionsDoneShort"); if (get_class($object) == 'Societe') $out.=''; $out.=''; + + if($conf->global->AGENDA_USE_EVENT_TYPE) { + $out.=''; + $out.=$langs->trans("Type"); + $out.=''; + } else { + $out.=''; + } + $out.='
'; $out.=dol_print_date($histo[$key]['datestart'],'dayhour'); @@ -1251,7 +1276,12 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) $out.=dol_trunc($libelle,120); } $out.=''; + $out.=$actionstatic->type; + $out.=''.dol_trunc($histo[$key]['note'], 40).'% '; @@ -257,6 +259,7 @@ if ($result) { print '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, 32)) . '' . price($objp->total_ht) . '' . price($objp->tva_tx) . '' . $codecompta . '' . $objp->rowid . ''; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 80f7bc5e6ee..4dd7cb6c15e 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent @@ -26,11 +26,14 @@ */ require '../../main.inc.php'; + +// Class require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +// Langs $langs->load("compta"); $langs->load("bills"); $langs->load("other"); @@ -39,24 +42,45 @@ $langs->load("accountancy"); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); +//Search Getpost $search_ref = GETPOST('search_ref','alpha'); $search_invoice = GETPOST('search_invoice','alpha'); $search_label = GETPOST('search_label','alpha'); $search_desc = GETPOST('search_desc','alpha'); $search_amount = GETPOST('search_amount','alpha'); $search_account = GETPOST('search_account','alpha'); +$search_vat = GETPOST('search_vat','alpha'); +//Getpost Order and column and limit page $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } +if ($page < 0) $page = 0; $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$limit = $conf->liste_limit; -if (! $sortfield) $sortfield="f.ref"; -if (! $sortorder) $sortorder="DESC"; +if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) +{ + $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; +} +else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) +{ + $limit = $conf->liste_limit; +} +else +{ + $limit = $conf->liste_limit; +} +if (! $sortfield) $sortfield="f.datef, f.ref, l.rowid"; + +if (! $sortorder) +{ + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) + { + $sortorder = " DESC "; + } +} // Security check if ($user->societe_id > 0) @@ -75,6 +99,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_desc=''; $search_amount=''; $search_account=''; + $search_vat=''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -124,9 +149,6 @@ print ''; -/* - * Action - */ /* * Supplier Invoice lines @@ -157,6 +179,10 @@ if (strlen(trim($search_amount))) { if (strlen(trim($search_account))) { $sql .= " AND aa.account_number like '%" . $search_account . "%'"; } +if (strlen(trim($search_vat))) +{ + $sql .= " AND (l.tva_tx like '" . $search_vat . "%')"; +} if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; } @@ -187,6 +213,7 @@ if ($result) { print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"],"l.total_ht","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"],"l.tva_tx","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"],"aa.account_number","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); print_liste_field_titre(''); @@ -198,11 +225,12 @@ if ($result) { print '% '; + print ''; print ''; - print "
' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, 32)) . '' . price($objp->total_ht) . '' . price($objp->tva_tx) . '' . $codeCompta . '' . $objp->rowid . ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 02057b31255..3e1622558cb 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent s @@ -41,15 +41,24 @@ $langs->load("main"); $langs->load("accountancy"); $action = GETPOST('action'); + +//Select Box $codeventil = GETPOST('codeventil', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array'); + +//Search Getpost +$search_invoice = GETPOST('search_invoice','alpha'); $search_ref = GETPOST('search_ref','alpha'); $search_label = GETPOST('search_label','alpha'); $search_desc = GETPOST('search_desc','alpha'); +$search_amount = GETPOST('search_amount','alpha'); +$search_account = GETPOST('search_account','alpha'); +$search_vat = GETPOST('search_vat','alpha'); +//Getpost Order and column and limit page $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); -//Should move to top with all GETPOST + $page = GETPOST('page'); if ($page < 0) $page = 0; @@ -62,18 +71,8 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->liste_limit; } $offset = $limit * $page; -//End Should move to top with all GETPOST - -// TODO : remove comment -//elarifr we can not use only -//$sql .= " ORDER BY l.rowid"; -// f.datef will order like FA08 FA09 FA10 FA05 FA06 FA07 FA04... -// f.ref will not order properly invoice / avoir / accompte you can have All AC then All AV and all FA -// l.rowid when an invoice is edited rowid are added at end of table & facturedet.rowid are not ordered -//if (! $sortfield) $sortfield="l.rowid"; if (! $sortfield) $sortfield="f.datef, f.ref, l.rowid"; -//if (! $sortorder) $sortorder="DESC"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = " DESC "; @@ -103,6 +102,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_ref=''; $search_label=''; $search_desc=''; + $search_amount=''; + $search_account=''; + $search_vat=''; } /* @@ -110,9 +112,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both */ llxHeader('', $langs->trans("Ventilation")); -//debug -//print_r($aarowid_s); -//print_r($aarowid_p); print ''; -//TODO For select box print ''; + $(function () { + $(\'#select-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = true; + }); + }); + $(\'#unselect-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = false; + }); + }); + }); + '; -/* - * Action - */ -//TODO -/* -if ($action == 'ventil') { - print '
' . $langs->trans("Processing") . '...
'; - if (! empty($codeventil_buy) && ! empty($mesCasesCochees)) { - if (! empty($codeventil_sell) && ! empty($mesCasesCochees)) { - } else { - print '
' . $langs->trans("AnyLineVentilate") . '
'; - } - print '
' . $langs->trans("EndProcessing") . '
'; -} -*/ -//do we really need to exclude old product not tosell / tobuy ? -//$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type , p.tosell , p.tobuy "; -//$sql .= " WHERE p.accountancy_code_sell IS NULL AND p.tosell = 1 OR p.accountancy_code_buy IS NULL AND p.tobuy = 1"; -//$sql .= " WHERE p.accountancy_code_sell ='' AND p.tosell = 1 OR p.accountancy_code_buy ='' AND p.tobuy = 1"; $sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; -//$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa"; $sql .= " WHERE ("; $sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; -//Search on correct pcg version + $pcgver = $conf->global->CHARTOFACCOUNTS; $sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN - (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - //(SELECT account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa WHERE fk_pcg_version='PCG99-BASE'))"; + (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; $sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN - (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - //(SELECT account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa WHERE fk_pcg_version='PCG99-BASE'))"; + (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; $sql .= ")"; //Add search filter like if (strlen(trim($search_ref))) { - $sql .= " AND (p.ref like '" . $search_ref . "%')"; + $sql .= " AND (p.ref like '" . $search_ref . "%')"; } if (strlen(trim($search_label))) { - $sql .= " AND (p.label like '" . $search_label . "%')"; + $sql .= " AND (p.label like '" . $search_label . "%')"; } if (strlen(trim($search_desc))) { - $sql .= " AND (p.description like '%" . $search_desc . "%')"; + $sql .= " AND (p.description like '%" . $search_desc . "%')"; } $sql.= $db->order($sortfield,$sortorder); @@ -249,176 +238,170 @@ $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { - $num_lines = $db->num_rows($result); - $i = 0; + $num_lines = $db->num_rows($result); + $i = 0; /* - - * View */ - print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); + print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - print '
' . $langs->trans("DescProductAccountingAccount") . '
'; +print ''; +print ''; +print "\n"; +print ''; +print '\n"; +print ''; +print '\n"; + +print "
'.$langs->trans('OptionMode').''.$langs->trans('Description').'
'.$langs->trans('Accountancy_code_sell').''.nl2br($langs->trans('OptionModeProductSell')); +print "
'.$langs->trans('Accountancy_code_buy').''.nl2br($langs->trans('OptionModeProductBuy'))."
\n"; + +print '

'; + +print "
\n"; -//DEBUG -//print $sql; - print '
'; -// print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
' . $langs->trans("ChangeAccount") . '
'; - print $langs->trans("Accountancy_code_buy") . ': ' . $form->select_account($account_number_buy, 'account_number_buy', 1,'', 0, 1); - print '
'; - print '
'; - print '
' . $langs->trans("ChangeAccount") . '
'; - print $langs->trans("Accountancy_code_sell") . ': ' . $form->select_account($account_number_sell, 'account_number_sell', 1, '', 0, 1); - print '
'; - print '
'; - //TODO change button - print ''; - print '
'; - print ''; - print ''; -// print ''; -// print ''; -// print ''; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); - print ''; - print ''; - print ''; - print ''; - print_liste_field_titre(''); -// print_liste_field_titre(''); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ' '; + print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"p.rowid","",$param,'',$sortfield,$sortorder); + print '  '; - print ''; - print ''; -// print ''; - print ''; - - $var = true; - - while ( $i < min($num_lines, 250) ) { - $obj = $db->fetch_object($result); - $var = ! $var; - - $compta_prodsell = $obj->accountancy_code_sell; - if (empty($compta_prodsell)) { - if ($obj->product_type == 0) { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell; - } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_servsell; - } - } - - $compta_prodbuy = $obj->accountancy_code_buy; - if (empty($compta_prodbuy)) { - if ($obj->product_type == 0) { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_prodbuy; - } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_servbuy; - } - } - - $product_static = new Product($db); - - print ""; -//debug -print ''; + print '
' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Description") . '' . $langs->trans("Accountancy_code_buy") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans("Accountancy_code_sell") . '' . $langs->trans("Accountancy_code_sell_suggest") . '' . $langs->trans("Ventilate") . '
/'.'
%%' . $langs->trans("DescProductAccountingAccount") . ' '; - print ''; -// print ''; - print ' '; - print ''; -// print ''; - print ' 
Compte Suggeres compta_prodbuy=' . $compta_prodbuy . ' -- compta_prodbuy_id' . $compta_prodbuy_id . '-- compta_prodsell:' . $compta_prodsell . '-- compta_prodsell_id' . $compta_prodsell_id . '
'; + print ''; + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); + IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { + print ''; + print ''; + } + else { + print ''; + print ''; + } + print_liste_field_titre(''); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print ""; - print ""; - // Ref produit as link - $product_static->ref = $obj->ref; - $product_static->id = $obj->rowid; - $product_static->type = $obj->type; - print ''; + print ''; + print ''; + print ''; + + $var = true; + + while ( $i < min($num_lines, 250) ) { + $obj = $db->fetch_object($result); + $var = ! $var; + + $compta_prodsell = $obj->accountancy_code_sell; + + if ($obj->product_type == 0) { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell; + } else { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_servsell; + } + + + $compta_prodbuy = $obj->accountancy_code_buy; + + if ($obj->product_type == 0) { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy; + } else { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy; + } + + + $product_static = new Product($db); + + print ""; - print ''; + print ""; + print ""; + // Ref produit as link + $product_static->ref = $obj->ref; + $product_static->id = $obj->rowid; + $product_static->type = $obj->type; + print ''; + print ''; //TODO ADJUST DESCRIPTION SIZE -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size - $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; - print ''; +// print ''; + //TODO: we shoul set a user defined value to adjust user square / wide screen size + $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; + print ''; - //acountingaccount buy - print ''; + //acountingaccount buy + + IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { + print ''; //TODO: replace by select -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; - - //acountingaccount sel - print ''; +// print ''; + //TODO: we shoul set a user defined value to adjust user square / wide screen size + //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; + } + Else { + //acountingaccount sel + print ''; //TODO: replace by select - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; - //action edit & select box - print ''; - print ''; - //Checkbox select - print ''; + //TODO: we shoul set a user defined value to adjust user square / wide screen size + //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; + } + + //Checkbox select + print ''; - print ""; - $i ++; - } + print ""; + $i ++; + } + print '
' . $langs->trans("Accountancy_code_buy") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans("Accountancy_code_sell") . '' . $langs->trans("Accountancy_code_sell_suggest") . '' . $langs->trans("Ventilate") . '
/'.'
%%
'; - if ($product_static->id) - print $product_static->getNomUrl(1); - else - print '- '; - print ' '; + print ''; + print ' '; + print ''; + print '
' . $obj->label . '
'; + if ($product_static->id) + print $product_static->getNomUrl(1); + else + print '- '; + print '' . $obj->label . '' . $obj->description . '' . nl2br(dol_trunc($obj->description, $trunclengh)) . '' . $obj->description . '' . nl2br(dol_trunc($obj->description, $trunclengh)) . '' . $obj->accountancy_code_buy . '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . ''; - print $form->select_account($compta_prodbuy_id, 'codeventil[]', 1); - print '' . $obj->accountancy_code_sell . '' . $compta_prodbuy . ''; + print $form->select_account($compta_prodbuy_id, 'codeventil[]', 1); + print '' . $obj->accountancy_code_sell . ''; - print $form->select_account($compta_prodsell_id, 'codeventil[]', 1); - print '' . $obj->rowid . ''; - print img_edit(); - print ''; - print ''; + print $form->select_account($compta_prodsell_id, 'codeventil[]', 1); + print ''; + print '
'; + print '
'; + print ''; - $db->free($result); + + + $db->free($result); } else { -// print $db->error(); - dol_print_error($db); + dol_print_error($db); } -print ""; + llxFooter(); $db->close(); \ No newline at end of file From 01671d02d1a7dae4ec3031a6986863d5665678ba Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 7 Aug 2015 00:39:44 +0200 Subject: [PATCH 27/55] New pdf for project - listing of elements --- .../project/doc/pdf_beluga.modules.php | 618 ++++++++++++++++++ 1 file changed, 618 insertions(+) create mode 100644 htdocs/core/modules/project/doc/pdf_beluga.modules.php diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php new file mode 100644 index 00000000000..7bca394d161 --- /dev/null +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -0,0 +1,618 @@ + + * Copyright (C) 2015 Charlie Benke + + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/project/doc/pdf_beluga.modules.php + * \ingroup project + * \brief Fichier de la classe permettant de generer les projets au modele beluga + * \author Charlie Benke + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; + +if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + + + +/** + * Classe permettant de generer les projets au modele Baleine + */ + +class pdf_beluga extends ModelePDFProjects +{ + var $emetteur; // Objet societe qui emet + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("projects"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "beluga"; + $this->description = $langs->trans("DocumentModelBeluga"); + + // Dimension page pour format A4 + $this->type = 'pdf'; + $formatarray=pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_codeproduitservice = 1; // Affiche code produit-service + + // Recupere emmetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + + // Defini position des colonnes + $this->posxref=$this->marge_gauche+1; + $this->posxdate=$this->marge_gauche+25; + $this->posxsociety=$this->marge_gauche+45; + $this->posxamountht=$this->marge_gauche+115; + $this->posxamountttc=$this->marge_gauche+140; + $this->posxstatut=$this->marge_gauche+165; + } + + + /** + * Fonction generant le projet sur le disque + * + * @param Project $object Object project a generer + * @param Translate $outputlangs Lang output object + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs) + { + global $user,$langs,$conf; + +$formproject=new FormProjets($this->db); + + if (! is_object($outputlangs)) $outputlangs=$langs; + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("projects"); + + if ($conf->projet->dir_output) + { + //$nblignes = count($object->lines); // This is set later with array of tasks + + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->projet->dir_output; + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return 0; + } + } + + if (file_exists($dir)) + { + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + $pdf->SetAutoPageBreak(1,0); + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + + // Complete object by loading several other informations + $task = new Task($this->db); + $tasksarray = $task->getTasksArray(0,0,$object->id); + + $object->lines=$tasksarray; + $nblignes=count($object->lines); + + $pdf->Open(); + $pagenb=0; + $pdf->SetDrawColor(128,128,128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("Project")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project")); + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + // New page + $pdf->AddPage(); + $pagenb++; + $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); + + $tab_top = 50; + $tab_height = 200; + $tab_top_newpage = 40; + $tab_height_newpage = 210; + + // Affiche notes + if (! empty($object->note_public)) + { + $pdf->SetFont('','', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); + $nexY = $pdf->GetY(); + $height_note=$nexY-($tab_top-2); + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; + +$listofreferent=array( +'propal'=>array( + 'name'=>"Proposals", + 'title'=>"ListProposalsAssociatedProject", + 'class'=>'Propal', + 'table'=>'propal', + 'datefieldname'=>'datep', + 'test'=>$conf->propal->enabled && $user->rights->propale->lire), +'order'=>array( + 'name'=>"CustomersOrders", + 'title'=>"ListOrdersAssociatedProject", + 'class'=>'Commande', + 'table'=>'commande', + 'datefieldname'=>'date_commande', + 'test'=>$conf->commande->enabled && $user->rights->commande->lire), +'invoice'=>array( + 'name'=>"CustomersInvoices", + 'title'=>"ListInvoicesAssociatedProject", + 'class'=>'Facture', + 'margin'=>'add', + 'table'=>'facture', + 'datefieldname'=>'datef', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), +'invoice_predefined'=>array( + 'name'=>"PredefinedInvoices", + 'title'=>"ListPredefinedInvoicesAssociatedProject", + 'class'=>'FactureRec', + 'table'=>'facture_rec', + 'datefieldname'=>'datec', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), +'order_supplier'=>array( + 'name'=>"SuppliersOrders", + 'title'=>"ListSupplierOrdersAssociatedProject", + 'class'=>'CommandeFournisseur', + 'table'=>'commande_fournisseur', + 'datefieldname'=>'date_commande', + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), +'invoice_supplier'=>array( + 'name'=>"BillsSuppliers", + 'title'=>"ListSupplierInvoicesAssociatedProject", + 'class'=>'FactureFournisseur', + 'margin'=>'minus', + 'table'=>'facture_fourn', + 'datefieldname'=>'datef', + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), +'contract'=>array( + 'name'=>"Contracts", + 'title'=>"ListContractAssociatedProject", + 'class'=>'Contrat', + 'table'=>'contrat', + 'datefieldname'=>'date_contrat', + 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), +'intervention'=>array( + 'name'=>"Interventions", + 'title'=>"ListFichinterAssociatedProject", + 'class'=>'Fichinter', + 'table'=>'fichinter', + 'datefieldname'=>'date_valid', + 'disableamount'=>1, + 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), +'trip'=>array( + 'name'=>"TripsAndExpenses", + 'title'=>"ListTripAssociatedProject", + 'class'=>'Deplacement', + 'table'=>'deplacement', + 'datefieldname'=>'dated', + 'margin'=>'minus', + 'disableamount'=>1, + 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), +'agenda'=>array( + 'name'=>"Agenda", + 'title'=>"ListActionsAssociatedProject", + 'class'=>'ActionComm', + 'table'=>'actioncomm', + 'datefieldname'=>'datep', + 'disableamount'=>1, + 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) +); + + +foreach ($listofreferent as $key => $value) +{ + $title=$value['title']; + $classname=$value['class']; + $tablename=$value['table']; + $datefieldname=$value['datefieldname']; + $qualified=$value['test']; + + if ($qualified) + { + $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); + $num=count($elementarray); +if ($num> 0) +{ + $nexY = $pdf->GetY()+5; + $curY = $nexY; + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L'); + + + $selectList=$formproject->select_element($tablename,$project->thirdparty->id); + $nexY = $pdf->GetY()+1; + $curY = $nexY; + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxdate-$this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L'); + $pdf->SetXY($this->posxdate, $curY); + $pdf->MultiCell($this->posxsociety-$this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C'); + $pdf->SetXY($this->posxsociety, $curY); + $pdf->MultiCell($this->posxamountht-$this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L'); + if (empty($value['disableamount'])) + { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxamountttc-$this->posxamountht, 3, $outputlangs->transnoentities("AmountHT"), 1, 'R'); + $pdf->SetXY($this->posxamountttc, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTC"), 1, 'R'); + } + else + { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountht, 3, "", 1, 'R'); + } + $pdf->SetXY($this->posxstatut, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R'); + + + if (is_array($elementarray) && count($elementarray)>0) + { + $nexY = $pdf->GetY(); + $curY = $nexY; + + $total_ht = 0; + $total_ttc = 0; + $num=count($elementarray); + for ($i = 0; $i < $num; $i++) + { + $element = new $classname($this->db); + $element->fetch($elementarray[$i]); + $element->fetch_thirdparty(); + //print $classname; + + $qualifiedfortotal=true; + if ($key == 'invoice') + { + if ($element->close_code == 'replaced') $qualifiedfortotal=false; // Replacement invoice + } + + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxdate-$this->posxref, 3, $element->ref, 1, 'L'); + + + // Date + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') $date=$element->date_commande; + else + { + $date=$element->date; + if (empty($date)) $date=$element->datep; + if (empty($date)) $date=$element->date_contrat; + if (empty($date)) $date=$element->datev; //Fiche inter + } + + $pdf->SetXY($this->posxdate, $curY); + $pdf->MultiCell($this->posxsociety-$this->posxdate, 3, dol_print_date($date,'day'), 1, 'C'); + + $pdf->SetXY($this->posxsociety, $curY); + if (is_object($element->thirdparty)) + $pdf->MultiCell($this->posxamountht-$this->posxsociety, 3, $element->thirdparty->name, 1, 'L'); + + + // Amount without tax + if (empty($value['disableamount'])) + { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxamountttc-$this->posxamountht, 3, + (isset($element->total_ht)?price($element->total_ht):' '), 1, 'R'); + $pdf->SetXY($this->posxamountttc, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountttc, 3, + (isset($element->total_ttc)?price($element->total_ttc):' '), 1, 'R'); + } + else + { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountht, 3, "", 1, 'R'); + } + + // Status + if ($element instanceof CommonInvoice) { + //This applies for Facture and FactureFournisseur + $outputstatut= $element->getLibStatut(1, $element->getSommePaiement()); + } else { + $outputstatut = $element->getLibStatut(1); + } + $pdf->SetXY($this->posxstatut, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxstatut, 3, + $outputstatut, 1, 'R',false, 1, '', '', true, 0, true); + + if ($qualifiedfortotal) + { + $total_ht = $total_ht + $element->total_ht; + $total_ttc = $total_ttc + $element->total_ttc; + } +$nexY = $pdf->GetY(); + $curY = $nexY; + } + + + if (empty($value['disableamount'])) + { + $curY = $nexY; + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxamountttc-$this->posxref, 3, "TOTAL", 1, 'L'); + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxamountttc-$this->posxamountht, 3, + (isset($element->total_ht)?price($total_ht):' '), 1, 'R'); + $pdf->SetXY($this->posxamountttc, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountttc, 3, + (isset($element->total_ttc)?price($total_ttc):' '), 1, 'R'); + $pdf->SetXY($this->posxstatut, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxstatut, 3, + $outputlangs->transnoentities("Nb")." ".$num, 1, 'L'); + } + $nexY = $pdf->GetY()+5; + $curY = $nexY; + } + } +} +} + + + + /* + * Pied de page + */ + $this->_pagefoot($pdf,$object,$outputlangs); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + + $pdf->Close(); + + $pdf->Output($file,'F'); + + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return 0; + } + } + + $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); + return 0; + } + + + /** + * Show table for lines + * + * @param PDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y + * @param Translate $outputlangs Langs object + * @param int $hidetop Hide top bar of array + * @param int $hidebottom Hide bottom bar of array + * @return void + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) + { + global $conf,$mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $pdf->SetDrawColor(128,128,128); + + // Rect prend une longueur en 3eme param + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); + // line prend une position y en 3eme param + $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); + + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size); + + $pdf->SetXY($this->posxref, $tab_top+1); + $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L'); + + $pdf->SetXY($this->posxlabel, $tab_top+1); + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L'); + + $pdf->SetXY($this->posxworkload, $tab_top+1); + $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R'); + + $pdf->SetXY($this->posxprogress, $tab_top+1); + $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R'); + + $pdf->SetXY($this->posxdatestart, $tab_top+1); + $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C'); + + $pdf->SetXY($this->posxdateend, $tab_top+1); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); + + } + + /** + * Show top header of page. + * + * @param PDF $pdf Object PDF + * @param Object $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void + */ + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + { + global $langs,$conf,$mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B', $default_font_size + 3); + + $posx=$this->page_largeur-$this->marge_droite-100; + $posy=$this->marge_haute; + + $pdf->SetXY($this->marge_gauche,$posy); + + // Logo + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; + if ($mysoc->logo) + { + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); + } + } + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); + + $pdf->SetFont('','B', $default_font_size + 3); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); + $pdf->SetFont('','', $default_font_size + 2); + + $posy+=6; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R'); + $posy+=6; + $pdf->SetXY($posx,$posy); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); + + $pdf->SetTextColor(0,0,60); + + } + + /** + * Show footer of page. Need this->emetteur object + * + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return void + */ + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) + { + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + } +} From 9f2b4c503e1bd14fb7235b3e078b447a8307cafa Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 09:57:43 +0200 Subject: [PATCH 28/55] Fix #3236 --- htdocs/langs/en_US/printing.lang | 1 + htdocs/printing/admin/printing.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index b4956e59c01..ce287f91dfe 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -10,6 +10,7 @@ PrintTestDesc=List of Printers. FileWasSentToPrinter=File %s was sent to printer NoActivePrintingModuleFound=No active module to print document PleaseSelectaDriverfromList=Please select a driver from list. +PleaseConfigureDriverfromList=Please configure the selected driver from list. SetupDriver=Driver setup TestDriver=Test TargetedPrinter=Targeted printer diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 36727048fc4..408d7cdfa87 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -229,7 +229,12 @@ if ($mode == 'test' && $user->admin) $langs->load($driver); $printer = new $classname($db); //print '
'.print_r($printer, true).'
'; - print $printer->listAvailablePrinters(); + if ($printer->getlist_available_printers) { + print $printer->listAvailablePrinters(); + } + else { + print $langs->trans('PleaseConfigureDriverfromList'); + } } else { print $langs->trans('PleaseSelectaDriverfromList'); From 0afd27e3c245617ddc2fdfeef1c36fb36f23871f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 7 Aug 2015 13:29:11 +0200 Subject: [PATCH 29/55] New : % of evolution on stats --- htdocs/comm/propal/stats/index.php | 6 ++++++ htdocs/commande/stats/index.php | 6 ++++++ htdocs/compta/facture/stats/index.php | 6 ++++++ htdocs/core/class/stats.class.php | 3 +++ 4 files changed, 21 insertions(+) diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 898f228fdb2..2622a6c239f 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -266,8 +266,11 @@ print ''; print ''; print ''; print ''; +print ''; print ''; +print ''; print ''; +print ''; print ''; $oldyear=0; @@ -287,8 +290,11 @@ foreach ($data as $val) print ''; print ''; print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; $oldyear=$year; } diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 71558be0e57..fd384524597 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -279,8 +279,11 @@ print '
'.$langs->trans("Year").''.$langs->trans("NbOfProposals").'%'.$langs->trans("AmountTotal").'%'.$langs->trans("AmountAverage").'%
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).''.price(price2num($val['total'],'MT'),1).''.round($val['total_diff']).''.price(price2num($val['avg'],'MT'),1).''.round($val['avg_diff']).'
'; print ''; print ''; print ''; +print ''; print ''; +print ''; print ''; +print ''; print ''; $oldyear=0; @@ -302,8 +305,11 @@ foreach ($data as $val) print ''; print ''; print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; $oldyear=$year; } diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 4eeea76abc0..afd17ed2f17 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -263,8 +263,11 @@ print '
'.$langs->trans("Year").''.$langs->trans("NbOfOrders").'%'.$langs->trans("AmountTotal").'%'.$langs->trans("AmountAverage").'%
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).''.price(price2num($val['total'],'MT'),1).''.round($val['total_diff']).''.price(price2num($val['avg'],'MT'),1).''.round($val['avg_diff']).'
'; print ''; print ''; print ''; +print ''; print ''; +print ''; print ''; +print ''; print ''; $oldyear=0; @@ -284,8 +287,11 @@ foreach ($data as $val) print ''; print ''; print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; $oldyear=$year; } diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 9a459f33e41..8ef77f3d282 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -383,8 +383,11 @@ abstract class Stats $row = $this->db->fetch_object($resql); $result[$i]['year'] = $row->year; $result[$i]['nb'] = $row->nb; + if($i>0) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100; $result[$i]['total'] = $row->total; + if($i>0) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100; $result[$i]['avg'] = $row->avg; + if($i>0) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100; $i++; } $this->db->free($resql); From a11962454fc680d52657e92f52f0d794bc150dfa Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 18:18:07 +0200 Subject: [PATCH 30/55] Best way to change ref and ref_supplier --- htdocs/contrat/card.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 0a7acee88ea..1d2e3355b24 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -762,7 +762,6 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra setEventMessage($object->error,'errors'); } } elseif ($action=='setref_supplier') { - $cancelbutton = GETPOST('cancel'); if (!$cancelbutton) { @@ -771,9 +770,8 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra if ($result < 0) { setEventMessage($object->errors, 'errors'); } - $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); - $result = $object->update($user); + $result = $object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); if ($result < 0) { setEventMessage($object->errors, 'errors'); $action = 'editref_supplier'; @@ -794,9 +792,8 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra if ($result < 0) { setEventMessage($object->errors, 'errors'); } - $object->ref = GETPOST('ref', 'alpha'); - $result = $object->update($user); + $result = $object->setValueFrom('ref',GETPOST('ref','alpha'));; if ($result < 0) { setEventMessage($object->errors, 'errors'); $action = 'editref'; From 7cb564586ea3033fabb92c61756f51722bd287ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 9 Aug 2015 13:52:02 +0200 Subject: [PATCH 31/55] Fix: [ bug #3310 ] OrderLine::fetch, FactureLigne::fetch and PropaleLigne::fetch do not return anything Close #3310 --- ChangeLog | 1 + htdocs/comm/propal/class/propal.class.php | 4 +++- htdocs/commande/class/commande.class.php | 4 +++- htdocs/compta/bank/class/account.class.php | 1 - htdocs/compta/facture/class/facture.class.php | 4 +++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6165077d1ca..7662760ad01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,7 @@ Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid Fix: [ bug #3268 ] SQL error when accessing thirdparty log page without a socid parameter Fix: [ bug #3180 ] formObjectOptions hook when editing thirdparty card does not print result Fix: [ bug #1791 ] Margin menu not available if any Finance module is not enabled +Fix: [ bug #3310 ] OrderLine::fetch, FactureLigne::fetch and PropaleLigne::fetch do not return anything ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 1a800dbf944..9cbb6e632fb 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2845,10 +2845,12 @@ class PropaleLigne extends CommonObject $this->date_end = $this->db->jdate($objp->date_end); $this->db->free($result); + + return 1; } else { - dol_print_error($this->db); + return -1; } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d1a776d3d24..a01e2df27c9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3156,10 +3156,12 @@ class OrderLine extends CommonOrderLine $this->date_end = $this->db->jdate($objp->date_end); $this->db->free($result); + + return 1; } else { - dol_print_error($this->db); + return -1; } } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 97e7543a030..77df9e6a3b2 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1133,7 +1133,6 @@ class AccountLine extends CommonObject } else { - dol_print_error($this->db); return -1; } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0d91d7944b8..79de4dbdb8a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3471,10 +3471,12 @@ class FactureLigne extends CommonInvoiceLine $this->product_desc = $objp->product_desc; $this->db->free($result); + + return 1; } else { - dol_print_error($this->db); + return -1; } } From f3ef4fed93cc45bc310b54810ff0198b4121038c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 9 Aug 2015 13:58:03 +0200 Subject: [PATCH 32/55] Fix: [ bug #3313 ] Error enabling module with PostgreSQL database Close #3313 --- ChangeLog | 1 + htdocs/core/class/menubase.class.php | 2 +- htdocs/core/modules/DolibarrModules.class.php | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6165077d1ca..d3347fc30f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,7 @@ Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid Fix: [ bug #3268 ] SQL error when accessing thirdparty log page without a socid parameter Fix: [ bug #3180 ] formObjectOptions hook when editing thirdparty card does not print result Fix: [ bug #1791 ] Margin menu not available if any Finance module is not enabled +Fix: [ bug #3313 ] Error enabling module with PostgreSQL database ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 961cfd5733c..570da8b27fa 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -152,7 +152,7 @@ class Menubase $sql.= " '".$this->fk_menu."',"; $sql.= " ".($this->fk_mainmenu?"'".$this->fk_mainmenu."'":"null").","; $sql.= " ".($this->fk_leftmenu?"'".$this->fk_leftmenu."'":"null").","; - $sql.= " '".$this->position."',"; + $sql.= " '".(int) $this->position."',"; $sql.= " '".$this->db->escape($this->url)."',"; $sql.= " '".$this->db->escape($this->target)."',"; $sql.= " '".$this->db->escape($this->titre)."',"; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index be498b04413..a9b80cef13e 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1009,7 +1009,6 @@ abstract class DolibarrModules $this->db->begin(); - //var_dump($this->menu); exit; foreach ($this->menu as $key => $value) { $menu = new Menubase($this->db); @@ -1018,11 +1017,9 @@ abstract class DolibarrModules if (! $this->menu[$key]['fk_menu']) { $menu->fk_menu=0; - //print 'aaa'.$this->menu[$key]['fk_menu']; } else { - //print 'xxx'.$this->menu[$key]['fk_menu'];exit; $foundparent=0; $fk_parent=$this->menu[$key]['fk_menu']; if (preg_match('/^r=/',$fk_parent)) // old deprecated method From 2f6587b48ecc8c1554f2194503796c0f034909be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 9 Aug 2015 18:08:22 +0200 Subject: [PATCH 33/55] FIX [ bug #3211 ] Error about sold to pay (Montant encours) Close #3211 --- ChangeLog | 1 + htdocs/societe/class/societe.class.php | 1 + 2 files changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index e4815781cd0..119556ecc2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ FIX [ bug 1925 ] "Link to order" option in supplier invoices is not working prop FIX [ bug #3198 ] Trigger LINECONTRACT_INSERT passes Contrat as $object instead of ContratLigne FIX: Not showing delivery date on rouget pdf FIX: Not showing task extrafields when creating from left menu +FIX [ bug #3211 ] Outstading bill amount of a client showed wrong amounts NEW: Created new ContratLigne::insert function diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 649af79e6cc..0869f46c575 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3162,6 +3162,7 @@ class Societe extends CommonObject $sql .= " AND fk_statut <> 0"; // Not a draft //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason $sql .= " AND fk_statut <> 3"; // Not abandonned + $sql .= " AND fk_statut <> 2"; // Not clasified as paid dol_syslog("get_OutstandingBill", LOG_DEBUG); $resql=$this->db->query($sql); From 2500e26072d2409344858cedf1452373e5b13619 Mon Sep 17 00:00:00 2001 From: Darkjeff Date: Mon, 10 Aug 2015 10:29:05 +0200 Subject: [PATCH 34/55] update product account clean sql if buy or sell --- htdocs/accountancy/admin/productaccount.php | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 8d79a81e8e3..7a33a698cd1 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) @@ -102,6 +102,7 @@ if ($action == 'update') { } if ($action == $langs->trans("Change_Account")) +//todo check sql { print '
' . $langs->trans("Processing") . '...
'; if (! empty($codeventil) && ! empty($mesCasesCochees)) @@ -120,7 +121,7 @@ if ($action == $langs->trans("Change_Account")) { $maLigneCourante = explode("_", $maLigneCochee); $monId = $maLigneCourante[0]; - $monNumLigne = $maLigneCourante[2]; + $monNumLigne = $maLigneCourante[1]; $monCompte = $mesCodesVentilChoisis[$monNumLigne]; $sql = " UPDATE " . MAIN_DB_PREFIX . "product"; @@ -212,15 +213,25 @@ print ''; - -$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type"; +$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; $sql .= " WHERE ("; $pcgver = $conf->global->CHARTOFACCOUNTS; IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { -$sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; -$sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN + $sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; + $sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - } - ELSE { -$sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL "; -$sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN +} else { + $sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL "; + $sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - } +} $sql .= ")"; - - - -//Add search filter like +// Add search filter like if (strlen(trim($search_ref))) { $sql .= " AND (p.ref like '" . $search_ref . "%')"; } @@ -242,7 +231,7 @@ if (strlen(trim($search_label))) { if (strlen(trim($search_desc))) { $sql .= " AND (p.description like '%" . $search_desc . "%')"; } -$sql.= $db->order($sortfield,$sortorder); +$sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); @@ -251,71 +240,65 @@ $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); $i = 0; - -/* + + /* * View */ print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - -print '
'; -print ''; -print ''; - -print '
'.$langs->trans("Year").''.$langs->trans("NumberOfBills").'%'.$langs->trans("AmountTotal").'%'.$langs->trans("AmountAverage").'%
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).''.price(price2num($val['total'],'MT'),1).''.round($val['total_diff']).''.price(price2num($val['avg'],'MT'),1).''.round($val['avg_diff']).'
'; -print ''; -print ''; -print "\n"; -print ''; -print '\n"; -print ''; -print '\n"; - -print "
'.$langs->trans('OptionMode').''.$langs->trans('Description').'
'.$langs->trans('Accountancy_code_sell').''.nl2br($langs->trans('OptionModeProductSell')); -print "
'.$langs->trans('Accountancy_code_buy').''.nl2br($langs->trans('OptionModeProductBuy'))."
\n"; - -print '

'; - -print "
\n"; - - - - - - - print '' . $langs->trans("DescProductAccountingAccount") . ' '; - print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"p.rowid","",$param,'',$sortfield,$sortorder); - print '  '; - - - - - + + print ''; + print ''; + print ''; + print ''; print ''; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); - IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { - print ''; - print ''; + print ''; + print "\n"; + print ''; + print '\n"; + print ''; + print '\n"; + + print "
' . $langs->trans("Accountancy_code_buy") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans('OptionMode') . '' . $langs->trans('Description') . '
' . $langs->trans('Accountancy_code_sell') . '' . nl2br($langs->trans('OptionModeProductSell')); + print "
' . $langs->trans('Accountancy_code_buy') . '' . nl2br($langs->trans('OptionModeProductBuy')) . "
\n"; + + print '
'; + + print "
\n"; + + if (! empty($msg)) { + print $msg; } - else { - print '' . $langs->trans("Accountancy_code_sell") . ''; - print '' . $langs->trans("Accountancy_code_sell_suggest") . ''; + + // print '' . $langs->trans("DescProductAccountingAccount") . ' '; + // print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "p.rowid", "", $param, '', $sortfield, $sortorder); + print '  '; + + print ''; + print ''; + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print ''; + // print_liste_field_titre(''); + print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; - - print ''; - print ''; + print ''; print ''; @@ -327,30 +310,28 @@ print "
\n"; $compta_prodsell = $obj->accountancy_code_sell; - if ($obj->product_type == 0) { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell; - } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_servsell; - } - + if ($obj->product_type == 0) { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell; + } else { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_servsell; + } $compta_prodbuy = $obj->accountancy_code_buy; - if ($obj->product_type == 0) { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_prodbuy; - } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_servbuy; - } - + if ($obj->product_type == 0) { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy; + } else { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy; + } $product_static = new Product($db); print ""; - + print ""; print ""; // Ref produit as link @@ -363,56 +344,51 @@ print "
\n"; else print '- '; print ''; - print ''; -//TODO ADJUST DESCRIPTION SIZE -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size + print ''; + // TODO ADJUST DESCRIPTION SIZE + // print ''; + // TODO: we shoul set a user defined value to adjust user square / wide screen size $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; print ''; - - //acountingaccount buy - IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { - print ''; -//TODO: replace by select -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; - } - Else { - - //acountingaccount sel - print ''; -//TODO: replace by select - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; + // acountingaccount buy + + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print ''; + // TODO: replace by select + // print ''; + // TODO: we shoul set a user defined value to adjust user square / wide screen size + // $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; + } else { + + // acountingaccount sel + print ''; + // TODO: replace by select + // TODO: we shoul set a user defined value to adjust user square / wide screen size + // $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; } - //Checkbox select + // Checkbox select print ''; - + print ''; + print ""; $i ++; } - print '
' . $langs->trans("Accountancy_code_buy") . ''; + print '' . $langs->trans("Accountancy_code_buy_suggest") . ''; + } else { + print '' . $langs->trans("Accountancy_code_sell") . ''; + print '' . $langs->trans("Accountancy_code_sell_suggest") . ''; } - print_liste_field_titre(''); - print '' . $langs->trans("Ventilate") . '
/'.'
' . $langs->trans("Ventilate") . '
/' . '
%% '; - print ''; + + print ' '; + print ''; print ' '; - print ''; + print ''; print '
'. dol_trunc($obj->label, 24) . '' . $obj->description . '' . dol_trunc($obj->label, 24) . '' . $obj->description . '' . nl2br(dol_trunc($obj->description, $trunclengh)) . '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . ''; - print $form->select_account($compta_prodbuy_id, 'codeventil[]', 1); - print '' . $obj->accountancy_code_sell . ''; - print $form->select_account($compta_prodsell_id, 'codeventil[]', 1); - print '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . ''; + print $form->select_account($compta_prodbuy_id, 'codeventil_'.$product_static->id, 1); + print '' . $obj->accountancy_code_sell . ''; + print $form->select_account($compta_prodsell_id, 'codeventil_'.$product_static->id, 1); + print ''; - print '
'; - print '
'; - print ''; - - + print ''; + print '
'; + print ''; $db->free($result); } else { dol_print_error($db); } - - llxFooter(); $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 0c79820ea44..988eecfab84 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -65,8 +65,10 @@ class AccountingAccount extends CommonObject * @param string $account_number Account number * @return int <0 if KO, >0 if OK */ - function fetch($rowid = null, $account_number = null) + function fetch($rowid = null, $account_number = null, $limittocurentchart=0) { + global $conf; + if ($rowid || $account_number) { $sql = "SELECT rowid, datec, tms, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, fk_user_author, fk_user_modif, active"; $sql.= " FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE"; @@ -75,7 +77,9 @@ class AccountingAccount extends CommonObject } elseif ($account_number) { $sql .= " account_number = '" . $account_number . "'"; } - + if (!empty($limittocurentchart)) { + $sql .=' AND fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; + } dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -101,7 +105,8 @@ class AccountingAccount extends CommonObject return 0; } } else { - dol_print_error($this->db); + $this->error="Error " . $this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); } } return -1; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index d3a4547c38b..6d82c324fd6 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -24,14 +24,13 @@ * \ingroup Accounting Expert * \brief Ventilation page from customers invoices */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -42,24 +41,25 @@ $langs->load("accountancy"); $action = GETPOST('action'); -//Select Box +// Select Box $codeventil = GETPOST('codeventil', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array'); -//Search Getpost -$search_invoice = GETPOST('search_invoice','alpha'); -$search_ref = GETPOST('search_ref','alpha'); -$search_label = GETPOST('search_label','alpha'); -$search_desc = GETPOST('search_desc','alpha'); -$search_amount = GETPOST('search_amount','alpha'); -$search_account = GETPOST('search_account','alpha'); -$search_vat = GETPOST('search_vat','alpha'); +// Search Getpost +$search_invoice = GETPOST('search_invoice', 'alpha'); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_account = GETPOST('search_account', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); -//Getpost Order and column and limit page -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page'); -if ($page < 0) $page = 0; +// Getpost Order and column and limit page +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page','int'); +if ($page < 0) + $page = 0; if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; @@ -70,7 +70,8 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { } $offset = $limit * $page; -if (! $sortfield) $sortfield="f.datef, f.facnumber, l.rowid"; +if (! $sortfield) + $sortfield = "f.datef, f.facnumber, l.rowid"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { @@ -91,23 +92,23 @@ $aarowid_s = $accounting->fetch('', ACCOUNTING_SERVICE_SOLD_ACCOUNT); $aarowid_p = $accounting->fetch('', ACCOUNTING_PRODUCT_SOLD_ACCOUNT); // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) -{ - $search_ref=''; - $search_invoice=''; - $search_label=''; - $search_desc=''; - $search_amount=''; - $search_account=''; - $search_vat=''; +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { + $search_ref = ''; + $search_invoice = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; } + /* * View */ llxHeader('', $langs->trans("Ventilation")); -print '