From bc8c36b08f6b3d8ffd653242c1658685ea23a1d4 Mon Sep 17 00:00:00 2001 From: fhenry Date: Mon, 21 Jan 2013 13:48:15 +0100 Subject: [PATCH 001/162] Add parameters force get Extarfield list from ll_extrafield even if external extrafield module is enabled --- htdocs/webservices/server_actioncomm.php | 4 ++-- htdocs/webservices/server_thirdparty.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index 1e5baa31144..45311cc52d2 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -291,7 +291,7 @@ function getActionComm($authentication,$id) //Retreive all extrafield for actioncomm // fetch optionals attributes and labels $extrafields=new ExtraFields($db); - $extralabels=$extrafields->fetch_name_optionals_label('actioncomm'); + $extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true); //Get extrafield values $actioncomm->fetch_optionals($actioncomm->id,$extralabels); @@ -436,7 +436,7 @@ function createActionComm($authentication,$actioncomm) //Retreive all extrafield for actioncomm // fetch optionals attributes and labels $extrafields=new ExtraFields($db); - $extralabels=$extrafields->fetch_name_optionals_label('actioncomm'); + $extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true); foreach($extrafields->attribute_label as $key=>$label) { $key='options_'.$key; diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 057a99ac6fa..0735f5880fe 100755 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -123,7 +123,7 @@ $thirdparty_fields= array( //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields=new ExtraFields($db); -$extralabels=$extrafields->fetch_name_optionals_label('company'); +$extralabels=$extrafields->fetch_name_optionals_label('company',true); if (count($extrafields)>0) { $extrafield_array = array(); } @@ -314,7 +314,7 @@ function getThirdParty($authentication,$id='',$ref='',$ref_ext='') //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields=new ExtraFields($db); - $extralabels=$extrafields->fetch_name_optionals_label('company'); + $extralabels=$extrafields->fetch_name_optionals_label('company',true); //Get extrafield values $thirdparty->fetch_optionals($thirdparty->id,$extralabels); @@ -428,7 +428,7 @@ function createThirdParty($authentication,$thirdparty) //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields=new ExtraFields($db); - $extralabels=$extrafields->fetch_name_optionals_label('company'); + $extralabels=$extrafields->fetch_name_optionals_label('company',true); foreach($extrafields->attribute_label as $key=>$label) { $key='options_'.$key; From ec7612762553d175e22e072722a17782df367b9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Jan 2013 15:14:46 +0100 Subject: [PATCH 002/162] Fix: http://www.dolibarr.fr/forum/12-howto--aide/28089-adherents--tiers Fix: Update member --- htdocs/adherents/class/adherent.class.php | 2 - .../install/mysql/migration/3.2.0-3.3.0.sql | 2 + htdocs/install/mysql/tables/llx_adherent.sql | 1 + htdocs/societe/class/societe.class.php | 51 ++++++++++++++++--- htdocs/societe/soc.php | 18 ++++++- 5 files changed, 65 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index a48c4fb1c0b..ddb434f2868 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -538,8 +538,6 @@ class Adherent extends CommonObject $luser->office_phone=$this->phone; $luser->user_mobile=$this->phone_mobile; - $luser->note=$this->note; - $luser->fk_member=$this->id; $result=$luser->update($user,0,1,1); // Use nosync to 1 to avoid cyclic updates diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index 43f397aedf1..3793e822102 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -20,6 +20,8 @@ DROP TABLE llx_document; DROP TABLE llx_dolibarr_modules; DROP TABLE llx_product_fournisseur; +ALTER TABLE llx_adherent ADD COLUMN canvas varchar(32); + ALTER TABLE llx_societe_rib MODIFY COLUMN bic varchar(20); ALTER TABLE llx_facture_rec ADD COLUMN usenewprice integer; diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index 34550703e28..3ab580b5de2 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -60,5 +60,6 @@ create table llx_adherent fk_user_author integer, -- can be null because member can be create by a guest fk_user_mod integer, fk_user_valid integer, + canvas varchar(32), -- type of canvas if used (null by default) import_key varchar(14) -- Import key )ENGINE=innodb; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9c2368f3f36..8dbebff7da8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -375,9 +375,10 @@ class Societe extends CommonObject * @param int $allowmodcodeclient Inclut modif code client et code compta * @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur * @param string $action 'create' or 'update' + * @param int $nosyncmember Do not synchronize info of linked member * @return int <0 if KO, >=0 if OK */ - function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update') + function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1) { global $langs,$conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -491,7 +492,7 @@ class Societe extends CommonObject if ($result >= 0) { - dol_syslog(get_class($this)."::Update verify ok"); + dol_syslog(get_class($this)."::update verify ok"); $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; $sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required @@ -564,11 +565,49 @@ class Societe extends CommonObject $resql=$this->db->query($sql); if ($resql) { - unset($this->country_code); // We clean this because it may have been changed after an update of country_id - unset($this->country); - unset($this->state_code); - unset($this->state); + unset($this->country_code); // We clean this because it may have been changed after an update of country_id + unset($this->country); + unset($this->state_code); + unset($this->state); + + $nbrowsaffected+=$this->db->affected_rows($resql); + if (! $error && $nbrowsaffected) + { + // Update information on linked member if it is an update + if (! $nosyncmember && ! empty($conf->adherent->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + + dol_syslog(get_class($this)."::update update linked member"); + + $lmember=new Adherent($this->db); + $result=$lmember->fetch(0, 0, $this->id); + + if ($result > 0) + { + $lmember->firstname=$this->firstname; + $lmember->lastname=$this->lastname; + $lmember->address=$this->address; + $lmember->email=$this->email; + $lmember->phone=$this->phone; + + $result=$lmember->update($user,0,1,1); // Use nosync to 1 to avoid cyclic updates + if ($result < 0) + { + $this->error=$lmember->error; + dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); + $error++; + } + } + else if ($result < 0) + { + $this->error=$lmember->error; + $error++; + } + } + } + // Si le fournisseur est classe on l'ajoute $this->AddFournisseurInCategory($this->fournisseur_categorie); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 8514ac0db62..063d33a27f3 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -346,7 +346,7 @@ if (empty($reshook)) if (empty($object->fournisseur)&& empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur=''; //var_dump($object);exit; - $result = $object->update($socid,$user,1,$object->oldcopy->codeclient_modifiable(),$object->oldcopy->codefournisseur_modifiable()); + $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 0); if ($result <= 0) { $error = $object->error; $errors = $object->errors; @@ -397,6 +397,22 @@ if (empty($reshook)) } // Gestion du logo de la société + + // Update linked member + if (! $error && $object->fk_soc > 0) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; + $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; + dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); + if (! $this->db->query($sql)) + { + $error++; + $this->error .= $this->db->lasterror(); + dol_syslog(get_class($this)."::delete erreur -1 ".$this->error, LOG_ERR); + } + } + if (! $error && ! count($errors)) { From 910543c5b9446f13ca82d649623d2eafba9ed73e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Jan 2013 16:53:39 +0100 Subject: [PATCH 003/162] Fix: broken feature --- htdocs/core/class/commonobject.class.php | 10 +++++----- htdocs/core/class/hookmanager.class.php | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8194474ff6c..d77b7487e1e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2279,16 +2279,16 @@ abstract class CommonObject $qty= $obj->qty; $discount_percent_line = $obj->remise_percent; $total_ht = $obj->total_ht; - + $total_discount_line = price2num(($pu_ht * $qty) - $total_ht, 'MT'); $total_discount += $total_discount_line; - + $i++; } } else dol_syslog(get_class($this).'::getTotalDiscount '.$this->db->lasterror(), LOG_ERR); - - //print $total_discount; exit; + + //print $total_discount; exit; return price2num($total_discount); } @@ -2479,7 +2479,7 @@ abstract class CommonObject $parameters=array(); $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook - if (! $reshook) + if (empty($hookmanager->resPrint)) { $num = count($this->linkedObjects); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index b5598689e0f..8b0ac34b6e2 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -41,6 +41,8 @@ class HookManager // Array result var $resArray=array(); + // Printable result (int, string) + var $resPrint; /** * Constructor From b0c11373978867eec537cb53ae71e15339e8206a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Jan 2013 17:43:41 +0100 Subject: [PATCH 004/162] Restore correct code: A module decide if standard code is used or not after running by a return code that is an int 0=execute standard code, 1=disable standard code To return a string to show or an array or error codes, this must be done by setting $actionclassinstance->results or $actionclassinstance->resprints --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/hookmanager.class.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d77b7487e1e..34a68f58fc4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2479,7 +2479,7 @@ abstract class CommonObject $parameters=array(); $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook - if (empty($hookmanager->resPrint)) + if (empty($reshook)) { $num = count($this->linkedObjects); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 8b0ac34b6e2..c6e5895f450 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -41,8 +41,8 @@ class HookManager // Array result var $resArray=array(); - // Printable result (int, string) - var $resPrint; + // Printable result + var $resPrint=''; /** * Constructor From a019b1c854f32c0afc0b3f60eb384f8632a8aa0d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Jan 2013 18:04:04 +0100 Subject: [PATCH 005/162] Fix: disable "datetimepicker" from edit in place for the moment --- htdocs/core/class/html.form.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bd6f11d0e40..6e331bc0a0e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -135,8 +135,7 @@ class Form $ret=''; // When option to edit inline is activated - // TODO change for compatibility - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;/',$typeofdata)) + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;|datehourpicker/',$typeofdata)) // FIXME add jquery timepicker { $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $success); } From 06a0da990be4889d1c4adbe15ca693905913569c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Jan 2013 21:35:15 +0100 Subject: [PATCH 006/162] Fix: broken features, special_code also used by externals modules ! --- htdocs/comm/propal/class/propal.class.php | 8 +++--- htdocs/commande/class/commande.class.php | 10 ++++--- htdocs/compta/facture/class/facture.class.php | 26 ++++++++++--------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8b481885b2e..8e3e4748f05 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005 Marc Barilley - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2012 Juanjo Menent @@ -301,7 +301,7 @@ class Propal extends CommonObject * @param int $info_bits Bits de type de lignes * @param int $type Type of line (product, service) * @param int $rang Position of line - * @param int $special_code Special code + * @param int $special_code Special code (also used by externals modules!) * @param int $fk_parent_line Id of parent line * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price without tax @@ -457,7 +457,7 @@ class Propal extends CommonObject * @param string $desc Description * @param double $price_base_type HT ou TTC * @param int $info_bits Miscellanous informations - * @param int $special_code Set special code ('' = we don't change it) + * @param int $special_code Special code (also used by externals modules!) * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) * @param int $fk_fournprice Id of origin supplier price @@ -480,7 +480,7 @@ class Propal extends CommonObject $txtva = price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - $pa_ht=price2num($pa_ht); + $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 diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6b6834539ad..481b51400a5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2012 Juanjo Menent * Copyright (C) 2011 Jean Heimburger @@ -995,7 +995,7 @@ class Commande extends CommonOrder * @param timestamp $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @param int $type Type of line (0=product, 1=service) * @param int $rang Position of line - * @param int $special_code Special code + * @param int $special_code Special code (also used by externals modules!) * @param int $fk_parent_line Parent line * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price (without tax) @@ -2176,9 +2176,10 @@ class Commande extends CommonOrder * @param int $fk_fournprice Id of origin supplier price * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label Label + * @param int $special_code Special code (also used by externals modules!) * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='') + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0) { global $conf; @@ -2197,6 +2198,7 @@ class Commande extends CommonOrder if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($remise)) $remise=0; if (empty($remise_percent)) $remise_percent=0; + if (empty($special_code) || $special_code == 3) $special_code=0; $remise_percent=price2num($remise_percent); $qty=price2num($qty); $pu = price2num($pu); @@ -2251,7 +2253,7 @@ class Commande extends CommonOrder $this->line->remise_percent=$remise_percent; $this->line->subprice=$subprice; $this->line->info_bits=$info_bits; - $this->line->special_code=0; // To remove special_code=3 coming from proposals copy + $this->line->special_code=$special_code; $this->line->total_ht=$total_ht; $this->line->total_tva=$total_tva; $this->line->total_localtax1=$total_localtax1; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8c194245015..cf7b89be7aa 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2010-2012 Juanjo Menent @@ -1874,7 +1874,7 @@ class Facture extends CommonInvoice * @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note) * @param int $type Type of line (0=product, 1=service) * @param int $rang Position of line - * @param int $special_code Special code + * @param int $special_code Special code (also used by externals modules!) * @param string $origin 'order', ... * @param int $origin_id Id of origin object * @param int $fk_parent_line Id of parent line @@ -2037,9 +2037,10 @@ class Facture extends CommonInvoice * @param int $fk_fournprice Id of origin supplier price * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label Label of the line + * @param int $special_code Special code (also used by externals modules!) * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='') + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2052,11 +2053,12 @@ class Facture extends CommonInvoice // Clean parameters if (empty($qty)) $qty=0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; + if (empty($special_code) || $special_code == 3) $special_code=0; $remise_percent = price2num($remise_percent); $qty = price2num($qty); $pu = price2num($pu); - $pa_ht = price2num($pa_ht); + $pa_ht = price2num($pa_ht); $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); @@ -2105,21 +2107,21 @@ class Facture extends CommonInvoice $this->line->rowid = $rowid; $this->line->label = $label; $this->line->desc = $desc; - $this->line->qty= ($this->type==2?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative + $this->line->qty = ($this->type==2?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; $this->line->remise_percent = $remise_percent; - $this->line->subprice= ($this->type==2?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->subprice = ($this->type==2?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->date_start = $date_start; $this->line->date_end = $date_end; - $this->line->total_ht= (($this->type==2||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva= (($this->type==2||$qty<0)?-abs($total_tva):$total_tva); - $this->line->total_localtax1=(($this->type==2||$qty<0)?-abs($total_localtax1):$total_localtax1); - $this->line->total_localtax2=(($this->type==2||$qty<0)?-abs($total_localtax2):$total_localtax2); - $this->line->total_ttc= (($this->type==2||$qty<0)?-abs($total_ttc):$total_ttc); + $this->line->total_ht = (($this->type==2||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type==2||$qty<0)?-abs($total_tva):$total_tva); + $this->line->total_localtax1 = (($this->type==2||$qty<0)?-abs($total_localtax1):$total_localtax1); + $this->line->total_localtax2 = (($this->type==2||$qty<0)?-abs($total_localtax2):$total_localtax2); + $this->line->total_ttc = (($this->type==2||$qty<0)?-abs($total_ttc):$total_ttc); $this->line->info_bits = $info_bits; - $this->line->special_code=0; // To remove special_code=3 coming from proposals copy + $this->line->special_code = $special_code; $this->line->product_type = $type; $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; From 5f2af003977831539a5b495e883b9865de710271 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Jan 2013 00:24:20 +0100 Subject: [PATCH 007/162] Add logs to debug --- htdocs/core/class/hookmanager.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index c6e5895f450..753086339fb 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -117,7 +117,7 @@ class HookManager * @param Object &$object Object to use hooks on * @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) * @return mixed For doActions,formObjectOptions: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO. - * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Must always return an int and things to print into ->resprints. + * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Must always return an int and things to print into ->resprints. * Can also return some values into an array ->results. * $this->error or this->errors are also defined by class called by this function if error. */ @@ -176,11 +176,13 @@ class HookManager // TODO. remove this. result must not be a string. we must use $actionclassinstance->resprint to return a string if (! is_array($result) && ! is_numeric($result)) $this->resPrint.=$result; } + + //print "method=".$method." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." result=".$result." resaction=".$resaction; } } } - if ($method != 'doActions' && $method != 'formObjectOptions') return $this->resPrint; // TODO remove this. When there is something to print, ->resPrint is filled. + if ($method != 'doActions' && $method != 'formObjectOptions') return $this->resPrint; // TODO remove this. When there is something to print, ->resPrint is filled. return ($error?-1:$resaction); } From c66c02e74595bcbfc946cfa715b159513e115727 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 23 Jan 2013 11:28:11 +0100 Subject: [PATCH 008/162] Fix: missing files library --- htdocs/fourn/commande/fiche.php | 5 +++-- htdocs/fourn/facture/fiche.php | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 348f296ff89..36643547088 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -36,9 +36,10 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (! empty($conf->produit->enabled)) +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +if (!empty($conf->produit->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load('orders'); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index f2ee3749897..99e1bf5da0a 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2010-2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -33,8 +33,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefo require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +if (!empty($conf->produit->enabled)) + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +if (!empty($conf->projet->enabled)) + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load('bills'); From 7b1e15f340c19356c5868d7671e5a1a1b187120e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Jan 2013 14:51:15 +0100 Subject: [PATCH 009/162] New: Allow to use upgrade script to upgrade sql of modules --- htdocs/install/upgrade.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 92d7f9b1eff..28aea7628e9 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -46,6 +46,7 @@ $setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):'auto'; $langs->setDefaultLang($setuplang); $versionfrom=GETPOST("versionfrom",'',3)?GETPOST("versionfrom",'',3):(empty($argv[1])?'':$argv[1]); $versionto=GETPOST("versionto",'',3)?GETPOST("versionto",'',3):(empty($argv[2])?'':$argv[2]); +$versionmodule=GETPOST("versionmodule",'',3)?GETPOST("versionmodule",'',3):(empty($argv[3])?'':$argv[3]); $langs->load("admin"); $langs->load("install"); @@ -319,8 +320,9 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) if ($ok) { $dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver + if (! empty($versionmodule)) $dir=dol_buildpath('/'.$versionmodule.'/sql/',0); - // For minor version + // For minor version $newversionfrom=preg_replace('/(\.[0-9]+)$/i','.0',$versionfrom); $newversionto=preg_replace('/(\.[0-9]+)$/i','.0',$versionto); @@ -387,7 +389,7 @@ $ret=0; if (! $ok && isset($argv[1])) $ret=1; dol_syslog("Exit ".$ret); -pFooter(! $ok && empty($_GET["ignoreerrors"]),$setuplang); +pFooter(((! $ok && empty($_GET["ignoreerrors"])) || $versionmodule),$setuplang); if ($db->connected) $db->close(); From b12101a650545e78cf024ea66699c936228c56f6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 23 Jan 2013 15:11:33 +0100 Subject: [PATCH 010/162] Fix: only once superadmin if no multicompany setup --- htdocs/user/fiche.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 52ca3932fdb..095a14ab439 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -223,10 +223,6 @@ if ($action == 'add' && $canadduser) $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); } } - else if (! empty($_POST["admin"])) - { - $object->entity=0; - } else { $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); @@ -372,10 +368,6 @@ if ($action == 'update' && ! $_POST["cancel"]) $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); } } - else if(! empty($_POST["admin"])) - { - $object->entity=0; - } else { $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); @@ -1582,7 +1574,7 @@ else print '
'; print ''; print ''; - print ''; + print ''; print ''; $rowspan=13; From 459adb146c00568f5de839e6b9eb0db98fdc983b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 23 Jan 2013 15:26:18 +0100 Subject: [PATCH 011/162] Fix: only once superadmin and an admin can not delete/modify a superadmin --- htdocs/user/fiche.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 095a14ab439..49a38c90f39 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -1360,7 +1360,7 @@ else print '
'; - if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + if ($caneditfield && ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { @@ -1372,7 +1372,7 @@ else } } elseif ($caneditpassword && ! $object->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("EditPassword").''; } @@ -1385,7 +1385,7 @@ else print ''.$langs->trans("ReinitPassword").''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("ReinitPassword").''; } @@ -1395,7 +1395,7 @@ else print ''.$langs->trans("SendNewPassword").''; } else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if ($object->email) print ''.$langs->trans("SendNewPassword").''; else print ''.$langs->trans("SendNewPassword").''; @@ -1404,19 +1404,19 @@ else // Activer if ($user->id <> $id && $candisableuser && $object->statut == 0 && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("Reactivate").''; } // Desactiver if ($user->id <> $id && $candisableuser && $object->statut == 1 && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("DisableUser").''; } // Delete if ($user->id <> $id && $candisableuser && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin { From beea9c2ec4bbfffcf0402ebf2d58e6a227d2e7a7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 23 Jan 2013 15:44:51 +0100 Subject: [PATCH 012/162] Fix: use the users entity --- htdocs/user/fiche.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 49a38c90f39..912783d9ca9 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -1360,7 +1360,7 @@ else print '
'; - if ($caneditfield && ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + if ($caneditfield && ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { @@ -1368,13 +1368,13 @@ else } else { - print ''.$langs->trans("Modify").''; + print ''.$langs->trans("Modify").''; } } elseif ($caneditpassword && ! $object->ldap_sid && - ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - print ''.$langs->trans("EditPassword").''; + print ''.$langs->trans("EditPassword").''; } // Si on a un gestionnaire de generation de mot de passe actif @@ -1385,9 +1385,9 @@ else print ''.$langs->trans("ReinitPassword").''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - print ''.$langs->trans("ReinitPassword").''; + print ''.$langs->trans("ReinitPassword").''; } if ($object->statut == 0) @@ -1395,32 +1395,32 @@ else print ''.$langs->trans("SendNewPassword").''; } else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - if ($object->email) print ''.$langs->trans("SendNewPassword").''; + if ($object->email) print ''.$langs->trans("SendNewPassword").''; else print ''.$langs->trans("SendNewPassword").''; } } // Activer if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - print ''.$langs->trans("Reactivate").''; + print ''.$langs->trans("Reactivate").''; } // Desactiver if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - print ''.$langs->trans("DisableUser").''; + print ''.$langs->trans("DisableUser").''; } // Delete if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $fuser->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin { - print ''.$langs->trans("DeleteUser").''; + print ''.$langs->trans("DeleteUser").''; } else { @@ -1574,7 +1574,7 @@ else print ''; print ''; print ''; - print ''; + print ''; print '
'; $rowspan=13; From 5e42a9ff8aa93c9fc931843acb47c2158bf358b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Jan 2013 18:08:11 +0100 Subject: [PATCH 013/162] Fix: Revert again another fix that was not correct. It was no more possible to edit a user even if user has permission for. If module multicompany does not exists (standard mode), no other test must be added to the if, except the $canxxx test. --- htdocs/user/fiche.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 912783d9ca9..bc0caf8d469 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -1360,7 +1360,7 @@ else print '
'; - if ($caneditfield && ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { @@ -1372,7 +1372,7 @@ else } } elseif ($caneditpassword && ! $object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("EditPassword").''; } @@ -1385,7 +1385,7 @@ else print ''.$langs->trans("ReinitPassword").''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("ReinitPassword").''; } @@ -1395,7 +1395,7 @@ else print ''.$langs->trans("SendNewPassword").''; } else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if ($object->email) print ''.$langs->trans("SendNewPassword").''; else print ''.$langs->trans("SendNewPassword").''; @@ -1404,19 +1404,19 @@ else // Activer if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("Reactivate").''; } // Desactiver if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("DisableUser").''; } // Delete if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin { From 7fcf206603235a1e4d45a2b452f3673c9518e396 Mon Sep 17 00:00:00 2001 From: fhenry Date: Wed, 23 Jan 2013 19:46:28 +0100 Subject: [PATCH 014/162] Add SparkAngel Support for Open-concept.pro --- htdocs/support/online.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/support/online.php b/htdocs/support/online.php index b9551c0251f..bd431b0fe68 100644 --- a/htdocs/support/online.php +++ b/htdocs/support/online.php @@ -72,6 +72,12 @@ array('name'=>'Auguria', 'sort'=>2, //'logo'=>'logoUrl='.urlencode('http://www.cap-networks.com/images/logo_small.jpg'), 'id'=>'7196', + 'lang'=>'fr'), +//Widget for Open-Concept +array('name'=>'Open-Concept.pro', + 'sort'=>2, + 'logo'=>'logoUrl='.urlencode('http://www.open-concept.pro/CMS/images/Logo/logosimplecomplet.png'), + 'id'=>'9340', 'lang'=>'fr') ); $arrayofwidgets=dol_sort_array($arrayofwidgets,'sort','asc',0,0); From efadc2c75c2c29ef6f9905d52aff416a018504d5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 23 Jan 2013 21:04:41 +0100 Subject: [PATCH 015/162] Fix: remove unused support --- htdocs/support/online.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/support/online.php b/htdocs/support/online.php index bd431b0fe68..33b18af7924 100644 --- a/htdocs/support/online.php +++ b/htdocs/support/online.php @@ -61,12 +61,6 @@ array('name'=>'Laurent Destailleur', // id user 4702 'logo'=>'logoUrl='.urlencode('http://www.nltechno.com/images/logo_nltechno_long.jpg'), // Put your own logo 'id'=>'4256,4255', // Put of list of sparkangels widget id (for each language) 'lang'=>'fr,en'), // Put list of language code of widgets (always english at end) -// Widget for Regis Houssin -array('name'=>'Régis Houssin', - 'sort'=>2, - 'logo'=>'logoUrl='.urlencode('http://www.cap-networks.com/images/logo_small.jpg'), - 'id'=>'5391', - 'lang'=>'fr'), // Widget for Auguria array('name'=>'Auguria', 'sort'=>2, From 347228270398b4793abe08de51ee6c5b3b0a78bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Jan 2013 23:34:43 +0100 Subject: [PATCH 016/162] Fix: [ bug #667 ] Customer categories wrong tree shown after update 3.2->3.3 --- htdocs/categories/class/categorie.class.php | 104 ++++++++++++-------- htdocs/categories/index.php | 3 + htdocs/ecm/class/ecmdirectory.class.php | 4 +- 3 files changed, 69 insertions(+), 42 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6daa65f4893..802e8e3ff11 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -47,6 +47,7 @@ class Categorie var $import_key; var $cats=array(); // Tableau en memoire des categories + var $motherof=array(); /** @@ -542,6 +543,40 @@ class Categorie return ($n[0] > 0); } + + /** + * Load this->motherof that is array(id_son=>id_parent, ...) + * + * @return int <0 if KO, >0 if OK + */ + private function load_motherof() + { + global $conf; + + $this->motherof=array(); + + // Load array[child]=parent + $sql = "SELECT fk_parent as id_parent, rowid as id_son"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE fk_parent != 0"; + $sql.= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::load_motherof sql=".$sql); + $resql = $this->db->query($sql); + if ($resql) + { + while ($obj= $this->db->fetch_object($resql)) + { + $this->motherof[$obj->id_son]=$obj->id_parent; + } + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } /** * Reconstruit l'arborescence des categories sous la forme d'un tableau @@ -554,13 +589,16 @@ class Categorie * fullpath = chemin complet compose des id * * @param string $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members) - * @param int $markafterid Mark all categories after this leaf in category tree. - * @return array Array of categories + * @param int $markafterid Removed all categories including the leaf $markafterid in category tree. + * @return array Array of categories. this->cats and this->motherof are set. */ function get_full_arbo($type,$markafterid=0) { $this->cats = array(); + // Init this->motherof that is array(id_son=>id_parent, ...) + $this->load_motherof(); + // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.fk_parent"; // Distinct reduce pb with old tables with duplicates $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c"; @@ -592,10 +630,11 @@ class Categorie dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); foreach($this->cats as $key => $val) { + //print 'key='.$key.'
'."\n"; $this->build_path_from_id_categ($key,0); // Process a branch from the root category key (this category has no parent) } - // Exclude tree for $markafterid + // Exclude leaf including $markafterid from tree if ($markafterid) { //print "Look to discard category ".$markafterid."\n"; @@ -608,8 +647,6 @@ class Categorie if (preg_match('/'.$keyfilter1.'/',$val['fullpath']) || preg_match('/'.$keyfilter2.'/',$val['fullpath']) || preg_match('/'.$keyfilter3.'/',$val['fullpath']) || preg_match('/'.$keyfilter4.'/',$val['fullpath'])) { - //print "Categ discarded ".$this->cats[$key]['fullpath']."\n"; - //$this->cats[$key]['marked']=1; unset($this->cats[$key]); } } @@ -630,51 +667,38 @@ class Categorie * @param int $protection Deep counter to avoid infinite loop * @return void */ - function build_path_from_id_categ($id_categ,$protection=0) + function build_path_from_id_categ($id_categ,$protection=1000) { dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); - //if (! empty($this->cats[$id_categ]['fullpath'])) - //{ - // Already defined - // dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); - // return; - //} + if (! empty($this->cats[$id_categ]['fullpath'])) + { + // Already defined + dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); + return; + } + + // First build full array $motherof + //$this->load_motherof(); // Disabled because already done by caller of build_path_from_id_categ // Define fullpath and fulllabel - if (! empty($this->cats[$id_categ]['fk_parent'])) + $this->cats[$id_categ]['fullpath'] = '_'.$id_categ; + $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label']; + $i=0; $cursor_categ=$id_categ; + //print 'Work for id_categ='.$id_categ.'
'."\n"; + while ((empty($protection) || $i < $protection) && ! empty($this->motherof[$cursor_categ])) { - $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['fk_parent']]['fullpath']; - $this->cats[$id_categ]['fullpath'].= '_'.$id_categ; - $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['fk_parent']]['fulllabel']; - $this->cats[$id_categ]['fulllabel'].= ' >> '.$this->cats[$id_categ]['label']; - } - else - { - $this->cats[$id_categ]['fullpath'] = '_'.$id_categ; - $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label']; + //print '  cursor_categ='.$cursor_categ.' i='.$i.' '.$this->motherof[$cursor_categ].'
'."\n"; + $this->cats[$id_categ]['fullpath'] = '_'.$this->motherof[$cursor_categ].$this->cats[$id_categ]['fullpath']; + $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->motherof[$cursor_categ]]['label'].' >> '.$this->cats[$id_categ]['fulllabel']; + //print '  Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].' '.$this->cats[$id_categ]['fulllabel'].'
'."\n"; + $i++; $cursor_categ=$this->motherof[$cursor_categ]; } + //print 'Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].'
'."\n"; + // We count number of _ to have level $this->cats[$id_categ]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->cats[$id_categ]['fullpath'])); - /* - // Process all childs on several levels of this category - $protection++; - if ($protection > 10) return; // On ne traite pas plus de 10 niveaux de profondeurs - if (empty($this->cats[$id_categ]['id_children'])) return; - foreach($this->cats[$id_categ]['id_children'] as $key => $idchild) - { - // Protection when a category has itself as a child (should not happen) - if ($idchild == $id_categ) - { - dol_syslog(get_class($this)."::build_path_from_id_categ bad couple (".$idchild.",".$id_categ.") in association table: An entry should not have itself has child", LOG_WARNING); - continue; - } - - $this->build_path_from_id_categ($idchild,$protection); - } - */ - return; } diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index be5cb6120b5..c9102fdaa17 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -209,12 +209,15 @@ foreach($fulltree as $key => $val) // Define showline $showline=0; + //var_dump($expandedsectionarray); + // If directory is son of expanded directory, we show line if (isset($val['fk_parent']) && in_array($val['fk_parent'],$expandedsectionarray)) $showline=4; // If directory is parent of selected directory or is selected directory, we show line elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2; // If we are level one we show line elseif ($val['level'] < 2) $showline=1; + //print 'xxx '.$val['level'].' - '.$fullpathselected.' - '.$val['fullpath'].' - '.$val['fk_parent'].' showline='.$showline.'
'."\n"; if ($showline) { diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 1b5cfde2370..bdb8dd0f366 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -479,13 +479,13 @@ class EcmDirectory // extends CommonObject $this->motherof=array(); - // Charge tableau des meres + // Load array[child]=parent $sql = "SELECT fk_parent as id_parent, rowid as id_son"; $sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories"; $sql.= " WHERE fk_parent != 0"; $sql.= " AND entity = ".$conf->entity; - dol_syslog(get_class($this)."::get_full_arbo sql=".$sql); + dol_syslog(get_class($this)."::load_motherof sql=".$sql); $resql = $this->db->query($sql); if ($resql) { From fa2e9cbd4f66ac6df6e5a20467851782a589aca0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Jan 2013 10:06:39 +0100 Subject: [PATCH 017/162] Exclude external modules --- htdocs/public/demo/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 9109cabc09b..b8a240b44b6 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -78,7 +78,7 @@ $alwayshiddencheckedmodules=array('accounting','barcode','bookmark','clicktodial 'memcached','numberwords','zipautofillfr'); $alwayshiddenuncheckedmodules=array('boutique','ftp', // Extended modules - 'awstats','bittorrent','cabinetmed','cmcic','concatpdf','dolicloud','filemanager','lightbox','mantis','monitoring','moretemplates','nltechno','numberingpack','openstreetmap', + 'awstats','bittorrent','bootstrap','cabinetmed','cmcic','concatpdf','customfield','dolicloud','filemanager','lightbox','mantis','monitoring','moretemplates','multicompany','nltechno','numberingpack','openstreetmap', 'ovh','phenix','phpsysinfo','pibarcode','postnuke','skincoloreditor','submiteverywhere','survey','thomsonphonebook','topten','tvacerfa','voyage','webcalendar','webmail'); // Search modules From 8682d3c928be430c7feec0537e1a547031d06271 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Jan 2013 12:16:00 +0100 Subject: [PATCH 018/162] Fix: Note not visible --- htdocs/compta/deplacement/fiche.php | 5 +++-- htdocs/core/tpl/bloc_showhide.tpl.php | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index f41cf6932ac..d13880f7559 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -522,7 +522,7 @@ else if ($id) print '
'; // Other attributes - $parameters=array('colspan' => ' colspan="3"'); + $parameters=array('colspan' => ' colspan="3"', 'showblocbydefault' => 1); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print "
'.$langs->trans("Status").''.$object->getLibStatut(4).'

"; @@ -578,7 +578,8 @@ else if ($id) } } -$db->close(); llxFooter(); + +$db->close(); ?> diff --git a/htdocs/core/tpl/bloc_showhide.tpl.php b/htdocs/core/tpl/bloc_showhide.tpl.php index d628a3e4579..2ac7ce4a397 100644 --- a/htdocs/core/tpl/bloc_showhide.tpl.php +++ b/htdocs/core/tpl/bloc_showhide.tpl.php @@ -1,5 +1,6 @@ + * Copyright (C) 2013 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 @@ -13,11 +14,11 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ -// Hide by default -$hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false); +$hide = true; // Hide by default +if (isset($parameters['showblocbydefault'])) $hide=(empty($parameters['showblocbydefault']) ? true : false); +if (isset($object->extraparams[$blocname]['showhide'])) $hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false); ?> From 9f44161e553966a0eeb6d30946dc141ed1ceedce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Jan 2013 12:47:06 +0100 Subject: [PATCH 019/162] New: Can attach file for trip and expenses module --- htdocs/compta/deplacement/document.php | 171 +++++++++++++++++++++++++ htdocs/core/lib/trip.lib.php | 11 +- htdocs/document.php | 11 ++ 3 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 htdocs/compta/deplacement/document.php diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php new file mode 100644 index 00000000000..9b07bccd7ae --- /dev/null +++ b/htdocs/compta/deplacement/document.php @@ -0,0 +1,171 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2011-2012 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 . + */ + +/** + * \file htdocs/compta/deplacement/document.php + * \ingroup deplacement + * \brief Page of linked files onto trip and expenses + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +$langs->load("other"); +$langs->load("trips"); +$langs->load("companies"); +$langs->load("interventions"); + +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'deplacement', $id, ''); + + +// Get parameters +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + + +$object = new Deplacement($db); +$object->fetch($id, $ref); + +$upload_dir = $conf->deplacement->dir_output.'/'.dol_sanitizeFileName($object->ref); +$modulepart='trip'; + + +/* + * Actions + */ + +if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + dol_add_file_process($upload_dir,0,1,'userfile'); +} + +// Delete +else if ($action == 'confirm_deletefile' && $confirm == 'yes') +{ + if ($object->id > 0) + { + $langs->load("other"); + $object->fetch_thirdparty(); + + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; + } +} + + +/* + * View + */ + +$form = new Form($db); + +llxHeader("","",$langs->trans("TripCard")); + + +if ($object->id) +{ + $object->fetch_thirdparty(); + + $head=trip_prepare_head($object, $user); + + dol_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Societe + //print ""; + + print ''; + print ''; + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); + print '
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + /* + * Confirmation suppression fichier + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + if ($ret == 'html') print '
'; + } + + // Affiche formulaire upload + $formfile=new FormFile($db); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/deplacement/document.php?id='.$object->id,'',0,0,$user->rights->deplacement->creer,50,$object); + + + // List of document + $param='&id='.$object->id; + $formfile->list_of_documents($filearray,$object,'deplacement',$param); + +} +else +{ + print $langs->trans("UnkownError"); +} + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php index 7655e68e6c0..309bcf33224 100644 --- a/htdocs/core/lib/trip.lib.php +++ b/htdocs/core/lib/trip.lib.php @@ -45,11 +45,16 @@ function trip_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'trip'); - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; - $head[$h][1] = $langs->trans("Info"); - $head[$h][2] = 'info'; + $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/document.php?id='.$object->id; + $head[$h][1] = $langs->trans("Documents"); + $head[$h][2] = 'documents'; $h++; + $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove'); return $head; diff --git a/htdocs/document.php b/htdocs/document.php index 537ad4657c6..29d189f9a83 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -137,6 +137,17 @@ if ($modulepart) $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$refname."' AND entity=".$conf->entity; } + // Wrapping pour les deplacements et notes de frais + else if ($modulepart == 'deplacement') + { + if ($user->rights->deplacement->lire || preg_match('/^specimen/i',$original_file)) + { + $accessallowed=1; + } + $original_file=$conf->deplacement->dir_output.'/'.$original_file; + //$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$refname."' AND entity=".$conf->entity; + } + // Wrapping pour les prelevements else if ($modulepart == 'prelevement') { From 03d6903248e748881f316a52769aa532cbf8f817 Mon Sep 17 00:00:00 2001 From: simnandez Date: Thu, 24 Jan 2013 12:53:42 +0100 Subject: [PATCH 020/162] Fix: [ bug #698 ] Bad calculation of totals of associated documents --- htdocs/comm/propal/tpl/linkedobjectblock.tpl.php | 4 +++- htdocs/commande/tpl/linkedobjectblock.tpl.php | 4 +++- htdocs/compta/facture/tpl/linkedobjectblock.tpl.php | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 4337611066e..e9ad176a86d 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 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 @@ -37,6 +38,7 @@ print_titre($langs->trans('RelatedCommercialProposals')); +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 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 @@ -38,6 +39,7 @@ print_titre($langs->trans('RelatedOrders')); +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 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 @@ -38,6 +39,7 @@ else print_titre($langs->trans("RelatedBill")); Date: Thu, 24 Jan 2013 17:29:11 +0100 Subject: [PATCH 021/162] New: add hook getFormMail --- htdocs/core/class/html.formmail.class.php | 835 +++++++++++----------- 1 file changed, 429 insertions(+), 406 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 3d15fdbeeee..c221cc33c07 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -217,422 +217,445 @@ class FormMail function get_form($addfileaction='addfile',$removefileaction='removefile') { global $conf, $langs, $user; + global $hookmanager; $langs->load("other"); $langs->load("mails"); - $out=''; - - // Define list of attached files - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); - if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); - if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - - - $form=new Form($this->db); - - $out.= "\n\n"; - if ($this->withform) + if (! is_object($hookmanager)) { - $out.= ''."\n"; - $out.= ''; + if (! class_exists('HookManager')) { + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array + require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } } - foreach ($this->param as $key=>$value) + $hookmanager->initHooks(array('formmail')); + + $parameters=array( + 'addfileaction' => $addfileaction, + 'removefileaction'=> $removefileaction + ); + $reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this); + + if (!empty($reshook)) { - $out.= ''."\n"; + return $hookmanager->resPrint; } - $out.= ''."\n"; - - // Substitution array - if (! empty($this->withsubstit)) + else { - $out.= '\n"; + $out=''; + + // Define list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); + + $form=new Form($this->db); + + $out.= "\n\n"; + if ($this->withform) + { + $out.= ''."\n"; + $out.= ''; + } + foreach ($this->param as $key=>$value) + { + $out.= ''."\n"; + } + $out.= '
'; - $help=""; - foreach($this->substit as $key => $val) - { - $help.=$key.' -> '.$langs->trans($val).'
'; - } - $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); - $out.= "
'."\n"; + + // Substitution array + if (! empty($this->withsubstit)) + { + $out.= '\n"; + } + + // From + if (! empty($this->withfrom)) + { + if (! empty($this->withfromreadonly)) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + $out.= "\n"; + } + else + { + $out.= "\n"; + } + } + + // Replyto + if (! empty($this->withreplyto)) + { + if ($this->withreplytoreadonly) + { + $out.= ''; + $out.= ''; + $out.= "\n"; + } + } + + // Errorsto + if (! empty($this->witherrorsto)) + { + //if (! $this->errorstomail) $this->errorstomail=$this->frommail; + $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); + if ($this->witherrorstoreadonly) + { + $out.= ''; + $out.= '\n"; + } + else + { + $out.= '\n"; + } + } + + // To + if (! empty($this->withto) || is_array($this->withto)) + { + $out.= '\n"; + } + + // CC + if (! empty($this->withtocc) || is_array($this->withtocc)) + { + $out.= '\n"; + } + + // CCC + if (! empty($this->withtoccc) || is_array($this->withtoccc)) + { + $out.= '\n"; + } + + // Ask delivery receipt + if (! empty($this->withdeliveryreceipt)) + { + $out.= '\n"; + } + + // Topic + if (! empty($this->withtopic)) + { + $this->withtopic=make_substitutions($this->withtopic,$this->substit); + + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + // Attached files + if (! empty($this->withfile)) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + // Message + if (! empty($this->withbody)) + { + $defaultmessage=""; + + // TODO A partir du type, proposer liste de messages dans table llx_models + if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } + + // Complete substitution array + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) + { + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + + $langs->load('paypal'); + + if ($this->param["models"]=='order_send') + { + $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + if ($this->param["models"]=='facture_send') + { + $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + } + + $defaultmessage=make_substitutions($defaultmessage,$this->substit); + if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; + $defaultmessage=str_replace('\n',"\n",$defaultmessage); + + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + if (! empty($this->withform)) + { + $out.= ''."\n"; + } + + $out.= '
'; + $help=""; + foreach($this->substit as $key => $val) + { + $help.=$key.' -> '.$langs->trans($val).'
'; + } + $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); + $out.= "
'.$langs->trans("MailFrom").''; + if ($this->fromtype == 'user' && $this->fromid > 0) + { + $langs->load("users"); + $fuser=new User($this->db); + $fuser->fetch($this->fromid); + $out.= $fuser->getNomUrl(1); + } + else + { + $out.= $this->fromname; + } + if ($this->frommail) + { + $out.= " <".$this->frommail.">"; + } + else + { + if ($this->fromtype) + { + $langs->load("errors"); + $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; + } + } + $out.= "
".$langs->trans("MailFrom").""; + $out.= $langs->trans("Name").':'; + $out.= '    '; + $out.= $langs->trans("EMail").':<>'; + $out.= "
".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); + $out.= "
'.$langs->trans("MailErrorsTo").''; + $out.= $errorstomail; + $out.= "
'.$langs->trans("MailErrorsTo").''; + $out.= ''; + $out.= "
'; + if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + else $out.= $langs->trans("MailTo"); + $out.= ''; + if ($this->withtoreadonly) + { + if (! empty($this->toname) && ! empty($this->tomail)) + { + $out.= ''; + $out.= ''; + if ($this->totype == 'thirdparty') + { + $soc=new Societe($this->db); + $soc->fetch($this->toid); + $out.= $soc->getNomUrl(1); + } + else if ($this->totype == 'contact') + { + $contact=new Contact($this->db); + $contact->fetch($this->toid); + $out.= $contact->getNomUrl(1); + } + else + { + $out.= $this->toname; + } + $out.= ' <'.$this->tomail.'>'; + if ($this->withtofree) + { + $out.= '
'.$langs->trans("or").' withto) :"").'" />'; + } + } + else + { + $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; + } + } + else + { + if (! empty($this->withtofree)) + { + $out.= 'withto) :"").'" />'; + } + if (! empty($this->withto) && is_array($this->withto)) + { + if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); + } + if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + if ($this->withtofree) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); + } + } + $out.= "
'; + $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if ($this->withtoccreadonly) + { + $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; + } + else + { + $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); + } + if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtoccsocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); + } + } + $out.= "
'; + $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if (! empty($this->withtocccreadonly)) + { + $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + } + else + { + $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); + } + if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); + } + } + //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); + $out.= "
'.$langs->trans("DeliveryReceipt").''; + + if (! empty($this->withdeliveryreceiptreadonly)) + { + $out.= yn($this->withdeliveryreceipt); + } + else + { + $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); + } + + $out.= "
'.$langs->trans("MailTopic").''; + if ($this->withtopicreadonly) + { + $out.= $this->withtopic; + $out.= ''; + } + else + { + $out.= 'withtopic) .'" />'; + } + $out.= "
'.$langs->trans("MailFile").''; + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + $out.= ''."\n"; + $out.= ''."\n"; + if (count($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $out.= '
'; + $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (! $this->withfilereadonly) + { + $out.= ' '; + //$out.= ' '.img_delete($langs->trans("Delete").''; + } + $out.= '
'; + } + } + else + { + $out.= $langs->trans("NoAttachedFiles").'
'; + } + if ($this->withfile == 2) // Can add other files + { + $out.= ''; + $out.= ' '; + $out.= ''; + } + $out.= "
'.$langs->trans("MailText").''; + if ($this->withbodyreadonly) + { + $out.= nl2br($defaultmessage); + $out.= ''; + } + else + { + if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); + $out.= $doleditor->Create(1); + } + $out.= "
'; + $out.= 'withfile == 2 && $conf->use_javascript_ajax) + { + $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; + } + $out.= ' />'; + if ($this->withcancel) + { + $out.= '     '; + $out.= ''; + } + $out.= '
'."\n"; + + if (! empty($this->withform)) $out.= ''."\n"; + $out.= "\n"; + + return $out; } - - // From - if (! empty($this->withfrom)) - { - if (! empty($this->withfromreadonly)) - { - $out.= ''; - $out.= ''; - $out.= ''.$langs->trans("MailFrom").''; - if ($this->fromtype == 'user' && $this->fromid > 0) - { - $langs->load("users"); - $fuser=new User($this->db); - $fuser->fetch($this->fromid); - $out.= $fuser->getNomUrl(1); - } - else - { - $out.= $this->fromname; - } - if ($this->frommail) - { - $out.= " <".$this->frommail.">"; - } - else - { - if ($this->fromtype) - { - $langs->load("errors"); - $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; - } - } - $out.= "\n"; - $out.= "\n"; - } - else - { - $out.= "".$langs->trans("MailFrom").""; - $out.= $langs->trans("Name").':'; - $out.= '    '; - $out.= $langs->trans("EMail").':<>'; - $out.= "\n"; - } - } - - // Replyto - if (! empty($this->withreplyto)) - { - if ($this->withreplytoreadonly) - { - $out.= ''; - $out.= ''; - $out.= "".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); - $out.= "\n"; - } - } - - // Errorsto - if (! empty($this->witherrorsto)) - { - //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); - if ($this->witherrorstoreadonly) - { - $out.= ''; - $out.= ''.$langs->trans("MailErrorsTo").''; - $out.= $errorstomail; - $out.= "\n"; - } - else - { - $out.= ''.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= "\n"; - } - } - - // To - if (! empty($this->withto) || is_array($this->withto)) - { - $out.= ''; - if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - else $out.= $langs->trans("MailTo"); - $out.= ''; - if ($this->withtoreadonly) - { - if (! empty($this->toname) && ! empty($this->tomail)) - { - $out.= ''; - $out.= ''; - if ($this->totype == 'thirdparty') - { - $soc=new Societe($this->db); - $soc->fetch($this->toid); - $out.= $soc->getNomUrl(1); - } - else if ($this->totype == 'contact') - { - $contact=new Contact($this->db); - $contact->fetch($this->toid); - $out.= $contact->getNomUrl(1); - } - else - { - $out.= $this->toname; - } - $out.= ' <'.$this->tomail.'>'; - if ($this->withtofree) - { - $out.= '
'.$langs->trans("or").' withto) :"").'" />'; - } - } - else - { - $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; - } - } - else - { - if (! empty($this->withtofree)) - { - $out.= 'withto) :"").'" />'; - } - if (! empty($this->withto) && is_array($this->withto)) - { - if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); - } - if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - if ($this->withtofree) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); - } - } - $out.= "\n"; - } - - // CC - if (! empty($this->withtocc) || is_array($this->withtocc)) - { - $out.= ''; - $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if ($this->withtoccreadonly) - { - $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; - } - else - { - $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); - } - if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtoccsocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); - } - } - $out.= "\n"; - } - - // CCC - if (! empty($this->withtoccc) || is_array($this->withtoccc)) - { - $out.= ''; - $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if (! empty($this->withtocccreadonly)) - { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; - } - else - { - $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); - } - if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); - } - } - //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); - $out.= "\n"; - } - - // Ask delivery receipt - if (! empty($this->withdeliveryreceipt)) - { - $out.= ''.$langs->trans("DeliveryReceipt").''; - - if (! empty($this->withdeliveryreceiptreadonly)) - { - $out.= yn($this->withdeliveryreceipt); - } - else - { - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); - } - - $out.= "\n"; - } - - // Topic - if (! empty($this->withtopic)) - { - $this->withtopic=make_substitutions($this->withtopic,$this->substit); - - $out.= ''; - $out.= ''.$langs->trans("MailTopic").''; - $out.= ''; - if ($this->withtopicreadonly) - { - $out.= $this->withtopic; - $out.= ''; - } - else - { - $out.= 'withtopic) .'" />'; - } - $out.= "\n"; - } - - // Attached files - if (! empty($this->withfile)) - { - $out.= ''; - $out.= ''.$langs->trans("MailFile").''; - $out.= ''; - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out.= ''."\n"; - $out.= ''."\n"; - if (count($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $out.= '
'; - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) - { - $out.= ' '; - //$out.= ' '.img_delete($langs->trans("Delete").''; - } - $out.= '
'; - } - } - else - { - $out.= $langs->trans("NoAttachedFiles").'
'; - } - if ($this->withfile == 2) // Can add other files - { - $out.= ''; - $out.= ' '; - $out.= ''; - } - $out.= "\n"; - } - - // Message - if (! empty($this->withbody)) - { - $defaultmessage=""; - - // TODO A partir du type, proposer liste de messages dans table llx_models - if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } - - // Complete substitution array - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) - { - require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; - - $langs->load('paypal'); - - if ($this->param["models"]=='order_send') - { - $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - if ($this->param["models"]=='facture_send') - { - $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - } - - $defaultmessage=make_substitutions($defaultmessage,$this->substit); - if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; - $defaultmessage=str_replace('\n',"\n",$defaultmessage); - - $out.= ''; - $out.= ''.$langs->trans("MailText").''; - $out.= ''; - if ($this->withbodyreadonly) - { - $out.= nl2br($defaultmessage); - $out.= ''; - } - else - { - if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); - $out.= $doleditor->Create(1); - } - $out.= "\n"; - } - - if (! empty($this->withform)) - { - $out.= '
'; - $out.= 'withfile == 2 && $conf->use_javascript_ajax) - { - $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; - } - $out.= ' />'; - if ($this->withcancel) - { - $out.= '     '; - $out.= ''; - } - $out.= '
'."\n"; - } - - $out.= ''."\n"; - - if (! empty($this->withform)) $out.= ''."\n"; - $out.= "\n"; - - return $out; } } From c688e2afab1196928363d12acefd8f4dbddaa458 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 24 Jan 2013 17:29:11 +0100 Subject: [PATCH 022/162] New: add hook getFormMail --- htdocs/core/class/html.formmail.class.php | 835 +++++++++++----------- 1 file changed, 429 insertions(+), 406 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 3d15fdbeeee..c221cc33c07 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -217,422 +217,445 @@ class FormMail function get_form($addfileaction='addfile',$removefileaction='removefile') { global $conf, $langs, $user; + global $hookmanager; $langs->load("other"); $langs->load("mails"); - $out=''; - - // Define list of attached files - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); - if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); - if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - - - $form=new Form($this->db); - - $out.= "\n\n"; - if ($this->withform) + if (! is_object($hookmanager)) { - $out.= '
'."\n"; - $out.= ''; + if (! class_exists('HookManager')) { + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array + require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } } - foreach ($this->param as $key=>$value) + $hookmanager->initHooks(array('formmail')); + + $parameters=array( + 'addfileaction' => $addfileaction, + 'removefileaction'=> $removefileaction + ); + $reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this); + + if (!empty($reshook)) { - $out.= ''."\n"; + return $hookmanager->resPrint; } - $out.= ''."\n"; - - // Substitution array - if (! empty($this->withsubstit)) + else { - $out.= '\n"; + $out=''; + + // Define list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); + + $form=new Form($this->db); + + $out.= "\n\n"; + if ($this->withform) + { + $out.= ''."\n"; + $out.= ''; + } + foreach ($this->param as $key=>$value) + { + $out.= ''."\n"; + } + $out.= '
'; - $help=""; - foreach($this->substit as $key => $val) - { - $help.=$key.' -> '.$langs->trans($val).'
'; - } - $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); - $out.= "
'."\n"; + + // Substitution array + if (! empty($this->withsubstit)) + { + $out.= '\n"; + } + + // From + if (! empty($this->withfrom)) + { + if (! empty($this->withfromreadonly)) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + $out.= "\n"; + } + else + { + $out.= "\n"; + } + } + + // Replyto + if (! empty($this->withreplyto)) + { + if ($this->withreplytoreadonly) + { + $out.= ''; + $out.= ''; + $out.= "\n"; + } + } + + // Errorsto + if (! empty($this->witherrorsto)) + { + //if (! $this->errorstomail) $this->errorstomail=$this->frommail; + $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); + if ($this->witherrorstoreadonly) + { + $out.= ''; + $out.= '\n"; + } + else + { + $out.= '\n"; + } + } + + // To + if (! empty($this->withto) || is_array($this->withto)) + { + $out.= '\n"; + } + + // CC + if (! empty($this->withtocc) || is_array($this->withtocc)) + { + $out.= '\n"; + } + + // CCC + if (! empty($this->withtoccc) || is_array($this->withtoccc)) + { + $out.= '\n"; + } + + // Ask delivery receipt + if (! empty($this->withdeliveryreceipt)) + { + $out.= '\n"; + } + + // Topic + if (! empty($this->withtopic)) + { + $this->withtopic=make_substitutions($this->withtopic,$this->substit); + + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + // Attached files + if (! empty($this->withfile)) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + // Message + if (! empty($this->withbody)) + { + $defaultmessage=""; + + // TODO A partir du type, proposer liste de messages dans table llx_models + if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } + + // Complete substitution array + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) + { + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + + $langs->load('paypal'); + + if ($this->param["models"]=='order_send') + { + $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + if ($this->param["models"]=='facture_send') + { + $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + } + + $defaultmessage=make_substitutions($defaultmessage,$this->substit); + if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; + $defaultmessage=str_replace('\n',"\n",$defaultmessage); + + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + if (! empty($this->withform)) + { + $out.= ''."\n"; + } + + $out.= '
'; + $help=""; + foreach($this->substit as $key => $val) + { + $help.=$key.' -> '.$langs->trans($val).'
'; + } + $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); + $out.= "
'.$langs->trans("MailFrom").''; + if ($this->fromtype == 'user' && $this->fromid > 0) + { + $langs->load("users"); + $fuser=new User($this->db); + $fuser->fetch($this->fromid); + $out.= $fuser->getNomUrl(1); + } + else + { + $out.= $this->fromname; + } + if ($this->frommail) + { + $out.= " <".$this->frommail.">"; + } + else + { + if ($this->fromtype) + { + $langs->load("errors"); + $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; + } + } + $out.= "
".$langs->trans("MailFrom").""; + $out.= $langs->trans("Name").':'; + $out.= '    '; + $out.= $langs->trans("EMail").':<>'; + $out.= "
".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); + $out.= "
'.$langs->trans("MailErrorsTo").''; + $out.= $errorstomail; + $out.= "
'.$langs->trans("MailErrorsTo").''; + $out.= ''; + $out.= "
'; + if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + else $out.= $langs->trans("MailTo"); + $out.= ''; + if ($this->withtoreadonly) + { + if (! empty($this->toname) && ! empty($this->tomail)) + { + $out.= ''; + $out.= ''; + if ($this->totype == 'thirdparty') + { + $soc=new Societe($this->db); + $soc->fetch($this->toid); + $out.= $soc->getNomUrl(1); + } + else if ($this->totype == 'contact') + { + $contact=new Contact($this->db); + $contact->fetch($this->toid); + $out.= $contact->getNomUrl(1); + } + else + { + $out.= $this->toname; + } + $out.= ' <'.$this->tomail.'>'; + if ($this->withtofree) + { + $out.= '
'.$langs->trans("or").' withto) :"").'" />'; + } + } + else + { + $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; + } + } + else + { + if (! empty($this->withtofree)) + { + $out.= 'withto) :"").'" />'; + } + if (! empty($this->withto) && is_array($this->withto)) + { + if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); + } + if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + if ($this->withtofree) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); + } + } + $out.= "
'; + $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if ($this->withtoccreadonly) + { + $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; + } + else + { + $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); + } + if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtoccsocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); + } + } + $out.= "
'; + $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if (! empty($this->withtocccreadonly)) + { + $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + } + else + { + $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); + } + if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); + } + } + //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); + $out.= "
'.$langs->trans("DeliveryReceipt").''; + + if (! empty($this->withdeliveryreceiptreadonly)) + { + $out.= yn($this->withdeliveryreceipt); + } + else + { + $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); + } + + $out.= "
'.$langs->trans("MailTopic").''; + if ($this->withtopicreadonly) + { + $out.= $this->withtopic; + $out.= ''; + } + else + { + $out.= 'withtopic) .'" />'; + } + $out.= "
'.$langs->trans("MailFile").''; + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + $out.= ''."\n"; + $out.= ''."\n"; + if (count($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $out.= '
'; + $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (! $this->withfilereadonly) + { + $out.= ' '; + //$out.= ' '.img_delete($langs->trans("Delete").''; + } + $out.= '
'; + } + } + else + { + $out.= $langs->trans("NoAttachedFiles").'
'; + } + if ($this->withfile == 2) // Can add other files + { + $out.= ''; + $out.= ' '; + $out.= ''; + } + $out.= "
'.$langs->trans("MailText").''; + if ($this->withbodyreadonly) + { + $out.= nl2br($defaultmessage); + $out.= ''; + } + else + { + if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); + $out.= $doleditor->Create(1); + } + $out.= "
'; + $out.= 'withfile == 2 && $conf->use_javascript_ajax) + { + $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; + } + $out.= ' />'; + if ($this->withcancel) + { + $out.= '     '; + $out.= ''; + } + $out.= '
'."\n"; + + if (! empty($this->withform)) $out.= '
'."\n"; + $out.= "\n"; + + return $out; } - - // From - if (! empty($this->withfrom)) - { - if (! empty($this->withfromreadonly)) - { - $out.= ''; - $out.= ''; - $out.= ''.$langs->trans("MailFrom").''; - if ($this->fromtype == 'user' && $this->fromid > 0) - { - $langs->load("users"); - $fuser=new User($this->db); - $fuser->fetch($this->fromid); - $out.= $fuser->getNomUrl(1); - } - else - { - $out.= $this->fromname; - } - if ($this->frommail) - { - $out.= " <".$this->frommail.">"; - } - else - { - if ($this->fromtype) - { - $langs->load("errors"); - $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; - } - } - $out.= "\n"; - $out.= "\n"; - } - else - { - $out.= "".$langs->trans("MailFrom").""; - $out.= $langs->trans("Name").':'; - $out.= '    '; - $out.= $langs->trans("EMail").':<>'; - $out.= "\n"; - } - } - - // Replyto - if (! empty($this->withreplyto)) - { - if ($this->withreplytoreadonly) - { - $out.= ''; - $out.= ''; - $out.= "".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); - $out.= "\n"; - } - } - - // Errorsto - if (! empty($this->witherrorsto)) - { - //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); - if ($this->witherrorstoreadonly) - { - $out.= ''; - $out.= ''.$langs->trans("MailErrorsTo").''; - $out.= $errorstomail; - $out.= "\n"; - } - else - { - $out.= ''.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= "\n"; - } - } - - // To - if (! empty($this->withto) || is_array($this->withto)) - { - $out.= ''; - if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - else $out.= $langs->trans("MailTo"); - $out.= ''; - if ($this->withtoreadonly) - { - if (! empty($this->toname) && ! empty($this->tomail)) - { - $out.= ''; - $out.= ''; - if ($this->totype == 'thirdparty') - { - $soc=new Societe($this->db); - $soc->fetch($this->toid); - $out.= $soc->getNomUrl(1); - } - else if ($this->totype == 'contact') - { - $contact=new Contact($this->db); - $contact->fetch($this->toid); - $out.= $contact->getNomUrl(1); - } - else - { - $out.= $this->toname; - } - $out.= ' <'.$this->tomail.'>'; - if ($this->withtofree) - { - $out.= '
'.$langs->trans("or").' withto) :"").'" />'; - } - } - else - { - $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; - } - } - else - { - if (! empty($this->withtofree)) - { - $out.= 'withto) :"").'" />'; - } - if (! empty($this->withto) && is_array($this->withto)) - { - if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); - } - if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - if ($this->withtofree) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); - } - } - $out.= "\n"; - } - - // CC - if (! empty($this->withtocc) || is_array($this->withtocc)) - { - $out.= ''; - $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if ($this->withtoccreadonly) - { - $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; - } - else - { - $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); - } - if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtoccsocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); - } - } - $out.= "\n"; - } - - // CCC - if (! empty($this->withtoccc) || is_array($this->withtoccc)) - { - $out.= ''; - $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if (! empty($this->withtocccreadonly)) - { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; - } - else - { - $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); - } - if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); - } - } - //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); - $out.= "\n"; - } - - // Ask delivery receipt - if (! empty($this->withdeliveryreceipt)) - { - $out.= ''.$langs->trans("DeliveryReceipt").''; - - if (! empty($this->withdeliveryreceiptreadonly)) - { - $out.= yn($this->withdeliveryreceipt); - } - else - { - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); - } - - $out.= "\n"; - } - - // Topic - if (! empty($this->withtopic)) - { - $this->withtopic=make_substitutions($this->withtopic,$this->substit); - - $out.= ''; - $out.= ''.$langs->trans("MailTopic").''; - $out.= ''; - if ($this->withtopicreadonly) - { - $out.= $this->withtopic; - $out.= ''; - } - else - { - $out.= 'withtopic) .'" />'; - } - $out.= "\n"; - } - - // Attached files - if (! empty($this->withfile)) - { - $out.= ''; - $out.= ''.$langs->trans("MailFile").''; - $out.= ''; - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out.= ''."\n"; - $out.= ''."\n"; - if (count($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $out.= '
'; - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) - { - $out.= ' '; - //$out.= ' '.img_delete($langs->trans("Delete").''; - } - $out.= '
'; - } - } - else - { - $out.= $langs->trans("NoAttachedFiles").'
'; - } - if ($this->withfile == 2) // Can add other files - { - $out.= ''; - $out.= ' '; - $out.= ''; - } - $out.= "\n"; - } - - // Message - if (! empty($this->withbody)) - { - $defaultmessage=""; - - // TODO A partir du type, proposer liste de messages dans table llx_models - if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } - - // Complete substitution array - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) - { - require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; - - $langs->load('paypal'); - - if ($this->param["models"]=='order_send') - { - $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - if ($this->param["models"]=='facture_send') - { - $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - } - - $defaultmessage=make_substitutions($defaultmessage,$this->substit); - if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; - $defaultmessage=str_replace('\n',"\n",$defaultmessage); - - $out.= ''; - $out.= ''.$langs->trans("MailText").''; - $out.= ''; - if ($this->withbodyreadonly) - { - $out.= nl2br($defaultmessage); - $out.= ''; - } - else - { - if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); - $out.= $doleditor->Create(1); - } - $out.= "\n"; - } - - if (! empty($this->withform)) - { - $out.= '
'; - $out.= 'withfile == 2 && $conf->use_javascript_ajax) - { - $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; - } - $out.= ' />'; - if ($this->withcancel) - { - $out.= '     '; - $out.= ''; - } - $out.= '
'."\n"; - } - - $out.= ''."\n"; - - if (! empty($this->withform)) $out.= ''."\n"; - $out.= "\n"; - - return $out; } } From 8ab450f69b50e78f34adf496c5a54b959552b8db Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 24 Jan 2013 17:54:51 +0100 Subject: [PATCH 023/162] Multicompany restriction for transverse mode not used anymore. RestrictedArea is enough --- htdocs/user/fiche.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 6172b08c740..7ce2640710a 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -67,12 +67,6 @@ if ($id) || (($user->id != $id) && $user->rights->user->user->password)); } -//Multicompany in mode transversal -if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode) -{ - accessforbidden(); -} - // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; From 7facbf7aa275694cd52b12ccc2eb5df8a1f65e55 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 24 Jan 2013 17:54:51 +0100 Subject: [PATCH 024/162] Multicompany restriction for transverse mode not used anymore. RestrictedArea is enough --- htdocs/user/fiche.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index bc0caf8d469..222ab62b846 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -67,12 +67,6 @@ if ($id) || (($user->id != $id) && $user->rights->user->user->password)); } -//Multicompany in mode transversal -if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode) -{ - accessforbidden(); -} - // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; From 70b21172f9090635b953fb17cccfc426b2fe9a71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 11:05:44 +0100 Subject: [PATCH 025/162] Qual: Removed not used and deprecated property --- htdocs/core/menus/smartphone/smartphone_backoffice.php | 2 -- htdocs/core/menus/smartphone/smartphone_frontoffice.php | 1 - htdocs/core/menus/standard/auguria_backoffice.php | 1 - htdocs/core/menus/standard/auguria_frontoffice.php | 1 - htdocs/core/menus/standard/eldy_backoffice.php | 1 - htdocs/core/menus/standard/eldy_frontoffice.php | 1 - htdocs/core/menus/standard/empty.php | 1 - 7 files changed, 8 deletions(-) diff --git a/htdocs/core/menus/smartphone/smartphone_backoffice.php b/htdocs/core/menus/smartphone/smartphone_backoffice.php index a909cce6826..e0144c6913f 100755 --- a/htdocs/core/menus/smartphone/smartphone_backoffice.php +++ b/htdocs/core/menus/smartphone/smartphone_backoffice.php @@ -28,8 +28,6 @@ class MenuSmart { var $db; - var $require_left=array("smartphone_backoffice"); // Si doit etre en phase avec un gestionnaire de menu particulier - var $hideifnotallowed=0; // Put 0 for back office menu, 1 for front office menu var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/smartphone/smartphone_frontoffice.php b/htdocs/core/menus/smartphone/smartphone_frontoffice.php index 4c17eca4447..9120537fa5b 100755 --- a/htdocs/core/menus/smartphone/smartphone_frontoffice.php +++ b/htdocs/core/menus/smartphone/smartphone_frontoffice.php @@ -28,7 +28,6 @@ class MenuSmart { - var $require_left=array("smartphone_frontoffice"); // Si doit etre en phase avec un gestionnaire de menu particulier var $hideifnotallowed=1; // Put 0 for back office menu, 1 for front office menu var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/auguria_backoffice.php b/htdocs/core/menus/standard/auguria_backoffice.php index 3c05a0f6170..a22c40ed315 100644 --- a/htdocs/core/menus/standard/auguria_backoffice.php +++ b/htdocs/core/menus/standard/auguria_backoffice.php @@ -34,7 +34,6 @@ class MenuManager { var $db; - var $require_left=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/auguria_frontoffice.php b/htdocs/core/menus/standard/auguria_frontoffice.php index 151abfbe9cc..cb8299feee3 100644 --- a/htdocs/core/menus/standard/auguria_frontoffice.php +++ b/htdocs/core/menus/standard/auguria_frontoffice.php @@ -34,7 +34,6 @@ class MenuManager { var $db; - var $require_left=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=1; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/eldy_backoffice.php b/htdocs/core/menus/standard/eldy_backoffice.php index ab00caccb3a..638fd45664d 100644 --- a/htdocs/core/menus/standard/eldy_backoffice.php +++ b/htdocs/core/menus/standard/eldy_backoffice.php @@ -33,7 +33,6 @@ class MenuManager { var $db; - var $require_left=array("eldy_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/eldy_frontoffice.php b/htdocs/core/menus/standard/eldy_frontoffice.php index 5ec673afe68..2221e0ec9f0 100644 --- a/htdocs/core/menus/standard/eldy_frontoffice.php +++ b/htdocs/core/menus/standard/eldy_frontoffice.php @@ -33,7 +33,6 @@ class MenuManager { var $db; - var $require_left=array("eldy_frontoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=1; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index da3eab44025..705dc2cf293 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -26,7 +26,6 @@ class MenuManager { var $db; - var $require_left=array("empty"); // If this top menu handler must be used with a particular left menu handler var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // To store arget to use in menu links From ad3645f7f4e654a1464e3c44cb9f2863b17fc70c Mon Sep 17 00:00:00 2001 From: simnandez Date: Thu, 24 Jan 2013 12:53:42 +0100 Subject: [PATCH 026/162] Fix: [ bug #698 ] Bad calculation of totals of associated documents --- htdocs/comm/propal/tpl/linkedobjectblock.tpl.php | 4 +++- htdocs/commande/tpl/linkedobjectblock.tpl.php | 4 +++- htdocs/compta/facture/tpl/linkedobjectblock.tpl.php | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 4337611066e..e9ad176a86d 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 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 @@ -37,6 +38,7 @@ print_titre($langs->trans('RelatedCommercialProposals')); +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 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 @@ -38,6 +39,7 @@ print_titre($langs->trans('RelatedOrders')); +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 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 @@ -38,6 +39,7 @@ else print_titre($langs->trans("RelatedBill")); Date: Fri, 25 Jan 2013 12:37:03 +0100 Subject: [PATCH 027/162] Fix: wrong object name --- htdocs/fourn/facture/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index b093d290a01..241c17b7cef 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -2078,7 +2078,7 @@ else $formmail->frommail = $user->email; $formmail->withfrom=1; $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$soc->id; + $formmail->withtosocid=$societe->id; $formmail->withtocc=1; $formmail->withtoccsocid=0; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; From e3be718a571627add1c1c6153d10a78cd4d87625 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 25 Jan 2013 12:37:03 +0100 Subject: [PATCH 028/162] Fix: wrong object name --- htdocs/fourn/facture/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 99e1bf5da0a..936fbd08572 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -2078,7 +2078,7 @@ else $formmail->frommail = $user->email; $formmail->withfrom=1; $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$soc->id; + $formmail->withtosocid=$societe->id; $formmail->withtocc=1; $formmail->withtoccsocid=0; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; From b11441555c90d2143288508abb424cc1bd66e7d0 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 25 Jan 2013 15:39:26 +0100 Subject: [PATCH 029/162] LDAP : Add SID sync in user creation --- scripts/user/sync_users_ldap2dolibarr.php | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 758440e201e..036d45f79a6 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -200,6 +200,7 @@ if ($result >= 0) $fuser->user_mobile=$ldapuser[$conf->global->LDAP_FIELD_MOBILE]; $fuser->office_fax=$ldapuser[$conf->global->LDAP_FIELD_FAX]; $fuser->email=$ldapuser[$conf->global->LDAP_FIELD_MAIL]; + $fuser->ldap_sid=$ldapuser[$conf->global->LDAP_FIELD_SID]; $fuser->job=$ldapuser[$conf->global->LDAP_FIELD_TITLE]; $fuser->note=$ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION]; From 2aa548560b7c9b1390c206801cc883dcdf7a30a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 16:52:23 +0100 Subject: [PATCH 030/162] doc: Update exemples --- dev/skeletons/modMyModule.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 4d7bf0df4ae..355964273f2 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -106,7 +106,7 @@ class modMyModule extends DolibarrModules // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) // ); $this->const = array(); From c2d334624b1b8bb26d7ef0a49b10292a9e9f3f46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 17:44:23 +0100 Subject: [PATCH 031/162] Qual: Simplify system for menu manager. Only one file, one class per manager. --- ChangeLog | 5 +- htdocs/admin/menus.php | 4 - htdocs/core/class/html.formadmin.class.php | 8 +- .../smartphone/smartphone_backoffice.php | 60 --------------- ...ne_frontoffice.php => smartphone_menu.php} | 38 ++++++---- .../menus/standard/auguria_backoffice.php | 74 ------------------- ...guria_frontoffice.php => auguria_menu.php} | 35 ++++----- .../core/menus/standard/eldy_frontoffice.php | 33 +++++---- .../{eldy_backoffice.php => eldy_menu.php} | 38 ++++++---- .../install/mysql/migration/3.3.0-3.4.0.sql | 8 ++ htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + htdocs/main.inc.php | 19 +++-- 13 files changed, 111 insertions(+), 213 deletions(-) delete mode 100755 htdocs/core/menus/smartphone/smartphone_backoffice.php rename htdocs/core/menus/smartphone/{smartphone_frontoffice.php => smartphone_menu.php} (57%) delete mode 100644 htdocs/core/menus/standard/auguria_backoffice.php rename htdocs/core/menus/standard/{auguria_frontoffice.php => auguria_menu.php} (63%) rename htdocs/core/menus/standard/{eldy_backoffice.php => eldy_menu.php} (63%) diff --git a/ChangeLog b/ChangeLog index 46f482aeab9..8775d808037 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,9 +4,12 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.4 compared to 3.3 ***** For users: -- New: Some performance enhancements +- New: Some performance enhancements. +- New: Can attach files onto trip and expenses modules. For developers: +- System of menu managers has been rewritten to reduce code to do same things. +- An external module can force its theme. For translators: diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 23eade151a1..e40af9b75dc 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -77,10 +77,6 @@ if ($action == 'update' && empty($_POST["cancel"])) // Define list of menu handlers to initialize $listofmenuhandler=array(); - $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_STANDARD"])]=1; - $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_STANDARD"])]=1; - if (isset($_POST["MAIN_MENU_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_SMARTPHONE"])]=1; - if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1; // Initialize menu handlers foreach ($listofmenuhandler as $key => $val) diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index c60f1a81504..ccd3e038f74 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -121,7 +121,7 @@ class FormAdmin global $langs,$conf; // Clean parameters - if ($selected == 'eldy.php') $selected='eldy_backoffice.php'; // For compatibility + // Check parameters if (! is_array($dirmenuarray)) return -1; @@ -143,7 +143,11 @@ class FormAdmin if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index') { if (preg_match('/lib\.php$/i',$file)) continue; // We exclude library files - $filelib=preg_replace('/\.php$/i','',$file); + if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files + if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files + if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files + + $filelib=preg_replace('/\.php$/i','',$file); $prefix=''; // 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other if (preg_match('/^eldy/i',$file)) $prefix='0'; diff --git a/htdocs/core/menus/smartphone/smartphone_backoffice.php b/htdocs/core/menus/smartphone/smartphone_backoffice.php deleted file mode 100755 index e0144c6913f..00000000000 --- a/htdocs/core/menus/smartphone/smartphone_backoffice.php +++ /dev/null @@ -1,60 +0,0 @@ - - * Copyright (C) 2007-2010 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/core/menus/smartphone/smartphone_backoffice.php - * \brief Gestionnaire nomme smartphone du menu smartphone - */ - - -/** - * Class to manage smartphone menu smartphone (for internal users) - */ -class MenuSmart -{ - var $db; - var $atarget=""; // Valeur du target a utiliser dans les liens - - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - /** - * Show menu - * - * @param string $limitmenuto To limit menu to a top or left menu value - * @return void - */ - function showmenu($limitmenuto) - { - require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php'; - - print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$limitmenuto); - } - -} - -?> \ No newline at end of file diff --git a/htdocs/core/menus/smartphone/smartphone_frontoffice.php b/htdocs/core/menus/smartphone/smartphone_menu.php similarity index 57% rename from htdocs/core/menus/smartphone/smartphone_frontoffice.php rename to htdocs/core/menus/smartphone/smartphone_menu.php index 9120537fa5b..e95bdc1df09 100755 --- a/htdocs/core/menus/smartphone/smartphone_frontoffice.php +++ b/htdocs/core/menus/smartphone/smartphone_menu.php @@ -17,45 +17,57 @@ */ /** - * \file htdocs/core/menus/smartphone/smartphone_frontoffice.php - * \brief Gestionnaire nomme smartphone du menu smartphone + * \file htdocs/core/menus/smartphone/smartphone_menu.php + * \brief Menu smartphone manager */ /** - * Class to manage smartphone menu smartphone (for external users) + * Class to manage smartphone menu smartphone */ class MenuSmart { var $hideifnotallowed=1; // Put 0 for back office menu, 1 for front office menu var $atarget=""; // Valeur du target a utiliser dans les liens - + var $name="smartphone"; + /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param int $type_user Type of user */ - function __construct($db) + function __construct($db, $type_user) { $this->db=$db; } /** - * Show menu + * Show menu * - * @param string $limitmenuto To limit menu to a top or left menu value - * @return void + * @param string $mode 'top' or 'left' + * @return int Number of menu entries shown */ - function showmenu($limitmenuto) + function showmenu($mode) { - require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php'; + global $conf; + + require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php'; - print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$limitmenuto); + if ($this->type_user == 1) + { + $conf->global->MAIN_SEARCHFORM_SOCIETE=0; + $conf->global->MAIN_SEARCHFORM_CONTACT=0; + } + + print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$mode); + + return 1; } } -?> +?> \ No newline at end of file diff --git a/htdocs/core/menus/standard/auguria_backoffice.php b/htdocs/core/menus/standard/auguria_backoffice.php deleted file mode 100644 index a22c40ed315..00000000000 --- a/htdocs/core/menus/standard/auguria_backoffice.php +++ /dev/null @@ -1,74 +0,0 @@ - - * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2008-2013 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 . - */ - -/** - * \file htdocs/core/menus/standard/auguria_backoffice.php - * \brief Gestionnaire nomme Auguria du menu du haut - * - * \remarks La construction d'un gestionnaire pour le menu du haut est simple: - * \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut - * \remarks doivent etre affichees par ... - * \remarks ou si menu selectionne ... - */ - - -/** - * Classe permettant la gestion du menu du haut Auguria - */ -class MenuManager -{ - var $db; - var $type_user=0; // Put 0 for internal users, 1 for external users - var $atarget=""; // Valeur du target a utiliser dans les liens - - var $menu_array; - var $menu_array_after; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - /** - * Show menu - * - * @param string $mode 'top' or 'left' - * @return int Number of menu entries shown - */ - function showmenu($mode) - { - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; - - $res='ErrorBadParameterForMode'; - if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user); - if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); - - return $res; - } - -} - -?> diff --git a/htdocs/core/menus/standard/auguria_frontoffice.php b/htdocs/core/menus/standard/auguria_menu.php similarity index 63% rename from htdocs/core/menus/standard/auguria_frontoffice.php rename to htdocs/core/menus/standard/auguria_menu.php index cb8299feee3..251a205290e 100644 --- a/htdocs/core/menus/standard/auguria_frontoffice.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -18,25 +18,21 @@ */ /** - * \file htdocs/core/menus/standard/auguria_frontoffice.php - * \brief Gestionnaire nomme Auguria du menu du haut - * - * \remarks La construction d'un gestionnaire pour le menu du haut est simple: - * \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut - * \remarks doivent etre affichees par ... - * \remarks ou si menu selectionne ... + * \file htdocs/core/menus/standard/auguria_menu.php + * \brief Menu auguria manager */ /** - * Classe permettant la gestion du menu du haut Auguria + * Class to manage menu Auguria */ class MenuManager { var $db; - var $type_user=1; // Put 0 for internal users, 1 for external users - var $atarget=""; // Valeur du target a utiliser dans les liens - + var $type_user; // Put 0 for internal users, 1 for external users + var $atarget=""; // Valeur du target a utiliser dans les liens + var $name="auguria"; + var $menu_array; var $menu_array_after; @@ -44,11 +40,13 @@ class MenuManager /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param int $type_user Type of user */ - function __construct($db) + function __construct($db, $type_user) { - $this->db=$db; + $this->type_user=$type_user; + $this->db=$db; } @@ -64,9 +62,12 @@ class MenuManager require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; - $conf->global->MAIN_SEARCHFORM_SOCIETE=0; - $conf->global->MAIN_SEARCHFORM_CONTACT=0; - + if ($this->type_user == 1) + { + $conf->global->MAIN_SEARCHFORM_SOCIETE=0; + $conf->global->MAIN_SEARCHFORM_CONTACT=0; + } + $res='ErrorBadParameterForMode'; if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user); if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); diff --git a/htdocs/core/menus/standard/eldy_frontoffice.php b/htdocs/core/menus/standard/eldy_frontoffice.php index 2221e0ec9f0..2d6d11f28dc 100644 --- a/htdocs/core/menus/standard/eldy_frontoffice.php +++ b/htdocs/core/menus/standard/eldy_frontoffice.php @@ -17,25 +17,21 @@ */ /** - * \file htdocs/core/menus/standard/eldy_frontoffice.php - * \brief Gestionnaire nomme eldy du menu du haut - * - * \remarks La construction d'un gestionnaire pour le menu du haut est simple: - * \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut - * \remarks doivent etre affichees par ... - * \remarks ou si menu selectionne ... + * \file htdocs/core/menus/standard/eldy_menu.php + * \brief Menu eldy manager */ /** - * Class to manage menu Eldy (for external users) + * Class to manage menu Eldy */ class MenuManager { var $db; - var $type_user=1; // Put 0 for internal users, 1 for external users + var $type_user; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens - + var $name="eldy"; + var $menu_array; var $menu_array_after; @@ -43,10 +39,12 @@ class MenuManager /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param int $type_user Type of user */ - function __construct($db) + function __construct($db, $type_user) { + $this->type_user=$type_user; $this->db=$db; } @@ -54,8 +52,8 @@ class MenuManager /** * Show menu * - * @param string $mode 'top' or 'left' - * @return int Number of menu entries shown + * @param string $mode 'top' or 'left' + * @return int Number of menu entries shown */ function showmenu($mode) { @@ -63,8 +61,11 @@ class MenuManager require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; - $conf->global->MAIN_SEARCHFORM_SOCIETE=0; - $conf->global->MAIN_SEARCHFORM_CONTACT=0; + if ($this->type_user == 1) + { + $conf->global->MAIN_SEARCHFORM_SOCIETE=0; + $conf->global->MAIN_SEARCHFORM_CONTACT=0; + } $res='ErrorBadParameterForMode'; if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user); diff --git a/htdocs/core/menus/standard/eldy_backoffice.php b/htdocs/core/menus/standard/eldy_menu.php similarity index 63% rename from htdocs/core/menus/standard/eldy_backoffice.php rename to htdocs/core/menus/standard/eldy_menu.php index 638fd45664d..2d6d11f28dc 100644 --- a/htdocs/core/menus/standard/eldy_backoffice.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007-2010 Regis Houssin + * Copyright (C) 2007-2009 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 @@ -17,25 +17,21 @@ */ /** - * \file htdocs/core/menus/standard/eldy_backoffice.php - * \brief Gestionnaire nomme eldy du menu du haut - * - * \remarks La construction d'un gestionnaire pour le menu du haut est simple: - * \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut - * \remarks doivent etre affichees par ... - * \remarks ou si menu selectionne ... + * \file htdocs/core/menus/standard/eldy_menu.php + * \brief Menu eldy manager */ /** - * Classe to manage menu Eldy + * Class to manage menu Eldy */ class MenuManager { var $db; - var $type_user=0; // Put 0 for internal users, 1 for external users + var $type_user; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens - + var $name="eldy"; + var $menu_array; var $menu_array_after; @@ -43,10 +39,12 @@ class MenuManager /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param int $type_user Type of user */ - function __construct($db) + function __construct($db, $type_user) { + $this->type_user=$type_user; $this->db=$db; } @@ -54,17 +52,25 @@ class MenuManager /** * Show menu * - * @param string $mode 'top' or 'left' - * @return int Number of menu entries shown + * @param string $mode 'top' or 'left' + * @return int Number of menu entries shown */ function showmenu($mode) { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; + if ($this->type_user == 1) + { + $conf->global->MAIN_SEARCHFORM_SOCIETE=0; + $conf->global->MAIN_SEARCHFORM_CONTACT=0; + } + $res='ErrorBadParameterForMode'; if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user); if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after); - + return $res; } diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index 4827eafb60b..fd779495e3e 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -23,3 +23,11 @@ create table llx_adherent_type_extrafields import_key varchar(14) -- import key ) ENGINE=innodb; ALTER TABLE llx_adherent_type_extrafields ADD INDEX idx_adherent_type_extrafields (fk_object); + +UPDATE llx_const set value='eldy_menu.php' where value='eldy_backoffice.php'; +UPDATE llx_const set value='eldy_menu.php' where value='eldy_frontoffice.php'; +UPDATE llx_const set value='auguria_menu.php' where value='auguria_backoffice.php'; +UPDATE llx_const set value='auguria_menu.php' where value='auguria_frontoffice.php'; +UPDATE llx_const set value='smartphone_menu.php' where value='smartphone_backoffice.php'; +UPDATE llx_const set value='smartphone_menu.php' where value='smartphone_frontoffice.php'; + diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c8430c95cac..bb10a493384 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -565,6 +565,7 @@ ThisLimitIsDefinedInSetup=Dolibarr limit (Menu home-setup-security): %s Kb, PHP NoFileFound=No documents saved in this directory CurrentUserLanguage=Current language CurrentTheme=Current theme +CurrentMenuManager=current men manager DisabledModules=Disabled modules For=For ForCustomer=For customer diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 80e4493ff84..52c7b339ffe 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -568,6 +568,7 @@ ThisLimitIsDefinedInSetup=Limite Dolibarr (Menu accueil-configuration-sécurité NoFileFound=Pas de documents stockés dans cette rubrique CurrentUserLanguage=Langue utilisateur actuelle CurrentTheme=Thème courant +CurrentMenuManager=Gestionnaire de menu courant DisabledModules=Modules désactivés For=Pour ForCustomer=Pour le client diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d464083167b..58f1ac48d02 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -778,21 +778,18 @@ if (! empty($conf->multicompany->enabled) && GETPOST('action') == 'switchentity' // Init menu manager if (empty($user->societe_id)) // If internal user or not defined { - $conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED); - $conf->smart_menu=(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED); + $conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?(empty($conf->global->MAIN_MENU_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENU_STANDARD):$conf->global->MAIN_MENU_STANDARD_FORCED); + $conf->smart_menu=(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?(empty($conf->global->MAIN_MENU_SMARTPHONE)?'smartphone_menu.php':$conf->global->MAIN_MENU_SMARTPHONE):$conf->global->MAIN_MENU_SMARTPHONE_FORCED); } else // If external user { - $conf->standard_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED); - $conf->smart_menu=(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED); + $conf->standard_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?(empty($conf->global->MAIN_MENUFRONT_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENUFRONT_STANDARD):$conf->global->MAIN_MENUFRONT_STANDARD_FORCED); + $conf->smart_menu=(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE)?'smartphone_menu.php':$conf->global->MAIN_MENUFRONT_SMARTPHONE):$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED); } -// For backward compatibility -if (empty($conf->standard_menu)) $conf->standard_menu ='eldy_backoffice.php'; -elseif ($conf->standard_menu == 'eldy.php') $conf->standard_menu='eldy_backoffice.php'; // Load the menu manager (only if not already done) $file_menu=empty($conf->browser->phone)?$conf->standard_menu:$conf->smart_menu; -if (GETPOST('menu')) $file_menu=GETPOST('menu'); // menu=eldy_backoffice.php +if (GETPOST('menu')) $file_menu=GETPOST('menu'); // example: menu=eldy_menu.php if (! class_exists('MenuManager')) { $menufound=0; @@ -804,11 +801,12 @@ if (! class_exists('MenuManager')) } if (! $menufound) // If failed to include, we try with standard { - $file_menu='eldy_backoffice.php'; + dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING); + $file_menu='eldy_menu.php'; include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; } } -$menumanager = new MenuManager($db); +$menumanager = new MenuManager($db, empty($user->societe_id)?0:1); @@ -1337,6 +1335,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $loginhtmltext.='
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin,"dayhour"); $loginhtmltext.='
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"]; $loginhtmltext.='
'.$langs->trans("CurrentTheme").': '.$conf->theme; + $loginhtmltext.='
'.$langs->trans("CurrentMenuManager").': '.$menumanager->name; $s=picto_from_langcode($langs->getDefaultLang()); $loginhtmltext.='
'.$langs->trans("CurrentUserLanguage").': '.($s?$s.' ':'').$langs->getDefaultLang(); $loginhtmltext.='
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version?' '.$conf->browser->version:'').' ('.$_SERVER['HTTP_USER_AGENT'].')'; From 56e11e52faeb70c42c2ff42aae0ef00a7416abda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 19:12:54 +0100 Subject: [PATCH 032/162] New: hookmanager class is used frequently and is a factory object, so we can move it during init of environment and use it globally. --- htdocs/adherents/class/adherent.class.php | 4 +-- .../adherents/class/adherent_type.class.php | 4 +-- htdocs/adherents/fiche.php | 2 -- htdocs/adherents/type.php | 2 -- htdocs/admin/dict.php | 2 -- htdocs/categories/categorie.php | 2 -- htdocs/comm/action/class/actioncomm.class.php | 10 +++---- htdocs/comm/action/fiche.php | 2 -- htdocs/comm/addpropal.php | 2 -- htdocs/comm/list.php | 2 -- htdocs/comm/mailing/fiche.php | 2 -- htdocs/comm/propal.php | 2 -- htdocs/comm/propal/list.php | 2 -- htdocs/comm/prospect/list.php | 2 -- htdocs/commande/class/commande.class.php | 8 +----- htdocs/commande/fiche.php | 2 -- htdocs/compta/deplacement/fiche.php | 2 -- htdocs/compta/dons/fiche.php | 2 -- htdocs/compta/facture.php | 2 -- htdocs/compta/facture/class/facture.class.php | 4 +-- htdocs/compta/facture/list.php | 2 -- htdocs/compta/tva/fiche.php | 2 -- htdocs/contact/class/contact.class.php | 4 +-- htdocs/contact/fiche.php | 2 -- htdocs/contrat/fiche.php | 2 -- htdocs/core/class/commonobject.class.php | 8 ++---- htdocs/core/class/html.formfile.class.php | 12 ++------- htdocs/core/class/html.formmail.class.php | 11 +------- htdocs/core/lib/files.lib.php | 27 ++----------------- htdocs/core/lib/security2.lib.php | 5 ---- htdocs/expedition/fiche.php | 2 -- htdocs/fichinter/fiche.php | 2 -- htdocs/fourn/commande/fiche.php | 2 -- htdocs/fourn/facture/fiche.php | 2 -- htdocs/fourn/liste.php | 2 -- htdocs/index.php | 2 -- htdocs/main.inc.php | 14 +--------- htdocs/master.inc.php | 10 ++++--- htdocs/product/class/product.class.php | 4 +-- htdocs/product/fiche.php | 2 -- htdocs/product/fournisseurs.php | 2 -- htdocs/projet/fiche.php | 2 -- htdocs/projet/tasks.php | 2 -- htdocs/projet/tasks/task.php | 2 -- htdocs/public/demo/index.php | 2 -- htdocs/societe/agenda.php | 2 -- htdocs/societe/class/societe.class.php | 6 +---- htdocs/societe/info.php | 2 -- htdocs/societe/soc.php | 2 -- htdocs/user/class/user.class.php | 4 +-- htdocs/user/fiche.php | 2 -- htdocs/user/passwordforgotten.php | 5 ---- 52 files changed, 27 insertions(+), 183 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 61edd3bee05..0eea1c6f5d7 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -394,7 +394,7 @@ class Adherent extends CommonObject */ function update($user,$notrigger=0,$nosyncuser=0,$nosyncuserpass=0,$nosyncthirdparty=0,$action='update') { - global $conf, $langs; + global $conf, $langs, $hookmanager; $nbrowsaffected=0; $error=0; @@ -462,8 +462,6 @@ class Adherent extends CommonObject $nbrowsaffected+=$this->db->affected_rows($resql); // Actions on extra fields (by external module) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('memberdao')); $parameters=array('id'=>$this->id); $action=''; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index ead494783aa..d829c5a84f9 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -98,6 +98,8 @@ class AdherentType extends CommonObject */ function update($user) { + global $hookmanager; + $this->libelle=trim($this->libelle); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type "; @@ -114,8 +116,6 @@ class AdherentType extends CommonObject if ($result) { // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('membertypedao')); $parameters=array('membertype'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 02e0af3a768..f84990b94e5 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -107,8 +107,6 @@ if ($rowid) } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('membercard')); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 592695130b3..369f925bc7e 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -67,8 +67,6 @@ if (GETPOST('button_removefilter')) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('membertypecard')); /* diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 56f4f6140bb..b5c49355672 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -64,8 +64,6 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('admin')); // This page is a generic page to edit dictionnaries diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index fb4ba30a269..d3a06304e46 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -86,8 +86,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('categorycard')); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 5e7a77c6ca2..43278dbaaa2 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -106,8 +106,8 @@ class ActionComm extends CommonObject */ function add($user,$notrigger=0) { - global $langs,$conf; - + global $langs,$conf,$hookmanager; + $error=0; $now=dol_now(); @@ -210,8 +210,6 @@ class ActionComm extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm","id"); // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('actioncommdao')); $parameters=array('actcomm'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -430,7 +428,7 @@ class ActionComm extends CommonObject */ function update($user,$notrigger=0) { - global $langs,$conf; + global $langs,$conf,$hookmanager; $error=0; @@ -482,8 +480,6 @@ class ActionComm extends CommonObject { // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('actioncommdao')); $parameters=array('actcomm'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 60233a20650..782d7444429 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -66,8 +66,6 @@ $extrafields = new ExtraFields($db); //var_dump($_POST); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('actioncard')); diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index b2d5285d849..8c5a07df0c3 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -46,8 +46,6 @@ $origin=GETPOST('origin','alpha'); $originid=GETPOST('originid','int'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('propalcard')); /* diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php index 496b9217059..fd7ea79f345 100755 --- a/htdocs/comm/list.php +++ b/htdocs/comm/list.php @@ -58,8 +58,6 @@ $search_categ = GETPOST("search_categ",'int'); $catid = GETPOST("catid",'int'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('customerlist')); diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 680790ff04e..310a48eb935 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -47,8 +47,6 @@ $result=$object->fetch($id); $extrafields = new ExtraFields($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('mailingcard')); // Tableau des substitutions possibles diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index f1850014a48..08a03ff8866 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -99,8 +99,6 @@ else } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('propalcard')); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 95e549c0b1d..b2f1f8dcc44 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -77,8 +77,6 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('propalcard')); diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index a093f73c57b..69aaab9e68e 100755 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -148,8 +148,6 @@ $sts = array(-1,0,1,2,3); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('prospectlist')); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 481b51400a5..28d56fcf3a2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -880,8 +880,7 @@ class Commande extends CommonOrder */ function createFromProposal($object) { - global $conf,$user,$langs; - global $hookmanager; + global $conf,$user,$langs,$hookmanager; $error=0; @@ -945,11 +944,6 @@ class Commande extends CommonOrder if ($ret > 0) { // Actions hooked (by external module) - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('orderdao')); $parameters=array('objFrom'=>$object); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index e3fd1029326..b6e7b821495 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -84,8 +84,6 @@ if ($id > 0 || ! empty($ref)) } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('ordercard')); diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index d13880f7559..1e20d91c350 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -49,8 +49,6 @@ $mesg = ''; $object = new Deplacement($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('tripsandexpensescard')); diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php index 51550f41ebd..6ba13a19631 100644 --- a/htdocs/compta/dons/fiche.php +++ b/htdocs/compta/dons/fiche.php @@ -50,8 +50,6 @@ $donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOS $result = restrictedArea($user, 'don', $id); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('doncard')); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 34b501f73c9..f15762b97bf 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -95,8 +95,6 @@ if ($id > 0 || ! empty($ref)) } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('invoicecard')); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index cf7b89be7aa..1637524cfce 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -637,7 +637,7 @@ class Facture extends CommonInvoice */ function createFromOrder($object) { - global $conf,$user,$langs; + global $conf,$user,$langs,$hookmanager; $error=0; @@ -701,8 +701,6 @@ class Facture extends CommonInvoice if ($ret > 0) { // Actions hooked (by external module) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('invoicedao')); $parameters=array('objFrom'=>$object); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 12d653e5b26..796bf769698 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -97,8 +97,6 @@ $usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MA $object=new Facture($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('invoicecard')); $now=dol_now(); diff --git a/htdocs/compta/tva/fiche.php b/htdocs/compta/tva/fiche.php index 45dc91263ad..c8139c5575f 100644 --- a/htdocs/compta/tva/fiche.php +++ b/htdocs/compta/tva/fiche.php @@ -41,8 +41,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('taxvatcard')); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index c1eb6426c7b..14c8630e1e5 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -210,7 +210,7 @@ class Contact extends CommonObject */ function update($id, $user=0, $notrigger=0, $action='update') { - global $conf, $langs; + global $conf, $langs, $hookmanager; $error=0; @@ -266,8 +266,6 @@ class Contact extends CommonObject unset($this->state); // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('contactdao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 0233c367b07..9097584bfb5 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -65,8 +65,6 @@ if (! empty($canvas)) $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', '', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('contactcard')); diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 50c30e4be2b..d3a7f48c24b 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -59,8 +59,6 @@ $result=restrictedArea($user,'contrat',$id); $usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('contractcard')); $object = new Contrat($db); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8b6002c29c5..344507971bb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2468,16 +2468,12 @@ abstract class CommonObject */ function showLinkedObjectBlock($hookmanager=false) { - global $conf,$langs,$bc; + global $conf,$langs,$hookmanager; + global $bc; $this->fetchObjectLinked(); // Bypass the default method - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('commonobject')); $parameters=array(); $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8e43669b2e8..83818285265 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -590,18 +590,10 @@ class FormFile */ function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='') { - global $user, $conf, $langs; - global $bc, $hookmanager; + global $user, $conf, $langs, $hookmanager; + global $bc; global $sortfield, $sortorder, $maxheightmini; - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } - } $hookmanager->initHooks(array('formfile')); $parameters=array( diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index c221cc33c07..f499bcb6b68 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -216,20 +216,11 @@ class FormMail */ function get_form($addfileaction='addfile',$removefileaction='removefile') { - global $conf, $langs, $user; - global $hookmanager; + global $conf, $langs, $user, $hookmanager; $langs->load("other"); $langs->load("mails"); - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } - } $hookmanager->initHooks(array('formmail')); $parameters=array( diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index c257b00e56d..b480184808f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -65,15 +65,8 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil $path=preg_replace('/([\\/]+)$/i','',$path); $newpath=dol_osencode($path); - if (! $nohook) { - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } - } + if (! $nohook) + { $hookmanager->initHooks(array('fileslib')); $parameters=array( @@ -653,14 +646,6 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable return -2; } - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - } - $hookmanager=new HookManager($db); - } $hookmanager->initHooks(array('fileslib')); $parameters=array('filename' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite); @@ -722,14 +707,6 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n if (empty($nohook)) { - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } - } $hookmanager->initHooks(array('fileslib')); $parameters=array( diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index b7196ba228f..6aa41576c01 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -131,11 +131,6 @@ function dol_loginfunction($langs,$conf,$mysoc) global $smartphone,$hookmanager; // Instantiate hooks of thirdparty module only if not already define - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } $hookmanager->initHooks(array('mainloginpage')); $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 7e9a24be0f9..1d34aea5d0c 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -59,8 +59,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user, $origin, $origin_id); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('expeditioncard')); $action = GETPOST('action','alpha'); diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 755b68b5af1..86230754ef3 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -60,8 +60,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('interventioncard')); $object = new Fichinter($db); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index bbe46c9a21a..ed5c7483c64 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -70,8 +70,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'commande_fournisseur', $id,''); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('ordersuppliercard')); $object = new CommandeFournisseur($db); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 241c17b7cef..abec49e0e89 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -61,8 +61,6 @@ if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('invoicesuppliercard')); $object=new FactureFournisseur($db); diff --git a/htdocs/fourn/liste.php b/htdocs/fourn/liste.php index 3c50b16cb4f..13361f10eb2 100644 --- a/htdocs/fourn/liste.php +++ b/htdocs/fourn/liste.php @@ -57,8 +57,6 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="nom"; // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('supplierlist')); /* diff --git a/htdocs/index.php b/htdocs/index.php index ba3cbf1b05f..8119e3a83be 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -34,8 +34,6 @@ $_GET['mainmenu']=GETPOST('mainmenu', 'alpha')?GETPOST('mainmenu', 'alpha'):'hom $action=GETPOST('action'); -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('index')); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 58f1ac48d02..ec82c9e7e41 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -603,8 +603,6 @@ if (! defined('NOLOGIN')) // Hooks on successfull login $action=''; - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); $hookmanager->initHooks(array('login')); $parameters=array('dol_authmode'=>$dol_authmode); $reshook=$hookmanager->executeHooks('afterLogin',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks @@ -1194,12 +1192,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a global $dolibarr_main_authentication; global $hookmanager,$menumanager; - // Instantiate hooks of thirdparty module only if not already define - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } + // Instantiate hooks of thirdparty module $hookmanager->initHooks(array('toprightmenu')); $toprightmenu=''; @@ -1426,11 +1419,6 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me $bookmarks=''; // Instantiate hooks of thirdparty module - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } $hookmanager->initHooks(array('searchform','leftblock')); if (empty($_SESSION['dol_hide_leftmenu'])) diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 6d6ce8680b8..b023f7110b0 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -186,9 +186,7 @@ if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) } } -/* - * Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr. - */ +// Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr. if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC')) { require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; @@ -207,6 +205,12 @@ if (! defined('NOREQUIRETRAN')) $langs->setDefaultLang((! empty($conf->global->MAIN_LANG_DEFAULT)?$conf->global->MAIN_LANG_DEFAULT:'')); } + +// Create the global $hookmanager object +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager=new HookManager($db); + + if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR'); // We force feature to help debug diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a9c0439b220..8f91e30b257 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -418,7 +418,7 @@ class Product extends CommonObject */ function update($id, $user, $notrigger=false, $action='update') { - global $langs, $conf; + global $langs, $conf, $hookmanager; $error=0; @@ -500,8 +500,6 @@ class Product extends CommonObject } // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('productdao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 74aa705eeab..1ccc7e2c8b3 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -78,8 +78,6 @@ $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype,$objcanvas); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('productcard')); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index b8b30184af9..43929c96b0c 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -59,8 +59,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service&fournisseur',$fieldvalue,'product&product','','',$fieldtype); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('pricesuppliercard')); diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index f5870301860..fc518e29d27 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -50,8 +50,6 @@ if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $id); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('projectcard')); $object = new Project($db); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 934bf9b238e..55055d0f467 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -55,8 +55,6 @@ if ($user->societe_id > 0) $socid = $user->societe_id; $result = restrictedArea($user, 'projet', $id); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('projecttaskcard')); $progress=GETPOST('progress', 'int'); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index def739e31f1..94034e9b541 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -42,8 +42,6 @@ if ($user->societe_id > 0) $socid = $user->societe_id; if (! $user->rights->projet->lire) accessforbidden(); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('projecttaskcard')); $object = new Task($db); diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index b8a240b44b6..40c499d5469 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -38,8 +38,6 @@ global $dolibarr_main_demo; if (empty($dolibarr_main_demo)) accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page',1,1,1); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('demo')); $demoprofiles=array( diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 9e373a97158..bc9b11b3149 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -38,8 +38,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('agendathirdparty')); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6ea29526c00..95c16965fb5 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -380,7 +380,7 @@ class Societe extends CommonObject */ function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1) { - global $langs,$conf; + global $langs,$conf,$hookmanager; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $error=0; @@ -612,8 +612,6 @@ class Societe extends CommonObject $this->AddFournisseurInCategory($this->fournisseur_categorie); // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('thirdpartydao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -1064,8 +1062,6 @@ class Societe extends CommonObject if (! $error) { // Additionnal action by hooks - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('thirdpartydao')); $parameters=array(); $action='delete'; $reshook=$hookmanager->executeHooks('deleteThirdparty',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/societe/info.php b/htdocs/societe/info.php index 82eab7da454..8f0d0836ed4 100644 --- a/htdocs/societe/info.php +++ b/htdocs/societe/info.php @@ -38,8 +38,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('infothirdparty')); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index d2f816cd1ca..9a9900df23e 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -70,8 +70,6 @@ if (! empty($canvas)) $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('thirdpartycard')); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index daf7b7ade4c..678be6bf873 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1079,7 +1079,7 @@ class User extends CommonObject */ function update($user,$notrigger=0,$nosyncmember=0,$nosyncmemberpass=0) { - global $conf, $langs; + global $conf, $langs, $hookmanager; $nbrowsaffected=0; $error=0; @@ -1218,8 +1218,6 @@ class User extends CommonObject } // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('userdao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 7ce2640710a..4d79b687c60 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -84,8 +84,6 @@ $object = new User($db); $extrafields = new ExtraFields($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('usercard')); diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index a3bbcea980a..61ac2f373fc 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -52,11 +52,6 @@ $passwordmd5 = GETPOST('passwordmd5'); $conf->entity = (GETPOST('entity') ? GETPOST('entity') : 1); // Instantiate hooks of thirdparty module only if not already define -if (! is_object($hookmanager)) -{ - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); -} $hookmanager->initHooks(array('passwordforgottenpage')); From 64cac3194ccbc2d594e2fc4e7be479eb1e6d6589 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 19:19:41 +0100 Subject: [PATCH 033/162] Fix: Use translation of NPR --- htdocs/admin/dict.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index b5c49355672..d5fe7846714 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -732,7 +732,7 @@ if ($id) if (in_array('region_id',$fieldlist)) { print ' '; continue; } // For region page, we do not show the country input $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; $align="center"; } + if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); } if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } @@ -846,7 +846,7 @@ if ($id) if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; } if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; } if ($fieldlist[$field]=='pays') { $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; $align="center"; } + if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); } if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } From fcee35c65dd590a05763e5d6185ce1735589a8a0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 26 Jan 2013 10:35:30 +0100 Subject: [PATCH 034/162] Fix: $hookmanager is a global object --- htdocs/comm/propal.php | 32 +++---- htdocs/comm/propal/class/propal.class.php | 5 +- htdocs/commande/class/commande.class.php | 5 +- htdocs/commande/fiche.php | 38 ++++---- htdocs/compta/facture.php | 32 +++---- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/compta/paiement/fiche.php | 2 +- htdocs/compta/payment_sc/fiche.php | 2 +- htdocs/contrat/fiche.php | 18 ++-- htdocs/core/class/commonobject.class.php | 33 +++---- htdocs/core/class/html.formfile.class.php | 11 +-- htdocs/core/lib/pdf.lib.php | 92 +++++++++++-------- .../doc/doc_generic_order_odt.modules.php | 5 +- .../commande/doc/pdf_einstein.modules.php | 34 ++++--- .../modules/commande/modules_commande.php | 7 +- htdocs/core/modules/dons/modules_don.php | 2 +- .../doc/pdf_expedition_merou.modules.php | 7 +- .../doc/pdf_expedition_rouget.modules.php | 7 +- .../doc/doc_generic_invoice_odt.modules.php | 5 +- .../modules/facture/doc/pdf_crabe.modules.php | 32 +++---- .../core/modules/facture/modules_facture.php | 5 +- .../fichinter/doc/pdf_soleil.modules.php | 5 +- .../modules/fichinter/modules_fichinter.php | 5 +- .../core/modules/project/modules_project.php | 7 +- .../doc/doc_generic_proposal_odt.modules.php | 10 +- .../modules/propale/doc/pdf_azur.modules.php | 37 +++----- .../core/modules/propale/modules_propale.php | 5 +- .../societe/doc/doc_generic_odt.modules.php | 10 +- .../modules_facturefournisseur.php | 5 +- .../pdf/pdf_canelle.modules.php | 21 ++--- .../modules_commandefournisseur.php | 5 +- .../pdf/pdf_muscadet.modules.php | 21 ++--- htdocs/expedition/fiche.php | 2 +- htdocs/fichinter/fiche.php | 2 +- .../class/fournisseur.commande.class.php | 5 +- htdocs/fourn/commande/fiche.php | 18 ++-- htdocs/fourn/facture/fiche.php | 10 +- htdocs/societe/class/societe.class.php | 15 +-- htdocs/societe/soc.php | 30 +++--- 39 files changed, 272 insertions(+), 317 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 08a03ff8866..31c9e36d898 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -121,7 +121,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') { if ($object->id > 0) { - $result=$object->createFromClone($socid, $hookmanager); + $result=$object->createFromClone($socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -170,7 +170,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -194,7 +194,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -371,7 +371,7 @@ else if ($action == 'add' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); @@ -607,7 +607,7 @@ if ($action == 'modif' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -814,7 +814,7 @@ else if ($action == "addline" && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -935,7 +935,7 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -981,7 +981,7 @@ else if ($action == 'builddoc' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { @@ -1070,7 +1070,7 @@ else if ($action == 'up' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); @@ -1092,7 +1092,7 @@ else if ($action == 'down' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); @@ -1626,7 +1626,7 @@ print ''; // Show object lines $result = $object->getLinesArray(); if (! empty($object->lines)) - $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,0,$hookmanager); + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid); // Form to add new line if ($object->statut == 0 && $user->rights->propal->creer) @@ -1638,18 +1638,18 @@ if ($object->statut == 0 && $user->rights->propal->creer) if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services - $object->formAddObjectLine(0,$mysoc,$soc,$hookmanager); + $object->formAddObjectLine(0,$mysoc,$soc); } else { // Add free products/services - $object->formAddFreeProduct(0,$mysoc,$soc,$hookmanager); + $object->formAddFreeProduct(0,$mysoc,$soc); // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var=!$var; - $object->formAddPredefinedProduct(0,$mysoc,$soc,$hookmanager); + $object->formAddPredefinedProduct(0,$mysoc,$soc); } } @@ -1799,7 +1799,7 @@ if ($action != 'presend') $var=true; - $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang,$hookmanager); + $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang); /* @@ -1843,7 +1843,7 @@ if ($action == 'presend') $outputlangs->setDefaultLang($newlang); } - $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8e3e4748f05..90ba3f93690 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -867,12 +867,11 @@ class Propal extends CommonObject * Load an object from its id and create a new one in database * * @param int $socid Id of thirdparty - * @param HookManager $hookmanager Hook manager instance * @return int New id of clone */ - function createFromClone($socid=0,$hookmanager=false) + function createFromClone($socid=0) { - global $user,$langs,$conf; + global $user,$langs,$conf,$hookmanager; $error=0; $now=dol_now(); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 28d56fcf3a2..335757c59d6 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -794,12 +794,11 @@ class Commande extends CommonOrder * Load an object from its id and create a new one in database * * @param int $socid Id of thirdparty - * @param HookManager $hookmanager Hook manager instance * @return int New id of clone */ - function createFromClone($socid=0,$hookmanager=false) + function createFromClone($socid=0) { - global $conf,$user,$langs; + global $conf,$user,$langs,$hookmanager; $error=0; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index b6e7b821495..ccaadefe2ee 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -105,7 +105,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande-> { if ($object->id > 0) { - $result=$object->createFromClone($socid, $hookmanager); + $result=$object->createFromClone($socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -172,7 +172,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -202,7 +202,7 @@ else if ($action == 'add' && $user->rights->commande->creer) $action='create'; $error++; } - + if ($socid<1) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors'); @@ -504,7 +504,7 @@ else if ($action == 'setconditions' && $user->rights->commande->creer) } $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -743,7 +743,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) } $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -870,7 +870,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' } $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -929,7 +929,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -968,7 +968,7 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -1021,7 +1021,7 @@ else if ($action == 'up' && $user->rights->commande->creer) $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); exit; @@ -1041,7 +1041,7 @@ else if ($action == 'down' && $user->rights->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); exit; @@ -1070,7 +1070,7 @@ else if ($action == 'builddoc') // In get or post $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { @@ -1491,7 +1491,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G print "'; - + // Ligne info remises tiers print ''; if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) @@ -2698,12 +2693,11 @@ abstract class CommonObject * @param string $seller Object of seller third party * @param string $buyer Object of buyer third party * @param string $selected Object line selected - * @param HookManager $hookmanager Hook manager * @return void */ - function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$hookmanager=false) + function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0) { - global $conf,$langs,$user; + global $conf,$langs,$user,$hookmanager; global $form,$bc,$bcdd; $element=$this->element; @@ -2808,12 +2802,11 @@ 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 HookManager $hookmanager Hook manager * @return void */ - function printOriginLinesList($hookmanager=false) + function printOriginLinesList() { - global $langs; + global $langs, $hookmanager; print ''; print ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 83818285265..525b163d994 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -161,13 +161,12 @@ class FormFile * @param string $title Title to show on top of form * @param string $buttonlabel Label on submit button * @param string $codelang Default language code to use on lang combo box if multilang is enabled - * @param HookManager $hookmanager Object hookmanager with instance of external modules hook classes * @return int <0 if KO, number of shown files if OK */ - function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$hookmanager=false) + function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='') { $this->numoffiles=0; - print $this->showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang,$hookmanager); + print $this->showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang); return $this->numoffiles; } @@ -191,15 +190,15 @@ class FormFile * @param string $title Title to show on top of form * @param string $buttonlabel Label on submit button * @param string $codelang Default language code to use on lang combo box if multilang is enabled - * @param HookManager $hookmanager Object hookmanager with instance of external modules hook classes * @return string Output string with HTML array of documents (might be empty string) */ - function showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$hookmanager=false) + function showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='') { // filedir = conf->...dir_ouput."/".get_exdir(id) include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - global $langs,$bc,$conf; + global $langs,$conf,$hookmanager; + global $bc; // For backward compatibility if (! empty($iconPDF)) { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 481e1751ef0..e07c660fddc 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -792,12 +792,11 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass * @param float $h Cell minimum height. The cell extends automatically if needed. * @param int $align Align * @param string $default_font_size Font size - * @param HookManager $hookmanager Hook manager object * @return void */ -function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false) +function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size) { - $linkedobjects = pdf_getLinkedObjects($object,$outputlangs,$hookmanager); + $linkedobjects = pdf_getLinkedObjects($object,$outputlangs); if (! empty($linkedobjects)) { foreach($linkedobjects as $linkedobject) @@ -833,12 +832,11 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al * @param int $hideref Hide reference * @param int $hidedesc Hide description * @param int $issupplierline Is it a line for a supplier object ? - * @param HookManager $hookmanager Instance of HookManager * @return void */ -function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0,$hookmanager=false) +function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0) { - global $db, $conf, $langs; + global $db, $conf, $langs, $hookmanager; if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) { @@ -1002,9 +1000,11 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0) { - if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + global $hookmanager; + + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1024,12 +1024,13 @@ function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0) { - if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + global $hookmanager; + + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1048,12 +1049,13 @@ function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0) { - if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + global $hookmanager; + + if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1072,12 +1074,13 @@ function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0,$hookman * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0) { - if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + global $hookmanager; + + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1098,12 +1101,11 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0,$hookmanager= * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0) { - global $conf; + global $conf, $hookmanager; $sign=1; if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; @@ -1133,7 +1135,9 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanage */ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0) { - if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) + global $hookmanager; + + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1155,11 +1159,12 @@ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0) * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code != 3) { if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) @@ -1184,11 +1189,12 @@ function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code != 3) { if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) @@ -1213,11 +1219,12 @@ function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0,$hookmanage * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code != 3) { if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) @@ -1242,11 +1249,12 @@ function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0,$hookmana * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code != 3) { if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) @@ -1271,11 +1279,12 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0,$hookm * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; if ($object->lines[$i]->special_code != 3) @@ -1302,12 +1311,11 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0,$hookma * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) { - global $conf; + global $conf, $hookmanager; $sign=1; if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; @@ -1344,13 +1352,15 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0,$hookman */ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code == 3) { return $outputlangs->transnoentities("Option"); } else { - if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1373,11 +1383,12 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0) * @param Object $object Object * @param string $type Type * @param Translate $outputlangs Object langs for output - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false) +function pdf_getTotalQty($object,$type,$outputlangs) { + global $hookmanager; + $total=0; $nblignes=count($object->lines); @@ -1390,7 +1401,7 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false) { $total += $object->lines[$i]->qty; } - else if ($type==9 && ! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1415,11 +1426,12 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false) * * @param object $object Object * @param Translate $outputlangs Object lang for output - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getLinkedObjects($object,$outputlangs,$hookmanager=false) +function pdf_getLinkedObjects($object,$outputlangs) { + global $hookmanager; + $linkedobjects=array(); $object->fetchObjectLinked(); diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index aa156eaf412..0ad0ecc0e7e 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -238,12 +238,11 @@ class doc_generic_order_odt extends ModelePDFCommandes * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1 if OK, <=0 if KO */ - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index a9b1e89ece9..cff6d9b099f 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -133,12 +133,11 @@ class pdf_einstein extends ModelePDFCommandes * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc,$db; + global $user,$langs,$conf,$mysoc,$db,$hookmanager; 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 @@ -230,7 +229,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -284,7 +283,7 @@ class pdf_einstein extends ModelePDFCommandes $showpricebeforepagebreak=1; $pdf->startTransaction(); - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -292,7 +291,7 @@ class pdf_einstein extends ModelePDFCommandes $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); $posyafter=$pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text { @@ -300,7 +299,7 @@ class pdf_einstein extends ModelePDFCommandes { $pdf->AddPage('','',true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pagenb+1); } } @@ -331,18 +330,18 @@ class pdf_einstein extends ModelePDFCommandes // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } // Unit price before discount - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0); // Quantity - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager); + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars @@ -350,12 +349,12 @@ class pdf_einstein extends ModelePDFCommandes if ($object->lines[$i]->remise_percent) { $pdf->SetXY($this->posxdiscount-2, $curY); - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager); + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); } // Total HT line - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); @@ -426,7 +425,7 @@ class pdf_einstein extends ModelePDFCommandes $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { @@ -443,7 +442,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } } @@ -1041,12 +1040,11 @@ class pdf_einstein extends ModelePDFCommandes * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs; + global $conf,$langs,$hookmanager; $outputlangs->load("main"); $outputlangs->load("bills"); @@ -1125,7 +1123,7 @@ class pdf_einstein extends ModelePDFCommandes $posy+=2; // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 8ebd473876d..aa52d55bad3 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -157,12 +157,11 @@ abstract class ModeleNumRefCommandes * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$user,$langs; + global $conf,$user,$langs,$hookmanager; $langs->load("orders"); $error=0; @@ -223,7 +222,7 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0 // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index 24816e4141a..ff05e6d8262 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -222,7 +222,7 @@ function don_create($db, $id, $message, $modele, $outputlangs) // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object,$outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object,$outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php index 42598a2094d..c2f8da7c0e2 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php @@ -78,12 +78,11 @@ class pdf_expedition_merou extends ModelePdfExpedition * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$conf,$langs,$mysoc; + global $user,$conf,$langs,$mysoc,$hookmanager; $object->fetch_thirdparty(); @@ -183,7 +182,7 @@ class pdf_expedition_merou extends ModelePdfExpedition // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 3); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php index e3113689726..b458a5a3a42 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php @@ -81,12 +81,11 @@ class pdf_expedition_rouget extends ModelePdfExpedition * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$conf,$langs; + global $user,$conf,$langs,$hookmanager; $object->fetch_thirdparty(); @@ -170,7 +169,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 35cb6851886..dcf8436636d 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -250,12 +250,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1 if OK, <=0 if KO */ - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index e12a4984104..bfa48ceed37 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -134,12 +134,11 @@ class pdf_crabe extends ModelePDFFactures * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc,$db; + global $user,$langs,$conf,$mysoc,$db,$hookmanager; 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 @@ -232,7 +231,7 @@ class pdf_crabe extends ModelePDFFactures if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -285,7 +284,7 @@ class pdf_crabe extends ModelePDFFactures $showpricebeforepagebreak=1; $pdf->startTransaction(); - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -293,7 +292,7 @@ class pdf_crabe extends ModelePDFFactures $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); $posyafter=$pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; @@ -303,7 +302,7 @@ class pdf_crabe extends ModelePDFFactures { $pdf->AddPage('','',true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pagenb+1); } } @@ -334,18 +333,18 @@ class pdf_crabe extends ModelePDFFactures // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } // Unit price before discount - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0); // Quantity - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager); + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars @@ -353,12 +352,12 @@ class pdf_crabe extends ModelePDFFactures if ($object->lines[$i]->remise_percent) { $pdf->SetXY($this->posxdiscount-2, $curY); - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager); + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); } // Total HT line - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); @@ -428,7 +427,7 @@ class pdf_crabe extends ModelePDFFactures $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { @@ -445,7 +444,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } } @@ -1194,10 +1193,9 @@ class pdf_crabe extends ModelePDFFactures * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; @@ -1331,7 +1329,7 @@ class pdf_crabe extends ModelePDFFactures $posy+=1; // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 42462c9b246..865d1f578bd 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -152,10 +152,9 @@ abstract class ModeleNumRefFactures * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int <0 if KO, >0 if OK */ -function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$user,$langs; @@ -224,7 +223,7 @@ function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 953466ec88a..d40dfb3c8f3 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -101,10 +101,9 @@ class pdf_soleil extends ModelePDFFicheinter * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { global $user,$langs,$conf,$mysoc; @@ -174,7 +173,7 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index 545a6979491..cb0336f2bd2 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -151,10 +151,9 @@ abstract class ModeleNumRefFicheinter * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$langs,$user; $langs->load("ficheinter"); @@ -216,7 +215,7 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $ // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index fc0260a0be2..6aae57c34d5 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -110,7 +110,7 @@ abstract class ModeleNumRefProjects /** * Renvoi prochaine valeur attribuee - * + * * @param Societe $objsoc Object third party * @param Project $project Object project * @return string Valeur @@ -149,10 +149,9 @@ abstract class ModeleNumRefProjects * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function project_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function project_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$langs; $langs->load("projects"); @@ -214,7 +213,7 @@ function project_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 812fb81a859..be0ac3f7d3f 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -237,12 +237,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1 if OK, <=0 if KO */ - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { @@ -485,11 +484,6 @@ class doc_generic_proposal_odt extends ModelePDFPropales } // Add odtgeneration hook - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('odtgeneration')); $parameters=array('odfHandler'=>$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 3a76d61f7f3..43f2bab3940 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -132,12 +132,11 @@ class pdf_azur extends ModelePDFPropales * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc,$db; + global $user,$langs,$conf,$mysoc,$db,$hookmanager; 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 @@ -229,7 +228,7 @@ class pdf_azur extends ModelePDFPropales $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -282,7 +281,7 @@ class pdf_azur extends ModelePDFPropales $showpricebeforepagebreak=1; $pdf->startTransaction(); - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -290,7 +289,7 @@ class pdf_azur extends ModelePDFPropales $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); $posyafter=$pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text @@ -299,7 +298,7 @@ class pdf_azur extends ModelePDFPropales { $pdf->AddPage('','',true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pagenb+1); } } @@ -330,18 +329,18 @@ class pdf_azur extends ModelePDFPropales // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } // Unit price before discount - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0); // Quantity - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager); + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars @@ -349,12 +348,12 @@ class pdf_azur extends ModelePDFPropales if ($object->lines[$i]->remise_percent) { $pdf->SetXY($this->posxdiscount-2, $curY); - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager); + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); } // Total HT line - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); @@ -423,7 +422,7 @@ class pdf_azur extends ModelePDFPropales $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { @@ -440,7 +439,7 @@ class pdf_azur extends ModelePDFPropales $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } } @@ -480,11 +479,6 @@ class pdf_azur extends ModelePDFPropales $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; @@ -1088,10 +1082,9 @@ class pdf_azur extends ModelePDFPropales * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; @@ -1186,7 +1179,7 @@ class pdf_azur extends ModelePDFPropales $posy+=2; // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index d26193d2a1b..b5a25954df9 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -153,10 +153,9 @@ abstract class ModeleNumRefPropales * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$user,$langs; $langs->load("propale"); @@ -219,7 +218,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index cc5c08f7431..0146ebfc253 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -161,12 +161,11 @@ class doc_generic_odt extends ModeleThirdPartyDoc * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1 if OK, <=0 if KO */ - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { @@ -298,11 +297,6 @@ class doc_generic_odt extends ModeleThirdPartyDoc } // Add odtgeneration hook - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('odtgeneration')); $parameters=array('odfHandler'=>$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index d29abaa08a0..5d409dd6c67 100755 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -65,10 +65,9 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf, $user, $langs; @@ -137,7 +136,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; 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 0813162020d..46b2e893996 100755 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -129,12 +129,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) + function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; 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 @@ -227,7 +226,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -276,7 +275,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Description of product line $curX = $this->posxdesc-1; - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); @@ -294,7 +293,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } @@ -414,11 +413,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $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; @@ -824,10 +818,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -907,7 +900,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetTextColor(0,0,60); // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index e66b22a4f83..6b9fd315f18 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -147,10 +147,9 @@ abstract class ModeleNumRefSuppliersOrders * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf, $user, $langs; $langs->load("suppliers"); @@ -218,7 +217,7 @@ function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedet // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 3074e73d19a..6805bb3fddb 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -138,12 +138,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf; + global $user,$langs,$conf,$hookmanager; 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 @@ -239,7 +238,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -288,7 +287,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Description of product line $curX = $this->posxdesc-1; - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1); $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); @@ -306,7 +305,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } @@ -433,11 +432,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // 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; @@ -917,10 +911,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -1005,7 +998,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetTextColor(0,0,60); // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 1d34aea5d0c..90850fce683 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -1422,7 +1422,7 @@ else $outputlangs->setDefaultLang($newlang); } - $result=expedition_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=expedition_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 86230754ef3..11e1eabd782 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1466,7 +1466,7 @@ else if ($id > 0 || ! empty($ref)) $outputlangs->setDefaultLang($newlang); } - $result=fichinter_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=fichinter_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3e7c5600582..28eae474799 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1029,12 +1029,11 @@ class CommandeFournisseur extends CommonOrder /** * Load an object from its id and create a new one in database * - * @param HookManager $hookmanager Hook manager instance * @return int New id of clone */ - function createFromClone($hookmanager=false) + function createFromClone() { - global $conf,$user,$langs; + global $conf,$user,$langs,$hookmanager; $error=0; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index ed5c7483c64..ee802c3dc0f 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -308,7 +308,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) } $ret=$object->fetch($object->id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); unset($_POST['type']); @@ -367,7 +367,7 @@ else if ($action == 'updateligne' && $user->rights->fournisseur->commande->creer if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -392,7 +392,7 @@ else if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->r if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -423,7 +423,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fourn if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -522,7 +522,7 @@ else if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->fourn { if ($object->id > 0) { - $result=$object->createFromClone($hookmanager); + $result=$object->createFromClone(); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -592,7 +592,7 @@ else if ($action == 'up' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid'])); exit; } @@ -606,7 +606,7 @@ else if ($action == 'down' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid'])); exit; } @@ -628,7 +628,7 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) / $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang(GETPOST('lang_id')); } - $result=supplier_order_pdf_create($db, $object,$object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=supplier_order_pdf_create($db, $object,$object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); @@ -1797,7 +1797,7 @@ if (! empty($object->id)) $outputlangs->setDefaultLang($newlang); } - $result=supplier_order_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=supplier_order_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index abec49e0e89..fd6ffc2efe2 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -562,7 +562,7 @@ elseif ($action == 'addline') $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); unset($_POST['qty']); unset($_POST['type']); @@ -613,7 +613,7 @@ elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $action=''; } @@ -839,7 +839,7 @@ elseif ($action == 'builddoc') $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - $result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); @@ -1221,7 +1221,7 @@ if ($action == 'create') print '
".$langs->trans("DefaultContact").''; $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); print '
'.$langs->trans('Discounts').''; if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); @@ -1684,7 +1684,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G print ''; - $objectsrc->printOriginLinesList($hookmanager); + $objectsrc->printOriginLinesList(); print '
'; } @@ -2166,7 +2166,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G // Show object lines if (! empty($object->lines)) - $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1); /* * Form to add new line @@ -2180,18 +2180,18 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services - $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); + $object->formAddObjectLine(1,$mysoc,$soc); } else { // Add free products/services - $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddFreeProduct(1,$mysoc,$soc); // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var=!$var; - $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddPredefinedProduct(1,$mysoc,$soc); } } @@ -2354,7 +2354,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $genallowed=$user->rights->commande->creer; $delallowed=$user->rights->commande->supprimer; - $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager); + $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); /* * Linked object block @@ -2397,7 +2397,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $outputlangs->setDefaultLang($newlang); } - $result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index f15762b97bf..4295e1f6fa9 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -117,7 +117,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->c { if ($object->fetch($id) > 0) { - $result=$object->createFromClone($socid, $hookmanager); + $result=$object->createFromClone($socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); @@ -191,7 +191,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } if ($result >= 0) { @@ -394,7 +394,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -471,7 +471,7 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -1184,7 +1184,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- } $ret=$object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -1314,7 +1314,7 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa } $ret=$object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -1360,7 +1360,7 @@ else if ($action == 'up' && $user->rights->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']); exit; @@ -1382,7 +1382,7 @@ else if ($action == 'down' && $user->rights->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']); exit; @@ -1614,7 +1614,7 @@ else if ($action == 'builddoc') // En get ou en post $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); @@ -2186,7 +2186,7 @@ if ($action == 'create') print ''; - $objectsrc->printOriginLinesList($hookmanager); + $objectsrc->printOriginLinesList(); print '
'; } @@ -3054,7 +3054,7 @@ else if ($id > 0 || ! empty($ref)) // Show object lines if (! empty($object->lines)) - $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1); /* * Form to add new line @@ -3066,18 +3066,18 @@ else if ($id > 0 || ! empty($ref)) if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services - $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); + $object->formAddObjectLine(1,$mysoc,$soc); } else { // Add free products/services - $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddFreeProduct(1,$mysoc,$soc); // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var=!$var; - $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddPredefinedProduct(1,$mysoc,$soc); } } @@ -3317,7 +3317,7 @@ else if ($id > 0 || ! empty($ref)) $delallowed=$user->rights->facture->supprimer; print '
'; - print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager); + print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); $somethingshown=$formfile->numoffiles; /* @@ -3382,7 +3382,7 @@ else if ($id > 0 || ! empty($ref)) $outputlangs->setDefaultLang($newlang); } - $result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1637524cfce..b96fd57916d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -541,7 +541,7 @@ class Facture extends CommonInvoice * @param HookManager $hookmanager Hook manager instance * @return int New id of clone */ - function createFromClone($socid=0,$hookmanager=false) + function createFromClone($socid=0) { global $conf,$user,$langs; diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index a3eaa76d463..50ce36d4e9c 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -112,7 +112,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture-> $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs); } header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); diff --git a/htdocs/compta/payment_sc/fiche.php b/htdocs/compta/payment_sc/fiche.php index 0bf129c567b..c8d710e2831 100644 --- a/htdocs/compta/payment_sc/fiche.php +++ b/htdocs/compta/payment_sc/fiche.php @@ -94,7 +94,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs); } header('Location: fiche.php?id='.$paiement->id); diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index d3a7f48c24b..9578bf54c98 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -209,7 +209,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer) setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")),'errors'); $error++; } - + if (! $error) { $ret=$object->fetch($id); @@ -1282,7 +1282,7 @@ else if ($user->rights->contrat->creer && ($object->statut >= 0)) { $dateSelector=1; - + print '
'; print ''; // Array with (n*2)+1 lines @@ -1298,28 +1298,28 @@ else if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services - $object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty,$hookmanager); + $object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty); } else { // Add free products/services - $object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager); - + $object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty); + // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var=!$var; - $object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager); + $object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty); } } - + $parameters=array(); $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } - + // Restore correct setup $conf->product->enabled = $savproductenabled; - + print ''; print '
'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 344507971bb..5c9b8d93122 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2463,10 +2463,9 @@ abstract class CommonObject * TODO Move this into html.class.php * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * - * @param HookManager $hookmanager Hook manager instance * @return void */ - function showLinkedObjectBlock($hookmanager=false) + function showLinkedObjectBlock() { global $conf,$langs,$hookmanager; global $bc; @@ -2543,13 +2542,12 @@ abstract class CommonObject * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object thirdparty who sell * @param Societe $buyer Object thirdparty who buy - * @param HookManager $hookmanager Hook manager instance * @return void * @deprecated */ - function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false) + function formAddPredefinedProduct($dateSelector,$seller,$buyer) { - global $conf,$langs,$object; + global $conf,$langs,$object,$hookmanager; global $form,$bcnd,$var; // Use global variables + $dateSelector + $seller and $buyer @@ -2564,13 +2562,12 @@ abstract class CommonObject * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object thirdparty who sell * @param Societe $buyer Object thirdparty who buy - * @param HookManager $hookmanager Hook manager instance * @return void * @deprecated */ - function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false) + function formAddFreeProduct($dateSelector,$seller,$buyer) { - global $conf,$langs,$object; + global $conf,$langs,$object,$hookmanager; global $form,$bcnd,$var; // Use global variables + $dateSelector + $seller and $buyer @@ -2586,12 +2583,11 @@ abstract class CommonObject * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object thirdparty who sell * @param Societe $buyer Object thirdparty who buy - * @param HookManager $hookmanager Hook manager instance * @return void */ - function formAddObjectLine($dateSelector,$seller,$buyer,$hookmanager=false) + function formAddObjectLine($dateSelector,$seller,$buyer) { - global $conf,$user,$langs,$object; + global $conf,$user,$langs,$object,$hookmanager; global $form,$bcnd,$var; // Output template part (modules that overwrite templates must declare this into descriptor) @@ -2625,12 +2621,11 @@ abstract class CommonObject * @param string $buyer Object of buyer third party * @param string $selected Object line selected * @param int $dateSelector 1=Show also date range input fields - * @param HookManager $hookmanager Hookmanager * @return void */ - function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $hookmanager=false) + function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf,$langs; + global $conf,$langs,$hookmanager; print '
'.$langs->trans('Ref').'
'; - $objectsrc->printOriginLinesList($hookmanager); + $objectsrc->printOriginLinesList(); print '
'; } @@ -2054,7 +2054,7 @@ else $outputlangs->setDefaultLang($newlang); } - $result=supplier_invoice_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=supplier_invoice_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 95c16965fb5..7cdc137d9f1 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -578,12 +578,12 @@ class Societe extends CommonObject if (! $nosyncmember && ! empty($conf->adherent->enabled)) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - + dol_syslog(get_class($this)."::update update linked member"); - + $lmember=new Adherent($this->db); $result=$lmember->fetch(0, 0, $this->id); - + if ($result > 0) { $lmember->firstname=$this->firstname; @@ -604,14 +604,15 @@ class Societe extends CommonObject { $this->error=$lmember->error; $error++; - } + } } } - + // Si le fournisseur est classe on l'ajoute $this->AddFournisseurInCategory($this->fournisseur_categorie); // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('thirdpartydao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -982,7 +983,8 @@ class Societe extends CommonObject */ function delete($id) { - global $user,$langs,$conf; + global $user, $langs, $conf, $hookmanager; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_syslog(get_class($this)."::delete", LOG_DEBUG); @@ -1062,6 +1064,7 @@ class Societe extends CommonObject if (! $error) { // Additionnal action by hooks + // FIXME on a déjà un trigger, pourquoi rajouter un hook !! $hookmanager->initHooks(array('thirdpartydao')); $parameters=array(); $action='delete'; $reshook=$hookmanager->executeHooks('deleteThirdparty',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 9a9900df23e..e8cff6c4016 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -200,7 +200,7 @@ if (empty($reshook)) $error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled"); $action = ($action=='add'?'create':'edit'); } - + // We set country_id, country_code and country for the selected country $object->country_id=GETPOST('country_id')?GETPOST('country_id'):$mysoc->country_id; if ($object->country_id) @@ -225,7 +225,7 @@ if (empty($reshook)) $action = ($action=='add'?'create':'edit'); } } - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { @@ -236,7 +236,7 @@ if (empty($reshook)) } } } - + if (! $error) { if ($action == 'add') @@ -395,11 +395,11 @@ if (empty($reshook)) } // Gestion du logo de la société - + // Update linked member if (! $error && $object->fk_soc > 0) { - + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); @@ -410,7 +410,7 @@ if (empty($reshook)) dol_syslog(get_class($this)."::delete erreur -1 ".$this->error, LOG_ERR); } } - + if (! $error && ! count($errors)) { @@ -867,13 +867,13 @@ else if ($idprof!='-') { if (($j % 2) == 0) print ''; - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if(empty($conf->global->$idprof_mandatory)) print ''.$idprof.''; else print ''.$idprof.''; - + $key='idprof'.$i; print $formcompany->get_input_id_prof($i,'idprof'.$i,$object->$key,$object->country_code); print ''; @@ -945,7 +945,7 @@ else // Capital print ''.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->currency).''; - // Local Taxes + // Local Taxes //TODO: Place into a function to control showing by country or study better option if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") { @@ -968,7 +968,7 @@ else print $form->selectyesno('localtax2assuj_value',0,1); print ''; } - + if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || GETPOST("type")=='') ) { print ''.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; @@ -1317,13 +1317,13 @@ else if ($idprof!='-') { if (($j % 2) == 0) print ''; - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if(empty($conf->global->$idprof_mandatory)) print ''.$idprof.''; else print ''.$idprof.''; - + $key='idprof'.$i; print $formcompany->get_input_id_prof($i,'idprof'.$i,$object->$key,$object->country_code); print ''; @@ -1393,7 +1393,7 @@ else print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); print ''; } - + if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1) { print ''.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; @@ -1716,7 +1716,7 @@ else print yn($object->localtax2_assuj); print ''; } - + if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1) { print ''.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; @@ -1879,7 +1879,7 @@ else $var=true; - $somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang,$hookmanager); + $somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang); print ''; print ''; From 647cbb08fbaa8113f56c8caf67eba338d653ebcb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 26 Jan 2013 10:38:11 +0100 Subject: [PATCH 035/162] Fix: wrong EOL --- htdocs/categories/class/categorie.class.php | 70 ++++++++++----------- htdocs/core/class/hookmanager.class.php | 2 +- htdocs/core/lib/trip.lib.php | 10 +-- htdocs/master.inc.php | 4 +- htdocs/societe/class/societe.class.php | 66 +++++++++---------- htdocs/societe/soc.php | 28 ++++----- 6 files changed, 90 insertions(+), 90 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 802e8e3ff11..c2c249f5e41 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -543,39 +543,39 @@ class Categorie return ($n[0] > 0); } - - /** - * Load this->motherof that is array(id_son=>id_parent, ...) - * - * @return int <0 if KO, >0 if OK - */ - private function load_motherof() - { - global $conf; - - $this->motherof=array(); - + + /** + * Load this->motherof that is array(id_son=>id_parent, ...) + * + * @return int <0 if KO, >0 if OK + */ + private function load_motherof() + { + global $conf; + + $this->motherof=array(); + // Load array[child]=parent - $sql = "SELECT fk_parent as id_parent, rowid as id_son"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE fk_parent != 0"; - $sql.= " AND entity = ".$conf->entity; - - dol_syslog(get_class($this)."::load_motherof sql=".$sql); - $resql = $this->db->query($sql); - if ($resql) - { - while ($obj= $this->db->fetch_object($resql)) - { - $this->motherof[$obj->id_son]=$obj->id_parent; - } - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } + $sql = "SELECT fk_parent as id_parent, rowid as id_son"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE fk_parent != 0"; + $sql.= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::load_motherof sql=".$sql); + $resql = $this->db->query($sql); + if ($resql) + { + while ($obj= $this->db->fetch_object($resql)) + { + $this->motherof[$obj->id_son]=$obj->id_parent; + } + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } } /** @@ -596,8 +596,8 @@ class Categorie { $this->cats = array(); - // Init this->motherof that is array(id_son=>id_parent, ...) - $this->load_motherof(); + // Init this->motherof that is array(id_son=>id_parent, ...) + $this->load_motherof(); // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.fk_parent"; // Distinct reduce pb with old tables with duplicates @@ -695,7 +695,7 @@ class Categorie $i++; $cursor_categ=$this->motherof[$cursor_categ]; } //print 'Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].'
'."\n"; - + // We count number of _ to have level $this->cats[$id_categ]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->cats[$id_categ]['fullpath'])); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 0c31a7569fa..cca22038746 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -179,7 +179,7 @@ class HookManager if (! is_array($result) && ! is_numeric($result)) $this->resPrint.=$result; } - //print "method=".$method." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." result=".$result." resaction=".$resaction; + //print "method=".$method." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." result=".$result." resaction=".$resaction; } } } diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php index 309bcf33224..60794497554 100644 --- a/htdocs/core/lib/trip.lib.php +++ b/htdocs/core/lib/trip.lib.php @@ -50,11 +50,11 @@ function trip_prepare_head($object) $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; - $head[$h][1] = $langs->trans("Info"); - $head[$h][2] = 'info'; - $h++; - + $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove'); return $head; diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index b023f7110b0..41bfa6d3a91 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -207,8 +207,8 @@ if (! defined('NOREQUIRETRAN')) // Create the global $hookmanager object -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager=new HookManager($db); if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR'); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7cdc137d9f1..269f428a61a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -565,45 +565,45 @@ class Societe extends CommonObject $resql=$this->db->query($sql); if ($resql) { - unset($this->country_code); // We clean this because it may have been changed after an update of country_id - unset($this->country); - unset($this->state_code); - unset($this->state); - - $nbrowsaffected+=$this->db->affected_rows($resql); + unset($this->country_code); // We clean this because it may have been changed after an update of country_id + unset($this->country); + unset($this->state_code); + unset($this->state); + + $nbrowsaffected+=$this->db->affected_rows($resql); if (! $error && $nbrowsaffected) { // Update information on linked member if it is an update if (! $nosyncmember && ! empty($conf->adherent->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - - dol_syslog(get_class($this)."::update update linked member"); - - $lmember=new Adherent($this->db); - $result=$lmember->fetch(0, 0, $this->id); - - if ($result > 0) - { - $lmember->firstname=$this->firstname; - $lmember->lastname=$this->lastname; - $lmember->address=$this->address; - $lmember->email=$this->email; - $lmember->phone=$this->phone; - - $result=$lmember->update($user,0,1,1); // Use nosync to 1 to avoid cyclic updates - if ($result < 0) - { - $this->error=$lmember->error; - dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); - $error++; - } - } - else if ($result < 0) - { - $this->error=$lmember->error; - $error++; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + + dol_syslog(get_class($this)."::update update linked member"); + + $lmember=new Adherent($this->db); + $result=$lmember->fetch(0, 0, $this->id); + + if ($result > 0) + { + $lmember->firstname=$this->firstname; + $lmember->lastname=$this->lastname; + $lmember->address=$this->address; + $lmember->email=$this->email; + $lmember->phone=$this->phone; + + $result=$lmember->update($user,0,1,1); // Use nosync to 1 to avoid cyclic updates + if ($result < 0) + { + $this->error=$lmember->error; + dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); + $error++; + } + } + else if ($result < 0) + { + $this->error=$lmember->error; + $error++; } } } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index e8cff6c4016..c1dd0c4c09d 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -395,21 +395,21 @@ if (empty($reshook)) } // Gestion du logo de la société - - // Update linked member - if (! $error && $object->fk_soc > 0) + + // Update linked member + if (! $error && $object->fk_soc > 0) { - - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; - dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); - if (! $this->db->query($sql)) - { - $error++; - $this->error .= $this->db->lasterror(); - dol_syslog(get_class($this)."::delete erreur -1 ".$this->error, LOG_ERR); - } - } + + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; + $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; + dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); + if (! $this->db->query($sql)) + { + $error++; + $this->error .= $this->db->lasterror(); + dol_syslog(get_class($this)."::delete erreur -1 ".$this->error, LOG_ERR); + } + } if (! $error && ! count($errors)) { From 20023880983ece133a0ba84cff1ec5d3368027fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Jan 2013 13:40:31 +0100 Subject: [PATCH 036/162] Revert "New: add hook getFormMail" This reverts commit c7325324839e1796400eb3246873af922d964434. --- htdocs/core/class/html.formmail.class.php | 835 +++++++++++----------- 1 file changed, 406 insertions(+), 429 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index c221cc33c07..3d15fdbeeee 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -217,445 +217,422 @@ class FormMail function get_form($addfileaction='addfile',$removefileaction='removefile') { global $conf, $langs, $user; - global $hookmanager; $langs->load("other"); $langs->load("mails"); - if (! is_object($hookmanager)) + $out=''; + + // Define list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); + + + $form=new Form($this->db); + + $out.= "\n\n"; + if ($this->withform) { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } + $out.= '
'."\n"; + $out.= ''; } - $hookmanager->initHooks(array('formmail')); - - $parameters=array( - 'addfileaction' => $addfileaction, - 'removefileaction'=> $removefileaction - ); - $reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this); - - if (!empty($reshook)) + foreach ($this->param as $key=>$value) { - return $hookmanager->resPrint; + $out.= ''."\n"; } - else + $out.= ''."\n"; + + // Substitution array + if (! empty($this->withsubstit)) { - $out=''; - - // Define list of attached files - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); - if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); - if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - - $form=new Form($this->db); - - $out.= "\n\n"; - if ($this->withform) - { - $out.= ''."\n"; - $out.= ''; - } - foreach ($this->param as $key=>$value) - { - $out.= ''."\n"; - } - $out.= '
'."\n"; - - // Substitution array - if (! empty($this->withsubstit)) - { - $out.= '\n"; - } - - // From - if (! empty($this->withfrom)) - { - if (! empty($this->withfromreadonly)) - { - $out.= ''; - $out.= ''; - $out.= '\n"; - $out.= "\n"; - } - else - { - $out.= "\n"; - } - } - - // Replyto - if (! empty($this->withreplyto)) - { - if ($this->withreplytoreadonly) - { - $out.= ''; - $out.= ''; - $out.= "\n"; - } - } - - // Errorsto - if (! empty($this->witherrorsto)) - { - //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); - if ($this->witherrorstoreadonly) - { - $out.= ''; - $out.= '\n"; - } - else - { - $out.= '\n"; - } - } - - // To - if (! empty($this->withto) || is_array($this->withto)) - { - $out.= '\n"; - } - - // CC - if (! empty($this->withtocc) || is_array($this->withtocc)) - { - $out.= '\n"; - } - - // CCC - if (! empty($this->withtoccc) || is_array($this->withtoccc)) - { - $out.= '\n"; - } - - // Ask delivery receipt - if (! empty($this->withdeliveryreceipt)) - { - $out.= '\n"; - } - - // Topic - if (! empty($this->withtopic)) - { - $this->withtopic=make_substitutions($this->withtopic,$this->substit); - - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - // Attached files - if (! empty($this->withfile)) - { - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - // Message - if (! empty($this->withbody)) - { - $defaultmessage=""; - - // TODO A partir du type, proposer liste de messages dans table llx_models - if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } - - // Complete substitution array - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) - { - require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; - - $langs->load('paypal'); - - if ($this->param["models"]=='order_send') - { - $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - if ($this->param["models"]=='facture_send') - { - $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - } - - $defaultmessage=make_substitutions($defaultmessage,$this->substit); - if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; - $defaultmessage=str_replace('\n',"\n",$defaultmessage); - - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - if (! empty($this->withform)) - { - $out.= ''."\n"; - } - - $out.= '
'; - $help=""; - foreach($this->substit as $key => $val) - { - $help.=$key.' -> '.$langs->trans($val).'
'; - } - $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); - $out.= "
'.$langs->trans("MailFrom").''; - if ($this->fromtype == 'user' && $this->fromid > 0) - { - $langs->load("users"); - $fuser=new User($this->db); - $fuser->fetch($this->fromid); - $out.= $fuser->getNomUrl(1); - } - else - { - $out.= $this->fromname; - } - if ($this->frommail) - { - $out.= " <".$this->frommail.">"; - } - else - { - if ($this->fromtype) - { - $langs->load("errors"); - $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; - } - } - $out.= "
".$langs->trans("MailFrom").""; - $out.= $langs->trans("Name").':'; - $out.= '    '; - $out.= $langs->trans("EMail").':<>'; - $out.= "
".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); - $out.= "
'.$langs->trans("MailErrorsTo").''; - $out.= $errorstomail; - $out.= "
'.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= "
'; - if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - else $out.= $langs->trans("MailTo"); - $out.= ''; - if ($this->withtoreadonly) - { - if (! empty($this->toname) && ! empty($this->tomail)) - { - $out.= ''; - $out.= ''; - if ($this->totype == 'thirdparty') - { - $soc=new Societe($this->db); - $soc->fetch($this->toid); - $out.= $soc->getNomUrl(1); - } - else if ($this->totype == 'contact') - { - $contact=new Contact($this->db); - $contact->fetch($this->toid); - $out.= $contact->getNomUrl(1); - } - else - { - $out.= $this->toname; - } - $out.= ' <'.$this->tomail.'>'; - if ($this->withtofree) - { - $out.= '
'.$langs->trans("or").' withto) :"").'" />'; - } - } - else - { - $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; - } - } - else - { - if (! empty($this->withtofree)) - { - $out.= 'withto) :"").'" />'; - } - if (! empty($this->withto) && is_array($this->withto)) - { - if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); - } - if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - if ($this->withtofree) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); - } - } - $out.= "
'; - $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if ($this->withtoccreadonly) - { - $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; - } - else - { - $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); - } - if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtoccsocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); - } - } - $out.= "
'; - $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if (! empty($this->withtocccreadonly)) - { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; - } - else - { - $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); - } - if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); - } - } - //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); - $out.= "
'.$langs->trans("DeliveryReceipt").''; - - if (! empty($this->withdeliveryreceiptreadonly)) - { - $out.= yn($this->withdeliveryreceipt); - } - else - { - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); - } - - $out.= "
'.$langs->trans("MailTopic").''; - if ($this->withtopicreadonly) - { - $out.= $this->withtopic; - $out.= ''; - } - else - { - $out.= 'withtopic) .'" />'; - } - $out.= "
'.$langs->trans("MailFile").''; - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out.= ''."\n"; - $out.= ''."\n"; - if (count($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $out.= '
'; - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) - { - $out.= ' '; - //$out.= ' '.img_delete($langs->trans("Delete").''; - } - $out.= '
'; - } - } - else - { - $out.= $langs->trans("NoAttachedFiles").'
'; - } - if ($this->withfile == 2) // Can add other files - { - $out.= ''; - $out.= ' '; - $out.= ''; - } - $out.= "
'.$langs->trans("MailText").''; - if ($this->withbodyreadonly) - { - $out.= nl2br($defaultmessage); - $out.= ''; - } - else - { - if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); - $out.= $doleditor->Create(1); - } - $out.= "
'; - $out.= 'withfile == 2 && $conf->use_javascript_ajax) - { - $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; - } - $out.= ' />'; - if ($this->withcancel) - { - $out.= '     '; - $out.= ''; - } - $out.= '
'."\n"; - - if (! empty($this->withform)) $out.= '
'."\n"; - $out.= "\n"; - - return $out; + $out.= ''; + $help=""; + foreach($this->substit as $key => $val) + { + $help.=$key.' -> '.$langs->trans($val).'
'; + } + $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); + $out.= "\n"; } + + // From + if (! empty($this->withfrom)) + { + if (! empty($this->withfromreadonly)) + { + $out.= ''; + $out.= ''; + $out.= ''.$langs->trans("MailFrom").''; + if ($this->fromtype == 'user' && $this->fromid > 0) + { + $langs->load("users"); + $fuser=new User($this->db); + $fuser->fetch($this->fromid); + $out.= $fuser->getNomUrl(1); + } + else + { + $out.= $this->fromname; + } + if ($this->frommail) + { + $out.= " <".$this->frommail.">"; + } + else + { + if ($this->fromtype) + { + $langs->load("errors"); + $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; + } + } + $out.= "\n"; + $out.= "\n"; + } + else + { + $out.= "".$langs->trans("MailFrom").""; + $out.= $langs->trans("Name").':'; + $out.= '    '; + $out.= $langs->trans("EMail").':<>'; + $out.= "\n"; + } + } + + // Replyto + if (! empty($this->withreplyto)) + { + if ($this->withreplytoreadonly) + { + $out.= ''; + $out.= ''; + $out.= "".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); + $out.= "\n"; + } + } + + // Errorsto + if (! empty($this->witherrorsto)) + { + //if (! $this->errorstomail) $this->errorstomail=$this->frommail; + $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); + if ($this->witherrorstoreadonly) + { + $out.= ''; + $out.= ''.$langs->trans("MailErrorsTo").''; + $out.= $errorstomail; + $out.= "\n"; + } + else + { + $out.= ''.$langs->trans("MailErrorsTo").''; + $out.= ''; + $out.= "\n"; + } + } + + // To + if (! empty($this->withto) || is_array($this->withto)) + { + $out.= ''; + if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + else $out.= $langs->trans("MailTo"); + $out.= ''; + if ($this->withtoreadonly) + { + if (! empty($this->toname) && ! empty($this->tomail)) + { + $out.= ''; + $out.= ''; + if ($this->totype == 'thirdparty') + { + $soc=new Societe($this->db); + $soc->fetch($this->toid); + $out.= $soc->getNomUrl(1); + } + else if ($this->totype == 'contact') + { + $contact=new Contact($this->db); + $contact->fetch($this->toid); + $out.= $contact->getNomUrl(1); + } + else + { + $out.= $this->toname; + } + $out.= ' <'.$this->tomail.'>'; + if ($this->withtofree) + { + $out.= '
'.$langs->trans("or").' withto) :"").'" />'; + } + } + else + { + $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; + } + } + else + { + if (! empty($this->withtofree)) + { + $out.= 'withto) :"").'" />'; + } + if (! empty($this->withto) && is_array($this->withto)) + { + if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); + } + if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + if ($this->withtofree) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); + } + } + $out.= "\n"; + } + + // CC + if (! empty($this->withtocc) || is_array($this->withtocc)) + { + $out.= ''; + $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if ($this->withtoccreadonly) + { + $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; + } + else + { + $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); + } + if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtoccsocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); + } + } + $out.= "\n"; + } + + // CCC + if (! empty($this->withtoccc) || is_array($this->withtoccc)) + { + $out.= ''; + $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if (! empty($this->withtocccreadonly)) + { + $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + } + else + { + $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); + } + if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); + } + } + //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); + $out.= "\n"; + } + + // Ask delivery receipt + if (! empty($this->withdeliveryreceipt)) + { + $out.= ''.$langs->trans("DeliveryReceipt").''; + + if (! empty($this->withdeliveryreceiptreadonly)) + { + $out.= yn($this->withdeliveryreceipt); + } + else + { + $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); + } + + $out.= "\n"; + } + + // Topic + if (! empty($this->withtopic)) + { + $this->withtopic=make_substitutions($this->withtopic,$this->substit); + + $out.= ''; + $out.= ''.$langs->trans("MailTopic").''; + $out.= ''; + if ($this->withtopicreadonly) + { + $out.= $this->withtopic; + $out.= ''; + } + else + { + $out.= 'withtopic) .'" />'; + } + $out.= "\n"; + } + + // Attached files + if (! empty($this->withfile)) + { + $out.= ''; + $out.= ''.$langs->trans("MailFile").''; + $out.= ''; + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + $out.= ''."\n"; + $out.= ''."\n"; + if (count($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $out.= '
'; + $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (! $this->withfilereadonly) + { + $out.= ' '; + //$out.= ' '.img_delete($langs->trans("Delete").''; + } + $out.= '
'; + } + } + else + { + $out.= $langs->trans("NoAttachedFiles").'
'; + } + if ($this->withfile == 2) // Can add other files + { + $out.= ''; + $out.= ' '; + $out.= ''; + } + $out.= "\n"; + } + + // Message + if (! empty($this->withbody)) + { + $defaultmessage=""; + + // TODO A partir du type, proposer liste de messages dans table llx_models + if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } + + // Complete substitution array + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) + { + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + + $langs->load('paypal'); + + if ($this->param["models"]=='order_send') + { + $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + if ($this->param["models"]=='facture_send') + { + $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + } + + $defaultmessage=make_substitutions($defaultmessage,$this->substit); + if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; + $defaultmessage=str_replace('\n',"\n",$defaultmessage); + + $out.= ''; + $out.= ''.$langs->trans("MailText").''; + $out.= ''; + if ($this->withbodyreadonly) + { + $out.= nl2br($defaultmessage); + $out.= ''; + } + else + { + if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); + $out.= $doleditor->Create(1); + } + $out.= "\n"; + } + + if (! empty($this->withform)) + { + $out.= '
'; + $out.= 'withfile == 2 && $conf->use_javascript_ajax) + { + $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; + } + $out.= ' />'; + if ($this->withcancel) + { + $out.= '     '; + $out.= ''; + } + $out.= '
'."\n"; + } + + $out.= ''."\n"; + + if (! empty($this->withform)) $out.= ''."\n"; + $out.= "\n"; + + return $out; } } From dde873899974f9fb473f10b93ede74587dbc08fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 11:30:28 +0100 Subject: [PATCH 037/162] Qual: Add a protection to detect bad usage of getStaticMember --- htdocs/core/lib/functions.lib.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3a17c270544..fa0a1c22619 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -51,15 +51,18 @@ function getStaticMember($class, $member) $classObj = new ReflectionClass($class); $result = null; + $found=0; foreach($classObj->getStaticProperties() as $prop => $value) { - if($prop == $member) + if ($prop == $member) { $result = $value; + $found++; break; } } + if (! $found) dol_print_error('','Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.'); return $result; } @@ -2122,7 +2125,7 @@ function dol_print_error($db='',$error='') $out.="
\n"; $out.="".$langs->trans("RequestedUrl").": ".$_SERVER["REQUEST_URI"]."
\n";; $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:'')."
\n";; - $out.="".$langs->trans("MenuManager").": ".$conf->standard_menu."
\n"; + $out.="".$langs->trans("MenuManager").": ".(isset($conf->standard_menu)?$conf->standard_menu:'')."
\n"; $out.="
\n"; $syslog.="url=".$_SERVER["REQUEST_URI"]; $syslog.=", query_string=".$_SERVER["QUERY_STRING"]; From 1b8634588f1ec7ca32b155732e0543fbfd68767c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 11:31:44 +0100 Subject: [PATCH 038/162] Fix: Missing property --- htdocs/core/db/pgsql.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 695ab573fc4..ecb17b8a9f0 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -41,7 +41,9 @@ class DoliDBPgsql //! Database label static $label='PostgreSQL'; // Label of manager //! Charset - var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value + var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value + //! Collate used to force collate when creating database + var $forcecollate=''; // Can't be static as it may be forced with a dynamic value //! Version min database static $versionmin=array(8,4,0); // Version min database From eeba48f9b094fde9e93ae9739f5b108b0ad04afc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 11:43:49 +0100 Subject: [PATCH 039/162] Fix: Log not reported Fix: charset not correctly forced --- htdocs/install/etape1.php | 11 +++++++---- htdocs/install/inc.php | 22 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 32717e18b80..009d953e73d 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -255,8 +255,10 @@ if (! $error && $db->connected) { if (! empty($_POST["db_create_database"])) // If we create database, we force default value { - $defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); - $defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + //$defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); + //$defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + $defaultCharacterSet=$db->forcecharset; + $defaultDBSortingCollation=$db->forcecollate; } else // If already created, we take current value { @@ -268,6 +270,7 @@ if (! $error && $db->connected) print ''; $db_character_set=$defaultCharacterSet; $db_collation=$defaultDBSortingCollation; + dolibarr_install_syslog("db_character_set=".$db_character_set." db_collation=".$db_collation); } @@ -559,8 +562,8 @@ if (! $error && $db->connected && $action == "set") // If database creation is asked, we create it if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on")) { - dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name, LOG_DEBUG); - $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); + dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name." ".$dolibarr_main_db_character_set." ".$dolibarr_main_db_collation." ".$dolibarr_main_db_user, LOG_DEBUG); + $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit; if ($newdb->connected) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 9e8565402d2..866bb471d78 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -200,6 +200,7 @@ if (constant('DOL_DATA_ROOT') && file_exists($lockfile)) // Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); +if (! defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS','["mod_syslog_file"]'); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); @@ -314,7 +315,26 @@ function conf($dolibarr_main_document_root) //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); - + // We init log handler for install + $handlers = array('mod_syslog_file'); + foreach ($handlers as $handler) + { + $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; + if (!file_exists($file)) + { + throw new Exception('Missing log handler file '.$handler.'.php'); + } + + require_once $file; + $loghandlerinstance = new $handler(); + if (!$loghandlerinstance instanceof LogHandlerInterface) + { + throw new Exception('Log handler does not extend LogHandlerInterface'); + } + + $conf->loghandlers[]=$loghandlerinstance; + } + return 1; } From abd8aea06b97f8eb3839c00fb5370da5b41a032d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 11:56:45 +0100 Subject: [PATCH 040/162] Fix: Log not reported Fix: charset not correctly forced Conflicts: htdocs/install/inc.php --- htdocs/install/etape1.php | 11 +++++++---- htdocs/install/inc.php | 23 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 32717e18b80..009d953e73d 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -255,8 +255,10 @@ if (! $error && $db->connected) { if (! empty($_POST["db_create_database"])) // If we create database, we force default value { - $defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); - $defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + //$defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); + //$defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + $defaultCharacterSet=$db->forcecharset; + $defaultDBSortingCollation=$db->forcecollate; } else // If already created, we take current value { @@ -268,6 +270,7 @@ if (! $error && $db->connected) print ''; $db_character_set=$defaultCharacterSet; $db_collation=$defaultDBSortingCollation; + dolibarr_install_syslog("db_character_set=".$db_character_set." db_collation=".$db_collation); } @@ -559,8 +562,8 @@ if (! $error && $db->connected && $action == "set") // If database creation is asked, we create it if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on")) { - dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name, LOG_DEBUG); - $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); + dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name." ".$dolibarr_main_db_character_set." ".$dolibarr_main_db_collation." ".$dolibarr_main_db_user, LOG_DEBUG); + $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit; if ($newdb->connected) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 354ad1e8cbe..f078f7a1802 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -200,6 +200,7 @@ if (constant('DOL_DATA_ROOT') && file_exists($lockfile)) // Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); +if (! defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS','["mod_syslog_file"]'); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); @@ -230,7 +231,6 @@ foreach ($handlers as $handler) $conf->loghandlers[]=$loghandlerinstance; } - // Removed magic_quotes if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP 5.4 { @@ -314,7 +314,26 @@ function conf($dolibarr_main_document_root) //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); - + // We init log handler for install + $handlers = array('mod_syslog_file'); + foreach ($handlers as $handler) + { + $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; + if (!file_exists($file)) + { + throw new Exception('Missing log handler file '.$handler.'.php'); + } + + require_once $file; + $loghandlerinstance = new $handler(); + if (!$loghandlerinstance instanceof LogHandlerInterface) + { + throw new Exception('Log handler does not extend LogHandlerInterface'); + } + + $conf->loghandlers[]=$loghandlerinstance; + } + return 1; } From b98151db9463ed9145748c81e522ac5392bdd30c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 12:22:12 +0100 Subject: [PATCH 041/162] Fix: A log handler can be loaded twice. --- htdocs/core/class/conf.class.php | 2 +- htdocs/install/etape5.php | 4 ++++ htdocs/install/inc.php | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 75414d8f109..500d215ef44 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -454,7 +454,7 @@ class Conf throw new Exception('Log handler does not extend LogHandlerInterface'); } - $this->loghandlers[]=$loghandlerinstance; + $this->loghandlers[$handler]=$loghandlerinstance; } } } diff --git a/htdocs/install/etape5.php b/htdocs/install/etape5.php index 4f7803c9786..1fb4f45e80f 100644 --- a/htdocs/install/etape5.php +++ b/htdocs/install/etape5.php @@ -142,6 +142,10 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); + // Create the global $hookmanager object + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($db); + $ok = 0; // If first install diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 866bb471d78..18648ab8680 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -228,7 +228,7 @@ foreach ($handlers as $handler) throw new Exception('Log handler does not extend LogHandlerInterface'); } - $conf->loghandlers[]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; } @@ -331,8 +331,8 @@ function conf($dolibarr_main_document_root) { throw new Exception('Log handler does not extend LogHandlerInterface'); } - - $conf->loghandlers[]=$loghandlerinstance; + + if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; } return 1; From db38c9baac84145c09068443e0eae35d72dfd3f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 12:35:29 +0100 Subject: [PATCH 042/162] Fix: loghandler loaded twice --- htdocs/core/class/conf.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 500d215ef44..685dfa93b9a 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -454,7 +454,7 @@ class Conf throw new Exception('Log handler does not extend LogHandlerInterface'); } - $this->loghandlers[$handler]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $this->loghandlers[$handler]=$loghandlerinstance; } } } From a8ccc0ab0b0cd3b3ec716f96b74ceef5db9ec2a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 12:36:15 +0100 Subject: [PATCH 043/162] Fix: loghandler loaded twice. --- htdocs/core/class/conf.class.php | 2 +- htdocs/install/inc.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 2d9fb472407..e456effe66e 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -466,7 +466,7 @@ class Conf throw new Exception('Log handler does not extend LogHandlerInterface'); } - $this->loghandlers[]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $this->loghandlers[$handler]=$loghandlerinstance; } } } diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index f078f7a1802..12c58371b29 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -228,7 +228,7 @@ foreach ($handlers as $handler) throw new Exception('Log handler does not extend LogHandlerInterface'); } - $conf->loghandlers[]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; } // Removed magic_quotes @@ -331,7 +331,7 @@ function conf($dolibarr_main_document_root) throw new Exception('Log handler does not extend LogHandlerInterface'); } - $conf->loghandlers[]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; } return 1; From ac3ccade985387beca8e7f7c1b2cf6bb9d71a79a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 13:11:12 +0100 Subject: [PATCH 044/162] Fix: number of chars to low to show value. --- htdocs/core/modules/syslog/mod_syslog_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index b00fa11945a..b0e1bd550b4 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -138,7 +138,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface LOG_DEBUG => 'DEBUG' ); - $message = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".sprintf("%-5s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident>0?str_pad('',$this->ident,' '):'').$content['message']; + $message = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident>0?str_pad('',$this->ident,' '):'').$content['message']; fwrite($filefd, $message."\n"); fclose($filefd); From c42a0c5b035d40a74a804fcf6c757f9107984e61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 14:40:15 +0100 Subject: [PATCH 045/162] Fix: removed warning --- htdocs/admin/company.php | 6 ++--- htdocs/core/menus/standard/eldy.lib.php | 16 +++++------ htdocs/main.inc.php | 2 +- htdocs/societe/class/societe.class.php | 35 +++++++++++++------------ 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index bc61dad4aed..28336d2966a 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -646,13 +646,13 @@ else print ''; $var=!$var; - print ''.$langs->trans("CompanyAddress").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . ''; + print ''.$langs->trans("CompanyAddress").'' . nl2br(empty($conf->global->MAIN_INFO_SOCIETE_ADRESSE)?'':$conf->global->MAIN_INFO_SOCIETE_ADRESSE) . ''; $var=!$var; - print ''.$langs->trans("CompanyZip").'' . $conf->global->MAIN_INFO_SOCIETE_CP . ''; + print ''.$langs->trans("CompanyZip").'' . (empty($conf->global->MAIN_INFO_SOCIETE_CP)?'':$conf->global->MAIN_INFO_SOCIETE_CP) . ''; $var=!$var; - print ''.$langs->trans("CompanyTown").'' . $conf->global->MAIN_INFO_SOCIETE_VILLE . ''; + print ''.$langs->trans("CompanyTown").'' . (empty($conf->global->MAIN_INFO_SOCIETE_VILLE)?'':$conf->global->MAIN_INFO_SOCIETE_VILLE) . ''; $var=!$var; print ''.$langs->trans("CompanyCountry").''; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 67b6b816ea9..c837de7c9fb 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -68,7 +68,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Third parties - $tmpentry=array('enabled'=>($conf->societe->enabled || $conf->fournisseur->enabled), 'perms'=>($user->rights->societe->lire || $user->rights->fournisseur->lire), 'module'=>'societe|fournisseur'); + $tmpentry=array('enabled'=>(! empty($conf->societe->enabled) || ! empty($conf->fournisseur->enabled)), 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), 'module'=>'societe|fournisseur'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { @@ -110,7 +110,7 @@ function print_eldy_menu($db,$atarget,$type_user) } // Products-Services - $tmpentry=array('enabled'=>($conf->product->enabled || $conf->service->enabled), 'perms'=>($user->rights->produit->lire || $user->rights->service->lire), 'module'=>'product|service'); + $tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { @@ -160,7 +160,7 @@ function print_eldy_menu($db,$atarget,$type_user) if (! empty($conf->fournisseur->enabled)) $menuqualified++; if (! empty($conf->contrat->enabled)) $menuqualified++; if (! empty($conf->ficheinter->enabled)) $menuqualified++; - $tmpentry=array('enabled'=>$menuqualified, 'perms'=>($user->rights->societe->lire || $user->rights->societe->contact->lire), 'module'=>'propal|commande|fournisseur|contrat|ficheinter'); + $tmpentry=array('enabled'=>$menuqualified, 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), 'module'=>'propal|commande|fournisseur|contrat|ficheinter'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { @@ -201,7 +201,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Financial $tmpentry=array('enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->don->enabled) || ! empty($conf->tax->enabled)), - 'perms'=>($user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->facture->lire || $user->rights->deplacement->lire || $user->rights->don->lire || $user->rights->tax->charges->lire), + 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->plancompte->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire)), 'module'=>'comptabilite|accounting|facture|deplacement|don|tax'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -243,7 +243,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Bank $tmpentry=array('enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), - 'perms'=>($user->rights->banque->lire || $user->rights->prelevement->lire), + 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), 'module'=>'banque|prelevement'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -286,7 +286,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Projects $tmpentry=array('enabled'=>(! empty($conf->projet->enabled)), - 'perms'=>($user->rights->projet->lire), + 'perms'=>(! empty($user->rights->projet->lire)), 'module'=>'projet'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -328,7 +328,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Tools $tmpentry=array('enabled'=>(! empty($conf->mailing->enabled) || ! empty($conf->export->enabled) || ! empty($conf->import->enabled)), - 'perms'=>($user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run), + 'perms'=>(! empty($user->rights->mailing->lire) || ! empty($user->rights->export->lire) || ! empty($user->rights->import->run)), 'module'=>'mailing|export|import'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -400,7 +400,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Members $tmpentry=array('enabled'=>(! empty($conf->adherent->enabled)), - 'perms'=>($user->rights->adherent->lire), + 'perms'=>(! empty($user->rights->adherent->lire)), 'module'=>'adherent'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ec82c9e7e41..2695a2fd3d0 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1347,7 +1347,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a && $_SESSION["dol_authmode"] != 'http') { $logouttext .='trans('Logout'), 'logout.png', 'class="login"'); $logouttext .=''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 269f428a61a..db147ffde86 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2504,17 +2504,18 @@ class Societe extends CommonObject global $langs; $this->id=0; - $this->name=(! empty($conf->global->MAIN_INFO_SOCIETE_NOM))?$conf->global->MAIN_INFO_SOCIETE_NOM:''; - $this->nom=$this->name; // deprecated - $this->address=(! empty($conf->global->MAIN_INFO_SOCIETE_ADRESSE))?$conf->global->MAIN_INFO_SOCIETE_ADRESSE:''; - $this->adresse=$this->address; // deprecated - $this->zip=(! empty($conf->global->MAIN_INFO_SOCIETE_CP))?$conf->global->MAIN_INFO_SOCIETE_CP:''; - $this->cp=$this->zip; // deprecated - $this->town=(! empty($conf->global->MAIN_INFO_SOCIETE_VILLE))?$conf->global->MAIN_INFO_SOCIETE_VILLE:''; - $this->ville=$this->town; // deprecated - $this->state_id=$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT; + $this->name=empty($conf->global->MAIN_INFO_SOCIETE_NOM)?'':$conf->global->MAIN_INFO_SOCIETE_NOM; + $this->address=empty($conf->global->MAIN_INFO_SOCIETE_ADRESSE)?'':$conf->global->MAIN_INFO_SOCIETE_ADRESSE; + $this->zip=empty($conf->global->MAIN_INFO_SOCIETE_CP)?'':$conf->global->MAIN_INFO_SOCIETE_CP; + $this->town=empty($conf->global->MAIN_INFO_SOCIETE_VILLE)?'':$conf->global->MAIN_INFO_SOCIETE_VILLE; + $this->state_id=empty($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT)?'':$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT; $this->note=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE; - + + $this->nom=$this->name; // deprecated + $this->adresse=$this->address; // deprecated + $this->cp=$this->zip; // deprecated + $this->ville=$this->town; // deprecated + // We define country_id, country_code and country $country_id=$country_code=$country_label=''; if (! empty($conf->global->MAIN_INFO_SOCIETE_PAYS)) @@ -2553,13 +2554,13 @@ class Societe extends CommonObject $this->idprof4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS; $this->idprof5=empty($conf->global->MAIN_INFO_PROFID5)?'':$conf->global->MAIN_INFO_PROFID5; $this->idprof6=empty($conf->global->MAIN_INFO_PROFID6)?'':$conf->global->MAIN_INFO_PROFID6; - $this->tva_intra=(! empty($conf->global->MAIN_INFO_TVAINTRA))?$conf->global->MAIN_INFO_TVAINTRA:''; // VAT number, not necessarly INTRA. - $this->capital=(! empty($conf->global->MAIN_INFO_CAPITAL))?$conf->global->MAIN_INFO_CAPITAL:''; - $this->forme_juridique_code=$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; - $this->email=(! empty($conf->global->MAIN_INFO_SOCIETE_MAIL))?$conf->global->MAIN_INFO_SOCIETE_MAIL:''; - $this->logo=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO))?$conf->global->MAIN_INFO_SOCIETE_LOGO:''; - $this->logo_small=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL))?$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL:''; - $this->logo_mini=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI))?$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI:''; + $this->tva_intra=empty($conf->global->MAIN_INFO_TVAINTRA)?'':$conf->global->MAIN_INFO_TVAINTRA; // VAT number, not necessarly INTRA. + $this->capital=empty($conf->global->MAIN_INFO_CAPITAL)?'':$conf->global->MAIN_INFO_CAPITAL; + $this->forme_juridique_code=empty($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)?'':$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; + $this->email=empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?'':$conf->global->MAIN_INFO_SOCIETE_MAIL; + $this->logo=empty($conf->global->MAIN_INFO_SOCIETE_LOGO)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO; + $this->logo_small=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL; + $this->logo_mini=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; // Define if company use vat or not (Do not use conf->global->FACTURE_TVAOPTION anymore) $this->tva_assuj=((isset($conf->global->FACTURE_TVAOPTION) && $conf->global->FACTURE_TVAOPTION=='franchise')?0:1); From 0743049dc4276c7eb67afaf3aa24d3ffab8cd457 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 14:57:37 +0100 Subject: [PATCH 046/162] Fix: get list of currencies --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a804948bf1d..e71a0f6eafe 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3005,14 +3005,14 @@ class Form { global $conf,$langs,$user; - $langs->load_cache_currencies(); + $langs->load_cache_currencies(''); $out=''; if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilite $out.= ' blocks. - * - * @access public - * - * @param string $buffer The source text to be filtered. - * - * @return string The filtered text. - * - */ - - public static function filter($buffer) - { - // Pull out the script blocks - preg_match_all("!]+>.*?!is", $buffer, $match); - $script_blocks = $match[0]; - $buffer = preg_replace( - "!]+>.*?!is", - '@@@SAVANT:TRIM:SCRIPT@@@', - $buffer - ); - - // Pull out the pre blocks - preg_match_all("!]*>.*?!is", $buffer, $match); - $pre_blocks = $match[0]; - $buffer = preg_replace( - "!]*>.*?!is", - '@@@SAVANT:TRIM:PRE@@@', - $buffer - ); - - // Pull out the textarea blocks - preg_match_all("!]+>.*?!is", $buffer, $match); - $textarea_blocks = $match[0]; - $buffer = preg_replace( - "!]+>.*?!is", - '@@@SAVANT:TRIM:TEXTAREA@@@', - $buffer - ); - - // remove all leading spaces, tabs and carriage returns NOT - // preceeded by a php close tag. - $buffer = trim(preg_replace('/((?)\n)[\s]+/m', '\1', $buffer)); - - // replace script blocks - Savant3_Filter_trimwhitespace::replace( - "@@@SAVANT:TRIM:SCRIPT@@@", - $script_blocks, - $buffer - ); - - // replace pre blocks - Savant3_Filter_trimwhitespace::replace( - "@@@SAVANT:TRIM:PRE@@@", - $pre_blocks, - $buffer - ); - - // replace textarea blocks - Savant3_Filter_trimwhitespace::replace( - "@@@SAVANT:TRIM:TEXTAREA@@@", - $textarea_blocks, - $buffer - ); - - return $buffer; - } - - - /** - * - * Does a simple search-and-replace on the source text. - * - * @access protected - * - * @param string $search The string to search for. - * - * @param string $replace Replace with this text. - * - * @param string &$buffer The source text. - * - * @return string The text after search-and-replace. - * - */ - - protected static function replace($search, $replace, &$buffer) - { - $len = strlen($search); - $pos = 0; - $count = count($replace); - - for ($i = 0; $i < $count; $i++) { - // does the search-string exist in the buffer? - $pos = strpos($buffer, $search, $pos); - if ($pos !== false) { - // replace the search-string - $buffer = substr_replace($buffer, $replace[$i], $pos, $len); - } else { - break; - } - } - } -} -?> \ No newline at end of file diff --git a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_ahref.php b/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_ahref.php deleted file mode 100644 index 6d6bb319bb3..00000000000 --- a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_ahref.php +++ /dev/null @@ -1,109 +0,0 @@ -... tag. -* -* @package Savant3 -* -* @author Paul M. Jones -* -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* -* @version $Id: Savant3_Plugin_ahref.php,v 1.4 2005/08/09 12:56:14 pmjones Exp $ -* -*/ - -/** -* -* Generates an ... tag. -* -* @package Savant3 -* -* @author Paul M. Jones -* -*/ - -class Savant3_Plugin_ahref extends Savant3_Plugin { - - /** - * - * Generate an HTML ... tag. - * - * @access public - * - * @param string|array $href A string URL for the resulting tag. May - * also be an array with any combination of the keys 'scheme', - * 'host', 'path', 'query', and 'fragment' (c.f. PHP's native - * parse_url() function). - * - * @param string $text The displayed text of the link. - * - * @param string|array $attr Any extra attributes for the tag. - * - * @return string The ... tag. - * - */ - - public function ahref($href, $text, $attr = null) - { - $html = ' $val) { - $key = htmlspecialchars($key); - $val = htmlspecialchars($val); - $html .= " $key=\"$val\""; - } - } elseif (! is_null($attr)) { - // from scalar - $html .= htmlspecialchars(" $attr"); - } - - // set the link text, close the tag, and return - $html .= '>' . $text . ''; - return $html; - } -} -?> \ No newline at end of file diff --git a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_date.php b/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_date.php deleted file mode 100644 index c35db4ca7b6..00000000000 --- a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_date.php +++ /dev/null @@ -1,123 +0,0 @@ - -* -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* -* @version $Id: Savant3_Plugin_date.php,v 1.3 2005/03/07 14:40:16 pmjones Exp $ -* -*/ - -/** -* -* Plugin to generate a formatted date using strftime() conventions. -* -* @package Savant3 -* -* @author Paul M. Jones -* -*/ - -class Savant3_Plugin_date extends Savant3_Plugin { - - /** - * - * The default strftime() format string. - * - * @access public - * - * @var array - * - */ - - public $default = '%c'; - - - /** - * - * Custom strftime() format strings to use for dates. - * - * You can preset the format strings via Savant3::setPluginConf(). - * - * - * $conf = array( - * 'custom' => array( - * 'mydate' => '%Y-%m-%d', - * 'mytime' => '%R' - * ) - * ); - * - * $Savant->setPluginConf('date', $conf); - * - * - * ... and in your template, to use a preset custom string by name: - * - * - * echo $this->date($value, 'mydate'); - * - * - * @access public - * - * @var array - * - */ - - public $custom = array( - 'date' => '%Y-%m-%d', - 'time' => '%H:%M:%S' - ); - - - /** - * - * Outputs a formatted date using strftime() conventions. - * - * @access public - * - * @param string $datestring Any date-time string suitable for - * strtotime(). - * - * @param string $format The strftime() formatting string, or a named - * custom string key from $this->custom. - * - * @return string The formatted date string. - * - */ - - function date($datestring, $format = null) - { - settype($format, 'string'); - - if (is_null($format)) { - $format = $this->default; - } - - // does the format string have a % sign in it? - if (strpos($format, '%') === false) { - // no, look for a custom format string - if (! empty($this->custom[$format])) { - // found a custom format string - $format = $this->custom[$format]; - } else { - // did not find the custom format, revert to default - $format = $this->default; - } - } - - // convert the date string to the specified format - if (trim($datestring != '')) { - return strftime($format, strtotime($datestring)); - } else { - // no datestring, return VOID - return; - } - } - -} -?> \ No newline at end of file diff --git a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_htmlAttribs.php b/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_htmlAttribs.php deleted file mode 100644 index 09257f77cf7..00000000000 --- a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_htmlAttribs.php +++ /dev/null @@ -1,63 +0,0 @@ - -* -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* -* @version $Id: Savant3_Plugin_htmlAttribs.php,v 1.3 2005/09/12 17:49:27 pmjones Exp $ -* -*/ - -/** -* -* Plugin to convert an associative array to a string of tag attributes. -* -* @package Savant3 -* -* @author Paul M. Jones -* -*/ - -class Savant3_Plugin_htmlAttribs extends Savant3_Plugin { - - /** - * - * Converts an associative array to a string of tag attributes. - * - * @access public - * - * @param array $attribs From this array, each key-value pair is - * converted to an attribute name and value. - * - * @return string The XHTML for the attributes. - * - */ - - public function htmlAttribs($attribs) - { - $xhtml = ''; - foreach ((array) $attribs as $key => $val) { - - if ($val === null) { - continue; - } - - if (is_array($val)) { - $val = implode(' ', $val); - } - - $key = htmlspecialchars($key); - $val = htmlspecialchars($val); - - $xhtml .= " $key=\"$val\""; - } - return $xhtml; - } -} -?> \ No newline at end of file diff --git a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_image.php b/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_image.php deleted file mode 100644 index 4b316e7537c..00000000000 --- a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_image.php +++ /dev/null @@ -1,199 +0,0 @@ - tag. -* -* @package Savant3 -* -* @author Paul M. Jones -* -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* -* @version $Id: Savant3_Plugin_image.php,v 1.7 2005/08/12 14:34:09 pmjones Exp $ -* -*/ - -/** -* -* Plugin to generate an tag. -* -* Support for alpha transparency of PNG files in Microsoft IE added by -* Edward Ritter; thanks, Edward. -* -* @package Savant3 -* -* @author Paul M. Jones -* -*/ - -class Savant3_Plugin_image extends Savant3_Plugin { - - - /** - * - * The document root. - * - * @access public - * - * @var string - * - */ - - protected $documentRoot = null; - - - /** - * - * The base directory for images within the document root. - * - * @access public - * - * @var string - * - */ - - protected $imageDir = null; - - - /** - * - * Outputs an tag. - * - * Microsoft IE alpha PNG support added by Edward Ritter. - * - * @access public - * - * @param string $file The path to the image on the local file system - * relative to $this->imageDir. - * - * @param string $alt Alternative descriptive text for the image; - * defaults to the filename of the image. - * - * @param int $border The border width for the image; defaults to zero. - * - * @param int $width The displayed image width in pixels; defaults to - * the width of the image. - * - * @param int $height The displayed image height in pixels; defaults to - * the height of the image. - * - * @return string An tag. - * - */ - - public function image($file, $alt = null, $height = null, $width = null, - $attr = null) - { - // is the document root set? - if (is_null($this->documentRoot) && isset($_SERVER['DOCUMENT_ROOT'])) { - // no, so set it - $this->documentRoot = $_SERVER['DOCUMENT_ROOT']; - } - - // make sure there's a DIRECTORY_SEPARATOR between the docroot - // and the image dir - if (substr($this->documentRoot, -1) != DIRECTORY_SEPARATOR && - substr($this->imageDir, 0, 1) != DIRECTORY_SEPARATOR) { - $this->documentRoot .= DIRECTORY_SEPARATOR; - } - - // make sure there's a separator between the imageDir and the - // file name - if (substr($this->imageDir, -1) != DIRECTORY_SEPARATOR && - substr($file, 0, 1) != DIRECTORY_SEPARATOR) { - $this->imageDir .= DIRECTORY_SEPARATOR; - } - - // the image file type code (PNG = 3) - $type = null; - - // get the file information - $info = false; - - if (strpos($file, '://') === false) { - // no "://" in the file, so it's local - $file = $this->imageDir . $file; - $tmp = $this->documentRoot . $file; - $info = @getimagesize($tmp); - } else { - // don't attempt to get file info from streams, it takes - // way too long. - $info = false; - } - - // did we find the file info? - if (is_array($info)) { - - // capture type info regardless - $type = $info[2]; - - // capture size info where both not specified - if (is_null($width) && is_null($height)) { - $width = $info[0]; - $height = $info[1]; - } - } - - // clean up - unset($info); - - // is the file a PNG? if so, check user agent, we will need to - // make special allowances for Microsoft IE. - if (stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && $type === 3) { - - // support alpha transparency for PNG files in MSIE - $html = 'Savant->htmlAttribs($attr); - - // done - $html .= '>'; - - } else { - - // not IE, so build a normal image tag. - $html = 'Savant->htmlAttribs($attr); - - // done - $html .= ' />'; - - } - - // done! - return $html; - } -} - -?> \ No newline at end of file From a177853299e92f3eac71cced8ce0bd3e46767e82 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 28 Jan 2013 20:30:33 +0100 Subject: [PATCH 051/162] =?UTF-8?q?Fix:=20la=20b=C3=A9tise=20n'a=20pas=20d?= =?UTF-8?q?e=20limite=20!=20restons=20archa=C3=AFque.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/main.inc.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2695a2fd3d0..f7081340f8a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -675,14 +675,6 @@ if (! defined('NOREQUIRETRAN')) } } -// Use php template engine -if (! empty($conf->global->MAIN_USE_TEMPLATE_ENGINE) && ! defined('NOTEMPLATEENGINE')) -{ - require_once DOL_DOCUMENT_ROOT.'/includes/savant/Savant3.php'; - - $tpl = new Savant3(); -} - // Case forcing style from url if (GETPOST('theme')) { @@ -832,7 +824,7 @@ if (! function_exists("llxHeader")) function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') { global $conf; - + // html header top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); @@ -845,7 +837,7 @@ if (! function_exists("llxHeader")) { left_menu('', $help_url, '', '', 1, $title); } - + // main area main_area($title); } From 180fb2c91a66a4cf3b9f901be827fefa55be576f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Jan 2013 15:22:07 +0100 Subject: [PATCH 052/162] Fix: Option COMPANY_USE_SEARCH_TO_SELECT was not working for third party selection when autocomplete is on. --- htdocs/core/class/html.form.class.php | 17 +++++++++++++++-- htdocs/core/js/lib_head.js | 8 +++++++- htdocs/core/lib/ajax.lib.php | 3 ++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e71a0f6eafe..f31cb0f741e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -688,8 +688,21 @@ class Form if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && ! $forcecombo) { //$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); - - $out.= ajax_combobox($htmlname, $event); + $out.= ajax_combobox($htmlname, $event, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); + /* + if ($selected && empty($selected_input_value)) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $product = new Product($this->db); + $product->fetch($selected); + $selected_input_value=$product->ref; + } + // mode=1 means customers products + $ajaxoptions=array(); + $urloption='htmlname='.$htmlname.'&outjson=1&filter='.urlencode($filter).'&showtype='.$showtype; + $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); + $out.=''; + */ } $out.= ''; +print ''; +print ''; // Show constants $sql = "SELECT"; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index bb10a493384..c24a0bd4ceb 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -59,6 +59,7 @@ NbOfEntries=Nb of entries GoToWikiHelpPage=Read online help (need Internet access) GoToHelpPage=Read help RecordSaved=Record saved +RecordDeleted=Record deleted LevelOfFeature=Level of features NotDefined=Not defined DefinedAndHasThisValue=Defined and value to diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 52c7b339ffe..ddac2178b58 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -59,6 +59,7 @@ NbOfEntries=Nb d'entrées GoToWikiHelpPage=Consulter l'aide (nécessite un accès internet) GoToHelpPage=Consulter l'aide RecordSaved=Enregistrement sauvegardé +RecordDeleted=Enregistrement supprimé LevelOfFeature=Niveau de fonctionnalités NotDefined=Non défini DolibarrInHttpAuthenticationSoPasswordUseless=Dolibarr est configuré en mode authentification %s dans son fichier de configuration conf.php.
Cela signifie que la base des mots de passe est externe à Dolibarr, aussi toute modification de ce champ peut s'avérer sans effet. From 031bc911ea5b2e25efc06c7f8f418379baf5a239 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Feb 2013 16:46:28 +0100 Subject: [PATCH 097/162] Fix: Mass save or update of const fails. --- htdocs/admin/const.php | 46 +++++++++++++++++++++++++++++------- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 0d263991714..77534fd0d76 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -35,7 +35,7 @@ $rowid=GETPOST('rowid','int'); $entity=GETPOST('entity','int'); $action=GETPOST('action','alpha'); $update=GETPOST('update','alpha'); -$delete=GETPOST('delete','alpha'); +$delete=GETPOST('delete'); // Do not use alpha here $debug=GETPOST('debug','int'); $consts=GETPOST('const'); $constname=GETPOST('constname','alpha'); @@ -47,6 +47,7 @@ $typeconst=array('yesno' => 'yesno', 'texte' => 'texte', 'chaine' => 'chaine'); $mesg=''; + /* * Actions */ @@ -68,46 +69,70 @@ if ($action == 'add') if (! $error) { - if (dolibarr_set_const($db, $constname, $constvalue, $typeconst[$consttype], 1, $constnote, $entity) < 0) + if (dolibarr_set_const($db, $constname, $constvalue, $typeconst[$consttype], 1, $constnote, $entity) >= 0) + { + setEventMessage($langs->trans("RecordSaved")); + } + else { dol_print_error($db); } } } -if (! empty($consts) && $update == $langs->trans("Modify")) +// Mass update +if (! empty($consts) && $action == 'update') { + $nbmodified=0; foreach($consts as $const) { if (! empty($const["check"])) { - if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) < 0) + if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0) + { + $nbmodified++; + } + else { dol_print_error($db); } } } + if ($nbmodified > 0) setEventMessage($langs->trans("RecordSaved")); + $action=''; } -// Delete several lines at once -if (! empty($consts) && $delete == $langs->trans("Delete")) +// Mass delete +if (! empty($consts) && $action == 'delete') { + + $nbdeleted=0; foreach($consts as $const) { if (! empty($const["check"])) // Is checkbox checked { - if (dolibarr_del_const($db, $const["rowid"], -1) < 0) + if (dolibarr_del_const($db, $const["rowid"], -1) >= 0) + { + $nbdeleted++; + } + else { dol_print_error($db); } } } + if ($nbdeleted > 0) setEventMessage($langs->trans("RecordDeleted")); + $action=''; } // Delete line from delete picto if ($action == 'delete') { - if (dolibarr_del_const($db, $rowid, $entity) < 0) + if (dolibarr_del_const($db, $rowid, $entity) >= 0) + { + setEventMessage($langs->trans("RecordDeleted")); + } + else { dol_print_error($db); } @@ -130,11 +155,13 @@ jQuery(document).ready(function() { jQuery("#delconst").hide(); jQuery(".checkboxfordelete").click(function() { jQuery("#delconst").show(); + jQuery("#action").val('delete'); }); jQuery(".inputforupdate").keypress(function() { var field_id = jQuery(this).attr("id"); var row_num = field_id.split("_"); jQuery("#updateconst").show(); + jQuery("#action").val('update'); jQuery("#check_" + row_num[1]).attr("checked",true); }); }); @@ -195,7 +222,8 @@ print ''; print "\n"; print '
entity) && $debug)?'?debug=1':'').'" method="POST">'; -print ''; +print ''; +print ''; // Show constants $sql = "SELECT"; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index dc2ee6b225e..98c28b231b2 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -58,6 +58,7 @@ NbOfEntries=Nb of entries GoToWikiHelpPage=Read online help (need Internet access) GoToHelpPage=Read help RecordSaved=Record saved +RecordDeleted=Record deleted LevelOfFeature=Level of features NotDefined=Not defined DefinedAndHasThisValue=Defined and value to diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index e402a8cd1fe..301b97c1e3a 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -58,6 +58,7 @@ NbOfEntries=Nb d'entrées GoToWikiHelpPage=Consulter l'aide (nécessite un accès internet) GoToHelpPage=Consulter l'aide RecordSaved=Enregistrement sauvegardé +RecordDeleted=Enregistrement supprimé LevelOfFeature=Niveau de fonctionnalités NotDefined=Non défini DolibarrInHttpAuthenticationSoPasswordUseless=Dolibarr est configuré en mode authentification %s dans son fichier de configuration conf.php.
Cela signifie que la base des mots de passe est externe à Dolibarr, aussi toute modification de ce champ peut s'avérer sans effet. From 365680d90eab9faee8d37b4bdc21e0ee2b0873a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Feb 2013 21:25:17 +0100 Subject: [PATCH 098/162] Fix: Missing vat rates --- htdocs/install/mysql/data/llx_c_tva.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 8b840baf392..4e301564db8 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -67,6 +67,10 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 2 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (141, 14, '7','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (142, 14, '0','0','VAT Rate 0',1); +-- CAMEROUN (id country=24) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (241, 24, '19.25','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (242, 24, '0','0','VAT Rate 0',1); + -- CHILE (id country=67) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (671, 67, '19','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (672, 67, '0','0','VAT Rate 0',1); @@ -151,6 +155,10 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (17 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1662, 166, '15','0','VAT standard rate', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1663, 166, '0','0','VAT Rate 0', 1); +-- NIGERIA (id country=169) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1692, 169, '5','0','VAT standard rate', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1693, 169, '0','0','VAT Rate 0', 1); + -- NORWAY (id country=173) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1731, 173, '25','0','VAT standard rate', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1732, 173, '14','0','VAT reduced rate', 1); From f043fcfaf7c99644c96ff5d84874dd24d5a8fb3e Mon Sep 17 00:00:00 2001 From: fhenry Date: Thu, 14 Feb 2013 13:55:05 +0100 Subject: [PATCH 099/162] Fix bug [ bug #709 ] --- htdocs/comm/action/listactions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index f369b25ab3b..341d430f2ac 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -143,6 +143,7 @@ if ($socid) $param.="&socid=".$socid; if ($showbirthday) $param.="&showbirthday=1"; if ($pid) $param.="&projectid=".$pid; if ($type) $param.="&type=".$type; +if ($actioncode) $param.="&actioncode=".$actioncode; $sql = "SELECT s.nom as societe, s.rowid as socid, s.client,"; $sql.= " a.id, a.datep as dp, a.datep2 as dp2,"; From 2af7fd858e387513f043f02abed6b897ba2cf0c3 Mon Sep 17 00:00:00 2001 From: fhenry Date: Thu, 14 Feb 2013 14:57:37 +0100 Subject: [PATCH 100/162] Task 714 --- htdocs/admin/mailing.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 54203dd7ae1..ea5c9b7bbb4 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -105,6 +105,24 @@ print_fiche_titre($langs->trans("MailingSetup"),$linkback,'setup'); dol_htmloutput_mesg($mesg); + +if (! empty($conf->use_javascript_ajax)) +{ + print "\n".''; +} + print '
'; print ''; print ''; @@ -155,7 +173,9 @@ print ''; $var=!$var; print ''; print $langs->trans("ActivateCheckReadKey").''; -print ''; +print ''; +if (! empty($conf->use_javascript_ajax)) + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); print ''; print ''; From d41e754f43b69fbe6e0230cd759afe3d16855cfe Mon Sep 17 00:00:00 2001 From: fhenry Date: Thu, 14 Feb 2013 15:08:22 +0100 Subject: [PATCH 101/162] Fix bug on task 350 --- htdocs/comm/prospect/list.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 69aaab9e68e..f00b93f1966 100755 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -24,6 +24,10 @@ * \brief Page to list prospects */ +error_reporting(E_ALL); +ini_set('display_errors', true); +ini_set('html_errors', false); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/prospect/class/prospect.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -389,6 +393,7 @@ if ($resql) $prospectstatic->id=$obj->rowid; $prospectstatic->nom=$obj->nom; $prospectstatic->status=$obj->status; + $prospectstatic->fk_prospectlevel=$obj->fk_prospectlevel; print $prospectstatic->getNomUrl(1,'prospect'); print ''; print "".$obj->zip." "; @@ -398,7 +403,7 @@ if ($resql) print ''.dol_print_date($db->jdate($obj->datec)).''; // Level print ''; - print $prospectstatic->LibLevel($obj->fk_prospectlevel); + print $prospectstatic->getLibProspLevel(); print ""; // Statut print ''; @@ -419,7 +424,7 @@ if ($resql) print ''; print ''; - print $prospectstatic->getLibStatut(3); + print $prospectstatic->LibStatut($prospectstatic->status,3); print ''; $parameters=array('obj' => $obj); From f65f0e3f11f658241fbca369ed198d5b6eaaad2b Mon Sep 17 00:00:00 2001 From: fhenry Date: Thu, 14 Feb 2013 15:27:48 +0100 Subject: [PATCH 102/162] Remove debug string in buf correction of task 350 --- htdocs/comm/prospect/list.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index f00b93f1966..302c47e2d1e 100755 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -24,10 +24,6 @@ * \brief Page to list prospects */ -error_reporting(E_ALL); -ini_set('display_errors', true); -ini_set('html_errors', false); - require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/prospect/class/prospect.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; From ff214dd295c5105d11c3eebef7527255c5e02600 Mon Sep 17 00:00:00 2001 From: fhenry Date: Thu, 14 Feb 2013 16:25:43 +0100 Subject: [PATCH 103/162] Manage tabs (add/remove by external module) for mass emalings screen --- htdocs/core/lib/emailing.lib.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index e3d1b790f6e..766886af2c0 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -31,6 +31,12 @@ function emailing_prepare_head($object) { global $user, $langs, $conf; + // 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 + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'mailling'); + $h = 0; $head = array(); @@ -53,6 +59,8 @@ function emailing_prepare_head($object) $head[$h][2] = 'info'; $h++; + complete_head_from_modules($conf,$langs,$object,$head,$h,'mailling','remove'); + return $head; } From c02bd0871159f2fdf4ce1d0dc91de050c6e703a5 Mon Sep 17 00:00:00 2001 From: fhenry Date: Thu, 14 Feb 2013 16:35:54 +0100 Subject: [PATCH 104/162] Checkstyle --- htdocs/core/lib/emailing.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index 766886af2c0..e68a62a2768 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -35,7 +35,7 @@ function emailing_prepare_head($object) // 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 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf,$langs,$object,$head,$h,'mailling'); + complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing'); $h = 0; $head = array(); @@ -59,7 +59,7 @@ function emailing_prepare_head($object) $head[$h][2] = 'info'; $h++; - complete_head_from_modules($conf,$langs,$object,$head,$h,'mailling','remove'); + complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing','remove'); return $head; } From 14f21bc9f1d11326f804d942734bf2fb9f85a941 Mon Sep 17 00:00:00 2001 From: jfefe Date: Thu, 14 Feb 2013 23:34:44 +0100 Subject: [PATCH 105/162] Add select list in extrafields type --- htdocs/core/admin_extrafields.inc.php | 19 ++++- htdocs/core/class/extrafields.class.php | 72 +++++++++++++++---- htdocs/core/tpl/admin_extrafields_add.tpl.php | 35 ++++++--- .../install/mysql/migration/3.3.0-3.4.0.sql | 5 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/errors.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + htdocs/langs/fr_FR/errors.lang | 1 + 8 files changed, 113 insertions(+), 22 deletions(-) diff --git a/htdocs/core/admin_extrafields.inc.php b/htdocs/core/admin_extrafields.inc.php index 46ed7d0c051..29c71f9ba45 100644 --- a/htdocs/core/admin_extrafields.inc.php +++ b/htdocs/core/admin_extrafields.inc.php @@ -28,6 +28,7 @@ $extrasize=GETPOST('size'); if (GETPOST('type')=='double' && strpos($extrasize,',')===false) $extrasize='24,8'; if (GETPOST('type')=='date') $extrasize=''; if (GETPOST('type')=='datetime') $extrasize=''; +if (GETPOST('type')=='select') $extrasize=''; // Add attribute @@ -58,13 +59,29 @@ if ($action == 'add') $mesg=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint); $action = 'create'; } + if (GETPOST('type')=='select' && !GETPOST('extra_value')) + { + $error++; + $langs->load("errors"); + $mesg=$langs->trans("ErrorNoValueForSelectType"); + $action = 'create'; + } if (! $error) { // Type et taille non encore pris en compte => varchar(255) if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname'])) { - $result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0)); + // Construct array for parameter (value of select list) + $parameters = GETPOST('extra_value'); + $parameters_array = explode("\r\n",$parameters); + foreach($parameters_array as $param_ligne) + { + list($key,$value) = explode(',',$param_ligne); + $params['options'][$key] = $value; + } + + $result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params); if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 799200ca5bf..0fd57fed96d 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -38,6 +38,8 @@ class ExtraFields var $attribute_label; // Tableau contenant le nom des champs en clef et la taille de ces champs en value var $attribute_size; + // Tableau contenant le nom des choix en clef et la valeur de ces choix en value + var $attribute_choice; // Array to store if attribute is unique or not var $attribute_unique; // Array to store if attribute is required or not @@ -56,7 +58,8 @@ class ExtraFields 'boolean'=>'Boolean', 'price'=>'ExtrafieldPrice', 'phone'=>'ExtrafieldPhone', - 'mail'=>'ExtrafieldMail' + 'mail'=>'ExtrafieldMail', + 'select' => 'ExtrafieldSelect' ); /** @@ -87,20 +90,22 @@ class ExtraFields * @param string $elementtype Element type ('member', 'product', 'company', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not + * @param array $param Params for field * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0) + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0,$default_value='', $param=0) { if (empty($attrname)) return -1; if (empty($label)) return -1; + // Create field into database - $result=$this->create($attrname,$type,$size,$elementtype, $unique, $required); + $result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param); $err1=$this->errno; if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS') { // Add declaration of field into table - $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required); + $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param); $err2=$this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { @@ -126,12 +131,15 @@ class ExtraFields * @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not + * @param string $default_value Default value for field + * @param array $param Params for field (ex for select list : array('options'=>array('value'=>'label of option')) + * * @return int <=0 if KO, >0 if OK */ - private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0) + private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='') { $table=$elementtype.'_extrafields'; - + // Special case for not normalized table names if ($elementtype == 'member') $table='adherent_extrafields'; elseif ($elementtype == 'company') $table='societe_extrafields'; @@ -151,11 +159,20 @@ class ExtraFields }elseif($type=='mail') { $typedb='varchar'; $lengthdb='128'; + } elseif ($type=='select') { + $typedb='text'; + $lengthdb=''; } else { $typedb=$type; $lengthdb=$length; } - $field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required?'NOT NULL':'NULL')); + $field_desc = array( + 'type'=>$typedb, + 'value'=>$lengthdb, + 'null'=>($required?'NOT NULL':'NULL'), + 'default' => $default_value + ); + $result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); if ($result > 0) { @@ -190,19 +207,33 @@ class ExtraFields * @param string $elementtype Element type ('member', 'product', 'company', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not + * @param array $param Params for field (ex for select list : array('value'=>'label of option') ) * @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) + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0,$param) { global $conf; // Clean parameters if (empty($pos)) $pos=0; - + if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired)"; + if(is_array($param) and count($param) > 0) + { + $params = $this->db->escape(serialize($param)); + } + elseif (strlen($param) > 0) + { + $params = trim($param); + } + else + { + $params=''; + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param)"; $sql.= " VALUES('".$attrname."',"; $sql.= " '".$this->db->escape($label)."',"; $sql.= " '".$type."',"; @@ -211,7 +242,8 @@ class ExtraFields $sql.= " ".$conf->entity.","; $sql.= " '".$elementtype."',"; $sql.= " '".$unique."',"; - $sql.= " '".$required."'"; + $sql.= " '".$required."',"; + $sql.= " '".$params."'"; $sql.=')'; dol_syslog(get_class($this)."::create_label sql=".$sql); @@ -480,7 +512,7 @@ class ExtraFields if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity = ".$conf->entity; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; @@ -502,6 +534,7 @@ class ExtraFields $this->attribute_elementtype[$tab->name]=$tab->elementtype; $this->attribute_unique[$tab->name]=$tab->fieldunique; $this->attribute_required[$tab->name]=$tab->fieldrequired; + $this->attribute_param[$tab->name]=unserialize($tab->param); } } return $array_name_label; @@ -531,6 +564,7 @@ class ExtraFields $elementtype=$this->attribute_elementtype[$key]; $unique=$this->attribute_unique[$key]; $required=$this->attribute_required[$key]; + $param=$this->attribute_param[$key]; if ($type == 'date') { $showsize=10; @@ -593,6 +627,15 @@ class ExtraFields { $out=' '.$langs->getCurrencySymbol($conf->currency); } + elseif ($type == 'select') + { + $out=''; + } // Add comments if ($type == 'date') $out.=' (YYYY-MM-DD)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; @@ -617,6 +660,7 @@ class ExtraFields $elementtype=$this->attribute_elementtype[$key]; $unique=$this->attribute_unique[$key]; $required=$this->attribute_required[$key]; + $params=$this->attribute_param[$key]; if ($type == 'date') { $showsize=10; @@ -649,6 +693,10 @@ class ExtraFields { $value=price($value).' '.$langs->getCurrencySymbol($conf->currency); } + elseif ($type == 'select') + { + $value=$params['options'][$value]; + } else { $showsize=round($size); diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 01190bf4405..0af2b782912 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -25,14 +25,22 @@ var size = jQuery("#size"); var unique = jQuery("#unique"); var required = jQuery("#required"); - if (type == 'date') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); } - else if (type == 'datetime') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); } - else if (type == 'double') { size.val('24,8').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); } - else if (type == 'int') { size.val('10').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); } - else if (type == 'text') { size.val('2000').removeAttr('disabled'); unique.attr('disabled','disabled').removeAttr('checked'); } - else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); } - else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');} - else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');} + + + if (type == 'date') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } + else if (type == 'datetime') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } + else if (type == 'double') { size.val('24,8').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } + else if (type == 'int') { size.val('10').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } + else if (type == 'text') { size.val('2000').removeAttr('disabled'); unique.attr('disabled','disabled').removeAttr('checked'); jQuery("#value_choice").hide(); } + else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } + else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();} + else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();} + else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();} else size.val('').attr('disabled','disabled'); } init_typeoffields(''); @@ -56,6 +64,17 @@ trans("Type"); ?> selectarray('type',$type2label,GETPOST('type')); ?> + + + + trans("Value"); ?> + + + + + + +trans("DefaultValue"); ?>"> trans("Size"); ?> diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index 093265e217c..1c17efb697c 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -35,4 +35,7 @@ ALTER TABLE llx_user add COLUMN fk_user integer; -- margin on contracts alter table llx_contratdet add column fk_product_fournisseur_price integer after info_bits; -alter table llx_contratdet add column buy_price_ht double(24,8) DEFAULT 0 after fk_product_fournisseur_price; \ No newline at end of file +alter table llx_contratdet add column buy_price_ht double(24,8) DEFAULT 0 after fk_product_fournisseur_price; + +-- serialised array, to store value of select list choices for example +alter table llx_extrafields add column param text DEFAULT '' after pos; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 42924eb253f..090064ab0ec 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -356,6 +356,7 @@ Boolean=Boolean (Checkbox) ExtrafieldPhone = Phone ExtrafieldPrice = Price ExtrafieldMail = Email +ExtrafieldSelect = Select list LibraryToBuildPDF=Library used to build PDF WarningUsingFPDF=Warning: Your conf.php contains directive dolibarr_pdf_force_fpdf=1. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.
To solve this and have a full support of PDF generation, please download TCPDF library, then comment or remove the line $dolibarr_pdf_force_fpdf=1, and add instead $dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir' LocalTaxDesc=Some countries apply 2 or 3 taxes on each invoice line. If this is the case, choose type for second and third tax and its rate. Possible type are:
1 : local tax apply on products and services without vat (vat is not applied on local tax)
2 : local tax apply on products and services before vat (vat is calculated on amount + localtax)
3 : local tax apply on products without vat (vat is not applied on local tax)
4 : local tax apply on products before vat (vat is calculated on amount + localtax)
5 : local tax apply on services without vat (vat is not applied on local tax)
6 : local tax apply on services before vat (vat is calculated on amount + localtax) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 2c5f634fff6..a4c5251bb69 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -58,6 +58,7 @@ ErrorUploadBlockedByAddon=Upload blocked by a PHP/Apache plugin. ErrorFileSizeTooLarge=File size is too large. ErrorSizeTooLongForIntType=Size too long for int type (%s digits maximum) ErrorSizeTooLongForVarcharType=Size too long for string type (%s chars maximum) +ErrorNoValueForSelectType=Please fill value for select list ErrorFieldCanNotContainSpecialCharacters=Field %s must not contains special characters. ErrorNoAccountancyModuleLoaded=No accountancy module activated ErrorExportDuplicateProfil=This profil name already exists for this export set. diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 802bbb28191..ee773c9ba46 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -351,6 +351,7 @@ Boolean=Booleen (Checkbox) ExtrafieldPhone = Téléphone ExtrafieldPrice = Prix ExtrafieldMail = Email +ExtrafieldSelect = Liste de sélection LibraryToBuildPDF=Bibliothèque utilisée pour la génération des PDF WarningUsingFPDF=Attention: Votre fichier conf.php contient la directive dolibarr_pdf_force_fpdf=1. Cela signifie que vous utilisez la librairie FPDF pour générer vos fichiers PDF. Cette librairie est ancienne et ne couvre pas de nombreuses fonctionnalitée (Unicode, transparence des images, langues cyrillic, arabes ou asiatiques...), aussi vous pouvez rencontrez des problèmes durant la génération des PDF.
Pour résoudre cela et avoir un support complet de PDF, vous pouvez télécharger la librairie TCPDF puis commenter ou supprimer la ligne $dolibarr_pdf_force_fpdf=1, et ajouter à la place $dolibarr_lib_TCPDF_PATH='chemin_vers_TCPDF' LocalTaxDesc=Certains pays appliquent 2 voir 3 taux sur chaque ligne de facture. Si c'est le cas, choisissez le type du deuxième et troisième taux et sa valeur. Les types possibles sont:
1 : taxe locale sur les produits et services hors tva (la tva n'est pas appliquée sur la taxe locale)
2 : taxe locale sur les produits et services avant tva (la tva est appliquée sur le montant + la taxe locale)
3 : taxe locale uniquement sur les produits hors tva (la tva n'est pas appliquée sur la taxe locale)
4 : taxe locale uniquement sur les produits avant tva (la tva est appliquée sur le montant + la taxe locale)
5 : taxe locale uniquement sur les services hors tva (la tva n'est pas appliquée sur la taxe locale)
6 : taxe locale uniquement sur les service avant tva (la tva est appliquée sur le montant + la taxe locale) diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index 99112a0db96..3c7d1e275ed 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -59,6 +59,7 @@ ErrorUploadBlockedByAddon=Upload bloqué par un plugin PHP/Apache. ErrorFileSizeTooLarge=La taille du fichier est trop grande. ErrorSizeTooLongForIntType=Longueur de champ trop longue pour le type int (%s chiffres maximum) ErrorSizeTooLongForVarcharType=Longueur de champ trop longue pour le type chaine (%s caractères maximum) +ErrorNoValueForSelectType=Les valeurs de la liste doivent être renseignées ErrorFieldCanNotContainSpecialCharacters=Le champ %s ne peut contenir de caractères spéciaux. ErrorNoAccountancyModuleLoaded=Aucun module de comptabilité activé ErrorExportDuplicateProfil=Ce nom de profil existe déjà pour ce lot d'export. From f847558363296ddf41bfe5a16149545973a27f4e Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Fri, 15 Feb 2013 07:21:10 +0100 Subject: [PATCH 106/162] Update htdocs/product/class/product.class.php fetch_prod_arbo / recursive call of the child product test --- htdocs/product/class/product.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 8724671c20d..fc0c08e736f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2185,10 +2185,10 @@ class Product extends CommonObject $this->res[]= array($compl_path.$nom_pere,$desc_pere); } - // Recursive call - if (is_array($desc_pere)>2) + // Recursive call if child is an array + if (is_array($desc_pere[0])) { - $this ->fetch_prod_arbo($desc_pere, $nom_pere." -> ", $desc_pere[1]*$multiply, $level+1); + $this ->fetch_prod_arbo($desc_pere[0], $nom_pere." -> ", $desc_pere[1]*$multiply, $level+1); } } } From bbb18b317568b0ea21fb3b56cf572a07bc34147b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Feb 2013 10:42:35 +0100 Subject: [PATCH 107/162] Look: More CSS3 --- htdocs/comm/action/index.php | 19 +++++++++++++++---- htdocs/theme/eldy/style.css.php | 11 +++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index dc48f407c03..cbf8ef0840e 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -941,7 +941,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
'."\n"; $curtime = dol_mktime(0, 0, 0, $month, $day, $year); print ''; - print ''; - print ''; From b434f58af3458744e4357c03e9b0db4c553b34c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 17:12:06 +0100 Subject: [PATCH 129/162] Fix: When creating invoice from other object, type must be standard only --- htdocs/compta/facture.php | 51 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 0d46ca1efcd..5bc85030f99 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1919,32 +1919,35 @@ if ($action == 'create') $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); print $desc; print ''."\n"; + } - // Replacement - print ''."\n"; + // Replacement + print ''."\n"; - // Credit note + if (empty($origin)) + { + // Credit note print ''."\n"; + } - if ($socid > 0) - { - // Replacement - print ''."\n"; + if ($socid > 0) + { + // Replacement + print ''."\n"; + } - // Credit note - print ''."\n"; - } + if (empty($origin) && $socid > 0) + { + // Credit note + print ''."\n"; } print '
'; + print '
'; print ''; } print '
'; + print '
'; //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); @@ -1004,8 +1004,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Show rect of event print '
'; - print ''; - print ''; @@ -1256,29 +1226,6 @@ else print "\n"; } - // Module Webcalendar - // TODO external module - if (! empty($conf->webcalendar->enabled)) - { - $langs->load("other"); - print ''; - print ''; - print ''."\n"; - } - - // Module Phenix - // TODO external module - if (! empty($conf->phenix->enabled)) - { - $langs->load("other"); - print ''; - print ''; - print "\n"; - print ''; - print ''; - print ''."\n"; - } - // Company / Contact if (! empty($conf->societe->enabled)) { @@ -1575,8 +1522,6 @@ else if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->adherent->enabled)) $rowspan++; - if (! empty($conf->webcalendar->enabled)) $rowspan++; // TODO external module - if (! empty($conf->phenix->enabled)) $rowspan+=2; // TODO external module print ''; print ''; - // Module Webcalendar - // TODO external module - if (! empty($conf->webcalendar->enabled)) - { - $langs->load("other"); - print "".''; - print ''; - } - - // Module Phenix - // TODO external module - if (! empty($conf->phenix->enabled)) - { - $langs->load("other"); - print "".''; - print ''; - print "".''; - print ''; - } - // Company / Contact if (! empty($conf->societe->enabled)) { From b1ee14ce6012a108257c20055d4fdc8cf8132eae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Feb 2013 18:39:27 +0100 Subject: [PATCH 116/162] New: Can define a hierarchical responsible on users. --- ChangeLog | 1 + htdocs/core/class/html.form.class.php | 4 +- htdocs/langs/en_US/users.lang | 3 +- htdocs/langs/fr_FR/users.lang | 3 +- htdocs/user/class/user.class.php | 1 + htdocs/user/fiche.php | 101 ++++++++++++++++---------- 6 files changed, 69 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 294c09a6997..68452e0ca4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ For users: - New: Some performance enhancements. - New: Can attach files onto trip and expenses modules. - New: Add option MAIN_PDF_TITLE_BACKGROUND_COLOR +- New: Can define a hierarchical responsible on user For developers: - System of menu managers has been rewritten to reduce code to do same things. diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 28dee6f9383..dcf70443fd8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -994,7 +994,7 @@ class Form global $conf,$user,$langs; // If no preselected user defined, we take current user - if ($selected < -1 && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id; + if ((is_numeric($selected) && ($selected < -1 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id; // Permettre l'exclusion d'utilisateurs if (is_array($exclude)) $excludeUsers = implode("','",$exclude); @@ -1043,7 +1043,7 @@ class Form if ($num) { $out.= '
'; + print '
  • '; + print ''; + print '
    '; if ($event->type_code == 'BIRTHDAY') // It's a birthday { print $event->getNomUrl(1,$maxnbofchar,'cal_event','birthday','contact'); @@ -1130,6 +1131,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') print $event->getLibStatut(3,1); else print ' '; print '
    '; + print '
'; print ''; $i++; } @@ -1174,4 +1176,13 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print ''."\n"; } +function dol_color_minus($color, $minus) +{ + $newcolor=$color; + $newcolor[0]=((hexdec($newcolor[0])-$minus)<0)?0:dechex((hexdec($newcolor[0])-$minus)); + $newcolor[2]=((hexdec($newcolor[2])-$minus)<0)?0:dechex((hexdec($newcolor[2])-$minus)); + $newcolor[4]=((hexdec($newcolor[4])-$minus)<0)?0:dechex((hexdec($newcolor[4])-$minus)); + return $newcolor; +} + ?> diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 0225c9d6cb8..ce27fdc40f1 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2059,8 +2059,15 @@ td.hidden { .cal_current_month { background: #FFFFFF; border: solid 1px #C0C0C0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_today { background: #FFFFFF; border: solid 2px #6C7C7B; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_past { } -table.cal_event { border-collapse: collapse; margin-bottom: 1px; -webkit-border-radius: 6px; border-radius: 6px; } -table.cal_event td { border: 0px; padding-: 0px; padding-: 2px; padding-top: 0px; padding-bottom: 0px; } +table.cal_event { border: none; border-collapse: collapse; margin-bottom: 1px; -webkit-border-radius: 6px; border-radius: 6px; + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.25); + moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.25); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.25); + background: -webkit-gradient(linear, left top, left bottom, from(#006aac), to(#00438d)); + } +table.cal_event td { border: none; padding-: 2px; padding-: 2px; padding-top: 0px; padding-bottom: 0px; } +ul.cal_event { padding-right: 2px; padding-top: 1px; border: none; list-style-type: none; margin: 0 auto; -webkit-padding-start: 2px !important; } +li.cal_event { border: none; list-style-type: none; } .cal_event a:link { color: #111111; font-size: 11px; font-weight: normal !important; } .cal_event a:visited { color: #111111; font-size: 11px; font-weight: normal !important; } .cal_event a:active { color: #111111; font-size: 11px; font-weight: normal !important; } From 7b9fc49deaaa81b492bf8543f34c09d4a7ccd1f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Feb 2013 10:46:50 +0100 Subject: [PATCH 108/162] More CSS3 --- htdocs/theme/amarok/style.css.php | 5 ++++- htdocs/theme/eldy/style.css.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index 115a63d7e66..71a1c47b375 100755 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -1168,7 +1168,7 @@ div.error { .product_line_stock_ok { color: #002200; } .product_line_stock_too_low { color: #664400; } - + .fieldrequired { font-weight:bold; color:#333333; @@ -1469,6 +1469,9 @@ table.cal_event { margin-bottom:1px; } +ul.cal_event { padding-right: 2px; padding-top: 1px; border: none; list-style-type: none; margin: 0 auto; -webkit-padding-start: 2px !important; } +li.cal_event { border: none; list-style-type: none; } + .cal_event a:link { color:#232323; font-size:11px; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ce27fdc40f1..6e51e2d257e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2071,7 +2071,7 @@ li.cal_event { border: none; list-style-type: none; } .cal_event a:link { color: #111111; font-size: 11px; font-weight: normal !important; } .cal_event a:visited { color: #111111; font-size: 11px; font-weight: normal !important; } .cal_event a:active { color: #111111; font-size: 11px; font-weight: normal !important; } -.cal_event a:hover { color: #111111; font-size: 11px; font-weight: normal !important; } +.cal_event a:hover { color: #111111; font-size: 11px; font-weight: normal !important; color:rgba(255,255,255,.75); } /* ============================================================================== */ From 3d8197ce4be0d36ee7de7a5dc11fe9c7ac0db1cf Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 15 Feb 2013 11:19:49 +0100 Subject: [PATCH 109/162] Work on extrafields : position management & new type : select list --- htdocs/core/admin_extrafields.inc.php | 15 +++++-- htdocs/core/class/extrafields.class.php | 33 +++++++++++---- htdocs/core/tpl/admin_extrafields_add.tpl.php | 5 ++- .../core/tpl/admin_extrafields_edit.tpl.php | 42 ++++++++++++++++--- htdocs/societe/admin/societe_extrafields.php | 2 + 5 files changed, 79 insertions(+), 18 deletions(-) diff --git a/htdocs/core/admin_extrafields.inc.php b/htdocs/core/admin_extrafields.inc.php index 29c71f9ba45..975fa94d308 100644 --- a/htdocs/core/admin_extrafields.inc.php +++ b/htdocs/core/admin_extrafields.inc.php @@ -59,7 +59,7 @@ if ($action == 'add') $mesg=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint); $action = 'create'; } - if (GETPOST('type')=='select' && !GETPOST('extra_value')) + if (GETPOST('type')=='select' && !GETPOST('param')) { $error++; $langs->load("errors"); @@ -73,7 +73,7 @@ if ($action == 'add') if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname'])) { // Construct array for parameter (value of select list) - $parameters = GETPOST('extra_value'); + $parameters = GETPOST('param'); $parameters_array = explode("\r\n",$parameters); foreach($parameters_array as $param_ligne) { @@ -136,7 +136,16 @@ if ($action == 'update') { if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname'])) { - $result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0)); + $pos = GETPOST('pos','int'); + // Construct array for parameter (value of select list) + $parameters = GETPOST('param'); + $parameters_array = explode("\r\n",$parameters); + foreach($parameters_array as $param_ligne) + { + list($key,$value) = explode(',',$param_ligne); + $params['options'][$key] = $value; + } + $result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$pos,$params); if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 0fd57fed96d..4f583a667f9 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -207,7 +207,7 @@ class ExtraFields * @param string $elementtype Element type ('member', 'product', 'company', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not - * @param array $param Params for field (ex for select list : array('value'=>'label of option') ) + * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @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) @@ -343,9 +343,11 @@ class ExtraFields * @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not + * @param int $pos Position of attribute + * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @return int >0 if OK, <=0 if KO */ - function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0) + function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos,$param='') { $table=$elementtype.'_extrafields'; @@ -368,6 +370,9 @@ class ExtraFields }elseif($type=='mail') { $typedb='varchar'; $lengthdb='128'; + } elseif ($type=='select') { + $typedb='text'; + $lengthdb=''; } else { $typedb=$type; $lengthdb=$length; @@ -378,7 +383,7 @@ class ExtraFields { if ($label) { - $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required); + $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param); } if ($result > 0) { @@ -424,9 +429,11 @@ class ExtraFields * @param string $elementtype Element type ('member', 'product', 'company', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not + * @param int $pos Position of attribute + * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0) + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='') { global $conf; dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required); @@ -434,7 +441,12 @@ class ExtraFields if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { $this->db->begin(); - + + if(is_array($param) && count($param) > 0) + { + $param = serialize($param); + } + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; $sql_del.= " WHERE name = '".$attrname."'"; $sql_del.= " AND entity = ".$conf->entity; @@ -450,7 +462,9 @@ class ExtraFields $sql.= " size,"; $sql.= " elementtype,"; $sql.= " fieldunique,"; - $sql.= " fieldrequired"; + $sql.= " fieldrequired,"; + $sql.= " pos,"; + $sql.= " param"; $sql.= ") VALUES ("; $sql.= "'".$attrname."',"; $sql.= " ".$conf->entity.","; @@ -459,7 +473,9 @@ class ExtraFields $sql.= " '".$size."',"; $sql.= " '".$elementtype."',"; $sql.= " '".$unique."',"; - $sql.= " '".$required."'"; + $sql.= " '".$required."',"; + $sql.= " '".$pos."',"; + $sql.= " '".$param."'"; $sql.= ")"; dol_syslog(get_class($this)."::update_label sql=".$sql); $resql2=$this->db->query($sql); @@ -512,7 +528,7 @@ class ExtraFields if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity = ".$conf->entity; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; @@ -535,6 +551,7 @@ class ExtraFields $this->attribute_unique[$tab->name]=$tab->fieldunique; $this->attribute_required[$tab->name]=$tab->fieldrequired; $this->attribute_param[$tab->name]=unserialize($tab->param); + $this->attribute_pos[$tab->name]=$tab->pos; } } return $array_name_label; diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 0af2b782912..d4f5cf9ae40 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -55,7 +55,8 @@ - + + @@ -70,7 +71,7 @@ trans("Value"); ?> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 8eed3b96c37..c2112b636f2 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -47,21 +47,53 @@
trans("Position"); ?>
trans("Label"); ?>
- +
- - - - -attribute_type[$attrname]; $size=$extrafields->attribute_size[$attrname]; $unique=$extrafields->attribute_unique[$attrname]; $required=$extrafields->attribute_required[$attrname]; +$pos=$extrafields->attribute_pos[$attrname]; +$param=$extrafields->attribute_param[$attrname]; + +if($type == 'select' && is_array($param)) +{ + $param_chain = ''; + foreach ($param['options'] as $key => $value) + { + if(strlen($key)) + { + $param_chain .= $key.', '.$value."\n"; + } + } +} ?> + + + + + + + + + + + + + + diff --git a/htdocs/societe/admin/societe_extrafields.php b/htdocs/societe/admin/societe_extrafields.php index cbac832ee3b..66957c0314a 100755 --- a/htdocs/societe/admin/societe_extrafields.php +++ b/htdocs/societe/admin/societe_extrafields.php @@ -84,6 +84,7 @@ $extrafields->fetch_name_optionals_label($elementtype); print "
trans("Label"); ?>
trans("AttributeCode"); ?>
trans("Position"); ?>
trans("Label"); ?>
trans("AttributeCode"); ?>
trans("Type"); ?>
+ trans("Value"); ?> + + +
trans("Size"); ?>
"; print ''; +print ''; print ''; print ''; print ''; @@ -98,6 +99,7 @@ foreach($extrafields->attribute_type as $key => $value) { $var=!$var; print ""; + print "\n"; print "\n"; print "\n"; print "\n"; From cddd59d98dfbe2f51c702445cb06c096a385b093 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Fri, 15 Feb 2013 14:23:35 +0100 Subject: [PATCH 110/162] fix : doesnt work with a \/ --- htdocs/langs/fr_FR/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 802bbb28191..d5c0daa97b8 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -283,7 +283,7 @@ GenericMaskCodes3= Tout autre caractère dans le masque sera laissé inchangé.< GenericMaskCodes4a= Exemple sur la 99eme %s du tiers LaCompanie faite le 31/03/2007:
GenericMaskCodes4b= Exemple sur un tiers créé le 31/03/2007:
GenericMaskCodes4c= Exemple sur un produit/service créé le 31/03/2007:
-GenericMaskCodes5= ABC{yy}{mm}-{000000} donnera ABC0703-000099
{0000+100}-XXX/{dd}/YYY donnera 0199-XXX/31/YYY +GenericMaskCodes5= ABC{yy}{mm}-{000000} donnera ABC0703-000099
{0000+100}-XXX-{dd}-YYY donnera 0199-XXX-31-YYY GenericNumRefModelDesc= Renvoie un numéro personnalisable selon un masque à définir. ServerAvailableOnIPOrPort= Serveur disponible à l'adresse %s sur le port %s ServerNotAvailableOnIPOrPort= Serveur non disponible à l'adresse %s sur le port %s From 7c1a4e6fdf49d4516adbfc338a6eaf8948843374 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Fri, 15 Feb 2013 15:48:53 +0100 Subject: [PATCH 111/162] fix trad to get better understanding --- htdocs/core/class/commonobject.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5c9b8d93122..5d6d869ad81 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1023,7 +1023,7 @@ abstract class CommonObject /** * Save a new position (field rang) for details lines. - * You can choose to ser position for lines with already a position or lines wihtout any position defined. + * You can choose to set position for lines with already a position or lines without any position defined. * Call this function only for table that contains a field fk_parent_line. * * @param boolean $renum true to renum all already ordered lines, false to renum only not already ordered lines. @@ -1064,7 +1064,7 @@ abstract class CommonObject // counter that parents. $rows=array(); - // We frist search all lines that are parent lines (for multilevel details lines) + // We first search all lines that are parent lines (for multilevel details lines) $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; $sql.= ' AND fk_parent_line IS NULL'; @@ -1080,10 +1080,10 @@ abstract class CommonObject { $row = $this->db->fetch_row($resql); $rows[] = $row[0]; // Add parent line into array rows - $childrens = $this->getChildrensOfLine($row[0]); - if (! empty($childrens)) + $childrens = $this->getChildrenOfLine($row[0]); + if (! empty($children)) { - foreach($childrens as $child) + foreach($children as $child) { array_push($rows, $child); } @@ -1108,12 +1108,12 @@ abstract class CommonObject } /** - * Get childrens of line + * Get children of line * * @param int $id Id of parent line - * @return array Array with list of child lines id + * @return array Array with list of children lines id */ - function getChildrensOfLine($id) + function getChildrenOfLine($id) { $rows=array(); @@ -1122,7 +1122,7 @@ abstract class CommonObject $sql.= ' AND fk_parent_line = '.$id; $sql.= ' ORDER BY rang ASC'; - dol_syslog(get_class($this)."::getChildrenOfLines search children lines for line ".$id." sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id." sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { From 7260f39d2121a71a9d966411315660e68c3980e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Feb 2013 17:06:32 +0100 Subject: [PATCH 112/162] New: Support tag total_vat_x.y for vat rate x.y into ODT templates --- .../commande/doc/doc_generic_order_odt.modules.php | 11 ++++++++++- .../facture/doc/doc_generic_invoice_odt.modules.php | 11 ++++++++++- .../propale/doc/doc_generic_proposal_odt.modules.php | 11 ++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 0ad0ecc0e7e..fff62466958 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -97,7 +97,7 @@ class doc_generic_order_odt extends ModelePDFCommandes { global $conf; - return array( + $resarray=array( 'object_id'=>$object->id, 'object_ref'=>$object->ref, 'object_ref_ext'=>$object->ref_ext, @@ -120,6 +120,15 @@ class doc_generic_order_odt extends ModelePDFCommandes 'object_note_private'=>$object->note, 'object_note'=>$object->note_public, ); + + // Add vat by rates + foreach ($object->lines as $line) + { + if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0; + $resarray['object_total_vat_'.$line->tva_tx]+=$line->total_tva; + } + + return $resarray; } /** diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index dcf8436636d..37e2b7e32b6 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -105,7 +105,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $sumpayed = $object->getSommePaiement(); $alreadypayed=price($sumpayed,0,$outputlangs); - return array( + $resarray=array( 'object_id'=>$object->id, 'object_ref'=>$object->ref, 'object_ref_ext'=>$object->ref_ext, @@ -132,6 +132,15 @@ class doc_generic_invoice_odt extends ModelePDFFactures 'object_already_payed'=>$alreadypayed, 'object_remain_to_pay'=>price($object->total_ttc - $sumpayed,0,$outputlangs) ); + + // Add vat by rates + foreach ($object->lines as $line) + { + if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0; + $resarray['object_total_vat_'.$line->tva_tx]+=$line->total_tva; + } + + return $resarray; } /** diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index be0ac3f7d3f..d18c17735ae 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -97,7 +97,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales { global $conf; - return array( + $resarray=array( 'object_id'=>$object->id, 'object_ref'=>$object->ref, 'object_ref_ext'=>$object->ref_ext, @@ -119,6 +119,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales 'object_note_private'=>$object->note, 'object_note'=>$object->note_public, ); + + // Add vat by rates + foreach ($object->lines as $line) + { + if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0; + $resarray['object_total_vat_'.$line->tva_tx]+=$line->total_tva; + } + + return $resarray; } /** From e0bbb78f56de33605eafe6c600a2e4f9eeb72aa7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Feb 2013 17:28:07 +0100 Subject: [PATCH 113/162] Fix: Merge customer and prospect tab --- htdocs/comm/fiche.php | 49 +++++++++++++++++---------------- htdocs/core/lib/company.lib.php | 4 ++- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 397fb9da835..fcecbf0a552 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -386,29 +386,32 @@ if ($id > 0) } // Level of prospect - print '
"; - print ''; - - // Status - print ''; - print ''; + if ($object->client == 2 || $object->client == 3) + { + print '"; + print ''; + + // Status + print ''; + print ''; + } // Sales representative include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 4fb851ce4d3..afd9522801a 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -45,7 +45,9 @@ function societe_prepare_head($object) if ($object->client==1 || $object->client==2 || $object->client==3 || (isset($object->object) && $object->object->client==1) || (isset($object->object) && $object->object->client==3)) { $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Customer"); + if ($object->client==2 || $object->client==3) $head[$h][1] = $langs->trans("Prospect"); + if ($object->client==3) $head[$h][1] .= '/'; + if ($object->client==1 || $object->client==3) $head[$h][1] .= $langs->trans("Customer"); $head[$h][2] = 'customer'; $h++; } From 7c47dedbcee621211216c8ce3c3db316ec1ebfb6 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Fri, 15 Feb 2013 17:33:07 +0100 Subject: [PATCH 114/162] fix trad: begin change address instead of adresse --- htdocs/adherents/class/adherent.class.php | 10 +++++----- htdocs/adherents/fiche.php | 4 ++-- htdocs/adherents/liste.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/core/modules/modAdherent.class.php | 10 +++++----- htdocs/install/mysql/tables/llx_adherent.sql | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0eea1c6f5d7..8e9c75e2423 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -51,7 +51,7 @@ class Adherent extends CommonObject var $login; var $pass; var $societe; - var $adresse; + //var $adresse; var $address; var $cp; var $zip; @@ -429,7 +429,7 @@ class Adherent extends CommonObject $sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null"); $sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null"); $sql.= ", fk_soc=" .($this->fk_soc > 0?"'".$this->fk_soc."'":"null"); - $sql.= ", adresse=" .($this->address?"'".$this->db->escape($this->address)."'":"null"); + $sql.= ", address=" .($this->address?"'".$this->db->escape($this->address)."'":"null"); $sql.= ", cp=" .($this->zip?"'".$this->db->escape($this->zip)."'":"null"); $sql.= ", ville=" .($this->town?"'".$this->db->escape($this->town)."'":"null"); $sql.= ", pays=" .($this->country_id>0?"'".$this->country_id."'":"null"); @@ -1019,7 +1019,7 @@ class Adherent extends CommonObject { global $langs; - $sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as lastname, d.societe, d.fk_soc, d.statut, d.public, d.adresse as address, d.cp as zip, d.ville as town, d.note,"; + $sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as lastname, d.societe, d.fk_soc, d.statut, d.public, d.address, d.cp as zip, d.ville as town, d.note,"; $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql.= " d.datec as datec,"; @@ -1065,7 +1065,7 @@ class Adherent extends CommonObject $this->pass = $obj->pass; $this->societe = $obj->societe; $this->fk_soc = $obj->fk_soc; - $this->adresse = $obj->address; // deprecated + //$this->adresse = $obj->address; // deprecated $this->address = $obj->address; $this->cp = $obj->zip; // deprecated $this->zip = $obj->zip; @@ -1824,7 +1824,7 @@ class Adherent extends CommonObject 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->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste; - if ($this->adresse && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->adresse; + if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; if ($this->cp && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->cp; if ($this->ville && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->ville; if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index f84990b94e5..d1c8beb6426 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -259,7 +259,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) $object->pass = trim($_POST["pass"]); $object->societe = trim($_POST["societe"]); - $object->adresse = trim($_POST["address"]); // deprecated + //$object->adresse = trim($_POST["address"]); // deprecated $object->address = trim($_POST["address"]); $object->cp = trim($_POST["zipcode"]); // deprecated $object->zip = trim($_POST["zipcode"]); @@ -440,7 +440,7 @@ if ($action == 'add' && $user->rights->adherent->creer) $object->firstname = $prenom; $object->lastname = $nom; $object->societe = $societe; - $object->adresse = $address; // deprecated + //$object->adresse = $address; // deprecated $object->address = $address; $object->cp = $zip; // deprecated $object->zip = $zip; diff --git a/htdocs/adherents/liste.php b/htdocs/adherents/liste.php index 2363a3529d2..b19fcae8d85 100644 --- a/htdocs/adherents/liste.php +++ b/htdocs/adherents/liste.php @@ -104,7 +104,7 @@ if ($sall) $sql.=" AND ("; if (is_numeric($sall)) $sql.= "d.rowid = ".$sall." OR "; $sql.=" d.prenom LIKE '%".$sall."%' OR d.nom LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'"; - $sql.=" OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.adresse LIKE '%".$sall."%'"; + $sql.=" OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.address LIKE '%".$sall."%'"; $sql.=" OR d.ville LIKE '%".$sall."%' OR d.note LIKE '%".$sall."%')"; } if ($type > 0) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 369f925bc7e..eaddb4866c4 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -416,7 +416,7 @@ if ($rowid > 0) if ($sall) { $sql.= " AND (d.prenom LIKE '%".$sall."%' OR d.nom LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'"; - $sql.= " OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.adresse LIKE '%".$sall."%'"; + $sql.= " OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.address LIKE '%".$sall."%'"; $sql.= " OR d.ville LIKE '%".$sall."%' OR d.note LIKE '%".$sall."%')"; } if ($status != '') diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 281a672c60d..4dea8571657 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -172,9 +172,9 @@ class modAdherent extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='MembersAndSubscriptions'; $this->export_permission[$r]=array(array("adherent","export")); - $this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civilite'=>"UserTitle",'a.nom'=>"Lastname",'a.prenom'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.adresse'=>"Address",'a.cp'=>"Zip",'a.ville'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel','c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.cotisation'=>'Amount'); - $this->export_TypeFields_array[$r]=array('a.civilite'=>"Text",'a.nom'=>"Text",'a.prenom'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.adresse'=>"Text",'a.cp'=>"Text",'a.ville'=>"Text",'a.pays'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.naiss'=>"Date",'a.statut'=>"Status",'a.note'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:fk_adherent_type:libelle','ta.libelle'=>'Text','c.dateadh'=>'Date','c.cotisation'=>'Number'); - $this->export_entities_array[$r]=array('a.rowid'=>'member','a.civilite'=>"member",'a.nom'=>"member",'a.prenom'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.adresse'=>"member",'a.cp'=>"member",'a.ville'=>"member",'a.pays'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.naiss'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.cotisation'=>'subscription'); + $this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civilite'=>"UserTitle",'a.nom'=>"Lastname",'a.prenom'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.address'=>"Address",'a.cp'=>"Zip",'a.ville'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel','c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.cotisation'=>'Amount'); + $this->export_TypeFields_array[$r]=array('a.civilite'=>"Text",'a.nom'=>"Text",'a.prenom'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.cp'=>"Text",'a.ville'=>"Text",'a.pays'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.naiss'=>"Date",'a.statut'=>"Status",'a.note'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:fk_adherent_type:libelle','ta.libelle'=>'Text','c.dateadh'=>'Date','c.cotisation'=>'Number'); + $this->export_entities_array[$r]=array('a.rowid'=>'member','a.civilite'=>"member",'a.nom'=>"member",'a.prenom'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.address'=>"member",'a.cp'=>"member",'a.ville'=>"member",'a.pays'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.naiss'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.cotisation'=>'subscription'); // Add extra fields $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'member'"; $resql=$this->db->query($sql); @@ -207,7 +207,7 @@ class modAdherent 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('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('a.civilite'=>"UserTitle",'a.nom'=>"Lastname*",'a.prenom'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.adresse'=>"Address",'a.cp'=>"Zip",'a.ville'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription'); + $this->import_fields_array[$r]=array('a.civilite'=>"UserTitle",'a.nom'=>"Lastname*",'a.prenom'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.cp'=>"Zip",'a.ville'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription'); // Add extra fields $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'member'"; $resql=$this->db->query($sql); @@ -223,7 +223,7 @@ class modAdherent extends DolibarrModules // End add extra fields $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r]=array('a.civilite'=>'code@'.MAIN_DB_PREFIX.'c_civilite','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); - $this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.nom'=>'Smith','a.prenom'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.adresse'=>'21 jump street','a.cp'=>'55000','a.ville'=>'New York','a.pays'=>'1','a.email'=>'jsmith@example.com','a.naiss'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')); + $this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.nom'=>'Smith','a.prenom'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.cp'=>'55000','a.ville'=>'New York','a.pays'=>'1','a.email'=>'jsmith@example.com','a.naiss'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')); } diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index 3ab580b5de2..90727f92419 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -39,7 +39,7 @@ create table llx_adherent morphy varchar(3) NOT NULL, -- personne morale / personne physique societe varchar(50), fk_soc integer NULL, -- Link to third party linked to member - adresse text, + address text, cp varchar(30), ville varchar(50), fk_departement integer, From 145573ea79756c81b4195cfc5c74af039ab7667a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Feb 2013 17:37:30 +0100 Subject: [PATCH 115/162] Qual: Removed useless code for old modules. There is hook now to do same job. --- htdocs/user/fiche.php | 84 ------------------------------------------- 1 file changed, 84 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index cf0e0170c94..451be57c976 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -196,11 +196,6 @@ if ($action == 'add' && $canadduser) } } - // FIXME external module - $object->webcal_login = $_POST["webcal_login"]; - $object->phenix_login = $_POST["phenix_login"]; - $object->phenix_pass = $_POST["phenix_pass"]; - // If multicompany is off, admin users must all be on entity 0. if (! empty($conf->multicompany->enabled)) { @@ -342,11 +337,6 @@ if ($action == 'update' && ! $_POST["cancel"]) } } - // FIXME external module - $object->webcal_login = $_POST["webcal_login"]; - $object->phenix_login = $_POST["phenix_login"]; - $object->phenix_pass = $_POST["phenix_pass"]; - if (! empty($conf->multicompany->enabled)) { if (! empty($_POST["superadmin"])) @@ -936,23 +926,6 @@ if (($action == 'create') || ($action == 'adduserldap')) } } - // Module Webcalendar - // TODO external module - if (! empty($conf->webcalendar->enabled)) - { - print "".''; - print ''; - } - - // Module Phenix - // TODO external module - if (! empty($conf->phenix->enabled)) - { - print "".''; - print ''; - print "".''; - print ''; - } print "
'.$langs->trans("Position").''.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").'
".$extrafields->attribute_pos[$key]."".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."
'; - print ''; - print '
'; - print $langs->trans('ProspectLevelShort'); - print ''; - if ($action != 'editlevel' && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('Modify'),1).'
'; - print '
'; - if ($action == 'editlevel') - $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1); - else - print $object->getLibProspLevel(); - print "
'.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4).''; - if ($object->stcomm_id != -1) print ''.img_action(0,-1).''; - if ($object->stcomm_id != 0) print ''.img_action(0,0).''; - if ($object->stcomm_id != 1) print ''.img_action(0,1).''; - if ($object->stcomm_id != 2) print ''.img_action(0,2).''; - if ($object->stcomm_id != 3) print ''.img_action(0,3).''; - print '
'; + print ''; + print '
'; + print $langs->trans('ProspectLevel'); + print ''; + if ($action != 'editlevel' && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('Modify'),1).'
'; + print '
'; + if ($action == 'editlevel') + $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1); + else + print $object->getLibProspLevel(); + print "
'.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4).''; + if ($object->stcomm_id != -1) print ''.img_action(0,-1).''; + if ($object->stcomm_id != 0) print ''.img_action(0,0).''; + if ($object->stcomm_id != 1) print ''.img_action(0,1).''; + if ($object->stcomm_id != 2) print ''.img_action(0,2).''; + if ($object->stcomm_id != 3) print ''.img_action(0,3).''; + print '
'.$langs->trans("LoginWebcal").'
'.$langs->trans("LoginPenix").'
'.$langs->trans("PassPenix").'
\n"; print '

'; @@ -1089,9 +1062,6 @@ else if (isset($conf->authmode) && preg_match('/myopenid/',$conf->authmode)) $rowspan++; if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->adherent->enabled)) $rowspan++; - if (! empty($conf->webcalendar->enabled)) $rowspan++; // TODO external module - if (! empty($conf->phenix->enabled)) $rowspan+=2; // TODO external module - // Lastname print '
'.$langs->trans("Lastname").'
'.$langs->trans("LoginWebcal").''.$object->webcal_login.' 
'.$langs->trans("LoginPhenix").''.$object->phenix_login.' 
'.$langs->trans("PassPhenix").''.preg_replace('/./i','*',$object->phenix_pass_crypted).' 
'.$langs->trans("Ref").''; @@ -1867,35 +1812,6 @@ else print $object->getLibStatut(4); print '
'.$langs->trans("LoginWebcal").''; - if ($caneditfield) print ''; - else print $object->webcal_login; - print '
'.$langs->trans("LoginPhenix").''; - if ($caneditfield) print ''; - else print $object->phenix_login; - print '
'.$langs->trans("PassPhenix").''; - if ($caneditfield) print ''; - else print preg_replace('/./i','*',$object->phenix_pass_crypted); - print '
'; // Ref @@ -1058,7 +1061,6 @@ else print ''; print ''."\n"; - $rowspan=15; if (isset($conf->authmode) && preg_match('/myopenid/',$conf->authmode)) $rowspan++; if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->adherent->enabled)) $rowspan++; @@ -1146,22 +1148,6 @@ else } print ''."\n"; - // Multicompany - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print '\n"; - } - // Type print ''."\n"; - // ldap sid + // Ldap sid if ($object->ldap_sid) { print '\n"; - + + // Hierarchy + print ''; + print ''; + print "\n"; + // Statut print ''; print ''; print "\n"; } - + // Company / Contact if (! empty($conf->societe->enabled)) { @@ -1274,6 +1272,22 @@ else print ''."\n"; } + // Multicompany + if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print '\n"; + } + // Other attributes $parameters=array('colspan' => ' colspan="2"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1512,14 +1526,14 @@ else if ($action == 'edit' && ($canedituser || ($user->id == $object->id))) { - print ''; + $rowspan=14; + + print ''; print ''; print ''; print ''; print '
'.$langs->trans("Entity").''; - if ($object->admin && ! $object->entity) - { - print $langs->trans("AllEntities"); - } - else - { - $mc->getInfo($object->entity); - print $mc->label; - } - print "
'.$langs->trans("Type").''; $type=$langs->trans("Internal"); @@ -1170,7 +1156,7 @@ else if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; print '
'.$langs->trans("Type").''; @@ -1202,7 +1188,19 @@ else print '
'.$langs->trans('Signature').''; print dol_textishtml($object->signature)?$object->signature:dol_nl2br($object->signature,1,false); print "
'.$langs->trans("HierarchicalResponsible").''; + if (empty($object->fk_user)) print $langs->trans("None"); + else { + $huser=new User($db); + $huser->fetch($object->fk_user); + print $huser->getNomUrl(1); + } + print '
'.$langs->trans("Status").''; @@ -1225,7 +1223,7 @@ else print ''.$object->openid.'
'.$langs->trans("Entity").''; + if ($object->admin && ! $object->entity) + { + print $langs->trans("AllEntities"); + } + else + { + $mc->getInfo($object->entity); + print $mc->label; + } + print "
'; - $rowspan=13; - if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->adherent->enabled)) $rowspan++; @@ -1693,21 +1707,6 @@ else print ''; } - // Multicompany - if (! empty($conf->multicompany->enabled)) - { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print "".''; - print "\n"; - } - else - { - print ''; - } - } - // Type print ''; print ''; - + // openid if (isset($conf->authmode) && preg_match('/myopenid/',$conf->authmode)) { @@ -1806,12 +1805,34 @@ else print ''; } + // Hierarchy + print ''; + print ''; + print "\n"; + // Statut print ''; print ''; - + + // Multicompany + if (! empty($conf->multicompany->enabled)) + { + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print "".''; + print "\n"; + } + else + { + print ''; + } + } + // Company / Contact if (! empty($conf->societe->enabled)) { From 12317d03711a65d7ae32ff94a1a4f9fba70a1aa6 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Fri, 15 Feb 2013 19:18:26 +0100 Subject: [PATCH 117/162] fix trad : change adresse versus address --- htdocs/commande/class/commande.class.php | 8 ++++---- htdocs/install/mysql/tables/llx_commande.sql | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 335757c59d6..15a42841002 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -66,7 +66,7 @@ class Commande extends CommonOrder var $demand_reason_id; var $demand_reason_code; var $fk_delivery_address; - var $adresse; + var $address; var $date; // Date commande var $date_commande; // Date commande (deprecated) var $date_livraison; // Date livraison souhaitee @@ -631,7 +631,7 @@ class Commande extends CommonOrder $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande ("; $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, note_public, ref_client, ref_int"; - $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, fk_input_reason, date_livraison, fk_adresse_livraison"; + $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, fk_input_reason, date_livraison, fk_delivery_address"; $sql.= ", remise_absolue, remise_percent"; $sql.= ", entity"; $sql.= ")"; @@ -1240,7 +1240,7 @@ class Commande extends CommonOrder $sql.= ', c.date_commande'; $sql.= ', c.date_livraison'; $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; - $sql.= ', c.note as note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison, c.extraparams'; + $sql.= ', c.note as note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', ca.code as availability_code'; @@ -1301,7 +1301,7 @@ class Commande extends CommonOrder $this->demand_reason_id = $obj->fk_input_reason; $this->demand_reason_code = $obj->demand_reason_code; $this->date_livraison = $this->db->jdate($obj->date_livraison); - $this->fk_delivery_address = $obj->fk_adresse_livraison; + $this->fk_delivery_address = $obj->fk_delivery_address; $this->extraparams = (array) json_decode($obj->extraparams, true); diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index bc5312b1fe2..0ef0eddb739 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -63,7 +63,7 @@ create table llx_commande date_livraison date default NULL, fk_availability integer NULL, fk_input_reason integer, - fk_adresse_livraison integer, -- delivery address (deprecated) + fk_delivery_address integer, -- delivery address (deprecated) import_key varchar(14), extraparams varchar(255) -- for stock other parameters with json format From 2bfd6c40d0e7bba5f05f06a96580360057749b30 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Fri, 15 Feb 2013 19:26:09 +0100 Subject: [PATCH 118/162] fix trad : change adresse versus address --- htdocs/compta/dons/class/don.class.php | 20 +++++++++---------- htdocs/compta/dons/fiche.php | 10 +++++----- .../modules/dons/html_cerfafr.modules.php | 2 +- htdocs/install/mysql/tables/llx_don.sql | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index e4ee40df7c3..4942c8f3f7e 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -42,7 +42,7 @@ class Don extends CommonObject var $prenom; var $nom; var $societe; - var $adresse; + var $address; var $cp; var $ville; var $pays; @@ -188,7 +188,7 @@ class Don extends CommonObject $this->amount = 100; $this->public = 1; $this->societe = 'The Company'; - $this->adresse = 'Twist road'; + $this->address = 'Twist road'; $this->cp = '99999'; $this->ville = 'Town'; $this->note_public='SPECIMEN'; @@ -217,7 +217,7 @@ class Don extends CommonObject } } - if (dol_strlen(trim($this->adresse)) == 0) + if (dol_strlen(trim($this->address)) == 0) { $error_string[$err] = "L'adresse saisie est invalide"; $err++; @@ -297,7 +297,7 @@ class Don extends CommonObject global $conf; // Clean parameters - $this->address=($this->address>0?$this->address:$this->adresse); + $this->address=($this->address>0?$this->address:$this->address); $this->zip=($this->zip>0?$this->zip:$this->cp); $this->town=($this->town>0?$this->town:$this->ville); $this->country_id=($this->country_id>0?$this->country_id:$this->fk_pays); @@ -313,7 +313,7 @@ class Don extends CommonObject $sql.= ", prenom"; $sql.= ", nom"; $sql.= ", societe"; - $sql.= ", adresse"; + $sql.= ", address"; $sql.= ", cp"; $sql.= ", ville"; $sql.= ", pays"; @@ -334,7 +334,7 @@ class Don extends CommonObject $sql.= ", '".$this->db->escape($this->prenom)."'"; $sql.= ", '".$this->db->escape($this->nom)."'"; $sql.= ", '".$this->db->escape($this->societe)."'"; - $sql.= ", '".$this->db->escape($this->adresse)."'"; + $sql.= ", '".$this->db->escape($this->address)."'"; $sql.= ", '".$this->db->escape($this->zip)."'"; $sql.= ", '".$this->db->escape($this->town)."'"; $sql.= ", '".$this->db->escape($this->country)."'"; // TODO use country_id @@ -382,7 +382,7 @@ class Don extends CommonObject function update($user) { // Clean parameters - $this->address=($this->address>0?$this->address:$this->adresse); + $this->address=($this->address>0?$this->address:$this->address); $this->zip=($this->zip>0?$this->zip:$this->cp); $this->town=($this->town>0?$this->town:$this->ville); $this->country_id=($this->country_id>0?$this->country_id:$this->fk_pays); @@ -394,7 +394,7 @@ class Don extends CommonObject $sql .= ",prenom = '".$this->db->escape($this->prenom)."'"; $sql .= ",nom='".$this->db->escape($this->nom)."'"; $sql .= ",societe='".$this->db->escape($this->societe)."'"; - $sql .= ",adresse='".$this->db->escape($this->address)."'"; + $sql .= ",address='".$this->db->escape($this->address)."'"; $sql .= ",cp='".$this->db->escape($this->zip)."'"; $sql .= ",ville='".$this->db->escape($this->town)."'"; $sql .= ",pays='".$this->db->escape($this->country)."'"; // TODO use country_id @@ -463,7 +463,7 @@ class Don extends CommonObject global $conf; $sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,"; - $sql.= " d.prenom, d.nom, d.societe, d.amount, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.phone, d.phone_mobile, d.fk_don_projet,"; + $sql.= " d.prenom, d.nom, d.societe, d.amount, d.fk_statut, d.address, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.phone, d.phone_mobile, d.fk_don_projet,"; $sql.= " p.title as project_label"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_don_projet"; @@ -487,7 +487,7 @@ class Don extends CommonObject $this->nom = $obj->nom; $this->societe = $obj->societe; $this->statut = $obj->fk_statut; - $this->adresse = $obj->adresse; + $this->address = $obj->address; $this->cp = $obj->cp; $this->ville = $obj->ville; $this->zip = $obj->cp; diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php index 6ba13a19631..5ea563fbf14 100644 --- a/htdocs/compta/dons/fiche.php +++ b/htdocs/compta/dons/fiche.php @@ -88,7 +88,7 @@ if ($action == 'update') $don->prenom = $_POST["prenom"]; $don->nom = $_POST["nom"]; $don->societe = $_POST["societe"]; - $don->adresse = $_POST["adresse"]; + $don->address = $_POST["address"]; $don->amount = price2num($_POST["amount"]); $don->cp = $_POST["zipcode"]; $don->ville = $_POST["town"]; @@ -140,7 +140,7 @@ if ($action == 'add') $don->prenom = $_POST["prenom"]; $don->nom = $_POST["nom"]; $don->societe = $_POST["societe"]; - $don->adresse = $_POST["adresse"]; + $don->address = $_POST["address"]; $don->amount = price2num($_POST["amount"]); $don->cp = $_POST["zipcode"]; $don->ville = $_POST["town"]; @@ -300,7 +300,7 @@ if ($action == 'create') print "".''; print "".''; print "".''; + print ''; // Zip / Town print '".''; print "".''; print "".''; + print ''; // Zip / Town print '".''; print "".''; print "".''; - print "".''; + print "".''; // Zip / Town print "".''; diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 47aa150dc4d..cf71f536593 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -144,7 +144,7 @@ class html_cerfafr extends ModeleDon $form = str_replace('__MAIN_INFO_SOCIETE_CP__',$mysoc->zip,$form); $form = str_replace('__MAIN_INFO_SOCIETE_VILLE__',$mysoc->town,$form); $form = str_replace('__DONATOR_NAME__',$don->nom,$form); - $form = str_replace('__DONATOR_ADDRESS__',$don->adresse,$form); + $form = str_replace('__DONATOR_ADDRESS__',$don->address,$form); $form = str_replace('__DONATOR_ZIP__',$don->cp,$form); $form = str_replace('__DONATOR_TOWN__',$don->ville,$form); $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form); diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index 60f977e886d..d23d112ee1b 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -33,7 +33,7 @@ create table llx_don prenom varchar(50), nom varchar(50), societe varchar(50), - adresse text, + address text, cp varchar(30), ville varchar(50), pays varchar(50), From 785e72d5339077aeb43bb36629dd9fe26bdf6fea Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Fri, 15 Feb 2013 19:36:09 +0100 Subject: [PATCH 119/162] fix trad : change adresse versus address --- htdocs/comm/propal/class/propal.class.php | 10 +++++----- htdocs/install/mysql/tables/llx_propal.sql | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 90ba3f93690..230e696bf10 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -90,7 +90,7 @@ class Propal extends CommonObject var $fk_delivery_address; // deprecated (for compatibility) var $fk_address; var $address_type; - var $adresse; + var $address; var $availability_id; var $availability_code; var $demand_reason_id; @@ -789,7 +789,7 @@ class Propal extends CommonObject if (! $error && $this->fk_delivery_address) { $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_adresse_livraison = ".$this->fk_delivery_address; + $sql.= " SET fk_delivery_address = ".$this->fk_delivery_address; $sql.= " WHERE ref = '".$this->ref."'"; $sql.= " AND entity = ".$conf->entity; @@ -985,7 +985,7 @@ class Propal extends CommonObject $sql.= ", p.note as note_private, p.note_public"; $sql.= ", p.fk_projet, p.fk_statut"; $sql.= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture"; - $sql.= ", p.fk_adresse_livraison"; + $sql.= ", p.fk_delivery_address"; $sql.= ", p.fk_availability"; $sql.= ", p.fk_input_reason"; $sql.= ", p.fk_cond_reglement"; @@ -1049,8 +1049,8 @@ class Propal extends CommonObject $this->demand_reason_id = $obj->fk_input_reason; $this->demand_reason_code = $obj->demand_reason_code; $this->demand_reason = $obj->demand_reason; - $this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete - $this->fk_address = $obj->fk_adresse_livraison; + //$this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete + $this->fk_address = $obj->fk_delivery_address; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 9c4a440c23b..2964e768e47 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -65,6 +65,6 @@ create table llx_propal fk_input_reason integer, import_key varchar(14), extraparams varchar(255), -- for stock other parameters with json format - fk_adresse_livraison integer -- delivery address (deprecated) + fk_delivery_address integer -- delivery address (deprecated) )ENGINE=innodb; From ab2b06117bc390d3215011ba406e5cd46ebba2f9 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Fri, 15 Feb 2013 19:56:51 +0100 Subject: [PATCH 120/162] fix trad : change adresse versus address --- htdocs/contact/class/contact.class.php | 2 +- htdocs/core/class/CMailFile.class.php | 6 +++--- htdocs/core/class/commonobject.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 14c8630e1e5..411de5d5fcd 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -520,7 +520,7 @@ class Contact extends CommonObject $this->prenom = $obj->firstname; // TODO deprecated $this->address = $obj->address; - $this->adresse = $obj->address; // TODO deprecated + //$this->adresse = $obj->address; // TODO deprecated $this->cp = $obj->zip; // TODO deprecated $this->zip = $obj->zip; $this->ville = $obj->town; // TODO deprecated diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 9165b082679..a9337c87b8b 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1020,7 +1020,7 @@ class CMailFile /** * Return an address for SMTP protocol * - * @param string $adresses Example: 'John Doe ' or 'john@doe.com' + * @param string $address Example: 'John Doe ' or 'john@doe.com' * @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between " * @param int $encode 1=Encode name to RFC2822 * @return string If format 0: '' or 'John Doe ' or '=?UTF-8?B?Sm9obiBEb2U=?= ' @@ -1028,13 +1028,13 @@ class CMailFile * If format 2: 'john@doe.com' * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' */ - function getValidAddress($adresses,$format,$encode='') + function getValidAddress($address,$format,$encode='') { global $conf; $ret=''; - $arrayaddress=explode(',',$adresses); + $arrayaddress=explode(',',$address); // Boucle sur chaque composant de l'adresse foreach($arrayaddress as $val) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5d6d869ad81..8184e186999 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -964,7 +964,7 @@ abstract class CommonObject */ function setDeliveryAddress($id) { - $fieldname = 'fk_adresse_livraison'; + $fieldname = 'fk_delivery_address'; if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 7c9a5917727..1f890d2da3d 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -675,7 +675,7 @@ class Expedition extends CommonObject if (isset($this->socid)) $this->socid=trim($this->socid); if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid); - if (isset($this->fk_adresse_livraison)) $this->fk_adresse_livraison=trim($this->fk_adresse_livraison); + if (isset($this->fk_delivery_address)) $this->fk_delivery_address=trim($this->fk_delivery_address); if (isset($this->expedition_method_id)) $this->expedition_method_id=trim($this->expedition_method_id); if (isset($this->tracking_number)) $this->tracking_number=trim($this->tracking_number); if (isset($this->statut)) $this->statut=trim($this->statut); @@ -706,7 +706,7 @@ class Expedition extends CommonObject $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").","; $sql.= " date_expedition=".(dol_strlen($this->date_expedition)!=0 ? "'".$this->db->idate($this->date_expedition)."'" : 'null').","; $sql.= " date_delivery=".(dol_strlen($this->date_delivery)!=0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; - $sql.= " fk_address=".(isset($this->fk_adresse_livraison)?$this->fk_adresse_livraison:"null").","; + $sql.= " fk_address=".(isset($this->fk_delivery_address)?$this->fk_delivery_address:"null").","; $sql.= " fk_expedition_methode=".((isset($this->expedition_method_id) && $this->expedition_method_id > 0)?$this->expedition_method_id:"null").","; $sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").","; $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; From fa53147d0a529875b9963d465172ad382c94abba Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Feb 2013 03:41:11 +0100 Subject: [PATCH 121/162] Retrieve extrafields when fetch thirparty Work on extrafields support in thirpdparty ODT document --- htdocs/core/class/commondocgenerator.class.php | 13 ++++++++++++- htdocs/societe/class/societe.class.php | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 8c8d79f7422..ec9ae1d2870 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -134,7 +134,7 @@ abstract class CommonDocGenerator $object->state=getState($object->state_code,0); } - return array( + $array_thirdparty = array( 'company_name'=>$object->name, 'company_email'=>$object->email, 'company_phone'=>$object->phone, @@ -163,6 +163,17 @@ abstract class CommonDocGenerator 'company_idprof6'=>$object->idprof6, 'company_note'=>$object->note ); + + $extrafields = array(); + if(is_array($object->array_options) && count($object->array_options)) + { + foreach($object->array_options as $key=>$label) + { + $extrafields['company_options_'.$key] = $label; + } + $array_thirdparty = array_merge($array_thirdparty,$extrafields); + } + return $array_thirdparty; } /** diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0f5e7051010..28b38702fb9 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -139,6 +139,8 @@ class Societe extends CommonObject var $logo; var $logo_small; var $logo_mini; + + var $array_options; var $oldcopy; @@ -852,6 +854,18 @@ class Societe extends CommonObject $this->import_key = $obj->import_key; $result = 1; + + // Retreive all extrafield for thirdparty + // fetch optionals attributes and labels + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label('company',true); + if (count($extralabels)>0) { + $this->array_options = array(); + } + foreach($extrafields->attribute_label as $key=>$label) + { + $this->array_options[$key]=$label; + } } else { From 4f5b636cc74cee609eccd7b3d7452ffc9355934b Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Feb 2013 13:58:21 +0100 Subject: [PATCH 122/162] Fix : missing class file --- htdocs/societe/class/societe.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 28b38702fb9..dfeec3eaab7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -857,6 +857,7 @@ class Societe extends CommonObject // Retreive all extrafield for thirdparty // fetch optionals attributes and labels + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $extrafields=new ExtraFields($this->db); $extralabels=$extrafields->fetch_name_optionals_label('company',true); if (count($extralabels)>0) { From 50decdd941cb1e81788dd4c91b713f49492360fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Feb 2013 21:06:15 +0100 Subject: [PATCH 123/162] Fix: When creating user on other entity, no way to read user after creation. --- htdocs/core/class/html.form.class.php | 26 +++++------ htdocs/user/class/user.class.php | 6 +-- htdocs/user/fiche.php | 65 +++++++++++++++------------ 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index dcf70443fd8..2d46eec81dc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -689,7 +689,7 @@ class Form { //$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); $out.= ajax_combobox($htmlname, $event, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); - /* + /* if ($selected && empty($selected_input_value)) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -876,7 +876,7 @@ class Form if ($resql) { $num=$this->db->num_rows($resql); - + if ($conf->use_javascript_ajax && $conf->global->CONTACT_USE_SEARCH_TO_SELECT && ! $forcecombo) { $out.= ajax_combobox($htmlname, $event); @@ -968,10 +968,10 @@ class Form * @param int $disabled If select list must be disabled * @param array $include Array list of users id to include * @param int $enableonly Array list of users id to be enabled. All other must be disabled - * @param int $force_entity Possibility to force entity + * @param int $force_entity 0 or Id of environment to force * @return void */ - function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=false) + function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0) { print $this->select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly,$force_entity); } @@ -986,10 +986,10 @@ class Form * @param int $disabled If select list must be disabled * @param array $include Array list of users id to include * @param int $enableonly Array list of users id to be enabled. All other must be disabled - * @param int $force_entity Possibility to force entity + * @param int $force_entity 0 or Id of environment to force * @return string HTML select string */ - function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=false) + function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0) { global $conf,$user,$langs; @@ -3946,17 +3946,17 @@ class Form /** * Return select list of groups * - * @param string $selected Id group preselected - * @param string $htmlname Field name in form - * @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * @param string $exclude Array list of groups id to exclude + * @param string $selected Id group preselected + * @param string $htmlname Field name in form + * @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue + * @param string $exclude Array list of groups id to exclude * @param int $disabled If select list must be disabled - * @param string $include Array list of groups id to include + * @param string $include Array list of groups id to include * @param int $enableonly Array list of groups id to be enabled. All other must be disabled - * @param int $force_entity Possibility to force entity + * @param int $force_entity 0 or Id of environment to force * @return void */ - function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity='') + function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0) { global $conf,$user,$langs; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6b144c79a08..59641c1bbc1 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -154,13 +154,13 @@ class User extends CommonObject $sql.= " u.ref_int, u.ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + if ((empty($conf->multicompany->enabled) || empty($conf->multicompany->transverse_mode)) && (! empty($user->entity))) { - $sql.= " WHERE u.entity IS NOT NULL"; + $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; } else { - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + $sql.= " WHERE u.entity IS NOT NULL"; } if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 7988b68dfd2..4da27c64a55 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -819,21 +819,6 @@ if (($action == 'create') || ($action == 'adduserldap')) print "\n"; } - //Multicompany - if (! empty($conf->multicompany->enabled)) - { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print "".''; - print "\n"; - } - else - { - print ''; - } - } - // Type print ''; print ''; + // Multicompany + if (! empty($conf->multicompany->enabled)) + { + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print "".''; + print "\n"; + } + else + { + print ''; + } + } + + // Hierarchy + print ''; + print ''; + print "\n"; + // Note print ''; From d2074d1a176c3ca57ce9480e89a1bb482c9a7c4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 17:06:55 +0100 Subject: [PATCH 128/162] Fix: When creating invoice from other object, type must be standard only --- htdocs/compta/facture.php | 109 ++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 86f03b2d040..0d46ca1efcd 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1899,14 +1899,6 @@ if ($action == 'create') print $desc; print ''."\n"; - // Deposit - print ''."\n"; - // Proforma if (! empty($conf->global->FACTURE_USE_PROFORMAT)) { @@ -1918,54 +1910,65 @@ if ($action == 'create') print ''."\n"; } - // Replacement - print ''."\n"; + // Deposit + print ''."\n"; - // Credit note - print ''."\n"; + + // Credit note + print ''."\n"; } - else - { - $text.=''; - } - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); - print $desc; - print ''."\n"; print '
'.$langs->trans("Entity").'".$mc->select_entities($object->entity); - print "
'.$langs->trans("Type").''; @@ -1788,7 +1787,7 @@ else print ''; print ''; print '
'.$langs->trans("HierarchicalResponsible").''; + print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id)); + print '
'.$langs->trans("Status").''; print $object->getLibStatut(4); print '
'.$langs->trans("Entity").'".$mc->select_entities($object->entity); + print "
'.$langs->trans("Firstname").'
'.$langs->trans("Lastname").'
'.$langs->trans("Address").''; - print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; @@ -390,7 +390,7 @@ if (! empty($id) && $action == 'edit') print "
'.$langs->trans("Firstname").'
'.$langs->trans("Lastname").'
'.$langs->trans("Address").''; - print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; @@ -485,7 +485,7 @@ if (! empty($id) && $action != 'edit') print "
'.$langs->trans("Company").''.$don->societe.'
'.$langs->trans("Firstname").''.$don->prenom.'
'.$langs->trans("Lastname").''.$don->nom.'
'.$langs->trans("Address").''.dol_nl2br($don->adresse).'
'.$langs->trans("Address").''.dol_nl2br($don->address).'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$don->cp.($don->cp && $don->ville?' / ':'').$don->ville.'
'.$langs->trans("Entity").'".$mc->select_entities($conf->entity); - print "
'.$langs->trans("Type").''; @@ -902,6 +887,28 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; print '
'.$langs->trans("Entity").'".$mc->select_entities($conf->entity); + print "
'.$langs->trans("HierarchicalResponsible").''; + print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$conf->entity); + print '
'; print $langs->trans("Note"); @@ -941,7 +948,7 @@ else /* */ /* ************************************************************************** */ - if ($id) + if ($id > 0) { $object->fetch($id); if ($res < 0) { dol_print_error($db,$object->error); exit; } @@ -1051,7 +1058,7 @@ else if ($action != 'edit') { $rowspan=16; - + print ''; // Ref @@ -1188,7 +1195,7 @@ else print '\n"; - + // Hierarchy print ''; print ''; print "\n"; - - // Statut + + // Status print ''; print ''; print "\n"; } - + // Company / Contact if (! empty($conf->societe->enabled)) { @@ -1287,7 +1294,7 @@ else } print "\n"; } - + // Other attributes $parameters=array('colspan' => ' colspan="2"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1315,7 +1322,7 @@ else print '
'; - if ($caneditfield && ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { @@ -1327,7 +1334,7 @@ else } } elseif ($caneditpassword && ! $object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("EditPassword").''; } @@ -1787,7 +1794,7 @@ else print '
'; - + // openid if (isset($conf->authmode) && preg_match('/myopenid/',$conf->authmode)) { @@ -1808,16 +1815,16 @@ else // Hierarchy print ''; print ''; print "\n"; - // Statut + // Status print ''; print ''; - + // Multicompany if (! empty($conf->multicompany->enabled)) { @@ -1832,7 +1839,7 @@ else print ''; } } - + // Company / Contact if (! empty($conf->societe->enabled)) { From aff919fd10f5cb411139ae044344db6741c1da38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 12:45:46 +0100 Subject: [PATCH 124/162] Fix: Bad test --- htdocs/product/class/product.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a9c0439b220..49f1d495cde 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2187,10 +2187,10 @@ class Product extends CommonObject $this->res[]= array($compl_path.$nom_pere,$desc_pere); } - // Recursive call - if (is_array($desc_pere)) + // Recursive call if child is an array + if (is_array($desc_pere[0])) { - $this ->fetch_prod_arbo($desc_pere, $nom_pere." -> ", $desc_pere[1]*$multiply, $level+1); + $this ->fetch_prod_arbo($desc_pere[0], $nom_pere." -> ", $desc_pere[1]*$multiply, $level+1); } } } From aa8413d7cb907a0e547ecfb85cfa52e0d840b42b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 16:20:49 +0100 Subject: [PATCH 125/162] Fix: Missing migration Fix: Error management --- htdocs/comm/propal.php | 4 ++-- htdocs/install/mysql/migration/3.3.0-3.4.0.sql | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index cc34443a622..90c37aaaa6f 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -79,12 +79,12 @@ $result = restrictedArea($user, 'propal', $id); $object = new Propal($db); -// Load object // Load object if ($id > 0 || ! empty($ref)) { $ret=$object->fetch($id, $ref); - $ret=$object->fetch_thirdparty(); + if ($ret > 0) $ret=$object->fetch_thirdparty(); + if ($ret < 0) dol_print_error('',$object->error); } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index 1c17efb697c..a58eb45f1ba 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -39,3 +39,9 @@ alter table llx_contratdet add column buy_price_ht double(24,8) DEFAULT 0 after -- serialised array, to store value of select list choices for example alter table llx_extrafields add column param text DEFAULT '' after pos; + + +alter table llx_propal CHANGE COLUMN fk_adresse_livraison fk_delivery_address integer; +alter table llx_commande CHANGE COLUMN fk_adresse_livraison fk_delivery_address integer; +alter table llx_don CHANGE COLUMN adresse address text; + From 9f8ffe242aa1b0fbc5feb549f2331e261f70dce6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 16:26:06 +0100 Subject: [PATCH 126/162] Fix: A text field can not have a default value --- htdocs/install/mysql/migration/3.3.0-3.4.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index a58eb45f1ba..f7fe723b9b6 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -38,7 +38,7 @@ alter table llx_contratdet add column fk_product_fournisseur_price integer after alter table llx_contratdet add column buy_price_ht double(24,8) DEFAULT 0 after fk_product_fournisseur_price; -- serialised array, to store value of select list choices for example -alter table llx_extrafields add column param text DEFAULT '' after pos; +alter table llx_extrafields add column param text after pos; alter table llx_propal CHANGE COLUMN fk_adresse_livraison fk_delivery_address integer; From e56e182fe90c52abf513c3fc0ba84bf3cffaf485 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 16:37:28 +0100 Subject: [PATCH 127/162] Fix: When creating invoice from other object, type must be "standard". --- htdocs/compta/facture.php | 111 +++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 54 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index bccac8d8354..7c42593f70b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1915,14 +1915,6 @@ if ($action == 'create') print $desc; print ''."\n"; - // Deposit - print ''."\n"; - // Proforma if (! empty($conf->global->FACTURE_USE_PROFORMAT)) { @@ -1934,56 +1926,67 @@ if ($action == 'create') print ''."\n"; } - if ($socid>0) - { - // Replacement - print ''."\n"; - // Credit note - print ''."\n"; + if ($socid > 0) + { + // Replacement + print ''."\n"; + + // Credit note + print ''."\n"; + } } print '
'.$langs->trans('Signature').''; print dol_textishtml($object->signature)?$object->signature:dol_nl2br($object->signature,1,false); print "
'.$langs->trans("HierarchicalResponsible").''; @@ -1200,8 +1207,8 @@ else } print '
'.$langs->trans("Status").''; print $object->getLibStatut(4); @@ -1223,7 +1230,7 @@ else print ''.$object->openid.'
'; print ''; print '
'.$langs->trans("HierarchicalResponsible").''; - print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id)); + print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$object->entity); print '
'.$langs->trans("Status").''; print $object->getLibStatut(4); print '
'; - print ''; - print ''; - $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); - print $desc; - print '
'; - print ''; + if (empty($origin)) + { + // Deposit + print '
'; + print ''; print ''; - $text=$langs->trans("InvoiceReplacementAsk").' '; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); print $desc; print '
'; - print ''; - print ''; - $text=$langs->transnoentities("InvoiceAvoirAsk").' '; - // $text.=''; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); - print $desc; - print '
'; + print ''; + print ''; + $text=$langs->trans("InvoiceReplacementAsk").' '; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + print $desc; + print '
'; + print ''; + print ''; + $text=$langs->transnoentities("InvoiceAvoirAsk").' '; + // $text.=''; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); + print $desc; + print '
'; print '
'; - print ''; - print ''; - $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); - print $desc; - print '
'; - print ''; - print ''; - $text=$langs->trans("InvoiceReplacementAsk").' '; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); - print $desc; - print '
'; + print ''; + print ''; + $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); + print $desc; + print '
'; - print ''; - print ''; - $text=$langs->transnoentities("InvoiceAvoirAsk").' '; - // $text.=''; - $text.=''; + print ''; + print ''; + $text=$langs->trans("InvoiceReplacementAsk").' '; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + print $desc; + print '
'; + print ''; + print ''; + $text=$langs->transnoentities("InvoiceAvoirAsk").' '; + // $text.=''; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); + print $desc; + print '
'; print '
'; - print ''; - print ''; - $text=$langs->trans("InvoiceReplacementAsk").' '; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); - print $desc; - print '
'; + print ''; + print ''; + $text=$langs->trans("InvoiceReplacementAsk").' '; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + print $desc; + print '
'; print ' Date: Sun, 17 Feb 2013 17:12:19 +0100 Subject: [PATCH 130/162] Fix: When creating invoice from other object, type must be standard only --- htdocs/compta/facture.php | 105 ++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 7c42593f70b..49604013c19 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1935,63 +1935,66 @@ if ($action == 'create') $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); print $desc; print '
'; - print ''; - print ''; - $text=$langs->trans("InvoiceReplacementAsk").' '; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); - print $desc; - print '
'; + print ''; + print ''; + $text=$langs->trans("InvoiceReplacementAsk").' '; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + print $desc; + print '
'; - print ''; - print ''; - $text=$langs->transnoentities("InvoiceAvoirAsk").' '; - // $text.=''; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); - print $desc; - print '
'; + print ''; + print ''; + $text=$langs->transnoentities("InvoiceAvoirAsk").' '; + // $text.=''; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); + print $desc; + print '
'; print ''; - if($socid>0) + if ($socid > 0) { // Discounts for third party print ''.$langs->trans('Discounts').''; From df2fde3a68b747fe1df13a8bea848a3391dc4bc4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 17:17:19 +0100 Subject: [PATCH 131/162] Prepare 3.3 release --- build/exe/doliwamp/doliwamp.iss | 4 ++-- build/makepack-dolibarr.pl | 2 +- build/makepack-howto.txt | 10 +++++----- build/pad/pad_dolibarr.xml | 6 +++--- build/pad/pad_doliwamp.xml | 6 +++--- htdocs/filefunc.inc.php | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 1dd37f24700..faafcf5ce6a 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -17,9 +17,9 @@ ; ----- Change this ----- AppName=DoliWamp ; DoliWamp-x.x.x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x -AppVerName=DoliWamp-3.3.0-beta +AppVerName=DoliWamp-3.3.0 ; DoliWamp-x.x x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x -OutputBaseFilename=DoliWamp-3.3.0-beta +OutputBaseFilename=DoliWamp-3.3.0 ; Define full path from wich all relative path are defined ; You must modify this to put here your dolibarr root directory ;SourceDir=C:\Documents and Settings\ldestailleur\git\dolibarr_old diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 8fcf7946de7..aee377023ac 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -10,7 +10,7 @@ use Cwd; $PROJECT="dolibarr"; $MAJOR="3"; $MINOR="3"; -$BUILD="0-beta"; # Mettre x pour release, x-dev pour dev, x-beta pour beta, x-rc pour release candidate +$BUILD="0"; # Mettre x pour release, x-dev pour dev, x-beta pour beta, x-rc pour release candidate $RPMSUBVERSION="auto"; # auto use value found into BUILD @LISTETARGET=("TGZ","ZIP","RPM_GENERIC","RPM_FEDORA","RPM_MANDRIVA","RPM_OPENSUSE","DEB","APS","EXEDOLIWAMP","SNAPSHOT"); # Possible packages diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index a8a9471cc1b..fad028cfbf6 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -33,11 +33,11 @@ complete release of Dolibarr, step by step. - Check all files are commited. - Update version/info in /ChangeLog and /filefunc.inc.php -- Update version number with x.x.x-y in htdocs/filefunc.inc.php -- Update version number with x.x.x-y in build/makepack-dolibarr.pl -- Update version number with x.x.x-y in build/debian/changelog -- Update version number with x.x.x-y in build/exe/doliwamp/doliwamp.iss -- Update version number with x.x.x-y in build/rpm/*.spec +- Update version number with x.x.x in htdocs/filefunc.inc.php +- Update version number with x.x.x in build/makepack-dolibarr.pl +- Update version number with x.x.x in build/debian/changelog +- Update version number with x.x.x in build/exe/doliwamp/doliwamp.iss +- Update version number with x.x.x in build/rpm/*.spec - Update PAD files. - Commit all changes. - Add a Tag (DOLIBARR_x_y) diff --git a/build/pad/pad_dolibarr.xml b/build/pad/pad_dolibarr.xml index e8c88ca8968..dd80e1ef53c 100644 --- a/build/pad/pad_dolibarr.xml +++ b/build/pad/pad_dolibarr.xml @@ -35,9 +35,9 @@ Dolibarr 3.3.0 - 08 - 10 - 2012 + 02 + 17 + 2013 diff --git a/build/pad/pad_doliwamp.xml b/build/pad/pad_doliwamp.xml index e20d9563559..148c4a4e79b 100644 --- a/build/pad/pad_doliwamp.xml +++ b/build/pad/pad_doliwamp.xml @@ -35,9 +35,9 @@ DoliWamp 3.3.0 - 08 - 10 - 2012 + 02 + 17 + 2013 diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 6173ef70704..734526bedc6 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -29,7 +29,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.3.0-beta'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.3.0'); if (! defined('EURO')) define('EURO',chr(128)); // Define syslog constants From b0695d3bbb64ab46380cbc585d1a7affe527e551 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 17:20:05 +0100 Subject: [PATCH 132/162] Preapre 3.3 --- build/rpm/dolibarr_fedora.spec | 2 +- build/rpm/dolibarr_generic.spec | 2 +- build/rpm/dolibarr_mandriva.spec | 2 +- build/rpm/dolibarr_opensuse.spec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 3481164a0af..b894d8367d1 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -333,5 +333,5 @@ fi %changelog -* Wed Dec 19 2012 Laurent Destailleur 3.3.0-0.1.a +* Sun Feb 17 2013 Laurent Destailleur 3.3.0-0.3 - Initial version (#723326) diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 8d8949f1f83..f2aa80cf0e3 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -522,5 +522,5 @@ fi %changelog -* Wed Dec 19 2012 Laurent Destailleur 3.3.0-0.1.a +* Sun Feb 17 2013 Laurent Destailleur 3.3.0-0.3 - Initial version (#723326) diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 161bf9f7b0b..fa4e379e885 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -322,5 +322,5 @@ fi %changelog -* Wed Dec 19 2012 Laurent Destailleur 3.3.0-0.1.a +* Sun Feb 17 2013 Laurent Destailleur 3.3.0-0.3 - Initial version (#723326) diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 170b4d28813..9eaf86f1d3d 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -333,5 +333,5 @@ fi %changelog -* Wed Dec 19 2012 Laurent Destailleur 3.3.0-0.1.a +* Sun Feb 17 2013 Laurent Destailleur 3.3.0-0.3 - Initial version (#723326) From 8af34ee97ea7c012be8c9dabfb9e52e48b4aacf5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 18:40:09 +0100 Subject: [PATCH 133/162] Fix: Bad property --- htdocs/expedition/class/expedition.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 1f890d2da3d..1840713b0e6 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -909,8 +909,8 @@ class Expedition extends CommonObject $line->volume = $obj->volume; $line->volume_units = $obj->volume_units; - //Invoicing - $line->desc = $obj->product_label; + // For invoicing + $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) $line->qty = $obj->qty_shipped; $line->total_ht = $obj->total_ht; $line->total_localtax1 = $obj->total_localtax1; From 660fd2e785da708d258a2bee2dcc7b639724399e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 18:46:46 +0100 Subject: [PATCH 134/162] Doc --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 68452e0ca4f..7c1b893fc12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ For users: - New: Can attach files onto trip and expenses modules. - New: Add option MAIN_PDF_TITLE_BACKGROUND_COLOR - New: Can define a hierarchical responsible on user +- New: Merge tab customer and prospect For developers: - System of menu managers has been rewritten to reduce code to do same things. From 2bad9c0d9a227662f77ca808bc2e6917c20e6e16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 19:25:55 +0100 Subject: [PATCH 135/162] Fix: Nb of holidays was not using correct user --- htdocs/holiday/index.php | 99 +++++++++++++++++++++++---------- htdocs/langs/en_US/holiday.lang | 2 +- htdocs/langs/fr_FR/holiday.lang | 2 +- 3 files changed, 71 insertions(+), 32 deletions(-) diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php index 19944b16ae8..16d2edddf7e 100644 --- a/htdocs/holiday/index.php +++ b/htdocs/holiday/index.php @@ -30,6 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; + +$langs->load('users'); +$langs->load('holidays'); // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -46,6 +51,8 @@ $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; +$id = GETPOST('id'); + $search_ref = GETPOST('search_ref'); $month_create = GETPOST('month_create'); $year_create = GETPOST('year_create'); @@ -72,6 +79,7 @@ $search_statut = GETPOST('select_statut'); $holiday = new Holiday($db); $holidaystatic=new Holiday($db); +$fuser = new User($db); // Update sold $holiday->updateSold(); @@ -151,28 +159,22 @@ if(!empty($search_statut) && $search_statut != -1) { // Récupération de l'ID de l'utilisateur $user_id = $user->id; +if ($id > 0) +{ + // Charge utilisateur edite + $fuser->fetch($id); + $fuser->getrights(); + $user_id = $fuser->id; +} // Récupération des congés payés de l'utilisateur ou de tous les users -if (!$user->rights->holiday->lire_tous) +if (!$user->rights->holiday->lire_tous || $id > 0) { - $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); + $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); } else { $holiday_payes = $holiday->fetchAll($order,$filter); } - -// Si pas de congés payés -if ($holiday_payes == 0) -{ - print_fiche_titre($langs->trans('CPTitreMenu')); - - print '
'; - print ''.$langs->trans('NoCPforUser').'

'; - print ''.$langs->trans('AddCP').'
'; - print '
'; - exit(); -} - // Si erreur SQL if ($holiday_payes == '-1') { @@ -189,14 +191,48 @@ if ($holiday_payes == '-1') * Affichage du tableau des congés payés *************************************/ -$var=true; $num = count($holiday->holiday); -$html = new Form($db); -$htmlother = new FormOther($db); -print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num); +$var=true; $num = count($holiday->holiday); +$form = new Form($db); +$formother = new FormOther($db); -print '
'; +if ($id > 0) +{ + $head = user_prepare_head($fuser); + + $title = $langs->trans("User"); + dol_fiche_head($head, 'paidholidays', $title, 0, 'user'); -$nbaquis=$holiday->getCPforUser($user->id); + print ''; + + // Ref + print ''; + print ''; + print ''; + + // Nom + print ''; + print ''; + print "\n"; + + // Prenom + print ''; + print ''; + print "\n"; + + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin); + print '
'.$langs->trans("LastName").''.$fuser->lastname.'
'.$langs->trans("FirstName").''.$fuser->firstname.'

'; + +} +else +{ + print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num); + + print '
'; +} + + +$nbaquis=$holiday->getCPforUser($user_id); $nbdeduced=$holiday->getConfCP('nbHolidayDeducted'); $nb_holiday = $nbaquis / $nbdeduced; print $langs->trans('SoldeCPUser',round($nb_holiday,2)).($nbdeduced != 1 ? ' ('.$nbaquis.' / '.$nbdeduced.')' : ''); @@ -223,13 +259,13 @@ print ''; print ''; -$htmlother->select_year($year_create,'year_create',1, $min_year, $max_year); +$formother->select_year($year_create,'year_create',1, $min_year, $max_year); print ''; // UTILISATEUR if($user->rights->holiday->lire_tous) { print ''; - $html->select_users($search_employe,"search_employe",1,"",0,''); + $form->select_users($search_employe,"search_employe",1,"",0,''); print ''; } else { print ' '; @@ -246,7 +282,7 @@ if($user->rights->holiday->lire_tous){ $validator = new UserGroup($db,$idGroupValid); $valideur = $validator->listUsersForGroup(); - $html->select_users($search_valideur,"search_valideur",1,"",0,$valideur,''); + $form->select_users($search_valideur,"search_valideur",1,"",0,$valideur,''); print ''; } else { print ' '; @@ -255,13 +291,13 @@ if($user->rights->holiday->lire_tous){ // DATE DEBUT print ''; print ''; -$htmlother->select_year($year_start,'year_start',1, $min_year, $max_year); +$formother->select_year($year_start,'year_start',1, $min_year, $max_year); print ''; // DATE FIN print ''; print ''; -$htmlother->select_year($year_end,'year_end',1, $min_year, $max_year); +$formother->select_year($year_end,'year_end',1, $min_year, $max_year); print ''; // DUREE @@ -327,10 +363,13 @@ if($holiday_payes == '2') print ''; print ''; -print '
'; -print '
'; -print ''.$langs->trans('AddCP').''; -print '
'; +if ($user_id == $user->id) +{ + print '
'; + print '
'; + print ''.$langs->trans('AddCP').''; + print '
'; +} llxFooter(); diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 2b83b1fcb1d..abf2b1dc514 100755 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -26,7 +26,7 @@ SendRequestCP=Creating demand for holidays DelayToRequestCP=Applications for holidays must be made at least %s day(s) before them. MenuConfCP=Edit balance of holidays UpdateAllCP=Update the holidays -SoldeCPUser=Your balance of holidays is %s days. +SoldeCPUser=Holidays balance is %s days. ErrorEndDateCP=You must select an end date greater than the start date. ErrorSQLCreateCP=An SQL error occurred during the creation: ErrorIDFicheCP=An error has occurred, the request for holidays does not exist. diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index 60c7594fe90..ed8d339af75 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -26,7 +26,7 @@ SendRequestCP=Envoyer la demande de congés DelayToRequestCP=Les demandes de congés doivent être faites au moins %s jours avant la date de ceux-ci. MenuConfCP=Mettre à jour solde UpdateAllCP=Mettre à jour les congés -SoldeCPUser=Votre solde de congés est de %s jours. +SoldeCPUser=Solde de congés: %s jours. ErrorEndDateCP=Vous devez choisir une date de fin supérieur à la date de début. ErrorSQLCreateCP=Une erreur SQL est survenue durant la création : ErrorIDFicheCP=Une erreur est survenue, cette demande de congés n'existe pas. From d6e907b69bf72bddae93ac5de264430f7649be5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 19:25:55 +0100 Subject: [PATCH 136/162] Fix: Nb of holidays was not using correct user --- htdocs/holiday/index.php | 99 +++++++++++++++++++++++---------- htdocs/langs/en_US/holiday.lang | 2 +- htdocs/langs/fr_FR/holiday.lang | 2 +- 3 files changed, 71 insertions(+), 32 deletions(-) diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php index 4dbb299a825..a3ebf0f1c1c 100644 --- a/htdocs/holiday/index.php +++ b/htdocs/holiday/index.php @@ -30,6 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; + +$langs->load('users'); +$langs->load('holidays'); // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -46,6 +51,8 @@ $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; +$id = GETPOST('id'); + $search_ref = GETPOST('search_ref'); $month_create = GETPOST('month_create'); $year_create = GETPOST('year_create'); @@ -72,6 +79,7 @@ $search_statut = GETPOST('select_statut'); $holiday = new Holiday($db); $holidaystatic=new Holiday($db); +$fuser = new User($db); // Update sold $holiday->updateSold(); @@ -151,28 +159,22 @@ if(!empty($search_statut) && $search_statut != -1) { // Récupération de l'ID de l'utilisateur $user_id = $user->id; +if ($id > 0) +{ + // Charge utilisateur edite + $fuser->fetch($id); + $fuser->getrights(); + $user_id = $fuser->id; +} // Récupération des congés payés de l'utilisateur ou de tous les users -if (!$user->rights->holiday->lire_tous) +if (!$user->rights->holiday->lire_tous || $id > 0) { - $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); + $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); } else { $holiday_payes = $holiday->fetchAll($order,$filter); } - -// Si pas de congés payés -if ($holiday_payes == 0) -{ - print_fiche_titre($langs->trans('CPTitreMenu')); - - print '
'; - print ''.$langs->trans('NoCPforUser').'

'; - print ''.$langs->trans('AddCP').'
'; - print '
'; - exit(); -} - // Si erreur SQL if ($holiday_payes == '-1') { @@ -189,14 +191,48 @@ if ($holiday_payes == '-1') * Affichage du tableau des congés payés *************************************/ -$var=true; $num = count($holiday->holiday); -$html = new Form($db); -$htmlother = new FormOther($db); -print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num); +$var=true; $num = count($holiday->holiday); +$form = new Form($db); +$formother = new FormOther($db); -print '
'; +if ($id > 0) +{ + $head = user_prepare_head($fuser); + + $title = $langs->trans("User"); + dol_fiche_head($head, 'paidholidays', $title, 0, 'user'); -$nbaquis=$holiday->getCPforUser($user->id); + print ''; + + // Ref + print ''; + print ''; + print ''; + + // Nom + print ''; + print ''; + print "\n"; + + // Prenom + print ''; + print ''; + print "\n"; + + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin); + print '
'.$langs->trans("LastName").''.$fuser->lastname.'
'.$langs->trans("FirstName").''.$fuser->firstname.'

'; + +} +else +{ + print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num); + + print '
'; +} + + +$nbaquis=$holiday->getCPforUser($user_id); $nbdeduced=$holiday->getConfCP('nbHolidayDeducted'); $nb_holiday = $nbaquis / $nbdeduced; print $langs->trans('SoldeCPUser',round($nb_holiday,2)).($nbdeduced != 1 ? ' ('.$nbaquis.' / '.$nbdeduced.')' : ''); @@ -223,13 +259,13 @@ print ''; print ''; -$htmlother->select_year($year_create,'year_create',1, $min_year, $max_year); +$formother->select_year($year_create,'year_create',1, $min_year, $max_year); print ''; // UTILISATEUR if($user->rights->holiday->lire_tous) { print ''; - $html->select_users($search_employe,"search_employe",1,"",0,''); + $form->select_users($search_employe,"search_employe",1,"",0,''); print ''; } else { print ' '; @@ -246,7 +282,7 @@ if($user->rights->holiday->lire_tous){ $validator = new UserGroup($db,$idGroupValid); $valideur = $validator->listUsersForGroup(); - $html->select_users($search_valideur,"search_valideur",1,"",0,$valideur,''); + $form->select_users($search_valideur,"search_valideur",1,"",0,$valideur,''); print ''; } else { print ' '; @@ -255,13 +291,13 @@ if($user->rights->holiday->lire_tous){ // DATE DEBUT print ''; print ''; -$htmlother->select_year($year_start,'year_start',1, $min_year, $max_year); +$formother->select_year($year_start,'year_start',1, $min_year, $max_year); print ''; // DATE FIN print ''; print ''; -$htmlother->select_year($year_end,'year_end',1, $min_year, $max_year); +$formother->select_year($year_end,'year_end',1, $min_year, $max_year); print ''; // DUREE @@ -327,10 +363,13 @@ if($holiday_payes == '2') print ''; print ''; -print '
'; -print '
'; -print ''.$langs->trans('AddCP').''; -print '
'; +if ($user_id == $user->id) +{ + print '
'; + print '
'; + print ''.$langs->trans('AddCP').''; + print '
'; +} llxFooter(); diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 2b83b1fcb1d..abf2b1dc514 100755 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -26,7 +26,7 @@ SendRequestCP=Creating demand for holidays DelayToRequestCP=Applications for holidays must be made at least %s day(s) before them. MenuConfCP=Edit balance of holidays UpdateAllCP=Update the holidays -SoldeCPUser=Your balance of holidays is %s days. +SoldeCPUser=Holidays balance is %s days. ErrorEndDateCP=You must select an end date greater than the start date. ErrorSQLCreateCP=An SQL error occurred during the creation: ErrorIDFicheCP=An error has occurred, the request for holidays does not exist. diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index 60c7594fe90..ed8d339af75 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -26,7 +26,7 @@ SendRequestCP=Envoyer la demande de congés DelayToRequestCP=Les demandes de congés doivent être faites au moins %s jours avant la date de ceux-ci. MenuConfCP=Mettre à jour solde UpdateAllCP=Mettre à jour les congés -SoldeCPUser=Votre solde de congés est de %s jours. +SoldeCPUser=Solde de congés: %s jours. ErrorEndDateCP=Vous devez choisir une date de fin supérieur à la date de début. ErrorSQLCreateCP=Une erreur SQL est survenue durant la création : ErrorIDFicheCP=Une erreur est survenue, cette demande de congés n'existe pas. From 16e9f6db48770a70f433399edf06a20f721656b1 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sun, 17 Feb 2013 14:37:33 +0100 Subject: [PATCH 137/162] Fix : bad name of property when retrieve extrafields for thirdparty --- htdocs/core/class/commondocgenerator.class.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ec9ae1d2870..d64a7c2710b 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -169,7 +169,7 @@ abstract class CommonDocGenerator { foreach($object->array_options as $key=>$label) { - $extrafields['company_options_'.$key] = $label; + $extrafields['company_'.$key] = $label; } $array_thirdparty = array_merge($array_thirdparty,$extrafields); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index dfeec3eaab7..7688eec0d66 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -865,7 +865,7 @@ class Societe extends CommonObject } foreach($extrafields->attribute_label as $key=>$label) { - $this->array_options[$key]=$label; + $this->array_options['options_'.$key]=$label; } } else From 060060f08ba00e41d499a068bbca6c3a6c17d375 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sun, 17 Feb 2013 20:14:18 +0100 Subject: [PATCH 138/162] Missing object $langs when showing extrafield of type 'price' --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4f583a667f9..ec02f906e70 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -669,7 +669,7 @@ class ExtraFields */ function showOutputField($key,$value,$moreparam='') { - global $conf; + global $conf,$langs; $label=$this->attribute_label[$key]; $type=$this->attribute_type[$key]; From 8ebb48cb5c9464865306c33cfec48bea86568398 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sun, 17 Feb 2013 21:14:00 +0100 Subject: [PATCH 139/162] Fix : in ODT show value and not label of company extrafield --- htdocs/core/class/commondocgenerator.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index d64a7c2710b..3b815e962c0 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -164,14 +164,20 @@ abstract class CommonDocGenerator 'company_note'=>$object->note ); - $extrafields = array(); + // Retrieve extrafields if(is_array($object->array_options) && count($object->array_options)) { - foreach($object->array_options as $key=>$label) + if(!class_exists('Extrafields')) + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + $extralabels = $extrafields->fetch_name_optionals_label('company',true); + //Get extrafield values + $object->fetch_optionals($object->id,$extralabels); + + foreach($extrafields->attribute_label as $key=>$label) { - $extrafields['company_'.$key] = $label; + $array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key])); } - $array_thirdparty = array_merge($array_thirdparty,$extrafields); } return $array_thirdparty; } From 3ef8c6e5dd33ed6106155e28a6c87ffc3e35929e Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 18 Feb 2013 00:40:49 +0100 Subject: [PATCH 140/162] Missing variable declaration --- htdocs/core/class/extrafields.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ec02f906e70..f72ddc8d6e2 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -44,6 +44,10 @@ class ExtraFields var $attribute_unique; // Array to store if attribute is required or not var $attribute_required; + // Array to store parameters of attribute (used in select type) + var $attribute_param; + // Int to store position of attribute + var $attribute_pos; var $error; var $errno; From bd2d9cdd3e39282dc904e2ab26ee2d482a7d89e7 Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 18 Feb 2013 00:41:50 +0100 Subject: [PATCH 141/162] Split extrafields display into 2 columns (thirdparty) --- htdocs/societe/soc.php | 57 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index c1dd0c4c09d..ee8f6e984b1 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -998,14 +998,25 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { + $e=0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan='3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:'')); - print ''; + $colspan='0'; + } + print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; + print '>'.$label.''; + print ''; print $extrafields->showInputField($key,$value); - print ''."\n"; + print ''; + + if (($e % 2) == 1) print ''."\n"; + $e++; } } @@ -1426,23 +1437,38 @@ else print ''; print ''; } - // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { + $old_pos=0; + $e=0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan = '3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print ''."\n"; + $colspan = '0'; + } + print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; + print '>'.$label.''."\n"; + print ''; print $extrafields->showInputField($key,$value); - print "\n"; + print ""."\n"; + + if (($e % 2) == 1 ) + { + print "\n"; + } + $old_pos = $extrafields->attribute_pos[$key]; + $e++; } } - // Logo print ''; print ''.$langs->trans("Logo").''; @@ -1756,12 +1782,23 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { + $e=0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan='3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); - print ''.$label.''; + if (($e % 2) == 0) + { + print ''; + $colspan='0'; + } + print ''.$label.''; + print ''; print $extrafields->showOutputField($key,$value); - print "\n"; + print ""; + + if (($e % 2) == 1) print ''; + $e++; } } From 71a2b4c8c0a4653ca4cceec3a8b945cdce48b36c Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 18 Feb 2013 00:58:40 +0100 Subject: [PATCH 142/162] In ODT document add currency symbol with extrafields of type "price" --- htdocs/core/class/commondocgenerator.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 3b815e962c0..aec9e74dcb8 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -171,11 +171,13 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('company',true); - //Get extrafield values - $object->fetch_optionals($object->id,$extralabels); foreach($extrafields->attribute_label as $key=>$label) { + if($extrafields->attribute_type[$key] == 'price') + { + $object->array_options['options_'.$key] = price($object->array_options['options_'.$key]).' '.$outputlangs->getCurrencySymbol($conf->currency); + } $array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key])); } } From d2cc6d299c70202a7ce7ca9858a24c7b5e104308 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Mon, 18 Feb 2013 12:19:01 +0100 Subject: [PATCH 143/162] fix language --- htdocs/langs/fr_FR/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index b471e19b473..e92b474efe7 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -973,7 +973,7 @@ NotificationsDesc= La fonction des notifications par emails permet d'envoyer aut ModelModules=Modèle de documents DocumentModelOdt=Genération depuis des modèles OpenDocument (Fichier .ODT OpenOffice, KOffice, TextEdit...) WatermarkOnDraft=Filigrane sur les documents brouillons -CompanyIdProfChecker=Id professionel unique +CompanyIdProfChecker=Id professionnel unique MustBeUnique=Doit être unique ? MustBeMandatory=Doit être obligatoire? Miscellanous=Divers From 37e9b04d8389844ad56e0c57c222f1015a452bb8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Feb 2013 12:57:14 +0100 Subject: [PATCH 144/162] Fix: Check id field are mandatory --- htdocs/societe/soc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index c1dd0c4c09d..a83ac0ca517 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -222,19 +222,20 @@ if (empty($reshook)) { $langs->load("errors"); $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel); - $action = ($action=='add'?'create':'edit'); + $action = (($action=='add'||$action=='create')?'create':'edit'); } } $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; + if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); - $action = ($action=='add'?'create':'edit'); + $action = (($action=='add'||$action=='create')?'create':'edit'); } - } + } } if (! $error) @@ -712,8 +713,7 @@ else print "
\n"; } - - dol_htmloutput_errors($error,$errors); + dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); print '
'; From f82bec552b344627f0ca1d9211ae5fee414de34c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Feb 2013 12:57:14 +0100 Subject: [PATCH 145/162] Fix: Check id field are mandatory --- htdocs/societe/soc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 063d33a27f3..135bd6f2295 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -224,19 +224,20 @@ if (empty($reshook)) { $langs->load("errors"); $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel); - $action = ($action=='add'?'create':'edit'); + $action = (($action=='add'||$action=='create')?'create':'edit'); } } $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; + if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); - $action = ($action=='add'?'create':'edit'); + $action = (($action=='add'||$action=='create')?'create':'edit'); } - } + } } if (! $error) @@ -714,8 +715,7 @@ else print "
\n"; } - - dol_htmloutput_errors($error,$errors); + dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); print ''; From 0a697e1033e30a69335c6a639249f5b1a991ed66 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Mon, 18 Feb 2013 13:47:46 +0100 Subject: [PATCH 146/162] fix language --- htdocs/langs/fr_FR/admin.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index e92b474efe7..216d9b67de4 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -47,9 +47,9 @@ DictionnarySetup= Dictionnaires Dictionnary= Dictionnaires DisableJavascript= Désactiver les fonctions Javascript et Ajax ConfirmAjax= Utiliser les popups de confirmation Ajax -UseSearchToSelectCompany= Utiliser un champ avec autocomplétion pour choisir un tiers (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. +UseSearchToSelectCompany= Utiliser un champ avec autocomplétion pour choisir un tiers (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de tiers (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. ActivityStateToSelectCompany= Ajouter une option de filtrage lors des recherches pour afficher/masquer les tiers en exercice ou ayant cessés d'exercer -UseSearchToSelectContact= Utiliser un champ avec autocomplétion pour choisir un contact (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante CONTACT_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. +UseSearchToSelectContact= Utiliser un champ avec autocomplétion pour choisir un contact (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de contacts (> 100 000), vous pouvez améliorer les performances en définissant la constante CONTACT_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. SearchFilter=Options des filtres de recherche NumberOfKeyToSearch=Nb carac. déclenchant recherche: %s ViewFullDateActions= Visualiser les dates des actions en entier dans la fiche tiers From b5260e4ab1b086a179cccd0182127249258480ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Feb 2013 14:13:02 +0100 Subject: [PATCH 147/162] Fix: Translation --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 2 +- htdocs/langs/fr_FR/holiday.lang | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9586ce352a8..7bcb30a2d62 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -967,7 +967,7 @@ NotificationsDesc=EMails notifications feature allows you to silently send autom ModelModules=Documents templates DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT files for OpenOffice, KOffice, TextEdit,...) WatermarkOnDraft=Watermark on draft document -CompanyIdProfChecker=Professional Id unique +CompanyIdProfChecker=Rules ono Professional Ids MustBeUnique=Must be unique ? MustBeMandatory=Must be mandatory ? Miscellanous=Miscellaneous diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index adb0a063d5d..ffa72893e4a 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -962,7 +962,7 @@ NotificationsDesc= La fonction des notifications par emails permet d'envoyer aut ModelModules=Modèle de documents DocumentModelOdt=Genération depuis des modèles OpenDocument (Fichier .ODT OpenOffice, KOffice, TextEdit...) WatermarkOnDraft=Filigrane sur les documents brouillons -CompanyIdProfChecker=Id professionel unique +CompanyIdProfChecker=Règles sur les Ids professionels MustBeUnique=Doit être unique ? MustBeMandatory=Doit être obligatoire? Miscellanous=Divers diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index ed8d339af75..ad8ebd7fcf1 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -91,7 +91,7 @@ LastDayOfHoliday=Dernier jour de congès ConfCP=Configuration du module Congés DescOptionCP=Description de l'option ValueOptionCP=Valeur -GroupToValidateCP=Groupe ayant la possibilité de valider les congés +GroupToValidateCP=Groupe ayant la possibilité d'approuver les congés ConfirmConfigCP=Valider la configuration LastUpdateCP=Dernière mise à jour automatique des congés UpdateConfCPOK=Mise à jour effectuée avec succès. From b484fef22a5909d9e55ca96c1dd28446e43047e2 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Mon, 18 Feb 2013 14:19:01 +0100 Subject: [PATCH 148/162] fix language --- htdocs/langs/fr_FR/admin.lang | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 216d9b67de4..a43179386de 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -931,11 +931,11 @@ MAIN_PROXY_PORT=Port du serveur proxy mandataire MAIN_PROXY_USER=Login pour passer le serveur proxy mandataire MAIN_PROXY_PASS=Mot de passe pour passer le serveur proxy mandataire DefineHereComplementaryAttributes=Définissez ici la liste des attributs supplémentaires, non disponibles en standard, et que vous voulez voir gérer sur les %s. -ExtraFields=Attributs suplémentaires -ExtraFieldsThirdParties=Attributs suplémentaires (tiers) -ExtraFieldsContacts=Attributs suplémentaires (contacts/adresses) -ExtraFieldsMember=Attributs suplémentaires (adhérents) -ExtraFieldsMemberType=Attributs suplémentaires (type d'adhérents) +ExtraFields=Attributs supplémentaires +ExtraFieldsThirdParties=Attributs supplémentaires (tiers) +ExtraFieldsContacts=Attributs supplémentaires (contacts/adresses) +ExtraFieldsMember=Attributs supplémentaires (adhérents) +ExtraFieldsMemberType=Attributs supplémentaires (type d'adhérents) ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte. AlphaNumOnlyCharsAndNoSpace=uniquement caractères alphanumériques sans espace SendingMailSetup=Configuration de l'envoi par mail From e9dc4b9db3ffa96d9e4a64e8cee6b815a8ebbf25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Feb 2013 15:15:10 +0100 Subject: [PATCH 149/162] Fix: We must not add month holidays after init of sold. --- htdocs/holiday/define_holiday.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 586ae4db258..079ecd01e03 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -72,6 +72,13 @@ if ($action == 'update' && isset($_POST['update_cp'])) // Mise à jour des congés de l'utilisateur $holiday->updateSoldeCP($userID,$userValue); + // If it first update of sold, we set date to havoid to have sold incremented by new month + $now=dol_now(); + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; + $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; + $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. + dol_syslog('define_holiday update lastUpdate entry sql='.$sql); + $result = $db->query($sql); $mesg='
'.$langs->trans('UpdateConfCPOK').'
'; From fd4a465c909cd4e1f976bf73c89bfb168d25d773 Mon Sep 17 00:00:00 2001 From: fhenry Date: Mon, 18 Feb 2013 15:25:13 +0100 Subject: [PATCH 150/162] Fix mass maling tabs regression --- htdocs/core/lib/emailing.lib.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index e68a62a2768..394f8b72349 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -31,12 +31,6 @@ function emailing_prepare_head($object) { global $user, $langs, $conf; - // 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 - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing'); - $h = 0; $head = array(); @@ -58,6 +52,8 @@ function emailing_prepare_head($object) $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; + + complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing'); complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing','remove'); From 3e42f90b1ec7291a499a100b3a9afd44f706e1b2 Mon Sep 17 00:00:00 2001 From: fhenry Date: Tue, 19 Feb 2013 04:48:39 +0100 Subject: [PATCH 151/162] Better to use foreach because when add mail in $cible array we can test with (!array_key_exists($obj->email, $cibles)) better than old method --- .../modules/mailings/modules_mailings.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 5dc82e85d63..ea9a54651a9 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -150,9 +150,9 @@ class MailingTargets // This can't be abstract as it is used for some method // Insert emailing targest from array into database $j = 0; $num = count($cibles); - for ($i = 0 ; $i < $num ; $i++) + foreach ($cibles as $targetarray) { - if (! empty($cibles[$i]['email'])) // avoid empty email address + if (! empty($targetarray['email'])) // avoid empty email address { $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " (fk_mailing,"; @@ -163,17 +163,17 @@ class MailingTargets // This can't be abstract as it is used for some method } $sql.= " source_type)"; $sql .= " VALUES (".$mailing_id.","; - $sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .","; - $sql .= "'".$this->db->escape($cibles[$i]['name'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['email'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; + $sql .= (empty($targetarray['fk_contact']) ? '0' : "'".$targetarray['fk_contact']."'") .","; + $sql .= "'".$this->db->escape($targetarray['name'])."',"; + $sql .= "'".$this->db->escape($targetarray['firstname'])."',"; + $sql .= "'".$this->db->escape($targetarray['email'])."',"; + $sql .= "'".$this->db->escape($targetarray['other'])."',"; + $sql .= "'".$this->db->escape($targetarray['source_url'])."',"; + $sql .= "'".$this->db->escape($targetarray['source_id'])."',"; if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) { - $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; + $sql .= "'".$this->db->escape(md5($targetarray['email'].';'.$targetarray['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; } - $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')"; + $sql .= "'".$this->db->escape($targetarray['source_type'])."')"; $result=$this->db->query($sql); if ($result) { From df0f281efd26b18da00dec6794191f101ecf9db0 Mon Sep 17 00:00:00 2001 From: simnandez Date: Mon, 18 Feb 2013 17:07:20 +0100 Subject: [PATCH 152/162] Fix: Translation --- htdocs/langs/ca_ES/admin.lang | 2 +- htdocs/langs/es_ES/admin.lang | 2 +- htdocs/langs/es_ES/holiday.lang | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/ca_ES/admin.lang b/htdocs/langs/ca_ES/admin.lang index b144352fcf2..5bbc3472c98 100644 --- a/htdocs/langs/ca_ES/admin.lang +++ b/htdocs/langs/ca_ES/admin.lang @@ -960,7 +960,7 @@ NotificationsDesc=La funció de les notificacions permet enviar automàticament ModelModules=Models de documents DocumentModelOdt=Generació des dels documents amb format OpenDocument (Arxiu .ODT OpenOffice, KOffice, TextEdit,...) WatermarkOnDraft=Marca d'aigua en els documents esborrany -CompanyIdProfChecker=Id Professional únic +CompanyIdProfChecker=Règles sobre els ID professionals MustBeUnique=Ha de ser únic? MustBeMandatory=Ha de ser obligatori? Miscellanous=Miscel·lània diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang index 2c0cc6c36e1..cbf15193742 100644 --- a/htdocs/langs/es_ES/admin.lang +++ b/htdocs/langs/es_ES/admin.lang @@ -962,7 +962,7 @@ NotificationsDesc=La función de las notificaciones permite enviar automáticame ModelModules=Modelos de documentos DocumentModelOdt=Generación desde los documentos OpenDocument (Archivo .ODT OpenOffice, KOffice, TextEdit,...) WatermarkOnDraft=Marca de agua en los documentos borrador -CompanyIdProfChecker=Id Profesional único +CompanyIdProfChecker=Reglas sobre los ID profesionales MustBeUnique=¿Debe ser único? MustBeMandatory=¿Debe ser obligatorio? Miscellanous=Miscelánea diff --git a/htdocs/langs/es_ES/holiday.lang b/htdocs/langs/es_ES/holiday.lang index 4d7344cc10c..3183101f294 100644 --- a/htdocs/langs/es_ES/holiday.lang +++ b/htdocs/langs/es_ES/holiday.lang @@ -91,7 +91,7 @@ LastDayOfHoliday=Último día libre ConfCP=Configuración del módulo Vacaciones DescOptionCP=Descripción de la opción ValueOptionCP=Valor -GroupToValidateCP=Grupo con posibilidad de validar las vacaciones +GroupToValidateCP=Grupo con posibilidad de aprobar las vacaciones ConfirmConfigCP=Validar la configuración LastUpdateCP=Última actualización automática de vacaciones UpdateConfCPOK=Actualización efectuada correctamente. From 7367a2472c5a6292744f436d20480c224e5dcbbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Feb 2013 13:24:32 +0100 Subject: [PATCH 153/162] Look: Mor CSS3 --- htdocs/comm/action/fiche.php | 4 +++- htdocs/comm/action/index.php | 11 ++++++++--- htdocs/langs/en_US/users.lang | 3 ++- htdocs/langs/fr_FR/users.lang | 3 ++- htdocs/theme/amarok/style.css.php | 11 +++++++---- htdocs/theme/auguria/style.css.php | 3 +++ htdocs/theme/bureau2crea/style.css.php | 15 +++++++++++---- htdocs/theme/cameleo/style.css.php | 15 +++++++++++---- htdocs/theme/eldy/style.css.php | 13 +++++++++---- htdocs/user/index.php | 2 +- 10 files changed, 57 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index af09519cfef..f5fdb2cfabb 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -407,6 +407,8 @@ if ($action == 'create') if ($result < 0) dol_print_error($db,$contact->error); } + dol_set_focus("#label"); + if (! empty($conf->use_javascript_ajax)) { print "\n".''; - //print 'aa'; - } - elseif($rang > $rangLast) - { - - print '
    • '; - - } - elseif($rang < $rangLast) - { - print ''; - - for($i=$rang; $i < $rangLast; $i++) - { - print '
  • '; - echo "\n"; - } - - } - } - else - { - if($rang > $rangLast) - { - - print '
    • '; - - } - elseif($rang < $rangLast) - { - - for($i=$rang; $i < $rangLast; $i++) - { - print '
  • '; - echo "\n"; - } - - } - } - - print '
  • '; - // Content of line - print '  '.$tab['title'].''; - print ''; - print ''; - print ''; - print ''; - - print '
  • '; - echo "\n"; + print '
    '; + print '   '.$tab['title'].''; + print ''; + print ''.img_edit('default',0,'class="menuEdit" id="edit'.$tab['rowid'].'"').' '; + print ''.img_edit_add('default',0,'class="menuNew" id="new'.$tab['rowid'].'"').' '; + print ''.img_delete('default',0,'class="menuDel" id="del'.$tab['rowid'].'"').' '; + print ''.img_picto("Monter","1uparrow").''.img_picto("Descendre","1downarrow").''; + print '
    '; $rangLast = $rang; $idLast = $tab['rowid']; @@ -218,41 +173,63 @@ function tree_showline($tab,$rang) /** * Recursive function to output menu tree * - * @param array $tab Array of elements + * @param array $tab Array of all elements * @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>) * @param int $rang Level of element * @return void */ function tree_recur($tab,$pere,$rang) { - if (empty($pere['rowid'])) print ''; } diff --git a/htdocs/includes/jquery/plugins/jquerytreeview/changelog.md b/htdocs/includes/jquery/plugins/jquerytreeview/changelog.md new file mode 100644 index 00000000000..29c6e1975d2 --- /dev/null +++ b/htdocs/includes/jquery/plugins/jquerytreeview/changelog.md @@ -0,0 +1,36 @@ +1.4.1 +----- +* Fix for #2360 +* Added option cookieOptions: Passed through to $.cookie to set path, domain etc. +* Tested with jQuery 1.2.x and 1.4.3 +* Fixed combination of persist: "location" and prerendered: true + +1.4 +--- + +* Added changelog (this file) +* Fixed tree control to search only for anchors, allowing images or other elements inside the controls, while keeping the control usable with the keyboard +* Restructured folder layout: root contains plugin resources, lib contains script dependencies, demo contains demos and related files +* Added prerendered option: If set to true, assumes all hitarea divs and classes already rendered, speeding up initialization for big trees, but more obtrusive +* Added jquery.treeview.async.js for ajax-lazy-loading trees, see async.html demo +* Exposed $.fn.treeview.classes for custom classes if necessary +* Show treecontrol only when JavaScript is enabled +* Completely reworked themeing via CSS sprites, resulting in only two files per theme + * updated dotted, black, gray and red theme + * added famfamfam theme (no lines) +* Improved cookie persistence to allow multiple persisted trees per page via cookieId option +* Improved location persistence by making it case-insensitive +* Improved swapClass and replaceClass plugin implementations +* Added folder-closed.gif to filetree example + +1.3 +--- + +* Fixes for all outstanding bugs +* Added persistence features + * location based: click on a link in the treeview and reopen that link after the page loaded + * cookie based: save the state of the tree in a cookie on each click and load that on reload +* smoothed animations, fixing flickering in both IE and Opera +* Tested in Firefox 2, IE 6 & 7, Opera 9, Safari 3 +* Moved documentation to jQuery wiki +* Requires jQuery 1.2+ diff --git a/htdocs/includes/jquery/plugins/jquerytreeview/jquery.treeview.async.js b/htdocs/includes/jquery/plugins/jquerytreeview/jquery.treeview.async.js new file mode 100644 index 00000000000..36e368a0737 --- /dev/null +++ b/htdocs/includes/jquery/plugins/jquerytreeview/jquery.treeview.async.js @@ -0,0 +1,108 @@ +/* + * Async Treeview 0.1 - Lazy-loading extension for Treeview + * + * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ + * + * Copyright 2010 Jörn Zaefferer + * Released under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ + +;(function($) { + +function load(settings, root, child, container) { + function createNode(parent) { + var current = $("
  • ").attr("id", this.id || "").html("" + this.text + "").appendTo(parent); + if (this.classes) { + current.children("span").addClass(this.classes); + } + if (this.expanded) { + current.addClass("open"); + } + if (this.hasChildren || this.children && this.children.length) { + var branch = $("