From 3faa2b558f033816986efad998a9e2cae97095a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jan 2013 15:04:34 +0100 Subject: [PATCH 01/10] Renamed param. --- htdocs/core/class/extrafields.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 9a44de0dbf0..799200ca5bf 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -467,17 +467,17 @@ class ExtraFields * Load array this->attribute_label * * @param string $elementtype Type of element - * @param boolean $forcecheck override test of MAIN_EXTRAFIELDS_DISABLED + * @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED * @return array Array of attributes for all extra fields */ - function fetch_name_optionals_label($elementtype='member',$forcecheck=false) + function fetch_name_optionals_label($elementtype='member',$forceload=false) { global $conf; $array_name_label=array(); // For avoid conflicts with external modules - if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && !$forcecheck) + if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired"; From 92849ae039b52149f79ce6bc22a9e843534a1e17 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 21 Jan 2013 18:20:14 +0100 Subject: [PATCH 02/10] Fix: $modules not loaded --- htdocs/admin/perms.php | 96 +++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index e7568331c7d..6871a1823db 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2011 Herve Prot * * This program is free software; you can redistribute it and/or modify @@ -69,6 +69,52 @@ print_fiche_titre($langs->trans("SecuritySetup"),'','setup'); print $langs->trans("DefaultRightsDesc"); print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; +$db->begin(); + +// Charge les modules soumis a permissions +$modules = array(); +$modulesdir = dolGetModulesDirs(); + +foreach ($modulesdir as $dir) +{ + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + $handle=@opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, dol_strlen($file) - 10); + if ($modName) + { + include_once $dir.$file; + $objMod = new $modName($db); + + // Load all lang files of module + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) + { + foreach($objMod->langfiles as $domain) + { + $langs->load($domain); + } + } + // Load all permissions + if ($objMod->rights_class) + { + $ret=$objMod->insert_permissions(0); + $modules[$objMod->rights_class]=$objMod; + //print "modules[".$objMod->rights_class."]=$objMod;"; + } + } + } + } + } +} + +$db->commit(); + // Show warning about external users print showModulesExludedForExternal($modules).'
'."\n"; print "
\n"; @@ -81,54 +127,6 @@ dol_fiche_head($head, 'default', $langs->trans("Security")); print ''; - -$db->begin(); - -// Charge les modules soumis a permissions -$modules = array(); -$modulesdir = dolGetModulesDirs(); - -foreach ($modulesdir as $dir) -{ - // Load modules attributes in arrays (name, numero, orders) from dir directory - //print $dir."\n
"; - $handle=@opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { - $modName = substr($file, 0, dol_strlen($file) - 10); - - if ($modName) - { - include_once $dir.$file; - $objMod = new $modName($db); - - // Load all lang files of module - if (isset($objMod->langfiles) && is_array($objMod->langfiles)) - { - foreach($objMod->langfiles as $domain) - { - $langs->load($domain); - } - } - // Load all permissions - if ($objMod->rights_class) - { - $ret=$objMod->insert_permissions(0); - $modules[$objMod->rights_class]=$objMod; - //print "modules[".$objMod->rights_class."]=$objMod;"; - } - } - } - } - } -} - -$db->commit(); - // Affiche lignes des permissions $sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; From 131dd663cb79b2d7531f749db4f547897999118a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Jan 2013 11:28:53 +0100 Subject: [PATCH 03/10] Fix: missing webservices and code more simple --- htdocs/webservices/admin/webservices.php | 67 +++++++----------------- 1 file changed, 19 insertions(+), 48 deletions(-) diff --git a/htdocs/webservices/admin/webservices.php b/htdocs/webservices/admin/webservices.php index e1935464124..2de3c12df2c 100644 --- a/htdocs/webservices/admin/webservices.php +++ b/htdocs/webservices/admin/webservices.php @@ -98,34 +98,26 @@ print ''; print '

'; +// Webservices list +$webservices = array( + 'user' => '', + 'thirdparty' => '!empty($conf->societe->enabled)', + 'productorservice' => '(!empty($conf->product->enabled) || !empty($conf->service->enabled))', + 'order' => '!empty($conf->commande->enabled)', + 'invoice' => '!empty($conf->facture->enabled)', + 'supplier_invoice' => '!empty($conf->fournisseur->enabled)', + 'actioncomm' => '!empty($conf->agenda->enabled)', + 'category' => '!empty($conf->categorie->enabled)', + 'other' => '' +); + // WSDL print ''.$langs->trans("WSDLCanBeDownloadedHere").':
'; -$url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php?wsdl'; -print img_picto('','object_globe.png').' '.$url."
\n"; -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) +foreach($webservices as $name => $right) { - $url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php?wsdl'; - print img_picto('','object_globe.png').' '.$url."
\n"; -} -if (! empty($conf->societe->enabled)) -{ - $url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php?wsdl'; - print img_picto('','object_globe.png').' '.$url."
\n"; -} -if (! empty($conf->facture->enabled)) -{ - $url=DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php?wsdl'; - print img_picto('','object_globe.png').' '.$url."
\n"; -} -if (! empty($conf->fournisseur->enabled)) -{ - $url=DOL_MAIN_URL_ROOT.'/webservices/server_supplier_invoice.php?wsdl'; - print img_picto('','object_globe.png').' '.$url."
\n"; -} -if (! empty($conf->agenda->enabled)) -{ - $url=DOL_MAIN_URL_ROOT.'/webservices/server_actioncomm.php?wsdl'; + if (!empty($right) && !verifCond($right)) continue; + $url=DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl'; print img_picto('','object_globe.png').' '.$url."
\n"; } print '
'; @@ -133,31 +125,10 @@ print '
'; // Endpoint print ''.$langs->trans("EndPointIs").':
'; -$url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php'; -print img_picto('','object_globe.png').' '.$url."
\n"; -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) +foreach($webservices as $name => $right) { - $url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; - print img_picto('','object_globe.png').' '.$url."
\n"; -} -if (! empty($conf->societe->enabled)) -{ - $url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php'; - print img_picto('','object_globe.png').' '.$url."
\n"; -} -if (! empty($conf->facture->enabled)) -{ - $url=DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php'; - print img_picto('','object_globe.png').' '.$url."
\n"; -} -if (! empty($conf->fournisseur->enabled)) -{ - $url=DOL_MAIN_URL_ROOT.'/webservices/server_supplier_invoice.php'; - print img_picto('','object_globe.png').' '.$url."
\n"; -} -if (! empty($conf->agenda->enabled)) -{ - $url=DOL_MAIN_URL_ROOT.'/webservices/server_actioncomm.php'; + if (!empty($right) && !verifCond($right)) continue; + $url=DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php'; print img_picto('','object_globe.png').' '.$url."
\n"; } print '
'; From f0361b9c4c11eb8c36b5e6b523eebd47928f2d6a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Jan 2013 16:48:32 +0100 Subject: [PATCH 04/10] Fix: broken feature --- htdocs/core/class/commonobject.class.php | 12 ++++++------ htdocs/core/class/hookmanager.class.php | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4b094236cde..26a1905a6af 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2135,7 +2135,7 @@ abstract class CommonObject $this->array_options[$key] = null; } break; - case 'price': + case 'price': $this->array_options[$key] = price2num($this->array_options[$key]); break; } @@ -2282,16 +2282,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); } @@ -2482,7 +2482,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 d3ddfe0ba8d..b836c001152 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 bfe57b21b0e48b42b883c2fe35ff7c06bb206238 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Jan 2013 18:04:04 +0100 Subject: [PATCH 05/10] 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 d050c7e0510..a804948bf1d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -134,8 +134,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 d2152a8342b4a9c65efc84baad13e154b0d35fd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Jan 2013 17:43:41 +0100 Subject: [PATCH 06/10] 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 26a1905a6af..8b6002c29c5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2482,7 +2482,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 b836c001152..5c84534f9f5 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 e8ce9cecf2c586bd708580fed8b73045ac65f5be Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Jan 2013 21:36:30 +0100 Subject: [PATCH 07/10] 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 98688801426b4a3d3ed508732058d08f3bd8d36e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 23 Jan 2013 11:28:11 +0100 Subject: [PATCH 08/10] 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 4b4f6095ee7..bbe46c9a21a 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 00c2a61c067..b093d290a01 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 4a0bc90d5a4c9a8403cdc0aa808d4f0279bd5e3c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 23 Jan 2013 15:26:18 +0100 Subject: [PATCH 09/10] 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 61d4efe68b0..a092d674978 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -1368,7 +1368,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)) { @@ -1380,7 +1380,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").''; } @@ -1393,7 +1393,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").''; } @@ -1403,7 +1403,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").''; @@ -1412,19 +1412,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 9203cce485bdc63a203ffdc5332bac75b2b35b03 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 23 Jan 2013 15:41:17 +0100 Subject: [PATCH 10/10] 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 a092d674978..6a0ca1db656 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -1368,7 +1368,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)) { @@ -1376,13 +1376,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 @@ -1393,9 +1393,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) @@ -1403,32 +1403,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 { @@ -1582,7 +1582,7 @@ else print '
'; print ''; print ''; - print ''; + print ''; print '
'; $rowspan=13;