From bc8c36b08f6b3d8ffd653242c1658685ea23a1d4 Mon Sep 17 00:00:00 2001 From: fhenry Date: Mon, 21 Jan 2013 13:48:15 +0100 Subject: [PATCH 01/12] 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 02/12] 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 03/12] 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 04/12] 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 05/12] 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 06/12] 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 07/12] 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 08/12] 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 b12101a650545e78cf024ea66699c936228c56f6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 23 Jan 2013 15:11:33 +0100 Subject: [PATCH 09/12] 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 10/12] 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 11/12] 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 12/12] 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 {