From 6ac08c3bee4ca8cac8a2be589a0fd63dc95e3bb9 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 29 May 2017 10:32:17 +0200 Subject: [PATCH 001/428] Fix : Product supplier price is related to supplier's currency --- htdocs/fourn/class/fournisseur.commande.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 245947932a3..df48e35c01d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1408,7 +1408,8 @@ class CommandeFournisseur extends CommonOrder $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', $this->fk_soc); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc if ($result > 0) { - $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $pu = 0; // Unit price supplier price set by get_buyprice + $pu_ht_devise = $prod->fourn_pu; // With multicurrency, supplier price is related to its currency, $pu will be calculated (= $pu_ht_devise if exchange rate is 1) $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice } if ($result == 0) // If result == 0, we failed to found the supplier reference price From 44dba391c11a2a579771a2ee627e6fd13db4e50d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 8 Jun 2017 10:24:16 +0200 Subject: [PATCH 002/428] New: add dictionnary sharing (multicompany) --- htdocs/admin/dict.php | 24 +++++------ htdocs/core/lib/functions.lib.php | 40 ++++++++++++------- .../install/mysql/migration/5.0.0-6.0.0.sql | 10 ++++- .../mysql/tables/llx_c_paiement.key.sql | 5 ++- .../install/mysql/tables/llx_c_paiement.sql | 11 +++-- .../mysql/tables/llx_c_payment_term.key.sql | 20 ++++++++++ .../mysql/tables/llx_c_payment_term.sql | 26 ++++++------ 7 files changed, 89 insertions(+), 47 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_c_payment_term.key.sql diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 22e7bf7087f..838f76aa296 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1,16 +1,16 @@ - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand - * Copyright (C) 2011 Remy Younes - * Copyright (C) 2012-2015 Marcos García - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2016 Alexandre Spangaro - * Copyright (C) 2015 Ferran Marcet - * Copyright (C) 2016 Raphaël Doursenaud +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2010-2016 Juanjo Menent + * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011 Remy Younes + * Copyright (C) 2012-2015 Marcos García + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2015 Ferran Marcet + * Copyright (C) 2016 Raphaël Doursenaud * * 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 diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5113c9f1d96..454607d7dd1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -102,18 +102,21 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) /** * Get list of entity id to use. * - * @param string $element Current element - * 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource', - * 'product', 'productprice', 'stock', - * 'propal', 'supplier_proposal', 'facture', 'facture_fourn', - * 'categorie', 'bank_account', 'bank_account', 'adherent', 'user', - * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', - * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', - * 'email_template', 'event', - * @param int $shared 1=Return id of current entity + shared entities (default), 0=Return id of current entity only + * @param string $element Current element + * 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource', + * 'product', 'productprice', 'stock', + * 'propal', 'supplier_proposal', 'facture', 'facture_fourn', + * 'categorie', 'bank_account', 'bank_account', 'adherent', 'user', + * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', + * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', + * 'email_template', 'event', + * @param int $shared 0=Return id of current entity only, + * 1=Return id of current entity + shared entities (default), + * 2=Return id of current entity OR $forceentity value (eg. dictionnary share) + * @param int $forceentity Entity id * @return mixed Entity id(s) to use */ -function getEntity($element=false, $shared=1) +function getEntity($element=false, $shared=1, $forceentity=null) { global $conf, $mc; @@ -124,14 +127,23 @@ function getEntity($element=false, $shared=1) if (is_object($mc)) { - return $mc->getEntity($element, $shared); + return $mc->getEntity($element, $shared, $forceentity); } else { $out=''; - $addzero = array('user', 'usergroup', 'email_template', 'default_values'); - if (in_array($element, $addzero)) $out.= '0,'; - $out.= $conf->entity; + + if ($shared == 2) + { + $out.= $forceentity; + } + else + { + $addzero = array('user', 'usergroup', 'email_template', 'default_values'); + if (in_array($element, $addzero)) $out.= '0,'; + $out.= $conf->entity; + } + return $out; } } diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 317fb6b7ff2..db67c58e51a 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -380,4 +380,12 @@ create table llx_loan_schedule fk_user_modif integer )ENGINE=innodb; -ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms; \ No newline at end of file +ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms; + +ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id; +ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement; +ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(entity, code); + +ALTER TABLE llx_c_payment_term ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; +ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(entity, code); + diff --git a/htdocs/install/mysql/tables/llx_c_paiement.key.sql b/htdocs/install/mysql/tables/llx_c_paiement.key.sql index 0d6686a774c..8c944e0c34d 100644 --- a/htdocs/install/mysql/tables/llx_c_paiement.key.sql +++ b/htdocs/install/mysql/tables/llx_c_paiement.key.sql @@ -1,5 +1,6 @@ -- ======================================================================== --- Copyright (C) 2012 Florian Henry +-- Copyright (C) 2012 Florian Henry +-- Copyright (C) 2017 Regis Houssin -- -- 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 @@ -16,4 +17,4 @@ -- -- ======================================================================== -ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(code); +ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(entity, code); diff --git a/htdocs/install/mysql/tables/llx_c_paiement.sql b/htdocs/install/mysql/tables/llx_c_paiement.sql index 1759af781f8..85e3cfb404d 100644 --- a/htdocs/install/mysql/tables/llx_c_paiement.sql +++ b/htdocs/install/mysql/tables/llx_c_paiement.sql @@ -1,7 +1,8 @@ -- ======================================================================== --- Copyright (C) 2001-2004 Rodolphe Quiedeville --- Copyright (C) 2004-2014 Laurent Destailleur --- Copyright (C) 2014 Alexandre Spangaro +-- Copyright (C) 2001-2004 Rodolphe Quiedeville +-- Copyright (C) 2004-2014 Laurent Destailleur +-- Copyright (C) 2014 Alexandre Spangaro +-- Copyright (C) 2017 Regis Houssin -- -- 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 @@ -21,6 +22,7 @@ create table llx_c_paiement ( id integer PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id code varchar(6) NOT NULL, libelle varchar(62), type smallint, -- 0: input money, 1: output money, 2: input and output, 3: other @@ -28,6 +30,3 @@ create table llx_c_paiement accountancy_code varchar(32) NULL, module varchar(32) NULL )ENGINE=innodb; - - - diff --git a/htdocs/install/mysql/tables/llx_c_payment_term.key.sql b/htdocs/install/mysql/tables/llx_c_payment_term.key.sql new file mode 100644 index 00000000000..e5977adf3cd --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_payment_term.key.sql @@ -0,0 +1,20 @@ +-- ======================================================================== +-- Copyright (C) 2012 Florian Henry +-- Copyright (C) 2017 Regis Houssin +-- +-- 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 . +-- +-- ======================================================================== + +ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(entity, code); diff --git a/htdocs/install/mysql/tables/llx_c_payment_term.sql b/htdocs/install/mysql/tables/llx_c_payment_term.sql index a2d79af2502..6c55a6742b2 100644 --- a/htdocs/install/mysql/tables/llx_c_payment_term.sql +++ b/htdocs/install/mysql/tables/llx_c_payment_term.sql @@ -1,6 +1,7 @@ -- ============================================================================ --- Copyright (C) 2002-2003 Rodolphe Quiedeville --- Copyright (C) 2016 Laurent Destailleur +-- Copyright (C) 2002-2003 Rodolphe Quiedeville +-- Copyright (C) 2016 Laurent Destailleur +-- Copyright (C) 2017 Regis Houssin -- -- 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 @@ -19,14 +20,15 @@ create table llx_c_payment_term ( - rowid integer PRIMARY KEY, - code varchar(16), - sortorder smallint, - active tinyint DEFAULT 1, - libelle varchar(255), - libelle_facture text, - type_cdr tinyint, -- Type of change date reckoning. 1=Payment at end of current month, 2=the Nth of next month - nbjour smallint, - decalage smallint, - module varchar(32) NULL + rowid integer PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + code varchar(16), + sortorder smallint, + active tinyint DEFAULT 1, + libelle varchar(255), + libelle_facture text, + type_cdr tinyint, -- Type of change date reckoning. 1=Payment at end of current month, 2=the Nth of next month + nbjour smallint, + decalage smallint, + module varchar(32) NULL )ENGINE=innodb; From ade915af5f0485bf2d2a468af55df11fd50f09b7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 8 Jun 2017 15:32:08 +0200 Subject: [PATCH 003/428] New: add dictionnary sharing (multicompany) --- htdocs/admin/dict.php | 85 +++++++++++++------ htdocs/core/lib/admin.lib.php | 20 ++--- htdocs/core/lib/functions.lib.php | 17 +--- .../install/mysql/migration/5.0.0-6.0.0.sql | 6 +- .../mysql/tables/llx_c_paiement.key.sql | 2 +- .../install/mysql/tables/llx_c_paiement.sql | 2 +- .../mysql/tables/llx_c_payment_term.key.sql | 2 +- .../mysql/tables/llx_c_payment_term.sql | 2 +- 8 files changed, 83 insertions(+), 53 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 86652fd7614..1f27fdd9dad 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -54,6 +54,7 @@ $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); $id=GETPOST('id','int'); $rowid=GETPOST('rowid','alpha'); +$entity=GETPOST('entity','int'); $allowed=$user->admin; if ($id == 7 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Tax page allowed to manager of chart account @@ -72,7 +73,7 @@ $active = 1; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if (empty($page) || $page == -1) { $page = 0 ; } $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; @@ -176,8 +177,8 @@ $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c"; $tabsql[10]= "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[11]= "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; -$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder FROM ".MAIN_DB_PREFIX.'c_payment_term AS c'; -$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code FROM ".MAIN_DB_PREFIX."c_paiement AS c"; +$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = " . getEntity($tabname[12], 2); +$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = " . getEntity($tabname[13], 2); $tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; $tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format"; $tabsql[16]= "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel"; @@ -250,8 +251,8 @@ $tabfield[8] = "code,libelle,country_id,country".(! empty($conf->global->SOCIETE $tabfield[9] = "code,label,unicode"; $tabfield[10]= "country_id,country,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[11]= "element,source,code,libelle,position"; -$tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; -$tabfield[13]= "code,libelle,type,accountancy_code"; +$tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; +$tabfield[13]= "code,libelle,type,accountancy_code,entity"; $tabfield[14]= "code,libelle,price,organization,country_id,country"; $tabfield[15]= "code,libelle,width,height,unit"; $tabfield[16]= "code,libelle,sortorder"; @@ -324,8 +325,8 @@ $tabfieldinsert[8] = "code,libelle,fk_country".(! empty($conf->global->SOCIETE_S $tabfieldinsert[9] = "code_iso,label,unicode"; $tabfieldinsert[10]= "fk_pays,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[11]= "element,source,code,libelle,position"; -$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; -$tabfieldinsert[13]= "code,libelle,type,accountancy_code"; +$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; +$tabfieldinsert[13]= "code,libelle,type,accountancy_code,entity"; $tabfieldinsert[14]= "code,libelle,price,organization,fk_pays"; $tabfieldinsert[15]= "code,label,width,height,unit"; $tabfieldinsert[16]= "code,label,sortorder"; @@ -703,7 +704,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); } else if ($value == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; + $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id], 2); } if ($i) $sql.=","; if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' @@ -751,7 +752,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); } else if ($field == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; + $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id], 2); } if ($i) $sql.=","; $sql.= $field."="; @@ -760,6 +761,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; + $sql.= " AND entity = '".getEntity($tabname[$id], 2)."'"; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; @@ -782,7 +784,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } - $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; + $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); @@ -806,10 +808,10 @@ if ($action == $acts[0]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($_GET["code"])."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity >= 0 ? " AND entity = " . $entity: ''); } $result = $db->query($sql); @@ -826,10 +828,10 @@ if ($action == $acts[1]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($_GET["code"])."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity >= 0 ? " AND entity = " . $entity: ''); } $result = $db->query($sql); @@ -846,10 +848,10 @@ if ($action == 'activate_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($_GET["code"])."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity >= 0 ? " AND entity = " . $entity: ''); } $result = $db->query($sql); @@ -866,10 +868,10 @@ if ($action == 'disable_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($_GET["code"])."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity >= 0 ? " AND entity = " . $entity: ''); } $result = $db->query($sql); @@ -921,6 +923,7 @@ print "
\n"; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id); +if ($entity >=0 ) $param.= '&entity='.$entity; $paramwithsearch = $param; if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; @@ -930,7 +933,7 @@ if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'rowid='.$rowid.'&code='.urlencode($_GET["code"]).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'rowid='.$rowid.'&code='.urlencode(GETPOST('code')).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); } //var_dump($elementList); @@ -977,6 +980,7 @@ if ($id) if ($tabname[$id]) { $alabelisused=0; + $withentity=false; $fieldlist=explode(',',$tabfield[$id]); @@ -986,6 +990,11 @@ if ($id) print ''; foreach ($fieldlist as $field => $value) { + if ($fieldlist[$field] == 'entity') { + $withentity = getEntity($tabname[$id], 2); + continue; + } + // Determine le nom du champ par rapport aux noms possibles // dans les dictionnaires de donnees $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut @@ -1076,6 +1085,8 @@ if ($id) if ($id == 4) print ''; print ''; print ''; + if (! empty($withentity)) + print ''; print ''; print ''; print ''; @@ -1156,7 +1167,9 @@ if ($id) $filterfound=0; foreach ($fieldlist as $field => $value) { - $showfield=1; // By defaut + if ($fieldlist[$field] == 'entity') continue; + + $showfield=1; // By default if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } @@ -1198,6 +1211,8 @@ if ($id) print ''; foreach ($fieldlist as $field => $value) { + if ($fieldlist[$field] == 'entity') continue; + // Determine le nom du champ par rapport aux noms possibles // dans les dictionnaires de donnees $showfield=1; // By defaut @@ -1305,12 +1320,16 @@ if ($id) $error=$hookmanager->error; $errors=$hookmanager->errors; // Show fields - if (empty($reshook)) fieldList($fieldlist, $obj, $tabname[$id], 'edit'); + if (empty($reshook)) { + $withentity = fieldList($fieldlist, $obj, $tabname[$id], 'edit'); + } print ''; print '
'; print ''; print ''; + if (! empty($withentity)) + print ''; print ''; print ''; print ''; @@ -1325,11 +1344,19 @@ if ($id) if (empty($reshook)) { + $withentity=false; + foreach ($fieldlist as $field => $value) { - $showfield=1; + $showfield=1; $align="left"; - $valuetoshow=$obj->{$fieldlist[$field]}; + $valuetoshow=$obj->{$fieldlist[$field]}; + + if ($fieldlist[$field] == 'entity') { + $withentity = $valuetoshow; + continue; + } + if ($value == 'element') { $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; @@ -1521,7 +1548,8 @@ if ($id) // If rowidcol not defined if (empty($rowidcol) || in_array($id, array(6,7,8,13,17,19,27))) $rowidcol='rowid'; $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((! empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0')?$obj->{$rowidcol}:(! empty($obj->code)?urlencode($obj->code):'')).'&code='.(! empty($obj->code)?urlencode($obj->code):''); - if ($param) $url .= '&'.$param; + if (! empty($param)) $url .= '&'.$param; + if (! empty($withentity)) $url .= '&entity='.$withentity; $url.='&'; // Favorite @@ -1664,8 +1692,15 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') $formcompany = new FormCompany($db); if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); + $withentity=false; + foreach ($fieldlist as $field => $value) { + if ($fieldlist[$field] == 'entity') { + $withentity = $obj->{$fieldlist[$field]}; + continue; + } + if (in_array($fieldlist[$field], array('code', 'libelle', 'type')) && $tabname == MAIN_DB_PREFIX."c_actioncomm" && in_array($obj->type, array('system','systemauto'))) { $hidden = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''); @@ -1856,5 +1891,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print ''; } } + + return $withentity; } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 6a0336aab38..98515f0271e 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -813,7 +813,7 @@ function activateModule($value,$withdeps=1) } $result=$objMod->init(); // Enable module - if ($result <= 0) + if ($result <= 0) { $ret['errors'][]=$objMod->error; } @@ -825,7 +825,7 @@ function activateModule($value,$withdeps=1) { // Activation of modules this module depends on // this->depends may be array('modModule1', 'mmodModule2') or array('always'=>"modModule1", 'FR'=>'modModule2') - foreach ($objMod->depend as $key => $modulestring) + foreach ($objMod->depends as $key => $modulestring) { if ((! is_numeric($key)) && $key != 'always' && $key != $mysoc->country_code) { @@ -848,19 +848,19 @@ function activateModule($value,$withdeps=1) break; } } - + if ($activate) { $ret['nbmodules']+=$resarray['nbmodules']; $ret['nbperms']+=$resarray['nbperms']; } - else + else { $ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $modulestring); } } } - + if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) { // Desactivation des modules qui entrent en conflit @@ -879,12 +879,12 @@ function activateModule($value,$withdeps=1) } } - if (! count($ret['errors'])) + if (! count($ret['errors'])) { $ret['nbmodules']++; $ret['nbperms']+=count($objMod->rights); } - + return $ret; } @@ -1221,7 +1221,7 @@ function form_constantes($tableau, $strictw3c=0, $helptext='') if ($result) { $obj = $db->fetch_object($result); // Take first result of select - + // For avoid warning in strict mode if (empty($obj)) { @@ -1360,7 +1360,7 @@ function showModulesExludedForExternal($modules) //if (empty($conf->global->$moduleconst)) continue; if (! in_array($modulename,$listofmodules)) continue; //var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name')); - + if ($i > 0) $text.=', '; else $text.=' '; $i++; @@ -1391,7 +1391,7 @@ function addDocumentModel($name, $type, $label='', $description='') $sql.= ($label?"'".$db->escape($label)."'":'null').", "; $sql.= (! empty($description)?"'".$db->escape($description)."'":"null"); $sql.= ")"; - + dol_syslog("admin.lib::addDocumentModel", LOG_DEBUG); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index de1cfafce0d..688624dc838 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -112,7 +112,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) * 'email_template', 'event', * @param int $shared 0=Return id of current entity only, * 1=Return id of current entity + shared entities (default), - * 2=Return id of current entity OR $forceentity value (eg. dictionnary share) + * 2=Return id of current entity OR master entity 1 value (eg. dictionnary share) * @param int $forceentity Entity id * @return mixed Entity id(s) to use */ @@ -132,18 +132,9 @@ function getEntity($element=false, $shared=1, $forceentity=null) else { $out=''; - - if ($shared == 2) - { - $out.= $forceentity; - } - else - { - $addzero = array('user', 'usergroup', 'email_template', 'default_values'); - if (in_array($element, $addzero)) $out.= '0,'; - $out.= $conf->entity; - } - + $addzero = array('user', 'usergroup', 'email_template', 'default_values'); + if (in_array($element, $addzero)) $out.= '0,'; + $out.= $conf->entity; return $out; } } diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index ccc54b09026..996d218bf12 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -395,9 +395,11 @@ ALTER TABLE llx_usergroup_rights DROP INDEX fk_usergroup; ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id); ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid); +ALTER TABLE llx_c_paiement DROP PRIMARY KEY ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id; ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement; -ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(entity, code); +ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(id, entity, code); +ALTER TABLE llx_c_payment_term DROP PRIMARY KEY ALTER TABLE llx_c_payment_term ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; -ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(entity, code); +ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(rowid, entity, code); diff --git a/htdocs/install/mysql/tables/llx_c_paiement.key.sql b/htdocs/install/mysql/tables/llx_c_paiement.key.sql index 8c944e0c34d..ad1930fba2e 100644 --- a/htdocs/install/mysql/tables/llx_c_paiement.key.sql +++ b/htdocs/install/mysql/tables/llx_c_paiement.key.sql @@ -17,4 +17,4 @@ -- -- ======================================================================== -ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(entity, code); +ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(id, entity, code); diff --git a/htdocs/install/mysql/tables/llx_c_paiement.sql b/htdocs/install/mysql/tables/llx_c_paiement.sql index 85e3cfb404d..60b4824748e 100644 --- a/htdocs/install/mysql/tables/llx_c_paiement.sql +++ b/htdocs/install/mysql/tables/llx_c_paiement.sql @@ -21,7 +21,7 @@ create table llx_c_paiement ( - id integer PRIMARY KEY, + id integer, entity integer DEFAULT 1 NOT NULL, -- multi company id code varchar(6) NOT NULL, libelle varchar(62), diff --git a/htdocs/install/mysql/tables/llx_c_payment_term.key.sql b/htdocs/install/mysql/tables/llx_c_payment_term.key.sql index e5977adf3cd..1bd86401945 100644 --- a/htdocs/install/mysql/tables/llx_c_payment_term.key.sql +++ b/htdocs/install/mysql/tables/llx_c_payment_term.key.sql @@ -17,4 +17,4 @@ -- -- ======================================================================== -ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(entity, code); +ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(rowid, entity, code); diff --git a/htdocs/install/mysql/tables/llx_c_payment_term.sql b/htdocs/install/mysql/tables/llx_c_payment_term.sql index 6c55a6742b2..4ecfdea6134 100644 --- a/htdocs/install/mysql/tables/llx_c_payment_term.sql +++ b/htdocs/install/mysql/tables/llx_c_payment_term.sql @@ -20,7 +20,7 @@ create table llx_c_payment_term ( - rowid integer PRIMARY KEY, + rowid integer, entity integer DEFAULT 1 NOT NULL, -- multi company id code varchar(16), sortorder smallint, From 3bddbd3bdf78b2de8562c44e59ee814caf227d4c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 8 Jun 2017 18:20:27 +0200 Subject: [PATCH 004/428] Fix: better test --- htdocs/admin/dict.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 1f27fdd9dad..e873e570930 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -784,7 +784,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } - $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); + $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); @@ -808,10 +808,10 @@ if ($action == $acts[0]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity >= 0 ? " AND entity = " . $entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int)$entity: ''); } $result = $db->query($sql); @@ -828,10 +828,10 @@ if ($action == $acts[1]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity >= 0 ? " AND entity = " . $entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int)$entity: ''); } $result = $db->query($sql); @@ -848,10 +848,10 @@ if ($action == 'activate_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity >= 0 ? " AND entity = " . $entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int)$entity: ''); } $result = $db->query($sql); @@ -868,10 +868,10 @@ if ($action == 'disable_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'".($entity >= 0 ? " AND entity = " . $entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity >= 0 ? " AND entity = " . $entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int)$entity: ''); } $result = $db->query($sql); @@ -923,7 +923,7 @@ print "
\n"; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id); -if ($entity >=0 ) $param.= '&entity='.$entity; +if ($entity != '') $param.= '&entity=' . (int)$entity; $paramwithsearch = $param; if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; From 73557151d295727c4c133b60e161d5a6e4b09d66 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 8 Jun 2017 18:27:32 +0200 Subject: [PATCH 005/428] Fix: better test if entity equal 0 --- htdocs/admin/dict.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index e873e570930..8cb30d6dd6e 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -980,7 +980,7 @@ if ($id) if ($tabname[$id]) { $alabelisused=0; - $withentity=false; + $withentity=null; $fieldlist=explode(',',$tabfield[$id]); @@ -1085,7 +1085,7 @@ if ($id) if ($id == 4) print ''; print ''; print ''; - if (! empty($withentity)) + if (! is_null($withentity)) print ''; print ''; print ''; @@ -1328,7 +1328,7 @@ if ($id) print '
'; print ''; print ''; - if (! empty($withentity)) + if (! is_null($withentity)) print ''; print ''; print ''; @@ -1344,7 +1344,7 @@ if ($id) if (empty($reshook)) { - $withentity=false; + $withentity=null; foreach ($fieldlist as $field => $value) { @@ -1549,7 +1549,7 @@ if ($id) if (empty($rowidcol) || in_array($id, array(6,7,8,13,17,19,27))) $rowidcol='rowid'; $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((! empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0')?$obj->{$rowidcol}:(! empty($obj->code)?urlencode($obj->code):'')).'&code='.(! empty($obj->code)?urlencode($obj->code):''); if (! empty($param)) $url .= '&'.$param; - if (! empty($withentity)) $url .= '&entity='.$withentity; + if (! is_null($withentity)) $url .= '&entity='.$withentity; $url.='&'; // Favorite @@ -1692,7 +1692,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') $formcompany = new FormCompany($db); if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); - $withentity=false; + $withentity=null; foreach ($fieldlist as $field => $value) { From 0546f288232236ac71e7a432374d57f1dc118104 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 8 Jun 2017 18:38:24 +0200 Subject: [PATCH 006/428] Fix: Travis error --- htdocs/admin/dict.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 8cb30d6dd6e..4f8b40e2259 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -784,7 +784,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } - $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); + $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : ''); dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); @@ -808,10 +808,10 @@ if ($action == $acts[0]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int)$entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int) $entity : ''); } $result = $db->query($sql); @@ -828,10 +828,10 @@ if ($action == $acts[1]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int)$entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int) $entity : ''); } $result = $db->query($sql); @@ -848,10 +848,10 @@ if ($action == 'activate_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int)$entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int) $entity : ''); } $result = $db->query($sql); @@ -868,10 +868,10 @@ if ($action == 'disable_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int)$entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : ''); } elseif ($_GET["code"]) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int)$entity: ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag(GETPOST('code'))."'".($entity != '' ? " AND entity = " . (int) $entity : ''); } $result = $db->query($sql); @@ -923,7 +923,7 @@ print "
\n"; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id); -if ($entity != '') $param.= '&entity=' . (int)$entity; +if ($entity != '') $param.= '&entity=' . (int) $entity; $paramwithsearch = $param; if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; From 4c70908ea2c9ec96893fb63b2bbc8a221e81c303 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 8 Jun 2017 18:52:01 +0200 Subject: [PATCH 007/428] Fix: entity field in combobox --- htdocs/core/class/html.form.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7a69172889e..01d28ecde24 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2743,7 +2743,8 @@ class Form $sql = "SELECT rowid, code, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_payment_term'; - $sql.= " WHERE active > 0"; + $sql.= " WHERE entity = " . getEntity('c_payment_term', 2); + $sql.= " AND active > 0"; $sql.= " ORDER BY sortorder"; $resql = $this->db->query($sql); @@ -2958,6 +2959,7 @@ class Form $sql = "SELECT id, code, libelle as label, type, active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement"; //if ($active >= 0) $sql.= " WHERE active = ".$active; + $sql.= " WHERE entity = " . getEntity('c_paiement', 2); $resql = $this->db->query($sql); if ($resql) From fa58f0f3e84886dd8960acc715124334f65bf46c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 09:25:15 +0200 Subject: [PATCH 008/428] Fix: add entity filter --- dev/initdata/import-thirdparties.php | 44 ++-- htdocs/adherents/subscription.php | 2 +- htdocs/cashdesk/validation_verif.php | 22 +- htdocs/comm/propal/class/propal.class.php | 26 +-- htdocs/commande/class/commande.class.php | 18 +- htdocs/compta/bank/bankentries.php | 46 ++-- htdocs/compta/bank/class/account.class.php | 55 ++--- htdocs/compta/bank/various_payment/index.php | 10 +- htdocs/compta/charges/index.php | 26 +-- htdocs/compta/facture/card.php | 10 +- .../facture/class/facture-rec.class.php | 156 +++++++------- htdocs/compta/facture/class/facture.class.php | 7 +- .../facture/class/paymentterm.class.php | 11 +- htdocs/compta/paiement.php | 67 +++--- htdocs/compta/paiement/avalider.php | 5 +- .../cheque/class/remisecheque.class.php | 18 +- .../compta/paiement/class/paiement.class.php | 53 ++--- htdocs/compta/paiement/list.php | 22 +- htdocs/compta/resultat/clientfourn.php | 22 +- htdocs/compta/resultat/index.php | 26 +-- htdocs/compta/salaries/index.php | 16 +- htdocs/compta/sociales/card.php | 41 ++-- .../sociales/class/chargesociales.class.php | 12 +- .../class/paymentsocialcontribution.class.php | 7 +- htdocs/compta/sociales/payments.php | 12 +- htdocs/compta/tva/reglement.php | 12 +- htdocs/core/class/commoninvoice.class.php | 31 +-- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/translate.class.php | 61 +++--- htdocs/core/lib/functions.lib.php | 5 +- .../modules/facture/doc/pdf_crabe.modules.php | 38 ++-- htdocs/core/modules/modFacture.class.php | 26 +-- htdocs/core/modules/modSalaries.class.php | 10 +- htdocs/core/modules/modSociete.class.php | 4 +- .../modules/rapport/pdf_paiement.class.php | 3 +- .../rapport/pdf_paiement_fourn.class.php | 3 +- .../pdf/pdf_canelle.modules.php | 2 +- htdocs/don/card.php | 1 + htdocs/don/class/don.class.php | 6 +- htdocs/don/class/paymentdonation.class.php | 11 +- htdocs/expensereport/card.php | 197 +++++++++--------- .../class/expensereport.class.php | 97 ++++----- .../class/paymentexpensereport.class.php | 9 +- .../class/fournisseur.commande.class.php | 68 +++--- .../fourn/class/fournisseur.facture.class.php | 10 +- htdocs/fourn/class/paiementfourn.class.php | 33 +-- htdocs/fourn/facture/card.php | 2 +- htdocs/fourn/facture/paiement.php | 74 +++---- htdocs/loan/card.php | 1 + htdocs/loan/class/loanschedule.class.php | 1 + htdocs/loan/class/paymentloan.class.php | 1 + .../class/supplier_proposal.class.php | 80 +++---- 52 files changed, 780 insertions(+), 742 deletions(-) diff --git a/dev/initdata/import-thirdparties.php b/dev/initdata/import-thirdparties.php index 08ad248ecc0..05fd0689102 100755 --- a/dev/initdata/import-thirdparties.php +++ b/dev/initdata/import-thirdparties.php @@ -21,7 +21,7 @@ /** * \file dev/initdata/import-thirdparties.php - * \brief Script example to insert thirdparties from a csv file. + * \brief Script example to insert thirdparties from a csv file. * To purge data, you can have a look at purge-data.php */ @@ -123,15 +123,15 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) if ($endlinenb && $i > $endlinenb) continue; $nboflines++; - + $object = new Societe($db); $object->state = $fields[6]; $object->client = $fields[7]; $object->fournisseur = $fields[8]; - + $object->name = $fields[13]?trim($fields[13]):$fields[0]; $object->name_alias = $fields[0]!=$fields[13]?trim($fields[0]):''; - + $object->address = trim($fields[14]); $object->zip = trim($fields[15]); $object->town = trim($fields[16]); @@ -149,7 +149,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) $condpayment = trim($fields[36]); if ($condpayment == 'A la commande') $condpayment = 'A réception de commande'; if ($condpayment == 'A reception facture') $condpayment = 'Réception de facture'; - $object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid'); + $object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', getEntity('c_payment_term', 2)); if (empty($object->cond_reglement_id)) { print " - Error cant find payment mode for ".$condpayment."\n"; @@ -166,7 +166,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) // Set price level $object->price_level = 1; if ($labeltype == 'Revendeur') $object->price_level = 2; - + print "Process line nb ".$i.", name ".$object->name; @@ -182,7 +182,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) print " - Error in create result code = ".$ret." - ".$object->errorsToString(); $errorrecord++; } - else + else { print " - Creation OK with name ".$object->name." - id = ".$ret; } @@ -198,7 +198,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) if (! $errorrecord && $fields[3]) { $salesrep=new User($db); - + $tmp=explode(' ',$fields[3],2); $salesrep->firstname = trim($tmp[0]); $salesrep->lastname = trim($tmp[1]); @@ -206,7 +206,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) else $salesrep->login=strtolower($salesrep->firstname); $salesrep->login=preg_replace('/ /','',$salesrep->login); $salesrep->fetch(0,$salesrep->login); - + $result = $object->add_commercial($user, $salesrep->id); if ($result < 0) { @@ -217,14 +217,14 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { print " - create link sale representative OK"; } - } - + } + dol_syslog("Add invoice contacts"); // Insert an invoice contact if there is an invoice email != standard email if (! $errorrecord && $fields[27] && $fields[26] != $fields[27]) { $ret1=$ret2=0; - + $contact = new Contact($db); $contact->lastname = $object->name; $contact->address=$object->address; @@ -233,7 +233,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) $contact->country_id=$object->country_id; $contact->email=$fields[27]; $contact->socid=$object->id; - + $ret1=$contact->create($user); if ($ret1 > 0) { @@ -244,18 +244,18 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString(); $errorrecord++; } - else + else { print " - create contact OK"; } } - + dol_syslog("Add delivery contacts"); // Insert a delivery contact if (! $errorrecord && $fields[47]) { $ret1=$ret2=0; - + $contact2 = new Contact($db); $contact2->lastname = 'Service livraison - '.$fields[47]; $contact2->address = $fields[48]; @@ -264,10 +264,10 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) $contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid'); $contact2->note_public=$fields[54]; $contact2->socid=$object->id; - + // Extrafields $contact2->array_options['options_anazoneliv']=price2num($fields[53]); - + $ret1=$contact2->create($user); if ($ret1 > 0) { @@ -278,16 +278,16 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString(); $errorrecord++; } - else + else { print " - create contact OK"; } } - + print "\n"; - - if ($errorrecord) + + if ($errorrecord) { fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n"); $error++; // $errorrecord will be reset diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 21de6e305b5..30853e2dedf 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -442,7 +442,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $paiement = new Paiement($db); $paiement->datepaye = $paymentdate; $paiement->amounts = $amounts; - $paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement'); + $paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement','code','id',getEntity('c_paiement', 2)); $paiement->num_paiement = $num_chq; $paiement->note = $label; diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 5e4ed9b028e..c28df626bc5 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -45,14 +45,14 @@ switch ($action) case 'valide_achat': $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - + $company=new Societe($db); $company->fetch($thirdpartyid); $invoice=new Facture($db); $invoice->date=dol_now(); $invoice->type= Facture::TYPE_STANDARD; - + // To use a specific numbering module for POS, reset $conf->global->FACTURE_ADDON and other vars here // and restore values just after $sav_FACTURE_ADDON=''; @@ -68,7 +68,7 @@ switch ($action) // To force rule only for POS with mercure //... } - + $num=$invoice->getNextNumRef($company); // Restore save values @@ -76,7 +76,7 @@ switch ($action) { $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; } - + $obj_facturation->numInvoice($num); $obj_facturation->getSetPaymentMode($_POST['hdnChoix']); @@ -137,7 +137,7 @@ switch ($action) $cond_reglement_id = 0; break; case 'ESP': - $mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement'); + $mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement','code','id',getEntity('c_paiement', 2)); $cond_reglement_id = 0; $note .= $langs->trans("Cash")."\n"; $note .= $langs->trans("Received").' : '.$obj_facturation->montantEncaisse()." ".$conf->currency."\n"; @@ -146,11 +146,11 @@ switch ($action) $note .= '--------------------------------------'."\n\n"; break; case 'CB': - $mode_reglement_id = dol_getIdFromCode($db,'CB','c_paiement'); + $mode_reglement_id = dol_getIdFromCode($db,'CB','c_paiement','code','id',getEntity('c_paiement', 2)); $cond_reglement_id = 0; break; case 'CHQ': - $mode_reglement_id = dol_getIdFromCode($db,'CHQ','c_paiement'); + $mode_reglement_id = dol_getIdFromCode($db,'CHQ','c_paiement','code','id',getEntity('c_paiement', 2)); $cond_reglement_id = 0; break; } @@ -192,10 +192,10 @@ switch ($action) $invoiceline->remise_percent=$tab_liste[$i]['remise_percent']; $invoiceline->price=$tab_liste[$i]['price']; $invoiceline->subprice=$tab_liste[$i]['price']; - + $invoiceline->tva_tx=empty($vat_rate)?0:$vat_rate; // works even if vat_rate is '' $invoiceline->info_bits=empty($vat_npr)?0:$vat_npr; - + $invoiceline->total_ht=$tab_liste[$i]['total_ht']; $invoiceline->total_ttc=$tab_liste[$i]['total_ttc']; $invoiceline->total_tva=$tab_liste[$i]['total_vat']; @@ -224,7 +224,7 @@ switch ($action) { $warehouseidtodecrease=(isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0); if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease=0; // If a particular stock is defined, we disable choice - + $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), 0); if ($warehouseidtodecrease > 0) @@ -264,7 +264,7 @@ switch ($action) { $warehouseidtodecrease=(isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0); if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease=0; // If a particular stock is defined, we disable choice - + $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), 0); if ($warehouseidtodecrease > 0) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index fb1ac46cd91..dfebeae6893 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -254,7 +254,7 @@ class Propal extends CommonObject $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; $vat_src_code = ''; // May be defined into tva_tx - + $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->thirdparty,$tva_npr); $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->thirdparty,$tva_npr); @@ -433,7 +433,7 @@ class Propal extends CommonObject // Check parameters if ($type < 0) return -1; - + if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); @@ -1270,8 +1270,8 @@ class Propal extends CommonObject $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity = ' . getEntity('c_paiement', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term', 2); $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid'; @@ -1392,17 +1392,17 @@ class Propal extends CommonObject return -1; } } - + /** * Load array lines - * + * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ function fetch_lines($only_product=0) { $this->lines=array(); - + $sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,'; $sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,'; $sql.= ' d.fk_unit,'; @@ -1422,7 +1422,7 @@ class Propal extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $num = $this->db->num_rows($result); - + $i = 0; while ($i < $num) { @@ -1489,9 +1489,9 @@ class Propal extends CommonObject //print "xx $i ".$this->lines[$i]->fk_product; $i++; } - + $this->db->free($result); - + return 1; } else @@ -2779,7 +2779,7 @@ class Propal extends CommonObject function availability($availability_id, $notrigger=0) { global $user; - + if ($this->statut >= self::STATUS_DRAFT) { $error=0; @@ -3352,9 +3352,9 @@ class Propal extends CommonObject function getLinesArray() { // TODO Duplicate with fetch_lines ? Wich one to keep ? - + $this->lines = array(); - + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.vat_src_code, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 93df2f1aa0b..eafb406ba58 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -706,10 +706,10 @@ class Commande extends CommonOrder // Clean parameters $this->brouillon = 1; // set command as draft - + // $date_commande is deprecated $date = ($this->date_commande ? $this->date_commande : $this->date); - + // Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate) if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $date); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); @@ -1468,7 +1468,7 @@ class Commande extends CommonOrder $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; $vat_src_code = ''; // May be defined into tva_tx - + $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr); $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr); @@ -1559,8 +1559,8 @@ class Commande extends CommonOrder $sql.= ', ca.code as availability_code, ca.label as availability_label'; $sql.= ', dr.code as demand_reason_code'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id)'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term', 2) . ')'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id AND cr.entity = ' . getEntity('c_paiement', 2) . ')'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; @@ -1798,7 +1798,7 @@ class Commande extends CommonOrder $line->product_type = $objp->product_type; $line->qty = $objp->qty; - $line->vat_src_code = $objp->vat_src_code; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -3106,7 +3106,7 @@ class Commande extends CommonOrder $error = 0; dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG); - + $this->db->begin(); if (! $error && ! $notrigger) @@ -3381,7 +3381,7 @@ class Commande extends CommonOrder global $conf, $langs, $user; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $result=''; if (! empty($conf->expedition->enabled) && ($option == 1 || $option == 2)) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; @@ -3418,7 +3418,7 @@ class Commande extends CommonOrder $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 5f6d5156b72..1f9f089270f 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -407,7 +407,7 @@ if ($id > 0 || ! empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); dol_fiche_end(); - + /* * Buttons actions */ @@ -521,10 +521,10 @@ if (($id > 0 || ! empty($ref)) && ((string) $page == '')) $offset = $limit * $page; if ($page < 0) $page = 0; } -if ($page >= $nbtotalofpages) +if ($page >= $nbtotalofpages) { // If we made a search and result has low page than the page number we were on - $page = ($nbtotalofpages -1); + $page = ($nbtotalofpages -1); $offset = $limit * $page; if ($page < 0) $page = 0; } @@ -598,7 +598,7 @@ if ($resql) print ''; print ' '.$langs->trans("or").' '; print ''; - + // Show last bank statements $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) $liste=""; @@ -703,8 +703,8 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - - if ($moreforfilter) + + if ($moreforfilter) { print '
'; print $moreforfilter; @@ -718,7 +718,7 @@ if ($resql) print ''."\n"; print ''; - if (! empty($arrayfields['b.rowid']['checked'])) + if (! empty($arrayfields['b.rowid']['checked'])) { print ''; // Ref - if (! empty($arrayfields['b.rowid']['checked'])) + if (! empty($arrayfields['b.rowid']['checked'])) { print '\n"; if (! $i) $totalarray['nbfield']++; } // Date value - if (! empty($arrayfields['b.datev']['checked'])) + if (! empty($arrayfields['b.datev']['checked'])) { print '\n"; @@ -1081,7 +1081,7 @@ if ($resql) } // Third party - if (! empty($arrayfields['bu.label']['checked'])) + if (! empty($arrayfields['bu.label']['checked'])) { print "'; - if (! $i) $totalarray['nbfield']++; - + if (! $i) $totalarray['nbfield']++; + // Action column print ''; - + // Ref print ''; - + // Ref supplier print ''; - + // Date if ($objp->df > 0 ) { @@ -470,13 +470,13 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { print ''; } - + // Multicurrency - if (!empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Currency print '\n"; - + print ''; print ''; - + print ''; - + print ''; - + print ''; - + print '"; - + // Multicurrency - if (!empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print '"; } - + print "\n"; $total+=$objp->total_ht; $total_ttc+=$objp->total_ttc; @@ -549,7 +549,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "\n"; } print "
'; print ''; @@ -840,19 +840,19 @@ if ($resql) $sign = 1; $totalarray=array(); - while ($i < min($num,$limit)) + while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); // If we are in a situation where we need/can show balance, we calculate the start of balance if (! $balancecalculated && ! empty($arrayfields['balance']['checked']) && $mode_balance_ok) { - if (! $account) + if (! $account) { dol_print_error('', 'account is not defined but $mode_balance_ok is true'); exit; } - + //Loop on each record $sign = 1; $i = 0; @@ -875,7 +875,7 @@ if ($resql) } } else dol_print_error($db); - + $balancecalculated=true; } @@ -896,7 +896,7 @@ if ($resql) print '
'; print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid."   "; @@ -908,14 +908,14 @@ if ($resql) if (! empty($arrayfields['description']['checked'])) { print ""; - + //print "rowid."&account=".$objp->fk_account."\">"; $reg=array(); preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); else print dol_trunc($objp->label,40); //print " "; - + // Add links after description $links = $bankaccountstatic->get_url($objp->rowid); $cachebankaccount=array(); @@ -1040,14 +1040,14 @@ if ($resql) } // Date ope - if (! empty($arrayfields['b.dateo']['checked'])) + if (! empty($arrayfields['b.dateo']['checked'])) { print ''.dol_print_date($db->jdate($objp->do),"day")."'; print ''.dol_print_date($db->jdate($objp->dv),"day").""; @@ -1063,10 +1063,10 @@ if ($resql) } // Payment type - if (! empty($arrayfields['type']['checked'])) + if (! empty($arrayfields['type']['checked'])) { print ''; - $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle'); + $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle','',getEntity('c_paiement', 2)); if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); else print $labeltype; print ""; if ($objp->url_id) @@ -1106,7 +1106,7 @@ if ($resql) } // Bank account - if (! empty($arrayfields['ba.ref']['checked'])) + if (! empty($arrayfields['ba.ref']['checked'])) { print ''; print $bankaccount->getNomUrl(1); @@ -1174,7 +1174,7 @@ if ($resql) print ''.$objp->num_releve.''; } else if ($action == 'reconcile') - { + { print 'rowid])?' checked':'').'>'; } } @@ -1229,8 +1229,8 @@ if ($resql) } } print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 43b6dace19c..5330eca86a4 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -39,7 +39,7 @@ class Account extends CommonObject public $element = 'bank_account'; public $table_element = 'bank_account'; public $picto = 'account'; - + /** * @var int Use id instead of rowid * @deprecated @@ -411,8 +411,9 @@ class Account extends CommonObject if (is_numeric($oper)) // Clean oper to have a code instead of a rowid { - $sql ="SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; - $sql.=" WHERE id=".$oper; + $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; + $sql.= " WHERE id=".$oper; + $sql.= " AND entity = " . getEntity('c_payement_term', 2) . ")"; $resql=$this->db->query($sql); if ($resql) { @@ -538,7 +539,7 @@ class Account extends CommonObject $now=dol_now(); $this->db->begin(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account ("; $sql.= "datec"; $sql.= ", ref"; @@ -619,14 +620,14 @@ class Account extends CommonObject $result=$this->insertExtraFields(); if ($result < 0) $error++; } - + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('BANKACCOUNT_CREATE',$user); if ($result < 0) $error++; // End call triggers - } + } } else { @@ -670,9 +671,9 @@ class Account extends CommonObject global $langs,$conf, $hookmanager; $error=0; - + $this->db->begin(); - + // Clean parameters $this->state_id = ($this->state_id?$this->state_id:$this->state_id); $this->country_id = ($this->country_id?$this->country_id:$this->country_id); @@ -739,7 +740,7 @@ class Account extends CommonObject if ($result < 0) $error++; } } - + if (! $error && ! $notrigger) { // Call trigger @@ -754,7 +755,7 @@ class Account extends CommonObject $this->error=$this->db->lasterror(); dol_print_error($this->db); } - + if (! $error) { $this->db->commit(); @@ -906,7 +907,7 @@ class Account extends CommonObject $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_update = $this->db->jdate($obj->date_update); - + // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); @@ -983,15 +984,15 @@ class Account extends CommonObject global $conf; $error=0; - + $this->db->begin(); - + // Delete link between tag and bank account if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; $sql.= " WHERE fk_account = ".$this->id; - + $resql = $this->db->query($sql); if (!$resql) { @@ -999,15 +1000,15 @@ class Account extends CommonObject $this->error = "Error ".$this->db->lasterror(); } } - + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE rowid = ".$this->rowid; - + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) + if ($result) { // Remove extrafields if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used @@ -1020,13 +1021,13 @@ class Account extends CommonObject } } } - else + else { $error++; $this->error = "Error ".$this->db->lasterror(); - } + } } - + if (! $error) { $this->db->commit(); @@ -1433,7 +1434,7 @@ class Account extends CommonObject * - DeskCode * * Some countries show less or more bank account properties to the user - * + * * @param int $includeibanbic 1=Return also key for IBAN and BIC * @return array * @see useDetailedBBAN @@ -1554,7 +1555,7 @@ class AccountLine extends CommonObject var $element='bank'; var $table_element='bank'; var $picto = 'generic'; - + var $id; var $ref; var $datec; @@ -1842,7 +1843,7 @@ class AccountLine extends CommonObject function update_conciliation(User $user, $cat) { global $conf; - + $this->db->begin(); // Check statement field @@ -1854,7 +1855,7 @@ class AccountLine extends CommonObject return -1; } } - + $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; $sql.= " rappro = 1"; $sql.= ", num_releve = '".$this->db->escape($this->num_releve)."'"; @@ -2042,7 +2043,7 @@ class AccountLine extends CommonObject return $result; } - + /** * Return label of status (activity, closed) * @@ -2053,7 +2054,7 @@ class AccountLine extends CommonObject { return $this->LibStatut($this->status,$mode); } - + /** * Renvoi le libelle d'un statut donne * @@ -2097,6 +2098,6 @@ class AccountLine extends CommonObject if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); }*/ } - + } diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 39c6d27be4f..5cea33d5baa 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -92,7 +92,7 @@ $sql = "SELECT v.rowid, v.amount, v.label, v.datep as datep, v.datev as datev, v $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement', 2); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql.= " WHERE v.entity = ".$conf->entity; @@ -142,9 +142,9 @@ if ($result) print ''; print ''; print ''; - + print_barre_liste($langs->trans("VariousPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); - + print '
'; print ''."\n"; @@ -188,13 +188,13 @@ if ($result) $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''; - + print "\n"; while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); - + print ''; $variousstatic->id=$obj->rowid; diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index d494f778df0..715d1c96627 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -92,7 +92,7 @@ print ''; print ''; print ''; -if ($mode != 'sconly') +if ($mode != 'sconly') { $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."":""); print_barre_liste($title,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$center,$num,$totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); @@ -139,7 +139,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity = " . getEntity('c_paiement', 2); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql.= " WHERE cs.fk_type = c.id"; @@ -260,7 +260,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id AND pct.entity = " . getEntity('c_paiement', 2); $sql.= " WHERE pv.entity = ".$conf->entity; if ($year > 0) { @@ -294,7 +294,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $total = $total + $obj->amount; - + print ''; print ''."\n"; @@ -309,12 +309,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) // Date print '\n"; - + // Type payment print ''; - + // Account if (! empty($conf->banque->enabled)) { @@ -333,7 +333,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) else print ' '; print ''; } - + // Paid print '"; print "\n"; @@ -424,7 +424,7 @@ while($j<$numlt) $total = $total + $obj->amount; - + print ''; print ''."\n"; @@ -465,7 +465,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $sal = new PaymentSalary($db); print "
"; - + print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, s.fk_bank, u.salary as current_salary,"; @@ -474,7 +474,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id AND pct.entity = " . getEntity('c_paiement', 2); $sql.= " , ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE s.entity IN (".getEntity('user').")"; $sql.= " AND u.rowid = s.fk_user"; @@ -508,7 +508,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $total = $total + $obj->amount; - + print ''; print ''."\n"; @@ -527,7 +527,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) print ''; - + // Account if (! empty($conf->banque->enabled)) { @@ -546,7 +546,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) else print ' '; print ''; } - + // Paid print '"; print "\n"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e9be0a0b962..319369fa304 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -649,9 +649,12 @@ if (empty($reshook)) { // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT - $sql = 'SELECT SUM(pf.amount) as total_paiements - FROM llx_c_paiement as c, llx_paiement_facture as pf, llx_paiement as p - WHERE pf.fk_facture = '.$object->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid ORDER BY p.datep, p.tms'; + $sql = 'SELECT SUM(pf.amount) as total_paiements'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; + $sql.= ' WHERE pf.fk_facture = '.$object->id; + $sql.= ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; + $sql.= ' AND p.entity = ' . getEntity('c_paiement', 2); + $sql.= ' ORDER BY p.datep, p.tms'; $resql = $db->query($sql); $res = $db->fetch_object($resql); @@ -3693,6 +3696,7 @@ else if ($id > 0 || ! empty($ref)) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; + $sql .= ' AND c.entity = ' . getEntity('c_paiement', 2); $sql .= ' ORDER BY p.datep, p.tms'; $result = $db->query($sql); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 6bc88e47490..6e7f2580859 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -43,7 +43,7 @@ class FactureRec extends CommonInvoice public $table_element_line='facturedet_rec'; public $fk_element='fk_facture'; public $picto='bill'; - + var $entity; var $number; var $date; @@ -58,7 +58,7 @@ class FactureRec extends CommonInvoice var $date_when; var $nb_gen_done; var $nb_gen_max; - + var $rang; var $special_code; @@ -91,20 +91,20 @@ class FactureRec extends CommonInvoice // Clean parameters $this->titre=trim($this->titre); $this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice; - + // No frequency defined then no next date to execution - if (empty($this->frequency)) + if (empty($this->frequency)) { $this->frequency=0; $this->date_when=NULL; } - - + + $this->frequency=abs($this->frequency); $this->nb_gen_done=0; $this->nb_gen_max=empty($this->nb_gen_max)?0:$this->nb_gen_max; $this->auto_validate=empty($this->auto_validate)?0:$this->auto_validate; - + $this->db->begin(); // Charge facture modele @@ -197,7 +197,7 @@ class FactureRec extends CommonInvoice $error++; } } - + // Add object linked if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) { @@ -210,7 +210,7 @@ class FactureRec extends CommonInvoice $error++; } } - } + } if ($error) { @@ -259,8 +259,8 @@ class FactureRec extends CommonInvoice $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; //$sql.= ', el.fk_source'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity = ' . getEntity('c_payment_term', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement', 2); //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; if ($rowid) $sql.= ' WHERE f.rowid='.$rowid; elseif ($ref) $sql.= " WHERE f.titre='".$this->db->escape($ref)."'"; @@ -268,7 +268,7 @@ class FactureRec extends CommonInvoice if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; */ - + $result = $this->db->query($sql); if ($result) { @@ -361,8 +361,8 @@ class FactureRec extends CommonInvoice { return $this->fetch_lines(); } - - + + /** * Recupere les lignes de factures predefinies dans this->lines * @@ -386,7 +386,7 @@ class FactureRec extends CommonInvoice $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= ' WHERE l.fk_facture = '.$this->id; $sql.= ' ORDER BY l.rang'; - + dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); if ($result) @@ -431,7 +431,7 @@ class FactureRec extends CommonInvoice $line->special_code = $objp->special_code; $line->fk_unit = $objp->fk_unit; $line->fk_contract_line = $objp->fk_contract_line; - + // Ne plus utiliser $line->price = $objp->price; $line->remise = $objp->remise; @@ -463,12 +463,12 @@ class FactureRec extends CommonInvoice function delete($user, $notrigger=0, $idwarehouse=-1) { $rowid=$this->id; - + dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); - + $error=0; $this->db->begin(); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; dol_syslog($sql); if ($this->db->query($sql)) @@ -486,7 +486,7 @@ class FactureRec extends CommonInvoice $this->error=$this->db->lasterror(); $error=-2; } - + if (! $error) { $this->db->commit(); @@ -525,7 +525,7 @@ class FactureRec extends CommonInvoice function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; - + $facid=$this->id; dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); @@ -578,7 +578,7 @@ class FactureRec extends CommonInvoice $total_ttc = $tabprice[2]; $total_localtax1=$tabprice[9]; $total_localtax2=$tabprice[10]; - + $product_type=$type; if ($fk_product) { @@ -679,12 +679,12 @@ class FactureRec extends CommonInvoice function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; - + $facid=$this->id; - + dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - + // Check parameters if ($type < 0) return -1; @@ -709,7 +709,7 @@ class FactureRec extends CommonInvoice $txtva=price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - + if ($price_base_type=='HT') { $pu=$pu_ht; @@ -718,7 +718,7 @@ class FactureRec extends CommonInvoice { $pu=$pu_ttc; } - + // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker @@ -730,7 +730,7 @@ class FactureRec extends CommonInvoice $total_ttc = $tabprice[2]; $total_localtax1=$tabprice[9]; $total_localtax2=$tabprice[10]; - + $product_type=$type; if ($fk_product) { @@ -738,7 +738,7 @@ class FactureRec extends CommonInvoice $result=$product->fetch($fk_product); $product_type=$product->type; } - + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; $sql.= "fk_facture = '".$facid."'"; $sql.= ", label=".(! empty($label)?"'".$this->db->escape($label)."'":"null"); @@ -778,12 +778,12 @@ class FactureRec extends CommonInvoice return -1; } } - } - - + } + + /** - * Return the next date of - * + * Return the next date of + * * @return timestamp false if KO, timestamp if OK */ function getNextDate() @@ -791,27 +791,27 @@ class FactureRec extends CommonInvoice if (empty($this->date_when)) return false; return dol_time_plus_duree($this->date_when, $this->frequency, $this->unit_frequency); } - + /** * Create all recurrents invoices (for all entities if multicompany is used). * A result may also be provided into this->output. - * - * WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found. - * - * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) + * + * WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found. + * + * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ function createRecurringInvoices() { global $conf, $langs, $db, $user; - + $langs->load("bills"); - + $nb_create=0; - + $now = dol_now(); $tmparray=dol_getdate($now); $today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day - + dol_syslog("createRecurringInvoices"); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec'; $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency @@ -819,30 +819,30 @@ class FactureRec extends CommonInvoice $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; $sql.= $db->order('entity', 'ASC'); //print $sql;exit; - + $resql = $db->query($sql); if ($resql) { $i=0; $num = $db->num_rows($resql); - + if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; else $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); - + $saventity = $conf->entity; - + while ($i < $num) // Loop on each template invoice { $line = $db->fetch_object($resql); $db->begin(); - + $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); - + // Set entity context $conf->entity = $facturerec->entity; - + dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); $error=0; @@ -850,12 +850,12 @@ class FactureRec extends CommonInvoice $facture = new Facture($db); $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice - + $facture->type = self::TYPE_STANDARD; $facture->brouillon = 1; $facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; - + $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) { @@ -888,16 +888,16 @@ class FactureRec extends CommonInvoice $i++; } - + $conf->entity = $saventity; // Restore entity context } else dol_print_error($db); - + $this->output=trim($this->output); - + return $error?$error:0; } - + /** * Return clicable name (with picto eventually) * @@ -914,13 +914,13 @@ class FactureRec extends CommonInvoice $result=''; $label=$langs->trans("ShowInvoice").': '.$this->ref; - + $url = DOL_URL_ROOT.'/compta/facture/fiche-rec.php?facid='.$this->id; - + if ($short) return $url; - + $picto='bill'; - + $link = ''; $linkend=''; @@ -952,7 +952,7 @@ class FactureRec extends CommonInvoice // Load array of products prodids $num_prods = 0; $prodids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE entity IN (".getEntity('product').")"; @@ -1065,7 +1065,7 @@ class FactureRec extends CommonInvoice $this->lines[$xnbp]=$line; $xnbp++; } - + $this->usenewprice = 1; } @@ -1085,7 +1085,7 @@ class FactureRec extends CommonInvoice return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - + /** * Update frequency and unit * @@ -1109,12 +1109,12 @@ class FactureRec extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET frequency = '.($frequency?$this->db->escape($frequency):'null'); - if (!empty($unit)) + if (!empty($unit)) { $sql.= ', unit_frequency = \''.$this->db->escape($unit).'\''; } $sql.= ' WHERE rowid = '.$this->id; - + dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); if ($this->db->query($sql)) { @@ -1128,7 +1128,7 @@ class FactureRec extends CommonInvoice return -1; } } - + /** * Update the next date of execution * @@ -1161,7 +1161,7 @@ class FactureRec extends CommonInvoice return -1; } } - + /** * Update the maximum period * @@ -1175,9 +1175,9 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined",LOG_ERR); return -1; } - + if (empty($nb)) $nb=0; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET nb_gen_max = '.$nb; $sql.= ' WHERE rowid = '.$this->id; @@ -1194,7 +1194,7 @@ class FactureRec extends CommonInvoice return -1; } } - + /** * Update the auto validate invoice * @@ -1208,7 +1208,7 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined",LOG_ERR); return -1; } - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET auto_validate = '.$validate; $sql.= ' WHERE rowid = '.$this->id; @@ -1235,7 +1235,7 @@ class FactureRec extends CommonInvoice */ class FactureLigneRec extends CommonInvoiceLine { - + /** * Delete line in database * @@ -1244,11 +1244,11 @@ class FactureLigneRec extends CommonInvoiceLine function delete() { global $conf,$langs,$user; - + $error=0; - + $this->db->begin(); - + // Call trigger /*$result=$this->call_trigger('LINEBILLREC_DELETE',$user); if ($result < 0) @@ -1257,8 +1257,8 @@ class FactureLigneRec extends CommonInvoiceLine return -1; }*/ // End call triggers - - + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE rowid = ".($this->rowid > 0 ? $this->rowid : $this->id); dol_syslog(get_class($this)."::delete", LOG_DEBUG); if ($this->db->query($sql) ) @@ -1273,5 +1273,5 @@ class FactureLigneRec extends CommonInvoiceLine return -1; } } - + } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 880832f80e1..b7042404262 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1153,8 +1153,8 @@ class Facture extends CommonInvoice $sql.= ', f.fk_incoterms, f.location_incoterms'; $sql.= ", i.libelle as libelle_incoterms"; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity = ' . getEntity('c_payment_term', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement', 2); $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; $sql.= ' WHERE f.entity = '.$conf->entity; if ($rowid) $sql.= " AND f.rowid=".$rowid; @@ -3112,6 +3112,7 @@ class Facture extends CommonInvoice //$sql.= ' WHERE pf.'.$field.' = 1'; $sql.= ' AND pf.'.$field2.' = p.rowid'; $sql.= ' AND p.fk_paiement = t.id'; + $sql.= ' AND t.entity = ' . getEntity('c_paiement', 2); if ($filtertype) $sql.=" AND t.code='PRE'"; dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); @@ -3594,7 +3595,7 @@ class Facture extends CommonInvoice if (! $error) { // Force payment mode of invoice to withdraw - $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement'); + $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', getEntity('c_paiement', 2)); if ($payment_mode_id > 0) { $result=$this->setPaymentMethods($payment_mode_id); diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 2899e3fae56..3f0c2bcf732 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -93,6 +93,7 @@ class PaymentTerm // extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_payment_term("; $sql.= "rowid,"; + $sql.= "entity,"; $sql.= "code,"; $sql.= "sortorder,"; $sql.= "active,"; @@ -106,6 +107,7 @@ class PaymentTerm // extends CommonObject $sql.= ") VALUES ("; $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->rowid."'").","; + $sql.= " ".(! isset($this->entity)?getEntity('c_payment_term', 2):"'".$this->entity."'").","; $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; $sql.= " ".(! isset($this->sortorder)?'NULL':"'".$this->sortorder."'").","; $sql.= " ".(! isset($this->active)?'NULL':"'".$this->active."'").","; @@ -172,6 +174,7 @@ class PaymentTerm // extends CommonObject global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; + $sql.= " t.entity"; $sql.= " t.code,"; $sql.= " t.sortorder,"; @@ -185,6 +188,7 @@ class PaymentTerm // extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; $sql.= " WHERE t.rowid = ".$id; + $sql.= " AND t.entity = " . getEntity('c_payment_term', 2); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); @@ -234,6 +238,7 @@ class PaymentTerm // extends CommonObject $sql.= " t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; $sql.= " WHERE t.code = 'RECEP'"; + $sql.= " AND t.entity = " . getEntity('c_payment_term', 2); dol_syslog(get_class($this)."::getDefaultId", LOG_DEBUG); $resql=$this->db->query($sql); @@ -296,7 +301,8 @@ class PaymentTerm // extends CommonObject $sql.= " decalage=".(isset($this->decalage)?$this->decalage:"null").""; - $sql.= " WHERE rowid=".$this->id; + $sql.= " WHERE rowid = " . $this->id; + $sql.= " AND entity = " . getEntity('c_payment_term', 2); $this->db->begin(); @@ -352,7 +358,8 @@ class PaymentTerm // extends CommonObject $error=0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_payment_term"; - $sql.= " WHERE rowid=".$this->id; + $sql.= " WHERE rowid = " . $this->id; + $sql.= " AND t.entity = " . getEntity('c_payment_term', 2); $this->db->begin(); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index cdc5eb2e545..023f94c5eef 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -99,7 +99,7 @@ if (empty($reshook)) $atleastonepaymentnotnull = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); + $tmpinvoice=new Facture($db); foreach ($_POST as $key => $value) { if (substr($key,0,7) == 'amount_') @@ -188,7 +188,7 @@ if (empty($reshook)) setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); $error++; } - + // Check if payments in both currency if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { @@ -228,7 +228,7 @@ if (empty($reshook)) $newvalue = price2num($value,'MT'); $amounts[$key] = -$newvalue; } - + foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch { $newvalue = price2num($value,'MT'); @@ -251,7 +251,7 @@ if (empty($reshook)) $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement'); + $paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement','code','id',getEntity('c_paiement', 2)); $paiement->num_paiement = GETPOST('num_paiement'); $paiement->note = GETPOST('comment'); @@ -389,7 +389,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { subJson[n["name"]] = n["value"]; }); - + return subJson; } function callForResult(imgId) @@ -516,31 +516,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; - + print '
'.dol_print_date($db->jdate($obj->dm),'day').''.dol_print_date($db->jdate($obj->dm),'day')."'; if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; print $obj->num_payment.''.price($obj->amount)."
'.dol_print_date($db->jdate($obj->dm),'day').'
'.dol_print_date($db->jdate($obj->dateep),'day').''; if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; print $obj->num_payment.''.price($obj->amount)."
'.$langs->trans('Comments').''; print '
'; dol_fiche_end(); - + /* * List of unpaid invoices */ - + $sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, '; $sql.= ' f.datef as df, f.fk_soc as socid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - + if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; } - + $sql.= ' WHERE f.entity = '.$conf->entity; $sql.= ' AND (f.fk_soc = '.$facture->socid; - + if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { $sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; } - + $sql.= ') AND f.paye = 0'; $sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled if ($facture->type != 2) @@ -577,7 +577,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie //print '
'; print '
'; print ''; - + print ''; print ''; print ''; @@ -602,7 +602,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie while ($i < $num) { $objp = $db->fetch_object($resql); - + $soc = new Societe($db); $soc->fetch($objp->socid); @@ -614,9 +614,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $deposits=$invoice->getSumDepositsUsed(); $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); - + // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { $multicurrency_payment = $invoice->getSommePaiement(1); $multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1); @@ -624,7 +624,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,'MT'); $multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,'MT'); } - + print ''; print '\n"; - + // Currency if (!empty($conf->multicurrency->enabled)) print '\n"; - + // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; - + // Multicurrency Price print ''; - + // Multicurrency Price print ''; } - + // Price print ''; - + // Received or paid back print '"; // Multicurrency Price - if (! empty($conf->multicurrency->enabled)) + if (! empty($conf->multicurrency->enabled)) { print ''; print '\n"; print '\n"; diff --git a/htdocs/compta/paiement/avalider.php b/htdocs/compta/paiement/avalider.php index 0fe627cf7ac..be0e96bb4c1 100644 --- a/htdocs/compta/paiement/avalider.php +++ b/htdocs/compta/paiement/avalider.php @@ -71,7 +71,8 @@ if ($socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; } $sql.= " WHERE p.fk_paiement = c.id"; -$sql.= " AND p.entity = ".$conf->entity; +$sql.= " AND p.entity = " . $conf->entity; +$sql.= " AND c.entity = " . getEntity('c_paiement', 2); if ($socid) { $sql.= " AND f.fk_soc = ".$socid; @@ -111,7 +112,7 @@ if ($resql) while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - + print ''; print ''; print '\n"; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 20afa14e0ca..45d64cf547e 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -36,7 +36,7 @@ class RemiseCheque extends CommonObject public $element='chequereceipt'; public $table_element='bordereau_cheque'; public $picto = 'payment'; - + var $num; var $intitule; //! Numero d'erreur Plage 1024-1279 @@ -345,7 +345,7 @@ class RemiseCheque extends CommonObject $this->errno = 0; $this->db->begin(); - + $numref = $this->getNextNumRef(); if ($this->errno == 0 && $numref) @@ -716,7 +716,7 @@ class RemiseCheque extends CommonObject * * @param int $bank_id Id of bank transaction line concerned * @param date $rejection_date Date to use on the negative payment - * @return int Id of negative payment line created + * @return int Id of negative payment line created */ function rejectCheck($bank_id, $rejection_date) { @@ -727,19 +727,19 @@ class RemiseCheque extends CommonObject $bankline = new AccountLine($db); $bankline->fetch($bank_id); - + /* Conciliation is allowed because when check is returned, a new line is created onto bank transaction log. if ($bankline->rappro) { $this->error='ActionRefusedLineAlreadyConciliated'; return -1; }*/ - + $this->db->begin(); - + // Not conciliated, we can delete it - //$bankline->delete($user); // We delete - + //$bankline->delete($user); // We delete + $bankaccount = $payment->fk_account; // Get invoices list to reopen them @@ -753,7 +753,7 @@ class RemiseCheque extends CommonObject $rejectedPayment = new Paiement($db); $rejectedPayment->amounts = array(); $rejectedPayment->datepaye = $rejection_date; - $rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement'); + $rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement','code','id',getEntity('c_paiement', 2)); $rejectedPayment->num_paiement = $payment->numero; while($obj = $db->fetch_object($resql)) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 03a7759e52c..0c66873647a 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -38,7 +38,7 @@ class Paiement extends CommonObject public $element='payment'; public $table_element='paiement'; public $picto = 'payment'; - + var $facid; var $datepaye; /** @@ -65,7 +65,7 @@ class Paiement extends CommonObject // fk_paiement dans llx_paiement_facture est le rowid du paiement var $fk_paiement; // Type of paiment - + /** * Constructor * @@ -93,6 +93,7 @@ class Paiement extends CommonObject $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid '; $sql.= ' WHERE p.fk_paiement = c.id'; + $sql.= ' AND c.entity = ' . getEntity('c_paiement', 2); if ($id > 0) $sql.= ' AND p.rowid = '.$id; else if ($ref) @@ -153,14 +154,14 @@ class Paiement extends CommonObject $error = 0; $way = $this->getWay(); - + $now=dol_now(); - + // Clean parameters $totalamount = 0; $totalamount_converted = 0; $atleastonepaymentnotnull = 0; - + if ($way == 'dolibarr') { $amounts = &$this->amounts; @@ -171,22 +172,22 @@ class Paiement extends CommonObject $amounts = &$this->multicurrency_amounts; $amounts_to_update = &$this->amounts; } - + foreach ($amounts as $key => $value) // How payment is dispatch { $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value, $way); $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); - + $newvalue = price2num($value,'MT'); $amounts[$key] = $newvalue; $totalamount += $newvalue; if (! empty($newvalue)) $atleastonepaymentnotnull++; } - + $totalamount = price2num($totalamount); $totalamount_converted = price2num($totalamount_converted); - + // Check parameters if (empty($totalamount) && empty($atleastonepaymentnotnull)) // We accept negative amounts for withdraw reject but not empty arrays { @@ -211,7 +212,7 @@ class Paiement extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_creat)"; $sql.= " VALUES (".$conf->entity.", '".$ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.")"; - + dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -227,7 +228,7 @@ class Paiement extends CommonObject $amount = price2num($amount); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)'; $sql .= ' VALUES ('.$facid.', '. $this->id.', \''.$amount.'\', \''.$this->multicurrency_amounts[$key].'\')'; - + dol_syslog(get_class($this).'::Create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -279,7 +280,7 @@ class Paiement extends CommonObject if ($invoice->type == Facture::TYPE_DEPOSIT) { $amount_ht = $amount_tva = $amount_ttc = array(); - + // Loop on each vat rate $i = 0; foreach ($invoice->lines as $line) @@ -292,20 +293,20 @@ class Paiement extends CommonObject $i ++; } } - + // Insert one discount by VAT rate category $discount = new DiscountAbsolute($this->db); $discount->description = '(DEPOSIT)'; $discount->fk_soc = $invoice->socid; $discount->fk_facture_source = $invoice->id; - + foreach ($amount_ht as $tva_tx => $xxx) { $discount->amount_ht = abs($amount_ht[$tva_tx]); $discount->amount_tva = abs($amount_tva[$tva_tx]); $discount->amount_ttc = abs($amount_ttc[$tva_tx]); $discount->tva_tx = abs($tva_tx); - + $result = $discount->create($user); if ($result < 0) { @@ -313,14 +314,14 @@ class Paiement extends CommonObject break; } } - + if ($error) { setEventMessages($discount->error, $discount->errors, 'errors'); $error++; - } + } } - + // Set invoice to paid if (! $error) { @@ -520,13 +521,13 @@ class Paiement extends CommonObject $acc = new Account($this->db); $result=$acc->fetch($this->fk_account); - + $totalamount=$this->amount; if (empty($totalamount)) $totalamount=$this->total; // For backward compatibility - + // if dolibarr currency != bank currency then we received an amount in customer currency (currently I don't manage the case : my currency is USD, the customer currency is EUR and he paid me in GBP. Seems no sense for me) if (!empty($conf->multicurrency->enabled) && $conf->currency != $acc->currency_code) $totalamount=$this->multicurrency_amount; - + if ($mode == 'payment_supplier') $totalamount=-$totalamount; // Insert payment into llx_bank @@ -796,7 +797,7 @@ class Paiement extends CommonObject /** * Information sur l'objet - * + * * @param int $id id du paiement dont il faut afficher les infos * @return void */ @@ -962,13 +963,13 @@ class Paiement extends CommonObject /** * get the right way of payment - * + * * @return string 'dolibarr' if standard comportment or paid in dolibarr currency, 'customer' if payment received from multicurrency inputs */ function getWay() { global $conf; - + $way = 'dolibarr'; if (!empty($conf->multicurrency->enabled)) { @@ -981,10 +982,10 @@ class Paiement extends CommonObject } } } - + return $way; } - + /** * Initialise an instance with random values. * Used to build previews or test instances. diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index efc9d5e10d2..450ff455e13 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -117,7 +117,8 @@ if (GETPOST("orphelins")) $sql.= " ".MAIN_DB_PREFIX."c_paiement as c)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; $sql.= " WHERE p.fk_paiement = c.id"; - $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.entity = " . $conf->entity; + $sql.= " AND c.entity = " . getEntity('c_paiement', 2); $sql.= " AND pf.fk_facture IS NULL"; // Add where from hooks $parameters=array(); @@ -148,7 +149,8 @@ else $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; } $sql.= " WHERE p.fk_paiement = c.id"; - $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.entity = " . $conf->entity; + $sql.= " AND c.entity = " . getEntity('c_paiement', 2); if (! $user->rights->societe->client->voir && ! $socid) { $sql.= " AND sc.fk_user = " .$user->id; @@ -177,7 +179,7 @@ else if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'"; if ($search_payment_num != '') $sql .= natural_search('p.num_paiement', $search_payment_num); - if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); + if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); if ($search_company) $sql .= natural_search('s.nom', $search_company); // Add where from hooks $parameters=array(); @@ -211,7 +213,7 @@ if ($resql) $param.=($search_amount?"&search_amount=".urlencode($search_amount):""); $param.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - + print ''; if ($optioncss != '') print ''; print ''; @@ -220,9 +222,9 @@ if ($resql) print ''; print ''; print ''; - + print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords,'title_accountancy.png', 0, '', '', $limit); - + print '
'; print '
'.$arraytitle.''.$langs->trans('Date').'
'; @@ -634,36 +634,36 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Date print ''.dol_print_date($db->jdate($objp->df),'day')."'.$objp->multicurrency_code."'; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc); print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { print price($sign * $multicurrency_payment); if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes); if ($multicurrency_deposits) print '+'.price($multicurrency_deposits); } print ''; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); print ''.price($sign * $objp->total_ttc).''.price($sign * $paiement); if ($creditnotes) print '+'.price($creditnotes); @@ -696,14 +696,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "'; - + // Add remind multicurrency amount $namef = 'multicurrency_amount_'.$objp->facid; $nameRemain = 'multicurrency_remain_'.$objp->facid; - + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { if ($action != 'add_paiement') @@ -723,7 +723,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Warning - print ''; + print ''; //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
"; if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) || $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) @@ -744,7 +744,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $totalrecudeposits+=$deposits; $i++; } - + if ($i > 1) { // Print total @@ -802,7 +802,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
'; if (!empty($totalpayment)) $text=$langs->trans('ConfirmCustomerPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); - if (!empty($multicurrency_totalpayment)) + if (!empty($multicurrency_totalpayment)) { $text.='
'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); } @@ -835,7 +835,8 @@ if (! GETPOST('action','aZ09')) $sql.=', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; $sql.= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; - $sql.= ' AND f.entity = '.$conf->entity; + $sql.= ' AND f.entity = ' . $conf->entity; + $sql.= ' AND c.entity = ' . getEntity('c_paiement', 2); if ($socid) { $sql.= ' AND f.fk_soc = '.$socid; @@ -864,7 +865,7 @@ if (! GETPOST('action','aZ09')) while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - + print '
'.$objp->facnumber."'.dol_print_date($db->jdate($objp->dp))."
'.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."
'."\n"; @@ -277,15 +279,15 @@ if ($resql) } print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"p.amount","",$param,'align="right"',$sortfield,$sortorder); //print_liste_field_titre($langs->trans("Invoices"),"","","",$param,'align="left"',$sortfield,$sortorder); - + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - + if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - + while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); @@ -314,7 +316,7 @@ if ($resql) // Type print ''; - + // Payment number print ''; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 62ee285d70b..632efaf5d43 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -234,7 +234,7 @@ if ($result) { while ($i < $num) { $objp = $db->fetch_object($result); - + print ''; print "\n"; @@ -278,7 +278,7 @@ if ($modecompta != 'CREANCES-DETTES') while ($i < $num) { $objp = $db->fetch_object($result); - + print ''; print "'; print ''; print ''; @@ -363,7 +363,7 @@ if ($result) { while ($i < $num) { $objp = $db->fetch_object($result); - + print ''; print "\n"; @@ -381,7 +381,7 @@ if ($result) { } } else - { + { print ''; print ''; print ''; @@ -581,7 +581,7 @@ if (! empty($conf->salaries->enabled)) $column = 'p.datep'; } - print ''; + print ''; $sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; @@ -595,7 +595,7 @@ if (! empty($conf->salaries->enabled)) if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; $sql.= $db->order($newsortfield, $sortorder); - + dol_syslog("get payment salaries"); $result=$db->query($sql); $subtotal_ht = 0; @@ -663,7 +663,7 @@ if (! empty($conf->expensereport->enabled)) $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement', 2); $sql.= " WHERE p.entity = ".getEntity('expensereport'); $sql.= " AND p.fk_statut>=5"; @@ -676,7 +676,7 @@ if (! empty($conf->expensereport->enabled)) { $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; } - + $sql.= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm"; $newsortfield = $sortfield; if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.ref'; @@ -744,9 +744,9 @@ if (! empty($conf->don->enabled)) $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement', 2); $sql.= " WHERE p.entity = ".getEntity('donation'); - $sql.= " AND fk_statut >= 2"; + $sql.= " AND fk_statut >= 2"; } if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'"; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 45cbbfe3a46..f1851bcfa36 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -492,14 +492,14 @@ if (! empty($conf->salaries->enabled)) } else { $column = 'p.datep'; } - + $subtotal_ht = 0; $subtotal_ttc = 0; $sql = "SELECT p.label as nom, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql.= " WHERE p.entity = ".$conf->entity; $sql.= " GROUP BY p.label, dm"; - + dol_syslog("get social salaries payments"); $result=$db->query($sql); if ($result) @@ -512,13 +512,13 @@ if (! empty($conf->salaries->enabled)) while ($i < $num) { $obj = $db->fetch_object($result); - + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; $decaiss[$obj->dm] += $obj->amount; - + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; $decaiss_ttc[$obj->dm] += $obj->amount; - + $i++; } } @@ -546,7 +546,7 @@ if (! empty($conf->expensereport->enabled)) $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement', 2); $sql.= " WHERE p.entity = ".getEntity('expensereport'); $sql.= " AND p.fk_statut>=5"; @@ -568,7 +568,7 @@ if (! empty($conf->expensereport->enabled)) { if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; $decaiss[$obj->dm] += $obj->amount_ht; - + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; $decaiss_ttc[$obj->dm] += $obj->amount_ttc; @@ -588,7 +588,7 @@ if (! empty($conf->don->enabled)) { $subtotal_ht = 0; $subtotal_ttc = 0; - + if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; @@ -599,7 +599,7 @@ if (! empty($conf->don->enabled)) $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement', 2); $sql.= " WHERE p.entity = ".getEntity('donation'); $sql.= " AND fk_statut >= 2"; } @@ -617,13 +617,13 @@ if (! empty($conf->don->enabled)) while ($i < $num) { $obj = $db->fetch_object($result); - + if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0; $encaiss[$obj->dm] += $obj->amount; - + if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0; $encaiss_ttc[$obj->dm] += $obj->amount; - + $i++; } } @@ -671,7 +671,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) { $mois_modulo = $mois; if($mois>12) {$mois_modulo = $mois-12;} - + print ''; print ""; for ($annee = $year_start ; $annee <= $year_end ; $annee++) diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index e87fc932c50..8d053028887 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -98,7 +98,7 @@ $sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.da $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement', 2); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,"; $sql.= " ".MAIN_DB_PREFIX."user as u"; @@ -151,9 +151,9 @@ if ($result) print ''; print ''; print ''; - + print_barre_liste($langs->trans("SalariesPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); - + print '
'; print '
'.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.$objp->num_paiement.'
 ".$langs->trans("Bills").' '.$objp->name."
 ".$langs->trans("Bills")." ".$langs->trans("Other")." (".$langs->trans("PaymentsNotLinkedToInvoice").")\n"; @@ -301,7 +301,7 @@ if ($modecompta != 'CREANCES-DETTES') } if ($total_ttc == 0) -{ +{ print '
 '.$langs->trans("None").'
 ".$langs->trans("Bills")." socid."\">".$objp->name."
 '.$langs->trans("None").'
'.$langs->trans("Salaries").'
'.$langs->trans("Salaries").'
".dol_print_date(dol_mktime(12,0,0,$mois_modulo,1,$annee),"%B")."
'."\n"; @@ -188,7 +188,7 @@ if ($result) $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''; - + print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Employee"),$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder); @@ -199,13 +199,13 @@ if ($result) print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - + print "\n"; while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); - + print ''; $userstatic->id=$obj->uid; @@ -238,11 +238,11 @@ if ($result) $accountstatic->id=$obj->bid; $accountstatic->ref=$obj->bref; $accountstatic->number=$obj->bnumber; - + if (! empty($conf->accounting->enabled)) { $accountstatic->account_number=$obj->account_number; - + $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($obj->fk_accountancy_journal); diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 630197cfc78..7d32da6f937 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -67,7 +67,7 @@ if ($action == 'reopen' && $user->rights->tax->charges->creer) { if ($object->paye) { $result = $object->set_unpaid($user); - if ($result > 0) + if ($result > 0) { header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); exit(); @@ -350,7 +350,7 @@ if ($action == 'create') print ''; } @@ -405,7 +405,7 @@ if ($id > 0) $head=tax_prepare_head($object); $totalpaye = $object->getSommePaiement(); - + // Clone confirmation if ($action === 'clone') { @@ -473,21 +473,21 @@ if ($id > 0) $morehtmlref.=''; } } - } + } $morehtmlref.=''; - + $linkback = '' . $langs->trans("BackToList") . ''; - + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status - + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); - + print '
'; print '
'; print '
'; - + print '
'.$langs->trans("Project").''; $numproject=$formproject->select_projects(-1, $projectid,'fk_project',0,0,1,1); - + print '
'; - + // Type print '"; print ""; @@ -581,6 +581,7 @@ if ($id > 0) $sql.= " AND p.fk_charge = cs.rowid"; $sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND p.fk_typepaiement = c.id"; + $sql.= " AND c.entity = " . getEntity('c_paiement', 2); $sql.= " ORDER BY dp DESC"; //print $sql; @@ -588,7 +589,7 @@ if ($id > 0) if ($resql) { $totalpaye = 0; - + $num = $db->num_rows($resql); $i = 0; $total = 0; print '
'.$langs->trans("Type")."".$object->type_libelle."
'; @@ -598,14 +599,14 @@ if ($id > 0) print ''; print ''; print ''; - + $var=true; if ($num > 0) { while ($i < $num) { $objp = $db->fetch_object($resql); - + print "'; print '\n"; @@ -619,18 +620,18 @@ if ($id > 0) } else { - + print ''; } - + //if ($object->status == ChargeSociales::STATUS_DRAFT) //{ print "\n"; print "\n"; - + $resteapayer = $object->amount - $totalpaye; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; - + print ""; print '\n"; //} @@ -640,12 +641,12 @@ if ($id > 0) else { dol_print_error($db); - } - + } + print ''; print ''; print ''; - + print '
'; dol_fiche_end(); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index cf359d691ec..9d1205c1cb0 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -/** +/** * Classe permettant la gestion des paiements des charges * La tva collectee n'est calculee que sur les factures payees. */ @@ -36,7 +36,7 @@ class ChargeSociales extends CommonObject public $table='chargesociales'; public $table_element='chargesociales'; public $picto = 'bill'; - + /** * {@inheritdoc} */ @@ -83,7 +83,7 @@ class ChargeSociales extends CommonObject $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement', 2); if ($ref) $sql.= " WHERE cs.rowid = ".$ref; else $sql.= " WHERE cs.rowid = ".$id; @@ -110,7 +110,7 @@ class ChargeSociales extends CommonObject $this->paye = $obj->paye; $this->periode = $this->db->jdate($obj->periode); $this->import_key = $this->import_key; - + $this->db->free($resql); return 1; @@ -378,7 +378,7 @@ class ChargeSociales extends CommonObject if ($return) return 1; else return -1; } - + /** * Retourne le libelle du statut d'une charge (impaye, payee) * @@ -445,7 +445,7 @@ class ChargeSociales extends CommonObject if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } - + return "Error, mode/status not found"; } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 1d553831f99..8a5c8f0eeef 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -78,7 +78,7 @@ class PaymentSocialContribution extends CommonObject $now=dol_now(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - + // Validate parametres if (! $this->datepaye) { @@ -125,7 +125,7 @@ class PaymentSocialContribution extends CommonObject if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge"); - + // Insere tableau des montants / factures foreach ($this->amounts as $key => $amount) { @@ -137,7 +137,7 @@ class PaymentSocialContribution extends CommonObject // If we want to closed payed invoices if ($closepaidcontrib) { - + $contrib=new ChargeSociales($this->db); $contrib->fetch($contribid); $paiement = $contrib->getSommePaiement(); @@ -205,6 +205,7 @@ class PaymentSocialContribution extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."paiementcharge as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepaiement = pt.id"; + $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 6c88305f72e..bd4b3efc8b7 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -88,7 +88,7 @@ print ''; print ''; print ''; -if ($mode != 'sconly') +if ($mode != 'sconly') { $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."":""); print_barre_liste($title,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$center,$num,$totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); @@ -133,7 +133,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs,"; $sql.= " ".MAIN_DB_PREFIX."paiementcharge as pc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity = " . getEntity('c_paiement', 2); $sql.= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid"; $sql.= " AND cs.entity = ".$conf->entity; if ($year > 0) @@ -260,7 +260,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $total = $total + $obj->amount; - + print ''; print ''."\n"; @@ -362,7 +362,7 @@ while($j<$numlt) $total = $total + $obj->amount; - + print ''; print ''."\n"; @@ -408,7 +408,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $sal = new PaymentSalary($db); print "
"; - + print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary"; @@ -444,7 +444,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $total = $total + $obj->amount; - + print ''; print ''."\n"; diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 44c45a65dc7..12ed60d6d68 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -100,7 +100,7 @@ $bankstatic = new Account($db); $sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,"; $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement', 2); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql.= " WHERE t.entity = ".$conf->entity; @@ -156,9 +156,9 @@ if ($result) print ''; print ''; print ''; - + print_barre_liste($langs->trans("VATPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines, 'title_accountancy', 0, '', '', $limit); - + print '
'; print '
'.$langs->trans("Type").''.$langs->trans("Amount").'
"; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."
'.$langs->trans("None").'
".$langs->trans("AlreadyPaid")." :".price($totalpaye)."
".$langs->trans("AmountExpected")." :".price($object->amount)."
".$langs->trans("RemainderToPay")." :'.price($resteapayer)."
'.dol_print_date($db->jdate($obj->dm),'day').'
'.dol_print_date($db->jdate($obj->dm),'day').'
'.dol_print_date($db->jdate($obj->dateep),'day').'
'; @@ -199,7 +199,7 @@ if ($result) print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"t.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - + while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); @@ -252,7 +252,7 @@ if ($result) $i++; } - + $colspan=5; if (! empty($conf->banque->enabled)) $colspan++; print ''; @@ -261,7 +261,7 @@ if ($result) print "
'.$langs->trans("Total").'
"; print ''; - + print ''; $db->free($result); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 4b6d70b1366..2be205fa5c9 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -51,7 +51,7 @@ abstract class CommonInvoice extends CommonObject const TYPE_DEPOSIT = 3; /** - * Proforma invoice. + * Proforma invoice. * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! */ const TYPE_PROFORMA = 4; @@ -89,7 +89,7 @@ abstract class CommonInvoice extends CommonObject */ const STATUS_ABANDONED = 3; - + /** * Return remain amount to pay. Property ->id and ->total_ttc must be set. * This does not include open direct debit requests. @@ -141,7 +141,7 @@ abstract class CommonInvoice extends CommonObject return -1; } } - + /** * Return amount (with tax) of all deposits invoices used by invoice. * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). @@ -154,11 +154,11 @@ abstract class CommonInvoice extends CommonObject if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { // TODO - return 0; + return 0; } - + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - + $discountstatic=new DiscountAbsolute($this->db); $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); if ($result >= 0) @@ -185,9 +185,9 @@ abstract class CommonInvoice extends CommonObject // TODO return 0; } - + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - + $discountstatic=new DiscountAbsolute($this->db); $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); if ($result >= 0) @@ -200,7 +200,7 @@ abstract class CommonInvoice extends CommonObject return -1; } } - + /** * Renvoie tableau des ids de facture avoir issus de la facture * @@ -418,7 +418,7 @@ abstract class CommonInvoice extends CommonObject if ($status == 0) return ''.$langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'),'statut0'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5'); if (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7'); - if ($alreadypaid <= 0) + if ($alreadypaid <= 0) { if ($type == self::TYPE_CREDIT_NOTE) return ''.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' '.img_picto($langs->trans('StatusNotRefunded'),'statut1'); return ''.$langs->trans('Bill'.$prefix.'StatusNotPaid').' '.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); @@ -450,8 +450,9 @@ abstract class CommonInvoice extends CommonObject $sqltemp = 'SELECT c.type_cdr,c.nbjour,c.decalage'; $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; - if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; - else $sqltemp.= " WHERE c.code='".$this->db->escape($cond_reglement)."'"; + $sqltemp.= " WHERE c.entity = " . getEntity('c_payment_term', 2); + if (is_numeric($cond_reglement)) $sqltemp.= " AND c.rowid=".$cond_reglement; + else $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); $resqltemp=$this->db->query($sqltemp); @@ -497,13 +498,13 @@ abstract class CommonInvoice extends CommonObject } elseif($cdr_type == 2 && !empty($cdr_nbjour)) // Application de la règle, le N du mois courant ou suivant { - + $date_piece = dol_mktime(0,0,0,date('m', $this->date),date('d', $this->date),date('Y', $this->date)); // Sans les heures minutes et secondes $date_lim_current = dol_mktime(0,0,0,date('m', $this->date),$cdr_nbjour,date('Y', $this->date)); // Sans les heures minutes et secondes $date_lim_next = strtotime(date('Y-m-d', $date_lim_current).' +1month'); - + $diff = $date_piece - $date_lim_current; - + if($diff < 0) $datelim = $date_lim_current; else $datelim = $date_lim_next; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 01d28ecde24..6b265584948 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2958,8 +2958,8 @@ class Form $sql = "SELECT id, code, libelle as label, type, active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement"; - //if ($active >= 0) $sql.= " WHERE active = ".$active; $sql.= " WHERE entity = " . getEntity('c_paiement', 2); + //if ($active >= 0) $sql.= " AND active = ".$active; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 169aec16307..008049d3d13 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -151,7 +151,7 @@ class Translate $this->load($domain); } } - + /** * Load translation key-value for a particular file, into a memory array. * If data for file already loaded, do nothing. @@ -177,7 +177,7 @@ class Translate global $conf,$db; //dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang); - + // Check parameters if (empty($domain)) { @@ -185,8 +185,8 @@ class Translate return -1; } if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys - - + + // Load $this->tab_translate[] from database if (empty($loadfromfileonly) && count($this->tab_translate) == 0) $this->loadFromDatabase($db); // Nothing was loaded yet, so we load database. @@ -278,14 +278,14 @@ class Translate * and split the rest until a line feed. * This is more efficient than fgets + explode + trim by a factor of ~2. */ - while ($line = fscanf($fp, "%[^= ]%*[ =]%[^\n]")) + while ($line = fscanf($fp, "%[^= ]%*[ =]%[^\n]")) { - if (isset($line[1])) + if (isset($line[1])) { list($key, $value) = $line; //if ($domain == 'orders') print "Domain=$domain, found a string for $tab[0] with value $tab[1]. Currently in cache ".$this->tab_translate[$key]."
"; //if ($key == 'Order') print "Domain=$domain, found a string for key=$key=$tab[0] with value $tab[1]. Currently in cache ".$this->tab_translate[$key]."
"; - if (empty($this->tab_translate[$key])) + if (empty($this->tab_translate[$key])) { // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries) $value = preg_replace('/\\n/', "\n", $value); // Parse and render carriage returns if ($key == 'DIRECTION') { // This is to declare direction of language @@ -375,8 +375,8 @@ class Translate if (! empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]]=$tmparray2[1]; } } - } - + } + // Check to be sure that SeparatorDecimal differs from SeparatorThousand if (! empty($this->tab_translate["SeparatorDecimal"]) && ! empty($this->tab_translate["SeparatorThousand"]) && $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"]=''; @@ -401,7 +401,7 @@ class Translate global $conf; $domain='database'; - + // Check parameters if (empty($db)) return 0; // Database handler can't be used @@ -418,7 +418,7 @@ class Translate } $this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only. - + $fileread=0; $langofdir=(empty($forcelangdir)?$this->defaultlang:$forcelangdir); @@ -467,24 +467,24 @@ class Translate if (! $found && ! empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Overwrite translation with database read - $sql="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."'"; + $sql="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."'"; $resql=$db->query($sql); - + if ($resql) { $num = $db->num_rows($resql); if ($num) { if ($usecachekey) $tabtranslatedomain=array(); // To save lang content in cache - + $i = 0; while ($i < $num) // Ex: Need 225ms for all fgets on all lang file for Third party page. Same speed than file_get_contents { $obj=$db->fetch_object($resql); - + $key=$obj->transkey; $value=$obj->transvalue; - + //print "Domain=$domain, found a string for $tab[0] with value $tab[1]
"; if (empty($this->tab_translate[$key])) // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries) { @@ -493,12 +493,12 @@ class Translate $this->tab_translate[$key]=$value; if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache } - + $i++; } - + $fileread=1; - + // TODO Move cache write out of loop on dirs // To save lang content for usecachekey into cache if ($usecachekey && count($tabtranslatedomain)) @@ -524,9 +524,9 @@ class Translate return 1; } - - - + + + /** * Return translated value of key for special keys ("Currency...", "Civility...", ...). * Search in lang file, then into database. Key must be any complete entry into lang file: CurrencyEUR, ... @@ -559,7 +559,7 @@ class Translate } elseif (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i',$key,$reg)) { - $newstr=$this->getLabelFromKey($db,$reg[1],'c_paiement','code','libelle'); + $newstr=$this->getLabelFromKey($db,$reg[1],'c_paiement','code','libelle','',getEntity('c_paiement', 2)); } elseif (preg_match('/^OppStatusShort([0-9A-Z]+)$/i',$key,$reg)) { @@ -611,8 +611,8 @@ class Translate $str=preg_replace('/'.preg_quote($tmparray2[0]).'/',$tmparray2[1],$str); } } - - if (! preg_match('/^Format/',$key)) + + if (! preg_match('/^Format/',$key)) { //print $str; $str=sprintf($str,$param1,$param2,$param3,$param4); // Replace %s and %d except for FormatXXX strings. @@ -690,9 +690,9 @@ class Translate $tmparray2=explode(':',$tmp); $str=preg_replace('/'.preg_quote($tmparray2[0]).'/',$tmparray2[1],$str); } - } + } - if (! preg_match('/^Format/',$key)) + if (! preg_match('/^Format/',$key)) { //print $str; $str=sprintf($str,$param1,$param2,$param3,$param4); // Replace %s and %d except for FormatXXX strings. @@ -867,10 +867,11 @@ class Translate * @param string $fieldkey Field for key * @param string $fieldlabel Field for label * @param string $keyforselect Use another value than the translation key for the where into select + * @param int $entity Field for filter by entity * @return string Label in UTF8 (but without entities) * @see dol_getIdFromCode */ - function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel,$keyforselect='') + function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel,$keyforselect='',$entity=null) { // If key empty if ($key == '') return ''; @@ -893,6 +894,8 @@ class Translate $sql = "SELECT ".$fieldlabel." as label"; $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; $sql.= " WHERE ".$fieldkey." = '".($keyforselect?$keyforselect:$key)."'"; + if (! is_null($entity)) + $sql.= " AND entity = " . (int) $entity; dol_syslog(get_class($this).'::getLabelFromKey', LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -930,7 +933,7 @@ class Translate } /** - * Return a currency code into its symbol. + * Return a currency code into its symbol. * If mb_convert_encoding is not available, return currency code. * * @param string $currency_code Currency code diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 688624dc838..204e55778af 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5652,10 +5652,11 @@ function dol_osencode($str) * @param string $tablename Table name without prefix * @param string $fieldkey Field for code * @param string $fieldid Field for id + * @param int $entity Field for filter by entity * @return int <0 if KO, Id of code if OK * @see $langs->getLabelFromKey */ -function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') +function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id',$entity=null) { global $cache_codes; @@ -5671,6 +5672,8 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') $sql = "SELECT ".$fieldid." as valuetoget"; $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; $sql.= " WHERE ".$fieldkey." = '".$db->escape($key)."'"; + if (! is_null($entity)) + $sql.= " AND entity = " . (int) $entity; dol_syslog('dol_getIdFromCode', LOG_DEBUG); $resql = $db->query($sql); if ($resql) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 693dd2e412f..2d0e09f57dc 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -255,16 +255,16 @@ class pdf_crabe extends ModelePDFFactures // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); $nbpayments = count($object->getListOfPayments()); - + // Create pdf instance $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment 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) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -509,7 +509,7 @@ class pdf_crabe extends ModelePDFFactures $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); // Enough for 6 chars - + if ($this->situationinvoice) { $pdf->MultiCell($this->posxprogress-$this->posxqty-0.8, 4, $qty, 0, 'R'); @@ -769,7 +769,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('','', $default_font_size - 4); - + // Loop on each deposits and credit notes included $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql.= " re.description, re.fk_facture_source,"; @@ -818,11 +818,11 @@ class pdf_crabe extends ModelePDFFactures $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id AND cp.entity = " . getEntity('c_paiement', 2); $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1"; $sql.= " ORDER BY p.datep"; - + $resql=$this->db->query($sql); if ($resql) { @@ -1052,7 +1052,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - + $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); @@ -1071,7 +1071,7 @@ class pdf_crabe extends ModelePDFFactures else { // FIXME amount of vat not supported with multicurrency - + //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ @@ -1397,7 +1397,7 @@ class pdf_crabe extends ModelePDFFactures if (empty($hidetop)) { $pdf->SetXY($this->posxqty-1, $tab_top+1); - + if($this->situationinvoice) { $pdf->MultiCell($this->posxprogress-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); @@ -1411,14 +1411,14 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); } } - + if ($this->situationinvoice) { $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height); - + if (empty($hidetop)) { - + $pdf->SetXY($this->posxprogress, $tab_top+1); - + if($conf->global->PRODUCT_USE_UNITS) { $pdf->MultiCell($this->posxunit-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); @@ -1431,9 +1431,9 @@ class pdf_crabe extends ModelePDFFactures { $pdf->MultiCell($this->postotalht-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); } - + } - + } if($conf->global->PRODUCT_USE_UNITS) { @@ -1554,7 +1554,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $textref=$outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref); - if ($object->statut == Facture::STATUS_DRAFT) + if ($object->statut == Facture::STATUS_DRAFT) { $pdf->SetTextColor(128,0,0); $textref.=' - '.$outputlangs->trans("NotValidated"); @@ -1616,7 +1616,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax,"day",false,$outputlangs), '', 'R'); } - + if ($object->type != 2) { $posy+=3; @@ -1647,7 +1647,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($w, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=1; // Show list of linked objects diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 3af85a1944d..71849018554 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -71,7 +71,7 @@ class modFacture extends DolibarrModules $this->warnings_activation = array('FR'=>'WarningNoteModuleInvoiceForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') $this->warnings_activation = array(); $this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') - + // Config pages $this->config_page_url = array("facture.php"); @@ -99,7 +99,7 @@ class modFacture extends DolibarrModules $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; - + /*$this->const[$r][0] = "FACTURE_DRAFT_WATERMARK"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "__(Draft)__"; @@ -107,7 +107,7 @@ class modFacture extends DolibarrModules $this->const[$r][4] = 0; $r++;*/ - + // Boxes //$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php')); $this->boxes = array( @@ -116,16 +116,16 @@ class modFacture extends DolibarrModules 2=>array('file'=>'box_graph_invoices_permonth.php','enabledbydefaulton'=>'Home') ); - // Cronjobs + // Cronjobs $this->cronjobs = array( - 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), + 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600) - ); - // List of cron jobs entries to add - // Example: + ); + // List of cron jobs entries to add + // Example: // $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) // ); // Permissions @@ -206,8 +206,8 @@ class modFacture extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=1; @@ -267,7 +267,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement AND pt.entity = ' . getEntity('c_paiement', 2); $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON b.rowid = p.fk_bank'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index bf37a7e73d8..a0f479e79fe 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -111,7 +111,7 @@ class modSalaries extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'write'; $this->rights[$r][5] = ''; - + $r++; $this->rights[$r][0] = 513; $this->rights[$r][1] = 'Create/modify payment of salaries'; @@ -119,7 +119,7 @@ class modSalaries extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'write'; $this->rights[$r][5] = ''; - + $r++; $this->rights[$r][0] = 514; $this->rights[$r][1] = 'Delete contracts/salaries'; @@ -140,8 +140,8 @@ class modSalaries extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; @@ -157,7 +157,7 @@ class modSalaries extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id AND cp.entity = ' . getEntity('c_paiement', 2); $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user').')'; } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index c4c93537444..641597de539 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -284,8 +284,8 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid AND payterm.entity = ' . getEntity('c_payment_term', 2); + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id AND paymode.entity = ' . getEntity('c_paiement', 2); $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) { $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 11ee8a32d7d..406e07b094d 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -180,6 +180,7 @@ class pdf_paiement $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid "; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND p.fk_paiement = c.id "; + $sql.= " AND c.entity = " . getEntity('c_paiement', 2); $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; if (! $user->rights->societe->client->voir && ! $socid) { @@ -199,7 +200,7 @@ class pdf_paiement while ($i < $num) { $objp = $this->db->fetch_object($result); - + $lines[$i][0] = $objp->facnumber; $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true); diff --git a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php index f20e912e1ed..f220c51b59d 100644 --- a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php @@ -178,6 +178,7 @@ class pdf_paiement_fourn $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid "; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND p.fk_paiement = c.id "; + $sql.= " AND c.entity = " . getEntity('c_paiement', 2); $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; if (! $user->rights->societe->client->voir && ! $socid) { @@ -197,7 +198,7 @@ class pdf_paiement_fourn while ($i < $num) { $objp = $this->db->fetch_object($result); - + $lines[$i][0] = $objp->ref; $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true); 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 1e7e6f4bcad..20f77c68a0e 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -914,7 +914,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id AND cp.entity = " . getEntity('c_paiement', 2); $sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id; $sql.= " ORDER BY p.datep"; $resql=$this->db->query($sql); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 8e1bd00d893..e671f06845b 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -683,6 +683,7 @@ if (! empty($id) && $action != 'edit') $sql.= " AND p.fk_donation = d.rowid"; $sql.= " AND d.entity = ".$conf->entity; $sql.= " AND p.fk_typepayment = c.id"; + $sql.= " AND c.entity = " . getEntity('c_paiement', 2); $sql.= " ORDER BY dp"; //print $sql; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 695314bb526..2c92e52be7c 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -39,7 +39,7 @@ class Don extends CommonObject public $fk_element = 'fk_donation'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe var $picto = 'generic'; - + var $date; var $amount; var $societe; @@ -163,7 +163,7 @@ class Don extends CommonObject global $conf, $user,$langs; $now = dol_now(); - + // Charge tableau des id de societe socids $socids = array(); @@ -611,7 +611,7 @@ class Don extends CommonObject $sql.= " c.code as country_code, c.label as country"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_projet"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment AND cp.entity = " . getEntity('c_paiement', 2); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid"; if (! empty($id)) { diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 9d478c4d7f5..5752878fecf 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -32,7 +32,7 @@ class PaymentDonation extends CommonObject public $element='payment_donation'; //!< Id that identify managed objects public $table_element='payment_donation'; //!< Name of table without prefix where object is stored public $picto = 'payment'; - + public $rowid; public $fk_donation; @@ -175,6 +175,7 @@ class PaymentDonation extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_donation as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; + $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); @@ -443,7 +444,7 @@ class PaymentDonation extends CommonObject { return ''; } - + /** * Renvoi le libelle d'un statut donne * @@ -454,11 +455,11 @@ class PaymentDonation extends CommonObject function LibStatut($statut,$mode=0) { global $langs; - + return ''; } - - + + /** * Initialise an instance with random values. * Used to build previews or test instances. diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index dff27139581..181b8d90b1d 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -125,7 +125,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) + if ($cancel) { $action=''; $fk_projet=''; @@ -158,7 +158,7 @@ if (empty($reshook)) { // Because createFromClone modifies the object, we must clone it so that we can restore it later if it fails $orig = clone $object; - + $result=$object->createFromClone(GETPOST('fk_user_author','int')); if ($result > 0) { @@ -174,7 +174,7 @@ if (empty($reshook)) } } } - + if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer) { $object = new ExpenseReport($db); @@ -190,20 +190,20 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + if ($action == 'add' && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); - + $object->date_debut = $date_start; $object->date_fin = $date_end; - + $object->fk_user_author = GETPOST('fk_user_author','int'); if (! ($object->fk_user_author > 0)) $object->fk_user_author = $user->id; - + $fuser=new User($db); $fuser->fetch($object->fk_user_author); - + $object->fk_statut = 1; $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); $object->fk_user_validator = GETPOST('fk_user_validator','int'); @@ -215,20 +215,20 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) $error++; } - + if ($object->periode_existe($fuser,$object->date_debut,$object->date_fin)) { $error++; setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); $action='create'; } - + if (! $error) { $db->begin(); - + $id = $object->create($user); - + if ($id > 0) { $db->commit(); @@ -243,25 +243,25 @@ if (empty($reshook)) } } } - + if ($action == 'update' && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); - + $object->date_debut = $date_start; $object->date_fin = $date_end; - + if($object->fk_statut < 3) { $object->fk_user_validator = GETPOST('fk_user_validator','int'); } - + $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); $object->note_public = GETPOST('note_public'); $object->note_private = GETPOST('note_private'); $object->fk_user_modif = $user->id; - + $result = $object->update($user); if ($result > 0) { @@ -273,14 +273,14 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + if ($action == 'update_extras') { // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error++; - + if (! $error) { // Actions on extra fields (by external module or standard code) @@ -296,17 +296,17 @@ if (empty($reshook)) } else if ($reshook < 0) $error++; } - + if ($error) $action = 'edit_extras'; } - + if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); $result = $object->setValidate($user); - + if ($result > 0) { // Define output language @@ -322,51 +322,51 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0 && $object->fk_user_validator > 0) { $langs->load("mails"); - + // TO $destinataire = new User($db); $destinataire->fetch($object->fk_user_validator); $emailTo = $destinataire->email; - + // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_author); $emailFrom = $expediteur->email; - + if ($emailTo && $emailFrom) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportWaitingForApproval"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $message = $langs->transnoentities("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link); - + // Rebuild pdf /* $object->setDocModel($user,""); $resultPDF = expensereport_pdf_create($db,$id,'',"",$langs); - + if($resultPDF): // ATTACHMENT array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref).".pdf"); array_push($mimetype,"application/pdf"); */ - + // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -411,13 +411,13 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); $result = $object->set_save_from_refuse($user); - + if ($result > 0) { // Define output language @@ -433,11 +433,11 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0) { // Send mail @@ -446,7 +446,7 @@ if (empty($reshook)) $destinataire = new User($db); $destinataire->fetch($object->fk_user_validator); $emailTo = $destinataire->email; - + // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_author); @@ -455,10 +455,10 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportWaitingForReApproval"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $dateRefusEx = explode(" ",$object->date_refuse); @@ -481,7 +481,7 @@ if (empty($reshook)) // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -526,15 +526,15 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + // Approve if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->approve) { $object = new ExpenseReport($db); $object->fetch($id); - + $result = $object->setApproved($user); - + if ($result > 0) { // Define output language @@ -550,11 +550,11 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0) { // Send mail @@ -576,19 +576,19 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportApproved"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); - + // Rebuilt pdf /* $object->setDocModel($user,""); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - + if($resultPDF { // ATTACHMENT @@ -600,7 +600,7 @@ if (empty($reshook)) */ $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -673,7 +673,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -686,28 +686,28 @@ if (empty($reshook)) $destinataire = new User($db); $destinataire->fetch($object->fk_user_author); $emailTo = $destinataire->email; - + // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_refuse); $emailFrom = $expediteur->email; - + if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportRefused"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_refuse'], $link); - + // Rebuilt pdf /* $object->setDocModel($user,""); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - + if($resultPDF { // ATTACHMENT @@ -796,7 +796,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -814,23 +814,23 @@ if (empty($reshook)) $expediteur = new User($db); $expediteur->fetch($object->fk_user_cancel); $emailFrom = $expediteur->email; - + if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportCanceled"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_cancel'], $link); - + // Rebuilt pdf /* $object->setDocModel($user,""); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - + if($resultPDF { // ATTACHMENT @@ -840,10 +840,10 @@ if (empty($reshook)) array_push($mimetype,"application/pdf"); } */ - + // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -881,7 +881,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); $action=''; - } + } } else { @@ -918,7 +918,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -961,7 +961,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -983,7 +983,7 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportPaid"); @@ -1154,7 +1154,7 @@ if (empty($reshook)) { $object = new ExpenseReport($db); $object->fetch($id); - + $object_ligne = new ExpenseReportLine($db); $object_ligne->fetch(GETPOST("rowid")); $total_ht = $object_ligne->total_ht; @@ -1178,11 +1178,11 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + $object->update_totaux_del($object_ligne->total_ht,$object_ligne->total_tva); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']); exit; @@ -1244,13 +1244,13 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + $result = $object->recalculer($id); - + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } @@ -1296,7 +1296,7 @@ if ($action == 'create') print ''; print ''; - + // Date start print ''; print ''; @@ -1304,7 +1304,7 @@ if ($action == 'create') $form->select_date($date_start?$date_start:-1,'date_debut',0,0,0,'',1,1); print ''; print ''; - + // Date end print ''; print ''; @@ -1312,7 +1312,7 @@ if ($action == 'create') $form->select_date($date_end?$date_end:-1,'date_fin',0,0,0,'',1,1); print ''; print ''; - + print ''; print ''; print ''; print ''; - + // Payment mode if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { @@ -1400,7 +1400,7 @@ else $result = $object->fetch($id, $ref); $res = $object->fetch_optionals($object->id, $extralabels); - + if ($result > 0) { if (! in_array($object->fk_user_author, $user->getAllChildIds(1))) @@ -1698,7 +1698,7 @@ else $userfee=new User($db); $result = $userfee->fetch($object->fk_user_validator); if ($result > 0) print $userfee->getNomUrl(-1); - if (empty($userfee->email) || ! isValidEmail($userfee->email)) + if (empty($userfee->email) || ! isValidEmail($userfee->email)) { $langs->load("errors"); print img_warning($langs->trans("ErrorBadEMail", $userfee->email)); @@ -1851,6 +1851,7 @@ else $sql.= " AND p.fk_expensereport = e.rowid"; $sql.= " AND e.entity = ".$conf->entity; $sql.= " AND p.fk_typepayment = c.id"; + $sql.= " AND c.entity = " . getEntity('c_paiement', 2); $sql.= " ORDER BY dp"; $resql = $db->query($sql); @@ -1902,9 +1903,9 @@ else { print ''; print ''; - + $remaintopay = $object->total_ttc - $totalpaid; - + print ''; print ''; } @@ -1984,7 +1985,7 @@ else if ($action != 'editline' || $objp->rowid != GETPOST('rowid')) { print ''; - + print ''; @@ -2006,7 +2007,7 @@ else print ''; print ''; print ''; - + if ($action != 'editline') { print ''; @@ -2034,7 +2035,7 @@ else if ($action == 'editline' && $objp->rowid == GETPOST('rowid')) { print ''; - + print ''; // Select date @@ -2049,7 +2050,7 @@ else $formproject->select_projects(-1, $objp->fk_projet,'fk_projet', 0, 0, 1, 1); print ''; } - + // Select type print ''; - + print ''; } // Fin si c'est payé/validé print '
'.$langs->trans("DateStart").'
'.$langs->trans("DateEnd").'
'.$langs->trans("User").''; @@ -1341,7 +1341,7 @@ if ($action == 'create') } print '
'.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
'.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
'.$langs->trans("RemainderToPay").':'.price($remaintopay).'
'; print img_picto($langs->trans("Document"), "object_generic"); print ' '.$piece_comptable.''.vatrate($objp->vatrate,true).''.price($objp->value_unit).''.$objp->qty.''.price($objp->total_ht).'
'; select_type_fees_id($objp->type_fees_code,'fk_c_type_fees'); @@ -2168,13 +2169,13 @@ else } print '
'; print ''; - + print ''; } else @@ -2290,7 +2291,7 @@ if ($action != 'create' && $action != 'edit') // If status is Appoved // -------------------- - + if ($user->rights->expensereport->approve && $object->fk_statut == 5) { print ''; @@ -2309,7 +2310,7 @@ if ($action != 'create' && $action != 'edit') print ''; } } - + // If bank module is not used if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5) { @@ -2319,26 +2320,26 @@ if ($action != 'create' && $action != 'edit') print '"; } } - + if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->fk_statut == 5) { // Cancel print ''; } - + // TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled. if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->fk_statut == 6) { // Cancel print ''; } - + // Clone if ($user->rights->expensereport->creer) { print ''; } - - /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ + + /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->fk_statut <= 4) { // Delete @@ -2389,7 +2390,7 @@ if ($action != 'create' && $action != 'edit' && ($id || $ref)) $object->fetch_thirdparty(); $result = $object->add_object_linked('fichinter', GETPOST('LinkedFichinter')); } - + // Show links to link elements $linktoelements=array(); if (! empty($conf->global->EXPENSES_LINK_TO_INTERVENTION)) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index ffef31cad8b..05be397fde3 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -37,9 +37,9 @@ class ExpenseReport extends CommonObject var $picto = 'trip'; var $lignes=array(); - + public $date_debut; - + public $date_fin; var $fk_user_validator; @@ -65,7 +65,7 @@ class ExpenseReport extends CommonObject // Update var $date_modif; var $fk_user_modif; - + // Refus var $date_refuse; var $detail_refuse; @@ -128,17 +128,17 @@ class ExpenseReport extends CommonObject $now = dol_now(); $error = 0; - + // Check parameters - if (empty($this->date_debut) || empty($this->date_fin)) + if (empty($this->date_debut) || empty($this->date_fin)) { $this->error='ErrorFieldRequired'; return -1; } - + $fuserid = $this->fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. if (empty($fuserid)) $fuserid = $user->id; - + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; @@ -208,7 +208,7 @@ class ExpenseReport extends CommonObject $result=$this->update_price(); if ($result > 0) { - + if (!$notrigger) { // Call trigger @@ -262,19 +262,19 @@ class ExpenseReport extends CommonObject function createFromClone($fk_user_author) { global $user,$hookmanager; - + $error=0; - + if (empty($fk_user_author)) $fk_user_author = $user->id; - + $this->context['createfromclone'] = 'createfromclone'; - + $this->db->begin(); - + // get extrafields so they will be clone //foreach($this->lines as $line) //$line->fetch_optionals($line->rowid); - + // Load source object $objFrom = clone $this; @@ -325,8 +325,8 @@ class ExpenseReport extends CommonObject return -1; } } - - + + /** * update * @@ -341,7 +341,7 @@ class ExpenseReport extends CommonObject $error = 0; $this->db->begin(); - + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql.= " total_ht = ".$this->total_ht; $sql.= " , total_ttc = ".$this->total_ttc; @@ -417,7 +417,8 @@ class ExpenseReport extends CommonObject $sql.= " d.fk_user_valid, d.fk_user_approve,"; $sql.= " d.fk_statut as status, d.fk_c_paiement,"; $sql.= " dp.libelle as libelle_paiement, dp.code as code_paiement"; // INNER JOIN paiement - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id AND dp.entity = " . getEntity('c_paiement', 2); if ($ref) $sql.= " WHERE d.ref = '".$this->db->escape($ref)."'"; else $sql.= " WHERE d.rowid = ".$id; $sql.= $restrict; @@ -455,7 +456,7 @@ class ExpenseReport extends CommonObject $this->fk_user_refuse = $obj->fk_user_refuse; $this->fk_user_cancel = $obj->fk_user_cancel; $this->fk_user_approve = $obj->fk_user_approve; - + $user_author = new User($this->db); if ($this->fk_user_author > 0) $user_author->fetch($this->fk_user_author); @@ -512,7 +513,7 @@ class ExpenseReport extends CommonObject { $error = 0; $this->db->begin(); - + $sql = "UPDATE ".MAIN_DB_PREFIX."expensereport"; $sql.= " SET fk_statut = 6, paid=1"; $sql.= " WHERE rowid = ".$id." AND fk_statut = 5"; @@ -533,7 +534,7 @@ class ExpenseReport extends CommonObject } // End call triggers } - + if (empty($error)) { $this->db->commit(); @@ -670,7 +671,7 @@ class ExpenseReport extends CommonObject $auser->fetch($obj->fk_user_approve); $this->user_approve = $auser; } - + } $this->db->free($resql); } @@ -704,8 +705,8 @@ class ExpenseReport extends CommonObject $this->date_fin = $now; $this->date_approve = $now; - $type_fees_id = 2; // TF_TRIP - + $type_fees_id = 2; // TF_TRIP + $this->status = 5; $this->fk_statut = 5; @@ -1078,14 +1079,14 @@ class ExpenseReport extends CommonObject { $now = dol_now(); $this->db->begin(); - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 2, fk_user_valid = ".$fuser->id.", date_valid='".$this->db->idate($now)."'"; if ($update_number_int) { $sql.= ", ref_number_int = ".$ref_number_int; } $sql.= ' WHERE rowid = '.$this->id; - + $resql=$this->db->query($sql); if ($resql) { @@ -1099,7 +1100,7 @@ class ExpenseReport extends CommonObject } // End call triggers } - + if (empty($error)) { $this->db->commit(); @@ -1123,7 +1124,7 @@ class ExpenseReport extends CommonObject { dol_syslog(get_class($this)."::setValidate expensereport already with validated status", LOG_WARNING); } - + return 0; } @@ -1183,13 +1184,13 @@ class ExpenseReport extends CommonObject { $now=dol_now(); $error = 0; - + // date approval $this->date_approve = $this->db->idate($now); if ($this->fk_statut != 5) { $this->db->begin(); - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 5, fk_user_approve = ".$fuser->id.","; $sql.= " date_approve='".$this->db->idate($this->date_approve)."'"; @@ -1206,7 +1207,7 @@ class ExpenseReport extends CommonObject } // End call triggers } - + if (empty($error)) { $this->db->commit(); @@ -1230,7 +1231,7 @@ class ExpenseReport extends CommonObject { dol_syslog(get_class($this)."::setApproved expensereport already with approve status", LOG_WARNING); } - + return 0; } @@ -1245,7 +1246,7 @@ class ExpenseReport extends CommonObject { $now = dol_now(); $error = 0; - + // date de refus if ($this->fk_statut != 99) { @@ -1261,7 +1262,7 @@ class ExpenseReport extends CommonObject $this->fk_user_refuse = $fuser->id; $this->detail_refuse = $details; $this->date_refuse = $now; - + if (!$notrigger) { // Call trigger @@ -1272,7 +1273,7 @@ class ExpenseReport extends CommonObject } // End call triggers } - + if (empty($error)) { $this->db->commit(); @@ -1308,11 +1309,11 @@ class ExpenseReport extends CommonObject function set_unpaid($fuser, $notrigger = 0) { $error = 0; - + if ($this->fk_c_deplacement_statuts != 5) { $this->db->begin(); - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET fk_statut = 5"; $sql.= ' WHERE rowid = '.$this->id; @@ -1331,7 +1332,7 @@ class ExpenseReport extends CommonObject } // End call triggers } - + if (empty($error)) { $this->db->commit(); @@ -1372,7 +1373,7 @@ class ExpenseReport extends CommonObject if ($this->fk_statut != 4) { $this->db->begin(); - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET fk_statut = 4, fk_user_cancel = ".$fuser->id; $sql.= ", date_cancel='".$this->db->idate($this->date_cancel)."'"; @@ -1393,7 +1394,7 @@ class ExpenseReport extends CommonObject } // End call triggers } - + if (empty($error)) { $this->db->commit(); @@ -1433,7 +1434,7 @@ class ExpenseReport extends CommonObject $sql = 'SELECT MAX(de.ref_number_int) as max'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' de'; - + $result = $this->db->query($sql); if($this->db->num_rows($result) > 0): @@ -1758,7 +1759,7 @@ class ExpenseReport extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; $sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve'; //print $sql; - + dol_syslog(get_class($this)."::fetch_users_approver_expensereport sql=".$sql); $result = $this->db->query($sql); if($result) @@ -1895,7 +1896,7 @@ class ExpenseReport extends CommonObject $now=dol_now(); $userchildids = $user->getAllChildIds(1); - + $sql = "SELECT ex.rowid, ex.date_valid"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; if ($option == 'toapprove') $sql.= " WHERE ex.fk_statut = 2"; @@ -1927,7 +1928,7 @@ class ExpenseReport extends CommonObject while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; - + if ($option == 'toapprove') { if ($this->db->jdate($obj->date_valid) < ($now - $conf->expensereport->approve->warning_delay)) { @@ -1951,7 +1952,7 @@ class ExpenseReport extends CommonObject return -1; } } - + /** * Return if an expense report is late or not * @@ -1961,11 +1962,11 @@ class ExpenseReport extends CommonObject public function hasDelay($option) { global $conf; - + //Only valid members if ($option == 'toapprove' && $this->status != 2) return false; if ($option == 'topay' && $this->status != 5) return false; - + $now = dol_now(); if ($option == 'toapprove') { @@ -1973,7 +1974,7 @@ class ExpenseReport extends CommonObject } else return ($this->datevalid?$this->datevalid:$this->date_valid) < ($now - $conf->expensereport->payment->warning_delay); - } + } } diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index edd80a0bff5..51321460760 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -168,6 +168,7 @@ class PaymentExpenseReport extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_expensereport as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; + $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); @@ -447,7 +448,7 @@ class PaymentExpenseReport extends CommonObject function LibStatut($statut,$mode=0) { global $langs; - + return ''; } @@ -506,7 +507,7 @@ class PaymentExpenseReport extends CommonObject $total=$this->total; if ($mode == 'payment_expensereport') $amount=$total; - + // Insert payment into llx_bank $bank_line_id = $acc->addline( $this->datepaid, @@ -543,7 +544,7 @@ class PaymentExpenseReport extends CommonObject dol_print_error($this->db); } } - + // Add link 'user' in bank_url between user and bank transaction if (! $error) { @@ -561,7 +562,7 @@ class PaymentExpenseReport extends CommonObject $er->user->getFullName($langs), 'user' ); - if ($result <= 0) + if ($result <= 0) { $this->error=$this->db->lasterror(); dol_syslog(get_class($this).'::addPaymentToBank '.$this->error); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 159f76249df..84b346028c1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -45,7 +45,7 @@ class CommandeFournisseur extends CommonOrder public $fk_element = 'fk_commande'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='order'; - + /** * {@inheritdoc} */ @@ -132,9 +132,9 @@ class CommandeFournisseur extends CommonOrder * Draft status */ const STATUS_DRAFT = 0; - - - + + + /** * Constructor * @@ -190,8 +190,8 @@ class CommandeFournisseur extends CommonOrder $sql.= ', c.fk_incoterms, c.location_incoterms'; $sql.= ', i.libelle as libelle_incoterms'; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (c.fk_mode_reglement = p.id)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid AND cr.entity = " . getEntity('c_payment_term', 2) . ")"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (c.fk_mode_reglement = p.id AND p.entity = " . getEntity('c_paiement', 2) . ")"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; $sql.= " WHERE c.entity = ".$conf->entity; @@ -318,7 +318,7 @@ class CommandeFournisseur extends CommonOrder $line->subprice = $objp->subprice; $line->pu_ht = $objp->subprice; $line->remise_percent = $objp->remise_percent; - + $line->vat_src_code = $objp->vat_src_code; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; @@ -615,7 +615,7 @@ class CommandeFournisseur extends CommonOrder $picto='order'; $url = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$this->id; - + $linkclose=''; if (empty($notooltip)) { @@ -627,7 +627,7 @@ class CommandeFournisseur extends CommonOrder $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; @@ -1378,7 +1378,7 @@ class CommandeFournisseur extends CommonOrder } $desc=trim($desc); $ref_supplier=''; // Ref of supplier price when we add line - + // Check parameters if ($qty < 1 && ! $fk_product) { @@ -1402,7 +1402,7 @@ class CommandeFournisseur extends CommonOrder { $product_type = $prod->type; $label = $prod->label; - + // We use 'none' instead of $fourn_ref, because fourn_ref may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', $this->fk_soc); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc @@ -1414,7 +1414,7 @@ class CommandeFournisseur extends CommonOrder if ($remise_percent == 0 && $prod->remise_percent !=0) $remise_percent =$prod->remise_percent; - + } if ($result == 0) // If result == 0, we failed to found the supplier reference price { @@ -1422,7 +1422,7 @@ class CommandeFournisseur extends CommonOrder $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); - //$pu = $prod->fourn_pu; // We do not overwrite unit price + //$pu = $prod->fourn_pu; // We do not overwrite unit price //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price return -1; } @@ -1468,7 +1468,7 @@ class CommandeFournisseur extends CommonOrder $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx,$pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -1487,7 +1487,7 @@ class CommandeFournisseur extends CommonOrder $localtax2_type=$localtaxes_type[2]; $subprice = price2num($pu,'MU'); - + $rangmax = $this->line_max(); $rang = $rangmax + 1; @@ -1513,7 +1513,7 @@ class CommandeFournisseur extends CommonOrder $this->line->subprice=$pu_ht; $this->line->rang=$this->rang; $this->line->info_bits=$info_bits; - + $this->line->vat_src_code=$vat_src_code; $this->line->total_ht=$total_ht; $this->line->total_tva=$total_tva; @@ -2001,7 +2001,7 @@ class CommandeFournisseur extends CommonOrder $old_statut = $this->statut; $this->statut = $statut; $this->actionmsg2 = $comment; - + // Call trigger $result=$this->call_trigger('ORDER_SUPPLIER_RECEIVE',$user); if ($result < 0) $error++; @@ -2334,7 +2334,7 @@ class CommandeFournisseur extends CommonOrder $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2678,14 +2678,14 @@ class CommandeFournisseur extends CommonOrder if ($db->num_rows($query)) { $obj = $db->fetch_object($query); - + $string = $langs->trans($obj->code); if ($string == $obj->code) { $string = $obj->label != '-' ? $obj->label : ''; } return $string; - } + } } else dol_print_error($db); } @@ -2819,7 +2819,7 @@ class CommandeFournisseur extends CommonOrder return $text; } - + /** * Calc status regarding to dispatched stock * @@ -2828,7 +2828,7 @@ class CommandeFournisseur extends CommonOrder * @param string $comment Comment * @return int <0 if KO, 0 if not applicable, >0 if OK */ - public function calcAndSetStatusDispatch(User $user, $closeopenorder=1, $comment='') + public function calcAndSetStatusDispatch(User $user, $closeopenorder=1, $comment='') { global $conf, $langs; @@ -2845,14 +2845,14 @@ class CommandeFournisseur extends CommonOrder $filter['t.status']=1; } $ret=$supplierorderdispatch->fetchAll('','',0,0,$filter); - if ($ret<0) + if ($ret<0) { $this->error=$supplierorderdispatch->error; $this->errors=$supplierorderdispatch->errors; return $ret; - } - else + } + else { - if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) + if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) { //Build array with quantity deliverd by product foreach($supplierorderdispatch->lines as $line) { @@ -2861,12 +2861,12 @@ class CommandeFournisseur extends CommonOrder foreach($this->lines as $line) { $qtywished[$line->fk_product]+=$line->qty; } - + $date_liv = dol_now(); - + //Compare array $diff_array=array_diff_assoc($qtydelivered,$qtywished); - + if (count($diff_array)==0) //No diff => mean everythings is received { if ($closeopenorder) @@ -2888,8 +2888,8 @@ class CommandeFournisseur extends CommonOrder } return 4; } - } - else + } + else { //Diff => received partially $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' @@ -3014,12 +3014,12 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->date_start = $this->db->jdate($objp->date_start); $this->date_end = $this->db->jdate($objp->date_end); $this->fk_unit = $objp->fk_unit; - + $this->multicurrency_subprice = $objp->multicurrency_subprice; $this->multicurrency_total_ht = $objp->multicurrency_total_ht; $this->multicurrency_total_tva = $objp->multicurrency_total_tva; $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - + $this->db->free($result); return 1; } @@ -3208,7 +3208,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql.= ", subprice='".price2num($this->subprice)."'"; //$sql.= ",remise='".price2num($remise)."'"; $sql.= ", remise_percent='".price2num($this->remise_percent)."'"; - + $sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->vat_src_code)."'"; $sql.= ", tva_tx='".price2num($this->tva_tx)."'"; $sql.= ", localtax1_tx='".price2num($this->total_localtax1)."'"; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 5c8a41a0466..5ae4be6692d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -130,7 +130,7 @@ class FactureFournisseur extends CommonInvoice public $multicurrency_total_ttc; //! id of source invoice if replacement invoice or credit note public $fk_facture_source; - + /** * Standard invoice */ @@ -517,8 +517,8 @@ class FactureFournisseur extends CommonInvoice $sql.= ' t.fk_multicurrency, t.multicurrency_code, t.multicurrency_tx, t.multicurrency_total_ht, t.multicurrency_total_tva, t.multicurrency_total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (t.fk_cond_reglement = cr.rowid)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (t.fk_mode_reglement = p.id)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (t.fk_cond_reglement = cr.rowid AND cr.entity = " . getEntity('c_payment_term', 2) . ")"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (t.fk_mode_reglement = p.id AND p.entity = " . getEntity('c_paiement', 2) . ")"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid'; if ($id) $sql.= " WHERE t.rowid=".$id; if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."'"; @@ -883,7 +883,7 @@ class FactureFournisseur extends CommonInvoice } // Fin appel triggers } - + if (! $error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';'; @@ -902,7 +902,7 @@ class FactureFournisseur extends CommonInvoice $error++; } } - + if (! $error) { // Delete linked object diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 12fccab91d8..eb685f113ba 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -37,7 +37,7 @@ class PaiementFourn extends Paiement public $element='payment_supplier'; public $table_element='paiementfourn'; public $picto = 'payment'; - + var $statut; //Status of payment. 0 = unvalidated; 1 = validated // fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...) // fk_paiement dans llx_paiement_facture est le rowid du paiement @@ -75,13 +75,14 @@ class PaiementFourn extends Paiement function fetch($id, $ref='', $fk_bank='') { $error=0; - + $sql = 'SELECT p.rowid, p.ref, p.entity, p.datep as dp, p.amount, p.statut, p.fk_bank,'; $sql.= ' c.code as paiement_code, c.libelle as paiement_type,'; $sql.= ' p.num_paiement, p.note, b.fk_account'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid '; $sql.= ' WHERE p.fk_paiement = c.id'; + $sql.= ' AND c.entity = ' . getEntity('c_paiement', 2); if ($id > 0) $sql.= ' AND p.rowid = '.$id; else if ($ref) @@ -141,9 +142,9 @@ class PaiementFourn extends Paiement // Clean parameters $totalamount = 0; $totalamount_converted = 0; - + dol_syslog(get_class($this)."::create", LOG_DEBUG); - + if ($way == 'dolibarr') { $amounts = &$this->amounts; @@ -154,13 +155,13 @@ class PaiementFourn extends Paiement $amounts = &$this->multicurrency_amounts; $amounts_to_update = &$this->amounts; } - + foreach ($amounts as $key => $value) { $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value, $way, 'facture_fourn'); $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); - + $newvalue = price2num($value,'MT'); $amounts[$key] = $newvalue; $totalamount += $newvalue; @@ -174,7 +175,7 @@ class PaiementFourn extends Paiement { $ref = $this->getNextNumRef(''); $now=dol_now(); - + if ($way == 'dolibarr') { $total = $totalamount; @@ -185,7 +186,7 @@ class PaiementFourn extends Paiement $total = $totalamount_converted; // Maybe use price2num with MT for the converted value $mtotal = $totalamount; } - + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn ('; $sql.= 'ref, entity, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; $sql.= " VALUES ('".$this->db->escape($ref)."', ".$conf->entity.", '".$this->db->idate($now)."',"; @@ -289,7 +290,7 @@ class PaiementFourn extends Paiement function delete($notrigger=0) { global $conf, $user, $langs; - + $bank_line_id = $this->bank_line; $this->db->begin(); @@ -358,7 +359,7 @@ class PaiementFourn extends Paiement return -4; } } - + if (! $notrigger) { // Appel des triggers @@ -370,7 +371,7 @@ class PaiementFourn extends Paiement } // Fin appel triggers } - + $this->db->commit(); return 1; } @@ -555,7 +556,7 @@ class PaiementFourn extends Paiement if ($withpicto != 2) $result.=$link.$text.$linkend; return $result; } - + /** * Initialise an instance with random values. * Used to build previews or test instances. @@ -579,7 +580,7 @@ class PaiementFourn extends Paiement $this->facid = 1; $this->datepaye = $nownotime; } - + /** * Return next reference of supplier invoice not already used (or last reference) * according to numbering module defined into constant SUPPLIER_PAYMENT_ADDON @@ -711,13 +712,13 @@ class PaiementFourn extends Paiement /** * get the right way of payment - * + * * @return string 'dolibarr' if standard comportment or paid in dolibarr currency, 'customer' if payment received from multicurrency inputs */ function getWay() { global $conf; - + $way = 'dolibarr'; if (!empty($conf->multicurrency->enabled)) { @@ -730,7 +731,7 @@ class PaiementFourn extends Paiement } } } - + return $way; } } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 0ec657ccdfe..7b97b70d71d 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2321,7 +2321,7 @@ else $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity = ' . getEntity('c_paiement', 2); $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; $sql.= ' ORDER BY p.datep, p.tms'; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index f51246d8eea..a6b395b030a 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -214,7 +214,7 @@ if (empty($reshook)) setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); $error++; } - + // Check if payments in both currency if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { @@ -341,7 +341,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { $obj = $db->fetch_object($resql); $total = $obj->total; - + print load_fiche_titre($langs->trans('DoPayment')); print '
'; @@ -353,7 +353,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; dol_fiche_head(null); - + print ''; print '
'.$langs->trans('Company').''; @@ -384,7 +384,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
'; dol_fiche_end(); - + $parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; @@ -447,19 +447,19 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie while ($i < $num) { $objp = $db->fetch_object($resql); - + print '
'; $invoicesupplierstatic->ref=$objp->ref; $invoicesupplierstatic->id=$objp->facid; print $invoicesupplierstatic->getNomUrl(1); print ''.$objp->ref_supplier.'!!!'.$objp->multicurrency_code."'; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { @@ -485,14 +485,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + { print price($objp->multicurrency_am); } print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { print price($objp->multicurrency_total_ttc - $objp->multicurrency_am); } @@ -500,20 +500,20 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print ''.price($objp->total_ttc).''.price($objp->am).''.price($objp->total_ttc - $objp->am).''; $namef = 'amount_'.$objp->facid; if (!empty($conf->use_javascript_ajax)) print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($objp->total_ttc - $objp->am)."'"); print ''; print "'; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) @@ -525,7 +525,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print "
\n"; - + print "
"; } $db->free($resql); @@ -574,7 +574,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
'; if (!empty($totalpayment)) $text=$langs->trans('ConfirmSupplierPayment',price($totalpayment),$langs->trans("Currency".$conf->currency)); - if (!empty($multicurrency_totalpayment)) + if (!empty($multicurrency_totalpayment)) { $text.='
'.$langs->trans('ConfirmSupplierPayment',price($multicurrency_totalpayment),$langs->trans("paymentInInvoiceCurrency")); } @@ -589,7 +589,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; } } - else dol_print_error($db); + else dol_print_error($db); } /* @@ -617,7 +617,7 @@ if (empty($action)) $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id AND c.entity = ' . getEntity('c_paiement', 2); $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; @@ -635,14 +635,14 @@ if (empty($action)) $sql.= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label"; if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= $db->order($sortfield,$sortorder); - + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - + $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); @@ -667,9 +667,9 @@ if (empty($action)) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - + print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); print '
'; @@ -680,24 +680,24 @@ if (empty($action)) print ''; print ''; print ''; - + $moreforfilter=''; - + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if ($moreforfilter) { print '
'; print $moreforfilter; print '
'; } - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print ''."\n"; @@ -739,11 +739,11 @@ if (empty($action)) //print_liste_field_titre($langs->trans('Invoice'),$_SERVER["PHP_SELF"],'ref_supplier','',$param,'',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; - + while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - + print ''; // Ref payment @@ -764,7 +764,7 @@ if (empty($action)) // Payment number print ''; - + print ''; - print ''; - + $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle)); print ''; From cfe667a3cee4991ef5208918de756350d0a25e19 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 14:29:04 +0200 Subject: [PATCH 015/428] Fix: show all logs --- .travis.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index a040342b2e6..c7f63c2ef33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -275,26 +275,26 @@ script: set +e cd htdocs/install php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log - php upgrade2.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-2.log - php step5.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-3.log + php upgrade2.php 3.5.0 3.6.0 >> $TRAVIS_BUILD_DIR/upgrade350360-2.log + php step5.php 3.5.0 3.6.0 >> $TRAVIS_BUILD_DIR/upgrade350360-3.log php upgrade.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370.log - php upgrade2.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-2.log - php step5.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-3.log + php upgrade2.php 3.6.0 3.7.0 >> $TRAVIS_BUILD_DIR/upgrade360370-2.log + php step5.php 3.6.0 3.7.0 >> $TRAVIS_BUILD_DIR/upgrade360370-3.log php upgrade.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-2.log - php step5.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-3.log + php upgrade2.php 3.7.0 3.8.0 >> $TRAVIS_BUILD_DIR/upgrade370380-2.log + php step5.php 3.7.0 3.8.0 >> $TRAVIS_BUILD_DIR/upgrade370380-3.log php upgrade.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390.log - php upgrade2.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-2.log - php step5.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-3.log + php upgrade2.php 3.8.0 3.9.0 >> $TRAVIS_BUILD_DIR/upgrade380390-2.log + php step5.php 3.8.0 3.9.0 >> $TRAVIS_BUILD_DIR/upgrade380390-3.log php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log - php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade390400-2.log - php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log + php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL >> $TRAVIS_BUILD_DIR/upgrade390400-2.log + php step5.php 3.9.0 4.0.0 >> $TRAVIS_BUILD_DIR/upgrade390400-3.log php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log - php upgrade2.php 4.0.0 5.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade400500-2.log - php step5.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-3.log + php upgrade2.php 4.0.0 5.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL >> $TRAVIS_BUILD_DIR/upgrade400500-2.log + php step5.php 4.0.0 5.0.0 >> $TRAVIS_BUILD_DIR/upgrade400500-3.log php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log - php upgrade2.php 5.0.0 6.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade500600-2.log - php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log + php upgrade2.php 5.0.0 6.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL >> $TRAVIS_BUILD_DIR/upgrade500600-2.log + php step5.php 5.0.0 6.0.0 >> $TRAVIS_BUILD_DIR/upgrade500600-3.log cd - set +e echo From d4edca585726314e6dab230a53c232b90d486ccc Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 14:30:02 +0200 Subject: [PATCH 016/428] Revert "Fix: show all logs" This reverts commit cfe667a3cee4991ef5208918de756350d0a25e19. --- .travis.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7f63c2ef33..a040342b2e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -275,26 +275,26 @@ script: set +e cd htdocs/install php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log - php upgrade2.php 3.5.0 3.6.0 >> $TRAVIS_BUILD_DIR/upgrade350360-2.log - php step5.php 3.5.0 3.6.0 >> $TRAVIS_BUILD_DIR/upgrade350360-3.log + php upgrade2.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-2.log + php step5.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-3.log php upgrade.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370.log - php upgrade2.php 3.6.0 3.7.0 >> $TRAVIS_BUILD_DIR/upgrade360370-2.log - php step5.php 3.6.0 3.7.0 >> $TRAVIS_BUILD_DIR/upgrade360370-3.log + php upgrade2.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-2.log + php step5.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-3.log php upgrade.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 >> $TRAVIS_BUILD_DIR/upgrade370380-2.log - php step5.php 3.7.0 3.8.0 >> $TRAVIS_BUILD_DIR/upgrade370380-3.log + php upgrade2.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-2.log + php step5.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-3.log php upgrade.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390.log - php upgrade2.php 3.8.0 3.9.0 >> $TRAVIS_BUILD_DIR/upgrade380390-2.log - php step5.php 3.8.0 3.9.0 >> $TRAVIS_BUILD_DIR/upgrade380390-3.log + php upgrade2.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-2.log + php step5.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-3.log php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log - php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL >> $TRAVIS_BUILD_DIR/upgrade390400-2.log - php step5.php 3.9.0 4.0.0 >> $TRAVIS_BUILD_DIR/upgrade390400-3.log + php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade390400-2.log + php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log - php upgrade2.php 4.0.0 5.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL >> $TRAVIS_BUILD_DIR/upgrade400500-2.log - php step5.php 4.0.0 5.0.0 >> $TRAVIS_BUILD_DIR/upgrade400500-3.log + php upgrade2.php 4.0.0 5.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade400500-2.log + php step5.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-3.log php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log - php upgrade2.php 5.0.0 6.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL >> $TRAVIS_BUILD_DIR/upgrade500600-2.log - php step5.php 5.0.0 6.0.0 >> $TRAVIS_BUILD_DIR/upgrade500600-3.log + php upgrade2.php 5.0.0 6.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade500600-2.log + php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log cd - set +e echo From 2864d431482741c976e609fbd5cf4ba3b8a05239 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 14:31:19 +0200 Subject: [PATCH 017/428] Fix: missing all logs --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a040342b2e6..8da1b9fcd2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -299,8 +299,10 @@ script: set +e echo #cat $TRAVIS_BUILD_DIR/upgrade400500-2.log + cat $TRAVIS_BUILD_DIR/upgrade500600.log cat $TRAVIS_BUILD_DIR/upgrade500600-2.log - cat /tmp/dolibarr_install.log + cat $TRAVIS_BUILD_DIR/upgrade500600-3.log + #cat /tmp/dolibarr_install.log - | echo "Unit testing" From fc08adff0f2a48a7798245abbaf0728ffc0e772c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 14:44:29 +0200 Subject: [PATCH 018/428] Fix: syntax error --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 996d218bf12..e990bb040e1 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -395,11 +395,11 @@ ALTER TABLE llx_usergroup_rights DROP INDEX fk_usergroup; ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id); ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid); -ALTER TABLE llx_c_paiement DROP PRIMARY KEY +ALTER TABLE llx_c_paiement DROP PRIMARY KEY; ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id; ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement; ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(id, entity, code); -ALTER TABLE llx_c_payment_term DROP PRIMARY KEY +ALTER TABLE llx_c_payment_term DROP PRIMARY KEY; ALTER TABLE llx_c_payment_term ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(rowid, entity, code); From 735a24fb07aa47ac180b1b386686a7f053540e29 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 15:43:43 +0200 Subject: [PATCH 019/428] Fix: remove debug --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8da1b9fcd2b..6b47e5de600 100644 --- a/.travis.yml +++ b/.travis.yml @@ -299,9 +299,9 @@ script: set +e echo #cat $TRAVIS_BUILD_DIR/upgrade400500-2.log - cat $TRAVIS_BUILD_DIR/upgrade500600.log - cat $TRAVIS_BUILD_DIR/upgrade500600-2.log - cat $TRAVIS_BUILD_DIR/upgrade500600-3.log + #cat $TRAVIS_BUILD_DIR/upgrade500600.log + #cat $TRAVIS_BUILD_DIR/upgrade500600-2.log + #cat $TRAVIS_BUILD_DIR/upgrade500600-3.log #cat /tmp/dolibarr_install.log - | From 6cac4b15d3e97be016608b1b16e749ab7fd11549 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 11 Jun 2017 06:54:40 +0200 Subject: [PATCH 020/428] Fix: Parameter must be an array or an object that implements Countable --- htdocs/core/lib/json.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 6b868663aa7..db343236e54 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -49,7 +49,7 @@ function dol_json_encode($elements) { dol_syslog('dol_json_encode() is deprecated. Please update your code to use native json_encode().', LOG_WARNING); - $num=count($elements); + $num = (is_null($elements) ? 0 : count($elements)); // for avoid phpunit error : "Parameter must be an array or an object that implements Countable" if (is_object($elements)) // Count number of properties for an object { $num=0; From c50b180e18b988d1bddfd113abc5fc624ab7e8d8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 19 Jun 2017 07:32:14 +0200 Subject: [PATCH 021/428] Fix: revert fix --- htdocs/install/inc.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index c799ab2c665..b9efc4eb8a4 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -453,11 +453,6 @@ function pFooter($nonext=0,$setuplang='',$jscheckfunction='', $withpleasewait=0) print '
'; if ($nonext == '2') { - if (!isset($_SERVER['REQUEST_URI'])) - { - $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'],1 ); - if (isset($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'].='?'.$_SERVER['QUERY_STRING']; } - } print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"])?$_SERVER["REQUEST_URI"].'&ignoreerrors=1':'').'

'; } From f876833b9a8eed8bbd1cb2789a91ca83a1df7882 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 18 Jul 2017 10:31:35 +0200 Subject: [PATCH 022/428] Fix : search on rowid don't work with pgsql and natural search --- htdocs/adherents/list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 4eda43dcca5..1334bc2ba7e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -83,7 +83,6 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'd.rowid'=>'Ref', 'd.login'=>'Login', 'd.lastname'=>'Lastname', 'd.firstname'=>'Firstname', From cbd8cb8cb75690859cd182c1ce458d6da3f23707 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 15 Sep 2017 17:32:49 +0200 Subject: [PATCH 023/428] Fix: missing merge conflict --- .../facture/class/paymentterm.class.php | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index b08594fd09a..36ff6d73791 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -260,9 +260,10 @@ class PaymentTerm // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user=null, $notrigger=0) - { - global $conf, $langs; + function update($user=null, $notrigger=0) + { + global $conf, $langs; + $error=0; // Clean parameters @@ -281,8 +282,8 @@ class PaymentTerm // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_payment_term SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_payment_term SET"; $sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").","; $sql.= " sortorder=".(isset($this->sortorder)?$this->sortorder:"null").","; $sql.= " active=".(isset($this->active)?$this->active:"null").","; @@ -291,44 +292,38 @@ class PaymentTerm // extends CommonObject $sql.= " type_cdr=".(isset($this->type_cdr)?$this->type_cdr:"null").","; $sql.= " nbjour=".(isset($this->nbjour)?$this->nbjour:"null").","; $sql.= " decalage=".(isset($this->decalage)?$this->decalage:"null").""; -<<<<<<< HEAD - - - $sql.= " WHERE rowid = " . $this->id; - $sql.= " AND entity = " . getEntity('c_payment_term', 2); -======= - $sql.= " WHERE rowid=".$this->id; ->>>>>>> branch 'develop' of https://github.com/Dolibarr/dolibarr.git + $sql.= " WHERE rowid = " . $this->id; + $sql.= " AND entity = " . getEntity('c_payment_term', 2); $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (! $error) { if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } + // Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + // End call triggers + } } - // Commit or rollback + // Commit or rollback if ($error) { foreach($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); } $this->db->rollback(); return -1*$error; @@ -338,7 +333,7 @@ class PaymentTerm // extends CommonObject $this->db->commit(); return 1; } - } + } /** From 9795f48046079fa4417af1d7b57efb50afa46ed4 Mon Sep 17 00:00:00 2001 From: arnaud Date: Mon, 18 Sep 2017 17:27:29 +0200 Subject: [PATCH 024/428] NEW comment system working with all objects --- htdocs/core/actions_comments.inc.php | 76 ++++ htdocs/core/class/comment.class.php | 322 +++++++++++++++++ htdocs/core/class/commonobject.class.php | 29 ++ htdocs/core/lib/project.lib.php | 18 +- htdocs/core/tpl/bloc_comment.tpl.php | 105 ++++++ .../install/mysql/migration/6.0.0-7.0.0.sql | 9 +- htdocs/langs/en_US/main.lang | 5 + htdocs/langs/en_US/projects.lang | 6 +- htdocs/langs/fr_FR/main.lang | 5 + htdocs/langs/fr_FR/projects.lang | 6 +- htdocs/projet/admin/project.php | 9 + htdocs/projet/class/project.class.php | 1 + htdocs/projet/class/task.class.php | 328 ------------------ htdocs/projet/comment.php | 189 ++++++++++ htdocs/projet/tasks/comment.php | 186 ++-------- 15 files changed, 787 insertions(+), 507 deletions(-) create mode 100644 htdocs/core/actions_comments.inc.php create mode 100644 htdocs/core/class/comment.class.php create mode 100644 htdocs/core/tpl/bloc_comment.tpl.php create mode 100644 htdocs/projet/comment.php diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php new file mode 100644 index 00000000000..185973cb258 --- /dev/null +++ b/htdocs/core/actions_comments.inc.php @@ -0,0 +1,76 @@ + + * + * 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/ + * + * $elementype must be defined. + */ + +/** + * \file htdocs/core/actions_comments.inc.php + * \brief Code for actions on comments pages + */ + + +require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php'; + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$comment = new Comment($db); + +/* + * Actions + */ + +if ($action == 'addcomment') +{ + $description = GETPOST('comment_description'); + if (!empty($description)) + { + $comment->description = $description; + $comment->datec = time(); + $comment->fk_element = GETPOST('id'); + $comment->element_type = GETPOST('comment_element_type'); + $comment->fk_user_author = $user->id; + $comment->entity = $conf->entity; + if ($comment->create($user) > 0) + { + setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); + header('Location: '.$varpage.'?id='.$id.($withproject?'&withproject=1':'')); + exit; + } + else + { + setEventMessages($comment->error, $comment->errors,'errors'); + $action=''; + } + } +} +if ($action == 'deletecomment') +{ + if ($comment->fetch($idcomment) >= 0) + { + if ($comment->delete($user) > 0) + { + setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs'); + header('Location: '.$varpage.'?id='.$id.($withproject?'&withproject=1':'')); + exit; + } + else + { + setEventMessages($comment->error, $comment->errors,'errors'); + $action=''; + } + } +} \ No newline at end of file diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php new file mode 100644 index 00000000000..0ec77405721 --- /dev/null +++ b/htdocs/core/class/comment.class.php @@ -0,0 +1,322 @@ +db = $db; + } + + + /** + * Create into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + function create($user, $notrigger=0) + { + global $conf, $langs; + + $error=0; + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; + $sql.= "description"; + $sql.= ", datec"; + $sql.= ", fk_element"; + $sql.= ", element_type"; + $sql.= ", fk_user_author"; + $sql.= ", entity"; + $sql.= ", import_key"; + $sql.= ") VALUES ("; + $sql.= "'".$this->db->escape($this->description)."'"; + $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); + $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; + $sql.= ", '".$this->db->escape($this->element_type)."'"; + $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; + $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); + $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); + $sql.= ")"; + + //var_dump($this->db); + //echo $sql; + + $this->db->begin(); + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from database + * + * @param int $id Id object + * @param int $ref ref object + * @return int <0 if KO, 0 if not found, >0 if OK + */ + function fetch($id, $ref='') + { + global $langs; + + $sql = "SELECT"; + $sql.= " c.rowid,"; + $sql.= " c.description,"; + $sql.= " c.datec,"; + $sql.= " c.tms,"; + $sql.= " c.fk_element,"; + $sql.= " c.element_type,"; + $sql.= " c.fk_user_author,"; + $sql.= " c.entity,"; + $sql.= " c.import_key"; + $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; + $sql.= " WHERE c.rowid = ".$id; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num_rows = $this->db->num_rows($resql); + + if ($num_rows) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->description = $obj->description; + $this->element_type = $obj->element_type; + $this->datec = $this->db->jdate($obj->datec); + $this->tms = $obj->tms; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_element = $obj->fk_element; + $this->entity = $obj->entity; + $this->import_key = $obj->import_key; + } + + $this->db->free($resql); + + if ($num_rows) return 1; + else return 0; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <=0 if KO, >0 if OK + */ + function update(User $user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); + if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); + if (isset($this->description)) $this->description=trim($this->description); + + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; + $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; + $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; + $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; + $sql.= " element_type='".$this->element_type."',"; + $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; + $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; + $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete task from database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $error=0; + + $this->db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; + $sql.= " WHERE rowid=".$this->id; + + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + }else{ + $this->db->commit(); + return 1; + } + } + + + /** + * Load comments linked with current task + * + * @return array Comment array + */ + public static function fetchAllFor($element_type, $fk_element) + { + global $db,$conf; + $TComments = array(); + if(!empty($element_type) && !empty($fk_element)) { + $sql = "SELECT"; + $sql.= " c.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; + $sql.= " WHERE c.fk_element = ".$fk_element; + $sql.= " AND c.element_type = '".$element_type."'"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " ORDER BY c.tms DESC"; + + dol_syslog("Comment::fetchAllFor", LOG_DEBUG); + $resql=$db->query($sql); + if ($resql) + { + $num_rows = $db->num_rows($resql); + if ($num_rows > 0) + { + while($obj = $db->fetch_object($resql)) + { + $comment = new self($db); + $comment->fetch($obj->rowid); + $TComments[] = $comment; + } + } + $db->free($resql); + } + } + return $TComments; + } +} \ No newline at end of file diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 54a907a3c0f..d7037ba5d2c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -308,6 +308,12 @@ abstract class CommonObject * @var CommonObjectLine[] */ public $lines; + + /** + * @var mixed Contains comments + * @see fetchComments() + */ + public $comments=array(); /** * @var int @@ -5283,5 +5289,28 @@ abstract class CommonObject // TODO... } + + /** + * Load comments linked with current task + * @return boolean 1 if ok + */ + public function fetchComments() + { + require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php'; + + $comment = new Comment($this->db); + $this->comments = Comment::fetchAllFor($this->element, $this->id); + return 1; + } + + /** + * Return nb comments already posted + * + * @return int + */ + public function getNbComments() + { + return count($this->comments); + } } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 0395f9f17ff..ec6be594ac3 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -66,7 +66,19 @@ function project_prepare_head($object) // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'project'); - + + + // Manage discussion + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) + { + $nbComments = $object->getNbComments(); + $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id; + $head[$h][1] = $langs->trans("CommentLink"); + if ($nbComments > 0) $head[$h][1].= ' '.$nbComments.''; + $head[$h][2] = 'project_comment'; + $h++; + } + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; @@ -179,9 +191,9 @@ function task_prepare_head($object) // Manage discussion if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { - $nbComments= $object->getNbComments(); + $nbComments = $object->getNbComments(); $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); - $head[$h][1] = $langs->trans("TaskCommentLinks"); + $head[$h][1] = $langs->trans("CommentLink"); if ($nbComments > 0) $head[$h][1].= ' '.$nbComments.''; $head[$h][2] = 'task_comment'; $h++; diff --git a/htdocs/core/tpl/bloc_comment.tpl.php b/htdocs/core/tpl/bloc_comment.tpl.php new file mode 100644 index 00000000000..b28699744d2 --- /dev/null +++ b/htdocs/core/tpl/bloc_comment.tpl.php @@ -0,0 +1,105 @@ +'; +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print '
'.$objp->num_paiement.''; if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.dol_trunc($objp->label,24).''; else print ' '; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 557d48be680..f42303361ec 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -639,6 +639,7 @@ if ($id > 0) $sql.= " AND p.fk_loan = l.rowid"; $sql.= " AND l.entity = ".$conf->entity; $sql.= " AND p.fk_typepayment = c.id"; + $sql.= " AND c.entity = " . getEntity('c_paiement', 2); $sql.= " ORDER BY dp DESC"; //print $sql; diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index fb6df8fcb6c..90729dd3468 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -179,6 +179,7 @@ class LoanSchedule extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX.$this->table_element." as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; + $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 52c822e54c1..ec6672d898f 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -178,6 +178,7 @@ class PaymentLoan extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_loan as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; + $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index e3f873476ba..dbb0dad7149 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -50,7 +50,7 @@ class SupplierProposal extends CommonObject public $fk_element='fk_supplier_proposal'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='propal'; - + /** * {@inheritdoc} */ @@ -140,7 +140,7 @@ class SupplierProposal extends CommonObject var $multicurrency_total_ht; var $multicurrency_total_tva; var $multicurrency_total_ttc; - + /** * Draft status */ @@ -160,10 +160,10 @@ class SupplierProposal extends CommonObject /** * Billed or closed/processed quote */ - const STATUS_CLOSE = 4; - - - + const STATUS_CLOSE = 4; + + + /** * Constructor * @@ -407,7 +407,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -419,7 +419,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - + // Rang to use $rangtouse = $rang; if ($rangtouse == -1) @@ -487,7 +487,7 @@ class SupplierProposal extends CommonObject $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - + // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; @@ -583,7 +583,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -595,7 +595,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - + // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; if ($remise_percent > 0) @@ -662,7 +662,7 @@ class SupplierProposal extends CommonObject if (is_array($array_option) && count($array_option)>0) { $this->line->array_options=$array_option; } - + // Multicurrency $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); $this->line->multicurrency_total_ht = $multicurrency_total_ht; @@ -1116,8 +1116,8 @@ class SupplierProposal extends CommonObject $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity = ' . getEntity('c_paiement', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term', 2); $sql.= " WHERE p.fk_statut = c.id"; $sql.= " AND p.entity = ".$conf->entity; if ($ref) $sql.= " AND p.ref='".$ref."'"; @@ -1180,7 +1180,7 @@ class SupplierProposal extends CommonObject $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - + if ($obj->fk_statut == 0) { $this->brouillon = 1; @@ -1271,7 +1271,7 @@ class SupplierProposal extends CommonObject $line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $line->fk_unit = $objp->fk_unit; - + $this->lines[$i] = $line; $i++; @@ -1653,7 +1653,7 @@ class SupplierProposal extends CommonObject { $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -1704,7 +1704,7 @@ class SupplierProposal extends CommonObject $productsupplier = new ProductFournisseur($this->db); dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); - foreach ($this->lines as $product) + foreach ($this->lines as $product) { if ($product->subprice <= 0) continue; @@ -1721,7 +1721,7 @@ class SupplierProposal extends CommonObject $this->createPriceFournisseur($product, $user); } } - + return 1; } @@ -2149,7 +2149,7 @@ class SupplierProposal extends CommonObject $response->label = $label; $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; $response->img = img_object('',"propal"); - + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { @@ -2187,7 +2187,7 @@ class SupplierProposal extends CommonObject global $user,$langs,$conf; // Load array of products prodids - $num_prods = 0; + $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; @@ -2250,7 +2250,7 @@ class SupplierProposal extends CommonObject $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; } - + $this->lines[$xnbp]=$line; $this->total_ht += $line->total_ht; @@ -2375,10 +2375,10 @@ class SupplierProposal extends CommonObject global $langs, $conf, $user; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $url=''; $result=''; - + $label=''.$langs->trans("ShowSupplierProposal").''; if (! empty($this->ref)) $label.= '
'.$langs->trans('Ref').': '.$this->ref; @@ -2396,7 +2396,7 @@ class SupplierProposal extends CommonObject if ($option == 'document') { $url = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$this->id. $get_params; } - + $linkclose=''; if (empty($notooltip) && $user->rights->propal->lire) { @@ -2408,7 +2408,7 @@ class SupplierProposal extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; @@ -2432,7 +2432,7 @@ class SupplierProposal extends CommonObject function getLinesArray() { // For other object, here we call fetch_lines. But fetch_lines does not exists on supplier proposal - + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; @@ -2486,7 +2486,7 @@ class SupplierProposal extends CommonObject $this->lines[$i]->rang = $obj->rang; $this->lines[$i]->ref_fourn = $obj->ref_produit_fourn; - + // Multicurrency $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; @@ -2541,7 +2541,7 @@ class SupplierProposal extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + /** * Function used to replace a thirdparty id with another one. * @@ -2555,10 +2555,10 @@ class SupplierProposal extends CommonObject $tables = array( 'supplier_proposal' ); - + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - + } @@ -2669,7 +2669,7 @@ class SupplierProposalLine extends CommonObjectLine var $skip_update_total; // Skip update price total for special lines var $ref_fourn; - + // Multicurrency var $fk_multicurrency; var $multicurrency_code; @@ -2750,7 +2750,7 @@ class SupplierProposalLine extends CommonObjectLine $this->product_desc = $objp->product_desc; $this->ref_fourn = $objp->ref_produit_forun; - + // Multicurrency $this->fk_multicurrency = $objp->fk_multicurrency; $this->multicurrency_code = $objp->multicurrency_code; @@ -2798,11 +2798,11 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; - + if (empty($this->pa_ht)) $this->pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { @@ -2869,7 +2869,7 @@ class SupplierProposalLine extends CommonObjectLine { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); $this->id=$this->rowid; - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -2982,11 +2982,11 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; - + if (empty($this->pa_ht)) $this->pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { @@ -3031,13 +3031,13 @@ class SupplierProposalLine extends CommonObjectLine if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " , ref_fourn=".(! empty($this->ref_fourn)?"'".$this->db->escape($this->ref_fourn)."'":"null"); $sql.= " , fk_unit=".($this->fk_unit?$this->fk_unit:'null'); - + // Multicurrency $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); From 58b3d86b498d18e99667a59a76ce1b5e98604cb0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 09:40:43 +0200 Subject: [PATCH 009/428] Fix: errors --- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/bank/class/account.class.php | 2 +- htdocs/compta/facture/card.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index eafb406ba58..ab76fa34fd5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1560,7 +1560,7 @@ class Commande extends CommonOrder $sql.= ', dr.code as demand_reason_code'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term', 2) . ')'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id AND cr.entity = ' . getEntity('c_paiement', 2) . ')'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement', 2) . ')'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 5330eca86a4..b5a2177d798 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -413,7 +413,7 @@ class Account extends CommonObject { $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE id=".$oper; - $sql.= " AND entity = " . getEntity('c_payement_term', 2) . ")"; + $sql.= " AND entity = " . getEntity('c_paiement', 2) . ")"; $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 319369fa304..6f1454de1d3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -653,7 +653,7 @@ if (empty($reshook)) $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; $sql.= ' WHERE pf.fk_facture = '.$object->id; $sql.= ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; - $sql.= ' AND p.entity = ' . getEntity('c_paiement', 2); + $sql.= ' AND c.entity = ' . getEntity('c_paiement', 2); $sql.= ' ORDER BY p.datep, p.tms'; $resql = $db->query($sql); From 4bd7bb86a79221131e7e95a90ca8064e8789adfb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 10:13:24 +0200 Subject: [PATCH 010/428] Fix: try to add functions.lib.php to avoid phpunit error --- test/phpunit/PricesTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 3e09450b9cb..a171feb9d3c 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -28,6 +28,7 @@ global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/functions.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/price.lib.php'; require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php'; @@ -160,7 +161,7 @@ class PricesTest extends PHPUnit_Framework_TestCase print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.56, 9.34795),$result1,'Test1 FR'); - + // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 $mysoc->country_code='FR'; $mysoc->country_id=1; @@ -168,7 +169,7 @@ class PricesTest extends PHPUnit_Framework_TestCase print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20),$result1,'Test1 FR'); - + /* * Country Spain */ From 0a442365a7e1278d8f469d8ae08e20d91d99bc40 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 11:46:26 +0200 Subject: [PATCH 011/428] Revert "Fix: try to add functions.lib.php to avoid phpunit error" This reverts commit 4bd7bb86a79221131e7e95a90ca8064e8789adfb. --- test/phpunit/PricesTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index a171feb9d3c..3e09450b9cb 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -28,7 +28,6 @@ global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; -require_once dirname(__FILE__).'/../../htdocs/core/lib/functions.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/price.lib.php'; require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php'; @@ -161,7 +160,7 @@ class PricesTest extends PHPUnit_Framework_TestCase print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.56, 9.34795),$result1,'Test1 FR'); - + // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 $mysoc->country_code='FR'; $mysoc->country_id=1; @@ -169,7 +168,7 @@ class PricesTest extends PHPUnit_Framework_TestCase print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20),$result1,'Test1 FR'); - + /* * Country Spain */ From 6dfb8e33c9354d0106752fe22edc1b344a73b27c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 12:12:25 +0200 Subject: [PATCH 012/428] Fix: try to debug --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bf34c86bd58..a040342b2e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -299,7 +299,8 @@ script: set +e echo #cat $TRAVIS_BUILD_DIR/upgrade400500-2.log - #cat /tmp/dolibarr_install.log + cat $TRAVIS_BUILD_DIR/upgrade500600-2.log + cat /tmp/dolibarr_install.log - | echo "Unit testing" From 1056473cdccc01a392057102c1cc024df73875ff Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 13:45:36 +0200 Subject: [PATCH 013/428] Try to fix travis error --- htdocs/install/inc.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 6da4125a56c..8045aada0b1 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -385,12 +385,12 @@ function pHeader($subtitle,$next,$action='set',$param='',$forcejqueryurl='',$css // We force the content charset header("Content-type: text/html; charset=".$conf->file->character_set_client); header("X-Content-Type-Options: nosniff"); - + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; @@ -453,9 +453,14 @@ function pFooter($nonext=0,$setuplang='',$jscheckfunction='', $withpleasewait=0) print '
'; if ($nonext == '2') { - print $langs->trans("ErrorFoundDuringMigration", $_SERVER["REQUEST_URI"].'&ignoreerrors=1').'

'; + if (!isset($_SERVER['REQUEST_URI'])) + { + $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'],1 ); + if (isset($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'].='?'.$_SERVER['QUERY_STRING']; } + } + print $langs->trans("ErrorFoundDuringMigration", $_SERVER["REQUEST_URI"].'&ignoreerrors=1').'

'; } - + print '"'; if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"'; print '>
'; From 460a6f0fb75c1eb96d273fa3279b2c3c8fa3ec97 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2017 14:15:29 +0200 Subject: [PATCH 014/428] Fix: phpunit : Unexpected 'print' (T_PRINT) --- htdocs/admin/perms.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 03b29abc109..eb348869b34 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -187,11 +187,11 @@ if ($result) print '
' + print ''; print img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName(); print ' '; print ''.$perm_libelle. '
'; + +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +print ''; +print ''; + +// Description +print ''; + +print ''; +print '
'.$langs->trans("Comments").'
'; + +$desc = GETPOST('comment_description'); + +$doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '100%'); +print $doleditor->Create(1); + +print ''; +print ''; +print '
'; + +// List of comments +if(!empty($object->comments)) { + // Default color for current user + $TColors = array($user->id => array('bgcolor'=>'efefef','color'=>'555')); + $first = true; + foreach($object->comments as $comment) { + $fk_user = $comment->fk_user_author; + $userstatic->fetch($fk_user); + if(empty($TColors[$fk_user])) { + $bgcolor = random_color(180,240); + if(!empty($userstatic->color)) { + $bgcolor = $userstatic->color; + } + $color = (colorIsLight($bgcolor))?'555':'fff'; + $TColors[$fk_user] = array('bgcolor'=>$bgcolor,'color'=>$color); + } + print '
'; + if($fk_user == $user->id) { + print '
 
'; + } + + print '
'; + print '
'; + if (! empty($user->photo)) + { + print Form::showphoto('userphoto', $userstatic, 80, 0, 0, '', 'small', 0, 1).'
'; + } + print $langs->trans('User').' : '.$userstatic->getNomUrl().'
'; + print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec'); + print '
'; // End comment-info + + print '
'; + print '
'; + print '
'; + print $comment->description; + print '
'; // End comment-description + if(($first && $fk_user == $user->id) || $user->admin == 1) { + print ''; + print img_picto('', 'delete.png'); + print ''; + } + print '
'; // End comment-table + print '
'; // End comment-right + print '
'; // End comment + + if($fk_user != $user->id) { + print '
 
'; + } + print '
'; + print '
'; // end 100p + + $first = false; + } +} + +print '
'; +print '
'; diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index d4e78720abf..80d2e7cb292 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -273,14 +273,15 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_CLOSE_SIGNED','Price request closed signed','Executed when a customer proposal is closed signed','proposal_supplier',10); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_CLOSE_REFUSED','Price request closed refused','Executed when a customer proposal is closed refused','proposal_supplier',10); - -CREATE TABLE llx_projet_task_comment ( +DROP TABLE `llx_projet_task_comment`; +CREATE TABLE IF NOT EXISTS llx_comment ( rowid integer AUTO_INCREMENT PRIMARY KEY, datec datetime DEFAULT NULL, tms timestamp, description text NOT NULL, - fk_user integer DEFAULT NULL, - fk_task integer DEFAULT NULL, + fk_user_author integer DEFAULT NULL, + fk_element integer DEFAULT NULL, + element_type varchar(50) DEFAULT NULL, entity integer DEFAULT 1, import_key varchar(125) DEFAULT NULL )ENGINE=innodb; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1b92d87e9ba..39df55e02ce 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -866,3 +866,8 @@ SearchIntoContracts=Contracts SearchIntoCustomerShipments=Customer shipments SearchIntoExpenseReports=Expense reports SearchIntoLeaves=Leaves +CommentLink=Comments +NbComments=Number of comments +CommentPage=Comments space +CommentAdded=Comment added +CommentDeleted=Comment deleted diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 408c3db5e7a..f9eb6c00477 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -210,8 +210,4 @@ OppStatusLOST=Lost Budget=Budget # Comments trans AllowCommentOnTask=Allow user comments on tasks -TaskCommentLinks=Comments -TaskNbComments=Number of comments -TaskComment=Task's comments space -CommentAdded=Comment added -CommentDeleted=Comment deleted +AllowCommentOnProject=Allow user comments on projects diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 6a6c80a78bf..7a47c934a80 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -842,3 +842,8 @@ SearchIntoContracts=Contrats SearchIntoCustomerShipments=Expéditions clients SearchIntoExpenseReports=Notes de frais SearchIntoLeaves=Congés +CommentLink=Commentaires +NbComments=Nombre de commentaires +CommentPage=Espace commentaires +CommentAdded=Commentaire ajouté avec succès +CommentDeleted=Commentaire supprimé avec succès diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 154c1138ab9..c235230eb2f 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -209,8 +209,4 @@ OppStatusLOST=Perdu Budget=Budget #Comments trans AllowCommentOnTask=Autoriser les commentaires entre utilisateurs sur les tâches -TaskCommentLinks=Commentaires -TaskNbComments=Nombre de commentaires -TaskComment=Tâches espace commentaires -CommentAdded=Commentaire ajouté avec succès -CommentDeleted=Commentaire supprimé avec succès +AllowCommentOnProject=Autoriser les commentaires entre utilisateurs sur les projets diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 0c0da27457e..54e864e1bf6 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -918,6 +918,15 @@ print ''; print ' '; print ''; +print ''; +print ''.$langs->trans("AllowCommentOnProject").''; + +print ''; +echo ajax_constantonoff('PROJECT_ALLOW_COMMENT_ON_PROJECT'); +print ''; +print ' '; +print ''; + print ''; print ''.$langs->trans("AllowCommentOnTask").''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index af55063c66a..18aa3fe1f52 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -441,6 +441,7 @@ class Project extends CommonObject // Retreive all extrafield for thirdparty $this->fetch_optionals(); + $this->fetchComments(); return 1; } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 10a78e017c8..2fc849f9fe7 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1783,332 +1783,4 @@ class Task extends CommonObject return ($datetouse > 0 && ($datetouse < ($now - $conf->projet->task->warning_delay))); } - - /** - * Return nb comments already posted - * - * @return int - */ - public function getNbComments() - { - return count($this->comments); - } - - /** - * Load comments linked with current task - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetchComments() - { - $this->comments = array(); - $sql = "SELECT"; - $sql.= " c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_comment as c"; - $sql.= " WHERE c.fk_task = ".$this->id; - $sql.= " ORDER BY c.tms DESC"; - - dol_syslog(get_class($this)."::fetchComments", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $num_rows = $this->db->num_rows($resql); - if ($num_rows > 0) - { - while($obj = $this->db->fetch_object($resql)) - { - $comment = new TaskComment($this->db); - $comment->fetch($obj->rowid); - $this->comments[] = $comment; - } - return $num_rows; - }else{ - return 0; - } - } - else - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } - } -} - -/** - * Class to manage tasks - */ -class TaskComment extends CommonObject -{ - public $element='project_task_comment'; //!< Id that identify managed objects - public $table_element='projet_task_comment'; //!< Name of table without prefix where object is stored - public $fk_element='fk_task'; - public $picto = 'task'; - - var $fk_task; - - var $description; - - var $tms; - - var $datec; - - var $fk_user; - - var $entity; - - var $import_key; - - public $oldcopy; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } - - - /** - * Create into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - function create($user, $notrigger=0) - { - global $conf, $langs; - - $error=0; - - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_comment ("; - $sql.= "description"; - $sql.= ", datec"; - $sql.= ", fk_task"; - $sql.= ", fk_user"; - $sql.= ", entity"; - $sql.= ", import_key"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->description)."'"; - $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); - $sql.= ", '".(isset($this->fk_task)?$this->fk_task:"null")."'"; - $sql.= ", '".(isset($this->fk_user)?$this->fk_user:"null")."'"; - $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); - $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); - $sql.= ")"; - - //var_dump($this->db); - //echo $sql; - - $this->db->begin(); - - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - - if (! $error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); - - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); - if ($result < 0) { $error++; } - // End call triggers - } - } - - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return $this->id; - } - } - - - /** - * Load object in memory from database - * - * @param int $id Id object - * @param int $ref ref object - * @return int <0 if KO, 0 if not found, >0 if OK - */ - function fetch($id, $ref='') - { - global $langs; - - $sql = "SELECT"; - $sql.= " c.rowid,"; - $sql.= " c.description,"; - $sql.= " c.datec,"; - $sql.= " c.tms,"; - $sql.= " c.fk_task,"; - $sql.= " c.fk_user,"; - $sql.= " c.entity,"; - $sql.= " c.import_key"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_comment as c"; - $sql.= " WHERE c.rowid = ".$id; - - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $num_rows = $this->db->num_rows($resql); - - if ($num_rows) - { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->description = $obj->description; - $this->datec = $this->db->jdate($obj->datec); - $this->tms = $obj->tms; - $this->fk_user = $obj->fk_user; - $this->fk_task = $obj->fk_task; - $this->entity = $obj->entity; - $this->import_key = $obj->import_key; - } - - $this->db->free($resql); - - if ($num_rows) return 1; - else return 0; - } - else - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } - } - - - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <=0 if KO, >0 if OK - */ - function update(User $user, $notrigger=0) - { - global $conf, $langs; - $error=0; - - // Clean parameters - if (isset($this->fk_task)) $this->fk_project=(int) trim($this->fk_task); - if (isset($this->fk_user)) $this->fk_user=(int) trim($this->fk_user); - if (isset($this->description)) $this->description=trim($this->description); - - - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; - $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; - $sql.= " fk_task=".(isset($this->fk_task)?$this->fk_task:"null").","; - $sql.= " fk_user=".(isset($this->fk_user)?$this->fk_user:"null").","; - $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; - $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); - $sql.= " WHERE rowid=".$this->id; - - $this->db->begin(); - - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - - if (! $error) - { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); - if ($result < 0) { $error++; } - // End call triggers - } - } - - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } - - - /** - * Delete task from database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - function delete($user, $notrigger=0) - { - global $conf, $langs; - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - $error=0; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_comment"; - $sql.= " WHERE rowid=".$this->id; - - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - - if (! $error) - { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); - if ($result < 0) { $error++; } - // End call triggers - } - } - - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - }else{ - $this->db->commit(); - return 1; - } - } } \ No newline at end of file diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php new file mode 100644 index 00000000000..4e3d52a2f37 --- /dev/null +++ b/htdocs/projet/comment.php @@ -0,0 +1,189 @@ + + * Copyright (C) 2006-2017 Laurent Destailleur + * Copyright (C) 2010-2012 Regis Houssin + * + * 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/projet/tasks/task.php + * \ingroup project + * \brief Page of a project task + */ + +require '../main.inc.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/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + +$langs->load("projects"); +$langs->load("companies"); + +$id=GETPOST('id','int'); +$idcomment=GETPOST('idcomment','int'); +$ref=GETPOST("ref",'alpha',1); // task ref +$objectref=GETPOST("taskref",'alpha'); // task ref +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$withproject=GETPOST('withproject','int'); +$project_ref=GETPOST('project_ref','alpha'); +$planned_workload=((GETPOST('planned_workloadhour','int')!='' || GETPOST('planned_workloadmin','int')!='') ? (GETPOST('planned_workloadhour','int')>0?GETPOST('planned_workloadhour','int')*3600:0) + (GETPOST('planned_workloadmin','int')>0?GETPOST('planned_workloadmin','int')*60:0) : ''); + +// Security check +$socid=0; +//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +if (! $user->rights->projet->lire) accessforbidden(); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('projectcard','globalcard')); + +$object = new Project($db); +$extrafields = new ExtraFields($db); +$object = new Project($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +if ($id > 0 || ! empty($ref)) +{ + $ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database + if ($ret > 0) { + $object->fetch_thirdparty(); + $id=$object->id; + } +} + +// include comment actions +include DOL_DOCUMENT_ROOT . '/core/actions_comments.inc.php'; + +/* + * View +*/ + + +llxHeader('', $langs->trans("CommentPage")); + +$form = new Form($db); +$formother = new FormOther($db); +$formfile = new FormFile($db); + +// Tabs for project +$tab = 'project_comment'; +$head = project_prepare_head($object); +dol_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project')); + +$param = ($mode == 'mine' ? '&mode=mine' : ''); + +// Project card + +$linkback = '' . $langs->trans("BackToList") . ''; + +$morehtmlref = '
'; +// Title +$morehtmlref .= $object->title; +// Thirdparty +if ($object->thirdparty->id > 0) { + $morehtmlref .= '
' . $langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); +} +$morehtmlref .= '
'; + +// Define a complementary filter for search of next/prev ref. +if (! $user->rights->projet->all->lire) { + $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); + $object->next_prev_filter = " rowid in (" . (count($objectsListId) ? join(',', array_keys($objectsListId)) : '0') . ")"; +} + +dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + +print '
'; +print '
'; +print '
'; + +print ''; + +// Visibility +print ''; + +// Date start - end +print ''; + +// Budget +print ''; + +// Other attributes +$cols = 2; +// include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + +print '
' . $langs->trans("Visibility") . ''; +if ($object->public) print $langs->trans('SharedProject'); +else + print $langs->trans('PrivateProject'); +print '
' . $langs->trans("DateStart") . ' - ' . $langs->trans("DateEnd") . ''; +print dol_print_date($object->date_start, 'day'); +$end = dol_print_date($object->date_end, 'day'); +if ($end) print ' - ' . $end; +print '
' . $langs->trans("Budget") . ''; +if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); +print '
'; + +print '
'; +print '
'; +print '
'; +print '
'; + +print ''; + +// Description +print ''; + +// Categories +if ($conf->categorie->enabled) { + print '"; +} + +// Nb comments +print ''; + +print '
' . $langs->trans("Description") . ''; +print nl2br($object->description); +print '
' . $langs->trans("Categories") . ''; + print $form->showCategories($object->id, 'project', 1); + print "
'.$langs->trans("NbComments").''; +print $object->getNbComments(); +print '
'; + +print '
'; +print '
'; +print '
'; + +print '
'; + +dol_fiche_end(); + +print '
'; + +// Include comment tpl view +include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_comment.tpl.php'; + + +llxFooter(); +$db->close(); diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index a36337c324d..e4250bad062 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -33,7 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("projects"); $langs->load("companies"); @@ -41,7 +40,7 @@ $langs->load("companies"); $id=GETPOST('id','int'); $idcomment=GETPOST('idcomment','int'); $ref=GETPOST("ref",'alpha',1); // task ref -$taskref=GETPOST("taskref",'alpha'); // task ref +$objectref=GETPOST("taskref",'alpha'); // task ref $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $withproject=GETPOST('withproject','int'); @@ -56,69 +55,25 @@ if (! $user->rights->projet->lire) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcard','globalcard')); -$task = new Task($db); -$object = new TaskComment($db); +$object = new Task($db); $extrafields = new ExtraFields($db); $projectstatic = new Project($db); -$userstatic = new User($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($task->table_element); +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - -/* - * Actions - */ - -if ($action == 'addcomment') -{ - if (!empty($_POST['comment_description'])) - { - $object->description = GETPOST('comment_description'); - $object->datec = time(); - $object->fk_task = $id; - $object->fk_user = $user->id; - $object->entity = $conf->entity; - if ($object->create($user) > 0) - { - setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); - header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':'')); - exit; - } - else - { - setEventMessages($task->error,$task->errors,'errors'); - $action=''; - } - } -} -if ($action == 'deletecomment') -{ - if ($object->fetch($idcomment) >= 0) - { - if ($object->delete($user) > 0) - { - setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs'); - header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':'')); - exit; - } - else - { - setEventMessages($task->error,$task->errors,'errors'); - $action=''; - } - } -} +// include comment actions +include DOL_DOCUMENT_ROOT . '/core/actions_comments.inc.php'; // Retreive First Task ID of Project if withprojet is on to allow project prev next to work if (! empty($project_ref) && ! empty($withproject)) { if ($projectstatic->fetch('',$project_ref) > 0) { - $tasksarray=$task->getTasksArray(0, 0, $projectstatic->id, $socid, 0); - if (count($tasksarray) > 0) + $objectsarray=$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); + if (count($objectsarray) > 0) { - $id=$tasksarray[0]->id; + $id=$objectsarray[0]->id; } else { @@ -132,7 +87,7 @@ if (! empty($project_ref) && ! empty($withproject)) */ -llxHeader('', $langs->trans("TaskComment")); +llxHeader('', $langs->trans("CommentPage")); $form = new Form($db); $formother = new FormOther($db); @@ -140,14 +95,14 @@ $formfile = new FormFile($db); if ($id > 0 || ! empty($ref)) { - if ($task->fetch($id,$ref) > 0) + if ($object->fetch($id,$ref) > 0) { - $res=$task->fetch_optionals($task->id,$extralabels); + $res=$object->fetch_optionals($object->id,$extralabels); - $result=$projectstatic->fetch($task->fk_project); + $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $task->project = clone $projectstatic; + $object->project = clone $projectstatic; $userWrite = $projectstatic->restrictedProjectArea($user,'write'); @@ -177,8 +132,8 @@ if ($id > 0 || ! empty($ref)) // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { - $tasksListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); - $projectstatic->next_prev_filter=" rowid in (".(count($tasksListId)?join(',',array_keys($tasksListId)):'0').")"; + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); + $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -245,7 +200,7 @@ if ($id > 0 || ! empty($ref)) print '
'; } - $head=task_prepare_head($task); + $head=task_prepare_head($object); /* * Fiche tache en mode visu @@ -263,9 +218,9 @@ if ($id > 0 || ! empty($ref)) if (! GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); - $task->next_prev_filter=" fk_projet in (".$projectsListId.")"; + $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; } - else $task->next_prev_filter=" fk_projet = ".$projectstatic->id; + else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; $morehtmlref=''; @@ -285,7 +240,7 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.=''; } - dol_banner_tab($task, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); print '
'; @@ -293,8 +248,8 @@ if ($id > 0 || ! empty($ref)) print ''; // Nb comments - print ''; // Other attributes @@ -308,102 +263,9 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); - - print '
'; - print '
'; - - // Add comment - - print '
'; - print ''; - print ''; - print ''; - print ''; - - print '
'.$langs->trans("TaskNbComments").''; - print $task->getNbComments(); + print ''.$langs->trans("NbComments").''; + print $object->getNbComments(); print '
'; - - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - print ''; - print ''; - - // Description - print ''; - - print ''; - print '
'.$langs->trans("Comments").'
'; - - $desc = ($_POST['comment_description']?$_POST['comment_description']:''); - - $doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '100%'); - print $doleditor->Create(1); - - print ''; - print ''; - print '
'; - - // List of comments - if(!empty($task->comments)) { - // Default color for current user - $TColors = array($user->id => array('bgcolor'=>'efefef','color'=>'555')); - $first = true; - foreach($task->comments as $comment) { - $fk_user = $comment->fk_user; - $userstatic->fetch($fk_user); - if(empty($TColors[$fk_user])) { - $bgcolor = random_color(180,240); - if(!empty($userstatic->color)) { - $bgcolor = $userstatic->color; - } - $color = (colorIsLight($bgcolor))?'555':'fff'; - $TColors[$fk_user] = array('bgcolor'=>$bgcolor,'color'=>$color); - } - print '
'; - if($comment->fk_user == $user->id) { - print '
 
'; - } - - print '
'; - print '
'; - if (! empty($user->photo)) - { - print Form::showphoto('userphoto', $userstatic, 80, 0, 0, '', 'small', 0, 1).'
'; - } - print $langs->trans('User').' : '.$userstatic->getNomUrl().'
'; - print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec'); - print '
'; // End comment-info - - print '
'; - print '
'; - print '
'; - print $comment->description; - print '
'; // End comment-description - if(($first && $fk_user == $user->id) || $user->admin == 1) { - print ''; - print img_picto('', 'delete.png'); - print ''; - } - print '
'; // End comment-table - print '
'; // End comment-right - print '
'; // End comment - - if($comment->fk_user != $user->id) { - print '
 
'; - } - print '
'; - print '
'; // end 100p - - $first = false; - } - } - - print '
'; - print '
'; + + // Include comment tpl view + include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_comment.tpl.php'; } } From 0803e03ca97a9fbeae5d9b56240be2f08acfbff7 Mon Sep 17 00:00:00 2001 From: tysauron Date: Tue, 19 Sep 2017 14:53:34 +0200 Subject: [PATCH 025/428] For use ajax combobox for societe and contacts in action card create. --- htdocs/comm/action/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 7b1c81af59c..e35d47691da 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -773,9 +773,9 @@ if ($action == 'create') $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); //For external user force the company to user company if (!empty($user->societe_id)) { - print $form->select_thirdparty_list($user->societe_id, 'socid', '', 1, 1, 0, $events); + print $form->select_company($user->societe_id, 'socid', '', 1, 1, 0, $events); } else { - print $form->select_thirdparty_list('', 'socid', '', 'SelectThirdParty', 1, 0, $events); + print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events); } } @@ -783,7 +783,7 @@ if ($action == 'create') // Related contact print ''.$langs->trans("ActionOnContact").''; - $form->select_contacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200'); + $form->selectcontacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200'); print ''; From d51c22a012fb4c55751c96b0247e6a1cab371ec5 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 21 Sep 2017 17:28:00 +0200 Subject: [PATCH 026/428] NEW : customizable meteo in value or percentage --- htdocs/admin/delais.php | 239 ++++++++++++++++++++++++++++++++-------- 1 file changed, 196 insertions(+), 43 deletions(-) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index d3ef125f2a7..0b6690cd051 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -136,8 +136,18 @@ if ($action == 'update') } } } - - dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity); + + dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE",GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"),'chaine',0,'',$conf->entity); + + // For update value with percentage + $plus=''; + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; + // Update values + for($i=0;$i<4;$i++) { + if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity); + } + } @@ -196,13 +206,6 @@ if ($action == 'edit') print ''.$langs->trans("MAIN_DISABLE_METEO").'' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . ''; print ''; - - print '
'; - - print '
'; - print '
'; - - print ''; } else { @@ -244,17 +247,20 @@ else print ''; - print '
'; - - // Boutons d'action - print '
'; - print ''.$langs->trans("Modify").''; - print '
'; - } -print '
'; +print '
'; +if($action == 'edit') { + + $str = $langs->trans('StdMod'); + $str = $langs->trans('PercentageMod'); + print ''.$str.''; + print ''; + + print '

'; + +} // Show logo for weather print $langs->trans("DescWeather").'
'; @@ -268,35 +274,182 @@ $level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level $level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; $level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; $text=''; $options='height="60px"'; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; + -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +if($action == 'edit') { + + + print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>'; + + print '
'; -print img_weather($text,'weather-clear.png',$options); -print '= '.$level0.'         '; -print img_weather($text,'weather-few-clouds.png',$options); -print '<= '.$level1.'         '; -print img_weather($text,'weather-clouds.png',$options); -print '<= '.$level2.'
'; -print img_weather($text,'weather-many-clouds.png',$options); -print '<= '.$level3.'         '; -print img_weather($text,'weather-storm.png',$options); -print '> '.$level3.'                        
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + /*print '';*/ + print ''; + print ''; + print ''; + print ''; + + print '
'; + print img_weather($text,'weather-clear.png',$options); + print '=         '; + print img_weather($text,'weather-few-clouds.png',$options); + print '<=         '; + print img_weather($text,'weather-clouds.png',$options); + print '<=
'; + print img_weather($text,'weather-many-clouds.png',$options); + print '<=         '; + print img_weather($text,'weather-storm.png',$options); + print '> '.$level3.'                        
'; + + print ''; + print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>'; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + /*print '';*/ + print ''; + print ''; + print ''; + print ''; + + print '
'; + print img_weather($text,'weather-clear.png',$options); + print '=  %         '; + print img_weather($text,'weather-few-clouds.png',$options); + print '<=  %         '; + print img_weather($text,'weather-clouds.png',$options); + print '<=  %
'; + print img_weather($text,'weather-many-clouds.png',$options); + print '<=  %         '; + print img_weather($text,'weather-storm.png',$options); + print '> '.$level3.'                        
'; + + print '
'; + +} else { + + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print img_weather($text,'weather-clear.png',$options); + print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.' %         '; + print img_weather($text,'weather-few-clouds.png',$options); + print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.' %         '; + print img_weather($text,'weather-clouds.png',$options); + print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.' %
'; + print img_weather($text,'weather-many-clouds.png',$options); + print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %         '; + print img_weather($text,'weather-storm.png',$options); + print '> '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %                        
'; + + } else { + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print img_weather($text,'weather-clear.png',$options); + print '= '.$level0.'         '; + print img_weather($text,'weather-few-clouds.png',$options); + print '<= '.$level1.'         '; + print img_weather($text,'weather-clouds.png',$options); + print '<= '.$level2.'
'; + print img_weather($text,'weather-many-clouds.png',$options); + print '<= '.$level3.'         '; + print img_weather($text,'weather-storm.png',$options); + print '> '.$level3.'                        
'; + + } +} +print ''; + +if($action == 'edit') { + + print '
'; + print '
'; + +} else { + + // Boutons d'action + print '
'; + +} -print ''; +?> + + +close(); From e6e3e8ca68ac1b9c3d9fb16b786f049ba2f622d9 Mon Sep 17 00:00:00 2001 From: tysauron Date: Fri, 22 Sep 2017 02:43:42 +0200 Subject: [PATCH 027/428] Adding Field "First date of expire" + filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout d'une colonnes "1er date de fin" avec filtre par mois année et choix "<" ou ">" Le filtre exclue toutes les lignes fermé. Permet de voir les contrat a renouvelé prochainement Présélection du mois encours. --- htdocs/contrat/list.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index c6fbaf478bf..32cc341ef3a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -46,6 +46,10 @@ $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$dfmonth=GETPOST('dfmonth')?GETPOST('dfmonth'):date("n"); +$dfyear=GETPOST('dfyear'); +$filter_op2df=GETPOST('filter_op2df'); + $search_name=GETPOST('search_name'); $search_town=GETPOST('search_town','alpha'); $search_zip=GETPOST('search_zip','alpha'); @@ -124,6 +128,7 @@ $arrayfields=array( 'c.date_contrat'=>array('label'=>$langs->trans("DateContract"), 'checked'=>1), 'c.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'c.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'first_date_fin_validite'=>array('label'=>"1er ".$langs->trans("DateEndPlannedShort"), 'checked'=>1, 'position'=>900), 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields @@ -155,6 +160,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $day=''; $month=''; $year=''; + $dfmonth=''; + $dfyear=''; + $filter_op2df=''; $search_name=""; $search_town=''; $search_zip=""; @@ -202,6 +210,7 @@ $sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_ $sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; +$sql.= " MIN(CASE WHEN cd.statut=4 THEN cd.date_fin_validite END) as first_date_fin_validite,"; $sql.= ' SUM('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,'; $sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')",1,0).') as nb_running,'; $sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')",1,0).') as nb_expired,'; @@ -285,6 +294,11 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +if ($dfyear > 0) +{ + $sql.= " HAVING first_date_fin_validite ".$filter_op2df."= '".$db->idate(($filter_op2df == "<" ? dol_get_last_day($dfyear,$dfmonth,false) : dol_get_first_day($dfyear,$dfmonth,false)))."'"; +} + $sql.= $db->order($sortfield,$sortorder); $totalnboflines=0; @@ -526,6 +540,18 @@ if ($resql) print ''; print ''; } + // 1er Date de fin + if (! empty($arrayfields['first_date_fin_validite']['checked'])) + { + print ''; + $arrayofoperators=array('<'=>'<','>'=>'>'); + print $form->selectarray('filter_op2df',$arrayofoperators,$filter_op2df,0); + print '
'; + print $formother->select_month($dfmonth,'dfmonth'); + print ' '; + $formother->select_year($dfyear,'dfyear',1, 20, 5); + print ''; + } // Status if (! empty($arrayfields['status']['checked'])) { @@ -569,6 +595,7 @@ if ($resql) print $hookmanager->resPrint; if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'],$_SERVER["PHP_SELF"],"c.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['first_date_fin_validite']['checked'])) print_liste_field_titre($arrayfields['first_date_fin_validite']['label'],$_SERVER["PHP_SELF"],"first_date_fin_validite","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['status']['checked'])) { print_liste_field_titre($staticcontratligne->LibStatut(0,3), '', '', '', '', 'width="16"'); @@ -743,6 +770,14 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } + // Date 1er date fin + if (! empty($arrayfields['first_date_fin_validite']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->first_date_fin_validite), 'day'); + print ''; + if (! $i) $totalarray['nbfield']++; + } // Status if (! empty($arrayfields['status']['checked'])) { From 6fa1929d5c66d39a00896ff75f8c2847bac64f20 Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 25 Sep 2017 12:26:15 +0200 Subject: [PATCH 028/428] NEW : change description on click --- htdocs/admin/delais.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 0b6690cd051..2ac922a6a0a 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -251,20 +251,26 @@ else print '
'; +// Show logo for weather +print $langs->trans("DescWeather").'
'; + if($action == 'edit') { - $str = $langs->trans('StdMod'); - $str = $langs->trans('PercentageMod'); - print ''.$str.''; + $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoPercentageMod')); + $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoStdMod')); + if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; + else $str_mode_enabled = $str_mode_percentage; + print ''.$str_mode_enabled.''; print ''; print '

'; - + +} else { + if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); + else print $langs->trans('MeteoPercentageModEnabled'); + print '

'; } -// Show logo for weather -print $langs->trans("DescWeather").'
'; - $offset=0; $cursor=10; // By default //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; @@ -432,16 +438,20 @@ if($action == 'edit') { $(document).ready(function() { $("#change_mode").click(function() { - use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE"); - + var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE"); + var str_mode_std = ""; + var str_mode_percentage = ""; + if(use_percent.val() == 1) { use_percent.val(0); $("#standard").show(); $("#percentage").hide(); + $(this).html(str_mode_std); } else { use_percent.val(1); $("#standard").hide(); $("#percentage").show(); + $(this).html(str_mode_percentage); } }); From 3db52aed78e02ab8d6fb841111ab9403faae5aa1 Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 25 Sep 2017 17:13:50 +0200 Subject: [PATCH 029/428] NEW : calcul percentage ok --- htdocs/admin/delais.php | 61 ++++++++++----------- htdocs/index.php | 114 ++++++++++++++++++++++++++++++++-------- 2 files changed, 122 insertions(+), 53 deletions(-) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 2ac922a6a0a..0d9e80f5326 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -350,6 +350,36 @@ if($action == 'edit') { print ''; + ?> + + + + global->MAIN_USE_METEO_WITH_PERCENTAGE)) { @@ -416,6 +446,7 @@ if($action == 'edit') { } } + print ''; if($action == 'edit') { @@ -431,35 +462,5 @@ if($action == 'edit') { } -?> - - - -close(); diff --git a/htdocs/index.php b/htdocs/index.php index 597d41423e5..c2b77d24222 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -384,7 +384,12 @@ if (! empty($conf->projet->enabled) && $user->rights->projet->lire) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $board=new Project($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['projects']; + } + $dashboardlines[] = $wb_res; } // Number of tasks to do (late) @@ -400,9 +405,17 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $board=new Propal($db); - $dashboardlines[] = $board->load_board($user,"opened"); + $wb_res = $board->load_board($user,"opened"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $nbtotal = (int)$board->nb['proposals']; + $wb_res->nbtotal = $nbtotal; + } + $dashboardlines[] = $wb_res; // Number of commercial proposals CLOSED signed (billed) - $dashboardlines[] = $board->load_board($user,"signed"); + $wb_res = $board->load_board($user,"signed"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; + $dashboardlines[] = $wb_res; } // Number of commercial proposals opened (expired) @@ -410,9 +423,17 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos { include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; $board=new SupplierProposal($db); - $dashboardlines[] = $board->load_board($user,"opened"); + $wb_res = $board->load_board($user,"opened"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $nbtotal = (int)$board->nb['askprice']; + $wb_res->nbtotal = $nbtotal; + } + $dashboardlines[] = $wb_res; // Number of commercial proposals CLOSED signed (billed) - $dashboardlines[] = $board->load_board($user,"signed"); + $wb_res = $board->load_board($user,"signed"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; + $dashboardlines[] = $wb_res; } // Number of customer orders a deal @@ -420,7 +441,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $board=new Commande($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['orders']; + } + $dashboardlines[] = $wb_res; } // Number of suppliers orders a deal @@ -428,7 +454,12 @@ if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->comma { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $board=new CommandeFournisseur($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['supplier_orders']; + } + $dashboardlines[] = $wb_res; } // Number of services enabled (delayed) @@ -436,16 +467,29 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $board=new Contrat($db); - $dashboardlines[] = $board->load_board($user,"inactives"); - // Number of active services (expired) - $dashboardlines[] = $board->load_board($user,"expired"); + $wb_res = $board->load_board($user,"inactives"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $nbtotal = (int)$board->nb['Contracts']; + $wb_res->nbtotal = $nbtotal; + } + $dashboardlines[] = $wb_res; + // Number of active services (expired) + $wb_res = $board->load_board($user,"expired"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; + $dashboardlines[] = $wb_res; } // Number of invoices customers (has paid) if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $board=new Facture($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['invoices']; + } + $dashboardlines[] = $wb_res; } // Number of supplier invoices (has paid) @@ -453,7 +497,12 @@ if (! empty($conf->supplier_invoice->enabled) && ! empty($user->rights->fourniss { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $board=new FactureFournisseur($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['supplier_invoices']; + } + $dashboardlines[] = $wb_res; } // Number of transactions to conciliate @@ -481,7 +530,12 @@ if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $use { include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $board=new Adherent($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['members']; + } + $dashboardlines[] = $wb_res; } // Number of expense reports to approve @@ -489,7 +543,12 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->appr { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board=new ExpenseReport($db); - $dashboardlines[] = $board->load_board($user,'toapprove'); + $wb_res = $board->load_board($user,'toapprove'); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['expensereports']; + } + $dashboardlines[] = $wb_res; } // Number of expense reports to pay @@ -497,11 +556,16 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_p { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board=new ExpenseReport($db); - $dashboardlines[] = $board->load_board($user,'topay'); + $wb_res = $board->load_board($user,'topay'); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['expensereports']; + } + $dashboardlines[] = $wb_res; } // Calculate total nb of late -$totallate=0; +$totallate=$totalglobal=0; $var=true; //Remove any invalid response @@ -516,11 +580,13 @@ foreach($dashboardlines as $tmp) foreach($valid_dashboardlines as $board) { if ($board->nbtodolate > 0) { + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totalglobal += $board->nbtotal; $totallate += $board->nbtodolate; } } - - +//var_dump($totallate, $totalglobal); +if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = $totallate / $totalglobal * 100; +//var_dump($totallate); $boxwork=''; $boxwork.='
'; $boxwork.=''."\n"; @@ -686,15 +752,17 @@ $db->close(); function showWeather($totallate,$text,$options) { global $conf; - + $out=''; $offset=0; $factor=10; // By default - $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0; - $level1=$offset+1*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1; - $level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; - $level3=$offset+3*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; + $used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL'; + + $level0=$offset; if (! empty($conf->global->{$used_conf.'0'})) $level0=$conf->global->{$used_conf.'0'}; + $level1=$offset+1*$factor; if (! empty($conf->global->{$used_conf.'1'})) $level1=$conf->global->{$used_conf.'1'}; + $level2=$offset+2*$factor; if (! empty($conf->global->{$used_conf.'2'})) $level2=$conf->global->{$used_conf.'2'}; + $level3=$offset+3*$factor; if (! empty($conf->global->{$used_conf.'3'})) $level3=$conf->global->{$used_conf.'3'}; if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options); if ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options); From 3cec3085862e911bfd7dbb824d3998cbfe4a4a3b Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 25 Sep 2017 17:19:56 +0200 Subject: [PATCH 030/428] NEW : langs --- htdocs/langs/en_US/admin.lang | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1e855abc41a..a7a0c6f645f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1089,6 +1089,11 @@ ShowProfIdInAddress=Show professionnal id with addresses on documents ShowVATIntaInAddress=Hide VAT Intra num with addresses on documents TranslationUncomplete=Partial translation MAIN_DISABLE_METEO=Disable meteo view +MeteoStdMod=Standard mode +MeteoStdModEnabled=Standard mode enabled +MeteoPercentageMod=Percentage mode +MeteoPercentageModEnabled=Percentage mode enabled +MeteoUseMod=Click to use %s TestLoginToAPI=Test login to API ProxyDesc=Some features of Dolibarr need to have an Internet access to work. Define here parameters for this. If the Dolibarr server is behind a Proxy server, those parameters tells Dolibarr how to access Internet through it. ExternalAccess=External access From a350a067550970fcb6934ff780f58eb45403bbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien?= Date: Mon, 25 Sep 2017 21:15:35 +0200 Subject: [PATCH 031/428] Solve bug with alias name display The bug display the alias name on the following name between brackets after name column. --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index f280a9db89c..5009a668ba3 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1024,6 +1024,7 @@ while ($i < min($num, $limit)) $companystatic->id=$obj->rowid; $companystatic->name=$obj->name; + $companystatic->name_alias=$obj->name_alias; $companystatic->canvas=$obj->canvas; $companystatic->client=$obj->client; $companystatic->status=$obj->status; @@ -1053,7 +1054,6 @@ while ($i < min($num, $limit)) } if (! empty($arrayfields['s.name_alias']['checked'])) { - $companystatic->name_alias=$obj->name_alias; // Added after the getNomUrl print '\n"; From ceb868493e5782fb8e1b67a3af91d817146c3608 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Tue, 26 Sep 2017 10:12:42 +0200 Subject: [PATCH 032/428] NEW get payement types using the REST API Adds the ability to get payments types using the REST API --- .../class/api_dictionarypayments.class.php | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 htdocs/api/class/api_dictionarypayments.class.php diff --git a/htdocs/api/class/api_dictionarypayments.class.php b/htdocs/api/class/api_dictionarypayments.class.php new file mode 100644 index 00000000000..4c9aa8a948b --- /dev/null +++ b/htdocs/api/class/api_dictionarypayments.class.php @@ -0,0 +1,97 @@ + + * + * 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 . + */ + +use Luracast\Restler\RestException; + +require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; + +/** + * API class for payment type (content of the paiement dictionary) + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class DictionaryPayments extends DolibarrApi +{ + /** + * Constructor + */ + function __construct() + { + global $db; + $this->db = $db; + } + + /** + * Get the list of payments types. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Payment type is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')" + * @return List of payment types + * + * @throws RestException + */ + function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT id, code, type, libelle as label, module"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t"; + $sql.= " WHERE t.active = ".$active; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of payment types : '.$this->db->lasterror()); + } + + return $list; + } + +} From 59571b1ce1780e7230a29ef798e208fee8bc4fe6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Sep 2017 21:41:53 +0200 Subject: [PATCH 033/428] FIX #7473 Mass update of vat rates and other bugs on localtax --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 2 +- .../fourn/class/fournisseur.product.class.php | 47 +++++- htdocs/product/admin/product_tools.php | 62 ++++++-- .../class/productcustomerprice.class.php | 4 + htdocs/product/price.php | 146 +++++++++++++++--- 6 files changed, 215 insertions(+), 48 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 33ad6a48ca3..bfddc4b4921 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3711,7 +3711,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0) if (! preg_match('/\//', $rate)) $ret=price($rate,0,'',0,0).($addpercent?'%':''); else { - // TODO Split on / and output with a price2num to have clean numbers with ton of 000. + // TODO Split on / and output with a price2num to have clean numbers without ton of 000. $ret=$rate.($addpercent?'%':''); } if ($info_bits & 1) $ret.=' *'; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index f968fdcbfc7..94c05fd9ffe 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -145,7 +145,7 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; '."\n"; print ''."\n"; - + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; - + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; /* - + print ''."\n"; print ''."\n"; print '
'; print $companystatic->name_alias; print "tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); + if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); if (price2num($line->total_localtax2)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); if (empty($positiverates)) $positiverates='0'; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 5184c8ffe80..17f8b2615ee 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -180,16 +180,18 @@ class ProductFournisseur extends Product * @param Societe $fourn Supplier * @param int $availability Product availability * @param string $ref_fourn Supplier ref - * @param float $tva_tx VAT rate + * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) * @param string $charges costs affering to product * @param float $remise_percent Discount regarding qty (percent) * @param float $remise Discount regarding qty (amount) * @param int $newnpr Set NPR or not * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) + * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). + * @param string $newdefaultvatcode Default vat code * @return int <0 if KO, >=0 if OK */ - function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0, $delivery_time_days=0, $supplier_reputation='') + function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0, $delivery_time_days=0, $supplier_reputation='', $localtaxes_array=array(), $newdefaultvatcode='') { global $conf, $langs; //global $mysoc; @@ -217,6 +219,25 @@ class ProductFournisseur extends Product $now=dol_now(); + $newvat = $tva_tx; + + if (count($localtaxes_array) > 0) + { + $localtaxtype1=$localtaxes_array['0']; + $localtax1=$localtaxes_array['1']; + $localtaxtype2=$localtaxes_array['2']; + $localtax2=$localtaxes_array['3']; + } + else // old method. deprecated because ot can't retreive type + { + $localtaxtype1='0'; + $localtax1=get_localtax($newvat,1); + $localtaxtype2='0'; + $localtax2=get_localtax($newvat,2); + } + if (empty($localtax1)) $localtax1=0; // If = '' then = 0 + if (empty($localtax2)) $localtax2=0; // If = '' then = 0 + $this->db->begin(); if ($this->product_fourn_price_id > 0) @@ -230,9 +251,15 @@ class ProductFournisseur extends Product $sql.= " remise = ".$remise.","; $sql.= " unitprice = ".$unitBuyPrice.","; $sql.= " unitcharges = ".$unitCharges.","; // deprecated - $sql.= " tva_tx = ".$tva_tx.","; $sql.= " fk_availability = ".$availability.","; $sql.= " entity = ".$conf->entity.","; + $sql.= " tva_tx = ".price2num($tva_tx).","; + // TODO Add localtax1 and localtax2 + //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; + //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; + //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$localtaxtype1."'":"'0'").","; + //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$localtaxtype2."'":"'0'").","; + $sql.= " default_vat_code=".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; $sql.= " info_bits = ".$newnpr.","; $sql.= " charges = ".$charges.","; // deprecated $sql.= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; @@ -279,7 +306,7 @@ class ProductFournisseur extends Product if ($resql) { // Add price for this quantity to supplier $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price("; - $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, info_bits, entity, delivery_time_days,supplier_reputation)"; + $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)"; $sql .= " values('" . $this->db->idate($now) . "',"; $sql .= " " . $this->id . ","; $sql .= " " . $fourn->id . ","; @@ -294,6 +321,7 @@ class ProductFournisseur extends Product $sql .= " " . $charges . ","; $sql .= " " . $unitCharges . ","; $sql .= " " . $availability . ","; + $sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; $sql .= " " . $newnpr . ","; $sql .= $conf->entity . ","; $sql .= $delivery_time_days . ","; @@ -364,9 +392,9 @@ class ProductFournisseur extends Product function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) { global $conf; - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability,"; + $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.fk_availability,"; $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price - $sql.=" pfp.supplier_reputation"; + $sql.= " pfp.supplier_reputation"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.rowid = ".$rowid; @@ -392,11 +420,14 @@ class ProductFournisseur extends Product $this->fourn_unitprice = $obj->unitprice; $this->fourn_unitcharges = $obj->unitcharges; // deprecated $this->fourn_tva_tx = $obj->tva_tx; - //$this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ? + // TODO + // $this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ? + // Add also localtaxes $this->fk_availability = $obj->fk_availability; $this->delivery_time_days = $obj->delivery_time_days; $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; - $this->supplier_reputation = $obj->supplier_reputation; + $this->supplier_reputation = $obj->supplier_reputation; + $this->default_vat_code = $obj->default_vat_code; if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) { diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 85351a0fb2a..f19f672a25e 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -38,8 +38,8 @@ $langs->load("products"); if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); -$oldvatrate=GETPOST('oldvatrate'); -$newvatrate=GETPOST('newvatrate'); +$oldvatrate=GETPOST('oldvatrate', 'alpha'); +$newvatrate=GETPOST('newvatrate', 'alpha'); //$price_base_type=GETPOST('price_base_type'); @@ -67,13 +67,31 @@ if ($action == 'convert') $db->begin(); + // Clean vat code old + $vat_src_code_old=''; + if (preg_match('/\((.*)\)/', $oldvatrate, $reg)) + { + $vat_src_code_old = $reg[1]; + $oldvatrateclean = preg_replace('/\s*\(.*\)/', '', $oldvatrate); // Remove code into vatrate. + } + + // Clean vat code new + $vat_src_code_new=''; + if (preg_match('/\((.*)\)/', $newvatrate, $reg)) + { + $vat_src_code_new = $reg[1]; + $newvatrateclean = preg_replace('/\s*\(.*\)/', '', $newvatrate); // Remove code into vatrate. + } + // If country to edit is my country, so we change customer prices if ($country_id == $mysoc->country_id) { $sql = 'SELECT rowid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product'; $sql.= ' WHERE entity IN ('.getEntity('product').')'; - $sql.= " AND tva_tx = '".$db->escape($oldvatrate)."'"; + $sql.= " AND tva_tx = '".$db->escape($oldvatrateclean)."'"; + if ($vat_src_code_old) $sql.= " AND default_vat_code = '".$vat_src_code_old."'"; + else " AND default_vat_code = IS NULL"; $resql=$db->query($sql); if ($resql) @@ -109,12 +127,15 @@ if ($action == 'convert') $newminprice=$objectstatic->multiprices_min[$level]; } if ($newminprice > $newprice) $newminprice=$newprice; + $newvat=str_replace('*','',$newvatrate); + $localtaxes_type=getLocalTaxesFromRate($newvat, 0, $mysoc, $mysoc); $newnpr=$objectstatic->multiprices_recuperableonly[$level]; + $newdefaultvatcode=$vat_src_code_new; $newlevel=$level; //print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; - $retm=$objectstatic->updatePrice($newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); + $retm=$objectstatic->updatePrice($newprice, $price_base_type, $user, $newvatratclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode); if ($retm < 0) { $error++; @@ -138,19 +159,21 @@ if ($action == 'convert') } if ($newminprice > $newprice) $newminprice=$newprice; $newvat=str_replace('*','',$newvatrate); + $localtaxes_type=getLocalTaxesFromRate($newvat, 0, $mysoc, $mysoc); $newnpr=$objectstatic->recuperableonly; + $newdefaultvatcode=$vat_src_code_new; $newlevel=0; if (! empty($price_base_type) && ! $updatelevel1) { //print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; - $ret=$objectstatic->updatePrice($newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); + $ret=$objectstatic->updatePrice($newprice, $price_base_type, $user, $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode); } if ($ret < 0 || $retm < 0) $error++; else $nbrecordsmodified++; } unset($objectstatic); - + $i++; } } @@ -164,6 +187,8 @@ if ($action == 'convert') $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp, '.MAIN_DB_PREFIX.'societe as s'; $sql.= ' WHERE pfp.fk_soc = s.rowid AND pfp.entity IN ('.getEntity('product').')'; $sql.= " AND tva_tx = '".$db->escape($oldvatrate)."'"; + if ($vat_src_code_old) $sql.= " AND default_vat_code = '".$vat_src_code_old."'"; + else " AND default_vat_code = IS NULL"; $sql.= " AND s.fk_pays = '".$country_id."'"; //print $sql; $resql=$db->query($sql); @@ -196,26 +221,33 @@ if ($action == 'convert') //} //if ($newminprice > $newprice) $newminprice=$newprice; $newvat=str_replace('*','',$newvatrate); + $localtaxes_type=getLocalTaxesFromRate($newvat, 0, $mysoc, $mysoc); //$newnpr=$objectstatic2->recuperableonly; + $newnpr=0; + $newdefaultvatcode=$vat_src_code_new; + + $newpercent = $objectstatic2->fourn_remise_percent; + $newdeliverydelay = $objectstatic2->delivery_time_days; + $newsupplierreputation = $objectstatic2->supplier_reputation; + $newlevel=0; if (! empty($price_base_type) && ! $updatelevel1) { //print "$objectstatic2->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; $fourn->id=$obj->fk_soc; - $ret=$objectstatic2->update_buyprice($obj->qty, $newprice, $user, $price_base_type, $fourn, $obj->fk_availability, $obj->ref_fourn, $newvat); + $ret=$objectstatic2->update_buyprice($obj->qty, $newprice, $user, $price_base_type, $fourn, $obj->fk_availability, $obj->ref_fourn, $newvat, '', $newpercent, 0, $newnpr, $newdeliverydelay, $newsupplierreputation, $localtaxes_type, $newdefaultvatcode); } if ($ret < 0 || $retm < 0) $error++; else $nbrecordsmodified++; } unset($objectstatic2); - + $i++; } } else dol_print_error($db); - if (! $error) { $db->commit(); @@ -274,24 +306,24 @@ else print '
'.$langs->trans("Value").'
'.$langs->trans("OldVATRates").''."\n"; - print $form->load_tva('oldvatrate', $oldvatrate, $mysoc); + print $form->load_tva('oldvatrate', $oldvatrate, $mysoc, null, 0, 0, '', false, 1); print '
'.$langs->trans("NewVATRates").''."\n"; - print $form->load_tva('newvatrate', $newvatrate, $mysoc); + print $form->load_tva('newvatrate', $newvatrate, $mysoc, null, 0, 0, '', false, 1); print '
'.$langs->trans("PriceBaseTypeToChange").''."\n"; @@ -303,7 +335,7 @@ else print '
'; print '
'; - + // Boutons actions print '
'; print ''; diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 441b865e255..4ff018bf031 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -329,6 +329,8 @@ class Productcustomerprice extends CommonObject $sql .= " t.recuperableonly,"; $sql .= " t.localtax1_tx,"; $sql .= " t.localtax2_tx,"; + $sql .= " t.localtax1_type,"; + $sql .= " t.localtax2_type,"; $sql .= " t.fk_user,"; $sql .= " t.import_key,"; $sql .= " soc.nom as socname,"; @@ -386,6 +388,8 @@ class Productcustomerprice extends CommonObject $line->recuperableonly = $obj->recuperableonly; $line->localtax1_tx = $obj->localtax1_tx; $line->localtax2_tx = $obj->localtax2_tx; + $line->localtax1_type = $obj->localtax1_type; + $line->localtax2_type = $obj->localtax2_type; $line->fk_user = $obj->fk_user; $line->import_key = $obj->import_key; $line->socname = $obj->socname; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 949711b4a1b..f16b716c9cc 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -107,8 +107,15 @@ if (empty($reshook)) $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' // We must define tva_tx, npr and local taxes + $tva_tx = $tva_tx_txt; $vatratecode = ''; - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + $vat_src_code = $reg[1]; + $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. + } + + $tva_tx = price2num(preg_replace('/\*/', '', $tva_tx)); // keep remove all after the numbers and dot $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes @@ -217,8 +224,15 @@ if (empty($reshook)) $tva_tx_txt = $newvattx[$i]; + $tva_tx = $tva_tx_txt; $vatratecode = ''; - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + $vat_src_code = $reg[1]; + $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. + } + $tva_tx = price2num(preg_replace('/\*/', '', $tva_tx)); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $localtax1 = $newlocaltax1_tx[$i]; $localtax1_type = $newlocaltax1_type[$i]; @@ -266,9 +280,15 @@ if (empty($reshook)) { $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' + $tva_tx = $tva_tx_txt; $vatratecode = ''; - // We must define tva_tx, npr and local taxes - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + $vat_src_code = $reg[1]; + $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. + } + $tva_tx = price2num(preg_replace('/\*/', '', $tva_tx)); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes @@ -280,7 +300,7 @@ if (empty($reshook)) $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; - $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; + $sql.= " AND t.taux = ".$tva_tx." AND t.active = 1"; $sql.= " AND t.code ='".$vatratecode."'"; $resql=$db->query($sql); if ($resql) @@ -469,11 +489,17 @@ if (empty($reshook)) $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); - $tva_tx_txt = GETPOST("tva_tx"); + $tva_tx_txt = GETPOST("tva_tx",'alpha'); + $tva_tx = $tva_tx_txt; $vatratecode = ''; - // We must define tva_tx, npr and local taxes - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + $vat_src_code = $reg[1]; + $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. + } + $tva_tx = price2num(preg_replace('/\*/', '', $tva_tx)); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes @@ -485,7 +511,7 @@ if (empty($reshook)) $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; - $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; + $sql.= " AND t.taux = ".$tva_tx." AND t.active = 1"; $sql.= " AND t.code ='".$vatratecode."'"; $resql=$db->query($sql); if ($resql) @@ -565,9 +591,15 @@ if (empty($reshook)) $tva_tx_txt = GETPOST("tva_tx"); - $vatratecode=''; - // We must define tva_tx, npr and local taxes - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + $tva_tx = $tva_tx_txt; + $vatratecode = ''; + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + $vat_src_code = $reg[1]; + $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. + } + $tva_tx = price2num(preg_replace('/\*/', '', $tva_tx)); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes @@ -579,7 +611,7 @@ if (empty($reshook)) $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; - $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; + $sql.= " AND t.taux = ".$tva_tx." AND t.active = 1"; $sql.= " AND t.code ='".$vatratecode."'"; $resql=$db->query($sql); if ($resql) @@ -712,17 +744,34 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // TVA - print '' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx[$soc->price_level], true) . ''; + print '' . $langs->trans("VATRate") . ''; + + $positiverates=''; + if (price2num($object->multiprices_tva_tx[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_tva_tx[$soc->price_level]); + if (price2num($object->multiprices_localtax1_type[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_localtax1_tx[$soc->price_level]); + if (price2num($object->multiprices_localtax2_type[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_localtax2_tx[$soc->price_level]); + if (empty($positiverates)) $positiverates='0'; + echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr); + //print vatrate($object->multiprices_tva_tx[$soc->price_level], true); + print ''; } else { // TVA print '' . $langs->trans("VATRate") . ''; + + $positiverates=''; + if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx); + if (price2num($object->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax1_tx); + if (price2num($object->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax2_tx); + if (empty($positiverates)) $positiverates='0'; + echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr); + /* if ($object->default_vat_code) { print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; } - else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true); + else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true);*/ print ''; } @@ -740,11 +789,19 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) { // TVA print '' . $langs->trans("VATRate") . ''; + + $positiverates=''; + if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx); + if (price2num($object->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax1_tx); + if (price2num($object->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax2_tx); + if (empty($positiverates)) $positiverates='0'; + echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr); + /* if ($object->default_vat_code) { print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; } - else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true); + else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true);*/ print ''; } print ''; @@ -889,11 +946,19 @@ else { // TVA print '' . $langs->trans("VATRate") . ''; + + $positiverates=''; + if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx); + if (price2num($object->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax1_tx); + if (price2num($object->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax2_tx); + if (empty($positiverates)) $positiverates='0'; + echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr); + /* if ($object->default_vat_code) { print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; } - else print vatrate($object->tva_tx, true, $object->tva_npr, true); + else print vatrate($object->tva_tx, true, $object->tva_npr, true);*/ print ''; // Price @@ -1314,7 +1379,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_price') && ! in_array($action, array('edit_price','edit_vat'))) { - $sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.default_vat_code, p.recuperableonly,"; + $sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.default_vat_code, p.recuperableonly, p.localtax1_tx, p.localtax1_type, p.localtax2_tx, p.localtax2_type,"; $sql .= " p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,"; $sql .= " p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login"; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price as p,"; @@ -1410,11 +1475,19 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ if (empty($conf->global->PRODUIT_MULTIPRICES)) { print ''; + + $positiverates=''; + if (price2num($objp->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($objp->tva_tx); + if (price2num($objp->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax1_tx); + if (price2num($objp->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax2_tx); + if (empty($positiverates)) $positiverates='0'; + echo vatrate($positiverates.($objp->default_vat_code?' ('.$objp->default_vat_code.')':''), '%', $objp->tva_npr); + /* if ($objp->default_vat_code) { print vatrate($objp->tva_tx, true) . ' ('.$objp->default_vat_code.')'; } - else print vatrate($objp->tva_tx, true, $objp->recuperableonly); + else print vatrate($objp->tva_tx, true, $objp->recuperableonly);*/ print ""; } @@ -1769,7 +1842,17 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print "" . $staticsoc->getNomUrl(1) . ""; print "" . dol_print_date($line->datec, "dayhour") . ""; print '' . $langs->trans($line->price_base_type) . ""; - print '' . vatrate($tva_tx, true, $line->recuperableonly) . ""; + print ''; +var_dump($prodcustprice);exit; + $positiverates=''; + if (price2num($objp->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($objp->tva_tx); + if (price2num($objp->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax1_tx); + if (price2num($objp->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax2_tx); + if (empty($positiverates)) $positiverates='0'; + echo vatrate($positiverates.($objp->default_vat_code?' ('.$objp->default_vat_code.')':''), '%', $objp->tva_npr); + + //. vatrate($tva_tx, true, $line->recuperableonly) . + print ""; print '' . price($line->price) . ""; print '' . price($line->price_ttc) . ""; @@ -1873,8 +1956,16 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '' . $langs->trans($object->price_base_type) . ""; print ''; - print vatrate($object->tva_tx, true, $object->recuperableonly); - print $object->default_vat_code?' ('.$object->default_vat_code.')':''; + + $positiverates=''; + if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx); + if (price2num($object->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax1_tx); + if (price2num($object->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax2_tx); + if (empty($positiverates)) $positiverates='0'; + echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr); + + //print vatrate($object->tva_tx, true, $object->tva_npr); + //print $object->default_vat_code?' ('.$object->default_vat_code.')':''; print ""; print '' . price($object->price) . ""; @@ -1939,7 +2030,16 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print "" . dol_print_date($line->datec, "dayhour") . ""; print '' . $langs->trans($line->price_base_type) . ""; - print '' . vatrate($tva_tx, true, $line->recuperableonly) . ""; + print ''; + + $positiverates=''; + if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); + if (price2num($line->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); + if (price2num($line->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); + if (empty($positiverates)) $positiverates='0'; + echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', $line->tva_npr); + + print ""; print '' . price($line->price) . ""; print '' . price($line->price_ttc) . ""; From 4f76545b628e9641a99e15b3054e7be2c7e03c47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 10:47:08 +0200 Subject: [PATCH 034/428] Add missing fields to manage localtax on supplier products --- .../install/mysql/migration/6.0.0-7.0.0.sql | 5 ++++ .../tables/llx_product_fournisseur_price.sql | 4 +++ htdocs/langs/en_US/main.lang | 1 + htdocs/product/price.php | 26 +++++++++---------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index c8f2142684c..0d2a6a7baed 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -41,6 +41,11 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer; -- For 7.0 +ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_tx double(6,3) DEFAULT 0; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0'; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax2_tx double(6,3) DEFAULT 0; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0'; + insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SENTBYMAIL','Mails sent from member card','Executed when you send email from member card','member',23); diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index f341b103edb..1c86bfe04f8 100755 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -38,6 +38,10 @@ create table llx_product_fournisseur_price unitcharges double(24,8) DEFAULT 0, -- deprecated default_vat_code varchar(10), tva_tx double(6,3) NOT NULL, + localtax1_tx double(6,3) DEFAULT 0, + localtax1_type varchar(10) NOT NULL DEFAULT '0', + localtax2_tx double(6,3) DEFAULT 0, + localtax2_type varchar(10) NOT NULL DEFAULT '0', info_bits integer NOT NULL DEFAULT 0, fk_user integer, fk_supplier_price_expression integer, -- Link to the rule for dynamic price calculation diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 7475d1194eb..93d2542ea69 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -382,6 +382,7 @@ LT2ES=IRPF LT1IN=CGST LT2IN=SGST VATRate=Tax Rate +DefaultTaxRate=Default tax rate Average=Average Sum=Sum Delta=Delta diff --git a/htdocs/product/price.php b/htdocs/product/price.php index f3d61b26f81..af9fa2a927f 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -744,7 +744,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // TVA - print '' . $langs->trans("VATRate") . ''; + print '' . $langs->trans("DefaultTaxRate") . ''; $positiverates=''; if (price2num($object->multiprices_tva_tx[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_tva_tx[$soc->price_level]); @@ -758,7 +758,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) else { // TVA - print '' . $langs->trans("VATRate") . ''; + print '' . $langs->trans("DefaultTaxRate") . ''; $positiverates=''; if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx); @@ -781,14 +781,14 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // We show only vat for level 1 - print '' . $langs->trans("VATRate") . ''; + print '' . $langs->trans("DefaultTaxRate") . ''; print '' . vatrate($object->multiprices_tva_tx[1], true) . ''; print ''; } else { // TVA - print '' . $langs->trans("VATRate") . ''; + print '' . $langs->trans("DefaultTaxRate") . ''; $positiverates=''; if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx); @@ -945,7 +945,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) else { // TVA - print '' . $langs->trans("VATRate") . ''; + print '' . $langs->trans("DefaultTaxRate") . ''; $positiverates=''; if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx); @@ -1123,7 +1123,7 @@ if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->se print ''; // VAT - print ''; @@ -1157,7 +1157,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) print '
' . $langs->trans("VATRate") . ''; + print '
' . $langs->trans("DefaultTaxRate") . ''; print $form->load_tva("tva_tx", $object->default_vat_code ? $object->tva_tx.' ('.$object->default_vat_code.')' : $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); print '
'; // VAT - print ''; @@ -1298,7 +1298,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) print ''; - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) print ''; + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) print ''; else print ''; print ''; @@ -1439,7 +1439,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print ''; print $conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''; print ''; if (! empty($conf->dynamicprices->enabled)) { @@ -1606,7 +1606,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; // VAT - print ''; @@ -1695,7 +1695,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; // VAT - print ''; @@ -1799,7 +1799,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print ''; @@ -1920,7 +1920,7 @@ var_dump($prodcustprice);exit; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print ''; From f5be144bebe72be6e36af481d837b868e00e6de0 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Tue, 26 Sep 2017 10:48:35 +0200 Subject: [PATCH 035/428] NEW Consolidates REST dictionary APIs into a single tree and a single file The php code of the files "htdocs / api / class / api_dictionary * .class.php" has been integrated into a single file: "htdocs / api / class / api_dictionary.class.php". --- htdocs/api/class/api_dictionary.class.php | 452 ++++++++++++++++++ .../class/api_dictionarycountries.class.php | 184 ------- .../api/class/api_dictionaryevents.class.php | 100 ---- .../class/api_dictionaryextrafields.class.php | 112 ----- .../class/api_dictionarypayments.class.php | 97 ---- .../api/class/api_dictionarytowns.class.php | 102 ---- 6 files changed, 452 insertions(+), 595 deletions(-) create mode 100644 htdocs/api/class/api_dictionary.class.php delete mode 100644 htdocs/api/class/api_dictionarycountries.class.php delete mode 100644 htdocs/api/class/api_dictionaryevents.class.php delete mode 100644 htdocs/api/class/api_dictionaryextrafields.class.php delete mode 100644 htdocs/api/class/api_dictionarypayments.class.php delete mode 100644 htdocs/api/class/api_dictionarytowns.class.php diff --git a/htdocs/api/class/api_dictionary.class.php b/htdocs/api/class/api_dictionary.class.php new file mode 100644 index 00000000000..93f16d44377 --- /dev/null +++ b/htdocs/api/class/api_dictionary.class.php @@ -0,0 +1,452 @@ + + * + * 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 . + */ + +use Luracast\Restler\RestException; + +require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; + +/** + * API class for payment type (content of the paiement dictionary) + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class Dictionary extends DolibarrApi +{ + private $translations = null; + + /** + * Constructor + */ + function __construct() + { + global $db; + $this->db = $db; + } + + /** + * Get the list of payments types. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Payment type is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')" + * + * @url GET payments + * + * @return List of payment types + * + * @throws RestException + */ + function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT id, code, type, libelle as label, module"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t"; + $sql.= " WHERE t.active = ".$active; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of payment types : '.$this->db->lasterror()); + } + + return $list; + } + + /** + * Get the list of countries. + * + * The names of the countries will be translated to the given language if + * the $lang parameter is provided. The value of $lang must be a language + * code supported by Dolibarr, for example 'en_US' or 'fr_FR'. + * The returned list is sorted by country ID. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $filter To filter the countries by name + * @param string $lang Code of the language the label of the countries must be translated to + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return List of countries + * + * @url GET countries + * + * @throws RestException + */ + function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') + { + $list = array(); + + // Note: The filter is not applied in the SQL request because it must + // be applied to the translated names, not to the names in database. + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t"; + $sql.=" WHERE 1 = 1"; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $obj = $this->db->fetch_object($result); + $country = new Ccountry($this->db); + if ($country->fetch($obj->rowid) > 0) { + // Translate the name of the country if needed + // and then apply the filter if there is one. + $this->translateLabel($country, $lang); + + if (empty($filter) || stripos($country->label, $filter) !== FALSE) { + $list[] = $this->_cleanObjectDatas($country); + } + } + } + } else { + throw new RestException(503, 'Error when retrieving list of countries : '.$country->error); + } + + return $list; + } + + /** + * Get country by ID. + * + * @param int $id ID of country + * @param string $lang Code of the language the name of the + * country must be translated to + * + * @url GET countries/{id} + * + * @throws RestException + */ + function getCountryByID($id, $lang = '') + { + $country = new Ccountry($this->db); + + if ($country->fetch($id) < 0) { + throw new RestException(503, 'Error when retrieving country : '.$country->error); + } + else if ($country->fetch($id) == 0) { + throw new RestException(404, 'country not found'); + } + + $this->translateLabel($country, $lang); + + return $this->_cleanObjectDatas($country); + } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) + { + $object = parent::_cleanObjectDatas($object); + + unset($object->error); + unset($object->errors); + + return $object; + } + + /** + * Translate the name of the country to the given language. + * + * @param Ccountry $country Country + * @param string $lang Code of the language the name of the + * country must be translated to + */ + private function translateLabel($country, $lang) + { + if (!empty($lang)) { + // Load the translations if this is a new language. + if ($this->translations == null || $this->translations->getDefaultLang() !== $lang) { + global $conf; + $this->translations = new Translate('', $conf); + $this->translations->setDefaultLang($lang); + $this->translations->load('dict'); + } + if ($country->code) { + $key = 'Country'.$country->code; + $translation = $this->translations->trans($key); + if ($translation != $key) { + $country->label = html_entity_decode($translation); + } + } + } + } + + /** + * Get the list of events types. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $type To filter on type of event + * @param string $module To filter on module events + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return List of events types + * + * @url GET events + * + * @throws RestException + */ + function getListOfEvents($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT id, code, type, libelle as label, module"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t"; + $sql.= " WHERE t.active = 1"; + if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; + if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of events types : '.$this->db->lasterror()); + } + + return $list; + } + + + /** + * Get the list of extra fields. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')" + * @return List of events types + * + * @url GET extrafields + * + * @throws RestException + */ + function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') + { + $list = array(); + + if ($type == 'thirdparty') $type='societe'; + if ($type == 'contact') $type='socpeople'; + + $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed"; + $sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t"; + $sql.= " WHERE t.entity IN (".getEntity('extrafields').")"; + if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'"; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $this->db->order($sortfield, $sortorder); + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + while ($tab = $this->db->fetch_object($resql)) + { + // New usage + $list[$tab->elementtype][$tab->name]['type']=$tab->type; + $list[$tab->elementtype][$tab->name]['label']=$tab->label; + $list[$tab->elementtype][$tab->name]['size']=$tab->size; + $list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype; + $list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault; + $list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed; + $list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique; + $list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired; + $list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : ''); + $list[$tab->elementtype][$tab->name]['pos']=$tab->pos; + $list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; + $list[$tab->elementtype][$tab->name]['perms']=$tab->perms; + $list[$tab->elementtype][$tab->name]['list']=$tab->list; + $list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden; + } + } + } + else + { + throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); + } + + if (! count($list)) + { + throw new RestException(404, 'No extrafield found'); + } + + return $list; + } + + + /** + * Get the list of towns. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $zipcode To filter on zipcode + * @param string $town To filter on city name + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return List of towns + * + * @url GET towns + * + * @throws RestException + */ + function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t"; + $sql.= " WHERE t.active = 1"; + if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'"; + if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'"; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of towns : '.$this->db->lasterror()); + } + + return $list; + } + +} diff --git a/htdocs/api/class/api_dictionarycountries.class.php b/htdocs/api/class/api_dictionarycountries.class.php deleted file mode 100644 index 070be509a8a..00000000000 --- a/htdocs/api/class/api_dictionarycountries.class.php +++ /dev/null @@ -1,184 +0,0 @@ - - * Copyright (C) 2016 Laurent Destailleur - * - * 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 . - */ - -use Luracast\Restler\RestException; - -require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; - -/** - * API class for countries - * - * @access protected - * @class DolibarrApiAccess {@requires user,external} - */ -class DictionaryCountries extends DolibarrApi -{ - private $translations = null; - - /** - * Constructor - */ - function __construct() - { - global $db; - $this->db = $db; - } - - /** - * Get the list of countries. - * - * The names of the countries will be translated to the given language if - * the $lang parameter is provided. The value of $lang must be a language - * code supported by Dolibarr, for example 'en_US' or 'fr_FR'. - * The returned list is sorted by country ID. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number (starting from zero) - * @param string $filter To filter the countries by name - * @param string $lang Code of the language the label of the countries must be translated to - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of countries - * - * @throws RestException - */ - function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') - { - $list = array(); - - // Note: The filter is not applied in the SQL request because it must - // be applied to the translated names, not to the names in database. - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t"; - $sql.=" WHERE 1 = 1"; - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - $sql.= $this->db->order($sortfield, $sortorder); - - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; - - $sql .= $this->db->plimit($limit, $offset); - } - - $result = $this->db->query($sql); - - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $obj = $this->db->fetch_object($result); - $country = new Ccountry($this->db); - if ($country->fetch($obj->rowid) > 0) { - // Translate the name of the country if needed - // and then apply the filter if there is one. - $this->translateLabel($country, $lang); - - if (empty($filter) || stripos($country->label, $filter) !== FALSE) { - $list[] = $this->_cleanObjectDatas($country); - } - } - } - } else { - throw new RestException(503, 'Error when retrieving list of countries : '.$country->error); - } - - return $list; - } - - /** - * Get country by ID. - * - * @param int $id ID of country - * @param string $lang Code of the language the name of the - * country must be translated to - * - * @throws RestException - */ - function get($id, $lang = '') - { - $country = new Ccountry($this->db); - - if ($country->fetch($id) < 0) { - throw new RestException(503, 'Error when retrieving country : '.$country->error); - } - else if ($country->fetch($id) == 0) { - throw new RestException(404, 'country not found'); - } - - $this->translateLabel($country, $lang); - - return $this->_cleanObjectDatas($country); - } - - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - function _cleanObjectDatas($object) - { - $object = parent::_cleanObjectDatas($object); - - unset($object->error); - unset($object->errors); - - return $object; - } - - /** - * Translate the name of the country to the given language. - * - * @param Ccountry $country Country - * @param string $lang Code of the language the name of the - * country must be translated to - */ - private function translateLabel($country, $lang) - { - if (!empty($lang)) { - // Load the translations if this is a new language. - if ($this->translations == null || $this->translations->getDefaultLang() !== $lang) { - global $conf; - $this->translations = new Translate('', $conf); - $this->translations->setDefaultLang($lang); - $this->translations->load('dict'); - } - if ($country->code) { - $key = 'Country'.$country->code; - $translation = $this->translations->trans($key); - if ($translation != $key) { - $country->label = html_entity_decode($translation); - } - } - } - } -} diff --git a/htdocs/api/class/api_dictionaryevents.class.php b/htdocs/api/class/api_dictionaryevents.class.php deleted file mode 100644 index 23d7e8e5dba..00000000000 --- a/htdocs/api/class/api_dictionaryevents.class.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * 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 . - */ - -use Luracast\Restler\RestException; - -require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; - -/** - * API class for events type (content of the actioncomm dictionary) - * - * @access protected - * @class DolibarrApiAccess {@requires user,external} - */ -class DictionaryEvents extends DolibarrApi -{ - /** - * Constructor - */ - function __construct() - { - global $db; - $this->db = $db; - } - - /** - * Get the list of events types. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number (starting from zero) - * @param string $type To filter on type of event - * @param string $module To filter on module events - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types - * - * @throws RestException - */ - function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $sqlfilters = '') - { - $list = array(); - - $sql = "SELECT id, code, type, libelle as label, module"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t"; - $sql.= " WHERE t.active = 1"; - if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; - if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - - $sql.= $this->db->order($sortfield, $sortorder); - - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; - - $sql .= $this->db->plimit($limit, $offset); - } - - $result = $this->db->query($sql); - - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); - } - } else { - throw new RestException(503, 'Error when retrieving list of events types : '.$this->db->lasterror()); - } - - return $list; - } - -} diff --git a/htdocs/api/class/api_dictionaryextrafields.class.php b/htdocs/api/class/api_dictionaryextrafields.class.php deleted file mode 100644 index 69f574797c7..00000000000 --- a/htdocs/api/class/api_dictionaryextrafields.class.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * 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 . - */ - -use Luracast\Restler\RestException; - -//require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; - -/** - * API class for extra fields (content of the extrafields) - * - * @access protected - * @class DolibarrApiAccess {@requires user,external} - */ -class DictionaryExtraFields extends DolibarrApi -{ - /** - * Constructor - */ - function __construct() - { - global $db; - $this->db = $db; - } - - /** - * Get the list of extra fields. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')" - * @return List of events types - * - * @throws RestException - */ - function index($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') - { - $list = array(); - - if ($type == 'thirdparty') $type='societe'; - if ($type == 'contact') $type='socpeople'; - - $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed"; - $sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t"; - $sql.= " WHERE t.entity IN (".getEntity('extrafields').")"; - if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'"; - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - $sql.= $this->db->order($sortfield, $sortorder); - - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - while ($tab = $this->db->fetch_object($resql)) - { - // New usage - $list[$tab->elementtype][$tab->name]['type']=$tab->type; - $list[$tab->elementtype][$tab->name]['label']=$tab->label; - $list[$tab->elementtype][$tab->name]['size']=$tab->size; - $list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype; - $list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault; - $list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed; - $list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique; - $list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired; - $list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : ''); - $list[$tab->elementtype][$tab->name]['pos']=$tab->pos; - $list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; - $list[$tab->elementtype][$tab->name]['perms']=$tab->perms; - $list[$tab->elementtype][$tab->name]['list']=$tab->list; - $list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden; - } - } - } - else - { - throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); - } - - if (! count($list)) - { - throw new RestException(404, 'No extrafield found'); - } - - return $list; - } - -} diff --git a/htdocs/api/class/api_dictionarypayments.class.php b/htdocs/api/class/api_dictionarypayments.class.php deleted file mode 100644 index 4c9aa8a948b..00000000000 --- a/htdocs/api/class/api_dictionarypayments.class.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * 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 . - */ - -use Luracast\Restler\RestException; - -require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; - -/** - * API class for payment type (content of the paiement dictionary) - * - * @access protected - * @class DolibarrApiAccess {@requires user,external} - */ -class DictionaryPayments extends DolibarrApi -{ - /** - * Constructor - */ - function __construct() - { - global $db; - $this->db = $db; - } - - /** - * Get the list of payments types. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number {@min 0} - * @param int $active Payment type is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')" - * @return List of payment types - * - * @throws RestException - */ - function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') - { - $list = array(); - - $sql = "SELECT id, code, type, libelle as label, module"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t"; - $sql.= " WHERE t.active = ".$active; - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - - $sql.= $this->db->order($sortfield, $sortorder); - - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; - - $sql .= $this->db->plimit($limit, $offset); - } - - $result = $this->db->query($sql); - - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); - } - } else { - throw new RestException(503, 'Error when retrieving list of payment types : '.$this->db->lasterror()); - } - - return $list; - } - -} diff --git a/htdocs/api/class/api_dictionarytowns.class.php b/htdocs/api/class/api_dictionarytowns.class.php deleted file mode 100644 index 0ebcfbe0b17..00000000000 --- a/htdocs/api/class/api_dictionarytowns.class.php +++ /dev/null @@ -1,102 +0,0 @@ - - * Copyright (C) 2016 Laurent Destailleur - * - * 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 . - */ - -use Luracast\Restler\RestException; - -require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; - -/** - * API class for towns (content of the ziptown dictionary) - * - * @access protected - * @class DolibarrApiAccess {@requires user,external} - */ -class DictionaryTowns extends DolibarrApi -{ - /** - * Constructor - */ - function __construct() - { - global $db; - $this->db = $db; - } - - /** - * Get the list of towns. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number (starting from zero) - * @param string $zipcode To filter on zipcode - * @param string $town To filter on city name - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of towns - * - * @throws RestException - */ - function index($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $sqlfilters = '') - { - $list = array(); - - $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t"; - $sql.= " WHERE t.active = 1"; - if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'"; - if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'"; - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - - $sql.= $this->db->order($sortfield, $sortorder); - - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; - - $sql .= $this->db->plimit($limit, $offset); - } - - $result = $this->db->query($sql); - - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); - } - } else { - throw new RestException(503, 'Error when retrieving list of towns : '.$this->db->lasterror()); - } - - return $list; - } - -} From 7f420f32463700bf3a499cdd57454e9681feb9d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 10:53:24 +0200 Subject: [PATCH 036/428] Complete vat rates for india --- htdocs/install/mysql/data/llx_c_tva.sql | 15 +++++++++------ htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 10 ++++++++-- htdocs/product/fournisseurs.php | 4 +++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index b4389ca8397..b805b9f8014 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -135,13 +135,16 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 3 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 34, 3, '0','0','VAT Rate 0',1); -- INDIA (id country=117) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1171, 117, '12.5','0','VAT standard rate', 0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1172, 117, '4','0','VAT reduced rate', 0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1173, 117, '1','0','VAT super-reduced rate',0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1174, 117, '0','0','VAT Rate 0', 0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1171, 117, '0','0','VAT Rate 0', 0); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'CGST+SGST', 0, 9, '1', 9, '1', 0, 'CGST+SGST - Same state sales', 1); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'IGST' , 18, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1178, 117, 'C+S-5', 0, 2.5, '1', 2.5, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1179, 117, 'I-5' , 5, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1180, 117, 'C+S-12', 0, 6, '1', 6, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1181, 117, 'I-12' , 12, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'C+S-18', 0, 9, '1', 9, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'I-18' , 18, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1182, 117, 'C+S-28', 0, 14, '1', 14, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1183, 117, 'I-28' , 28, 0, '0', 0, '0', 0, 'IGST', 1); -- IRELAND (id country=8) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (81, 8, '0','0','VAT Rate 0',1); diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index cd955b0416b..a2534728683 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -597,5 +597,11 @@ ALTER TABLE llx_mailing_cibles MODIFY COLUMN source_url varchar(255); -- VPGSQL8.2 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -- VPGSQL8.2 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website_page FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'CGST+SGST', 0, 9, '1', 9, '1', 0, 'CGST+SGST - Same state sales', 1); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'IGST' , 18, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1178, 117, 'C+S-5', 0, 2.5, '1', 2.5, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1179, 117, 'I-5' , 5, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1180, 117, 'C+S-12', 0, 6, '1', 6, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1181, 117, 'I-12' , 12, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'C+S-18', 0, 9, '1', 9, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'I-18' , 18, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1182, 117, 'C+S-28', 0, 14, '1', 14, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1183, 117, 'I-28' , 28, 0, '0', 0, '0', 0, 'IGST', 1); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index ed53163615d..cb295012795 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -472,7 +472,9 @@ if ($id > 0 || $ref) $default_vat=$object->tva_tx; } } - print ''; + $vattosuggest=(GETPOST("tva_tx")?vatrate(GETPOST("tva_tx")):($default_vat!=''?vatrate($default_vat):'')); + $vattosuggest=preg_replace('/\s*\(.*\)$/','', $vattosuggest); + print ''; print ''; if (! empty($conf->dynamicprices->enabled)) //Only show price mode and expression selector if module is enabled From 1002923dea899c1caf700d81f0e029e1587d2dbe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 10:58:24 +0200 Subject: [PATCH 037/428] Fix css --- htdocs/product/composition/card.php | 2 +- htdocs/product/traduction.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index fc8ae32fb38..946ce1be7a8 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -208,7 +208,7 @@ if ($id > 0 || ! empty($ref)) $shownav = 1; if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 1); + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 0); if ($object->type!=Product::TYPE_SERVICE || empty($conf->global->PRODUIT_MULTIPRICES)) { diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 004662972c4..791da80c05d 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -205,7 +205,7 @@ $linkback = ''.$langs->trans("BackTo $shownav = 1; if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; -dol_banner_tab($object, 'ref', $linkback, shownav, 'ref'); +dol_banner_tab($object, 'ref', $linkback, shownav, 'ref', '', '', '', 0, '', '', 1); dol_fiche_end(); From d2c55ea07bd7d4ea65013d15588038736fab6eae Mon Sep 17 00:00:00 2001 From: Papoteur Date: Tue, 26 Sep 2017 11:27:53 +0200 Subject: [PATCH 038/428] Factorize code between payments reports client/provider --- .../modules/rapport/pdf_paiement.class.php | 129 ++++-- .../rapport/pdf_paiement_fourn.class.php | 387 +----------------- 2 files changed, 100 insertions(+), 416 deletions(-) diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index da1223526db..606419e9a2a 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -77,6 +77,8 @@ class pdf_paiement $this->posxinvoiceamount-=10; $this->posxpaymentamount-=20; } + // which type of document will be generated: clients (client) or providers (fourn) invoices + $this->doc_type = "client"; } @@ -105,7 +107,7 @@ class pdf_paiement $this->month=$month; $this->year=$year; - +dol_syslog(get_class($this)."::write_file".$year." ".$month, LOG_DEBUG); $dir=$_dir.'/'.$year; if (! is_dir($dir)) @@ -120,7 +122,15 @@ class pdf_paiement $month = sprintf("%02d",$month); $year = sprintf("%04d",$year); - $file = $dir . "/payments-".$year."-".$month.".pdf"; + switch ($this->doc_type) { + case "client": + $file = $dir . "/payments-".$year."-".$month.".pdf"; + break; + case "fourn": + $file = $dir . "/supplier_payments-".$year."-".$month.".pdf"; + break; + } + // Add pdfgeneration hook if (! is_object($hookmanager)) @@ -147,8 +157,19 @@ class pdf_paiement $lines=array(); // count number of lines of payment +dol_syslog(get_class($this)."::write_file".$year." ".$month." ".dol_get_first_day($year,$month), LOG_DEBUG); +dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate(dol_get_first_day($year,$month)), LOG_DEBUG); +dol_syslog(get_class($this)."::write_file".$year." ".$month." ".dol_get_last_day($year,$month), LOG_DEBUG); +dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate(dol_get_last_day($year,$month)), LOG_DEBUG); $sql = "SELECT p.rowid as prowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p"; + switch ($this->doc_type) { + case "client": + $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p"; + break; + case "fourn": + $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p"; + break; + } $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; $sql.= " AND p.entity = " . $conf->entity; $result = $this->db->query($sql); @@ -158,35 +179,70 @@ class pdf_paiement } // number of bill - $sql = "SELECT p.datep as dp, f.facnumber"; - //$sql .= ", c.libelle as paiement_type, p.num_paiement"; - $sql.= ", c.code as paiement_code, p.num_paiement"; - $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount"; - $sql.= ", pf.amount as pf_amount"; - if (! empty($conf->banque->enabled)) - $sql.= ", ba.ref as bankaccount"; - $sql.= ", p.rowid as prowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."facture as f,"; - $sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf,"; - if (! empty($conf->banque->enabled)) - $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) - { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid"; - if (! empty($conf->banque->enabled)) - $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid "; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND p.fk_paiement = c.id "; - $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; - if (! $user->rights->societe->client->voir && ! $socid) - { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - } - if (! empty($socid)) $sql .= " AND s.rowid = ".$socid; - $sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC"; + switch ($this->doc_type) { + case "client": + $sql = "SELECT p.datep as dp, f.facnumber"; + //$sql .= ", c.libelle as paiement_type, p.num_paiement"; + $sql.= ", c.code as paiement_code, p.num_paiement"; + $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount"; + $sql.= ", pf.amount as pf_amount"; + if (! empty($conf->banque->enabled)) + $sql.= ", ba.ref as bankaccount"; + $sql.= ", p.rowid as prowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."facture as f,"; + $sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf,"; + if (! empty($conf->banque->enabled)) + $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,"; + $sql.= " ".MAIN_DB_PREFIX."societe as s"; + if (! $user->rights->societe->client->voir && ! $socid) + { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid"; + if (! empty($conf->banque->enabled)) + $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid "; + $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND p.fk_paiement = c.id "; + $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; + if (! $user->rights->societe->client->voir && ! $socid) + { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + } + if (! empty($socid)) $sql .= " AND s.rowid = ".$socid; + $sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC"; + break; + case "fourn": + $sql = "SELECT p.datep as dp, f.ref as facnumber"; + //$sql .= ", c.libelle as paiement_type, p.num_paiement"; + $sql.= ", c.code as paiement_code, p.num_paiement"; + $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount"; + $sql.= ", pf.amount as pf_amount"; + if (! empty($conf->banque->enabled)) + $sql.= ", ba.ref as bankaccount"; + $sql.= ", p.rowid as prowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p, ".MAIN_DB_PREFIX."facture_fourn as f,"; + $sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,"; + if (! empty($conf->banque->enabled)) + $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,"; + $sql.= " ".MAIN_DB_PREFIX."societe as s"; + if (! $user->rights->societe->client->voir && ! $socid) + { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid"; + if (! empty($conf->banque->enabled)) + $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid "; + $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND p.fk_paiement = c.id "; + $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; + if (! $user->rights->societe->client->voir && ! $socid) + { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + } + if (! empty($socid)) $sql .= " AND s.rowid = ".$socid; + $sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC"; + break; + } dol_syslog(get_class($this)."::write_file", LOG_DEBUG); $result = $this->db->query($sql); @@ -300,7 +356,14 @@ class pdf_paiement $default_font_size = pdf_getPDFFontSize($outputlangs); $title=$conf->global->MAIN_INFO_SOCIETE_NOM; - $title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments"); + switch($this->doc_type) { + case "client": + $title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments"); + break; + case "fourn": + $title.=' - '.$outputlangs->transnoentities("ListOfSupplierPayments"); + break; + } $title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true); $pdf->SetFont('','B',$default_font_size + 1); $pdf->SetXY($this->marge_gauche,10); diff --git a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php index 108b3bd6ce6..c7cb11ad31f 100644 --- a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php @@ -23,12 +23,12 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - +require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement.class.php'; /** * Classe permettant de generer les rapports de paiement */ -class pdf_paiement_fourn +class pdf_paiement_fourn extends pdf_paiement { /** * Constructor @@ -37,389 +37,10 @@ class pdf_paiement_fourn */ function __construct($db) { - global $langs,$conf; - $langs->load("bills"); - $langs->load("compta"); - - $this->db = $db; - $this->description = $langs->transnoentities("ListOfCustomerPayments"); - - // 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->tab_top = 30; - - $this->line_height = 5; - $this->line_per_page = 40; - $this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5; // must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5; - - $this->posxdate=$this->marge_gauche+2; - $this->posxpaymenttype=42; - $this->posxinvoice=82; - $this->posxbankaccount=110; - $this->posxinvoiceamount=132; - $this->posxpaymentamount=162; - if ($this->page_largeur < 210) // To work with US executive format - { - $this->line_per_page = 35; - $this->posxpaymenttype-=10; - $this->posxinvoice-=0; - $this->posxinvoiceamount-=10; - $this->posxpaymentamount-=20; + parent::__construct($db); + $this->doc_type = "fourn"; } } - /** - * Fonction generant la rapport sur le disque - * - * @param string $_dir repertoire - * @param int $month mois du rapport - * @param int $year annee du rapport - * @param string $outputlangs Lang output object - * @return int <0 if KO, >0 if OK - */ - function write_file($_dir, $month, $year, $outputlangs) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - - global $conf, $hookmanager, $langs, $user; - - $socid=0; - if ($user->societe_id) $socid=$user->societe_id; - - 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'; - - $this->month=$month; - $this->year=$year; - - $dir=$_dir.'/'.$year; - - if (! is_dir($dir)) - { - $result=dol_mkdir($dir); - if ($result < 0) - { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); - return -1; - } - } - - $month = sprintf("%02d",$month); - $year = sprintf("%04d",$year); - $file = $dir . "/supplier_payments-".$year."-".$month.".pdf"; - - // 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,'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 - - if (class_exists('TCPDF')) - { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - - $num=0; - $lines=array(); - - // count number of lines of payment - $sql = "SELECT p.rowid as prowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p"; - $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; - $sql.= " AND p.entity = " . $conf->entity; - $result = $this->db->query($sql); - if ($result) - { - $numpaiement = $this->db->num_rows($result); - } - - // number of bill - $sql = "SELECT p.datep as dp, f.ref"; - //$sql .= ", c.libelle as paiement_type, p.num_paiement"; - $sql.= ", c.code as paiement_code, p.num_paiement"; - $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount"; - $sql.= ", pf.amount as pf_amount"; - if (! empty($conf->banque->enabled)) - $sql.= ", ba.ref as bankaccount"; - $sql.= ", p.rowid as prowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p, ".MAIN_DB_PREFIX."facture_fourn as f,"; - $sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,"; - if (! empty($conf->banque->enabled)) - $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) - { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid"; - if (! empty($conf->banque->enabled)) - $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid "; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND p.fk_paiement = c.id "; - $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; - if (! $user->rights->societe->client->voir && ! $socid) - { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - } - if (! empty($socid)) $sql .= " AND s.rowid = ".$socid; - $sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC"; - - dol_syslog(get_class($this)."::write_file", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - $var=True; - - while ($i < $num) - { - $objp = $this->db->fetch_object($result); - - - $lines[$i][0] = $objp->ref; - $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true); - $lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code); - $lines[$i][3] = $objp->num_paiement; - $lines[$i][4] = price($objp->paiement_amount); - $lines[$i][5] = price($objp->facture_amount); - $lines[$i][6] = price($objp->pf_amount); - $lines[$i][7] = $objp->prowid; - $lines[$i][8] = $objp->bankaccount; - $i++; - } - } - else - { - dol_print_error($this->db); - } - - $pages = intval(($num + $numpaiement) / $this->line_per_page); - - if ((($num + $numpaiement) % $this->line_per_page)>0) - { - $pages++; - } - - if ($pages == 0) - { - // force to build at least one page if report has no line - $pages = 1; - } - - $pdf->Open(); - $pagenb=0; - $pdf->SetDrawColor(128,128,128); - - $pdf->SetTitle($outputlangs->transnoentities("Payments")); - $pdf->SetSubject($outputlangs->transnoentities("Payments")); - $pdf->SetCreator("Dolibarr ".DOL_VERSION); - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - //$pdf->SetKeyWords(); - 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 - $pdf->SetAutoPageBreak(1,0); - - // New page - $pdf->AddPage(); - $pagenb++; - $this->_pagehead($pdf, $pagenb, 1, $outputlangs); - $pdf->SetFont('','', 9); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 - $pdf->SetTextColor(0,0,0); - - - $this->Body($pdf, 1, $lines, $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)); - - $this->result = array('fullpath'=>$file); - - return 1; - } - - /** - * Show top header of page. - * - * @param PDF $pdf Object PDF - * @param int $page Object to show - * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output - * @return void - */ - function _pagehead(&$pdf, $page, $showaddress, $outputlangs) - { - global $langs; - - // Do not add the BACKGROUND as this is a report - //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); - - $default_font_size = pdf_getPDFFontSize($outputlangs); - - $title=$conf->global->MAIN_INFO_SOCIETE_NOM; - $title.=' - '.$outputlangs->transnoentities("ListOfSupplierPayments"); - $title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true); - $pdf->SetFont('','B',$default_font_size + 1); - $pdf->SetXY($this->marge_gauche,10); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C'); - - $pdf->SetFont('','',$default_font_size); - - $pdf->SetXY($this->posxdate, 16); - $pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L'); - - $pdf->SetXY($this->posxdate+100, 16); - $pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R'); - - - // Title line - $pdf->SetXY($this->posxdate, $this->tab_top+2); - $pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date'); - - $pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10); - $pdf->SetXY($this->posxpaymenttype, $this->tab_top+2); - $pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L'); - - $pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10); - $pdf->SetXY($this->posxinvoice, $this->tab_top+2); - $pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L'); - - $pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10); - $pdf->SetXY($this->posxbankaccount, $this->tab_top+2); - $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L'); - - - $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10); - $pdf->SetXY($this->posxinvoiceamount, $this->tab_top+2); - $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R'); - - $pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10); - $pdf->SetXY($this->posxpaymentamount, $this->tab_top+2); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R'); - - $pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10); - - $pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10); - } - - - /** - * Output body - * - * @param PDF $pdf PDF object - * @param string $page Page - * @param array $lines Array of lines - * @param Translate $outputlangs Object langs - * @return void - */ - function Body(&$pdf, $page, $lines, $outputlangs) - { - $default_font_size = pdf_getPDFFontSize($outputlangs); - - $pdf->SetFont('','', $default_font_size - 1); - $oldprowid = 0; - $pdf->SetFillColor(220,220,220); - $yp = 0; - $numlines=count($lines); - for ($j = 0 ; $j < $numlines ; $j++) - { - $i = $j; - if ($yp > $this->tab_height -5) - { - $page++; - $pdf->AddPage(); - $this->_pagehead($pdf, $page, 0, $outputlangs); - $pdf->SetFont('','', $default_font_size - 1); - $yp = 0; - } - if ($oldprowid <> $lines[$j][7]) - { - if ($yp > $this->tab_height -10) - { - $page++; - $pdf->AddPage(); - $this->_pagehead($pdf, $page, 0, $outputlangs); - $pdf->SetFont('','', $default_font_size - 1); - $yp = 0; - } - - $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp); - $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1); - - $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp); - $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1); - - $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp); - $pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1); - - $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1); - $yp = $yp + 5; - } - - // Invoice number - $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp); - $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0); - - // BankAccount - $pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp); - $pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0); - - // Invoice amount - $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp); - $pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0); - - // Payment amount - $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0); - $yp = $yp + 5; - - if ($oldprowid <> $lines[$j][7]) - { - $oldprowid = $lines[$j][7]; - } - } - } -} - From cbe1683fe736557bd52be585b29016c790b4fe92 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Tue, 26 Sep 2017 11:30:28 +0200 Subject: [PATCH 039/428] Invoice number on one line instead of two (issue#7487) --- htdocs/core/modules/rapport/pdf_paiement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 606419e9a2a..6cd8e7aa655 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -465,7 +465,7 @@ dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate // Invoice number $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp); - $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0); + $pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0); // BankAccount $pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp); From 49982b36accdd8c8c7491b5bd2cc2eb4a5a47733 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 11:55:19 +0200 Subject: [PATCH 040/428] FIX #7490 --- htdocs/compta/facture/list.php | 13 +++++---- htdocs/core/actions_massactions.inc.php | 29 ++++++++++--------- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/facture/list.php | 23 +++++++-------- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 3ffd0af9cd3..67ef9c96973 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -95,8 +95,10 @@ $month_lim = GETPOST('month_lim','int'); $year_lim = GETPOST('year_lim','int'); $option = GETPOST('option'); -if ($option == 'late') $filter = 'paye:0'; -$filtre = GETPOST('filtre'); +if ($option == 'late') { + $search_status = '1'; +} +$filtre = GETPOST('filtre','alpha'); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -386,7 +388,7 @@ if ($search_user > 0) $sql.= ' WHERE f.fk_soc = s.rowid'; $sql.= ' AND f.entity IN ('.getEntity('facture').')'; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; +if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category); if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if ($userid) { @@ -399,7 +401,7 @@ if ($filtre) foreach ($aFilter as $filter) { $filt = explode(':', $filter); - $sql .= ' AND ' . trim($filt[0]) . ' = ' . trim($filt[1]); + $sql .= ' AND ' . $db->escape(trim($filt[0])) . ' = ' . $db->escape(trim($filt[1])); } } if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref); @@ -433,7 +435,7 @@ if ($search_status != '' && $search_status >= 0) if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned } -if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode; +if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode); if ($month > 0) { if ($year > 0 && empty($day)) @@ -461,7 +463,6 @@ else if ($year_lim > 0) $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'"; } if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; -if ($filter == 'paye:0') $sql.= " AND f.fk_statut = 1"; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; if ($search_user > 0) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index d03fb5df214..6dc6fed25f1 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -463,22 +463,23 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se $outputlangs->setDefaultLang($newlang); } - if(!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) { + if(!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) + { // Create output dir if not exists - dol_mkdir($diroutputmassaction); + dol_mkdir($diroutputmassaction); - // Defined name of merged file - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); - $filename=preg_replace('/\s/','_',$filename); + // Defined name of merged file + $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); + $filename=preg_replace('/\s/','_',$filename); - // Save merged file - if ($filter=='paye:0') - { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); - } - if ($year) $filename.='_'.$year; - if ($month) $filename.='_'.$month; + // Save merged file + if (in_array($object->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) + { + if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + } + if ($year) $filename.='_'.$year; + if ($month) $filename.='_'.$month; if (count($files)>0) { @@ -546,7 +547,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se $filename=preg_replace('/\s/','_',$filename); // Save merged file - if ($filter=='paye:0') + if (in_array($object->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) { if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 6e5e7fce66a..8b573679f82 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1799,7 +1799,7 @@ class FactureFournisseur extends CommonInvoice $response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24; $response->label=$langs->trans("SupplierBillsToPay"); - $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=fac.fk_statut:1,paye:0&mainmenu=accountancy&leftmenu=suppliers_bills'; + $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=suppliers_bills'; $response->img=img_object($langs->trans("Bills"),"bill"); $facturestatic = new FactureFournisseur($this->db); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index e4b18202d7b..6d388540053 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -54,6 +54,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$optioncss = GETPOST('optioncss','alpha'); $socid = GETPOST('socid','int'); @@ -67,6 +68,11 @@ if ($user->societe_id > 0) $mode=GETPOST("mode"); +$search_all = GETPOST('sall', 'alphanohtml'); +$search_label = GETPOST("search_label","alpha"); +$search_company = GETPOST("search_company","alpha"); +$search_amount_no_tax = GETPOST("search_amount_no_tax","alpha"); +$search_amount_all_tax = GETPOST("search_amount_all_tax","alpha"); $search_product_category=GETPOST('search_product_category','int'); $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha'); $search_refsupplier=GETPOST('search_refsupplier','alpha'); @@ -93,20 +99,12 @@ $day_lim = GETPOST('day_lim','int'); $month_lim = GETPOST('month_lim','int'); $year_lim = GETPOST('year_lim','int'); $toselect = GETPOST('toselect', 'array'); -$filter = GETPOST('filtre','alpha'); $option = GETPOST('option'); if ($option == 'late') { - $filter = 'paye:0'; + $search_status = '1'; } - -$search_all = GETPOST('sall', 'alphanohtml'); -$search_label = GETPOST("search_label","alpha"); -$search_company = GETPOST("search_company","alpha"); -$search_amount_no_tax = GETPOST("search_amount_no_tax","alpha"); -$search_amount_all_tax = GETPOST("search_amount_all_tax","alpha"); -$search_status=GETPOST('search_status','alpha'); -$optioncss = GETPOST('optioncss','alpha'); +$filter = GETPOST('filtre','alpha'); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -348,7 +346,6 @@ else if ($year_lim > 0) $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'"; } if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; -if ($filter == 'paye:0') $sql.= " AND f.fk_statut = 1"; if ($search_label) $sql .= natural_search('f.libelle', $search_label); if ($search_status != '' && $search_status >= 0) { @@ -360,10 +357,10 @@ if ($filter && $filter != -1) foreach ($aFilter as $fil) { $filt = explode(':', $fil); - $sql .= ' AND ' . trim($filt[0]) . ' = ' . trim($filt[1]); + $sql .= ' AND ' . $db->escape(trim($filt[0])) . ' = ' . $db->escape(trim($filt[1])); } } -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; +if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); if ($search_user > 0) { $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; From 50d639f1fa868be2f74b52edf39101076954e59e Mon Sep 17 00:00:00 2001 From: Papoteur Date: Tue, 26 Sep 2017 12:10:51 +0200 Subject: [PATCH 041/428] Add total and subtotal in payments reports --- .../core/modules/rapport/pdf_paiement.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 6cd8e7aa655..007057819f8 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -42,6 +42,7 @@ class pdf_paiement global $langs,$conf; $langs->load("bills"); $langs->load("compta"); + $langs->load("main"); $this->db = $db; $this->description = $langs->transnoentities("ListOfCustomerPayments"); @@ -266,6 +267,7 @@ dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate $lines[$i][6] = price($objp->pf_amount); $lines[$i][7] = $objp->prowid; $lines[$i][8] = $objp->bankaccount; + $lines[$i][9] = $objp->paiement_amount; $i++; } } @@ -420,10 +422,13 @@ dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate */ function Body(&$pdf, $page, $lines, $outputlangs) { + global $langs; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('','', $default_font_size - 1); $oldprowid = 0; + $total_page = 0; + $total = 0; $pdf->SetFillColor(220,220,220); $yp = 0; $numlines=count($lines); @@ -440,13 +445,17 @@ dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate } if ($oldprowid <> $lines[$j][7]) { - if ($yp > $this->tab_height -10) + if ($yp > $this->tab_height -15) { + $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0); $page++; $pdf->AddPage(); $this->_pagehead($pdf, $page, 0, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $yp = 0; + $total += $total_page; + $total_page = 0; } $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp); @@ -461,6 +470,7 @@ dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1); $yp = $yp + 5; + $total_page += $lines[$j][9]; } // Invoice number @@ -485,6 +495,9 @@ dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate $oldprowid = $lines[$j][7]; } } + $total += $total_page; + $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('Total')." : ".price($total), 0, 'R', 0); } } From 76f1dbe16b6e748bfc4cd04a4502a66a48fdc5e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 12:25:26 +0200 Subject: [PATCH 042/428] FIX #7288 --- htdocs/societe/class/societe.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 523ab31c8f9..b950b2f2c46 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1021,7 +1021,7 @@ class Societe extends CommonObject $sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; $sql .= ', s.status'; $sql .= ', s.price_level'; - $sql .= ', s.tms as date_modification'; + $sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif'; $sql .= ', s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; $sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6'; $sql .= ', s.capital, s.tva_intra'; @@ -1087,8 +1087,10 @@ class Societe extends CommonObject $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; - $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); + $this->user_creation = $obj->fk_user_creat; + $this->user_modification = $obj->fk_user_modif; $this->address = $obj->address; $this->zip = $obj->zip; From 2fe0736b87e215ab823e9dbf172fe95b25b30016 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 26 Sep 2017 12:32:50 +0200 Subject: [PATCH 043/428] Update qty dispatched on qty change Store qty dispatched and qty ordered only once per orderline --- htdocs/fourn/js/lib_dispatch.js | 55 +++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/htdocs/fourn/js/lib_dispatch.js b/htdocs/fourn/js/lib_dispatch.js index 84f74c30c54..50b6809a979 100644 --- a/htdocs/fourn/js/lib_dispatch.js +++ b/htdocs/fourn/js/lib_dispatch.js @@ -1,5 +1,5 @@ // Copyright (C) 2014 Cedric GROSS -// Copyright (C) 2015 Francis Appels +// Copyright (C) 2017 Francis Appels // // 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 @@ -24,7 +24,7 @@ * addDispatchLine * Adds new table row for dispatching to multiple stock locations * - * @param index int index of produt line. 0 = first product line + * @param index int index of product line. 0 = first product line * @param type string type of dispatch (batch = batch dispatch, dispatch = non batch dispatch) * @param mode string 'qtymissing' will create new line with qty missing, 'lessone' will keep 1 in old line and the rest in new one */ @@ -35,17 +35,17 @@ function addDispatchLine(index, type, mode) console.log("Split line type="+type+" index="+index+" mode="+mode); var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch - qtyOrdered = parseFloat($("#qty_ordered_"+(nbrTrs - 1)+"_"+index).val()), + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()), qtyDispatched; if (mode === 'lessone') { - qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + 1; + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + 1; } else { - qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + qty; + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + qty; } if (qtyDispatched < qtyOrdered) @@ -63,10 +63,10 @@ function addDispatchLine(index, type, mode) //insert new row before last row $("tr[name^='"+type+"_'][name$='_"+index+"']:last").after($row); //remove cloned select2 with duplicate id. - $("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); + $("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); /* Suffix of lines are: _ trs.length _ index */ $("#qty_"+nbrTrs+"_"+index).focus(); - $("#qty_dispatched_"+(nbrTrs)+"_"+index).val(qtyDispatched); + $("#qty_dispatched_0_"+index).val(qtyDispatched); //hide all buttons then show only the last one $("tr[name^='"+type+"_'][name$='_"+index+"'] .splitbutton").hide(); @@ -79,10 +79,47 @@ function addDispatchLine(index, type, mode) } else { - $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + // Store arbitrary data for dispatch qty input field change event + $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); + $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); + $("#qty_"+(nbrTrs-1)+"_"+index).data('index', index); + // Update dispatched qty when value dispatch qty input field changed + $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); } - //set focus on lot of new line (if it exists) $("#lot_number_"+(nbrTrs)+"_"+index).focus(); } +} + +/** + * onChangeDispatchLineQty + * + * event handler for dispatch qty input field + * + * element requires arbitrary data qty (value before change), type (type of dispatch) and index (index of product line) + */ + +function onChangeDispatchLineQty() { + var index = $(this).data('index'), + type = $(this).data('type'), + qty = parseFloat($(this).data('qty')), + changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched; + + if (index >= 0 && type && qty >= 0) { + nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length; + qtyChanged = parseFloat($(this).val()) - qty; // qty changed + qtyDispatching = parseFloat($("#qty_"+(nbrTrs-1)+"_"+index).val()); // qty currently being dispatched + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // qty ordered + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()); // qty already dispatched + + // console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); + + if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) { + $("#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged); + } else { + $(this).val($(this).data('qty')); + } + $(this).data('qty', $(this).val()); + } } \ No newline at end of file From 7f938bc517f1ae1e3766f5c68e6519ce6c71fd6d Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 26 Sep 2017 12:32:58 +0200 Subject: [PATCH 044/428] NEW : unexistant function load_state_board() on several objects --- htdocs/comm/action/class/actioncomm.class.php | 132 +++++++++----- htdocs/compta/bank/class/account.class.php | 128 ++++++++----- .../cheque/class/remisecheque.class.php | 65 +++++-- htdocs/index.php | 29 ++- htdocs/projet/class/task.class.php | 171 +++++++++++------- 5 files changed, 356 insertions(+), 169 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index ec1c84dd652..ff5b2aca769 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -907,7 +907,7 @@ class ActionComm extends CommonObject return $db->lasterror(); } } - + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -916,50 +916,92 @@ class ActionComm extends CommonObject */ function load_board($user) { - global $conf, $langs; - - $sql = "SELECT a.id, a.datep as dp"; - $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= ")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - $sql.= " WHERE a.percent >= 0 AND a.percent < 100"; - $sql.= " AND a.entity IN (".getEntity('agenda').")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; - if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; - if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; - - $resql=$this->db->query($sql); - if ($resql) - { - $agenda_static = new ActionComm($this->db); - - $response = new WorkboardResponse(); - $response->warning_delay = $conf->agenda->warning_delay/60/60/24; - $response->label = $langs->trans("ActionsToDo"); - $response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda'; - if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; - $response->img = img_object('',"action",'class="inline-block valigntextmiddle"'); - - // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) - { - $response->nbtodo++; - - $agenda_static->datep = $this->db->jdate($obj->dp); - - if ($agenda_static->hasDelay()) { - $response->nbtodolate++; - } - } - - return $response; - } - else - { - $this->error=$this->db->error(); - return -1; - } + global $conf, $langs; + + $sql = "SELECT a.id, a.datep as dp"; + $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= ")"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + $sql.= " WHERE a.percent >= 0 AND a.percent < 100"; + $sql.= " AND a.entity IN (".getEntity('agenda').")"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; + if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; + if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; + + $resql=$this->db->query($sql); + if ($resql) + { + $agenda_static = new ActionComm($this->db); + + $response = new WorkboardResponse(); + $response->warning_delay = $conf->agenda->warning_delay/60/60/24; + $response->label = $langs->trans("ActionsToDo"); + $response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda'; + if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; + $response->img = img_object('',"action",'class="inline-block valigntextmiddle"'); + + // This assignment in condition is not a bug. It allows walking the results. + while ($obj=$this->db->fetch_object($resql)) + { + $response->nbtodo++; + + $agenda_static->datep = $this->db->jdate($obj->dp); + + if ($agenda_static->hasDelay()) { + $response->nbtodolate++; + } + } + + return $response; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board() + { + global $user; + + $this->nb=array(); + + $sql = "SELECT count(a.id) as nb"; + $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= ")"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; + if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; + if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; + + $resql=$this->db->query($sql); + if ($resql) + { + $agenda_static = new ActionComm($this->db); + + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["actionscomm"]=$obj->nb; + } + + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index cb59862e005..4de089f767b 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1151,7 +1151,7 @@ class Account extends CommonObject return $solde; } } - + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1161,50 +1161,88 @@ class Account extends CommonObject */ function load_board(User $user, $filteraccountid = 0) { - global $conf, $langs; - - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe - - $sql = "SELECT b.rowid, b.datev as datefin"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; - $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.rappro=0"; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable - $sql.= " AND clos = 0"; - if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; - - $resql=$this->db->query($sql); - if ($resql) - { - $langs->load("banks"); - $now=dol_now(); - - require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; - - $response = new WorkboardResponse(); - $response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24; - $response->label=$langs->trans("TransactionsToConciliate"); - $response->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank'; - $response->img=img_object('',"payment"); - - while ($obj=$this->db->fetch_object($resql)) - { - $response->nbtodo++; - if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) { - $response->nbtodolate++; - } - } - - return $response; - } - else - { - dol_print_error($this->db); - $this->error=$this->db->error(); - return -1; - } + global $conf, $langs; + + if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + + $sql = "SELECT b.rowid, b.datev as datefin"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql.= " WHERE b.rappro=0"; + $sql.= " AND b.fk_account = ba.rowid"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable + $sql.= " AND clos = 0"; + if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; + + $resql=$this->db->query($sql); + if ($resql) + { + $langs->load("banks"); + $now=dol_now(); + + require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; + + $response = new WorkboardResponse(); + $response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24; + $response->label=$langs->trans("TransactionsToConciliate"); + $response->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank'; + $response->img=img_object('',"payment"); + + while ($obj=$this->db->fetch_object($resql)) + { + $response->nbtodo++; + if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) { + $response->nbtodolate++; + } + } + + return $response; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } + + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board($filteraccountid = 0) + { + global $user; + + if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + + $sql = "SELECT count(b.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql.= " WHERE b.fk_account = ba.rowid"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable + $sql.= " AND clos = 0"; + if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; + + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["banklines"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 808d2cbb00b..8f5f51f36e9 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -478,20 +478,20 @@ class RemiseCheque extends CommonObject return ""; } } - - + + /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Objet user - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Objet user + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ function load_board($user) { global $conf, $langs; - + if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe - + $sql = "SELECT b.rowid, b.datev as datefin"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; @@ -500,28 +500,28 @@ class RemiseCheque extends CommonObject $sql.= " AND b.fk_type = 'CHQ'"; $sql.= " AND b.fk_bordereau = 0"; $sql.= " AND b.amount > 0"; - + $resql=$this->db->query($sql); if ($resql) { $langs->load("banks"); $now=dol_now(); - + $response = new WorkboardResponse(); $response->warning_delay=$conf->bank->cheque->warning_delay/60/60/24; $response->label=$langs->trans("BankChecksToReceipt"); $response->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank'; $response->img=img_object('',"payment"); - + while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; - + if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->cheque->warning_delay)) { $response->nbtodolate++; } } - + return $response; } else @@ -531,6 +531,45 @@ class RemiseCheque extends CommonObject return -1; } } + + + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board() + { + global $user; + + if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + + $sql = "SELECT count(b.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql.= " WHERE b.fk_account = ba.rowid"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql.= " AND b.fk_type = 'CHQ'"; + $sql.= " AND b.amount > 0"; + + $resql=$this->db->query($sql); + if ($resql) + { + + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["cheques"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } /** diff --git a/htdocs/index.php b/htdocs/index.php index c2b77d24222..9298e9c411f 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -375,8 +375,12 @@ if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) { include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $board=new ActionComm($db); - - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['actionscomm']; + } + $dashboardlines[] = $wb_res; } // Number of project opened @@ -397,7 +401,12 @@ if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) { include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $board=new Task($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['tasks']; + } + $dashboardlines[] = $wb_res; } // Number of commercial proposals opened (expired) @@ -513,7 +522,12 @@ if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->s $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate if ($nb > 0) { - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['banklines']; + } + $dashboardlines[] = $wb_res; } } @@ -522,7 +536,12 @@ if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->s { include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; $board=new RemiseCheque($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['cheques']; + } + $dashboardlines[] = $wb_res; } // Number of foundation members diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 10a78e017c8..32ae678b016 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1693,8 +1693,8 @@ class Task extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } - - + + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1703,65 +1703,114 @@ class Task extends CommonObject */ function load_board($user) { - global $conf, $langs; - - $mine=0; $socid=$user->societe_id; - - $projectstatic = new Project($this->db); - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); - - // List of tasks (does not care about permissions. Filtering will be done later) - $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; - $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; - $sql.= " t.dateo as date_start, t.datee as datee"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; - $sql.= " AND p.fk_statut = 1"; - $sql.= " AND t.fk_projet = p.rowid"; - $sql.= " AND t.progress < 100"; // tasks to do - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; - // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser - //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - //print $sql; - $resql=$this->db->query($sql); - if ($resql) - { - $task_static = new Task($this->db); - - $response = new WorkboardResponse(); - $response->warning_delay = $conf->projet->task->warning_delay/60/60/24; - $response->label = $langs->trans("OpenedTasks"); - if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; - else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project'; - $response->img = img_object('',"task"); - - // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) - { - $response->nbtodo++; - - $task_static->projectstatus = $obj->projectstatus; - $task_static->progress = $obj->progress; - $task_static->fk_statut = $obj->status; - $task_static->date_end = $this->db->jdate($obj->datee); - - if ($task_static->hasDelay()) { - $response->nbtodolate++; - } - } - - return $response; - } - else - { - $this->error=$this->db->error(); - return -1; - } + global $conf, $langs; + + $mine=0; $socid=$user->societe_id; + + $projectstatic = new Project($this->db); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); + + // List of tasks (does not care about permissions. Filtering will be done later) + $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; + $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; + $sql.= " t.dateo as date_start, t.datee as datee"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql.= " AND p.fk_statut = 1"; + $sql.= " AND t.fk_projet = p.rowid"; + $sql.= " AND t.progress < 100"; // tasks to do + if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser + //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + //print $sql; + $resql=$this->db->query($sql); + if ($resql) + { + $task_static = new Task($this->db); + + $response = new WorkboardResponse(); + $response->warning_delay = $conf->projet->task->warning_delay/60/60/24; + $response->label = $langs->trans("OpenedTasks"); + if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; + else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project'; + $response->img = img_object('',"task"); + + // This assignment in condition is not a bug. It allows walking the results. + while ($obj=$this->db->fetch_object($resql)) + { + $response->nbtodo++; + + $task_static->projectstatus = $obj->projectstatus; + $task_static->progress = $obj->progress; + $task_static->fk_statut = $obj->status; + $task_static->date_end = $this->db->jdate($obj->datee); + + if ($task_static->hasDelay()) { + $response->nbtodolate++; + } + } + + return $response; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board() + { + global $user; + + $mine=0; $socid=$user->societe_id; + + $projectstatic = new Project($this->db); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); + + // List of tasks (does not care about permissions. Filtering will be done later) + $sql = "SELECT count(p.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql.= " AND t.fk_projet = p.rowid"; // tasks to do + if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser + //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + + $resql=$this->db->query($sql); + if ($resql) + { + + // This assignment in condition is not a bug. It allows walking the results. + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["tasks"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } } /** From 74a2a4c257dd11948453d52b3f0b07dc2bdbb7e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 12:34:18 +0200 Subject: [PATCH 045/428] Better translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 7d96aba7d8f..3c10edc86ca 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1400,7 +1400,7 @@ CompressionOfResources=Compression of HTTP responses CompressionOfResourcesDesc=For exemple using the Apache directive "AddOutputFilterByType DEFLATE" TestNotPossibleWithCurrentBrowsers=Such an automatic detection is not possible with current browsers DefaultValuesDesc=You can define/force here the default value you want to get when your create a new record, and/or defaut filters or sort order when your list record. -DefaultCreateForm=Default values for new objects +DefaultCreateForm=Default values for creation form DefaultSearchFilters=Default search filters DefaultSortOrder=Default sort orders DefaultFocus=Default focus fields From cc9954e95e1d1ddc830e141bf714f8f0c8a20e07 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Tue, 26 Sep 2017 12:51:14 +0200 Subject: [PATCH 046/428] Clean debug messages --- htdocs/core/modules/rapport/pdf_paiement.class.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 007057819f8..35ffc399372 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -108,7 +108,6 @@ class pdf_paiement $this->month=$month; $this->year=$year; -dol_syslog(get_class($this)."::write_file".$year." ".$month, LOG_DEBUG); $dir=$_dir.'/'.$year; if (! is_dir($dir)) @@ -158,10 +157,6 @@ dol_syslog(get_class($this)."::write_file".$year." ".$month, LOG_DEBUG); $lines=array(); // count number of lines of payment -dol_syslog(get_class($this)."::write_file".$year." ".$month." ".dol_get_first_day($year,$month), LOG_DEBUG); -dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate(dol_get_first_day($year,$month)), LOG_DEBUG); -dol_syslog(get_class($this)."::write_file".$year." ".$month." ".dol_get_last_day($year,$month), LOG_DEBUG); -dol_syslog(get_class($this)."::write_file".$year." ".$month." ".$this->db->idate(dol_get_last_day($year,$month)), LOG_DEBUG); $sql = "SELECT p.rowid as prowid"; switch ($this->doc_type) { case "client": From e14087845883657bcf4e9469480d4c7ac9845fb0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 13:00:09 +0200 Subject: [PATCH 047/428] NEW Can import local tax rates in prices --- htdocs/core/modules/modProduct.class.php | 9 +++++++-- htdocs/langs/en_US/main.lang | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index f51e69039e9..79541c10105 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -260,10 +260,12 @@ class modProduct extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'); + $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'); if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields @@ -300,9 +302,12 @@ class modProduct extends DolibarrModules $this->import_fields_array[$r]=array('sp.fk_product'=>"ProductOrService*", 'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.price'=>"PriceQtyMinHT*", - 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this file not required and calculate it from price and qty + 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' ); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_convertvalue_array[$r]=array( 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 93d2542ea69..93616b6151c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -376,7 +376,9 @@ VATIN=IGST VATs=Sales taxes VATINs=IGST taxes LT1=Sales tax 2 +LT1Type=Sales tax 2 type LT2=Sales tax 3 +LT2Type=Sales tax 3 type LT1ES=RE LT2ES=IRPF LT1IN=CGST From d1bee67b40a1f1bcf2a56e0b47c7cb5636f590c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 13:09:19 +0200 Subject: [PATCH 048/428] FIX #3991 --- htdocs/core/class/html.formmail.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 3e09c1a83e8..dab36ec250d 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -907,8 +907,8 @@ class FormMail extends Form /** - * Return templates of email with type = $type_template or type = 'all' - * This search into table c_email_templates. + * Return templates of email with type = $type_template or type = 'all'. + * This search into table c_email_templates. Used by the get_form function. * * @param DoliDB $db Database handler * @param string $type_template Get message for type=$type_template, type='all' also included. @@ -918,7 +918,7 @@ class FormMail extends Form * @param int $active 1=Only active template, 0=Only disabled, -1=All * @return array array('topic'=>,'content'=>,..) */ - private function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1) + public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1) { $ret=array(); From 7b106bc6426872e2f39df651564a7d01432d042b Mon Sep 17 00:00:00 2001 From: dolibarr95 Date: Tue, 26 Sep 2017 14:13:11 +0200 Subject: [PATCH 049/428] Try to fix 7492 check if enough quantity --- htdocs/fourn/commande/card.php | 230 +++++++++++++++++---------------- 1 file changed, 119 insertions(+), 111 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f121a9e371f..c955d7b98d3 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -560,123 +560,131 @@ if (empty($reshook)) $res = $line->fetch($lineid); if (!$res) dol_print_error($db); } + + if( $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid','int')) < 0 ) + { + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); + } + else + { - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) - $info_bits |= 0x01; + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $vat_rate)) + $info_bits |= 0x01; - // Define vat_rate - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty); - $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); + // Define vat_rate + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty); + $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); - if (GETPOST('price_ht') != '') - { - $price_base_type = 'HT'; - $ht = price2num(GETPOST('price_ht')); - } - else - { - $vatratecleaned = $vat_rate; - if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)" - { - $vatratecleaned = trim($reg[1]); - $vatratecode = $reg[2]; - } - - $ttc = price2num(GETPOST('price_ttc')); - $ht = $ttc / (1 + ($vatratecleaned / 100)); - $price_base_type = 'HT'; - } - - $pu_ht_devise = GETPOST('multicurrency_subprice'); - - // Extrafields Lines - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); - // Unset extrafield POST Data - if (is_array($extralabelsline)) { - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + if (GETPOST('price_ht') != '') + { + $price_base_type = 'HT'; + $ht = price2num(GETPOST('price_ht')); + } + else + { + $vatratecleaned = $vat_rate; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = trim($reg[1]); + $vatratecode = $reg[2]; } + + $ttc = price2num(GETPOST('price_ttc')); + $ht = $ttc / (1 + ($vatratecleaned / 100)); + $price_base_type = 'HT'; + } + + $pu_ht_devise = GETPOST('multicurrency_subprice'); + + // Extrafields Lines + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + // Unset extrafield POST Data + if (is_array($extralabelsline)) { + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key]); + } + } + + $result = $object->updateline( + $lineid, + $_POST['product_desc'], + $ht, + $_POST['qty'], + $_POST['remise_percent'], + $vat_rate, + $localtax1_rate, + $localtax2_rate, + $price_base_type, + 0, + isset($_POST["type"])?$_POST["type"]:$line->product_type, + false, + $date_start, + $date_end, + $array_options, + $_POST['units'], + $pu_ht_devise + ); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprodfournprice']); + unset($_POST['remmise_percent']); + unset($_POST['dp_desc']); + unset($_POST['np_desc']); + unset($_POST['pu']); + unset($_POST['tva_tx']); + unset($_POST['date_start']); + unset($_POST['date_end']); + unset($_POST['units']); + unset($localtax1_tx); + unset($localtax2_tx); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); + } + } + else + { + dol_print_error($db,$object->error); + exit; + } } - - $result = $object->updateline( - $lineid, - $_POST['product_desc'], - $ht, - $_POST['qty'], - $_POST['remise_percent'], - $vat_rate, - $localtax1_rate, - $localtax2_rate, - $price_base_type, - 0, - isset($_POST["type"])?$_POST["type"]:$line->product_type, - false, - $date_start, - $date_end, - $array_options, - $_POST['units'], - $pu_ht_devise - ); - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['idprodfournprice']); - unset($_POST['remmise_percent']); - unset($_POST['dp_desc']); - unset($_POST['np_desc']); - unset($_POST['pu']); - unset($_POST['tva_tx']); - unset($_POST['date_start']); - unset($_POST['date_end']); - unset($_POST['units']); - unset($localtax1_tx); - unset($localtax2_tx); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); - - if ($result >= 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db,$result); - } - } - else - { - dol_print_error($db,$object->error); - exit; - } } // Remove a product line From 8de9c5cd36d454eeb71e1fda311e010b9c8d5b03 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 26 Sep 2017 14:18:26 +0200 Subject: [PATCH 050/428] FIX : forgotten php doc on function parameter --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4de089f767b..2eedf341178 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1209,7 +1209,7 @@ class Account extends CommonObject /** * Charge indicateurs this->nb de tableau de bord - * + * @param int id of bank acount for filter * @return int <0 if ko, >0 if ok */ function load_state_board($filteraccountid = 0) From eacb221ffea90cc6706983d608dc799d7515838f Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 26 Sep 2017 15:15:39 +0200 Subject: [PATCH 051/428] fix : add missing column into service's contract lines --- htdocs/contrat/services.php | 76 ++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index aaf0d0cd796..2662f6f33f4 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -115,6 +115,11 @@ $companystatic=new Societe($db); $arrayfields=array( 'c.ref'=>array('label'=>$langs->trans("Contract"), 'checked'=>1, 'position'=>80), 'p.description'=>array('label'=>$langs->trans("Service"), 'checked'=>1, 'position'=>80), + 'cd.qty'=>array('label'=>$langs->trans("Qty"), 'checked'=>0, 'position'=>100), + 'cd.total_ht'=>array('label'=>$langs->trans("TotalHT"), 'checked'=>0, 'position'=>100), + 'cd.total_tva'=>array('label'=>$langs->trans("TotalVAT"), 'checked'=>0, 'position'=>100), + 'cd.tva_tx'=>array('label'=>$langs->trans("VAT"), 'checked'=>0, 'position'=>100), + 'cd.subprice'=>array('label'=>$langs->trans("PriceUHT"), 'checked'=>0, 'position'=>100), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>100), 'cd.date_ouverture_prevue'=>array('label'=>$langs->trans("DateStartPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode == "0")), 'cd.date_ouverture'=>array('label'=>$langs->trans("DateStartRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode > 0)), @@ -199,7 +204,11 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk $sql.= " cd.date_ouverture_prevue,"; $sql.= " cd.date_ouverture,"; $sql.= " cd.date_fin_validite,"; -$sql.= " cd.date_cloture,"; +$sql.= " cd.qty,"; +$sql.= " cd.total_ht,"; +$sql.= " cd.total_tva,"; +$sql.= " cd.tva_tx,"; +$sql.= " cd.subprice,"; //$sql.= " cd.date_c as date_creation,"; $sql.= " cd.tms as date_update"; // Add fields from extrafields @@ -362,6 +371,11 @@ print '
' . $langs->trans("VATRate") . ''; + print '
' . $langs->trans("DefaultTaxRate") . ''; print $form->load_tva("tva_tx", $object->default_vat_code ? $object->tva_tx.' ('.$object->default_vat_code.')' : $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); print '
'.$langs->trans("PriceLevel").''.$langs->trans("VATRate").''.$langs->trans("DefaultTaxRate").''.$langs->trans("SellingPrice").'' . $langs->trans("PriceBase") . '' . $langs->trans("VATRate") . '' . $langs->trans("DefaultTaxRate") . '' . $langs->trans("HT") . '' . $langs->trans("TTC") . '
' . $langs->trans("VATRate") . ''; + print '
' . $langs->trans("DefaultTaxRate") . ''; print $form->load_tva("tva_tx", $object->default_vat_code ? $object->tva_tx.' ('.$object->default_vat_code.')' : $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); print '
' . $langs->trans("VATRate") . ''; + print '
' . $langs->trans("DefaultTaxRate") . ''; print $form->load_tva("tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.' ('.$prodcustprice->default_vat_code.')' : $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly, $object->type, false, 1); print '
' . $langs->trans("ThirdParty") . '' . $langs->trans("AppliedPricesFrom") . '' . $langs->trans("PriceBase") . '' . $langs->trans("VATRate") . '' . $langs->trans("DefaultTaxRate") . '' . $langs->trans("HT") . '' . $langs->trans("TTC") . '' . $langs->trans("INCT") . '' . $langs->trans("ThirdParty") . '' . $langs->trans("AppliedPricesFrom") . '' . $langs->trans("PriceBase") . '' . $langs->trans("VATRate") . '' . $langs->trans("DefaultTaxRate") . '' . $langs->trans("HT") . '' . $langs->trans("TTC") . '' . $langs->trans("INCT") . '
'; if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'],$_SERVER["PHP_SELF"],"c.ref","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['p.description']['checked'])) print_liste_field_titre($arrayfields['p.description']['label'],$_SERVER["PHP_SELF"],"p.description","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['cd.qty']['checked'])) print_liste_field_titre($arrayfields['cd.qty']['label'],$_SERVER["PHP_SELF"],"cd.qty","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['cd.total_ht']['checked'])) print_liste_field_titre($arrayfields['cd.total_ht']['label'],$_SERVER["PHP_SELF"],"cd.total_ht","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['cd.total_tva']['checked'])) print_liste_field_titre($arrayfields['cd.total_tva']['label'],$_SERVER["PHP_SELF"],"cd.total_tva","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['cd.tva_tx']['checked'])) print_liste_field_titre($arrayfields['cd.tva_tx']['label'],$_SERVER["PHP_SELF"],"cd.tva_tx","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['cd.subprice']['checked'])) print_liste_field_titre($arrayfields['cd.subprice']['label'],$_SERVER["PHP_SELF"],"cd.subprice","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'],$_SERVER["PHP_SELF"],"cd.date_ouverture_prevue","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['cd.date_ouverture']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture']['label'],$_SERVER["PHP_SELF"],"cd.date_ouverture","",$param,'align="center"',$sortfield,$sortorder); @@ -407,6 +421,32 @@ if (! empty($arrayfields['p.description']['checked'])) print ''; print ''; } +// detail lines +if (! empty($arrayfields['cd.qty']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['cd.total_ht']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['cd.total_tva']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['cd.tva_tx']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['cd.subprice']['checked'])) +{ + print ''; +} // Third party if (! empty($arrayfields['s.nom']['checked'])) { @@ -414,6 +454,8 @@ if (! empty($arrayfields['s.nom']['checked'])) print ''; print ''; } + + if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) { print ''; } + if (! empty($arrayfields['cd.qty']['checked'])) + { + print ''; + } + if (! empty($arrayfields['cd.total_ht']['checked'])) + { + print ''; + } + if (! empty($arrayfields['cd.total_tva']['checked'])) + { + print ''; + } + if (! empty($arrayfields['cd.tva_tx']['checked'])) + { + print ''; + } + if (! empty($arrayfields['cd.subprice']['checked'])) + { + print ''; + } + + // Third party if (! empty($arrayfields['s.nom']['checked'])) { From d4488cb040beebd84ff0a1e2843c7e9ebea331a1 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 26 Sep 2017 15:44:40 +0200 Subject: [PATCH 052/428] Fix for 'lessone' mode --- htdocs/fourn/js/lib_dispatch.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/htdocs/fourn/js/lib_dispatch.js b/htdocs/fourn/js/lib_dispatch.js index 50b6809a979..2b39c18cbb2 100644 --- a/htdocs/fourn/js/lib_dispatch.js +++ b/htdocs/fourn/js/lib_dispatch.js @@ -35,7 +35,7 @@ function addDispatchLine(index, type, mode) console.log("Split line type="+type+" index="+index+" mode="+mode); var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch - qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), // Qty ordered is same for all rows qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()), qtyDispatched; @@ -74,19 +74,16 @@ function addDispatchLine(index, type, mode) if (mode === 'lessone') { - $("#qty_"+(nbrTrs)+"_"+index).val(qty-1); - $("#qty_"+(nbrTrs-1)+"_"+index).val(1); - } - else - { - $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); - // Store arbitrary data for dispatch qty input field change event - $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); - $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); - $("#qty_"+(nbrTrs-1)+"_"+index).data('index', index); - // Update dispatched qty when value dispatch qty input field changed - $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); + qty = 1; // keep 1 in old line + $("#qty_"+(nbrTrs-1)+"_"+index).val(qty); } + $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + // Store arbitrary data for dispatch qty input field change event + $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); + $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); + $("#qty_"+(nbrTrs-1)+"_"+index).data('index', index); + // Update dispatched qty when value dispatch qty input field changed + $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); //set focus on lot of new line (if it exists) $("#lot_number_"+(nbrTrs)+"_"+index).focus(); } @@ -95,7 +92,9 @@ function addDispatchLine(index, type, mode) /** * onChangeDispatchLineQty * - * event handler for dispatch qty input field + * Change event handler for dispatch qty input field, + * recalculate qty dispatched when qty input has changed. + * If qty is more then qty ordered reset input qty to max qty to dispatch. * * element requires arbitrary data qty (value before change), type (type of dispatch) and index (index of product line) */ @@ -113,7 +112,7 @@ function onChangeDispatchLineQty() { qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // qty ordered qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()); // qty already dispatched - // console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); + console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) { $("#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged); From 0dfbc8d72fa3be023ed3a4fd82b2b45939463ca6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 16:03:08 +0200 Subject: [PATCH 053/428] doxygen --- htdocs/core/modules/modApi.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index fc1821fde53..34c8e62a03f 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -20,7 +20,7 @@ /** * \defgroup api Module Api * \brief Descriptor file for Api modulee - * \file htdocs/api/core/modules/modApi.class.php + * \file htdocs/core/modules/modApi.class.php * \ingroup api * \brief Description and activation file for module Api */ @@ -67,7 +67,7 @@ class modApi extends DolibarrModules // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' $this->picto='technic'; - + $this->module_parts = array(); // Data directories to create when module is enabled. From d270a8e0093aeae5b57613b58445fc1c4ebb077c Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 26 Sep 2017 16:09:40 +0200 Subject: [PATCH 054/428] FIX : same than precedent commit --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 2eedf341178..53e84b036d4 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1209,7 +1209,7 @@ class Account extends CommonObject /** * Charge indicateurs this->nb de tableau de bord - * @param int id of bank acount for filter + * @param int $filteraccountid To get info for a particular account id * @return int <0 if ko, >0 if ok */ function load_state_board($filteraccountid = 0) From d7dd6ed3344a79fa8ec10063f1d9f6f71404df1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 16:07:46 +0200 Subject: [PATCH 055/428] Fix undefined var --- htdocs/core/class/html.formmail.class.php | 7 ++++--- htdocs/core/lib/functions.lib.php | 4 +++- htdocs/expedition/card.php | 2 +- htdocs/product/inventory/card.php | 2 +- htdocs/societe/card.php | 2 +- htdocs/user/card.php | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index dab36ec250d..e1df1156239 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -329,6 +329,7 @@ class FormMail extends Form $out.= ''."\n"; } + $modelmail_array=array(); if ($this->param['models'] != 'none') { $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); @@ -336,7 +337,6 @@ class FormMail extends Form { setEventMessages($this->error, $this->errors, 'errors'); } - $modelmail_array=array(); foreach($this->lines_model as $line) { $langs->trans("members"); @@ -1076,11 +1076,11 @@ class FormMail extends Form * @return void * @see getCommonSubstitutionArray */ - function setSubstitFromObject($object, $outputlangs=null) + function setSubstitFromObject($object, $outputlangs) { global $conf, $user; - $parameters=array('mode'=>$mode); + $parameters=array(); $tmparray=getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($tmparray, $outputlangs, null, $parameters); @@ -1135,6 +1135,7 @@ class FormMail extends Form { global $conf, $langs; + $tmparray=array(); if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') { $parameters=array('mode'=>$mode); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c3c80a3c54a..ba8e9f4d085 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5280,10 +5280,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob // TODO USe this ? $msgishtml = 0; + $birthday = dol_print_date($object->birth,'day'); + if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname; $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname; - if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($langs)):$object->getFullName($langs); + if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs); $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe; $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address; $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 17777e6e228..ef4bf2a9a70 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2221,7 +2221,7 @@ else if ($id || $ref) $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Tableau des substitutions - $formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object, $outputlangs); $formmail->substit['__SHIPPINGREF__']=$object->ref; $formmail->substit['__SHIPPINGTRACKNUM__']=$object->tracking_number; $formmail->substit['__SHIPPINGTRACKNUMURL__']=$object->tracking_url; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 7ef847855e5..dae399a9907 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -542,7 +542,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; // Tableau des substitutions - $formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object, $outputlangs); $formmail->substit ['__ORDERREF__'] = $object->ref; $custcontact = ''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 3b56046e55f..236faaaa232 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2485,7 +2485,7 @@ else $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Array of substitutions - $formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object, $outputlangs); $formmail->substit['__THIRDPARTY_ID__']=$object->id; // substit in setSubstitFromObject was wrong for this one $formmail->substit['__THIRDPARTY_NAME__']=$object->name; // substit in setSubstitFromObject was wrong for this one $formmail->substit['__PERSONALIZED__']=''; // deprecated diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 273c71d8e8c..40fa4db7a37 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1760,7 +1760,7 @@ else $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Tableau des substitutions - $formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object, $outputlangs); $formmail->substit['__LASTNAME__']=$object->lastname; $formmail->substit['__FIRSTNAME__']=$object->firstname; From 7d965f58d6d1d8eb24ba46b2e8c64f27b5c109da Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 26 Sep 2017 16:21:28 +0200 Subject: [PATCH 056/428] Clean code --- htdocs/fourn/commande/dispatch.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index f4f05f96b78..67b22c6767c 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -547,6 +547,9 @@ if ($id > 0 || ! empty($ref)) { print "\n"; print '' . "\n"; + // hidden fields for js function + print ''; + print ''; print ''; $linktoprod = '' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . ''; @@ -607,9 +610,6 @@ if ($id > 0 || ! empty($ref)) { print ''; } - // hidden fields for js function - print ''; - print ''; print ''; print ''; } // Qty to dispatch print ''; + print ''; print ''; - print ''; + print ''; print ''; From 00862913d8213e401b47d6ed126d4c011e82acce Mon Sep 17 00:00:00 2001 From: dolibarr95 Date: Wed, 27 Sep 2017 11:12:38 +0200 Subject: [PATCH 066/428] Add the attribute accept to input tag I know this is not a security check but it is more convenient for the user when in a form only images or pdf are accepted for example. see : *https://www.w3.org/wiki/HTML/Elements/input/file *https://www.w3schools.com/TagS/att_input_accept.asp Hope every body needs it. tks --- htdocs/core/class/html.formfile.class.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 9d01a3c70b2..73198771b93 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -57,21 +57,22 @@ class FormFile /** * Show form to upload a new file * - * @param string $url Url - * @param string $title Title zone (Title or '' or 'none') + * @param string $url Url + * @param string $title Title zone (Title or '' or 'none') * @param int $addcancel 1=Add 'Cancel' button * @param int $sectionid If upload must be done inside a particular ECM section * @param int $perm Value of permission to allow upload - * @param int $size Length of input file area. Deprecated. - * @param Object $object Object to use (when attachment is done on an element) - * @param string $options Add an option column - * @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used. - * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' - * @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files - * @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM) + * @param int $size Length of input file area. Deprecated. + * @param Object $object Object to use (when attachment is done on an element) + * @param string $options Add an option column + * @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used. + * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' + * @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files + * @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM) + * @param string $accept Specifies the types of files accepted (This is not a security check but an user interface facility. eg '.pdf,image/*' or '.png,.jpg' or 'video/*') * @return int <0 if KO, >0 if OK */ - function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile') + function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile', $accept='') { global $conf,$langs, $hookmanager; $hookmanager->initHooks(array('formfile')); @@ -130,6 +131,7 @@ class FormFile $out .= 'global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic')?' name="userfile"':' name="userfile[]" multiple'); $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); + $out .= (!empty($accept)?' accept="'.$accept.'"':'accept=""'); $out .= '>'; $out .= ' '; $out .= ' Date: Wed, 27 Sep 2017 12:24:19 +0200 Subject: [PATCH 067/428] NEW Get the list of payments terms Adds the ability to get the list of payments terms using the REST API. --- htdocs/api/class/api_dictionary.class.php | 90 ++++++++++++++++++++--- 1 file changed, 79 insertions(+), 11 deletions(-) diff --git a/htdocs/api/class/api_dictionary.class.php b/htdocs/api/class/api_dictionary.class.php index 93f16d44377..e65bac7c670 100644 --- a/htdocs/api/class/api_dictionary.class.php +++ b/htdocs/api/class/api_dictionary.class.php @@ -1,5 +1,9 @@ +/* Copyright (C) 2016 Xebax Christy + * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin + * Copyright (C) 2017 Neil Orley + * * * 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 @@ -21,7 +25,7 @@ require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; /** - * API class for payment type (content of the paiement dictionary) + * API class for dictionaries * * @access protected * @class DolibarrApiAccess {@requires user,external} @@ -47,13 +51,14 @@ class Dictionary extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number {@min 0} * @param int $active Payment type is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')" + * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')" * - * @url GET payments + * @url GET payment/types * - * @return List of payment types - * - * @throws RestException + * @return array [List of payment types] + * + * @throws 400 RestException + * @throws 200 OK */ function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -62,14 +67,15 @@ class Dictionary extends DolibarrApi $sql = "SELECT id, code, type, libelle as label, module"; $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t"; $sql.= " WHERE t.active = ".$active; + // Add sql filters if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -94,7 +100,7 @@ class Dictionary extends DolibarrApi $list[] = $this->db->fetch_object($result); } } else { - throw new RestException(503, 'Error when retrieving list of payment types : '.$this->db->lasterror()); + throw new RestException(400, $this->db->lasterror()); } return $list; @@ -447,6 +453,68 @@ class Dictionary extends DolibarrApi } return $list; - } + } + + /** + * Get the list of payments terms. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Payment term is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')" + * + * @url GET payment/terms + * + * @return array List of payment terms + * + * @throws 400 RestException + * @throws 200 OK + */ + function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; + $sql.= " WHERE t.active = ".$active; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(400, $this->db->lasterror()); + } + + return $list; + } } From b8afabfd0bacfb332a11bd6568be6d9e3737b811 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Wed, 27 Sep 2017 12:27:47 +0200 Subject: [PATCH 068/428] Change RestException return code 503 to 400 (Bad request) when the request is incorrect : SQL error or wrong sqlfilter Add comment to getPaymentTypes function Change the "API class for" description from "payment type" to "dictionaries" Change Copyright to add all previous devs --- htdocs/api/class/api_dictionary.class.php | 62 ----------------------- 1 file changed, 62 deletions(-) diff --git a/htdocs/api/class/api_dictionary.class.php b/htdocs/api/class/api_dictionary.class.php index e65bac7c670..ac15f3dec3f 100644 --- a/htdocs/api/class/api_dictionary.class.php +++ b/htdocs/api/class/api_dictionary.class.php @@ -455,66 +455,4 @@ class Dictionary extends DolibarrApi return $list; } - /** - * Get the list of payments terms. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number {@min 0} - * @param int $active Payment term is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')" - * - * @url GET payment/terms - * - * @return array List of payment terms - * - * @throws 400 RestException - * @throws 200 OK - */ - function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') - { - $list = array(); - - $sql = "SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; - $sql.= " WHERE t.active = ".$active; - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - - $sql.= $this->db->order($sortfield, $sortorder); - - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; - - $sql .= $this->db->plimit($limit, $offset); - } - - $result = $this->db->query($sql); - - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); - } - } else { - throw new RestException(400, $this->db->lasterror()); - } - - return $list; - } - } From 8c8868d76d5d6f841ce69d3e935f4067170a29f4 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Wed, 27 Sep 2017 12:32:18 +0200 Subject: [PATCH 069/428] Remove spaces --- htdocs/api/class/api_dictionary.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/api/class/api_dictionary.class.php b/htdocs/api/class/api_dictionary.class.php index ac15f3dec3f..30e6138b1a2 100644 --- a/htdocs/api/class/api_dictionary.class.php +++ b/htdocs/api/class/api_dictionary.class.php @@ -67,7 +67,6 @@ class Dictionary extends DolibarrApi $sql = "SELECT id, code, type, libelle as label, module"; $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t"; $sql.= " WHERE t.active = ".$active; - // Add sql filters if ($sqlfilters) { @@ -454,5 +453,4 @@ class Dictionary extends DolibarrApi return $list; } - } From bb4b2c5d881625938e68f200777c59afc75655da Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Wed, 27 Sep 2017 12:34:41 +0200 Subject: [PATCH 070/428] NEW Get the list of payments terms Adds the ability to get the list of payments terms using the REST API. --- htdocs/api/class/api_dictionary.class.php | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/htdocs/api/class/api_dictionary.class.php b/htdocs/api/class/api_dictionary.class.php index 30e6138b1a2..b0d5bb00b0a 100644 --- a/htdocs/api/class/api_dictionary.class.php +++ b/htdocs/api/class/api_dictionary.class.php @@ -453,4 +453,67 @@ class Dictionary extends DolibarrApi return $list; } + + /** + * Get the list of payments terms. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Payment term is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')" + * + * @url GET payment/terms + * + * @return array List of payment terms + * + * @throws 400 RestException + * @throws 200 OK + */ + function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; + $sql.= " WHERE t.active = ".$active; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(400, $this->db->lasterror()); + } + + return $list; + } + } From 4084da28d19e0134089cd21e5106f7e6382987ef Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 27 Sep 2017 15:21:36 +0200 Subject: [PATCH 071/428] FIX : revert wrong code --- htdocs/index.php | 205 ++++++++++++++--------------------------------- 1 file changed, 61 insertions(+), 144 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 1d5f9c5350b..f8e90919c6a 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -373,218 +373,135 @@ require DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; // Number of actions to do (late) if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) { - include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $board=new ActionComm($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_board($user, 1); - $wb_res->nbtotal = (int)$board->nb['actionscomm']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + $board=new ActionComm($db); + + $dashboardlines[] = $board->load_board($user); } // Number of project opened if (! empty($conf->projet->enabled) && $user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $board=new Project($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['projects']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $board=new Project($db); + $dashboardlines[] = $board->load_board($user); } // Number of tasks to do (late) if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - $board=new Task($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['tasks']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + $board=new Task($db); + $dashboardlines[] = $board->load_board($user); } // Number of commercial proposals opened (expired) if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $board=new Propal($db); - $wb_res = $board->load_board($user,"opened"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $nbtotal = (int)$board->nb['proposals']; - $wb_res->nbtotal = $nbtotal; - } - $dashboardlines[] = $wb_res; - // Number of commercial proposals CLOSED signed (billed) - $wb_res = $board->load_board($user,"signed"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $board=new Propal($db); + $dashboardlines[] = $board->load_board($user,"opened"); + // Number of commercial proposals CLOSED signed (billed) + $dashboardlines[] = $board->load_board($user,"signed"); } // Number of commercial proposals opened (expired) if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { - include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; - $board=new SupplierProposal($db); - $wb_res = $board->load_board($user,"opened"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $nbtotal = (int)$board->nb['askprice']; - $wb_res->nbtotal = $nbtotal; - } - $dashboardlines[] = $wb_res; - // Number of commercial proposals CLOSED signed (billed) - $wb_res = $board->load_board($user,"signed"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; + $board=new SupplierProposal($db); + $dashboardlines[] = $board->load_board($user,"opened"); + // Number of commercial proposals CLOSED signed (billed) + $dashboardlines[] = $board->load_board($user,"signed"); } // Number of customer orders a deal if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $board=new Commande($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['orders']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $board=new Commande($db); + $dashboardlines[] = $board->load_board($user); } // Number of suppliers orders a deal if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $board=new CommandeFournisseur($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['supplier_orders']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $board=new CommandeFournisseur($db); + $dashboardlines[] = $board->load_board($user); } // Number of services enabled (delayed) if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $board=new Contrat($db); - $wb_res = $board->load_board($user,"inactives"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $nbtotal = (int)$board->nb['Contracts']; - $wb_res->nbtotal = $nbtotal; - } - $dashboardlines[] = $wb_res; - // Number of active services (expired) - $wb_res = $board->load_board($user,"expired"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + $board=new Contrat($db); + $dashboardlines[] = $board->load_board($user,"inactives"); + // Number of active services (expired) + $dashboardlines[] = $board->load_board($user,"expired"); } // Number of invoices customers (has paid) if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $board=new Facture($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['invoices']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $board=new Facture($db); + $dashboardlines[] = $board->load_board($user); } // Number of supplier invoices (has paid) if (! empty($conf->supplier_invoice->enabled) && ! empty($user->rights->fournisseur->facture->lire)) { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $board=new FactureFournisseur($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['supplier_invoices']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $board=new FactureFournisseur($db); + $dashboardlines[] = $board->load_board($user); } // Number of transactions to conciliate if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id) { - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $board=new Account($db); - $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate - if ($nb > 0) - { - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['banklines']; - } - $dashboardlines[] = $wb_res; - } + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $board=new Account($db); + $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate + if ($nb > 0) + { + $dashboardlines[] = $board->load_board($user); + } } // Number of cheque to send if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) { - include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; - $board=new RemiseCheque($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['cheques']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; + $board=new RemiseCheque($db); + $dashboardlines[] = $board->load_board($user); } // Number of foundation members if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $user->societe_id) { - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $board=new Adherent($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['members']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $board=new Adherent($db); + $dashboardlines[] = $board->load_board($user); } // Number of expense reports to approve if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) { - include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $board=new ExpenseReport($db); - $wb_res = $board->load_board($user,'toapprove'); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['expensereports']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $board=new ExpenseReport($db); + $dashboardlines[] = $board->load_board($user,'toapprove'); } // Number of expense reports to pay if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) { - include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $board=new ExpenseReport($db); - $wb_res = $board->load_board($user,'topay'); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['expensereports']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $board=new ExpenseReport($db); + $dashboardlines[] = $board->load_board($user,'topay'); } // Calculate total nb of late -$totallate=$totalglobal=0; +$totallate=$totaltodo=0; $var=true; //Remove any invalid response @@ -599,12 +516,12 @@ foreach($dashboardlines as $tmp) foreach($valid_dashboardlines as $board) { if ($board->nbtodolate > 0) { - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totalglobal += $board->nbtotal; + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totaltodo += $board->nbtodo; $totallate += $board->nbtodolate; } } -//var_dump($totallate, $totalglobal); -if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = $totallate / $totalglobal * 100; +//var_dump($totallate, $totaltodo); +if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = round($totallate / $totaltodo * 100, 2); //var_dump($totallate); $boxwork=''; $boxwork.='
'; @@ -618,7 +535,7 @@ if ($showweather) $boxwork.='
'; $boxwork.='\n"; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 881616ebc45..576c477116c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -414,7 +414,7 @@ class Account extends CommonObject { $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE id=".$oper; - $sql.= " AND entity = " . getEntity('c_paiement', 2) . ")"; + $sql.= " AND entity = " . getEntity('c_paiement') . ")"; $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index ef0d45751a9..db668b47eef 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -96,7 +96,7 @@ $sql = "SELECT v.rowid, v.amount, v.label, v.datep as datep, v.datev as datev, v $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement', 2); +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement'); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql.= " WHERE v.entity = ".$conf->entity; diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index c7d58a7070c..a504a730976 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -139,7 +139,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity = " . getEntity('c_paiement', 2); + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity = " . getEntity('c_paiement'); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql.= " WHERE cs.fk_type = c.id"; @@ -260,7 +260,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id AND pct.entity = " . getEntity('c_paiement', 2); + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id AND pct.entity = " . getEntity('c_paiement'); $sql.= " WHERE pv.entity = ".$conf->entity; if ($year > 0) { @@ -474,7 +474,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id AND pct.entity = " . getEntity('c_paiement', 2); + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id AND pct.entity = " . getEntity('c_paiement'); $sql.= " , ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE s.entity IN (".getEntity('user').")"; $sql.= " AND u.rowid = s.fk_user"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7fb0b86a39a..be4de99efb5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -721,7 +721,7 @@ if (empty($reshook)) $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; $sql.= ' WHERE pf.fk_facture = '.$object->id; $sql.= ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; - $sql.= ' AND c.entity = ' . getEntity('c_paiement', 2); + $sql.= ' AND c.entity = ' . getEntity('c_paiement'); $sql.= ' ORDER BY p.datep, p.tms'; $resql = $db->query($sql); @@ -3802,7 +3802,7 @@ else if ($id > 0 || ! empty($ref)) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; - $sql .= ' AND c.entity = ' . getEntity('c_paiement', 2); + $sql .= ' AND c.entity = ' . getEntity('c_paiement'); $sql .= ' ORDER BY p.datep, p.tms'; $result = $db->query($sql); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index db7d4f09752..5ff3e0d065f 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -262,8 +262,8 @@ class FactureRec extends CommonInvoice $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; //$sql.= ', el.fk_source'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity = ' . getEntity('c_payment_term', 2); - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity = ' . getEntity('c_payment_term'); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement'); //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; if ($rowid) $sql.= ' WHERE f.rowid='.$rowid; elseif ($ref) $sql.= " WHERE f.titre='".$this->db->escape($ref)."'"; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d4a68b29ef6..485256d4529 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1197,8 +1197,8 @@ class Facture extends CommonInvoice $sql.= ', f.fk_incoterms, f.location_incoterms'; $sql.= ", i.libelle as libelle_incoterms"; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity = ' . getEntity('c_payment_term', 2); - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity = ' . getEntity('c_payment_term'); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement'); $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; $sql.= ' WHERE f.entity = '.$conf->entity; if ($rowid) $sql.= " AND f.rowid=".$rowid; @@ -3167,7 +3167,7 @@ class Facture extends CommonInvoice //$sql.= ' WHERE pf.'.$field.' = 1'; $sql.= ' AND pf.'.$field2.' = p.rowid'; $sql.= ' AND p.fk_paiement = t.id'; - $sql.= ' AND t.entity = ' . getEntity('c_paiement', 2); + $sql.= ' AND t.entity = ' . getEntity('c_paiement'); if ($filtertype) $sql.=" AND t.code='PRE'"; dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); @@ -3650,7 +3650,7 @@ class Facture extends CommonInvoice if (! $error) { // Force payment mode of invoice to withdraw - $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', getEntity('c_paiement', 2)); + $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', getEntity('c_paiement')); if ($payment_mode_id > 0) { $result=$this->setPaymentMethods($payment_mode_id); diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 36ff6d73791..bc13b0d5876 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -102,7 +102,7 @@ class PaymentTerm // extends CommonObject $sql.= "decalage"; $sql.= ") VALUES ("; $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").","; - $sql.= " ".(! isset($this->entity)?getEntity('c_payment_term', 2):"'".$this->db->escape($this->entity)."'").","; + $sql.= " ".(! isset($this->entity)?getEntity('c_payment_term'):"'".$this->db->escape($this->entity)."'").","; $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; $sql.= " ".(! isset($this->sortorder)?'NULL':"'".$this->db->escape($this->sortorder)."'").","; $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").","; @@ -181,7 +181,7 @@ class PaymentTerm // extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; $sql.= " WHERE t.rowid = ".$id; - $sql.= " AND t.entity = " . getEntity('c_payment_term', 2); + $sql.= " AND t.entity = " . getEntity('c_payment_term'); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); @@ -231,7 +231,7 @@ class PaymentTerm // extends CommonObject $sql.= " t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; $sql.= " WHERE t.code = 'RECEP'"; - $sql.= " AND t.entity = " . getEntity('c_payment_term', 2); + $sql.= " AND t.entity = " . getEntity('c_payment_term'); dol_syslog(get_class($this)."::getDefaultId", LOG_DEBUG); $resql=$this->db->query($sql); @@ -293,7 +293,7 @@ class PaymentTerm // extends CommonObject $sql.= " nbjour=".(isset($this->nbjour)?$this->nbjour:"null").","; $sql.= " decalage=".(isset($this->decalage)?$this->decalage:"null").""; $sql.= " WHERE rowid = " . $this->id; - $sql.= " AND entity = " . getEntity('c_payment_term', 2); + $sql.= " AND entity = " . getEntity('c_payment_term'); $this->db->begin(); @@ -350,7 +350,7 @@ class PaymentTerm // extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_payment_term"; $sql.= " WHERE rowid = " . $this->id; - $sql.= " AND t.entity = " . getEntity('c_payment_term', 2); + $sql.= " AND t.entity = " . getEntity('c_payment_term'); $this->db->begin(); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index e9d9dd6984f..b2ba863d096 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -251,7 +251,7 @@ if (empty($reshook)) $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement','code','id',getEntity('c_paiement', 2)); + $paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement','code','id',getEntity('c_paiement')); $paiement->num_paiement = GETPOST('num_paiement'); $paiement->note = GETPOST('comment'); @@ -832,7 +832,7 @@ if (! GETPOST('action','aZ09')) $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; $sql.= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; $sql.= ' AND f.entity = ' . $conf->entity; - $sql.= ' AND c.entity = ' . getEntity('c_paiement', 2); + $sql.= ' AND c.entity = ' . getEntity('c_paiement'); if ($socid) { $sql.= ' AND f.fk_soc = '.$socid; diff --git a/htdocs/compta/paiement/avalider.php b/htdocs/compta/paiement/avalider.php index b8ea972dc52..4c7fafe4429 100644 --- a/htdocs/compta/paiement/avalider.php +++ b/htdocs/compta/paiement/avalider.php @@ -72,7 +72,7 @@ if ($socid) } $sql.= " WHERE p.fk_paiement = c.id"; $sql.= " AND p.entity = " . $conf->entity; -$sql.= " AND c.entity = " . getEntity('c_paiement', 2); +$sql.= " AND c.entity = " . getEntity('c_paiement'); if ($socid) { $sql.= " AND f.fk_soc = ".$socid; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 46e50fba56e..df6b8ead3b8 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -753,7 +753,7 @@ class RemiseCheque extends CommonObject $rejectedPayment = new Paiement($db); $rejectedPayment->amounts = array(); $rejectedPayment->datepaye = $rejection_date; - $rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement','code','id',getEntity('c_paiement', 2)); + $rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement','code','id',getEntity('c_paiement')); $rejectedPayment->num_paiement = $payment->numero; while($obj = $db->fetch_object($resql)) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index f2b8cb26cdf..23dfafbeb8b 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -93,7 +93,7 @@ class Paiement extends CommonObject $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid '; $sql.= ' WHERE p.fk_paiement = c.id'; - $sql.= ' AND c.entity = ' . getEntity('c_paiement', 2); + $sql.= ' AND c.entity = ' . getEntity('c_paiement'); if ($id > 0) $sql.= ' AND p.rowid = '.$id; else if ($ref) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index f7938811057..b7b0b0489e2 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -120,7 +120,7 @@ if (GETPOST("orphelins")) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; $sql.= " WHERE p.fk_paiement = c.id"; $sql.= " AND p.entity = " . $conf->entity; - $sql.= " AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " AND c.entity = " . getEntity('c_paiement'); $sql.= " AND pf.fk_facture IS NULL"; // Add where from hooks $parameters=array(); @@ -152,7 +152,7 @@ else } $sql.= " WHERE p.fk_paiement = c.id"; $sql.= " AND p.entity = " . $conf->entity; - $sql.= " AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " AND c.entity = " . getEntity('c_paiement'); if (! $user->rights->societe->client->voir && ! $socid) { $sql.= " AND sc.fk_user = " .$user->id; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 14d4ee994f4..eea830dfbc5 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -822,7 +822,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement'); $sql.= " WHERE p.entity = ".getEntity('expensereport'); $sql.= " AND p.fk_statut>=5"; @@ -906,7 +906,7 @@ else $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement'); $sql.= " WHERE p.entity = ".getEntity('donation'); $sql.= " AND fk_statut >= 2"; } diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 983b3faa5e0..bd1d8effcc7 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -698,7 +698,7 @@ if (! empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES' $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement'); $sql.= " WHERE p.entity = ".getEntity('expensereport'); $sql.= " AND p.fk_statut>=5"; @@ -761,7 +761,7 @@ if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement'); $sql.= " WHERE p.entity = ".getEntity('donation'); $sql.= " AND fk_statut >= 2"; if (! empty($date_start) && ! empty($date_end)) diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 9a5c352b739..6928d3e38f6 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -105,7 +105,7 @@ $sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.da $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement', 2); +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement'); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,"; $sql.= " ".MAIN_DB_PREFIX."user as u"; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 7d32da6f937..a8f795115c4 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -581,7 +581,7 @@ if ($id > 0) $sql.= " AND p.fk_charge = cs.rowid"; $sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND p.fk_typepaiement = c.id"; - $sql.= " AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " AND c.entity = " . getEntity('c_paiement'); $sql.= " ORDER BY dp DESC"; //print $sql; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 15774c04ed3..ab60f007e55 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -83,7 +83,7 @@ class ChargeSociales extends CommonObject $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement'); if ($ref) $sql.= " WHERE cs.rowid = ".$ref; else $sql.= " WHERE cs.rowid = ".$id; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 8a5c8f0eeef..6c7cda1f07e 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -205,7 +205,7 @@ class PaymentSocialContribution extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."paiementcharge as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepaiement = pt.id"; - $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); + $sql.= " AND pt.entity = " . getEntity('c_paiement'); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 0f197b9495b..0bdff23007a 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -133,7 +133,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs,"; $sql.= " ".MAIN_DB_PREFIX."paiementcharge as pc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity = " . getEntity('c_paiement', 2); + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity = " . getEntity('c_paiement'); $sql.= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid"; $sql.= " AND cs.entity = ".$conf->entity; if ($year > 0) diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 23b63afeb22..c22fb4ed30a 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -100,7 +100,7 @@ $bankstatic = new Account($db); $sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,"; $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement', 2); +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement'); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql.= " WHERE t.entity = ".$conf->entity; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index a9802db1205..dce39a950aa 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -450,7 +450,7 @@ abstract class CommonInvoice extends CommonObject $sqltemp = 'SELECT c.type_cdr,c.nbjour,c.decalage'; $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; - $sqltemp.= " WHERE c.entity = " . getEntity('c_payment_term', 2); + $sqltemp.= " WHERE c.entity = " . getEntity('c_payment_term'); if (is_numeric($cond_reglement)) $sqltemp.= " AND c.rowid=".$cond_reglement; else $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 12f88eef153..1df33c7bccf 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2737,7 +2737,7 @@ class Form $sql = "SELECT rowid, code, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_payment_term'; - $sql.= " WHERE entity = " . getEntity('c_payment_term', 2); + $sql.= " WHERE entity = " . getEntity('c_payment_term'); $sql.= " AND active > 0"; $sql.= " ORDER BY sortorder"; @@ -2952,7 +2952,7 @@ class Form $sql = "SELECT id, code, libelle as label, type, active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement"; - $sql.= " WHERE entity = " . getEntity('c_paiement', 2); + $sql.= " WHERE entity = " . getEntity('c_paiement'); //if ($active >= 0) $sql.= " AND active = ".$active; $resql = $this->db->query($sql); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 008049d3d13..66bde287ad1 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -559,7 +559,7 @@ class Translate } elseif (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i',$key,$reg)) { - $newstr=$this->getLabelFromKey($db,$reg[1],'c_paiement','code','libelle','',getEntity('c_paiement', 2)); + $newstr=$this->getLabelFromKey($db,$reg[1],'c_paiement','code','libelle','',getEntity('c_paiement')); } elseif (preg_match('/^OppStatusShort([0-9A-Z]+)$/i',$key,$reg)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 566416016aa..7fe650f7c2c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -111,8 +111,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', * 'email_template', 'event', * @param int $shared 0=Return id of current entity only, - * 1=Return id of current entity + shared entities (default), - * 2=Return id of current entity OR master entity 1 value (eg. dictionnary share) + * 1=Return id of current entity + shared entities (default) * @param int $forceentity Entity id * @return mixed Entity id(s) to use */ diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 0552e2fb4a6..3617a130c68 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -820,7 +820,7 @@ class pdf_crabe extends ModelePDFFactures $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id AND cp.entity = " . getEntity('c_paiement', 2); + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id AND cp.entity = " . getEntity('c_paiement'); $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1"; $sql.= " ORDER BY p.datep"; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 8655b8832ad..6e3c1660fb2 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -260,7 +260,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement AND pt.entity = ' . getEntity('c_paiement', 2); + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement AND pt.entity = ' . getEntity('c_paiement'); $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON b.rowid = p.fk_bank'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index 729023456f8..6b84e549d10 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -165,7 +165,7 @@ class modSalaries extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id AND cp.entity = ' . getEntity('c_paiement', 2); + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id AND cp.entity = ' . getEntity('c_paiement'); $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user').')'; } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 229db9763e5..c01bdca6985 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -284,8 +284,8 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid AND payterm.entity = ' . getEntity('c_payment_term', 2); - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id AND paymode.entity = ' . getEntity('c_paiement', 2); + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid AND payterm.entity = ' . getEntity('c_payment_term'); + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id AND paymode.entity = ' . getEntity('c_paiement'); $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) { $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; 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 a11a517904a..53d47ebc608 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -933,7 +933,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id AND cp.entity = " . getEntity('c_paiement', 2); + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id AND cp.entity = " . getEntity('c_paiement'); $sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id; $sql.= " ORDER BY p.datep"; $resql=$this->db->query($sql); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 14ce9a86403..6998b7bdb52 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -638,7 +638,7 @@ if (! empty($id) && $action != 'edit') $sql.= " AND p.fk_donation = d.rowid"; $sql.= " AND d.entity = ".$conf->entity; $sql.= " AND p.fk_typepayment = c.id"; - $sql.= " AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " AND c.entity = " . getEntity('c_paiement'); $sql.= " ORDER BY dp"; //print $sql; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 2c92e52be7c..0a683fea355 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -611,7 +611,7 @@ class Don extends CommonObject $sql.= " c.code as country_code, c.label as country"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_projet"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment AND cp.entity = " . getEntity('c_paiement', 2); + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment AND cp.entity = " . getEntity('c_paiement'); $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid"; if (! empty($id)) { diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 5752878fecf..22fbcd6dab4 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -175,7 +175,7 @@ class PaymentDonation extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_donation as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; - $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); + $sql.= " AND pt.entity = " . getEntity('c_paiement'); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index e337c1e1c72..8ba9f40c04d 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1865,7 +1865,7 @@ else $sql.= " AND p.fk_expensereport = e.rowid"; $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; $sql.= " AND p.fk_typepayment = c.id"; - $sql.= " AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " AND c.entity = " . getEntity('c_paiement'); $sql.= " ORDER BY dp"; $resql = $db->query($sql); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index c135d92a12c..3f2db4f984c 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -448,7 +448,7 @@ class ExpenseReport extends CommonObject $sql.= " d.fk_statut as status, d.fk_c_paiement,"; $sql.= " dp.libelle as libelle_paiement, dp.code as code_paiement"; // INNER JOIN paiement $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id AND dp.entity = " . getEntity('c_paiement', 2); + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id AND dp.entity = " . getEntity('c_paiement'); if ($ref) $sql.= " WHERE d.ref = '".$this->db->escape($ref)."'"; else $sql.= " WHERE d.rowid = ".$id; //$sql.= $restrict; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 3935021041a..b836f410245 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -168,7 +168,7 @@ class PaymentExpenseReport extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_expensereport as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; - $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); + $sql.= " AND pt.entity = " . getEntity('c_paiement'); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9335e4dcbb4..cf52c06ae55 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -190,8 +190,8 @@ class CommandeFournisseur extends CommonOrder $sql.= ', c.fk_incoterms, c.location_incoterms'; $sql.= ', i.libelle as libelle_incoterms'; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid AND cr.entity = " . getEntity('c_payment_term', 2) . ")"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (c.fk_mode_reglement = p.id AND p.entity = " . getEntity('c_paiement', 2) . ")"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid AND cr.entity = " . getEntity('c_payment_term') . ")"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (c.fk_mode_reglement = p.id AND p.entity = " . getEntity('c_paiement') . ")"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; $sql.= " WHERE c.entity = ".$conf->entity; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 5410d7aba65..76b9a70c7dc 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -517,8 +517,8 @@ class FactureFournisseur extends CommonInvoice $sql.= ' t.fk_multicurrency, t.multicurrency_code, t.multicurrency_tx, t.multicurrency_total_ht, t.multicurrency_total_tva, t.multicurrency_total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (t.fk_cond_reglement = cr.rowid AND cr.entity = " . getEntity('c_payment_term', 2) . ")"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (t.fk_mode_reglement = p.id AND p.entity = " . getEntity('c_paiement', 2) . ")"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (t.fk_cond_reglement = cr.rowid AND cr.entity = " . getEntity('c_payment_term') . ")"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (t.fk_mode_reglement = p.id AND p.entity = " . getEntity('c_paiement') . ")"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid'; if ($id) $sql.= " WHERE t.rowid=".$id; if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."'"; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 6ae730732d9..f2d5460a864 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -82,7 +82,7 @@ class PaiementFourn extends Paiement $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid '; $sql.= ' WHERE p.fk_paiement = c.id'; - $sql.= ' AND c.entity = ' . getEntity('c_paiement', 2); + $sql.= ' AND c.entity = ' . getEntity('c_paiement'); if ($id > 0) $sql.= ' AND p.rowid = '.$id; else if ($ref) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index bd883091059..28b57ea5931 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2358,7 +2358,7 @@ else $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity = ' . getEntity('c_paiement', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity = ' . getEntity('c_paiement'); $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; $sql.= ' ORDER BY p.datep, p.tms'; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 21e10e6a8d5..5000494bcd3 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -745,7 +745,7 @@ if (empty($action)) $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id AND c.entity = ' . getEntity('c_paiement', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id AND c.entity = ' . getEntity('c_paiement'); $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 57eb4eb62c6..2edf3c34547 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -642,7 +642,7 @@ if ($id > 0) $sql.= " AND p.fk_loan = l.rowid"; $sql.= " AND l.entity = ".$conf->entity; $sql.= " AND p.fk_typepayment = c.id"; - $sql.= " AND c.entity = " . getEntity('c_paiement', 2); + $sql.= " AND c.entity = " . getEntity('c_paiement'); $sql.= " ORDER BY dp DESC"; //print $sql; diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index 90729dd3468..c5794b52daf 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -179,7 +179,7 @@ class LoanSchedule extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX.$this->table_element." as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; - $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); + $sql.= " AND pt.entity = " . getEntity('c_paiement'); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index ec6672d898f..836acd082e1 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -178,7 +178,7 @@ class PaymentLoan extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_loan as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; - $sql.= " AND pt.entity = " . getEntity('c_paiement', 2); + $sql.= " AND pt.entity = " . getEntity('c_paiement'); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index b6166124af0..1234e3c4468 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1116,8 +1116,8 @@ class SupplierProposal extends CommonObject $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity = ' . getEntity('c_paiement', 2); - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity = ' . getEntity('c_paiement'); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term'); $sql.= " WHERE p.fk_statut = c.id"; $sql.= " AND p.entity = ".$conf->entity; if ($ref) $sql.= " AND p.ref='".$ref."'"; From f1f4a2fb445ea01be6adf5828c3a25f36411283d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 17:40:14 +0200 Subject: [PATCH 074/428] Add email template to send SEPA mandate --- htdocs/core/lib/functions.lib.php | 7 ++++++- htdocs/install/mysql/data/llx_c_email_templates.sql | 4 +++- htdocs/langs/en_US/banks.lang | 4 +++- htdocs/langs/en_US/main.lang | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ba8e9f4d085..a826b16d266 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5234,7 +5234,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob '__MYCOMPANY_PROFID5__' => $mysoc->idprof5, '__MYCOMPANY_PROFID6__' => $mysoc->idprof6, '__MYCOMPANY_CAPITAL__' => $mysoc->capital, - '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id + '__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1), + '__MYCOMPANY_ADDRESS__' => $mysoc->address, + '__MYCOMPANY_ZIP__' => $mysoc->zip, + '__MYCOMPANY_TOWN__' => $mysoc->town, + '__MYCOMPANY_COUNTRY__' => $mysoc->country, + '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id )); } if (($onlykey || is_object($object)) && (empty($exclude) || ! in_array('object', $exclude))) diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index b3bb3292ba6..240be5fcbe6 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -20,4 +20,6 @@ -- de l'install et tous les sigles '--' sont supprimés. -- -INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null); +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(Hello)__

__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null); + +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'thirdparty',null,0,null,null,'(YourSEPAMandate)',1,1,'__(YourSEPAMandate)__','__(Hello)__

__(PleaseFindYourSEPAMandate)__
\n__MYCOMPANY_NAME__
\n__MYCOMPANY_FULLADDRESS__',null); diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index caed4498f3b..3ca1ac9ce5c 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -157,4 +157,6 @@ NewVariousPayment=New miscellaneous payments VariousPayment=Miscellaneous payments VariousPayments=Miscellaneous payments ShowVariousPayment=Show miscellaneous payments -AddVariousPayment=Add miscellaneous payments \ No newline at end of file +AddVariousPayment=Add miscellaneous payments +YourSEPAMandate=Your SEPA mandate +PleaseFindYourSEPAMandate=This is your SEPA mandate. Thanks to return it signed (scan of the signed document) or sent by mail to diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 93616b6151c..ba6b43fb9fc 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -814,6 +814,9 @@ Websites=Web sites Events=Events EMailTemplates=Emails templates FileNotShared=File not shared to exernal public +Hello=Hello +Goodbye=Goodbye +Sincerely=Sincerely # Week day Monday=Monday Tuesday=Tuesday From a38668033d2ca3e5c5bba3557b7581428c584c18 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Sep 2017 17:46:17 +0200 Subject: [PATCH 075/428] Fix: missing modification --- htdocs/admin/dict.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 32f895dc1ec..673ce2f2d24 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -182,8 +182,8 @@ $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c"; $tabsql[10]= "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[11]= "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; -$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = " . getEntity($tabname[12], 2); -$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = " . getEntity($tabname[13], 2); +$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = " . getEntity($tabname[12]); +$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = " . getEntity($tabname[13]); $tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; $tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format"; $tabsql[16]= "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel"; @@ -734,7 +734,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); } else if ($value == 'entity') { - $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id], 2); + $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); } if ($i) $sql.=","; if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position' @@ -786,7 +786,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); } else if ($field == 'entity') { - $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id], 2); + $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); } if ($i) $sql.=","; $sql.= $field."="; @@ -799,7 +799,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - $sql.= " AND entity = '".getEntity($tabname[$id], 2)."'"; + $sql.= " AND entity = '".getEntity($tabname[$id])."'"; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; @@ -1031,7 +1031,7 @@ if ($id) foreach ($fieldlist as $field => $value) { if ($fieldlist[$field] == 'entity') { - $withentity = getEntity($tabname[$id], 2); + $withentity = getEntity($tabname[$id]); continue; } From 8242469e40af90d2c873d4acc91665bb94621ffd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 18:16:28 +0200 Subject: [PATCH 076/428] FIX The unique index on email templates can work now. --- htdocs/admin/mails_templates.php | 6 +++--- htdocs/core/lib/functions.lib.php | 12 +++++++++--- htdocs/install/mysql/data/llx_c_email_templates.sql | 5 +++-- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 6 +++++- .../install/mysql/tables/llx_c_email_templates.sql | 3 ++- htdocs/langs/en_US/banks.lang | 2 +- htdocs/langs/en_US/main.lang | 4 +--- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 2f440f9f873..755440a47fd 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -177,7 +177,7 @@ if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$la if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember'); if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); -$elementList['all']=$langs->trans('VisibleEverywhere'); +$elementList['all'] =$langs->trans('VisibleEverywhere'); $elementList['none']=$langs->trans('VisibleNowhere'); @@ -295,7 +295,7 @@ if (empty($reshook)) if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]=''; if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0'; if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1'; - if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = '' + if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } @@ -485,7 +485,7 @@ if (! $user->admin) } if (empty($conf->global->MAIN_MULTILANGS)) { - $sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL)"; + $sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL OR lang = '')"; } if ($search_label) $sql.=natural_search('label', $search_label); if ($search_type_template != '' && $search_type_template != '-1') $sql.=natural_search('type_template', $search_type_template); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a826b16d266..c252df5070e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5234,7 +5234,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob '__MYCOMPANY_PROFID5__' => $mysoc->idprof5, '__MYCOMPANY_PROFID6__' => $mysoc->idprof6, '__MYCOMPANY_CAPITAL__' => $mysoc->capital, - '__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1), + '__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1, ', '), '__MYCOMPANY_ADDRESS__' => $mysoc->address, '__MYCOMPANY_ZIP__' => $mysoc->zip, '__MYCOMPANY_TOWN__' => $mysoc->town, @@ -5395,8 +5395,14 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob '__USER_FIRSTNAME__' => (string) $user->firstname, '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs), '__USER_SUPERVISOR_ID__' => (string) $user->fk_user, - '__SIGNATURE__' => (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '') - )); + '__USER_SIGNATURE__' => (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '') + ) + ); + // For backward compatibility + if ($onlykey != 2) + { + $substitutionarray['__SIGNATURE__'] = (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : ''); + } } if (! empty($conf->multicompany->enabled)) { diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index 240be5fcbe6..bfa183781c7 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -20,6 +20,7 @@ -- de l'install et tous les sigles '--' sont supprimés. -- -INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(Hello)__

__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null); +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'adherent','member','',0,null,null,'(SendAnEMailToMember)',1,1,1,'__(CardContent)__','__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null); +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'banque','thirdparty','',0,null,null,'(YourSEPAMandate)',1,1,0,'__(YourSEPAMandate)__','__(Hello)__,

\n\n__(FindYourSEPAMandate)__ :
\n__MYCOMPANY_NAME__
\n__MYCOMPANY_FULLADDRESS__

\n__(Sincerely)__
\n__USER_SIGNATURE__',null); + -INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'thirdparty',null,0,null,null,'(YourSEPAMandate)',1,1,'__(YourSEPAMandate)__','__(Hello)__

__(PleaseFindYourSEPAMandate)__
\n__MYCOMPANY_NAME__
\n__MYCOMPANY_FULLADDRESS__',null); diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 0d2a6a7baed..b2df01afe51 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -70,8 +70,12 @@ ALTER TABLE llx_contrat MODIFY COLUMN ref_ext varchar(50); UPDATE llx_c_email_templates SET position = 0 WHERE position IS NULL; +UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL; -INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null); +ALTER TABLE llx_c_email_templates ADD COLUMN enabled varchar(255) DEFAULT '1'; + +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'adherent','member','',0,null,null,'(SendAnEMailToMember)',1,1,1,'__(CardContent)__','__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null); +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'banque','thirdparty','',0,null,null,'(YourSEPAMandate)',1,1,0,'__(YourSEPAMandate)__','__(Hello)__,

\n\n__(FindYourSEPAMandate)__ :
\n__MYCOMPANY_NAME__
\n__MYCOMPANY_FULLADDRESS__

\n__(Sincerely)__
\n__USER_SIGNATURE__',null); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VENTES', 'Income of products/services', 'Exemple: 7xxxxx', 0, 0, '', '10', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'DEPENSES', 'Expenses of products/services', 'Exemple: 6xxxxx', 0, 0, '', '20', 1, 1); diff --git a/htdocs/install/mysql/tables/llx_c_email_templates.sql b/htdocs/install/mysql/tables/llx_c_email_templates.sql index 9d82d37768a..69cbc186ebd 100644 --- a/htdocs/install/mysql/tables/llx_c_email_templates.sql +++ b/htdocs/install/mysql/tables/llx_c_email_templates.sql @@ -23,13 +23,14 @@ create table llx_c_email_templates entity integer DEFAULT 1 NOT NULL, -- multi company id module varchar(32), -- Nom du module en rapport avec le modele type_template varchar(32), -- template for which type of email (send invoice by email, send order, ...) - lang varchar(6), + lang varchar(6) DEFAULT '', -- We use a default to '' so the unique index that include this field will work private smallint DEFAULT 0 NOT NULL, -- Template public or private fk_user integer, -- Id user owner if template is private, or null datec datetime, tms timestamp, label varchar(255), -- Label of predefined email position smallint, -- Position + enabled varchar(255) DEFAULT '1', -- Condition to have this module visible active tinyint DEFAULT 1 NOT NULL, topic text, -- Predefined topic content text, -- Predefined text diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 3ca1ac9ce5c..d45c0c15c1c 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -159,4 +159,4 @@ VariousPayments=Miscellaneous payments ShowVariousPayment=Show miscellaneous payments AddVariousPayment=Add miscellaneous payments YourSEPAMandate=Your SEPA mandate -PleaseFindYourSEPAMandate=This is your SEPA mandate. Thanks to return it signed (scan of the signed document) or sent by mail to +FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make direct debit order to your bank. Thanks to return it signed (scan of the signed document) or sent it by mail to diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index ba6b43fb9fc..a21b2a9d355 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -770,6 +770,7 @@ Genderwoman=Woman ViewList=List view Mandatory=Mandatory Hello=Hello +GoodBye=GoodBye Sincerely=Sincerely DeleteLine=Delete line ConfirmDeleteLine=Are you sure you want to delete this line? @@ -814,9 +815,6 @@ Websites=Web sites Events=Events EMailTemplates=Emails templates FileNotShared=File not shared to exernal public -Hello=Hello -Goodbye=Goodbye -Sincerely=Sincerely # Week day Monday=Monday Tuesday=Tuesday From 7a0b8c39643c37d9b3582192ef5a125d8b1f63d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 18:23:49 +0200 Subject: [PATCH 077/428] Translation --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a21b2a9d355..bfcbb5a2010 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -262,6 +262,7 @@ DateBuild=Report build date DatePayment=Date of payment DateApprove=Approving date DateApprove2=Approving date (second approval) +RegistrationDate=Registration date UserCreation=Creation user UserModification=Modification user UserCreationShort=Creat. user From fdc1aa2a03e26cb45da0b356297934c6a957b59e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 19:56:03 +0200 Subject: [PATCH 078/428] NEW Move contacts of a thirdparty on tab Contacts/Addresses --- htdocs/contact/card.php | 4 +- htdocs/core/class/html.formmail.class.php | 8 +- htdocs/core/lib/company.lib.php | 13 +- htdocs/core/lib/order.lib.php | 20 +- htdocs/core/tpl/card_presend.tpl.php | 42 +++-- htdocs/langs/en_US/other.lang | 4 +- htdocs/societe/card.php | 176 ++++++++--------- htdocs/societe/class/societe.class.php | 5 + htdocs/societe/contact.php | 218 ++++++++++++++++++++++ 9 files changed, 353 insertions(+), 137 deletions(-) create mode 100644 htdocs/societe/contact.php diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 2d6f728b502..43b9b7e4760 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -541,7 +541,7 @@ else { print '
'; print ''; print ''; print ''; @@ -1063,7 +1063,7 @@ else $objsoc->fetch($object->socid); // Thirdparty $morehtmlref.=$langs->trans('ThirdParty') . ' : '; - if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1); + if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1, 'contact'); else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany"); } $morehtmlref.=''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index e1df1156239..0621e1d21f4 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -301,7 +301,7 @@ class FormMail extends Form { $model_id=$this->param["models_id"]; } - $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); + $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, ($model_id ? $model_id : -1)); // we set -1 if model_id empty } //var_dump($this->param["models"]); //var_dump($model_id); @@ -914,7 +914,7 @@ class FormMail extends Form * @param string $type_template Get message for type=$type_template, type='all' also included. * @param string $user Use template public or limited to this user * @param Translate $outputlangs Output lang object - * @param int $id Id template to find + * @param int $id Id of template to find, or -1 for first found with position = 0, or 0 for all * @param int $active 1=Only active template, 0=Only disabled, -1=All * @return array array('topic'=>,'content'=>,..) */ @@ -929,8 +929,10 @@ class FormMail extends Form $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; - if (!empty($id)) $sql.= " AND rowid=".$id; + if ($id > 0) $sql.= " AND rowid=".$id; + if ($id == -1) $sql.= " AND position=0"; $sql.= $db->order("position,lang,label","ASC"); + if ($id == -1) $sql.= $db->plimit(1); //print $sql; $resql = $db->query($sql); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 159e7a6435a..54c5abfda93 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -48,6 +48,17 @@ function societe_prepare_head(Societe $object) $head[$h][2] = 'card'; $h++; + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $nbContact = 0; // TODO + $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; + } + if ($object->client==1 || $object->client==2 || $object->client==3) { $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id; @@ -748,7 +759,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print ''; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print "\n".'
'; + print ''; + print ''; + print ''; + print ''; + print ''; @@ -557,6 +599,38 @@ while ($i < min($num,$limit)) print ''; + print $obj->qty; + print ''; + print price($obj->total_ht); + print ''; + print price($obj->total_tva); + print ''; + print price2num($obj->tva_tx).'%'; + print ''; + print price($obj->subprice); + print '
'; @@ -649,16 +649,13 @@ if ($id > 0 || ! empty($ref)) { print ''; } - // hidden fields for js function - print ''; - print ''; print ''; print ''; - print ''; if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) { From ca6ad909e7cb9afe929618d728435e65155c0b51 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 26 Sep 2017 16:23:00 +0200 Subject: [PATCH 057/428] remove deprecated file --- htdocs/core/js/lib_batch.js | 50 ------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 htdocs/core/js/lib_batch.js diff --git a/htdocs/core/js/lib_batch.js b/htdocs/core/js/lib_batch.js deleted file mode 100644 index 54ddb8fa77d..00000000000 --- a/htdocs/core/js/lib_batch.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2014 Cedric GROSS -// -// 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/js/lib_batch.js -// \brief File that include javascript functions used when dispatching batch-enabled product -// - -/** - * addLineBatch - * @deprecated replaced by addDispatchLine and moved to module folder and file fourn/js/lib_dispatch.js - * - * @param index int number of produt. 0 = first product line - */ -function addLineBatch(index) -{ - var nme = 'dluo_0_'+index; - $row=$("tr[name='"+nme+"']").clone(true); - $row.find("input[name^='qty']").val(''); - var trs = $("tr[name^='dluo_'][name$='_"+index+"']"); /* trs.length = position of line for batch */ - var newrow=$row.html().replace(/_0_/g,"_"+(trs.length)+"_"); - $row.html(newrow); - //clear value - $row.find("input[name^='qty']").val(''); - //change name of row - $row.attr('name','dluo_'+trs.length+'_'+index); - $("tr[name^='dluo_'][name$='_"+index+"']:last").after($row); - - /* Suffix of lines are: _ trs.length _ index */ - jQuery("#lot_number_"+trs.length+"_"+index).focus(); - nb = jQuery("#qty_"+(trs.length - 1)+"_"+index).val(); - if (nb > 0) - { - jQuery("#qty_"+(trs.length - 1)+"_"+index).val(1); - jQuery("#qty_"+trs.length+"_"+index).val(nb - 1); - } -} From 7178bf013271fcf374cb01c90b920a30a9bc0e7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 16:56:33 +0200 Subject: [PATCH 058/428] Work on direct external link for dolibarr objects --- htdocs/compta/facture/class/facture.class.php | 11 +++++++++-- htdocs/document.php | 2 +- .../modulebuilder/template/class/myobject.class.php | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b6d294c6e18..b7603400c61 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1059,13 +1059,20 @@ class Facture extends CommonInvoice */ function getDirectExternalLink($withpicto=0) { + global $dolibarr_main_url_root; + // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $url='eee'; - return ''.$this->ref.''; + // TODO Read into ecmfile table to get entry and hash exists (PS: If not found, add it) + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($this->db); + //$result = $ecmfile->get(); + + $hashp='todo'; + return ''.$this->ref.''; } /** diff --git a/htdocs/document.php b/htdocs/document.php index 11017f52cc2..0b2db2323cd 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -25,7 +25,7 @@ * \file htdocs/document.php * \brief Wrapper to download data files * \remarks Call of this wrapper is made with URL: - * document.php?modulepart=repfichierconcerne&file=pathrelatifdufichier + * document.php?modulepart=repfichierconcerne&file=relativepathoffile * document.php?modulepart=logs&file=dolibarr.log */ diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 259db698024..4a5f349215b 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -324,6 +324,17 @@ class MyObject extends CommonObject return $result; } + /** + * Return link to download file from a direct external access + * + * @param int $withpicto Add download picto into link + * @return string HTML link to file + */ + function getDirectExternalLink($withpicto=0) + { + return 'todo'; + } + /** * Retourne le libelle du status d'un user (actif, inactif) * From 15c8515d5356ec3ca41481a0c55b033124f4d2a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 19:08:04 +0200 Subject: [PATCH 059/428] Fix default --- htdocs/install/mysql/migration/3.0.0-3.1.0.sql | 2 +- htdocs/install/mysql/tables/llx_societe.sql | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index fa94a5deeed..a4ab666299d 100644 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -63,7 +63,7 @@ ALTER TABLE llx_facturedet ADD UNIQUE INDEX uk_fk_remise_except (fk_remise_excep ALTER TABLE llx_societe ADD COLUMN fk_currency integer DEFAULT 0 AFTER fk_forme_juridique; ALTER TABLE llx_societe ADD COLUMN status tinyint DEFAULT 1; -ALTER TABLE llx_societe ADD COLUMN logo varchar(255); +ALTER TABLE llx_societe ADD COLUMN logo varchar(255) DEFAULT NULL; ALTER TABLE llx_societe_remise MODIFY remise_client double(6,3) DEFAULT 0 NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 20440b692d7..0f0cb437750 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -95,13 +95,13 @@ create table llx_societe barcode varchar(255), -- barcode fk_barcode_type integer NULL DEFAULT 0, -- barcode type price_level integer NULL, -- level of price for multiprices - outstanding_limit double(24,8) DEFAULT NULL, -- allowed outstanding limit + outstanding_limit double(24,8) DEFAULT NULL, -- allowed outstanding limit default_lang varchar(6), -- default language - logo varchar(255), - canvas varchar(32), -- type of canvas if used (null by default) + logo varchar(255) DEFAULT NULL, + canvas varchar(32) DEFAULT NULL, -- type of canvas if used (null by default) import_key varchar(14), -- import key - webservices_url varchar(255), -- supplier webservice url - webservices_key varchar(128), -- supplier webservice key + webservices_url varchar(255), -- supplier webservice url + webservices_key varchar(128), -- supplier webservice key fk_multicurrency integer, multicurrency_code varchar(255) From 938989d2e4fcb18445afd18cbfa5a46eefdeca72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 20:31:39 +0200 Subject: [PATCH 060/428] Update doc --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 7823d4cefb1..d75938891f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ Following changes may create regressions for some external modules, but were nec * The methode "cloture" on contact were renamed into "closeAll". * The substitution key for reference of object is now __REF__ whatever is the object (it replaces __ORDERREF__, __PROPALREF__, ...) +* Some REST API to access the dictionary (country, town, ...) were moved into a common API. ***** ChangeLog for 6.0.1 compared to 6.0.* ***** From 7cf1a418537d5f5c0dc01d866f1b634a9f7f41c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 20:57:09 +0200 Subject: [PATCH 061/428] Try to replace error into warning, so we can still make the order if qty too low --- htdocs/fourn/commande/card.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index c955d7b98d3..a7568f446ca 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -555,18 +555,16 @@ if (empty($reshook)) $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); if ($lineid) - { - $line = new CommandeFournisseurLigne($db); - $res = $line->fetch($lineid); - if (!$res) dol_print_error($db); - } + { + $line = new CommandeFournisseurLigne($db); + $res = $line->fetch($lineid); + if (!$res) dol_print_error($db); + } - if( $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid','int')) < 0 ) - { - setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); - } - else - { + if ($productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid','int')) < 0 ) + { + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); + } $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); @@ -684,7 +682,7 @@ if (empty($reshook)) dol_print_error($db,$object->error); exit; } - } + } // Remove a product line From 04f4a81736385d61ca91300898c545b967fe4eb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 22:06:59 +0200 Subject: [PATCH 062/428] FIX #7505 --- htdocs/fichinter/card.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index fc634bed9ff..297e6097fe2 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1685,18 +1685,11 @@ else if ($id > 0 || ! empty($ref)) * Built documents */ $filename=dol_sanitizeFileName($object->ref); - $filedir=$conf->ficheinter->dir_output . "/".$object->ref; + $filedir=$conf->ficheinter->dir_output . "/".$filename; $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed=$user->rights->ficheinter->creer; $delallowed=$user->rights->ficheinter->supprimer; - $genallowed=1; - $delallowed=1; - - $var=true; - - //print "
\n"; - print $somethingshown=$formfile->showdocuments('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); - + print $formfile->showdocuments('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('fichinter')); From 3849da4fe421fa97974116264eeb2f64d56beab2 Mon Sep 17 00:00:00 2001 From: dolibarr95 Date: Wed, 27 Sep 2017 09:09:38 +0200 Subject: [PATCH 063/428] Line missing (error 500) Create an instance of ProductFournisseur. --- htdocs/fourn/commande/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index a7568f446ca..0e23b62fbb0 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -561,6 +561,7 @@ if (empty($reshook)) if (!$res) dol_print_error($db); } + $productsupplier = new ProductFournisseur($db); if ($productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid','int')) < 0 ) { setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); From 1694737e0bc37d676da556d5ea848a7ca7a1a370 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 27 Sep 2017 10:09:21 +0200 Subject: [PATCH 064/428] NEW : new param on load_board() function in ActionComm class to avoid duplicate code --- htdocs/comm/action/class/actioncomm.class.php | 87 ++++++------------- htdocs/index.php | 2 +- 2 files changed, 27 insertions(+), 62 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index ff5b2aca769..12c11f863f1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -911,19 +911,25 @@ class ActionComm extends CommonObject /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Objet user + * @param User $user Objet user + * @param int $load_state_board Charge indicateurs this->nb de tableau de bord * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + function load_board($user, $load_state_board=0) { global $conf, $langs; - $sql = "SELECT a.id, a.datep as dp"; + if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; + else { + $this->nb=array(); + $sql = "SELECT count(a.id) as nb"; + } $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; $sql.= ")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - $sql.= " WHERE a.percent >= 0 AND a.percent < 100"; + $sql.= " WHERE 1"; + if(empty($load_state_board)) $sql.= " AND a.percent >= 0 AND a.percent < 100"; $sql.= " AND a.entity IN (".getEntity('agenda').")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; @@ -932,69 +938,28 @@ class ActionComm extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $agenda_static = new ActionComm($this->db); - - $response = new WorkboardResponse(); - $response->warning_delay = $conf->agenda->warning_delay/60/60/24; - $response->label = $langs->trans("ActionsToDo"); - $response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda'; - if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; - $response->img = img_object('',"action",'class="inline-block valigntextmiddle"'); - + if(empty($load_state_board)) { + $agenda_static = new ActionComm($this->db); + $response = new WorkboardResponse(); + $response->warning_delay = $conf->agenda->warning_delay/60/60/24; + $response->label = $langs->trans("ActionsToDo"); + $response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda'; + if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; + $response->img = img_object('',"action",'class="inline-block valigntextmiddle"'); + } // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { - $response->nbtodo++; - - $agenda_static->datep = $this->db->jdate($obj->dp); - - if ($agenda_static->hasDelay()) { - $response->nbtodolate++; - } - } - - return $response; - } - else - { - $this->error=$this->db->error(); - return -1; - } - } - - /** - * Charge indicateurs this->nb de tableau de bord - * - * @return int <0 if ko, >0 if ok - */ - function load_state_board() - { - global $user; - - $this->nb=array(); - - $sql = "SELECT count(a.id) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= ")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; - if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; - if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; - - $resql=$this->db->query($sql); - if ($resql) - { - $agenda_static = new ActionComm($this->db); - - while ($obj=$this->db->fetch_object($resql)) - { - $this->nb["actionscomm"]=$obj->nb; + if(empty($load_state_board)) { + $response->nbtodo++; + $agenda_static->datep = $this->db->jdate($obj->dp); + if ($agenda_static->hasDelay()) $response->nbtodolate++; + } else $this->nb["actionscomm"]=$obj->nb; } $this->db->free($resql); - return 1; + if(empty($load_state_board)) return $response; + else return 1; } else { diff --git a/htdocs/index.php b/htdocs/index.php index 9298e9c411f..1d5f9c5350b 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -377,7 +377,7 @@ if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) $board=new ActionComm($db); $wb_res = $board->load_board($user); if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); + $board->load_board($user, 1); $wb_res->nbtotal = (int)$board->nb['actionscomm']; } $dashboardlines[] = $wb_res; From 7f807986d7b1de8cd5ad7762f190f57444b6465a Mon Sep 17 00:00:00 2001 From: arnaud Date: Wed, 27 Sep 2017 10:53:29 +0200 Subject: [PATCH 065/428] FIX replenish if line test GETPOST on line 0 --- htdocs/product/stock/replenish.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 55fe5908c7f..28786f0d324 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -115,7 +115,7 @@ if ($action == 'order' && isset($_POST['valid'])) $suppliers = array(); for ($i = 0; $i < $linecount; $i++) { - if (GETPOST($i, 'alpha') === 'on' && GETPOST('fourn' . $i, 'int') > 0) + if (GETPOST('choose' . $i, 'alpha') === 'on' && GETPOST('fourn' . $i, 'int') > 0) { //one line $box = $i; @@ -616,7 +616,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) // Select field //print '
'.$prod->getNomUrl(1, '').'
'; $text=''; - if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')'; + if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')'; $text.='. '.$langs->trans("LateDesc"); //$text.=$form->textwithpicto('',$langs->trans("LateDesc")); $options='height="64px"'; From be60e66d626420731ffa017d1d8696695e0034a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 16:29:33 +0200 Subject: [PATCH 072/428] Uniformsize code/options --- htdocs/compta/facture/card.php | 72 +++++++++++++++++------------- htdocs/theme/eldy/img/stcomm0.png | Bin 914 -> 929 bytes 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2535d8e7442..940ada5e04b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -604,27 +604,30 @@ if (empty($reshook)) $ventilExportCompta = $object->getVentilExportCompta(); // On verifie si aucun paiement n'a ete effectue - if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) + if ($ventilExportCompta == 0) { - $result=$object->set_draft($user, $idwarehouse); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); - - - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records + $result=$object->set_draft($user, $idwarehouse); + if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } } } } @@ -1436,7 +1439,7 @@ if (empty($reshook)) $object->situation_counter = $object->situation_counter + 1; $id = $object->createFromCurrent($user); - if ($id <= 0) + if ($id <= 0) { $mesg = $object->error; } @@ -4115,28 +4118,35 @@ else if ($id > 0 || ! empty($ref)) $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { // Editer une facture deja validee, sans paiement effectue et pas exporte en compta - if ($object->statut == 1) + if ($object->statut == Facture::STATUS_VALIDATED) { // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees $ventilExportCompta = $object->getVentilExportCompta(); - if ($resteapayer == $object->total_ttc && empty($object->paye) && $ventilExportCompta == 0) + if ($ventilExportCompta == 0) { - if (! $objectidnext && $object->is_last_in_cycle()) + if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) + if (! $objectidnext && $object->is_last_in_cycle()) { - print ''; + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) + { + print ''; + } else { + print '
' . $langs->trans('Modify') . '
'; + } + } else if (!$object->is_last_in_cycle()) { + print '
' . $langs->trans('Modify') . '
'; } else { - print '
' . $langs->trans('Modify') . '
'; + print '
' . $langs->trans('Modify') . '
'; } - } else if (!$object->is_last_in_cycle()) { - print '
' . $langs->trans('Modify') . '
'; - } else { - print '
' . $langs->trans('Modify') . '
'; } } + else + { + print '
' . $langs->trans('Modify') . '
'; + } } $discount = new DiscountAbsolute($db); @@ -4158,7 +4168,7 @@ else if ($id > 0 || ! empty($ref)) } // Validate - if ($object->statut == 0 && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { + if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate))) { diff --git a/htdocs/theme/eldy/img/stcomm0.png b/htdocs/theme/eldy/img/stcomm0.png index b6c11d4569a5c96c92fb645c2479f82ecb4da690..1220cf8113e453c82a2fdb2d639eb086aef570e4 100644 GIT binary patch delta 864 zcmV-m1E2ho2cZX$B#|*Kf8hxm3lk$$84qay00S;bL_t(I%Y~C&Xj^3*#-I0`B%~+J zhe?{`)JSQ&NeRpFLfFv2aNrozY4Kwh!-0Yq4zVbT1BG48E7ythV$NRGFFM95bHW7I zV$j(QbQf)1x^~SdIV5emHpVu|N%Efe{l8ww2J`c|{KNBuKRiE%fB(s`W8e6tq;yAz z=S9xN{(8Or8t2YeCr=(!0O0z!;_>6(d4-^i*Q>wK-yeU>G=mS6%NuNZy71K6TKii7 z_TK=fPGvPI$zY5m#gmqSiA=?GV)_wDYYjQ zGM+ch(B6T8ggX}Ve?!+9q*SO>Y`EPnY~5=5=H^N-0eA-h*y!k$`-s%DhT$IU>+8yN zcZY(e8Gx>9005;FI43MDl;QV#A%w!|)04C1@^4R^IrC~!BcgOT?E7HXt_SyR+twX4 z%^-AL17i$~F+`(L3=a>ZRI0+`al!4@kV+-{iPYfW;D?$fe+1oT47VJIShZ?nX{mx@ zv5H2c4Iw1XojZ>cC*Frr3Q`grhtSv8<@5PE9w(xxMnp@+Vs%nV5{X0rk%$4?=9rpV z#M!go>C&`1BT&2B+`jw zGK>QU_9K&de-6F9I}wkEKm>3uK%~IAG%Rb)r39RLhUsi!pnIC5lf%eMJvxm-yS{rRg960@@<)axze zawWQU?UuE$Q2f$yoRMtyXz?yUO4TTps^=}M@^CQdbG6$7`TROKm$0k~rlxN2`T5dV zrLy@sk-D7C9u)wf-vL~`I!@{IleTU1%$6;&c(duCR%_$ZrC)0k6Ejx|h1)~5TJvK- zdKO&;9FI;$Y{hy>`e?1&J^vRw; qz!+_{_!k=+^|A5s*JuAr_dfvX^`3}Qvc+ov0000yXApqp$&s3;T^x~RK~7#F2x z75`{A6|GP~GBCstDVjw(G)=-Zq2#O+SO&g!MS+3+3dW{dGO8D)JX*Z#=ikCT=+381RV~C^;1JbeJ|K{{K-ni zWlKw&uk7q}egNS8jo{+Nye1`CjIpORjlI*`8-MQ5p{FwGbOcHPy3XJ@)rqaG`iB6D zj}c5y|J0|HI+jRSuiJLw`0#Kh)Y}_>g|0J5sZgtV2!#yn-)~25-!8ui;C%pKGc!Lw zL8M-@tkC%2V9(+H{zTliW6*UC0HBlt=Y+Mj3Zl_4giyG2DOadeetYT4mA6V75sfC3 zk&llYIdJ0O!Tz{y#~*?LKuU!mAe75>n5KbHNW;iTc8ExgkB@(%X+qF_#;_iL1jOof z4;vdbluC7Y9tY8b>+Lp&QVLQMf`BkM*b|9Fx?Uurv_?c5rBXd7C5cQXhE&Re=W#47 z6fr+vM77#Lz1{)<1c8JQ65ZWl3=E{64+1f&U%&pjJbLtG!}rCB;bA*wSte4cZe+7b zxUP@c*#e5i3i|pIAObiSd!I>v%W-xLV^8PO=4SPmd-vRIHk*J_0Kkw=cVleq06edQ zWHJg(V`#NHXtx6Z3`(h2H2^q!_PFnP{EOw~vLt$-RR{^!Z6lM3V_+Z+)6^k^1m^-b zZ*B&;+|p{Z>A&|d2fMr8T(P+Q>&Qs|SWizBjYbECq3>xYG@Cw_m&>$&xVY}Dt(CqG zf?ztIKUXpyv8z=s*S~d~+B5NZ#OQPcOw$185{^^D!omt)T`ga()poxmQuF!zIq_H$ ziAcC^XZFU8^;7%yrAB=}K&!sD#y&Yi6~Pl@QeYuDbb{!{7LUl*rOe|9Vuvu1psf91N(%U7?SDg0O6 Z{{UZ^ppoHEEv5hf002ovPDHLkV1jRSpN{|l From 9823d6622c6b453b5caefb1d25fd66adeadac761 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Sep 2017 17:40:02 +0200 Subject: [PATCH 073/428] Fix: use default $shared value --- dev/initdata/import-thirdparties.php | 2 +- htdocs/adherents/subscription.php | 2 +- htdocs/cashdesk/validation_verif.php | 6 +++--- htdocs/comm/propal/class/propal.class.php | 4 ++-- htdocs/commande/class/commande.class.php | 4 ++-- htdocs/compta/bank/bankentries.php | 2 +- htdocs/compta/bank/class/account.class.php | 2 +- htdocs/compta/bank/various_payment/index.php | 2 +- htdocs/compta/charges/index.php | 6 +++--- htdocs/compta/facture/card.php | 4 ++-- htdocs/compta/facture/class/facture-rec.class.php | 4 ++-- htdocs/compta/facture/class/facture.class.php | 8 ++++---- htdocs/compta/facture/class/paymentterm.class.php | 10 +++++----- htdocs/compta/paiement.php | 4 ++-- htdocs/compta/paiement/avalider.php | 2 +- .../paiement/cheque/class/remisecheque.class.php | 2 +- htdocs/compta/paiement/class/paiement.class.php | 2 +- htdocs/compta/paiement/list.php | 4 ++-- htdocs/compta/resultat/clientfourn.php | 4 ++-- htdocs/compta/resultat/index.php | 4 ++-- htdocs/compta/salaries/index.php | 2 +- htdocs/compta/sociales/card.php | 2 +- htdocs/compta/sociales/class/chargesociales.class.php | 2 +- .../sociales/class/paymentsocialcontribution.class.php | 2 +- htdocs/compta/sociales/payments.php | 2 +- htdocs/compta/tva/reglement.php | 2 +- htdocs/core/class/commoninvoice.class.php | 2 +- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/class/translate.class.php | 2 +- htdocs/core/lib/functions.lib.php | 3 +-- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/core/modules/modFacture.class.php | 2 +- htdocs/core/modules/modSalaries.class.php | 2 +- htdocs/core/modules/modSociete.class.php | 4 ++-- .../supplier_invoice/pdf/pdf_canelle.modules.php | 2 +- htdocs/don/card.php | 2 +- htdocs/don/class/don.class.php | 2 +- htdocs/don/class/paymentdonation.class.php | 2 +- htdocs/expensereport/card.php | 2 +- htdocs/expensereport/class/expensereport.class.php | 2 +- .../expensereport/class/paymentexpensereport.class.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 4 ++-- htdocs/fourn/class/fournisseur.facture.class.php | 4 ++-- htdocs/fourn/class/paiementfourn.class.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/fourn/facture/paiement.php | 2 +- htdocs/loan/card.php | 2 +- htdocs/loan/class/loanschedule.class.php | 2 +- htdocs/loan/class/paymentloan.class.php | 2 +- .../class/supplier_proposal.class.php | 4 ++-- 50 files changed, 74 insertions(+), 75 deletions(-) diff --git a/dev/initdata/import-thirdparties.php b/dev/initdata/import-thirdparties.php index 05fd0689102..a5ccbf2c45d 100755 --- a/dev/initdata/import-thirdparties.php +++ b/dev/initdata/import-thirdparties.php @@ -149,7 +149,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) $condpayment = trim($fields[36]); if ($condpayment == 'A la commande') $condpayment = 'A réception de commande'; if ($condpayment == 'A reception facture') $condpayment = 'Réception de facture'; - $object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', getEntity('c_payment_term', 2)); + $object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', getEntity('c_payment_term')); if (empty($object->cond_reglement_id)) { print " - Error cant find payment mode for ".$condpayment."\n"; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index f192469e301..132d616e17b 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -461,7 +461,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $paiement = new Paiement($db); $paiement->datepaye = $paymentdate; $paiement->amounts = $amounts; - $paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement','code','id',getEntity('c_paiement', 2)); + $paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement','code','id',getEntity('c_paiement')); $paiement->num_paiement = $num_chq; $paiement->note = $label; diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 88c1e62a479..9937deab531 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -136,7 +136,7 @@ switch ($action) $cond_reglement_id = 0; break; case 'ESP': - $mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement','code','id',getEntity('c_paiement', 2)); + $mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement','code','id',getEntity('c_paiement')); $cond_reglement_id = 0; $note .= $langs->trans("Cash")."\n"; $note .= $langs->trans("Received").' : '.$obj_facturation->montantEncaisse()." ".$conf->currency."\n"; @@ -145,11 +145,11 @@ switch ($action) $note .= '--------------------------------------'."\n\n"; break; case 'CB': - $mode_reglement_id = dol_getIdFromCode($db,'CB','c_paiement','code','id',getEntity('c_paiement', 2)); + $mode_reglement_id = dol_getIdFromCode($db,'CB','c_paiement','code','id',getEntity('c_paiement')); $cond_reglement_id = 0; break; case 'CHQ': - $mode_reglement_id = dol_getIdFromCode($db,'CHQ','c_paiement','code','id',getEntity('c_paiement', 2)); + $mode_reglement_id = dol_getIdFromCode($db,'CHQ','c_paiement','code','id',getEntity('c_paiement')); $cond_reglement_id = 0; break; } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 316227cbe42..ca470b9d668 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1271,8 +1271,8 @@ class Propal extends CommonObject $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity = ' . getEntity('c_paiement', 2); - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term', 2); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity = ' . getEntity('c_paiement'); + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term'); $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3104ec7f975..283c5e3d663 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1559,8 +1559,8 @@ class Commande extends CommonOrder $sql.= ', ca.code as availability_code, ca.label as availability_label'; $sql.= ', dr.code as demand_reason_code'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term', 2) . ')'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement', 2) . ')'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid AND cr.entity = ' . getEntity('c_payment_term') . ')'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id AND p.entity = ' . getEntity('c_paiement') . ')'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index acd8ab93aef..78ffe7f61ec 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -1161,7 +1161,7 @@ if ($resql) if (! empty($arrayfields['type']['checked'])) { print '
'; - $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle','',getEntity('c_paiement', 2)); + $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle','',getEntity('c_paiement')); if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); else print $labeltype; print "
'; - print $objsoc->getNomUrl(1); + print $objsoc->getNomUrl(1, 'contact'); print '
'."\n"; $param="socid=".$object->id; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 89bbe24ea47..5d9f9280cc8 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -48,6 +48,16 @@ function commande_prepare_head(Commande $object) $h++; } + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; + } + if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)) { @@ -60,16 +70,6 @@ function commande_prepare_head(Commande $object) $h++; } - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); - $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; - $head[$h][2] = 'contact'; - $h++; - } - // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index e24fbb44f7a..aa9353201cf 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -34,16 +34,19 @@ if ($action == 'presend') $object->fetch_projet(); - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - // - if ($object->element == 'invoice_supplier') + if (! in_array($object->element, array('societe', 'user'))) { - $fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id,2,0,0,$object,$object->element).$ref, preg_quote($ref,'/').'([^\-])+'); - } + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + // + if ($object->element == 'invoice_supplier') + { + $fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id,2,0,0,$object,$object->element).$ref, preg_quote($ref,'/').'([^\-])+'); + } - $file = $fileparams['fullname']; + $file = $fileparams['fullname']; + } // Define output language $outputlangs = $langs; @@ -72,16 +75,19 @@ if ($action == 'presend') } // Build document if it not exists - if (! $file || ! is_readable($file)) { - if ($object->element != 'member') - { - $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) { - dol_print_error($db, $object->error, $object->errors); - exit(); + if (! in_array($object->element, array('societe', 'user'))) + { + if (! $file || ! is_readable($file)) { + if ($object->element != 'member') + { + $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { + dol_print_error($db, $object->error, $object->errors); + exit(); + } + $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; } - $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; } } @@ -106,7 +112,7 @@ if ($action == 'presend') if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); + $formmail->frommail=dolAddEmailTrackId($formmail->frommail, $trackid); } $formmail->withfrom = 1; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index f1cca6a1696..a78981f32a1 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -87,8 +87,8 @@ PredefinedMailContentSendSupplierOrder=__CONTACTCIVNAME__\n\nYou will find here PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __SHIPPINGREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __FICHINTERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentThirdparty=__CONTACTCIVNAME__\n\n__PERSONALIZED__\n\n__SIGNATURE__ -PredefinedMailContentUser=aa__PERSONALIZED__\n\n__SIGNATURE__ +PredefinedMailContentThirdparty=\n\n__SIGNATURE__ +PredefinedMailContentUser=\n\n__SIGNATURE__ DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfilMore=...or build your own profile
(manual module selection) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 236faaaa232..89074892fa9 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -59,7 +59,7 @@ $action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view'); $cancel = GETPOST('cancel','alpha'); $backtopage = GETPOST('backtopage','alpha'); $confirm = GETPOST('confirm'); -$socid = GETPOST('socid','int'); +$socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; if (empty($socid) && $action == 'view') $action='create'; @@ -2372,69 +2372,68 @@ else /* * Actions */ - print '
'."\n"; + if ($action != 'presend') + { + print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { - $at_least_one_email_contact = false; - $TContact = $object->contact_array_objects(); - foreach ($TContact as &$contact) + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { - if (!empty($contact->email)) + $at_least_one_email_contact = false; + $TContact = $object->contact_array_objects(); + foreach ($TContact as &$contact) { - $at_least_one_email_contact = true; - break; + if (!empty($contact->email)) + { + $at_least_one_email_contact = true; + break; + } } + + if (! empty($object->email) || $at_least_one_email_contact) + { + $langs->load("mails"); + print ''; + } + else + { + $langs->load("mails"); + print ''; + } + + if ($user->rights->societe->creer) + { + print ''."\n"; + } + + if ($user->rights->societe->supprimer) + { + print ''; + } + + if ($user->rights->societe->supprimer) + { + if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile + { + print '
'.$langs->trans('Delete').'
'."\n"; + } + else + { + print ''."\n"; + } + } } - if (! empty($object->email) || $at_least_one_email_contact) - { - $langs->load("mails"); - print ''; - } - else - { - $langs->load("mails"); - print ''; - } - - if ($user->rights->societe->creer) - { - print ''."\n"; - } - - if ($user->rights->societe->supprimer) - { - print ''; - } - - if ($user->rights->societe->supprimer) - { - if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile - { - print '
'.$langs->trans('Delete').'
'."\n"; - } - else - { - print ''."\n"; - } - } - } - - print '
'."\n"; + print '
'."\n"; + } //Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } - if ($action == 'presend') + /*if ($action == 'presend') { - /* - * Affiche formulaire mail - */ - // By default if $action=='presend' $titreform='SendMail'; $topicmail=''; @@ -2491,31 +2490,6 @@ else $formmail->substit['__PERSONALIZED__']=''; // deprecated $formmail->substit['__CONTACTCIVNAME__']=''; - //Find the good contact adress - /* - $custcontact=''; - $contactarr=array(); - $contactarr=$object->liste_contact(-1,'external'); - - if (is_array($contactarr) && count($contactarr)>0) - { - foreach($contactarr as $contact) - { - if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) { - - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - - $contactstatic=new Contact($db); - $contactstatic->fetch($contact['id']); - $custcontact=$contactstatic->getFullName($langs,1); - } - } - - if (!empty($custcontact)) { - $formmail->substit['__CONTACTCIVNAME__']=$custcontact; - } - }*/ - // Tableau des parametres complementaires du post $formmail->param['action']=$action; @@ -2533,14 +2507,15 @@ else print $formmail->get_form(); dol_fiche_end(); - } - else + }*/ + + if ($action != 'presend') { + print '
'; if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) { - print '
'; - print ''; // ancre + print ''; // ancre /* * Documents generes @@ -2553,35 +2528,34 @@ else $var=true; print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); - - print '
'; - - - print '
'; - - print '
'; } - print '

'; - // Subsidiaries list if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) { - $result=show_subsidiaries($conf,$langs,$db,$object); + $result=show_subsidiaries($conf,$langs,$db,$object); } - // Contacts list - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } + print '
'; - // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) - { - $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } + $MAX = 5; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAX); // Show all action for thirdparty + + print '
'; } + + // Presend form + $modelmail='thirdparty'; + $defaulttopic='Information'; + $diroutput = $conf->societe->dir_output; + $trackid = 'thi'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 56ca7d3042b..1c8c515545a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1898,6 +1898,11 @@ class Societe extends CommonObject $label.= '' . $langs->trans("ShowMargin") . ''; $linkstart = ''; + $linkstart = 'load("commercial"); +$langs->load("bills"); +$langs->load("banks"); +$langs->load("users"); +if (! empty($conf->categorie->enabled)) $langs->load("categories"); +if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); +if (! empty($conf->notification->enabled)) $langs->load("mails"); + +$mesg=''; $error=0; $errors=array(); + +$action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view'); +$cancel = GETPOST('cancel','alpha'); +$backtopage = GETPOST('backtopage','alpha'); +$confirm = GETPOST('confirm'); +$socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int'); +if ($user->societe_id) $socid=$user->societe_id; +if (empty($socid) && $action == 'view') $action='create'; + +$object = new Societe($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('thirdpartycard','globalcard')); + +if ($action == 'view' && $object->fetch($socid)<=0) +{ + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; +} + +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +$object->getCanvas($socid); +$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); +$objcanvas=null; +if (! empty($canvas)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('thirdparty', 'card', $canvas); +} + +// Security check +$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); + + + + +/* + * Actions + */ + +$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if ($cancel) + { + $action=''; + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } +} + + +/* + * View + */ + +$form = new Form($db); +$formfile = new FormFile($db); +$formadmin = new FormAdmin($db); +$formcompany = new FormCompany($db); + +if ($socid > 0 && empty($object->id)) +{ + $result=$object->fetch($socid); + if ($result <= 0) dol_print_error('',$object->error); +} + +$title=$langs->trans("ThirdParty"); +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card'); +$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('',$title,$help_url); + +$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) +{ + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template +} +else +{ + + if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); + //if ($res < 0) { dol_print_error($db); exit; } + + + $head = societe_prepare_head($object); + + dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); + + // Confirm delete third party + if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); + } + + if ($action == 'merge') + { + $formquestion = array( + array( + 'name' => 'soc_origin', + 'label' => $langs->trans('MergeOriginThirdparty'), + 'type' => 'other', + 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') + ) + ); + + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 200); + } + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); + + + print '
'; + + dol_fiche_end(); + + + if ($action != 'presend') + { + print '
'; + + // Contacts list + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } + + // Addresses list + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) + { + $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } + + + print '
'; + + } + +} + + +// End of page +llxFooter(); +$db->close(); From 6bdfa99fc2f2c0dbec14b06035bf4a8f32be741e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 20:07:01 +0200 Subject: [PATCH 079/428] FIX The backtopage --- htdocs/contact/card.php | 9 +++++++++ htdocs/core/lib/company.lib.php | 11 +++++++++++ htdocs/ecm/docfile.php | 6 +++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 43b9b7e4760..ac3c52ae8f5 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -396,6 +396,15 @@ if (empty($reshook)) $action = 'edit'; } } + + if (! $error && empty($errors)) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } } } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 54c5abfda93..f22da301ec4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -52,6 +52,17 @@ function societe_prepare_head(Societe $object) { //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); $nbContact = 0; // TODO + + $sql = "SELECT COUNT(p.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; + $sql .= " WHERE p.fk_soc = ".$object->id; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $nbContact = $obj->nb; + } + $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index a856ab22c36..f6719d08604 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -117,9 +117,9 @@ if (! ($result >= 0)) if ($cancel) { $action =''; - if ($backtourl) + if ($backtopage) { - header("Location: ".$backtourl); + header("Location: ".$backtopage); exit; } else @@ -387,7 +387,7 @@ if ($action != 'edit') { print ''.$langs->trans('Edit').''; - //print ''.$langs->trans('Cancel').''; + //print ''.$langs->trans('Cancel').''; } /* if ($user->rights->ecm->setup) From e878f3cfd5ba574c56d8a93486347b7b3eaf894b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 20:15:56 +0200 Subject: [PATCH 080/428] No more need of contacts on each tab by default --- htdocs/core/class/conf.class.php | 5 ++--- htdocs/societe/contact.php | 38 +++++++------------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index aa1651d6fc6..e0e032d7e25 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -259,9 +259,8 @@ class Conf // Load translation object with current language if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US"; - // By default, we repeat info on all tabs - if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1; - if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1; + //if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1; + //if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1; $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index f69eef22795..56c729e76f4 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -151,43 +151,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) else { - if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); - //if ($res < 0) { dol_print_error($db); exit; } + if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); + //if ($res < 0) { dol_print_error($db); exit; } - $head = societe_prepare_head($object); + $head = societe_prepare_head($object); - dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); - // Confirm delete third party - if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) - { - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); - } + $linkback = ''.$langs->trans("BackToList").''; - if ($action == 'merge') - { - $formquestion = array( - array( - 'name' => 'soc_origin', - 'label' => $langs->trans('MergeOriginThirdparty'), - 'type' => 'other', - 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') - ) - ); + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 200); - } - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); - - - print '
'; - - dol_fiche_end(); + dol_fiche_end(); + print '
'; if ($action != 'presend') { From 537a551bb5972cd2d413ea3f453a499951c924e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 21:58:42 +0200 Subject: [PATCH 081/428] Fix vat visiblity on pdf --- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/core/lib/pdf.lib.php | 7 ++++--- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 6 +++--- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 6 +++--- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 7 ++++--- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bfddc4b4921..e87f46ad2bf 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3684,7 +3684,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee * @param string $rate Rate value to format ('19.6', '19,6', '19.6%', '19,6%', '19.6 (CODEX)', ...) * @param boolean $addpercent Add a percent % sign in output * @param int $info_bits Miscellaneous information on vat (0=Default, 1=French NPR vat) - * @param int $usestarfornpr 1=Use '*' for NPR vat rate intead of MAIN_LABEL_MENTION_NPR + * @param int $usestarfornpr -1=Never show, 0 or 1=Use '*' for NPR vat rates * @return string String with formated amounts ('19,6' or '19,6%' or '8.5% (NPR)' or '8.5% *' or '19,6 (CODEX)') */ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0) @@ -3714,7 +3714,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0) // TODO Split on / and output with a price2num to have clean numbers without ton of 000. $ret=$rate.($addpercent?'%':''); } - if ($info_bits & 1) $ret.=' *'; + if (($info_bits & 1) && $usestarfornpr >= 0) $ret.=' *'; $ret.=$morelabel; return $ret; } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 8a445625022..698ba131ca6 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1491,14 +1491,14 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0) { $tmpresult=''; - $tmpresult.=vatrate($object->lines[$i]->tva_tx, 1, $object->lines[$i]->info_bits, 1); + $tmpresult.=vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) { if ($object->lines[$i]->total_localtax1 != 0) { if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; else $tmpresult=''; - $tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx),1); + $tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx), 0); } } if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) @@ -1507,9 +1507,10 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0) { if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; else $tmpresult=''; - $tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx),1); + $tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx), 0); } } + $tmpresult.= '%'; $result.=$tmpresult; } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 74a72b36581..80c6e6680b2 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -140,7 +140,7 @@ class pdf_einstein extends ModelePDFCommandes } else { - $this->posxtva=112; + $this->posxtva=110; $this->posxup=126; $this->posxqty=145; } @@ -431,8 +431,8 @@ class pdf_einstein extends ModelePDFCommandes if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R'); + $pdf->SetXY($this->posxtva-5, $curY); + $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R'); } // Unit price before discount diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 338a6019b56..98b2367db32 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -125,7 +125,7 @@ class pdf_crabe extends ModelePDFFactures } else { - $this->posxtva=112; + $this->posxtva=110; $this->posxup=126; $this->posxqty=145; } @@ -496,8 +496,8 @@ class pdf_crabe extends ModelePDFFactures if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R'); + $pdf->SetXY($this->posxtva-5, $curY); + $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R'); } // Unit price before discount diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 8b9929f2880..9105a82b0d4 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -114,7 +114,7 @@ class pdf_azur extends ModelePDFPropales } else { - $this->posxtva=112; + $this->posxtva=110; $this->posxup=126; $this->posxqty=145; } @@ -505,8 +505,8 @@ class pdf_azur extends ModelePDFPropales if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R'); + $pdf->SetXY($this->posxtva-5, $curY); + $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R'); } // Unit price before discount @@ -1310,6 +1310,7 @@ class pdf_azur extends ModelePDFPropales $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); if (empty($hidetop)) { + // Not do -3 and +3 instead of -1 -1 to have more space for text 'Sales tax' $pdf->SetXY($this->posxtva-3, $tab_top+1); $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); } From 93cf135d5e459595bf36ae5bea608c89d34ccb30 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 28 Sep 2017 12:05:41 +0200 Subject: [PATCH 082/428] FIX: #7510 Bug: extrafield content disappear when generate pdf within intervention --- htdocs/fichinter/card.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 4ed3ecb7cef..213e4cc4d2b 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2002-2007 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2015 Regis Houssin - * Copyright (C) 2011-2013 Juanjo Menent + * Copyright (C) 2011-2017 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Ferran Marcet * Copyright (C) 2014-2015 Charlie Benke @@ -785,7 +785,8 @@ if (empty($reshook)) $parameters=array('id'=>$object->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) - { $result=$object->updateExtraField($_POST["attribute"]); + { + $result=$object->insertExtraFields(); if ($result < 0) { $error++; From 7374a2accd5155a960828e155b79424248d450eb Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Thu, 28 Sep 2017 12:14:49 +0200 Subject: [PATCH 083/428] NEW Download a document using the REST API Adds the ability to download a document using the REST API The document is sent in a base64 encoded format. The API will return : { "filename": "CO1709-0002.pdf", "content": "JVBERi0xLjMKJ...", "encoding": "MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)" } --- htdocs/api/class/api_documents.class.php | 51 ++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index e26486981fa..4d0efb63d62 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -22,6 +22,7 @@ use Luracast\Restler\Format\UploadFormat; require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; /** * API class for receive files @@ -54,13 +55,57 @@ class Documents extends DolibarrApi * * @param string $module_part Name of module or area concerned by file download ('facture', ...) * @param string $ref Reference of object (This will define subdir automatically) - * @param string $subdir Subdirectory (Only if ref not provided) + * @param string $subdir NOT YET AVAILABLE : Subdirectory (Only if ref not provided) * @return array List of documents * - * @throws RestException + * @throws 400 + * @throws 401 + * @throws 200 OK */ public function index($module_part, $ref='', $subdir='') { - return array('note'=>'FeatureNotYetAvailable'); + global $conf; + + if (empty($module_part)) { + throw new RestException(400, 'bad value for parameter modulepart'); + } + if (empty($ref) && empty($subdir)) { + throw new RestException(400, 'bad value for parameter ref or subdir'); + } + if (empty($ref)) { + throw new RestException(404, 'FeatureNotYetAvailable'); + } + if (!DolibarrApiAccess::$user->rights->ecm->read) { + throw new RestException(401); + } + + $original_file = str_replace("../","/", $ref.'/'.$ref.'.pdf'); + $refname=basename(dirname($original_file)."/"); + $entity=$conf->entity; + + $check_access = dol_check_secure_access_document($module_part,$original_file,$entity,DolibarrApiAccess::$user); + $accessallowed = $check_access['accessallowed']; + $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; + $original_file = $check_access['original_file']; + + if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) + { + throw new RestException(401); + } + if (!$accessallowed) { + throw new RestException(401); + } + + + $filename = basename($original_file); + $original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset + + if (! file_exists($original_file_osencoded)) + { + throw new RestException(404, 'File not found'); + } + + $file_content=file_get_contents($original_file_osencoded); + return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); } From 7ba2dd8397f638b07ac7d8e4e8b3506c8b9aa538 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 28 Sep 2017 15:25:51 +0200 Subject: [PATCH 084/428] Fix the pdf_getlineprogress hook isn't use because hookmanager is null --- htdocs/core/lib/pdf.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1b79cc9163d..89c4ceaa137 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1753,6 +1753,8 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0) */ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null) { + if (empty($hookmanager)) global $hookmanager; + $reshook=0; $result=''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) From 30a9e40f4ed0ebd4c0b8c6eb0b6c2c3674e17f6f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Sep 2017 17:29:37 +0200 Subject: [PATCH 085/428] Fix position of fields --- htdocs/api/class/api.class.php | 3 ++ .../comm/propal/class/api_proposals.class.php | 44 ++++++++++++++----- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index dcda8255e7c..10d03acef8e 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -131,6 +131,9 @@ class DolibarrApi unset($object->table_element_line); unset($object->picto); + unset($object->skip_update_total); + unset($object->context); + // Remove the $oldcopy property because it is not supported by the JSON // encoder. The following error is generated when trying to serialize // it: "Error encoding/decoding JSON: Type is not supported" diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 42dbdbf9d2c..46ac4cf0327 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -278,7 +278,7 @@ class Proposals extends DolibarrApi $request_data->fk_unit, $this->element, $request_data->id, - $request_data->pu_ht_devise, + $request_data->multicurrency_subprice, $request_data->fk_remise_except ); @@ -316,26 +316,27 @@ class Proposals extends DolibarrApi $request_data = (object) $request_data; $updateRes = $this->propal->updateline( $lineid, - $request_data->desc, $request_data->subprice, $request_data->qty, $request_data->remise_percent, $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, - 'HT', + $request_data->desc, + 'HT', $request_data->info_bits, - $request_data->date_start, - $request_data->date_end, - $request_data->product_type, - $request_data->fk_parent_line, - 0, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, $request_data->special_code, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->product_type, + $request_data->date_start, + $request_data->date_end, $request_data->array_options, - $request_data->fk_unit + $request_data->fk_unit, + $request_data->multicurrency_subprice ); if ($updateRes > 0) { @@ -508,4 +509,23 @@ class Proposals extends DolibarrApi } return $propal; } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->address); + + return $object; + } } From f510f3062bd17552b8d101f0520e23b697674fc7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Sep 2017 17:41:18 +0200 Subject: [PATCH 086/428] Clean param type --- htdocs/comm/propal/class/propal.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f2ecb877a9a..ce56e1386ef 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -639,6 +639,7 @@ class Propal extends CommonObject $pa_ht=price2num($pa_ht); if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag + if (empty($type)) $type=0; if ($this->statut == self::STATUS_DRAFT) { From 8a09472def1ad1a5dd5ed1ea15275c95a7fa500a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Sep 2017 18:23:06 +0200 Subject: [PATCH 087/428] Fix: civility_id is not an integer ! --- htdocs/adherents/class/adherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 5eb757c0c5c..76f94d15d50 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -419,7 +419,7 @@ class Adherent extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " civility = ".($this->civility_id>0?$this->db->escape($this->civility_id):"null"); + $sql.= " civility = ".($this->civility_id?$this->db->escape($this->civility_id):"null"); $sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null"); $sql.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null"); $sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null"); From f58fb6b6f6a8e91912ecca669ac85a106cadb87d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Sep 2017 18:29:11 +0200 Subject: [PATCH 088/428] Fix: syntax error --- htdocs/adherents/class/adherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 76f94d15d50..7c2cdb2f2aa 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -419,7 +419,7 @@ class Adherent extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " civility = ".($this->civility_id?$this->db->escape($this->civility_id):"null"); + $sql.= " civility = ".($this->civility_id?"'".$this->db->escape($this->civility_id)."'":"null"); $sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null"); $sql.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null"); $sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null"); From 660c5dd03d437ff793713df6c1f87b67d0ad22e5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Sep 2017 18:49:33 +0200 Subject: [PATCH 089/428] Fix: avoid ldap error when firstname and lastname is empty --- htdocs/adherents/class/adherent.class.php | 11 +++++++---- htdocs/admin/ldap_members.php | 21 +++++++++++++++------ htdocs/langs/en_US/admin.lang | 2 ++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7c2cdb2f2aa..e70ef9893bc 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1957,20 +1957,23 @@ class Adherent extends CommonObject $info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS); $this->fullname=$this->getFullName($langs); + // For avoid ldap error when firstname and lastname is empty + if ($this->morphy == 'mor' && empty($this->fullname)) $this->fullname = $this->societe; // Member if ($this->fullname && ! empty($conf->global->LDAP_MEMBER_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FULLNAME] = $this->fullname; - if ($this->lastname && ! empty($conf->global->LDAP_MEMBER_FIELD_NAME)) $info[$conf->global->LDAP_MEMBER_FIELD_NAME] = $this->lastname; + if ($this->lastname && ! empty($conf->global->LDAP_MEMBER_FIELD_NAME)) $info[$conf->global->LDAP_MEMBER_FIELD_NAME] = $this->lastname; if ($this->firstname && ! empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname; if ($this->login && ! empty($conf->global->LDAP_MEMBER_FIELD_LOGIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LOGIN] = $this->login; - if ($this->pass && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte + if ($this->pass && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte if ($this->pass && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // md5 for OpenLdap TODO add type of encryption if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste; + if ($this->societe && ! empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->societe; if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; if ($this->zip && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; - if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; + if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; - if ($this->email && ! empty($conf->global->LDAP_MEMBER_FIELD_MAIL)) $info[$conf->global->LDAP_MEMBER_FIELD_MAIL] = $this->email; + if ($this->email && ! empty($conf->global->LDAP_MEMBER_FIELD_MAIL)) $info[$conf->global->LDAP_MEMBER_FIELD_MAIL] = $this->email; if ($this->skype && ! empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index cad37cc4ccc..da04c852b2f 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005 Regis Houssin - * Copyright (C) 2006-2008 Laurent Destailleur - * Copyright (C) 2011-2013 Juanjo Menent +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2006-2008 Laurent Destailleur + * Copyright (C) 2011-2013 Juanjo Menent * * 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 @@ -68,6 +68,7 @@ if ($action == 'setvalue' && $user->admin) if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY',GETPOST("fieldcompany"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP',GETPOST("fieldzip"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN',GETPOST("fieldtown"),'chaine',0,'',$conf->entity)) $error++; @@ -282,6 +283,14 @@ print '
'; print ''; print ''; +// Company + +print ''; +print ''; +print ''; + // Address print ' -global->MAIN_FEATURES_LEVEL >= 2) { ?> - - +
'.$langs->trans("LDAPFieldFaxExample").' 
'.$langs->trans("LDAPFieldCompany").''; +print ''; +print ''.$langs->trans("LDAPFieldCompanyExample").' 
'.$langs->trans("LDAPFieldAddress").''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3c10edc86ca..c17ecd88a0e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1349,6 +1349,8 @@ LDAPFieldMobile=Cellular phone LDAPFieldMobileExample=Example : mobile LDAPFieldFax=Fax number LDAPFieldFaxExample=Example : facsimiletelephonenumber +LDAPFieldCompany=Company name +LDAPFieldCompanyExample=Example : displayName LDAPFieldAddress=Street LDAPFieldAddressExample=Example : street LDAPFieldZip=Zip From 35b290a7dfff248ae1d4783362c491b69dbeda18 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Sep 2017 19:04:33 +0200 Subject: [PATCH 090/428] Fix: Trad already exists --- htdocs/langs/en_US/admin.lang | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c17ecd88a0e..3c10edc86ca 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1349,8 +1349,6 @@ LDAPFieldMobile=Cellular phone LDAPFieldMobileExample=Example : mobile LDAPFieldFax=Fax number LDAPFieldFaxExample=Example : facsimiletelephonenumber -LDAPFieldCompany=Company name -LDAPFieldCompanyExample=Example : displayName LDAPFieldAddress=Street LDAPFieldAddressExample=Example : street LDAPFieldZip=Zip From 76c89aed9bc5cafceecf9bd67537f48752e0b2a5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Sep 2017 19:13:26 +0200 Subject: [PATCH 091/428] Fix: add lastname --- htdocs/adherents/class/adherent.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index e70ef9893bc..ceaf13335f3 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1956,9 +1956,12 @@ class Adherent extends CommonObject // Object classes $info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS); - $this->fullname=$this->getFullName($langs); - // For avoid ldap error when firstname and lastname is empty - if ($this->morphy == 'mor' && empty($this->fullname)) $this->fullname = $this->societe; + $this->fullname=$this->getFullName($langs); + // For avoid ldap error when firstname and lastname are empty + if ($this->morphy == 'mor' && empty($this->fullname)) { + $this->fullname = $this->societe; + $this->lastname = $this->societe; + } // Member if ($this->fullname && ! empty($conf->global->LDAP_MEMBER_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FULLNAME] = $this->fullname; From f007f9e7e5fd93ddf8493ca23305ec24d132868a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Sep 2017 13:26:44 +0200 Subject: [PATCH 092/428] NEW Add new property visible dy default on lists on extrafields --- htdocs/adherents/list.php | 2 +- htdocs/comm/propal/card.php | 8 +--- htdocs/comm/propal/list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/bank/bankentries.php | 2 +- htdocs/compta/bank/index.php | 2 +- .../compta/facture/invoicetemplate_list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/contact/list.php | 2 +- htdocs/contrat/list.php | 2 +- htdocs/contrat/services.php | 2 +- htdocs/core/actions_extrafields.inc.php | 5 ++- htdocs/core/class/extrafields.class.php | 8 ++-- htdocs/core/tpl/admin_extrafields_add.tpl.php | 13 +++--- .../core/tpl/admin_extrafields_edit.tpl.php | 13 +++--- .../core/tpl/admin_extrafields_view.tpl.php | 11 +++-- htdocs/core/tpl/extrafields_add.tpl.php | 40 +++++++++++++++++ htdocs/core/tpl/extrafields_edit.tpl.php | 40 +++++++++++++++++ htdocs/expedition/list.php | 2 +- htdocs/expensereport/list.php | 2 +- htdocs/fichinter/list.php | 2 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/facture/list.php | 2 +- .../install/mysql/migration/6.0.0-7.0.0.sql | 4 ++ .../template/class/myobject.class.php | 2 +- .../modulebuilder/template/myobject_card.php | 43 ++++++++++++++----- .../modulebuilder/template/myobject_list.php | 2 +- htdocs/product/inventory/list.php | 2 +- htdocs/product/list.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- htdocs/projet/list.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/projet/tasks/time.php | 2 +- htdocs/societe/list.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- htdocs/user/index.php | 2 +- 36 files changed, 170 insertions(+), 67 deletions(-) create mode 100644 htdocs/core/tpl/extrafields_add.tpl.php create mode 100644 htdocs/core/tpl/extrafields_edit.tpl.php diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 783934deb34..398d5b62adc 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -129,7 +129,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4fc1eebb66d..a7540c69840 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1530,13 +1530,7 @@ if ($action == 'create') } // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $object->showOptionals($extrafields, 'edit'); - } - + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; // Lines from source if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 41002eb9e71..0f2fd46c3f6 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -158,7 +158,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 927460c511a..fed61c1fc17 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -142,7 +142,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 8cb5b878dc0..a04d9cf0f2e 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -151,7 +151,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 4485680a4e9..31c777740ac 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -103,7 +103,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index e911f6eab74..f39fc7a3185 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -138,7 +138,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index d6ffc854844..be81fe48a0c 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -174,7 +174,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index ebf7bc611f9..05fcf3e0916 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -160,7 +160,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 2afee019bed..64f2b6b94f2 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -133,7 +133,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index ddb19e3e88c..945b5b8b983 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -134,7 +134,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 433288606ec..b6e70059da3 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -159,6 +159,7 @@ if ($action == 'add') $params['options'][$key] = $value; } } + $result=$extrafields->addExtraField( GETPOST('attrname', 'alpha'), GETPOST('label', 'alpha'), @@ -172,7 +173,7 @@ if ($action == 'add') $params, (GETPOST('alwayseditable', 'alpha')?1:0), (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), - (GETPOST('list', 'alpha')?1:0), + GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list (GETPOST('ishidden', 'alpha')?1:0), GETPOST('computed_value','alpha'), (GETPOST('entitycurrentorall', 'alpha')?0:''), @@ -334,7 +335,7 @@ if ($action == 'update') $params, (GETPOST('alwayseditable', 'alpha')?1:0), (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), - (GETPOST('list', 'alpha')?1:0), + GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list (GETPOST('ishidden', 'alpha')?1:0), GETPOST('default_value','alpha'), GETPOST('computed_value','alpha'), diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f79198a7096..4c7fb824559 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -140,14 +140,14 @@ class ExtraFields * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Into list view by default + * @param int $list Into list view by default (-1, 0 or 1) * @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) * @param string $computed Computed value * @param string $entity Entity of extrafields * @param string $langfile Language file * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0, $computed='', $entity='', $langfile='') + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $computed='', $entity='', $langfile='') { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -279,7 +279,7 @@ class ExtraFields * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Into list view by default + * @param int $list Into list view by default (-1, 0 or 1) * @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -287,7 +287,7 @@ class ExtraFields * @param string $langfile Language file * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0, $default='', $computed='',$entity='', $langfile='') + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $default='', $computed='',$entity='', $langfile='') { global $conf,$user; diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 6c5f563e106..e04f4e0cb92 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -26,6 +26,8 @@ * $elementtype */ +$langs->load("modulebuilder"); + ?> @@ -101,13 +103,13 @@ if (type == 'separate') { - required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); + required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.removeAttr('checked').prop('disabled', true); jQuery('#size, #default_value').val('').prop('disabled', true); } else { default_value.removeAttr('disabled'); - required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); + required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.removeAttr('disabled'); } } init_typeoffields(''); @@ -178,12 +180,9 @@ multicompany->enabled) { ?>
trans("AllEntities"); ?>>
trans("ByDefaultInList"); ?> -trans("FeatureNotYetSupported")); ?> ->
textwithpicto($langs->trans("ByDefaultInList"), $langs->trans("VisibleDesc")); ?> +
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 85cfe510df8..def07fa432f 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -25,6 +25,8 @@ * $elementtype */ +$langs->load("modulebuilder"); + ?> @@ -96,13 +98,13 @@ if (type == 'separate') { - required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); + required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.removeAttr('checked').prop('disabled', true); jQuery('#size, #default_value').val('').prop('disabled', true); } else { default_value.removeAttr('disabled'); - required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); + required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.removeAttr('disabled'); } } init_typeoffields(jQuery("#type").val()); @@ -238,11 +240,8 @@ else trans("AllEntities"); ?>> -global->MAIN_FEATURES_LEVEL >= 2) { ?> -trans("ByDefaultInList"); ?> -trans("FeatureNotYetSupported")); ?> -> - +textwithpicto($langs->trans("ByDefaultInList"), $langs->trans("VisibleDesc")); ?> + diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index f989ce448b5..30b4299a21e 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -22,6 +22,9 @@ * $extrafield * $elementtype */ + +$langs->load("modulebuilder"); + ?> @@ -48,6 +51,7 @@ print ''.$langs->trans("Unique").''; print ''.$langs->trans("ComputedFormula").''; print ''.$langs->trans("Required").''; print ''.$langs->trans("AlwaysEditable").''; +print ''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''; if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''.$langs->trans("Hidden").''; if ($conf->multicompany->enabled) { print ''.$langs->trans("Entities").''; @@ -59,7 +63,7 @@ if (count($extrafields->attribute_type)) { foreach($extrafields->attribute_type as $key => $value) { - + print ''; print "".$extrafields->attribute_pos[$key]."\n"; print "".$extrafields->attribute_label[$key]."\n"; @@ -70,7 +74,8 @@ if (count($extrafields->attribute_type)) print ''.dol_trunc($extrafields->attribute_computed[$key], 20)."\n"; print ''.yn($extrafields->attribute_required[$key])."\n"; print ''.yn($extrafields->attribute_alwayseditable[$key])."\n"; - if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''.yn($extrafields->attribute_hidden[$key])."\n"; // Add hidden option on not working feature. Why hide if user can't see it. + print ''.$extrafields->attribute_list[$key]."\n"; + if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''.yn($extrafields->attribute_hidden[$key])."\n"; // Add hidden option on not working feature. Why hide if user can't see it. if ($conf->multicompany->enabled) { print ''.($extrafields->attribute_entityid[$key]==0?$langs->trans("All"):$extrafields->attribute_entitylabel[$key]).''; } @@ -83,7 +88,7 @@ else { $colspan=9; if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) $colspan++; - + print ''; print ''; print $langs->trans("None"); diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php new file mode 100644 index 00000000000..a608cb2da6b --- /dev/null +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -0,0 +1,40 @@ + + * Copyright (C) 2014 Juanjo Menent + * + * 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 . + * + * Need to have following variables defined: + * $object (invoice, order, ...) + * $action + * $conf + * $langs + * + * $parameters + * $cols + */ +?> + +executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (empty($reshook) && ! empty($extrafields->attribute_label)) { + print $object->showOptionals($extrafields, 'edit'); +} + +?> + \ No newline at end of file diff --git a/htdocs/core/tpl/extrafields_edit.tpl.php b/htdocs/core/tpl/extrafields_edit.tpl.php new file mode 100644 index 00000000000..aa0e30473f1 --- /dev/null +++ b/htdocs/core/tpl/extrafields_edit.tpl.php @@ -0,0 +1,40 @@ + + * Copyright (C) 2014 Juanjo Menent + * + * 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 . + * + * Need to have following variables defined: + * $object (invoice, order, ...) + * $action + * $conf + * $langs + * + * $parameters + * $cols + */ +?> + +executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (empty($reshook) && ! empty($extrafields->attribute_label)) { + print $object->showOptionals($extrafields, 'edit'); +} + +?> + \ No newline at end of file diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index a5b693aa3f9..7a0a7fabfc7 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -110,7 +110,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 682ecf44839..0c34ff43ef0 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -120,7 +120,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 9dca5d1badb..c483dae647f 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -119,7 +119,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 5f1e564e30b..4b7bcb454cd 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -158,7 +158,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 349726bab5b..9d6c5e4ccd3 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -175,7 +175,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index b2df01afe51..e1af6e30de5 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -261,6 +261,10 @@ ALTER TABLE llx_extrafields ADD COLUMN fk_user_modif integer; ALTER TABLE llx_extrafields ADD COLUMN datec datetime; ALTER TABLE llx_extrafields ADD COLUMN tms timestamp; +-- We fix value of 'list' fro m0 to 1 for all extrafields created before this migration +UPDATE llx_extrafields SET list = 1 WHERE list = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL; + + ALTER TABLE llx_extrafields MODIFY COLUMN langs varchar(64); ALTER TABLE llx_holiday_config MODIFY COLUMN name varchar(128); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 4a5f349215b..f0576367b51 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -81,7 +81,7 @@ class MyObject extends CommonObject 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200'), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Amount'), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 515768b8011..80ccc893bf2 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -280,6 +280,7 @@ if ($action == 'create') print $langs->trans($val['label']); print ''; print ''; + $defaultcss='minwidth100'; if ($val['type'] == 'text') { print ''; } elseif (is_array($val['arrayofkeyval'])) @@ -344,12 +348,16 @@ if (($id || $ref) && $action == 'edit') } else { - $cssforinput = 'minwidth100'; - print ''; + $cssforinput = empty($val['css'])?$defaultcss:$val['css']; + print ''; } print ''; print ''; } + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + print ''; dol_fiche_end(); @@ -361,9 +369,6 @@ if (($id || $ref) && $action == 'edit') print ''; } - - - // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { @@ -469,7 +474,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($val['notnull'] > 0) print ' fieldrequired'; print '"'; print '>'.$langs->trans($val['label']).''; - print ''; + print ''; + print $object->$key; + print ''; print ''; } @@ -512,6 +519,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; } + /* + if ($user->rights->sellyoursaas->create) + { + if ($object->status == 1) + { + print ''."\n"; + } + else + { + print ''."\n"; + } + } + */ + if ($user->rights->mymodule->delete) { print ''."\n"; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 475716114fa..5677ab3baf2 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -130,7 +130,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index a8ce9c404e6..4861fe83ff6 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -100,7 +100,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 7d2b1a22b68..71bbee0a016 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -183,7 +183,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 567d60911ae..6c282f12101 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -114,7 +114,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 657e6d610d3..560853ac1c9 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -137,7 +137,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index c730fd074d5..f2da27ea56f 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -127,7 +127,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index b3bbccfcb4e..85e05c41f96 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -622,7 +622,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 5009a668ba3..4f8b5513016 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -197,7 +197,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 7ad6c0d1b82..013ad832898 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -157,7 +157,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 04bbbcf8b81..47b8bb4879e 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -105,7 +105,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } From 9654c4f16856527eacb8c801e0cb4618a205bc44 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Sep 2017 13:29:48 +0200 Subject: [PATCH 093/428] New extrafields are visible into list by default --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_extrafields.sql | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index e1af6e30de5..a34b5e8cab6 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -264,6 +264,8 @@ ALTER TABLE llx_extrafields ADD COLUMN tms timestamp; -- We fix value of 'list' fro m0 to 1 for all extrafields created before this migration UPDATE llx_extrafields SET list = 1 WHERE list = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL; +ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1; +--VPGSQL8.2 ALTER TABLE llx_extrafields ALTER COLUMN list SET DEFAULT 1; ALTER TABLE llx_extrafields MODIFY COLUMN langs varchar(64); diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index 3b9a9b2d72b..548508d451d 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -34,7 +34,7 @@ create table llx_extrafields pos integer DEFAULT 0, alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status param text, -- extra parameters to define possible values of field - list integer DEFAULT 0, -- list of values for field that are combo lists + list integer DEFAULT 1, -- list of values for field that are combo lists langs varchar(64), -- example: fileofmymodule@mymodule ishidden integer DEFAULT 0, -- Can be foreign key of external system fk_user_author integer, -- user making creation From abc86d72f645986faab1fd2a072fe173a1aa9fa1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Sep 2017 13:41:59 +0200 Subject: [PATCH 094/428] Module builder --- htdocs/modulebuilder/template/myobject_card.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 80ccc893bf2..c30ac858ec8 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -166,8 +166,9 @@ if (empty($reshook)) { foreach ($object->fields as $key => $val) { + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields + $object->$key=GETPOST($key,'alpha'); - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; if ($val['notnull'] > 0 && $object->$key == '') { $error++; @@ -328,6 +329,7 @@ if (($id || $ref) && $action == 'edit') foreach($object->fields as $key => $val) { if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; + print ''.$langs->trans($val['label']).''; From 9490e13c21590cdd1c7a224f4ee05571c63d11a1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 29 Sep 2017 14:52:05 +0200 Subject: [PATCH 095/428] Fix: command not found with escapeshellarg ! --- htdocs/core/class/antivir.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index 357f184eea8..7fa7d866489 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -63,9 +63,9 @@ class AntiVir if (preg_match('/\.virus$/i', $file)) { $this->errors='File has an extension saying file is a virus'; - return -97; + return -97; } - + $fullcommand=$this->getCliCommand($file); //$fullcommand='"c:\Program Files (x86)\ClamWin\bin\clamscan.exe" --database="C:\Program Files (x86)\ClamWin\lib" "c:\temp\aaa.txt"'; $fullcommand.=' 2>&1'; // This is to get error output @@ -160,7 +160,8 @@ class AntiVir if (! preg_match('/%file/',$conf->global->MAIN_ANTIVIRUS_PARAM)) $param=$param." ".escapeshellarg(trim($file)); - if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command. Using escapeshellcmd fails. + //if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command. Using escapeshellcmd fails. + if (preg_match("/\s/",$command)) $command=escapeshellcmd($command); // Use quotes on command. Using escapeshellarg fails. $ret=$command.' '.$param; //$ret=$command.' '.$param.' 2>&1'; From d2d77d46257685ea23b5755e3234e61e5a1fa940 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Sep 2017 15:19:49 +0200 Subject: [PATCH 096/428] Module builder --- .../tpl/document_actions_post_headers.tpl.php | 2 +- .../modulebuilder/template/myobject_card.php | 32 ++++++++++++++++--- .../template/myobject_document.php | 16 +++++++--- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index e613c479ee0..da1cb9658a0 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -79,7 +79,7 @@ $formfile->form_attach_new_file( ); $disablemove=1; -if ($modulepart == 'produit') $disablemove=0; +if ($modulepart == 'product' || $modulepart == 'produit') $disablemove=0; // Drag and drop for up and down allowed on product // List of document $formfile->list_of_documents( diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index c30ac858ec8..335823cc88b 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -478,13 +478,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '"'; print '>'.$langs->trans($val['label']).''; print ''; - print $object->$key; + print dol_escape_htmltag($object->$key, 1, 1); print ''; print ''; - } - // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + //if ($key == 'targetsrcfile3') break; // key used for break on second column + } print ''; print '
'; @@ -493,7 +492,30 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print ''; - // ... + $alreadyoutput = 1; + foreach($object->fields as $key => $val) + { + if ($alreadyoutput) + { + //if ($key == 'targetsrcfile3') $alreadyoutput = 0; // key used for break on second column + continue; + } + + if (in_array($key, array('rowid', 'ref', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue; + + print ''.$langs->trans($val['label']).''; + print ''; + print ''; + } + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'; + print dol_escape_htmltag($object->$key, 1, 1); + print '
'; print '
'; diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 0f8ce367bb5..05b76b3d588 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -79,7 +79,9 @@ $extralabels = $extrafields->fetch_name_optionals_label('myobject'); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id; + +//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/packages/" . dol_sanitizeFileName($object->id); +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/packages/" . dol_sanitizeFileName($object->ref); @@ -167,10 +169,16 @@ if ($object->id) dol_fiche_end(); - $modulepart = 'societe'; - $permission = $user->rights->societe->creer; - $permtoedit = $user->rights->societe->creer; + $modulepart = 'mymodule'; + //$permission = $user->rights->mymodule->create; + $permission = 1; + //$permtoedit = $user->rights->mymodule->create; + $permtoedit = 1; $param = '&id=' . $object->id; + + //$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->ref).'/'; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } else From b50a0df6fb5227571bec26d74061035ede775adf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Sep 2017 15:44:43 +0200 Subject: [PATCH 097/428] Tab notes and linked files supported by module builder --- .../template/class/myobject.class.php | 2 ++ .../template/lib/myobject.lib.php | 23 +++++++++++++++---- .../modulebuilder/template/myobject_card.php | 4 ++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f0576367b51..e91a9751b60 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -83,6 +83,8 @@ class MyObject extends CommonObject 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'index'=>1, 'position'=>20), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200'), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Amount'), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>45), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>46), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>500), diff --git a/htdocs/modulebuilder/template/lib/myobject.lib.php b/htdocs/modulebuilder/template/lib/myobject.lib.php index 25f85052133..5ce7c4f7c97 100644 --- a/htdocs/modulebuilder/template/lib/myobject.lib.php +++ b/htdocs/modulebuilder/template/lib/myobject.lib.php @@ -29,7 +29,7 @@ */ function myobjectPrepareHead($object) { - global $langs, $conf; + global $db, $langs, $conf; $langs->load("mymodule@mymodule"); @@ -40,17 +40,30 @@ function myobjectPrepareHead($object) $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; - if (isset($object->fields['note_public']) || isset($object->fields['note_pricate'])) + + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { - $head[$h][0] = dol_buildpath("/mymodule/myobject_note.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Notes"); + $nbNote = 0; + if(!empty($object->fields['note_private'])) $nbNote++; + if(!empty($object->fields['note_public'])) $nbNote++; + $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; $head[$h][2] = 'note'; $h++; } + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->mymodule->dir_output . "/myobject/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); + $nbLinks=Link::count($db, $object->element, $object->id); $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Documents"); + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; $head[$h][2] = 'document'; $h++; + $head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id; $head[$h][1] = $langs->trans("Events"); $head[$h][2] = 'agenda'; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 335823cc88b..4160b2045fd 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -470,7 +470,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea foreach($object->fields as $key => $val) { - if (in_array($key, array('rowid', 'ref', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue; + if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue; print ' Date: Fri, 29 Sep 2017 16:03:05 +0200 Subject: [PATCH 098/428] Fix: wrong contante value --- htdocs/adherents/admin/adherent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 93b90c01c92..d96f2cd0888 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -162,7 +162,7 @@ print "\n"; // Login/Pass required for members print ''.$langs->trans("AdherentLoginRequired").''; -print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED',(! empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)?0:1),1); +print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED',(! empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)?$conf->global->ADHERENT_LOGIN_NOT_REQUIRED:0),1); print "\n"; // Mail required for members From 7134884a08e724948bc080423f785b37b94634a7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 29 Sep 2017 16:57:25 +0200 Subject: [PATCH 099/428] Revert "Fix: wrong contante value" This reverts commit ffc4f5021af5855283b84a636e3c85c5841a0bbb. --- htdocs/adherents/admin/adherent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index d96f2cd0888..93b90c01c92 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -162,7 +162,7 @@ print "\n"; // Login/Pass required for members print ''.$langs->trans("AdherentLoginRequired").''; -print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED',(! empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)?$conf->global->ADHERENT_LOGIN_NOT_REQUIRED:0),1); +print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED',(! empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)?0:1),1); print "\n"; // Mail required for members From 02f069713ebc1c031d8f26a00250cfdda7104cea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Sep 2017 17:43:32 +0200 Subject: [PATCH 100/428] Standardize code --- htdocs/core/tpl/notes.tpl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 45e7dc32697..0d1a0a79339 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -17,15 +17,15 @@ * along with this program. If not, see . */ -// $permission must be defined by caller. -// $cssclass must be defined by caller. For example cssclass='fieldtitle" +// $permissionnote must be defined by caller. For example $permissionnote=$user->rights->module->create +// $cssclass must be defined by caller. For example $cssclass='fieldtitle" $module = $object->element; $note_public = 'note_public'; $note_private = 'note_private'; $colwidth=(isset($colwidth)?$colwidth:(empty($cssclass)?'25':'')); - -$permission=(isset($permission)?$permission:(isset($user->rights->$module->creer)?$user->rights->$module->creer:0)); // If already defined by caller page +// Set $permission from the $permissionnote var defined on calling page +$permission=(isset($permissionnote)?$permissionnote:(isset($permission)?$permission:(isset($user->rights->$module->create)?$user->rights->$module->create:(isset($user->rights->$module->creer)?$user->rights->$module->creer:0)))); $moreparam=(isset($moreparam)?$moreparam:''); $value_public=$object->note_public; $value_private=$object->note_private; From 4a63e6b6ec256e3ff4bb7ea0c9773a3e8f0d12ee Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 29 Sep 2017 19:07:13 +0200 Subject: [PATCH 101/428] Fix: two errors when you create invoice from shipping --- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/install/mysql/data/llx_c_type_contact.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6c73746d9af..3c4bfec6a45 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -486,7 +486,7 @@ class Facture extends CommonInvoice foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; - $originidforcontact = $value->id; + $originidforcontact = $value; break; // We take first one } } diff --git a/htdocs/install/mysql/data/llx_c_type_contact.sql b/htdocs/install/mysql/data/llx_c_type_contact.sql index a0b36634ce1..ce51eb20ca5 100644 --- a/htdocs/install/mysql/data/llx_c_type_contact.sql +++ b/htdocs/install/mysql/data/llx_c_type_contact.sql @@ -43,6 +43,7 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (60, 'facture', 'external', 'BILLING', 'Contact client facturation', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'SHIPPING', 'Contact client livraison', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (62, 'facture', 'external', 'SERVICE', 'Contact client prestation', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (63, 'facture', 'external', 'CUSTOMER', 'Contact client suivi facturation', 1) insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (70, 'invoice_supplier', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (71, 'invoice_supplier', 'external', 'BILLING', 'Contact fournisseur facturation', 1); From 0e15aef44f15c07a9800993916c487e9c1b34ac0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Sep 2017 00:30:58 +0200 Subject: [PATCH 102/428] CSS --- htdocs/comm/action/card.php | 9 ++++----- htdocs/comm/action/document.php | 9 ++++----- htdocs/comm/action/info.php | 11 ++++++----- htdocs/core/class/html.form.class.php | 2 +- htdocs/resource/element_resource.php | 9 ++++----- htdocs/theme/eldy/style.css.php | 9 +++++---- htdocs/theme/md/style.css.php | 3 +++ 7 files changed, 27 insertions(+), 25 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 78e580a4318..c8b92acd5fc 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1202,14 +1202,13 @@ if ($id > 0) // Link to other agenda views $out=''; - $out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); + $out.='
  • '.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewPerUser").''; - $out.='
    '; - $out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); + $out.='
  • '.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewCal").''; - $out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); + $out.='
  • '.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewWeek").''; - $out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); + $out.='
  • '.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewDay").''; $linkback.=$out; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 1e54db9d449..68a36844e39 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -128,14 +128,13 @@ if ($object->id > 0) // Link to other agenda views $out=''; - $out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); + $out.='
  • '.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewPerUser").''; - $out.='
    '; - $out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); + $out.='
  • '.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewCal").''; - $out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); + $out.='
  • '.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewWeek").''; - $out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); + $out.='
  • '.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewDay").''; $linkback.=$out; diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 7bee5550453..9bcf1d2b9cd 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -51,6 +51,8 @@ $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions| * View */ +$form=new Form($db); + $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('',$langs->trans("Agenda"),$help_url); @@ -66,14 +68,13 @@ $linkback.= ''.$langs->trans("B // Link to other agenda views $out=''; -$out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); +$out.='
  • '.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewPerUser").''; -$out.='
    '; -$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); +$out.='
  • '.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewCal").''; -$out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); +$out.='
  • '.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewWeek").''; -$out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); +$out.='
  • '.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewDay").''; $linkback.=$out; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8db18e2c748..f33ab83ee29 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5973,7 +5973,7 @@ class Form if ($previous_ref || $next_ref || $morehtml) { - $ret.=' '."\n"; // End div container + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print ' '."\n"; // End div container - if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent; + if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent; - // TODO Move this in lib_head.js.php + // TODO Move this in lib_head.js.php - // Wrapper to show tooltips (html or onclick popup) - if (! empty($conf->use_javascript_ajax) && empty($conf->dol_no_mouse_hover)) - { - print "\n\n"; - print '' . "\n"; - } + } - // Wrapper to manage document_preview - if (! empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone')) - { - print "\n\n"; - print '' . "\n"; - } + } - // Wrapper to manage dropdown - if (! empty($conf->use_javascript_ajax) && ! defined('JS_JQUERY_DISABLE_DROPDOWN')) - { - print "\n\n"; - print ''; - } + } - // Wrapper to add log when clicking on download or preview - if (! empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) - { - if (in_array($object->element, array('facture'))) // Restrict for the moment to element 'facture' - { - print "\n\n"; - ?> + // Wrapper to add log when clicking on download or preview + if (! empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) + { + if (in_array($object->element, array('facture'))) // Restrict for the moment to element 'facture' + { + print "\n\n"; + ?> \n"; print ''."\n"; - print "\n"; - print "\n"; - } + print "\n"; + print "\n"; + } } diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 5b5a10b598b..2affb8057e1 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -540,164 +540,164 @@ if ($socid && $action != 'edit' && $action != "create") print ' '.img_picto($langs->trans("SwiftValid"),'info'); } } - print ''; + print ''; - if (! empty($conf->prelevement->enabled)) - { - // RUM + if (! empty($conf->prelevement->enabled)) + { + // RUM //print ''.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).''; - print ''.$rib->rum.''; + print ''.$rib->rum.''; // FRSTRECUR print ''.$rib->frstrecur.''; - } + } - // Default - print ''; - if (!$rib->default_rib) { - print ''; - print img_picto($langs->trans("Disabled"),'off'); - print ''; - } else { - print img_picto($langs->trans("Enabled"),'on'); - } - print ''; + // Default + print ''; + if (!$rib->default_rib) { + print ''; + print img_picto($langs->trans("Disabled"),'off'); + print ''; + } else { + print img_picto($langs->trans("Enabled"),'on'); + } + print ''; - // Generate doc - print ''; + // Generate doc + print ''; - $buttonlabel = $langs->trans("BuildDoc"); - $forname='builddocrib'.$rib->id; + $buttonlabel = $langs->trans("BuildDoc"); + $forname='builddocrib'.$rib->id; - include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; - $modellist=ModeleBankAccountDoc::liste_modeles($db); + include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; + $modellist=ModeleBankAccountDoc::liste_modeles($db); - $out = ''; - if (is_array($modellist) && count($modellist)) - { - $out.= '
    '; - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ''; + $out = ''; + if (is_array($modellist) && count($modellist)) + { + $out.= ''; + $out.= ''; + $out.= ''; + $out.= ''; + $out.= ''; - if (is_array($modellist) && count($modellist) == 1) // If there is only one element - { - $arraykeys=array_keys($modellist); - $modelselected=$arraykeys[0]; - } - if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; + if (is_array($modellist) && count($modellist) == 1) // If there is only one element + { + $arraykeys=array_keys($modellist); + $modelselected=$arraykeys[0]; + } + if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; - $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); - $out.= ajax_combobox('modelrib'.$rib->id); + $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out.= ajax_combobox('modelrib'.$rib->id); - // Language code (if multilang) - if ($conf->global->MAIN_MULTILANGS) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin=new FormAdmin($db); - $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); - $morecss='maxwidth150'; - if (! empty($conf->browser->phone)) $morecss='maxwidth100'; - $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); - } - // Button - $genbutton = 'dol_no_mouse_hover) && $modulepart != 'unpaid') - { - $langs->load("errors"); - $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); - } - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; - $out.= $genbutton; - $out.= '
    '; - } - print $out; - print ''; + // Language code (if multilang) + if ($conf->global->MAIN_MULTILANGS) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin=new FormAdmin($db); + $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); + $morecss='maxwidth150'; + if (! empty($conf->browser->phone)) $morecss='maxwidth100'; + $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); + } + // Button + $genbutton = 'dol_no_mouse_hover) && $modulepart != 'unpaid') + { + $langs->load("errors"); + $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); + } + if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; + if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; + $out.= $genbutton; + $out.= ''; + } + print $out; + print ''; - // Edit/Delete - print ''; - if ($user->rights->societe->creer) - { - print ''; - print img_picto($langs->trans("Modify"),'edit'); - print ''; + // Edit/Delete + print ''; + if ($user->rights->societe->creer) + { + print ''; + print img_picto($langs->trans("Modify"),'edit'); + print ''; - print ' '; + print ' '; - print ''; - print img_picto($langs->trans("Delete"),'delete'); - print ''; - } - print ''; + print ''; + print img_picto($langs->trans("Delete"),'delete'); + print ''; + } + print ''; - print ''; - } + print ''; + } - if (count($rib_list) == 0) - { - $colspan=8; - if (! empty($conf->prelevement->enabled)) $colspan+=2; - print ''.$langs->trans("NoBANRecord").''; - } + if (count($rib_list) == 0) + { + $colspan=8; + if (! empty($conf->prelevement->enabled)) $colspan+=2; + print ''.$langs->trans("NoBANRecord").''; + } - print ''; - print ''; - } else { - dol_print_error($db); - } + print ''; + print ''; + } else { + dol_print_error($db); + } - dol_fiche_end(); + dol_fiche_end(); - if ($socid && $action != 'edit' && $action != 'create') - { - /* + if ($socid && $action != 'edit' && $action != 'create') + { + /* * Barre d'actions */ - print '
    '; + print '
    '; - if ($user->rights->societe->creer) - { - print ''.$langs->trans("Add").''; - } + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Add").''; + } - print '
    '; - } + print '
    '; + } - if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) - { - print '
    '; - print ''; // ancre + if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) + { + print '
    '; + print ''; // ancre - /* + /* * Documents generes */ - $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed=$user->rights->societe->creer; - $delallowed=$user->rights->societe->supprimer; + $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; + $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; + $genallowed=$user->rights->societe->creer; + $delallowed=$user->rights->societe->supprimer; - $var=true; + $var=true; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); - print '
    '; + print '
    '; - print '
    '; + print '
    '; - print '
    '; - } - /* + print '
    '; + } + /* include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; $modellist=ModeleBankAccountDoc::liste_modeles($db); //print ''; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index e76306fe983..145d16ef8b8 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -194,8 +194,8 @@ if (empty($reshook)) // Validation else if ($action == 'confirm_validate' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) ) { $result = $object->valid($user); @@ -258,7 +258,7 @@ if (empty($reshook)) if ($object->fetch(GETPOST('copie_supplier_proposal')) > 0) { $object->ref = GETPOST('ref'); $object->date_livraison = $date_delivery; - $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); + $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); @@ -279,7 +279,7 @@ if (empty($reshook)) $object->ref = GETPOST('ref'); $object->date_livraison = $date_delivery; $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); + $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); @@ -381,7 +381,7 @@ if (empty($reshook)) // Hooks $parameters = array('objFrom' => $srcobject); $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook + // modified by hook if ($reshook < 0) $error ++; } else { @@ -404,23 +404,23 @@ if (empty($reshook)) { $db->commit(); - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db,$result); - } + $ret = $object->fetch($id); // Reload to get new records + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); + } header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); exit(); @@ -451,8 +451,8 @@ if (empty($reshook)) // Close proposal else if ($action == 'close' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel','alpha')) { - // prevent browser refresh from reopening proposal several times - if ($object->statut == SupplierProposal::STATUS_SIGNED) { + // prevent browser refresh from reopening proposal several times + if ($object->statut == SupplierProposal::STATUS_SIGNED) { $object->setStatut(SupplierProposal::STATUS_CLOSE); } } @@ -465,7 +465,7 @@ if (empty($reshook)) } else { // prevent browser refresh from closing proposal several times if ($object->statut == SupplierProposal::STATUS_VALIDATED) { - $object->cloture($user, GETPOST('statut'), GETPOST('note','none')); + $object->cloture($user, GETPOST('statut'), GETPOST('note','none')); } } } @@ -518,12 +518,12 @@ if (empty($reshook)) // Add a product line if ($action == 'addline' && $user->rights->supplier_proposal->creer) { - $langs->load('errors'); - $error = 0; + $langs->load('errors'); + $error = 0; // Set if we used free entry or predefined product - $predef=''; - $ref_fourn = GETPOST('fourn_ref'); + $predef=''; + $ref_fourn = GETPOST('fourn_ref'); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -583,117 +583,117 @@ if (empty($reshook)) // Ecrase $txtva par celui du produit if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { - $productsupplier = new ProductFournisseur($db); + $productsupplier = new ProductFournisseur($db); - if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) // TODO this test seems useless - { - $idprod=0; - if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) - } - if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg)) - { - $idprod=$reg[1]; - $res=$productsupplier->fetch($idprod); - // Call to init properties of $productsupplier - // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price - $productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist - } - elseif (GETPOST('idprodfournprice') > 0) - { - //$qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. - $qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist - $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qtytosearch); - $res=$productsupplier->fetch($idprod); - } + if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) // TODO this test seems useless + { + $idprod=0; + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + } + if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg)) + { + $idprod=$reg[1]; + $res=$productsupplier->fetch($idprod); + // Call to init properties of $productsupplier + // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price + $productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist + } + elseif (GETPOST('idprodfournprice') > 0) + { + //$qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. + $qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist + $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qtytosearch); + $res=$productsupplier->fetch($idprod); + } - if ($idprod > 0) - { - $pu_ht = $productsupplier->fourn_pu; - $price_base_type = $productsupplier->fourn_price_base_type; - $type = $productsupplier->type; - $label = $productsupplier->label; - $desc = $productsupplier->description; - if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); + if ($idprod > 0) + { + $pu_ht = $productsupplier->fourn_pu; + $price_base_type = $productsupplier->fourn_price_base_type; + $type = $productsupplier->type; + $label = $productsupplier->label; + $desc = $productsupplier->description; + if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); - $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); - if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); + if (empty($tva_tx)) $tva_npr=0; + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - $result=$object->addline( - $desc, - $pu_ht, - $qty, - $tva_tx, - $localtax1_tx, - $localtax2_tx, - $productsupplier->id, - $remise_percent, - $price_base_type, - $pu_ttc, - $tva_npr, - $type, - -1, - 0, - GETPOST('fk_parent_line'), - $fournprice, - $buyingprice, - $label, - $array_options, - $ref_fourn, - $fk_unit - ); - //var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit; - } - if ($idprod == -99 || $idprod == 0) - { - // Product not selected - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors'); - } - if ($idprod == -1) - { - // Quantity too low - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); - } + $result=$object->addline( + $desc, + $pu_ht, + $qty, + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $productsupplier->id, + $remise_percent, + $price_base_type, + $pu_ttc, + $tva_npr, + $type, + -1, + 0, + GETPOST('fk_parent_line'), + $fournprice, + $buyingprice, + $label, + $array_options, + $ref_fourn, + $fk_unit + ); + //var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit; + } + if ($idprod == -99 || $idprod == 0) + { + // Product not selected + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors'); + } + if ($idprod == -1) + { + // Quantity too low + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); + } } else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); - $fk_unit= GETPOST('units', 'alpha'); + $fk_unit= GETPOST('units', 'alpha'); - $tva_tx = price2num($tva_tx); // When vat is text input field + $tva_tx = price2num($tva_tx); // When vat is text input field - // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + // Local Taxes + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - if (GETPOST('price_ht')!=='') - { - $price_base_type = 'HT'; - $ht = price2num(GETPOST('price_ht')); - $ttc = 0; - } - else - { - $ttc = price2num(GETPOST('price_ttc')); - $ht = $ttc / (1 + ($tva_tx / 100)); - $price_base_type = 'HT'; - } + if (GETPOST('price_ht')!=='') + { + $price_base_type = 'HT'; + $ht = price2num(GETPOST('price_ht')); + $ttc = 0; + } + else + { + $ttc = price2num(GETPOST('price_ttc')); + $ht = $ttc / (1 + ($tva_tx / 100)); + $price_base_type = 'HT'; + } $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn, $fk_unit); - //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); + //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); } @@ -706,9 +706,9 @@ if (empty($reshook)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -716,7 +716,7 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db,$result); + if ($result < 0) dol_print_error($db,$result); } unset($_POST['prod_entry_mode']); @@ -729,7 +729,7 @@ if (empty($reshook)) unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); - unset($_POST['label']); + unset($_POST['label']); unset($_POST['product_ref']); unset($_POST['product_label']); unset($_POST['product_desc']); @@ -958,9 +958,9 @@ $now = dol_now(); // Add new askprice if ($action == 'create') { - $currency_code = $conf->currency; + $currency_code = $conf->currency; - print load_fiche_titre($langs->trans("NewAskPrice")); + print load_fiche_titre($langs->trans("NewAskPrice")); $soc = new Societe($db); if ($socid > 0) @@ -997,8 +997,8 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled)) { - if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; - if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } } else @@ -1036,7 +1036,7 @@ if ($action == 'create') } else { print ''; print $form->select_company('', 'socid', 's.fournisseur = 1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").''; print ''; } print '' . "\n"; @@ -1051,19 +1051,19 @@ if ($action == 'create') $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id'); print ''; - // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) { - print '' . $langs->trans('BankAccount') . ''; - $form->select_comptes(GETPOST('fk_account')>0 ? GETPOST('fk_account','int') : $fk_account, 'fk_account', 0, '', 1); - print ''; - } + // Bank Account + if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) { + print '' . $langs->trans('BankAccount') . ''; + $form->select_comptes(GETPOST('fk_account')>0 ? GETPOST('fk_account','int') : $fk_account, 'fk_account', 0, '', 1); + print ''; + } - // Shipping Method - if (! empty($conf->expedition->enabled)) { - print '' . $langs->trans('SendingMethod') . ''; - print $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : $shipping_method_id, 'shipping_method_id', '', 1); - print ''; - } + // Shipping Method + if (! empty($conf->expedition->enabled)) { + print '' . $langs->trans('SendingMethod') . ''; + print $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : $shipping_method_id, 'shipping_method_id', '', 1); + print ''; + } // Delivery date (or manufacturing) print '' . $langs->trans("DeliveryDate") . ''; @@ -1115,15 +1115,15 @@ if ($action == 'create') { print ''; print ''.fieldLabel('Currency','multicurrency_code').''; - print ''; - print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print ''; + print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print ''; } // Other attributes $parameters = array('colspan' => ' colspan="3"'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); } @@ -1181,7 +1181,7 @@ if ($action == 'create') if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) { - print '
    '; + print '
    '; // For backward compatibility print ''; @@ -1339,34 +1339,34 @@ if ($action == 'create') // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; - if ($user->rights->supplier_proposal->creer) - { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } + $langs->load("projects"); + $morehtmlref.='
    '.$langs->trans('Project') . ' '; + if ($user->rights->supplier_proposal->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } } $morehtmlref.=''; @@ -1468,17 +1468,17 @@ if ($action == 'create') print '
    '; print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if($action == 'actualizemulticurrencyrate') { + if($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); - } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print '
            '; - print ''.$langs->trans("ActualizeCurrency").''; - print '
    '; - } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print '
            '; + print ''.$langs->trans("ActualizeCurrency").''; + print '
    '; + } } print ''; } @@ -1498,22 +1498,22 @@ if ($action == 'create') if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) { - // Bank Account - print ''; - print ''; - if ($action != 'editbankaccount' && $user->rights->supplier_proposal->creer) - print ''; - print '
    '; - print $langs->trans('BankAccount'); - print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
    '; - print ''; - if ($action == 'editbankaccount') { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } else { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); - } - print ''; - print ''; + // Bank Account + print ''; + print ''; + if ($action != 'editbankaccount' && $user->rights->supplier_proposal->creer) + print ''; + print '
    '; + print $langs->trans('BankAccount'); + print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
    '; + print ''; + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print ''; + print ''; } // Other attributes @@ -1619,7 +1619,7 @@ if ($action == 'create') include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } - print '
    '; + print '
    '; print ''; // Add free products/services form @@ -1643,7 +1643,7 @@ if ($action == 'create') } print '
    '; - print '
    '; + print '
    '; print "\n"; dol_fiche_end(); @@ -1684,15 +1684,15 @@ if ($action == 'create') $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook + // modified by hook if (empty($reshook)) { if ($action != 'statut' && $action != 'editline') { // Validate if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) ) { if (count($object->lines) > 0) print ''; @@ -1733,8 +1733,8 @@ if ($action == 'create') // Close if ($object->statut == SupplierProposal::STATUS_SIGNED && $user->rights->supplier_proposal->cloturer) { - print ''; + print ''; } // Clone diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 4438812cc60..fa33f9bae43 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -313,7 +313,7 @@ if ($action == 'add') } */ - //$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + //$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '', $tmp); } $objectpage->htmlheader = trim($tmp); diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 7daf0dace88..a56c2be2055 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -32,7 +32,7 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { - echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit(-1); } @@ -116,10 +116,10 @@ if ($resql) $sql2 = "SELECT mc.rowid, mc.lastname as lastname, mc.firstname as firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; $sql2.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql2.= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id; - if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0) - { - $sql2.= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI; - } + if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0) + { + $sql2.= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI; + } $resql2=$db->query($sql2); if ($resql2) @@ -157,31 +157,31 @@ if ($resql) // Make subtsitutions on topic and body $other=explode(';',$obj2->other); $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); + $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); - $object = null; // Not defined with mass emailing - $parameters=array('mode'=>'emailing'); - $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'), $object); // Note: On mass emailing, this is null because we don't know object + $object = null; // Not defined with mass emailing + $parameters=array('mode'=>'emailing'); + $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'), $object); // Note: On mass emailing, this is null because we don't know object - // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) - $substitutionarray['__ID__'] = $obj->source_id; - $substitutionarray['__EMAIL__'] = $obj->email; - $substitutionarray['__LASTNAME__'] = $obj->lastname; - $substitutionarray['__FIRSTNAME__'] = $obj->firstname; - $substitutionarray['__MAILTOEMAIL__'] = ''.$obj->email.''; - $substitutionarray['__OTHER1__'] = $other1; - $substitutionarray['__OTHER2__'] = $other2; - $substitutionarray['__OTHER3__'] = $other3; - $substitutionarray['__OTHER4__'] = $other4; - $substitutionarray['__OTHER5__'] = $other5; - $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) + $substitutionarray['__ID__'] = $obj->source_id; + $substitutionarray['__EMAIL__'] = $obj->email; + $substitutionarray['__LASTNAME__'] = $obj->lastname; + $substitutionarray['__FIRSTNAME__'] = $obj->firstname; + $substitutionarray['__MAILTOEMAIL__'] = ''.$obj->email.''; + $substitutionarray['__OTHER1__'] = $other1; + $substitutionarray['__OTHER2__'] = $other2; + $substitutionarray['__OTHER3__'] = $other3; + $substitutionarray['__OTHER4__'] = $other4; + $substitutionarray['__OTHER5__'] = $other5; + $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility - $substitutionarray['__CHECK_READ__'] = ''; - $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; + $substitutionarray['__CHECK_READ__'] = ''; + $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; $onlinepaymentenabled = 0; if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; @@ -232,22 +232,22 @@ if ($resql) // Fabrication du mail $trackid='emailing-'.$obj2->source_type.$obj2->source_id; $mail = new CMailFile( - $newsubject, - $sendto, - $from, - $newmessage, - array(), - array(), - array(), - '', - '', - 0, - $msgishtml, - $errorsto, - '', - $trackid, - '', - 'emailing' + $newsubject, + $sendto, + $from, + $newmessage, + array(), + array(), + array(), + '', + '', + 0, + $msgishtml, + $errorsto, + '', + $trackid, + '', + 'emailing' ); if ($mail->error) @@ -314,7 +314,7 @@ if ($resql) $error++; } - //Update status communication of contact prospect + //Update status communication of contact prospect $sqlx = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj2->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("card.php: set prospect contact status", LOG_DEBUG); @@ -326,9 +326,9 @@ if ($resql) } } - if (!empty($conf->global->MAILING_DELAY)) { - sleep($conf->global->MAILING_DELAY); - } + if (!empty($conf->global->MAILING_DELAY)) { + sleep($conf->global->MAILING_DELAY); + } } } From afdc176f472aa67e667ca481f694c0a5006393ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Oct 2017 08:52:00 +0200 Subject: [PATCH 409/428] Fix scrutinizer --- htdocs/adherents/class/subscription.class.php | 2 +- htdocs/api/class/api_documents.class.php | 12 ++++++----- htdocs/blockedlog/class/blockedlog.class.php | 20 +++++++++---------- .../core/class/emailsenderprofile.class.php | 2 ++ htdocs/core/lib/files.lib.php | 2 +- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index bdb43dd41d3..397be6ee8da 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -216,7 +216,7 @@ class Subscription extends CommonObject $result=$member->fetch($this->fk_adherent); $result=$member->update_end_date($user); - if (is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) + if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) { $result=$accountline->delete($user); // Return false if refused because line is conciliated if ($result > 0) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 397910a6e2f..b47584eea99 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -130,18 +130,20 @@ class Documents extends DolibarrApi } /** - * Return the list of documents of an element + * Return the list of documents of a dedicated element (from its ID or Ref) * - * @param string $modulepart Name of module or area concerned ('facture', 'project', 'member', ...) - * @param int $id ID of element + * @param string $modulepart Name of module or area concerned ('facture', 'project', 'member', ...) + * @param int $id ID of element * @param string $ref Ref of element - * @return array Array of documents with path + * @param string $sortfield Sort criteria ('','fullname','relativename','name','date','size') + * @param string $sortorder Sort order ('asc' or 'desc') + * @return array Array of documents with path * * @throws RestException * * @url GET list */ - function getDocumentsListByElement($modulepart, $id=0, $ref='') + function getDocumentsListByElement($modulepart, $id=0, $ref='', $sortfield='', $sortorder='') { global $conf; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 8a1508b7a04..4bce16fb796 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -21,13 +21,15 @@ class BlockedLog { - /** * Id of the log * @var int */ public $id; + public $error = ''; + public $errors = array(); + /** * Unique fingerprint of the log * @var string @@ -78,7 +80,7 @@ class BlockedLog public $object_data = null; - public $error = 0; + /** * Constructor @@ -126,7 +128,7 @@ class BlockedLog /** * try to retrieve user author - */ + */ public function getUser() { global $langs, $cachedUser; @@ -188,8 +190,6 @@ class BlockedLog $this->object_data->amounts = $object->amounts; } - - } /** @@ -231,7 +231,7 @@ class BlockedLog $this->action = $obj->action; $this->element = $obj->element; - $this->fk_object = trim($obj->fk_object); + $this->fk_object = $obj->fk_object; $this->date_object = $this->db->jdate($obj->date_object); $this->ref_object = $obj->ref_object; @@ -432,10 +432,10 @@ class BlockedLog /** * return log object for a element. * - * @param string $element element to search - * @param int $fk_object id of object to search - * @param int $limit max number of element, 0 for all - * @param string $order sort of query + * @param string $element element to search + * @param int $fk_object id of object to search + * @param int $limit max number of element, 0 for all + * @param string $order sort of query * @return array array of object log */ public function getLog($element, $fk_object, $limit = 0, $order = -1) { diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 66e37744cc7..f779e949dc3 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -273,6 +273,8 @@ class EmailSenderProfile extends CommonObject $result = ''; $companylink = ''; + $label=$this->label; + $url=''; //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 44a404c6c67..2f59c7e388c 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -47,7 +47,7 @@ function dol_basename($pathfile) * @param string $filter Regex filter to restrict list. This regex value must be escaped for '/' by doing preg_quote($var,'/'), since this char is used for preg_match function, * but must not contains the start and end '/'. Filter is checked into basename only. * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked into fullpath. - * @param string $sortcriteria Sort criteria ("","fullname","relativename","name","date","size") + * @param string $sortcriteria Sort criteria ('','fullname','relativename','name','date','size') * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @param int $nohook Disable all hooks From 87814af7b6170f1501dba0a492a1bc8568a01ccf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Oct 2017 09:29:10 +0200 Subject: [PATCH 410/428] Move function colorIsLight into functions.lib.php Fix scrutinizer bugs. --- .../accountancy/class/bookkeeping.class.php | 21 +++++--- htdocs/adherents/class/adherent.class.php | 4 +- .../adherents/class/adherent_type.class.php | 2 +- htdocs/adherents/type.php | 4 +- htdocs/admin/mails_templates.php | 6 +-- htdocs/api/class/api_access.class.php | 4 +- htdocs/api/class/api_documents.class.php | 4 +- htdocs/cashdesk/class/Facturation.class.php | 53 ++++++++++--------- htdocs/categories/class/categorie.class.php | 17 ++---- htdocs/core/db/DoliDB.class.php | 8 +-- htdocs/core/lib/functions.lib.php | 34 ++++++++++++ htdocs/core/lib/functions2.lib.php | 34 ------------ 12 files changed, 99 insertions(+), 92 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 52f7a473bed..2d828298b51 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1079,22 +1079,26 @@ class BookKeeping extends CommonObject * @param string $mode Mode * @return number <0 if KO, >0 if OK */ - public function updateByMvt($piece_num='', $field='', $value='', $mode='') { + public function updateByMvt($piece_num='', $field='', $value='', $mode='') + { + $error=0; + $this->db->begin(); + $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab"; $sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'"); $sql .= ' WHERE ab.piece_num=' . $piece_num ; $resql = $this->db->query($sql); if (! $resql) { - $error ++; + $error++; $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -1521,11 +1525,16 @@ class BookKeeping extends CommonObject * @param string $piece_num Piece num * @return void */ - public function transformTransaction($direction=0,$piece_num='') { + public function transformTransaction($direction=0,$piece_num='') + { + $error = 0; + $this->db->begin(); - if ($direction==0) { + + if ($direction==0) + { $next_piecenum=$this->getNextNumMvt(); - if ($result < 0) { + if ($next_piecenum < 0) { $error++; } $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'(doc_date, doc_type,'; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c197d1a2362..33be4abb8e6 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1563,7 +1563,7 @@ class Adherent extends CommonObject * @param int $withpictoimg 0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) * @param int $maxlen length max label * @param string $option Page for link ('card', 'category', 'subscription', ...) - * @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref + * @param string $mode ''=Show firstname+lastname as label (using default order), 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL @@ -1574,6 +1574,8 @@ class Adherent extends CommonObject if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; + $notooltip=0; + $result=''; $label=''; $link=''; $linkstart=''; $linkend=''; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 99c343a1ff0..f65e363cef9 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -167,7 +167,7 @@ class AdherentType extends CommonObject $sql.= "libelle = '".$this->db->escape($this->label) ."',"; $sql.= "subscription = '".$this->db->escape($this->subscription)."',"; $sql.= "note = '".$this->db->escape($this->note)."',"; - $sql.= "vote = '".$this->db->escape($this->vote)."',"; + $sql.= "vote = ".(integer) $this->db->escape($this->vote).","; $sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; $sql.= " WHERE rowid =".$this->id; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index c9edce35f60..7eaefa6fc33 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -107,7 +107,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) $object->subscription = (int) trim($subscription); $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->vote = trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -160,7 +160,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object->subscription = (int) trim($subscription); $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->vote = trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 111084388ce..4e25e93084b 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1019,9 +1019,9 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } print ''; } - elseif ($context == 'add' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; - elseif ($context == 'edit' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; - elseif ($context == 'hide' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'edit' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'hide' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; else { $size=''; $class=''; $classtd=''; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index b2dcfefa49f..5848620f735 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -83,10 +83,10 @@ class DolibarrApiAccess implements iAuthenticate // api key can be provided in url with parameter api_key=xxx or ni header with header DOLAPIKEY:xxx $api_key = ''; - if (isset($_GET['api_key'])) + if (isset($_GET['api_key'])) // For backward compatibility { // TODO Add option to disable use of api key on url. Return errors if used. - $api_key = $_GET['api_key']; // For backward compatibility + $api_key = $_GET['api_key']; } if (isset($_GET['DOLAPIKEY'])) { diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index b47584eea99..92b48dfd0c6 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -256,9 +256,11 @@ class Documents extends DolibarrApi // Define $uploadir $object = null; - $entity = $user->entity; + $entity = DolibarrApiAccess::$user->entity; if ($ref) { + $tmpreldir=''; + if ($modulepart == 'facture' || $modulepart == 'invoice') { $modulepart='facture'; diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index b55524a874a..8bfd1d3082c 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -117,7 +117,7 @@ class Facturation } // Define part of HT, VAT, TTC - $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray); + $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; @@ -207,6 +207,9 @@ class Facturation $total_ht=0; $total_ttc=0; + $total_vat = 0; + $total_localtax1 = 0; + $total_localtax2 = 0; $tab=array(); $tab = $_SESSION['poscart']; @@ -309,7 +312,7 @@ class Facturation public function ref($aRef=null) { - if ( !$aRef ) + if (is_null($aRef)) { return $this->ref; } @@ -330,9 +333,9 @@ class Facturation * @param int $aQte Qty * @return int Qty */ - public function qte( $aQte=null ) + public function qte($aQte=null) { - if ( !$aQte ) + if (is_null($aQte)) { return $this->qte; } @@ -357,7 +360,7 @@ class Facturation public function stock($aStock=null) { - if ( !$aStock ) + if (is_null($aStock)) { return $this->stock; } @@ -381,7 +384,7 @@ class Facturation public function remisePercent($aRemisePercent=null) { - if ( !$aRemisePercent ) + if (is_null($aRemisePercent)) { return $this->remise_percent; } @@ -405,7 +408,7 @@ class Facturation public function montantRemise($aMontantRemise=null) { - if ( !$aMontantRemise ) { + if (is_null($aMontantRemise)) { return $this->montant_remise; @@ -427,10 +430,10 @@ class Facturation * @param int $aPrix Price * @return string Stock */ - public function prix ( $aPrix=null ) + public function prix($aPrix=null) { - if ( !$aPrix ) { + if (is_null($aPrix)) { return $this->prix; @@ -454,7 +457,7 @@ class Facturation */ public function tva($aTva=null) { - if ( !$aTva ) { + if (is_null($aTva)) { return $this->tva; @@ -478,7 +481,7 @@ class Facturation */ public function numInvoice($aNumFacture=null) { - if ( !$aNumFacture ) { + if (is_null($aNumFacture)) { return $this->num_facture; @@ -499,10 +502,10 @@ class Facturation * @param int $aModeReglement Payment mode * @return int Payment mode */ - public function getSetPaymentMode( $aModeReglement=null ) + public function getSetPaymentMode($aModeReglement=null) { - if ( !$aModeReglement ) { + if (is_null($aModeReglement)) { return $this->mode_reglement; @@ -524,10 +527,10 @@ class Facturation * @param int $aMontantEncaisse Amount * @return int Amount */ - public function montantEncaisse( $aMontantEncaisse=null ) + public function montantEncaisse($aMontantEncaisse=null) { - if ( !$aMontantEncaisse ) { + if (is_null($aMontantEncaisse)) { return $this->montant_encaisse; @@ -549,10 +552,10 @@ class Facturation * @param int $aMontantRendu Amount * @return int Amount */ - public function montantRendu( $aMontantRendu=null ) + public function montantRendu($aMontantRendu=null) { - if ( !$aMontantRendu ) { + if (is_null($aMontantRendu)) { return $this->montant_rendu; } else if ( $aMontantRendu == 'RESET' ) { @@ -573,9 +576,9 @@ class Facturation * @param date $aPaiementLe Date * @return date Date */ - public function paiementLe( $aPaiementLe=null ) + public function paiementLe($aPaiementLe=null) { - if ( !$aPaiementLe ) { + if (is_null($aPaiementLe)) { return $this->paiement_le; @@ -596,9 +599,9 @@ class Facturation * @param int $aTotalHt Total amount * @return int Total amount */ - public function prixTotalHt( $aTotalHt=null ) + public function prixTotalHt($aTotalHt=null) { - if ( !$aTotalHt ) { + if (is_null($aTotalHt)) { return $this->prix_total_ht; @@ -619,9 +622,9 @@ class Facturation * @param int $aMontantTva Amount vat * @return int Amount vat */ - public function montantTva( $aMontantTva=null ) + public function montantTva($aMontantTva=null) { - if ( !$aMontantTva ) { + if (is_null($aMontantTva)) { return $this->montant_tva; @@ -643,9 +646,9 @@ class Facturation * @param int $aTotalTtc Amount ttc * @return int Amount ttc */ - public function prixTotalTtc( $aTotalTtc=null ) + public function prixTotalTtc($aTotalTtc=null) { - if ( !$aTotalTtc ) + if (is_null($aTotalTtc)) { return $this->prix_total_ttc; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6242691d1f1..7a7a6f06a1f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -163,7 +163,7 @@ class Categorie extends CommonObject */ public $socid; /** - * @var int Category type + * @var string Category type * * @see Categorie::TYPE_PRODUCT * @see Categorie::TYPE_SUPPLIER @@ -1327,6 +1327,7 @@ class Categorie extends CommonObject { $w = array(); $i = 0; + $forced_color=''; foreach ($way as $cat) { $i++; @@ -1340,12 +1341,7 @@ class Categorie extends CommonObject $forced_color='categtextwhite'; if ($cat->color) { - $hex=$cat->color; - $r = hexdec($hex[0].$hex[1]); - $g = hexdec($hex[2].$hex[3]); - $b = hexdec($hex[4].$hex[5]); - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60% + if (colorIsLight($cat->color)) $forced_color='categtextblack'; } } } @@ -1602,12 +1598,7 @@ class Categorie extends CommonObject $forced_color='categtextwhite'; if ($this->color) { - $hex=$this->color; - $r = hexdec($hex[0].$hex[1]); - $g = hexdec($hex[2].$hex[3]); - $b = hexdec($hex[4].$hex[5]); - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60% + if (colorIsLight($this->color)) $forced_color='categtextblack'; } $link = ''; diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 9fc1739334c..99b799d5d6e 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -59,7 +59,7 @@ abstract class DoliDB implements Database public $lastqueryerror; /** @var string Last error message */ public $lasterror; - /** @var int Last error number */ + /** @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... */ public $lasterrno; /** @var bool Status */ @@ -238,16 +238,16 @@ abstract class DoliDB implements Database else $return.=', '; $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); - + $tmpsortorder = trim($orders[$i]); - + // Only ASC and DESC values are valid SQL if (strtoupper($tmpsortorder) === 'ASC') { $return .= ' ASC'; } elseif (strtoupper($tmpsortorder) === 'DESC') { $return .= ' DESC'; } - + $i++; } return $return; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f56cd2f523d..2626e917460 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6791,3 +6791,37 @@ function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield=' return ''; } } + +/** + * Return true if the color is light + * + * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') + * @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light + */ +function colorIsLight($stringcolor) +{ + $res = -1; + if (!empty($stringcolor)) + { + $res = 0; + $tmp=explode(',', $stringcolor); + if (count($tmp) > 1) // This is a comma RGB ('255','255','255') + { + $r = $tmp[0]; + $g = $tmp[1]; + $b = $tmp[2]; + } + else + { + $hexr=$stringcolor[0].$stringcolor[1]; + $hexg=$stringcolor[2].$stringcolor[3]; + $hexb=$stringcolor[4].$stringcolor[5]; + $r = hexdec($hexr); + $g = hexdec($hexg); + $b = hexdec($hexb); + } + $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm + if ($bright > 0.6) $res = 1; + } + return $res; +} diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 3d2e2bb359b..98d113525c1 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2153,40 +2153,6 @@ function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); } -/** - * Return true if the color is light - * - * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') - * @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light - */ -function colorIsLight($stringcolor) -{ - $res = -1; - if (!empty($stringcolor)) - { - $res = 0; - $tmp=explode(',', $stringcolor); - if (count($tmp) > 1) // This is a comma RGB ('255','255','255') - { - $r = $tmp[0]; - $g = $tmp[1]; - $b = $tmp[2]; - } - else - { - $hexr=$stringcolor[0].$stringcolor[1]; - $hexg=$stringcolor[2].$stringcolor[3]; - $hexb=$stringcolor[4].$stringcolor[5]; - $r = hexdec($hexr); - $g = hexdec($hexg); - $b = hexdec($hexb); - } - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright > 0.6) $res = 1; - } - return $res; -} - /** * Applies the Cartesian product algorithm to an array * Source: http://stackoverflow.com/a/15973172 From 82348cc1e9edb703e0d0be293f9f489c8fbb31e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Oct 2017 10:17:57 +0200 Subject: [PATCH 411/428] NEW Can filter on date on the page showing existing bindings --- htdocs/accountancy/customer/lines.php | 31 +++++++++++++++++++- htdocs/accountancy/customer/list.php | 1 + htdocs/accountancy/expensereport/lines.php | 33 +++++++++++++++++++++- htdocs/accountancy/expensereport/list.php | 1 + htdocs/accountancy/supplier/lines.php | 33 +++++++++++++++++++++- htdocs/accountancy/supplier/list.php | 1 + 6 files changed, 97 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 0e3e71c1527..13602160c48 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.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 . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("bills"); @@ -51,6 +53,9 @@ $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_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); @@ -95,6 +100,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; $search_country = ''; $search_tvaintra = ''; } @@ -131,6 +139,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { */ $form = new Form($db); +$formother = new FormOther($db); llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched")); @@ -197,6 +206,19 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("fd.tva_tx", $search_vat); } +if ($search_month > 0) +{ + if ($search_year > 0 && empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; + else if ($search_year > 0 && ! empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; + else + $sql.= " AND date_format(f.datef, '%m') = '".$db->escape($search_month)."'"; +} +else if ($search_year > 0) +{ + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; +} if (strlen(trim($search_country))) { $sql .= natural_search("co.label", $search_country); } @@ -237,6 +259,9 @@ if ($result) { $param .= "&search_account=" . $search_account; if ($search_vat) $param .= "&search_vat=" . $search_vat; + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year='.urlencode($search_year); if ($search_country) $param .= "&search_country=" . $search_country; if ($search_tvaintra) @@ -267,7 +292,11 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year,'search_year',1, 20, 5); + print ''; print ''; //print ''; print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 51f62ecabf6..2d26a2d06d8 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -115,6 +115,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; $search_month = ''; $search_year = ''; } diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 156d80f09e4..750a5bc9f25 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("compta"); @@ -50,6 +52,9 @@ $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_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); @@ -90,6 +95,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -123,6 +131,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { * View */ +$form = new Form($db); +$formother = new FormOther($db); + llxHeader('', $langs->trans("ExpenseReportsVentilation") . ' - ' . $langs->trans("Dispatched")); print ''."\n"; - $out .= ' '."\n"; + $out .= ' '."\n"; } return $out; } + /** * Returns the rights used for this class * @return stdClass diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 2ea2447f5bc..7130287b6bd 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -806,13 +806,13 @@ class ExtraFields * @param string $key Key of attribute * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) * @param string $moreparam To add more parametes on html input tag - * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @param mixed $showsize Value for css to define size. May also be a numeric. * @param int $objectid Current object id * @return string */ - function showInputField($key, $value, $moreparam='', $keyprefix='', $keysuffix='', $showsize=0, $objectid=0) + function showInputField($key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0, $objectid=0) { global $conf,$langs; @@ -831,51 +831,51 @@ class ExtraFields if ($computed) { - if ($keysuffix != 'search_') return ''.$langs->trans("AutomaticallyCalculated").''; - else return ''; + if ($keyprefix != 'search_') return ''.$langs->trans("AutomaticallyCalculated").''; + else return ''; } if (empty($showsize)) { - if ($type == 'date') - { - //$showsize=10; - $showsize = 'minwidth100imp'; - } + if ($type == 'date') + { + //$showsize=10; + $showsize = 'minwidth100imp'; + } elseif ($type == 'datetime') - { - //$showsize=19; - $showsize = 'minwidth200imp'; - } - elseif (in_array($type,array('int','double','price'))) - { - //$showsize=10; - $showsize = 'maxwidth75'; - } - elseif ($type == 'url') - { - $showsize='minwidth400'; - } - elseif ($type == 'boolean') - { - $showsize=''; - } - else - { - if (round($size) < 12) - { - $showsize = 'minwidth100'; - } - else if (round($size) <= 48) - { - $showsize = 'minwidth200'; - } - else - { - //$showsize=48; - $showsize = 'minwidth400'; - } - } + { + //$showsize=19; + $showsize = 'minwidth200imp'; + } + elseif (in_array($type,array('int','double','price'))) + { + //$showsize=10; + $showsize = 'maxwidth75'; + } + elseif ($type == 'url') + { + $showsize='minwidth400'; + } + elseif ($type == 'boolean') + { + $showsize=''; + } + else + { + if (round($size) < 12) + { + $showsize = 'minwidth100'; + } + else if (round($size) <= 48) + { + $showsize = 'minwidth200'; + } + else + { + //$showsize=48; + $showsize = 'minwidth400'; + } + } } if (in_array($type,array('date','datetime'))) @@ -893,26 +893,26 @@ class ExtraFields if (! is_object($form)) $form=new Form($this->db); // TODO Must also support $moreparam - $out = $form->select_date($value, $keysuffix.'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, ($keysuffix != 'search_' ? 1 : 0), 1, 0, 1); + $out = $form->select_date($value, $keyprefix.'options_'.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1); } elseif (in_array($type,array('int'))) { $tmp=explode(',',$size); $newsize=$tmp[0]; - $out=''; + $out=''; } elseif ($type == 'varchar') { - $out=''; + $out=''; } elseif (in_array($type, array('mail', 'phone', 'url'))) { - $out=''; + $out=''; } elseif ($type == 'text') { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keysuffix.'options_'.$key.$keyprefix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); + $doleditor=new DolEditor($keyprefix.'options_'.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); $out=$doleditor->Create(1); } elseif ($type == 'boolean') @@ -923,21 +923,21 @@ class ExtraFields } else { $checked=' value="1" '; } - $out=''; + $out=''; } elseif ($type == 'price') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } - $out=' '.$langs->getCurrencySymbol($conf->currency); + $out=' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } - $out=' '; + $out=' '; } elseif ($type == 'select') { @@ -945,10 +945,10 @@ class ExtraFields if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($keysuffix.'options_'.$key.$keyprefix, array(), 0); + $out.= ajax_combobox($keyprefix.'options_'.$key.$keysuffix, array(), 0); } - $out.=''; $out.=''; foreach ($param['options'] as $key => $val) { @@ -967,10 +967,10 @@ class ExtraFields if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($keysuffix.'options_'.$key.$keyprefix, array(), 0); + $out.= ajax_combobox($keyprefix.'options_'.$key.$keysuffix, array(), 0); } - $out.=''; if (is_array($param['options'])) { $param_list=array_keys($param['options']); @@ -1132,7 +1132,7 @@ class ExtraFields $form = new Form($db); $value_arr=explode(',',$value); - $out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); + $out=$form->multiselectarray($keyprefix.'options_'.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); } elseif ($type == 'radio') @@ -1140,11 +1140,11 @@ class ExtraFields $out=''; foreach ($param['options'] as $keyopt => $val) { - $out.=''.$val.'
    '; + $out.='/>
    '; } } elseif ($type == 'chkbxlst') @@ -1268,15 +1268,15 @@ class ExtraFields if (empty($labeltoshow)) $labeltoshow = '(not defined)'; - if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + $data[$obj->rowid]=$labeltoshow; + } + + if (! empty($InfoFieldList[3])) { + $parent = $parentName . ':' . $obj->{$parentField}; + } + $data[$obj->rowid]=$labeltoshow; - } - - if (! empty($InfoFieldList[3])) { - $parent = $parentName . ':' . $obj->{$parentField}; - } - - $data[$obj->rowid]=$labeltoshow; } $i ++; @@ -1286,7 +1286,7 @@ class ExtraFields require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $form = new Form($db); - $out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, $data, $value_arr, '', 0, '', 0, '100%'); + $out=$form->multiselectarray($keyprefix.'options_'.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); } else { print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
    '; @@ -1305,40 +1305,41 @@ class ExtraFields dol_include_once($InfoFieldList[1]); if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) { - $valuetoshow=$value; - if (!empty($value)) - { - $object = new $InfoFieldList[0]($this->db); - $resfetch=$object->fetch($value); - if ($resfetch > 0) - { - $valuetoshow=$object->ref; - if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique) - } - } - $out.=''; + $valuetoshow=$value; + if (!empty($value)) + { + $object = new $InfoFieldList[0]($this->db); + $resfetch=$object->fetch($value); + if ($resfetch > 0) + { + $valuetoshow=$object->ref; + if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique) + } + } + $out.=''; } else { - dol_syslog('Error bad setup of extrafield', LOG_WARNING); - $out.='Error bad setup of extrafield'; + dol_syslog('Error bad setup of extrafield', LOG_WARNING); + $out.='Error bad setup of extrafield'; } } elseif ($type == 'password') { // If prefix is 'search_', field is used as a filter, we use a common text field. - $out=''; + $out=''; } if (!empty($hidden)) { - $out=''; + $out=''; } /* Add comments if ($type == 'date') $out.=' (YYYY-MM-DD)'; - elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; - */ + elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; + */ return $out; } + /** * Return HTML string to put an output field into a page * From 51ce8bf2a5741ae0bcca4b76e4d1f5ce96d1010e Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 16 Oct 2017 21:08:09 +0200 Subject: [PATCH 421/428] js --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a07a95f1e6d..d33dca39ee1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4713,7 +4713,7 @@ abstract class CommonObject } $out .= "\n"; // Add code to manage list depending on others - if (! empty($conf->use_javascript_ajax)) + if (! empty($conf->use_javascript_ajax)) { $out .= ' '."\n"; $out .= ' '."\n"; + } } return $out; } From 23e2c95af685641ec5fc06c186edffabba9c4112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 16 Oct 2017 21:22:13 +0200 Subject: [PATCH 422/428] enhance admin translation --- htdocs/admin/translation.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index e2d2db9e659..1b2a52466e5 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -1,6 +1,7 @@ * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2017 Frédéric France * * 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 @@ -170,7 +171,7 @@ if ($action == 'add') else { setEventMessages($db->lasterror(), null, 'errors'); - } + } $action=''; } } @@ -291,9 +292,9 @@ if ($mode == 'overwrite') print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit?1:0, 'maxwidthonsmartphone', 1); print ''."\n"; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; // Limit to superadmin /*if (! empty($conf->multicompany->enabled) && !$user->entity) @@ -483,7 +484,7 @@ if ($mode == 'searchkey') //} print ''; // Action column - print ''; + print ''; $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); print $searchpicto; print ''; @@ -508,9 +509,28 @@ if ($mode == 'searchkey') { if ($val != $newlangfileonly->tab_translate[$key]) { + // retrieve rowid + $sql = "SELECT rowid"; + $sql.= " FROM " . MAIN_DB_PREFIX . "overwrite_trans"; + $sql.= " WHERE transkey = '".$key."'"; + $sql.= " AND entity IN (" . $user->entity . ", " . $conf->entity . ")"; + dol_syslog("translation::select from table", LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + $obj = $db->fetch_object($result); + } + print '
    ' . img_edit() . ''; + print '  '; + print '' . img_delete() . ''; + print '  '; $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); print $form->textwithpicto('', $htmltext, 1, 'info'); } + else if (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) + { + print '' . img_edit() . ''; + } } else { From 082d59439f6de18bd0e09a48ecd121ed0972dc13 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Oct 2017 10:43:37 +0200 Subject: [PATCH 423/428] Fix add missing seconds when adding event so sort order on date is ok --- htdocs/comm/action/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c8b92acd5fc..0cfa31e12c8 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -199,8 +199,8 @@ if ($action == 'add') $percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):(in_array(GETPOST('complete'),array(-1,100))?GETPOST('complete'):GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status // Clean parameters - $datep=dol_mktime($fulldayevent?'00':GETPOST("aphour"), $fulldayevent?'00':GETPOST("apmin"), 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear")); - $datef=dol_mktime($fulldayevent?'23':GETPOST("p2hour"), $fulldayevent?'59':GETPOST("p2min"), $fulldayevent?'59':'0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year")); + $datep=dol_mktime($fulldayevent?'00':GETPOST("aphour",'int'), $fulldayevent?'00':GETPOST("apmin",'int'), $fulldayevent?'00':GETPOST("apsec",'int'), GETPOST("apmonth",'int'), GETPOST("apday",'int'), GETPOST("apyear",'int')); + $datef=dol_mktime($fulldayevent?'23':GETPOST("p2hour",'int'), $fulldayevent?'59':GETPOST("p2min",'int'), $fulldayevent?'59':GETPOST("apsec",'int'), GETPOST("p2month",'int'), GETPOST("p2day",'int'), GETPOST("p2year",'int')); // Check parameters if (! $datef && $percentage == 100) From eb1fdca157ebbe800e8d580134e5e4e29a80d202 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Oct 2017 10:44:18 +0200 Subject: [PATCH 424/428] NEW Can create intervention from a proposal --- htdocs/comm/action/class/actioncomm.class.php | 8 +-- htdocs/comm/propal/card.php | 8 +++ htdocs/commande/card.php | 2 + htdocs/core/class/commonobject.class.php | 20 +++--- htdocs/core/class/html.form.class.php | 4 ++ htdocs/core/tpl/originproductline.tpl.php | 6 +- htdocs/fichinter/card.php | 71 ++++++++++++++----- 7 files changed, 85 insertions(+), 34 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 12c11f863f1..cf380871926 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -907,7 +907,7 @@ class ActionComm extends CommonObject return $db->lasterror(); } } - + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -918,7 +918,7 @@ class ActionComm extends CommonObject function load_board($user, $load_state_board=0) { global $conf, $langs; - + if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; else { $this->nb=array(); @@ -934,7 +934,7 @@ class ActionComm extends CommonObject if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; - + $resql=$this->db->query($sql); if ($resql) { @@ -956,7 +956,7 @@ class ActionComm extends CommonObject if ($agenda_static->hasDelay()) $response->nbtodolate++; } else $this->nb["actionscomm"]=$obj->nb; } - + $this->db->free($resql); if(empty($load_state_board)) return $response; else return 1; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 35767c16167..48756a8828c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2284,6 +2284,14 @@ if ($action == 'create') } } + // Create an intervention + if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if ($user->rights->ficheinter->creer) { + $langs->load("interventions"); + print ''; + } + } + // Create contract if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) { $langs->load("contracts"); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index c385fe9a6ae..c5d03f399f2 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1686,6 +1686,8 @@ if ($action == 'create' && $user->rights->commande->creer) } print '' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . ''; + + // Amount print '' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht) . ''; print '' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva) . ""; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3631a6509ee..df35201af24 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3648,11 +3648,12 @@ abstract class CommonObject * Return HTML table table of source object lines * TODO Move this and previous function into output html class file (htmlline.class.php). * If lines are into a template, title must also be into a template - * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. + * But for the moment we don't know if it's possible, so we keep the method available on overloaded objects. * + * @param string $restrictlist ''=All lines, 'services'=Restrict to services only * @return void */ - function printOriginLinesList() + function printOriginLinesList($restrictlist='') { global $langs, $hookmanager, $conf; @@ -3674,8 +3675,6 @@ abstract class CommonObject foreach ($this->lines as $line) { - - if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) { if (empty($line->fk_parent_line)) @@ -3687,7 +3686,7 @@ abstract class CommonObject } else { - $this->printOriginLine($line,$var); + $this->printOriginLine($line, $var, $restrictlist); } $i++; @@ -3700,11 +3699,12 @@ abstract class CommonObject * If lines are into a template, title must also be into a template * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * - * @param CommonObjectLine $line Line - * @param string $var Var + * @param CommonObjectLine $line Line + * @param string $var Var + * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) * @return void */ - function printOriginLine($line,$var) + function printOriginLine($line, $var, $restrictlist='') { global $langs, $conf; @@ -3806,6 +3806,10 @@ abstract class CommonObject if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->getLabelOfUnit('long'); $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; + // Is the line strike or not + $this->tpl['strike']=0; + if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike']=1; + // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index faf26f7c111..389519d7b7f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4742,6 +4742,7 @@ class Form { $shour = dol_print_date($set_time, "%H"); $smin = dol_print_date($set_time, "%M"); + $ssec = dol_print_date($set_time, "%S"); } } else @@ -4752,6 +4753,7 @@ class Form $sday = ''; $shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? '' : $conf->global->MAIN_DEFAULT_DATE_HOUR; $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? '' : $conf->global->MAIN_DEFAULT_DATE_MIN; + $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? '' : $conf->global->MAIN_DEFAULT_DATE_SEC; } // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' @@ -4932,6 +4934,8 @@ class Form $retstring.=''; } $retstring.=''; + + $retstring.=''; } // Add a "Now" link diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index c8cd6674a7a..2efc114cc1d 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -19,8 +19,8 @@ ?> -'; +tpl['strike'])?'':' strikefordisabled').'">'; print ''.$this->tpl['label'].''; print ''.$this->tpl['description'].''; print ''.$this->tpl['vat_rate'].''; @@ -29,7 +29,7 @@ if (!empty($conf->multicurrency->enabled)) print ''.$this->tpl['multicurrency_price'].''; print ''.$this->tpl['qty'].''; -if($conf->global->PRODUCT_USE_UNITS) +if($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($this->tpl['unit']).''; print ''.$this->tpl['remise_percent'].''; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 52c23f551d2..bc6fb9d3014 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -60,6 +60,7 @@ $ref = GETPOST('ref','alpha'); $socid = GETPOST('socid','int'); $contratid = GETPOST('contratid','int'); $action = GETPOST('action','alpha'); +$cancel = GETPOST('cancel','alpha'); $confirm = GETPOST('confirm','alpha'); $mesg = GETPOST('msg','alpha'); $origin=GETPOST('origin','alpha'); @@ -105,6 +106,16 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action=''; + } + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once @@ -201,11 +212,11 @@ if (empty($reshook)) else if ($action == 'add' && $user->rights->ficheinter->creer) { $object->socid = $socid; - $object->duration = GETPOST('duration','int'); + $object->duration = GETPOST('duration','int'); $object->fk_project = GETPOST('projectid','int'); $object->fk_contrat = GETPOST('contratid','int'); $object->author = $user->id; - $object->description = GETPOST('description'); + $object->description = GETPOST('description','none'); $object->ref = $ref; $object->modelpdf = GETPOST('model','alpha'); $object->note_private = GETPOST('note_private','none'); @@ -276,7 +287,7 @@ if (empty($reshook)) $fk_parent_line=0; $num=count($lines); - for ($i=0;$i<$num;$i++) + for ($i=0; $i<$num; $i++) { $product_type=($lines[$i]->product_type?$lines[$i]->product_type:Product::TYPE_PRODUCT); @@ -829,7 +840,7 @@ if ($action == 'create') $soc=new Societe($db); - print load_fiche_titre($langs->trans("AddIntervention")); + print load_fiche_titre($langs->trans("AddIntervention"), '', 'title_commercial'); dol_htmloutput_mesg($mesg); @@ -1008,6 +1019,30 @@ if ($action == 'create') $newclassname=$classname; if ($newclassname=='Propal') $newclassname='CommercialProposal'; print ''.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).''; + + // Amount + /* Hide amount because we only copy services so amount may differ than source + print '' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht) . ''; + print '' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva) . ""; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE + { + print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . ""; + } + + if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF + { + print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . ""; + } + + print '' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . ""; + + if (!empty($conf->multicurrency->enabled)) + { + print '' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; + print '' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . ""; + print '' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; + } + */ } print ''; @@ -1029,6 +1064,18 @@ if ($action == 'create') print ''; print ''; + + // Show origin lines + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + $title = $langs->trans('Services'); + print load_fiche_titre($title); + + print ''; + + $objectsrc->printOriginLinesList(empty($conf->global->FICHINTER_PRINT_PRODUCTS)?'services':''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on + + print '
    '; + } } else { @@ -1604,22 +1651,8 @@ else if ($id > 0 || ! empty($ref)) else print ''; } - // Event agenda - if (! empty($conf->global->FICHINTER_ADDLINK_TO_EVENT)) - { - if (! empty($conf->agenda->enabled) && $object->statut > Fichinter::STATUS_DRAFT) - { - $langs->load("agenda"); - if ($object->statut < Fichinter::STATUS_BILLED) - { - if ($user->rights->agenda->myactions->create) print ''; - else print ''; - } - } - } - // Proposal - if (! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) + if ($conf->service->enabled && ! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("propal"); if ($object->statut < Fichinter::STATUS_BILLED) From 81e7f4520014fdf7df371f06533d5e90fe631e2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Oct 2017 11:08:49 +0200 Subject: [PATCH 425/428] FIX Stats on invoices show nothing --- htdocs/compta/facture/class/facturestats.class.php | 12 ++++++------ htdocs/compta/facture/stats/index.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index b2fd603a394..b6874862286 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -39,7 +39,7 @@ class FactureStats extends Stats var $from; var $field; var $where; - + /** * Constructor @@ -56,8 +56,8 @@ class FactureStats extends Stats $this->db = $db; $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; - $this->cachefilesuffix = $mode; - + $this->cachefilesuffix = $mode; + if ($mode == 'customer') { $object=new Facture($this->db); @@ -195,7 +195,7 @@ class FactureStats extends Stats return $this->_getAllByYear($sql); } - + /** * Return nb, amount of predefined product for year * @@ -218,7 +218,7 @@ class FactureStats extends Stats return $this->_getAllByProduct($sql); } - - + + } diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 6d2a15ceb8f..5f3076f9b37 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -84,7 +84,7 @@ dol_mkdir($dir); $stats = new FactureStats($db, $socid, $mode, ($userid>0?$userid:0)); if ($mode == 'customer') { - if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')'; + if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')'; } if ($mode == 'supplier') { From 3a97a3e2ad7e35002fec66bf954d86189e291937 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Oct 2017 13:05:55 +0200 Subject: [PATCH 426/428] Move key "Translation" into main file. Add direct link to edit on transifex --- htdocs/admin/translation.php | 16 +++++++++++++--- htdocs/langs/fr_FR/main.lang | 1 + htdocs/langs/fr_FR/products.lang | 1 - 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 1b2a52466e5..0c02b2efe67 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -227,7 +227,9 @@ else print load_fiche_titre($langs->trans("Translation"), $enabledisablehtml, 'title_setup'); +//print ''; print $langs->trans("TranslationDesc")."
    \n"; +//print '
    '; print "
    \n"; $current_language_code=$langs->defaultlang; @@ -320,7 +322,7 @@ if ($mode == 'overwrite') $sql = "SELECT rowid, entity, lang, transkey, transvalue"; $sql.= " FROM ".MAIN_DB_PREFIX."overwrite_trans"; $sql.= " WHERE 1 = 1"; - //$sql.= " AND entity IN (".$user->entity.",".$conf->entity.")"; + $sql.= " AND entity IN (".getEntity('overwrite_trans').")"; $sql.= $db->order($sortfield, $sortorder); dol_syslog("translation::select from table", LOG_DEBUG); @@ -513,7 +515,7 @@ if ($mode == 'searchkey') $sql = "SELECT rowid"; $sql.= " FROM " . MAIN_DB_PREFIX . "overwrite_trans"; $sql.= " WHERE transkey = '".$key."'"; - $sql.= " AND entity IN (" . $user->entity . ", " . $conf->entity . ")"; + $sql.= " AND entity IN (" . getEntity('overwrite_trans') . ")"; dol_syslog("translation::select from table", LOG_DEBUG); $result = $db->query($sql); if ($result) @@ -529,7 +531,15 @@ if ($mode == 'searchkey') } else if (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { - print '' . img_edit() . ''; + //print $key.'-'.$val; + print '' . img_edit_add($langs->trans("Overwrite")) . ''; + } + + if (! empty($conf->global->MAIN_FEATURES_LEVEL)) + { + $transifexlangfile='$'; // $ means 'All' + $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key; + print '   '.img_picto('FixOnTransifex', 'object_globe').''; } } else diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 7a47c934a80..83a9c889b97 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -771,6 +771,7 @@ Calendar=Calendrier GroupBy=Grouper par... ViewFlatList=Voir vue liste RemoveString=Supprimer la chaine '%s' +Translation=Traduction SomeTranslationAreUncomplete=Certains languages pourraient n'être que partiellement traduis, ou contenir des erreurs. Si vous en détectez, vous pouvez les corriger en vous enregistrant sur https://transifex.com/projects/p/dolibarr/ DirectDownloadLink=Lien de téléchargement direct Download=Téléchargement diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index ee4c7c328cf..ca61fff3460 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -100,7 +100,6 @@ ParentProductsNumber=Nbre de produits virtuels/packages parent ParentProducts=Produits parents IfZeroItIsNotAVirtualProduct=Si 0, ce produit n'est pas un produit virtuel IfZeroItIsNotUsedByVirtualProduct=Si 0, ce produit n'est pas utilisé par un produit virtuel -Translation=Traduction KeywordFilter=Filtre par mot-clé CategoryFilter=Filtre par catégorie ProductToAddSearch=Recherche des produits à ajouter From 6bcdf2ff75c8b9b9e8486dc56c027c656664f05c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Oct 2017 14:03:22 +0200 Subject: [PATCH 427/428] Test replacement of img switcher with FA css --- htdocs/admin/defaultvalues.php | 10 ++++++++-- htdocs/admin/translation.php | 18 ++++++++++++++---- htdocs/main.inc.php | 10 +++++++--- htdocs/theme/eldy/style.css.php | 3 +++ htdocs/theme/md/style.css.php | 3 +++ 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index e4ba112511e..6b98668b0d3 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -193,14 +193,20 @@ if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { // Button off, click to enable $enabledisablehtml.= ''; - $enabledisablehtml.= img_picto($langs->trans("Disabled"),'switch_off'); + //$enabledisablehtml.= img_picto($langs->trans("Disabled"),'switch_off'); + $enabledisablehtml.=''; + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$langs->trans("EnableDefaultValues"); + $enabledisablehtml.=''; $enabledisablehtml.= ''; } else { // Button on, click to disable $enabledisablehtml.= ''; - $enabledisablehtml.= img_picto($langs->trans("Activated"),'switch_on'); + //$enabledisablehtml.= img_picto($langs->trans("Activated"),'switch_on'); + $enabledisablehtml.=''; + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$langs->trans("DisableDefaultValues"); + $enabledisablehtml.=''; $enabledisablehtml.= ''; } diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 0c02b2efe67..f38406c3df5 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -209,19 +209,26 @@ llxHeader('',$langs->trans("Setup"),$wikihelp); $param='&mode='.$mode; -$enabledisablehtml = $langs->trans("EnableOverwriteTranslation").' '; +$enabledisablehtml=''; +if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.= $langs->trans("EnableOverwriteTranslation").' '; if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Button off, click to enable $enabledisablehtml.=''; - $enabledisablehtml.=img_picto($langs->trans("Disabled"),'switch_off'); + //$enabledisablehtml.=img_picto($langs->trans("Disabled"),'switch_off'); + $enabledisablehtml.=''; + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$langs->trans("EnableOverwriteTranslation"); + $enabledisablehtml.=''; $enabledisablehtml.=''; } else { // Button on, click to disable $enabledisablehtml.=''; - $enabledisablehtml.=img_picto($langs->trans("Activated"),'switch_on'); + //$enabledisablehtml.=img_picto($langs->trans("Activated"),'switch_on'); + $enabledisablehtml.=''; + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$langs->trans("DisableOverwriteTranslation"); + $enabledisablehtml.=''; $enabledisablehtml.=''; } @@ -262,11 +269,14 @@ if ($mode == 'overwrite') { //print load_fiche_titre($langs->trans("TranslationOverwriteKey"), '', '')."\n"; + print '
    '; print img_info().' '.$langs->trans("SomeTranslationAreUncomplete"); $urlwikitranslatordoc='https://wiki.dolibarr.org/index.php/Translator_documentation'; - print ' ('.$langs->trans("SeeAlso").': '.$urlwikitranslatordoc.')
    '; + print ' ('.$langs->trans("SeeAlso").': '.$langs->trans("Here").')
    '; print $langs->trans("TranslationOverwriteDesc",$langs->transnoentitiesnoconv("Language"),$langs->transnoentitiesnoconv("Key"),$langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n"; print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."
    \n"; + print '
    '; + print '
    '; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c19faf054ea..77af64afa3d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -816,6 +816,10 @@ if (GETPOST('textbrowser','int') || (! empty($conf->browser->name) && $conf->bro { $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER=1; } +elseif (! empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) +{ + $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER=$user->conf->MAIN_OPTIMIZEFORTEXTBROWSER; +} // Set terminal output option according to conf->browser. if (GETPOST('dol_hide_leftmenu','int') || ! empty($_SESSION['dol_hide_leftmenu'])) $conf->dol_hide_leftmenu=1; @@ -1093,9 +1097,9 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; if (empty($conf->dol_use_jmobile)) print ''."\n"; // Not required into an Android webview - //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser','int')) print ''."\n"; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser','int')) print ''."\n"; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser','int')) print ''."\n"; + //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; + //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; + //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; // Displays title $appli=constant('DOL_APPLICATION_TITLE'); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index f08d51b861b..c38f15f96eb 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -579,6 +579,9 @@ textarea.centpercent { .right { text-align: ; } +.justify { + text-align: justify; +} .nowrap { white-space: ; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 7cec201021e..05b0f306ead 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -584,6 +584,9 @@ textarea.centpercent { .right { text-align: ; } +.justify { + text-align: justify; +} .nowrap { white-space: ; } From 536e1a95c793806fcc7f9b618fea7a912998cbde Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Oct 2017 14:20:39 +0200 Subject: [PATCH 428/428] Add SEPA file example --- dev/resources/sepa/test.xml | 133 ++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 dev/resources/sepa/test.xml diff --git a/dev/resources/sepa/test.xml b/dev/resources/sepa/test.xml new file mode 100644 index 00000000000..fc969a7624c --- /dev/null +++ b/dev/resources/sepa/test.xml @@ -0,0 +1,133 @@ + + + + + PREL20171012/REF10 + 2017-10-12T00:08:30 + 2 + 734.4 + + MyBigCompany + + + + FR76AAAAA + + + + + + + PREL20171012/ID00010-T171001 + DD + 2 + 734.4 + + + SEPA + + + CORE + + RCUR + + 2017-10-12 + + MyBigCompany + + FR + Address1 + Address2 + + + + + FR76123456 + + + + + BICABCDEF + + + SLEV + + + + + FR76AAAAA + + SEPA + + + + + + + + AS-FA1710-0416-000679 + + 540 + + + RUM-CU1610-0001-3-1476058417 + 2016-10-10 + false + + + + + BICXYZ + + + + CUSTOMER A + + FR + Mr abc + + + + + FR123456 + + + + FA1710-0416 + + + + + AS-FA1710-0415-000683 + + 194.4 + + + RUM-CU1709-0011-4-1506525346 + 2017-09-27 + false + + + + + BICJKL + + + + CUSTOMER2 + + FR + + + + + FR76123456 + + + + FA1710-0415 + + + + +