From bb8f8332f99de2bbdf3a46eda7e6ec36897349e0 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Tue, 3 Sep 2013 11:12:29 +0200 Subject: [PATCH 01/14] Update modProjet.class.php enhance export feature with left join and projet_task_time data --- htdocs/core/modules/modProjet.class.php | 36 ++++++++++++++----------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 7b9ec52aef6..e8dee7fbc8a 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -177,26 +177,30 @@ class modProjet extends DolibarrModules $this->export_label[$r]='ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("projet","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country', - 's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', - 'p.rowid'=>"ProjectId",'p.ref'=>"ProjectRef",'p.datec'=>"DateCreation",'p.dateo'=>"DateDebutProjet",'p.datee'=>"DateFinProjet",'p.fk_statut'=>'ProjectStatus','p.description'=>"projectNote", - 'pt.rowid'=>'RefTask','pt.dateo'=>"TaskDateo",'pt.datee'=>"TaskDatee",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"DurationPlanned",'pt.progress'=>"Progress",'pt.description'=>"TaskDesc"); + 's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', + 'p.rowid'=>"ProjectId",'p.ref'=>"ProjectRef",'p.datec'=>"DateCreation",'p.dateo'=>"DateDebutProjet",'p.datee'=>"DateFinProjet",'p.fk_statut'=>'ProjectStatus','p.description'=>"projectNote", + 'pt.rowid'=>'RefTask','pt.dateo'=>"TaskDateo",'pt.datee'=>"TaskDatee",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"DurationPlanned",'pt.progress'=>"Progress",'pt.description'=>"TaskDesc", + 'ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"); - //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_pays:libelle', - $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_pays:libelle', - 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text', - 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.description'=>"Text", - 'pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Duree",'pt.progress'=>"Number",'pt.description'=>"Text"); - - $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company', - 's.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - 'f.rowid'=>"project",'f.ref'=>"project",'f.datec'=>"project",'f.duree'=>"project",'f.fk_statut'=>"project",'f.description'=>"project", - 'pt.rowid'=>'task','pt.dateo'=>"task",'pt.datee'=>"task",'pt.duration_effective'=>"task",'pt.planned_workload'=>"task",'pt.progress'=>"task",'pt.description'=>"task"); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_pays:libelle', + 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text', + 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.description'=>"Text", + 'pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Number",'pt.progress'=>"Number",'pt.description'=>"Text", + 'ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:Name",'ptt.note'=>"Text"); + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company', + 's.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', + 'f.rowid'=>"project",'f.ref'=>"project",'f.datec'=>"project",'f.duree'=>"project",'f.fk_statut'=>"project",'f.description'=>"project", + 'pt.rowid'=>'task','pt.dateo'=>"task",'pt.datee'=>"task",'pt.duration_effective'=>"task",'pt.planned_workload'=>"task",'pt.progress'=>"task",'pt.description'=>"task", + 'ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"); + $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'projet as p, '.MAIN_DB_PREFIX.'projet_task as pt, '.MAIN_DB_PREFIX.'societe as s)'; - $this->export_sql_end[$r] .=' WHERE p.fk_soc = s.rowid AND p.rowid = pt.fk_projet '; + $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'projet as p, '.MAIN_DB_PREFIX.'societe as s)'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON (p.rowid = pt.fk_projet)"; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON (pt.rowid = ptt.fk_task)"; + $this->export_sql_end[$r] .=' WHERE p.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' AND p.entity = '.$conf->entity; - $r++; + } From 5e9cb8a1d42aabfe229ee601ef446582549687c5 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 14 Sep 2013 10:45:41 +0200 Subject: [PATCH 02/14] Update modProjet.class.php add export_dependencies_array --- htdocs/core/modules/modProjet.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index e8dee7fbc8a..584a8e3494f 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -176,6 +176,8 @@ class modProjet extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("projet","export")); + $this->export_dependencies_array[$r]=array('task_time'=>'ppt.rowid'); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country', 's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', 'p.rowid'=>"ProjectId",'p.ref'=>"ProjectRef",'p.datec'=>"DateCreation",'p.dateo'=>"DateDebutProjet",'p.datee'=>"DateFinProjet",'p.fk_statut'=>'ProjectStatus','p.description'=>"projectNote", @@ -194,6 +196,7 @@ class modProjet extends DolibarrModules 'pt.rowid'=>'task','pt.dateo'=>"task",'pt.datee'=>"task",'pt.duration_effective'=>"task",'pt.planned_workload'=>"task",'pt.progress'=>"task",'pt.description'=>"task", 'ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"); + $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'projet as p, '.MAIN_DB_PREFIX.'societe as s)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON (p.rowid = pt.fk_projet)"; From 9fdac2aa8e9df021e1d992e1b05dd122f4c0a340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Salvador?= Date: Wed, 18 Sep 2013 11:59:51 +0200 Subject: [PATCH 03/14] changed dol_htmlentities() parameters to match standard htmlentities() --- htdocs/core/lib/functions.lib.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b509c41666a..7e7577f9f3d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3478,16 +3478,17 @@ function dol_html_entity_decode($a,$b,$c='UTF-8') /** * Replace htmlentities functions to manage errors + * http://php.net/manual/en/function.htmlentities.php * - * @param string $a Operand a - * @param string $b Operand b - * @param string $c Operand c - * @return string String encoded + * @param string $string The input string. + * @param int $flags + * @param string $encoding + * @return bool $double_encode When double_encode is turned off PHP will not encode existing html entities */ -function dol_htmlentities($a,$b,$c='UTF-8') +function dol_htmlentities($string, $flags=null, $encoding='UTF-8', $double_encode=false) { // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; - $ret=@htmlentities($a,$b,$c); + $ret=@htmlentities($string, $flags, $encoding, $double_encode); return $ret; } From e0295cefc163bd25fa3e839eba32afb2dd4d7598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Salvador?= Date: Fri, 20 Sep 2013 10:38:17 +0200 Subject: [PATCH 04/14] get thirdparty's contacts as Contact objects --- htdocs/societe/class/societe.class.php | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index bd1fae497f2..dd9ab8f1abf 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1665,6 +1665,41 @@ class Societe extends CommonObject return $contacts; } + /** + * Renvoie la liste des contacts de cette societe + * + * @return array $contacts tableau des contacts + */ + function contact_array_objects() + { + require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + $contacts = array(); + + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = '".$this->id."'"; + $resql=$this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object($resql); + $contact = new Contact($this->db); + $contact->fetch($obj->rowid); + $contacts[] = $contact; + $i++; + } + } + } + else + { + dol_print_error($this->db); + } + return $contacts; + } + /** * Return property of contact from its id * From 81a9bc3960181a1ba7de21d36cd2fa8035f62e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Salvador?= Date: Fri, 20 Sep 2013 10:56:15 +0200 Subject: [PATCH 05/14] checkstyle --- htdocs/core/lib/functions.lib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7e7577f9f3d..7b21c9ca20c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3480,10 +3480,11 @@ function dol_html_entity_decode($a,$b,$c='UTF-8') * Replace htmlentities functions to manage errors * http://php.net/manual/en/function.htmlentities.php * - * @param string $string The input string. - * @param int $flags - * @param string $encoding - * @return bool $double_encode When double_encode is turned off PHP will not encode existing html entities + * @param string $string The input string. + * @param int $flags Flags(see PHP doc above) + * @param string $encoding Encoding + * @param bool $double_encode When double_encode is turned off PHP will not encode existing html entities + * @return string $ret Encoded string */ function dol_htmlentities($string, $flags=null, $encoding='UTF-8', $double_encode=false) { From 53979ad58cbcc905481366579026933ac097ffc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Sep 2013 14:29:09 +0200 Subject: [PATCH 06/14] Fix: Bad param --- htdocs/compta/bank/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index 407a5398dc5..62ef1957f45 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -71,7 +71,7 @@ if ($_POST["action"] == 'add') $account->currency_code = trim($_POST["account_currency_code"]); - $account->state_id = $_POST["account_departement_id"]; + $account->state_id = $_POST["account_state_id"]; $account->country_id = $_POST["account_country_id"]; $account->min_allowed = $_POST["account_min_allowed"]; From bb2404c16dad52fc900c1316b41124136e267cb0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Sep 2013 21:57:33 +0200 Subject: [PATCH 07/14] Remove duplicate file for distributions to avoid warnings --- build/makepack-dolibarr.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index c39c66b6e7b..49deff65c33 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -340,6 +340,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/template`; # Package not valid for most linux distributions (errors reported into compile.js). Package should be embed by modules to avoid problems. $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpmailer`; # Package not valid for most linux distributions (errors reported into file LICENSE). Package should be embed by modules to avoid problems. + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/license.txt`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PDF`; From b74f73c8853053e2dbfe34a44485481c5d9fa5ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Sep 2013 10:53:46 +0200 Subject: [PATCH 08/14] Fix: Calculation of deposit amount when using a percent was done only on last line. --- htdocs/compta/facture.php | 94 +++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index bd058a9418e..02a60d4764a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1,28 +1,28 @@ * Copyright (C) 2004 Eric Seigne -* Copyright (C) 2004-2013 Laurent Destailleur -* Copyright (C) 2005 Marc Barilley / Ocebo -* Copyright (C) 2005-2012 Regis Houssin -* Copyright (C) 2006 Andre Cianfarani -* Copyright (C) 2010-2013 Juanjo Menent -* Copyright (C) 2012 Christophe Battarel -* Copyright (C) 2013 Jean-Francois FERRY -* Copyright (C) 2013 Florian Henry -* -* 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 . -*/ + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2013 Jean-Francois FERRY + * Copyright (C) 2013 Florian Henry + * + * 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 . + */ /** * \file htdocs/compta/facture.php @@ -100,7 +100,7 @@ $hookmanager->initHooks(array('invoicecard')); /* * Actions -*/ + */ $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -872,14 +872,18 @@ else if ($action == 'add' && $user->rights->facture->creer) if ($id > 0) { - //If deposit invoice - if ($_POST['type'] == 3) { + // If deposit invoice + if ($_POST['type'] == 3) + { $typeamount=GETPOST('typedeposit','alpha'); $valuedeposit=GETPOST('valuedeposit','int'); - if ($typeamount=='amount') { + if ($typeamount=='amount') + { $amountdeposit=$valuedeposit; - }else { + } + else + { $amountdeposit=0; dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); @@ -887,19 +891,20 @@ else if ($action == 'add' && $user->rights->facture->creer) $classname = ucfirst($subelement); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add deposit line"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add deposit lines"); $result=$srcobject->fetch($object->origin_id); if ($result > 0) { $totalamount=0; $lines = $srcobject->lines; - $num=count($lines); - for ($i=0;$i<$num;$i++) + $numlines=count($lines); + for ($i=0; $i<$numlines; $i++) { - $totalamount=+$lines[$i]->subprice; + $totalamount += $lines[$i]->subprice; } - if ($totalamount!=0) { + if ($totalamount!=0) + { $amountdeposit=($totalamount*$valuedeposit)/100; } } @@ -1537,7 +1542,7 @@ else if ($action == 'down' && $user->rights->facture->creer) /* * Add file in email form -*/ + */ if (GETPOST('addfile')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1552,7 +1557,7 @@ if (GETPOST('addfile')) /* * Remove file in email form -*/ + */ if (! empty($_POST['removedfile'])) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1568,7 +1573,7 @@ if (! empty($_POST['removedfile'])) /* * Send mail -*/ + */ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) { $langs->load('mails'); @@ -1742,7 +1747,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO /* * Generate document -*/ + */ else if ($action == 'builddoc') // En get ou en post { $object->fetch($id); @@ -2000,8 +2005,7 @@ if ($action == 'create') // Ref print ''.$langs->trans('Ref').''.$langs->trans('Draft').''; - // Tiers - print ''; + // Thirdparty print ''.$langs->trans('Customer').''; if($soc->id > 0) { @@ -2018,7 +2022,7 @@ if ($action == 'create') } print ''."\n"; - // Factures predefinies + // Predefined invoices if (empty($origin) && empty($originid) && $socid > 0) { $sql = 'SELECT r.rowid, r.titre, r.total_ttc'; @@ -2125,10 +2129,13 @@ if ($action == 'create') print ''; $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); print ''; - if (($origin=='propal') ) { - print ''; - print ''; + print '
'.$desc.''.$langs->trans('Value').':'; + if (($origin=='propal')) + { + print ''; + $arraylist=array('amount'=>'FixAmount','variable'=>'VarAmount'); + print $form->selectarray('typedeposit',$arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); + print ''.$langs->trans('Value').':'; } print '
'; print ''."\n"; @@ -2395,6 +2402,7 @@ if ($action == 'create') print ''; } + print '
'; } else if ($id > 0 || ! empty($ref)) { From fd564f5c7d8f9001ece53d93abf1ff8d474af5dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Sep 2013 12:30:44 +0200 Subject: [PATCH 09/14] Optimize cookie usage for boxes. Only 1 cookie per box, instead of 1 cookie per parameter. --- .../boxes/box_graph_invoices_permonth.php | 26 +++++++++++----- .../box_graph_invoices_supplier_permonth.php | 26 +++++++++++----- .../core/boxes/box_graph_orders_permonth.php | 26 +++++++++++----- .../box_graph_orders_supplier_permonth.php | 26 +++++++++++----- .../boxes/box_graph_product_distribution.php | 31 +++++++++++++------ .../boxes/box_graph_propales_permonth.php | 26 +++++++++++----- htdocs/main.inc.php | 18 ++++++++--- 7 files changed, 130 insertions(+), 49 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 159c834ea9e..c8fc4a917f2 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -83,17 +83,29 @@ class box_graph_invoices_permonth extends ModeleBoxes if ($user->rights->facture->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='customer'; $userid=0; @@ -191,7 +203,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.='
'; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 6c4c18824d6..45f3be02933 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -82,17 +82,29 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if ($user->rights->fournisseur->facture->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='supplier'; $userid=0; @@ -190,7 +202,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 8c33c138623..17fc0215fef 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -83,17 +83,29 @@ class box_graph_orders_permonth extends ModeleBoxes if ($user->rights->commande->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='customer'; $userid=0; @@ -191,7 +203,7 @@ class box_graph_orders_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index d85b0f7a09c..61cc4f8fe87 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -82,17 +82,29 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if ($user->rights->fournisseur->commande->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='supplier'; $userid=0; @@ -190,7 +202,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index e2b6dfe907c..a39b0acf1cb 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -82,20 +82,33 @@ class box_graph_product_distribution extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_showinvoicenb='DOLUSERCOOKIE_param'.$this->boxcode.'showinvoicenb'; - $param_showpropalnb='DOLUSERCOOKIE_param'.$this->boxcode.'showpropalnb'; - $param_showordernb='DOLUSERCOOKIE_param'.$this->boxcode.'showordernb'; - $showinvoicenb=GETPOST($param_showinvoicenb,'alpha',4); - $showpropalnb=GETPOST($param_showpropalnb,'alpha',4); - $showordernb=GETPOST($param_showordernb,'alpha',4); + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_showinvoicenb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb'; + $param_showpropalnb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb'; + $param_showordernb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb'; + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $year=GETPOST($param_year,'int'); + $showinvoicenb=GETPOST($param_showinvoicenb,'alpha'); + $showpropalnb=GETPOST($param_showpropalnb,'alpha'); + $showordernb=GETPOST($param_showordernb,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $year=$tmparray['year']; + $showinvoicenb=$tmparray['showinvoicenb']; + $showpropalnb=$tmparray['showpropalnb']; + $showordernb=$tmparray['showordernb']; + } if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; } if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0; if (empty($conf->propal->enabled) || empty($user->rights->propal->lire)) $showpropalnb=0; if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0; $nowarray=dol_getdate(dol_now(),true); - $year=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($year)) $year=$nowarray['year']; $nbofgraph=0; if ($showinvoicenb) $nbofgraph++; @@ -300,7 +313,7 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire)) { $stringtoshow.=' '.$langs->trans("ForCustomersInvoices"); diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index e09b19b45ad..8fd42d525fd 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -83,17 +83,29 @@ class box_graph_propales_permonth extends ModeleBoxes if ($user->rights->propal->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='customer'; $userid=0; @@ -196,7 +208,7 @@ class box_graph_propales_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfProposalsByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfProposalsByMonthHT"); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5deef696da0..59974316021 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -165,13 +165,21 @@ require_once 'filefunc.inc.php'; // If there is a POST parameter to tell to save automatically some POST params into a cookies, we do it if (! empty($_POST["DOL_AUTOSET_COOKIE"])) { - $tmplist=explode(',',$_POST["DOL_AUTOSET_COOKIE"]); - foreach ($tmplist as $value) + require_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmpautoset=explode(':',$_POST["DOL_AUTOSET_COOKIE"],2); + $tmplist=explode(',',$tmpautoset[1]); + $cookiearrayvalue=''; + foreach ($tmplist as $tmpkey) { - //var_dump('setcookie key='.$value.' value='.$_POST[$value]); - setcookie($value, empty($_POST[$value])?'':$_POST[$value], empty($_POST[$value])?0:(time()+(86400*354)), '/'); // keep cookie 1 year - if (empty($_POST[$value])) unset($_COOKIE[$value]); + $postkey=$tmpautoset[0].'_'.$tmpkey; + //var_dump('tmpkey='.$tmpkey.' postkey='.$postkey.' value='.$_POST[$postkey]); + if (! empty($_POST[$postkey])) $cookiearrayvalue[$tmpkey]=$_POST[$postkey]; } + $cookiename=$tmpautoset[0]; + $cookievalue=dol_json_encode($cookiearrayvalue); + //var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue); + setcookie($cookiename, empty($cookievalue)?'':$cookievalue, empty($cookievalue)?0:(time()+(86400*354)), '/'); // keep cookie 1 year + if (empty($cookievalue)) unset($_COOKIE[$cookiename]); } // Init session. Name of session is specific to Dolibarr instance. From 44d2fbcb1a4ee6f09a51d7dea418e890011ff9c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Sep 2013 19:41:14 +0200 Subject: [PATCH 10/14] A better tag command --- build/debian/README.howto | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/debian/README.howto b/build/debian/README.howto index abfa7f456fb..4978b686070 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -139,11 +139,11 @@ Warning: Name and email must match value into debian/control file (Entry added h > git-buildpackage -us -uc Note: You can use git-buildpackage -us -uc --git-ignore-new if you want to test build with uncommited file - +Note: Package is built into directory ../build-area * If package .deb is ok: Note: If there was errors managed manually, you may need to make a git commit but do not use option "amend" previous commit -> git-buildpackage --git-tag +> git-buildpackage --git-tag-only --git-retag > git push --all ou git push origin --all > git push --tags @@ -195,10 +195,11 @@ Warning: Name and email must match value into debian/control file (Entry added h > git-buildpackage -us -uc Note: You can use git-buildpackage -us -uc --git-ignore-new if you want to test build with uncommited file +Note: Package is built into directory ../build-area * If package .deb is ok: Note: If there was errors managed manually, you may need to make a git commit but do not use option "amend" previous commit -> git-buildpackage --git-tag +> git-buildpackage --git-tag-only --git-retag > git push --all ou git push origin --all > git push --tags From ad09470f48dbbf8374171c82847145e916c7c79e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Sep 2013 19:53:27 +0200 Subject: [PATCH 11/14] Fix: Better management of pdf generation when tcpdf not available. --- htdocs/core/modules/action/rapport.pdf.php | 2 +- .../modules/cheque/pdf/pdf_blochet.class.php | 2 +- .../commande/doc/pdf_einstein.modules.php | 2 +- .../doc/pdf_expedition_merou.modules.php | 4 +- .../doc/pdf_expedition_rouget.modules.php | 4 +- .../modules/facture/doc/pdf_crabe.modules.php | 2 +- .../fichinter/doc/pdf_soleil.modules.php | 2 +- .../livraison/pdf/pdf_typhon.modules.php | 52 +++++++++---------- .../project/pdf/pdf_baleine.modules.php | 2 +- .../modules/propale/doc/pdf_azur.modules.php | 2 +- .../modules/rapport/pdf_paiement.class.php | 2 +- .../pdf/pdf_canelle.modules.php | 2 +- .../pdf/pdf_muscadet.modules.php | 2 +- 13 files changed, 40 insertions(+), 40 deletions(-) diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index 1a04322d68b..1ae875fc7fb 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -145,7 +145,7 @@ class CommActionRapport $nbpage = $this->_pages($pdf, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file,'F'); diff --git a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php index c2023f10924..bec2b079883 100644 --- a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php @@ -161,7 +161,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts // Pied de page $this->_pagefoot($pdf,'',$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 538a5b02be8..2316396d370 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -471,7 +471,7 @@ class pdf_einstein extends ModelePDFCommandes // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php index 42598a2094d..97cf267844c 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php @@ -169,7 +169,7 @@ class pdf_expedition_merou extends ModelePdfExpedition $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Sending")); @@ -302,7 +302,7 @@ class pdf_expedition_merou extends ModelePdfExpedition // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php index e3113689726..3f321607f86 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php @@ -155,7 +155,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Sending")); @@ -322,7 +322,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index d0c7a9972d8..b6909274ce5 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -473,7 +473,7 @@ class pdf_crabe extends ModelePDFFactures // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 953466ec88a..a10b207523f 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -320,7 +320,7 @@ class pdf_soleil extends ModelePDFFicheinter } $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index adf1b8689b1..a55401156f4 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -162,7 +162,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $dir = $conf->expedition->dir_output."/receipt/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } - + if (! file_exists($dir)) { if (dol_mkdir($dir) < 0) @@ -175,7 +175,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (file_exists($dir)) { $nblines = count($object->lines); - + // Create pdf instance $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance @@ -288,7 +288,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $curX = $this->posxdesc-1; $showpricebeforepagebreak=1; - + $pdf->startTransaction(); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxcomm-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); @@ -320,7 +320,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder { $pdf->commitTransaction(); } - + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); $pdf->setPage($pageposbefore); @@ -429,11 +429,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Affiche zone infos $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - + // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); - + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + // Check product remaining to be delivered // TODO doit etre modifie //$waitingDelivery = $object->getRemainingDelivered(); @@ -492,7 +492,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); }*/ $pdf->Close(); @@ -539,20 +539,20 @@ class pdf_typhon extends ModelePDFDeliveryOrder { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); - + $pdf->SetFont('','', $default_font_size); $pdf->SetXY($this->marge_gauche, $posy); - + $larg_sign = ($this->page_largeur-$this->marge_gauche-$this->marge_droite)/3; $pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25); $pdf->SetXY($this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign,2, $outputlangs->trans("For").' '.$outputlangs->convToOutputCharset($mysoc->name).":",'','L'); - + $pdf->Rect(2*$larg_sign+$this->marge_gauche, $posy + 1, $larg_sign, 25); $pdf->SetXY(2*$larg_sign+$this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign,2, $outputlangs->trans("ForCustomer").':','','L'); } - + /** * Show table for lines * @@ -568,13 +568,13 @@ class pdf_typhon extends ModelePDFDeliveryOrder function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) { global $conf,$mysoc; - + // Force to disable hidetop and hidebottom $hidebottom=0; if ($hidetop) $hidetop=-1; - + $default_font_size = pdf_getPDFFontSize($outputlangs); - + // Amount in (at tab_top - 1) $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -586,11 +586,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder { $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); } - + $pdf->SetDrawColor(128,128,128); $pdf->SetFont('','', $default_font_size - 1); - if (empty($hidetop)) + if (empty($hidetop)) { $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell($this->posxcomm - $this->posxdesc,2, $outputlangs->transnoentities("Designation"),'','L'); @@ -634,15 +634,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder { pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); } - + $pdf->SetTextColor(0,0,60); $pdf->SetFont('','B', $default_font_size + 3); - + $posy=$this->marge_haute; $posx=$this->page_largeur-$this->marge_droite-100; - + $pdf->SetXY($this->marge_gauche,$posy); - + // Logo $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) @@ -694,21 +694,21 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetTextColor(0,0,60); $posy+=2; - + // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); - + if ($showaddress) { // Sender properties $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); - + // Show sender $posy=42; $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; $hautcadre=40; - + // Show sender frame $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -728,7 +728,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetXY($posx+2,$posy+8); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); - + // Client destinataire $posy=42; $pdf->SetTextColor(0,0,0); diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php index 1befddf2168..a09ee857a96 100644 --- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php @@ -287,7 +287,7 @@ class pdf_baleine extends ModelePDFProjects * Pied de page */ $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index ed63d09715b..03864e1a572 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -471,7 +471,7 @@ class pdf_azur extends ModelePDFPropales // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 8ef322a0a0c..b7e2f8e5d91 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -210,7 +210,7 @@ class pdf_paiement $this->Body($pdf, 1, $lines, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 1477b202878..1d04d8f3165 100755 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -407,7 +407,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 4141190f451..0227ae8187a 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -425,7 +425,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); From 2bf4a2bdb8489227b9d1ce069f4d42ab77bf00e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Sep 2013 21:02:42 +0200 Subject: [PATCH 12/14] Missing project label --- htdocs/comm/action/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 94941d53e6c..81723b8283d 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -1003,7 +1003,7 @@ if ($id > 0) { $project=new Project($db); $project->fetch($act->fk_project); - print $project->getNomUrl(1); + print $project->getNomUrl(1,'',1); } print ''; } From 9a475e9ed2414c1a3dbd7d89c6056b2040fa065c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Sep 2013 23:54:01 +0200 Subject: [PATCH 13/14] New: Add method to use a dictionnary as a combo box. --- ChangeLog | 1 + htdocs/core/class/html.formother.class.php | 61 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9ca1cc847e7..b6de1a1d94f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -85,6 +85,7 @@ For developers: - New: Add hook addHomeSetup. - New: Add trigger CATEGORY_LINK and CATEGORY_UNLINK. - New: A trigger can return an array of error strings instead of one error string. +- New: Add method to use a dictionnary as a combo box. WARNING: Following change may create regression for some external modules, but was necessary to make Dolibarr better: diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 15bb2f9acf5..1ee016c6ee7 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1084,6 +1084,67 @@ class FormOther } + /** + * Return a HTML select list of bank accounts + * + * @param string $htmlname Name of select zone + * @param string $dictionnarytable Dictionnary table + * @param string $keyfield Field for key + * @param string $labelfield Label field + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @return void + */ + function select_dictionnary($htmlname,$dictionnarytable,$keyfield='code',$labelfield='label',$selected='',$useempty=0) + { + global $langs, $conf; + + $langs->load("admin"); + + $sql = "SELECT rowid, ".$keyfield.", ".$labelfield; + $sql.= " FROM ".MAIN_DB_PREFIX.$dictionnarytable; + $sql.= " ORDER BY ".$labelfield; + + dol_syslog(get_class($this)."::select_dictionnary sql=".$sql); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + if ($num) + { + print '"; + } + else + { + print $langs->trans("DictionnaryEmpty"); + } + } + else { + dol_print_error($this->db); + } + } + } ?> From 31d3e419b2522aecc998dcca7ac24dec569042e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Sep 2013 09:35:16 +0200 Subject: [PATCH 14/14] Fix: doxygen --- htdocs/core/class/html.formother.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 1ee016c6ee7..aec3884ac15 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1091,6 +1091,7 @@ class FormOther * @param string $dictionnarytable Dictionnary table * @param string $keyfield Field for key * @param string $labelfield Label field + * @param string $selected Selected value * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */