From 04228cca82989ccf79c116805aec09521c33471d Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 4 May 2018 12:20:29 +0200 Subject: [PATCH 001/228] NEW triggers add commercial and del commercial --- htdocs/societe/class/societe.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 32f29522268..05e15b9cb03 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1909,6 +1909,11 @@ class Societe extends CommonObject */ function add_commercial(User $user, $commid) { + $error=0; + + + + if ($this->id > 0 && $commid > 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; @@ -1924,6 +1929,12 @@ class Societe extends CommonObject { dol_syslog(get_class($this)."::add_commercial Erreur"); } + else { + $this->commercial_modified = $commid; + + $result=$this->call_trigger('COMPANY_ADD_COMMERCIAL',$user); + if ($result < 0) $error++; + } } } @@ -1936,6 +1947,12 @@ class Societe extends CommonObject */ function del_commercial(User $user, $commid) { + $error=0; + $this->commercial_modified = $commid; + + $result=$this->call_trigger('COMPANY_DEL_COMMERCIAL',$user); + if ($result < 0) $error++; + if ($this->id > 0 && $commid > 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; From 5802eb63ecf07f5100e697cc471272429b1043db Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 7 May 2018 11:36:34 +0200 Subject: [PATCH 002/228] FIX name of trigger and use of context --- htdocs/societe/class/societe.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 05e15b9cb03..69812787b8c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1930,9 +1930,9 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::add_commercial Erreur"); } else { - $this->commercial_modified = $commid; + $this->context=array('commercial_modified'=>$commid); - $result=$this->call_trigger('COMPANY_ADD_COMMERCIAL',$user); + $result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE',$user); if ($result < 0) $error++; } } @@ -1948,9 +1948,9 @@ class Societe extends CommonObject function del_commercial(User $user, $commid) { $error=0; - $this->commercial_modified = $commid; + $this->context=array('commercial_modified'=>$commid); - $result=$this->call_trigger('COMPANY_DEL_COMMERCIAL',$user); + $result=$this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE',$user); if ($result < 0) $error++; if ($this->id > 0 && $commid > 0) From 85469438981f29cf13e2caa7bb641f04055d0d5e Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:30:40 +0200 Subject: [PATCH 003/228] Create index.html --- htdocs/core/modules/holiday/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/core/modules/holiday/index.html diff --git a/htdocs/core/modules/holiday/index.html b/htdocs/core/modules/holiday/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/core/modules/holiday/index.html @@ -0,0 +1 @@ + From ffaff97af121e56f82b2da8096fadb930c8a2f12 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:33:14 +0200 Subject: [PATCH 004/228] Create modules_holiday.php --- .../core/modules/holiday/modules_holiday.php | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 htdocs/core/modules/holiday/modules_holiday.php diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php new file mode 100644 index 00000000000..7e7865c87e8 --- /dev/null +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2014 Marcos García + * Copyright (C) 2018 Charlene Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/holiday/modules_holiday.php + * \ingroup contract + * \brief File with parent class for generating holiday to PDF and File of class to manage contract numbering + */ + + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + + +/** + * Parent class to manage intervention document templates + */ +abstract class ModelePDFHoliday extends CommonDocGenerator +{ + var $error=''; + + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='contract'; + $liste=array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + + return $liste; + } +} + + +/** + * Parent class for all contract numbering modules + */ +class ModelNumRefHolidays +{ + var $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + function isEnabled() + { + return true; + } + + /** + * Return default description of numbering model + * + * @return string text description + */ + function info() + { + global $langs; + $langs->load("holidays"); + return $langs->trans("NoDescription"); + } + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + global $langs; + $langs->load("holidays"); + return $langs->trans("NoExample"); + } + + /** + * Test if existing numbers make problems with numbering + * + * @return boolean false if conflict, true if ok + */ + function canBeActivated() + { + return true; + } + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $contract contract object + * @return string Value + */ + function getNextValue($objsoc, $contract) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Return numbering version module + * + * @return string Value + */ + function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} From a20632d31d401e3e346c441f1ff4fa64fa81c85b Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:34:26 +0200 Subject: [PATCH 005/228] Create mod_holiday_immaculate.php --- .../holiday/mod_holiday_immaculate.php | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 htdocs/core/modules/holiday/mod_holiday_immaculate.php diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php new file mode 100644 index 00000000000..1355ba90302 --- /dev/null +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -0,0 +1,132 @@ + + * Copyright (C) 2018 Charlene Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/holiday/mod_holiday_immaculate.php + * \ingroup contract + * \brief File of class to manage contract numbering rules Magre + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php'; + +/** + * Class to manage contract numbering rules Magre + */ +class mod_holiday_immaculate extends ModelNumRefHolidays +{ + var $version='dolibarr'; + var $error = ''; + var $nom = 'Immaculate'; + var $code_auto=1; + + /** + * Return default description of numbering model + * + * @return string text description + */ + function info() + { + global $conf,$langs; + + $langs->load("bills"); + + $form = new Form($this->db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('',$tooltip,1,1).' 
'; + $texte.= '
'; + + return $texte; + } + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + global $conf,$langs,$user; + + $old_login=$user->login; + $user->login='UUUUUUU'; + $numExample = $this->getNextValue($user, ''); + $user->login=$old_login; + + if (! $numExample) + { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next value + * + * @param Societe $user user object + * @param Object $holiday holiday object + * @return string Value if OK, 0 if KO + */ + function getNextValue($user, $holiday) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + $mask=$conf->global->HOLIDAY_IMMACULATE_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $numFinal=get_next_value($db,$mask,'holiday','ref','', $user, $holiday->date_create); + + return $numFinal; + } + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $objforref contract object + * @return string Value if OK, 0 if KO + */ + function holiday_get_num($user, $objforref) + { + return $this->getNextValue($user, $objforref); + } +} From 3d268933a43f56929a72d9b139f6d9a1cf043202 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:35:19 +0200 Subject: [PATCH 006/228] Create mod_holiday_madonna.php --- .../modules/holiday/mod_holiday_madonna.php | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 htdocs/core/modules/holiday/mod_holiday_madonna.php diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php new file mode 100644 index 00000000000..b5848263c98 --- /dev/null +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -0,0 +1,148 @@ + + * Copyright (C) 2018 Charlene Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/holiday/mod_holiday_madonna.php + * \ingroup contract + * \brief File of class to manage contract numbering rules Serpis + */ +require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php'; + +/** + * Class to manage contract numbering rules madonna + */ +class mod_holiday_madonna extends ModelNumRefHolidays +{ + var $version='dolibarr'; + var $prefix='HL'; + var $error=''; + var $nom='Madonna'; + var $code_auto=1; + + + /** + * Return default description of numbering model + * + * @return string text description + */ + function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); + } + + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Test if existing numbers make problems with numbering + * + * @return boolean false if conflit, true if ok + */ + function canBeActivated() + { + global $conf,$langs,$db; + + $coyymm=''; $max=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } + } + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $contract contract object + * @return string Value if OK, 0 if KO + */ + function getNextValue($objsoc,$contract) + { + global $db,$conf; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog("mod_holiday_madonna::getNextValue", LOG_DEBUG); + return -1; + } + + $date=$contract->date_contrat; + $yymm = strftime("%y%m",$date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); + + dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } + + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $objforref contract object + * @return string Value if OK, 0 if KO + */ + function holiday_get_num($objsoc,$objforref) + { + return $this->getNextValue($objsoc,$objforref); + } + +} From 79bb8ef6c7adbb37b1ee867e8014004b9107aff8 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:47:24 +0200 Subject: [PATCH 007/228] Update modHoliday.class.php --- htdocs/core/modules/modHoliday.class.php | 31 ++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 3fd056b525e..4f41f2eae2d 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2011 Dimitri Mouillard * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2018 Charlene Benke * * 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 @@ -69,9 +70,13 @@ class modHoliday extends DolibarrModules // Data directories to create when module is enabled. // Example: this->dirs = array("/mymodule/temp"); - $this->dirs = array(); + $this->dirs = array("/holiday/temp"); $r=0; + // Config pages + $this->config_page_url = array("holiday.php"); + + // Config pages. Put here list of php page names stored in admmin directory used to setup module. // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); @@ -87,7 +92,29 @@ class modHoliday extends DolibarrModules // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') - + $r=0; + + $this->const[$r][0] = "HOLIDAY_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_holiday_madonna"; + $this->const[$r][3] = 'Nom du gestionnaire de numerotation des congés'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "HOLIDAY_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "celebrate"; + $this->const[$r][3] = 'Name of PDF model of holiday'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "HOLIDAY_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/holiday"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + // Array to add new pages in new tabs $this->tabs[] = array('data'=>'user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); // To add a new tab identified by code tabname1 From e3963c3518cf87023d666b9a80992c95b136856c Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:48:43 +0200 Subject: [PATCH 008/228] Create holiday.php --- htdocs/admin/holiday.php | 521 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 521 insertions(+) create mode 100644 htdocs/admin/holiday.php diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php new file mode 100644 index 00000000000..b199505d214 --- /dev/null +++ b/htdocs/admin/holiday.php @@ -0,0 +1,521 @@ + + * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2018 Charlene Benke + * + * 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/admin/contract.php + * \ingroup contract + * \brief Setup page of module Contracts + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; + +$langs->load("admin"); +$langs->load("errors"); +$langs->load("holiday"); + +if (!$user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$label = GETPOST('label','alpha'); +$scandir = GETPOST('scan_dir','alpha'); +$type='contract'; + +if (empty($conf->global->HOLIDAY_ADDON)) +{ + $conf->global->HOLIDAY_ADDON='mod_holiday_madona'; +} + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + +if ($action == 'updateMask') +{ + $maskconst = GETPOST('maskconstholidaty','alpha'); + $maskvalue = GETPOST('maskholiday','alpha'); + if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +else if ($action == 'specimen') // For contract +{ + $modele= GETPOST('module','alpha'); + + $contract = new Contrat($db); + $contract->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php",0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($contract,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessages($obj->error, $obj->errors, 'errors'); + dol_syslog($obj->error, LOG_ERR); + } + } + else + { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +// Activate a model +else if ($action == 'set') +{ + $ret = addDocumentModel($value, $type, $label, $scandir); +} + +else if ($action == 'del') +{ + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF',$conf->entity); + } +} + +// Set default model +else if ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "HOLIDAY_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->HOLIDAY_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + +else if ($action == 'setmod') +{ + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated + + dolibarr_set_const($db, "HOLIDAY_ADDON",$value,'chaine',0,'',$conf->entity); +} + +else if ($action == 'set_other') +{ + $freetext= GETPOST('HOLIDAY_FREE_TEXT','none'); // No alpha here, we want exact string + $res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + + $draft= GETPOST('HOLIDAY_DRAFT_WATERMARK','alpha'); + $res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); + + if (! $res1 > 0 || ! $res2 > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + + +/* + * View + */ + +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + +llxHeader(); + +$form=new Form($db); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("HolidaySetup"),$linkback,'title_setup'); + +$head=holiday_admin_prepare_head(); + +dol_fiche_head($head, 'holiday', $langs->trans("Holidays"), -1, 'holiday'); + +/* + * Holiday Numbering model + */ + +print load_fiche_titre($langs->trans("HolidaysNumberingModules"),'',''); + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/holiday/"); + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + $var=true; + + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file)-4); + + require_once $dir.$file.'.php'; + + $module = new $file($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + + print ''; + + // Show example of numbering model + print ''."\n"; + + print ''; + + $holiday=new Holiday($db); + $holiday->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval=$module->getNextValue($mysoc,$contract); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print ''; + } + } + } + closedir($handle); + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->nom."\n"; + print $module->info(); + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + if ($conf->global->HOLIDAY_ADDON == "$file") + { + print img_picto($langs->trans("Activated"),'switch_on'); + } + else + { + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print '

'; + +/* + * Documents models for Contracts + */ + +print load_fiche_titre($langs->trans("TemplatePDFHolidays"),'',''); + +// Defini tableau def des modeles +$def = array(); +$sql = "SELECT nom"; +$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql.= " WHERE type = '".$type."'"; +$sql.= " AND entity = ".$conf->entity; +$resql=$db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} +else +{ + dol_print_error($db); +} + + +print ''; +print ''; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +$var=true; +foreach ($dirmodels as $reldir) +{ + foreach (array('','/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/holiday".$valdir); + + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + { + + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + + if ($modulequalified) + { + $var = !$var; + print ''; + + // Active + if (in_array($name, $def)) + { + print ''; + } + else + { + print '"; + } + + // Defaut + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1); + + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print "'; + if ($conf->global->HOLIDAY_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'contract').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print '
'; +print "
"; + +/* + * Other options + * + */ + +print '
'; +print ''; +print ''; + +print load_fiche_titre($langs->trans("OtherOptions"),'',''); +print ''; +print ''; +print ''; +print ''; +print "\n"; +$var=true; + +$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + +$var=! $var; +print ''."\n"; + +//Use draft Watermark + +print ''."\n"; + +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); +print '
'; +$variablename='HOLIDAY_FREE_TEXT'; +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) +{ + print ''; +} +else +{ + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); + print $doleditor->Create(); +} +print '
'; +print $form->textwithpicto($langs->trans("WatermarkOnDraftHolidayCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; +print '
'; +print ''; +print '
'; + +print '
'; +print ''; +print '
'; + +print '
'; + +dol_fiche_end(); + +llxFooter(); +$db->close(); From 468635867db6fc93ad983bb2c9a6ccae98952bd8 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 12 May 2018 17:52:56 +0200 Subject: [PATCH 009/228] Add dateemployementend --- htdocs/install/mysql/tables/llx_user.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 2ecb52511d4..7ae732d51e6 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -84,6 +84,7 @@ create table llx_user salary double(24,8), -- denormalized value coming from llx_user_employment salaryextra double(24,8), -- denormalized value coming from llx_user_employment dateemployment date, -- denormalized value coming from llx_user_employment + dateemploymentend date, -- denormalized value coming from llx_user_employment weeklyhours double(16,8), -- denormalized value coming from llx_user_employment import_key varchar(14), -- import key From fcf6ab6ee5d8872ba02aa51dd65fa8afd78c74ce Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 12 May 2018 17:55:14 +0200 Subject: [PATCH 010/228] Update 7.0.0-8.0.0.sql --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index a57e02455cc..d259da1fe55 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -44,6 +44,7 @@ ALTER TABLE llx_website_page ADD COLUMN type_container varchar(16) NOT NULL DEFA DROP TABLE llx_c_accountancy_category; DROP TABLE llx_c_accountingaccount; + update llx_propal set fk_statut = 1 where fk_statut = -1; ALTER TABLE llx_inventory ADD COLUMN fk_user_creat integer; @@ -79,6 +80,10 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE -- For 8.0 + +ALTER TABLE llx_user ADD COLUMN dateemploymentend date after dateemployment; + + -- delete old permission no more used DELETE FROM llx_rights_def WHERE perms = 'main' and module = 'commercial'; From caa35e03590fb51dc2dcf5ed3b0b20efd599503b Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 12 May 2018 17:59:43 +0200 Subject: [PATCH 011/228] Update user.class.php --- htdocs/user/class/user.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8ac4963f5b5..77b4a59df7a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -10,6 +10,7 @@ * Copyright (C) 2013-2014 Philippe Grand * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2015 Marcos García + * Copyright (C) 2018 charlene Benke * * 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 @@ -131,6 +132,7 @@ class User extends CommonObject public $color; // Define background color for user in agenda public $dateemployment; // Define date of employment by company + public $dateemploymentend; // Define date of employment end by company public $default_c_exp_tax_cat; public $default_range; @@ -201,7 +203,7 @@ class User extends CommonObject $sql.= " u.salaryextra,"; $sql.= " u.weeklyhours,"; $sql.= " u.color,"; - $sql.= " u.dateemployment,"; + $sql.= " u.dateemployment, u.dateemploymentend,"; $sql.= " u.ref_int, u.ref_ext,"; $sql.= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode $sql.= " c.code as country_code, c.label as country,"; @@ -304,6 +306,7 @@ class User extends CommonObject $this->weeklyhours = $obj->weeklyhours; $this->color = $obj->color; $this->dateemployment = $this->db->jdate($obj->dateemployment); + $this->dateemploymentend = $this->db->jdate($obj->dateemploymentend); $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); @@ -1376,6 +1379,7 @@ class User extends CommonObject $this->accountancy_code = trim($this->accountancy_code); $this->color = empty($this->color)?'':$this->color; $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; + $this->dateemploymentend = empty($this->dateemploymentend)?'':$this->dateemploymentend; // Check parameters if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email)) @@ -1418,6 +1422,7 @@ class User extends CommonObject $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; $sql.= ", color = '".$this->db->escape($this->color)."'"; $sql.= ", dateemployment=".(strval($this->dateemployment)!='' ? "'".$this->db->idate($this->dateemployment)."'" : 'null'); + $sql.= ", dateemploymentend=".(strval($this->dateemploymentend)!='' ? "'".$this->db->idate($this->dateemploymentend)."'" : 'null'); $sql.= ", note = '".$this->db->escape($this->note)."'"; $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null"); From 0dad083cb529999cd15e29605ace10768406be3b Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 12 May 2018 18:05:06 +0200 Subject: [PATCH 012/228] Update card.php --- htdocs/user/card.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 48dc1049706..1823adc8044 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -11,7 +11,7 @@ * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2015-2017 Jean-François Ferry * Copyright (C) 2015 Ari Elbaz (elarifr) - * Copyright (C) 2015 Charlie Benke + * Copyright (C) 2015-2018 Charlene Benke * Copyright (C) 2016 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify @@ -222,6 +222,9 @@ if (empty($reshook)) { $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear')); $object->dateemployment = $dateemployment; + $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth'), GETPOST('dateemploymentendday'), GETPOST('dateemploymentendyear')); + $object->dateemploymentend = $dateemploymentend; + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) { @@ -364,6 +367,8 @@ if (empty($reshook)) { $object->color = GETPOST("color",'alpha') != '' ? GETPOST("color",'alpha') : ''; $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth','int'), GETPOST('dateemploymentday','int'), GETPOST('dateemploymentyear','int')); $object->dateemployment = $dateemployment; + $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth','int'), GETPOST('dateemploymentendday','int'), GETPOST('dateemploymentendyear','int')); + $object->dateemploymentend = $dateemploymentend; if (! empty($conf->multicompany->enabled)) { @@ -1159,6 +1164,13 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print "\n"; + // Date employment END + print ''.$langs->trans("DateEmploymentEnd").''; + print ''; + echo $form->select_date(GETPOST('dateemploymentend'),'dateemploymentend',0,0,1,'form'.'dateemploymentend',1,0,1); + print ''; + print "\n"; + // Date birth print ''.$langs->trans("DateToBirth").''; print ''; @@ -1505,6 +1517,13 @@ else print ''; print "\n"; + // Date employment + print ''.$langs->trans("DateEmploymentEnd").''; + print ''; + print dol_print_date($object->dateemploymentend); + print ''; + print "\n"; + // Date of birth print ''.$langs->trans("DateToBirth").''; print ''; @@ -2430,6 +2449,14 @@ else print ''; print "\n"; + // Date employmentEnd + print ''.$langs->trans("DateEmploymentEnd").''; + print ''; + echo $form->select_date(GETPOST('dateemploymentend')?GETPOST('dateemploymentend'):$object->dateemploymentend,'dateemploymentend',0,0,1,'form'.'dateemploymentend',1,0,1); + print ''; + print "\n"; + + // Date birth print ''.$langs->trans("DateToBirth").''; print ''; From 537048a10a37c8cee123722112835c6193524be0 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 13 May 2018 15:30:32 +0200 Subject: [PATCH 013/228] Update html.formcontract.class.php --- htdocs/core/class/html.formcontract.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index f4902e4912e..c6cf20dd5f1 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2018 Charlene BENKE * * 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 @@ -57,7 +57,7 @@ class FormContract global $db,$user,$conf,$langs; $hideunselectables = false; - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->SELECT_HIDE_UNSELECTABLES)) $hideunselectables = true; // Search all contacts $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; From 2f1800f3e23dd2fd03d7182c95cfac48efb8ded9 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 13 May 2018 15:34:26 +0200 Subject: [PATCH 014/228] Update html.formprojet.class.php --- htdocs/core/class/html.formprojet.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index a572d546ca7..75ccc1d8245 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2015 Marcos García + * Copyright (C) 2018 Charlene Benke * * 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 @@ -139,10 +140,10 @@ class FormProjets if (empty($htmlid)) $htmlid = $htmlname; $out=''; - $outarray=array(); + $outarray=array(); $hideunselectables = false; - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->SELECT_HIDE_UNSELECTABLES)) $hideunselectables = true; $projectsListId = false; if (empty($user->rights->projet->all->lire)) @@ -317,7 +318,7 @@ class FormProjets $out=''; $hideunselectables = false; - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->SELECT_HIDE_UNSELECTABLES)) $hideunselectables = true; if (empty($projectsListId)) { From b0757916c4731fea9e04048fffb88e08b2d1ee45 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 13 May 2018 16:59:03 +0200 Subject: [PATCH 015/228] Update html.formcontract.class.php --- htdocs/core/class/html.formcontract.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index c6cf20dd5f1..28b256e32ef 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -64,8 +64,18 @@ class FormContract $sql.= ' FROM '.MAIN_DB_PREFIX .'contrat as c'; $sql.= " WHERE c.entity = ".$conf->entity; //if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")"; + if ($socid > 0) + { + // CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. + if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) + $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; + else if ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') + { + $sql.= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; + $sql.= " OR p.fk_soc IS NULL)"; + } + } if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; - if ($socid > 0) $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; $sql.= " ORDER BY c.ref "; dol_syslog(get_class($this)."::select_contract", LOG_DEBUG); From f4af9ec22f9b2c55fb9cf73523cb4d8ae05a7bff Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 13 May 2018 19:38:30 +0200 Subject: [PATCH 016/228] Update html.formcontract.class.php --- htdocs/core/class/html.formcontract.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 28b256e32ef..64d28e6b281 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -72,7 +72,7 @@ class FormContract else if ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { $sql.= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; - $sql.= " OR p.fk_soc IS NULL)"; + $sql.= " OR c.fk_soc IS NULL)"; } } if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; From 4bebc8149baae5a744159a046e8a2c074794ec9e Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 13 May 2018 21:17:15 +0200 Subject: [PATCH 017/228] Update html.formcontract.class.php --- htdocs/core/class/html.formcontract.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 64d28e6b281..01ebe66666b 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -108,12 +108,12 @@ class FormContract else { $disabled=0; - if (! $obj->statut > 0) + if ( $obj->statut == 0) { $disabled=1; $labeltoshow.=' ('.$langs->trans("Draft").')'; } - if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) + if ( empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) { $disabled=1; $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); From 90881fe488df4bfebcf3c1d43b926de6a5e5b99a Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 18 May 2018 16:32:46 +0100 Subject: [PATCH 018/228] Add link to inventory code --- htdocs/product/stock/mouvement.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index edabf9184da..19aaa6c1289 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -1067,7 +1067,15 @@ if ($resql) if (! empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code - print ''.$objp->inventorycode.''; + print ''.'' + .$objp->inventorycode + .'' + .''; } if (! empty($arrayfields['m.label']['checked'])) { From 2ccaf1ad956813a88be718c7d734ca4fe79d869b Mon Sep 17 00:00:00 2001 From: patrick Delcroix Date: Tue, 22 May 2018 22:00:20 +0200 Subject: [PATCH 019/228] New: support sellist in modulebuilder --- htdocs/core/class/commonobject.class.php | 165 ++++++++++++----------- htdocs/core/lib/modulebuilder.lib.php | 12 +- 2 files changed, 92 insertions(+), 85 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0e9deeade80..750ddd8337c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4969,8 +4969,7 @@ abstract class CommonObject * @param string|int $showsize Value for css to define size. May also be a numeric. * @return string */ - function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0) - { + function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss=0){ global $conf,$langs,$form; if (! is_object($form)) @@ -4979,38 +4978,36 @@ abstract class CommonObject $form=new Form($this->db); } - $objectid = $this->id; + $out=''; + $type=''; + $param['options']=array(); + $keyprefix = $keyprefix.'options_'; // Because we work on extrafields + if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){ + $param['options']=array($reg[1].':'.$reg[2]=>'N'); + $type ='link'; + }else if(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)){ + $param['options']=array($reg[1].':'.$reg[2]=>'N'); + $type ='link'; + }else if(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){ + + $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N'); + $type ='sellist'; + }else { + $param['options']=array(); + $type =$this->fields[$key]['type']; + } - $label= $val['label']; - $type = $val['type']; - $size = $val['css']; - - // Convert var to be able to share same code than showInputField of extrafields - if (preg_match('/varchar\((\d+)\)/', $type, $reg)) - { - $type = 'varchar'; // convert varchar(xx) int varchar - $size = $reg[1]; - } - elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar - if (is_array($val['arrayofkeyval'])) $type='select'; - if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link'; - - //$elementtype=$this->attribute_elementtype[$key]; // seems to not be used - $default=$val['default']; - $computed=$val['computed']; - $unique=$val['unique']; - $required=$val['required']; - $param=$val['param']; - if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; - if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) - { - $type='link'; - $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); - } - $langfile=$val['langfile']; - $list=$val['list']; - $hidden=(abs($val['visible'])!=1 ? 1 : 0); - $help=$val['help']; + $label=$this->fields[$key]['label']; + $size =$this->fields[$key]['size']; + //$elementtype=$this->fields[$key]['elementtype']; // Seems not used + $default=$this->fields[$key]['default']; + $computed=$this->fields[$key]['computed']; + //$unique=$this->fields[$key]['unique']; + $required=$this->fields[$key]['required']; + + //$langfile=$this->fields[$key]['label']; + //$list=$this->fields[$key]['arrayofkeyval']; + $hidden=!$this->fields[$key]['visible']; if ($computed) { @@ -5018,54 +5015,44 @@ abstract class CommonObject else return ''; } - // Use in priorit showsize from parameters, then $val['css'] then autodefine - if (empty($showsize) && ! empty($val['css'])) - { - $showsize = $val['css']; - } - if (empty($showsize)) + if (empty($morecss)) { if ($type == 'date') { - //$showsize=10; - $showsize = 'minwidth100imp'; + $morecss = 'minwidth100imp'; } elseif ($type == 'datetime') { - //$showsize=19; - $showsize = 'minwidth200imp'; + $morecss = 'minwidth200imp'; } - elseif (in_array($type,array('int','double','price'))) + elseif (in_array($type,array('int','integer','double','price'))) { - //$showsize=10; - $showsize = 'maxwidth75'; + $morecss = 'maxwidth75'; } elseif ($type == 'url') { - $showsize='minwidth400'; + $morecss='minwidth400'; } elseif ($type == 'boolean') { - $showsize=''; + $morecss=''; } else { if (round($size) < 12) { - $showsize = 'minwidth100'; + $morecss = 'minwidth100'; } else if (round($size) <= 48) { - $showsize = 'minwidth200'; + $morecss = 'minwidth200'; } else { - //$showsize=48; - $showsize = 'minwidth400'; + $morecss = 'minwidth400'; } } } - //var_dump($showsize.' '.$size); if (in_array($type,array('date','datetime'))) { @@ -5078,33 +5065,47 @@ abstract class CommonObject if (!$required && $value == '') $value = '-1'; // TODO Must also support $moreparam - $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1); + $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0, 1); } elseif (in_array($type,array('int','integer'))) { $tmp=explode(',',$size); $newsize=$tmp[0]; - $out=''; + $out=''; } elseif (preg_match('/varchar/', $type)) { - $out=''; + $out=''; } elseif (in_array($type, array('mail', 'phone', 'url'))) { - $out=''; + $out=''; } elseif ($type == 'text') { - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,0,ROWS_5,'90%'); - $out=$doleditor->Create(1); + if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field + { + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,false,ROWS_5,'90%'); + $out=$doleditor->Create(1); + } + else + { + $out=''; + } } elseif ($type == 'html') { - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); - $out=$doleditor->Create(1); + if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field + { + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); + $out=$doleditor->Create(1); + } + else + { + $out=''; + } } elseif ($type == 'boolean') { @@ -5114,21 +5115,21 @@ abstract class CommonObject } else { $checked=' value="1" '; } - $out=''; + $out=''; } elseif ($type == 'price') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } - $out=' '.$langs->getCurrencySymbol($conf->currency); + $out=' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } - $out=' '; + $out=' '; } elseif ($type == 'select') { @@ -5139,8 +5140,8 @@ abstract class CommonObject $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; + $out.=''; foreach ($param['options'] as $key => $val) { if ((string) $key == '') continue; @@ -5161,11 +5162,13 @@ abstract class CommonObject $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; if (is_array($param['options'])) { $param_list=array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); + $parentName=''; + $parentField=''; // 0 : tableName // 1 : label field name // 2 : key fields name (if differ of rowid) @@ -5250,8 +5253,9 @@ abstract class CommonObject $obj = $this->db->fetch_object($resql); // Several field into label (eq table:code|libelle:rowid) + $notrans = false; $fields_label = explode('|',$InfoFieldList[1]); - if(is_array($fields_label)) + if (is_array($fields_label)) { $notrans = true; foreach ($fields_label as $field_toshow) @@ -5265,7 +5269,7 @@ abstract class CommonObject } $labeltoshow=dol_trunc($labeltoshow,45); - if ($value==$obj->rowid) + if ($value == $obj->rowid) { foreach ($fields_label as $field_toshow) { @@ -5280,7 +5284,7 @@ abstract class CommonObject } else { - if(!$notrans) + if (! $notrans) { $translabel=$langs->trans($obj->{$InfoFieldList[1]}); if ($translabel!=$obj->{$InfoFieldList[1]}) { @@ -5296,7 +5300,7 @@ abstract class CommonObject $out.=''; } - if (!empty($InfoFieldList[3])) + if (!empty($InfoFieldList[3]) && $parentField) { $parent = $parentName.':'.$obj->{$parentField}; } @@ -5327,7 +5331,7 @@ abstract class CommonObject $out=''; foreach ($param['options'] as $keyopt => $val) { - $out.='db->fetch_object($resql); + $notrans = false; // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label)) { @@ -5459,7 +5466,7 @@ abstract class CommonObject $data[$obj->rowid]=$labeltoshow; } - if (! empty($InfoFieldList[3])) { + if (! empty($InfoFieldList[3]) && $parentField) { $parent = $parentName . ':' . $obj->{$parentField}; } @@ -5476,18 +5483,17 @@ abstract class CommonObject print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; } } - $out .= ''; } elseif ($type == 'link') { $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' - $showempty=(($val['notnull'] == 1 && $val['default'] != '')?0:1); + $showempty=(($required && $default != '')?0:1); $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty); } elseif ($type == 'password') { // If prefix is 'search_', field is used as a filter, we use a common text field. - $out=''; + $out=''; } if (!empty($hidden)) { $out=''; @@ -5498,8 +5504,7 @@ abstract class CommonObject */ return $out; } - - + /** * Return HTML string to show a field into a page * Code very similar with showOutputField of extra fields diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 8e2cba43097..343b596d66b 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -63,7 +63,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors'); return -2; } - if (! preg_match('/^(integer|date|timestamp|varchar|double)/', $addfieldentry['type'])) + if (! preg_match('/^(boolean|sellist|integer|date|timestamp|varchar|double)/', $addfieldentry['type'])) { setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors'); return -2; @@ -253,10 +253,12 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', foreach($object->fields as $key => $val) { $i++; - - $type = $val['type']; + + $type = $val['type']; $type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php' - if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database + if ($type == 'html') $type = 'text'; + else if ($type=='link'||$type=='sellist')$type='integer'; +// html modulebuilder type is a text type in database $texttoinsert.= "\t".$key." ".$type; if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; @@ -265,7 +267,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', if ($val['default'] != '') { if (preg_match('/^null$/i', $val['default'])) $texttoinsert.= " DEFAULT NULL"; - else if (preg_match('/varchar/', $val['type'])) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'"; + else if (preg_match('/varchar/', $type )) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'"; else $texttoinsert.= (($val['default'] > 0)?' DEFAULT '.$val['default']:''); } } From 29d26b6e89dda4b1d7648a445c54c25ea3ac5b72 Mon Sep 17 00:00:00 2001 From: patrick Delcroix Date: Tue, 22 May 2018 22:16:25 +0200 Subject: [PATCH 020/228] New: support sellist in modulebuilder --- htdocs/core/class/commonobject.class.php | 27 ++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 750ddd8337c..c90c5c43283 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4981,7 +4981,9 @@ abstract class CommonObject $out=''; $type=''; $param['options']=array(); - $keyprefix = $keyprefix.'options_'; // Because we work on extrafields + $size =$this->fields[$key]['size']; + $keyprefix = $keyprefix.'options_'; + // Because we work on extrafields if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){ $param['options']=array($reg[1].':'.$reg[2]=>'N'); $type ='link'; @@ -4992,6 +4994,19 @@ abstract class CommonObject $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N'); $type ='sellist'; + }else if(preg_match('/varchar\((\d+)\)/', $val['type'],reg)){ + + $param['options']=array(); + $type ='varchar'; + $size=$reg[1]; + }else if(preg_match('/varchar/', $val['type'])){ + + $param['options']=array(); + $type ='varchar'; + }else if(is_array($this->fields[$key]['arrayofkeyval'])){ + + $param['options']=$this->fields[$key]['arrayofkeyval']; + $type ='select'; }else { $param['options']=array(); $type =$this->fields[$key]['type']; @@ -5002,12 +5017,12 @@ abstract class CommonObject //$elementtype=$this->fields[$key]['elementtype']; // Seems not used $default=$this->fields[$key]['default']; $computed=$this->fields[$key]['computed']; - //$unique=$this->fields[$key]['unique']; + $unique=$this->fields[$key]['unique']; $required=$this->fields[$key]['required']; - //$langfile=$this->fields[$key]['label']; - //$list=$this->fields[$key]['arrayofkeyval']; - $hidden=!$this->fields[$key]['visible']; + $langfile=$this->fields[$key]['langfile']; + $list=$this->fields[$key]['list']; + $hidden=abs($this->fields[$key]['visible'])!=1?1:0; if ($computed) { @@ -5141,7 +5156,7 @@ abstract class CommonObject } $out.=' '.$langs->getCurrencySymbol($conf->currency); } - elseif ($type == 'double') + elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type)) { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 81cf2b99c55..978e3bdf246 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -263,8 +263,8 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php' if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database - if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database - + else if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database + else if ($type == 'link' || $type == 'sellist') $type = 'integer'; $texttoinsert.= "\t".$key." ".$type; if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; From 4a7ac774f7e328c25775e30e810cd79613d280e2 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 28 May 2018 16:38:11 +0200 Subject: [PATCH 027/228] introduce fichinter rec models --- htdocs/core/lib/fichinter.lib.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 8507a85292a..fcb14be9c67 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -2,8 +2,9 @@ /* Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2016 Gilles Poirier - + * Copyright (C) 2016 Gilles Poirier + * Copyright (C) 2018 charlene Benke + * * 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 @@ -162,4 +163,23 @@ function fichinter_admin_prepare_head() return $head; } +function fichinter_rec_prepare_head ($object) +{ + global $langs, $conf; //, $user; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id; + $head[$h][1] = $langs->trans("CardFichinter"); + $head[$h][2] = 'card'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec'); + + complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove'); + + + return $head; +} From eef8249ad7189ecdb36633879da061fad4a19405 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 28 May 2018 16:39:40 +0200 Subject: [PATCH 028/228] Create llx_fichinter_rec.sql --- htdocs/install/llx_fichinter_rec.sql | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 htdocs/install/llx_fichinter_rec.sql diff --git a/htdocs/install/llx_fichinter_rec.sql b/htdocs/install/llx_fichinter_rec.sql new file mode 100644 index 00000000000..fa50540ae9f --- /dev/null +++ b/htdocs/install/llx_fichinter_rec.sql @@ -0,0 +1,48 @@ +-- =========================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2012-2014 Laurent Destailleur +-- Copyright (C) 2009 Regis Houssin +-- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2016 Charlie Benke +-- +-- 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 . +-- +-- =========================================================================== + +create table llx_fichinter_rec +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + titre varchar(50) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_soc integer DEFAULT NULL, + datec datetime, -- date de creation + + fk_contrat integer DEFAULT 0, -- contrat auquel est rattache la fiche + fk_user_author integer, -- createur + fk_projet integer, -- projet auquel est associe la facture + duree real, -- duree totale de l'intervention + description text, + modelpdf varchar(50), + note_private text, + note_public text, + + frequency integer, -- frequency (for example: 3 for every 3 month) + unit_frequency varchar(2) DEFAULT 'm', -- 'm' for month (date_when must be a day <= 28), 'y' for year, ... + date_when datetime DEFAULT NULL, -- date for next gen (when an invoice is generated, this field must be updated with next date) + date_last_gen datetime DEFAULT NULL, -- date for last gen (date with last successfull generation of invoice) + nb_gen_done integer DEFAULT NULL, -- nb of generation done (when an invoice is generated, this field must incremented) + nb_gen_max integer DEFAULT NULL, -- maximum number of generation + auto_validate integer NULL DEFAULT NULL -- statut of the generated intervention + +)ENGINE=innodb; From 8124ea15225797f1cdd3498386a4ba6a035f1b42 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 28 May 2018 16:39:56 +0200 Subject: [PATCH 029/228] Delete llx_fichinter_rec.sql --- htdocs/install/llx_fichinter_rec.sql | 48 ---------------------------- 1 file changed, 48 deletions(-) delete mode 100644 htdocs/install/llx_fichinter_rec.sql diff --git a/htdocs/install/llx_fichinter_rec.sql b/htdocs/install/llx_fichinter_rec.sql deleted file mode 100644 index fa50540ae9f..00000000000 --- a/htdocs/install/llx_fichinter_rec.sql +++ /dev/null @@ -1,48 +0,0 @@ --- =========================================================================== --- Copyright (C) 2003 Rodolphe Quiedeville --- Copyright (C) 2012-2014 Laurent Destailleur --- Copyright (C) 2009 Regis Houssin --- Copyright (C) 2010 Juanjo Menent --- Copyright (C) 2016 Charlie Benke --- --- 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 . --- --- =========================================================================== - -create table llx_fichinter_rec -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - titre varchar(50) NOT NULL, - entity integer DEFAULT 1 NOT NULL, -- multi company id - fk_soc integer DEFAULT NULL, - datec datetime, -- date de creation - - fk_contrat integer DEFAULT 0, -- contrat auquel est rattache la fiche - fk_user_author integer, -- createur - fk_projet integer, -- projet auquel est associe la facture - duree real, -- duree totale de l'intervention - description text, - modelpdf varchar(50), - note_private text, - note_public text, - - frequency integer, -- frequency (for example: 3 for every 3 month) - unit_frequency varchar(2) DEFAULT 'm', -- 'm' for month (date_when must be a day <= 28), 'y' for year, ... - date_when datetime DEFAULT NULL, -- date for next gen (when an invoice is generated, this field must be updated with next date) - date_last_gen datetime DEFAULT NULL, -- date for last gen (date with last successfull generation of invoice) - nb_gen_done integer DEFAULT NULL, -- nb of generation done (when an invoice is generated, this field must incremented) - nb_gen_max integer DEFAULT NULL, -- maximum number of generation - auto_validate integer NULL DEFAULT NULL -- statut of the generated intervention - -)ENGINE=innodb; From 17016d03fe5b68793f307f1df738126569054159 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 28 May 2018 16:40:36 +0200 Subject: [PATCH 030/228] Create llx_fichinter_rec.sql --- .../mysql/tables/llx_fichinter_rec.sql | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_fichinter_rec.sql diff --git a/htdocs/install/mysql/tables/llx_fichinter_rec.sql b/htdocs/install/mysql/tables/llx_fichinter_rec.sql new file mode 100644 index 00000000000..10dacbde4ee --- /dev/null +++ b/htdocs/install/mysql/tables/llx_fichinter_rec.sql @@ -0,0 +1,48 @@ +-- =========================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2012-2014 Laurent Destailleur +-- Copyright (C) 2009 Regis Houssin +-- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2018 Charlene Benke +-- +-- 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 . +-- +-- =========================================================================== + +create table llx_fichinter_rec +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + titre varchar(50) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_soc integer DEFAULT NULL, + datec datetime, -- date de creation + + fk_contrat integer DEFAULT 0, -- contrat auquel est rattache la fiche + fk_user_author integer, -- createur + fk_projet integer, -- projet auquel est associe la facture + duree real, -- duree totale de l'intervention + description text, + modelpdf varchar(50), + note_private text, + note_public text, + + frequency integer, -- frequency (for example: 3 for every 3 month) + unit_frequency varchar(2) DEFAULT 'm', -- 'm' for month (date_when must be a day <= 28), 'y' for year, ... + date_when datetime DEFAULT NULL, -- date for next gen (when an invoice is generated, this field must be updated with next date) + date_last_gen datetime DEFAULT NULL, -- date for last gen (date with last successfull generation of invoice) + nb_gen_done integer DEFAULT NULL, -- nb of generation done (when an invoice is generated, this field must incremented) + nb_gen_max integer DEFAULT NULL, -- maximum number of generation + auto_validate integer NULL DEFAULT NULL -- statut of the generated intervention + +)ENGINE=innodb; From 0b7342f34b833f2376f61241f0dc8c993cd9a7eb Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 28 May 2018 16:41:45 +0200 Subject: [PATCH 031/228] Create llx_fichinter_rec.key.sql --- .../mysql/tables/llx_fichinter_rec.key.sql | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_fichinter_rec.key.sql diff --git a/htdocs/install/mysql/tables/llx_fichinter_rec.key.sql b/htdocs/install/mysql/tables/llx_fichinter_rec.key.sql new file mode 100644 index 00000000000..0c420fd6395 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_fichinter_rec.key.sql @@ -0,0 +1,30 @@ +-- ============================================================================ +-- Copyright (C) 2002-2004 Rodolphe Quiedeville +-- Copyright (C) 2004-2006 Laurent Destailleur +-- Copyright (C) 2009 Regis Houssin +-- Copyright (C) 2018 Charlene Benke +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + + +ALTER TABLE llx_fichinter_rec ADD UNIQUE INDEX idx_fichinter_rec_uk_titre (titre, entity); + +ALTER TABLE llx_fichinter_rec ADD INDEX idx_fichinter_rec_fk_soc (fk_soc); +ALTER TABLE llx_fichinter_rec ADD INDEX idx_fichinter_rec_fk_user_author (fk_user_author); +ALTER TABLE llx_fichinter_rec ADD INDEX idx_fichinter_rec_fk_projet (fk_projet); + +ALTER TABLE llx_fichinter_rec ADD CONSTRAINT fk_fichinter_rec_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); +ALTER TABLE llx_fichinter_rec ADD CONSTRAINT fk_fichinter_rec_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); From a85ba00d2e5bdf7c387c7f204289eb1aea777a58 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 28 May 2018 16:42:19 +0200 Subject: [PATCH 032/228] Create llx_fichinterdet_rec.sql --- .../mysql/tables/llx_fichinterdet_rec.sql | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_fichinterdet_rec.sql diff --git a/htdocs/install/mysql/tables/llx_fichinterdet_rec.sql b/htdocs/install/mysql/tables/llx_fichinterdet_rec.sql new file mode 100644 index 00000000000..682453f2dfd --- /dev/null +++ b/htdocs/install/mysql/tables/llx_fichinterdet_rec.sql @@ -0,0 +1,63 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2009-2014 Laurent Destailleur +-- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2010-2012 Regis Houssin +-- Copyright (C) 2012 Cédric Salvador +-- Copyright (C) 2016-2018 Charlene Benke +-- +-- 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 . +-- +-- =================================================================== + +create table llx_fichinterdet_rec +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_fichinter integer NOT NULL, + date datetime, -- date de la ligne d'intervention + description text, -- description de la ligne d'intervention + duree integer, -- duree de la ligne d'intervention + rang integer DEFAULT 0, -- ordre affichage sur la fiche + total_ht DOUBLE(24, 8) NULL DEFAULT NULL, + subprice DOUBLE(24, 8) NULL DEFAULT NULL, + fk_parent_line integer NULL DEFAULT NULL, + fk_product integer NULL DEFAULT NULL, + label varchar(255) NULL DEFAULT NULL, + tva_tx DOUBLE(6, 3) NULL DEFAULT NULL, + localtax1_tx DOUBLE(6, 3) NULL DEFAULT 0, + localtax1_type VARCHAR(1) NULL DEFAULT NULL, + localtax2_tx DOUBLE(6, 3) NULL DEFAULT 0, + localtax2_type VARCHAR(1) NULL DEFAULT NULL, + qty double NULL DEFAULT NULL, + remise_percent double NULL DEFAULT 0, + remise double NULL DEFAULT 0, + fk_remise_except integer NULL DEFAULT NULL, + price DOUBLE(24, 8) NULL DEFAULT NULL, + total_tva DOUBLE(24, 8) NULL DEFAULT NULL, + total_localtax1 DOUBLE(24, 8) NULL DEFAULT 0, + total_localtax2 DOUBLE(24, 8) NULL DEFAULT 0, + total_ttc DOUBLE(24, 8) NULL DEFAULT NULL, + product_type INTEGER NULL DEFAULT 0, + date_start datetime NULL DEFAULT NULL, + date_end datetime NULL DEFAULT NULL, + info_bits INTEGER NULL DEFAULT 0, + buy_price_ht DOUBLE(24, 8) NULL DEFAULT 0, + fk_product_fournisseur_price integer NULL DEFAULT NULL, + fk_code_ventilation integer NOT NULL DEFAULT 0, + fk_export_commpta integer NOT NULL DEFAULT 0, + special_code integer UNSIGNED NULL DEFAULT 0, + fk_unit integer NULL DEFAULT NULL, + import_key varchar(14) NULL DEFAULT NULL + +)ENGINE=innodb; From 0e7c82af95fdb0055fa7622439fa1f71ebc644f5 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 28 May 2018 16:43:23 +0200 Subject: [PATCH 033/228] Update eldy.lib.php --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 448d3d4870c..876780c1243 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -784,7 +784,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 2200); $newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201); $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202); - + $newmenu->add("/fichinter/card-red.php?leftmenu=ficheinter", $langs->trans("ModelList"), 1, $user->rights->ficheinter->lire, '', '', '', 203); $newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire); } From 991c6d97c07a9626a34ee3a8f2e36d9f427b2a25 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 28 May 2018 16:44:49 +0200 Subject: [PATCH 034/228] Update card.php --- htdocs/fichinter/card.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 540f897ffe5..dbd1d3bd71b 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2011-2017 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2018 Ferran Marcet - * Copyright (C) 2014-2015 Charlie Benke + * Copyright (C) 2014-2018 Charlene Benke * Copyright (C) 2015-2016 Abbes Bahfir * * This program is free software; you can redistribute it and/or modify @@ -1645,6 +1645,14 @@ else if ($id > 0 || ! empty($ref)) else print ''; } + // create interventional model + if ($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) { + print ''; + } + // Proposal if ($conf->service->enabled && ! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) { From 7f8132e9715c138c987174fefdec9855e9874330 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 28 May 2018 16:46:34 +0200 Subject: [PATCH 035/228] Create card-rec.php --- htdocs/fichinter/card-rec.php | 976 ++++++++++++++++++++++++++++++++++ 1 file changed, 976 insertions(+) create mode 100644 htdocs/fichinter/card-rec.php diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php new file mode 100644 index 00000000000..96d7e106b5a --- /dev/null +++ b/htdocs/fichinter/card-rec.php @@ -0,0 +1,976 @@ + + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016-2018 Charlie Benke + * + * 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 fichinter/card-rec.php + * \ingroup fichinter + * \brief Page to show predefined fichinter + */ + +$res=0; +if (! $res && file_exists("../../main.inc.php")) + $res=@include("../../main.inc.php"); // For root directory +if (! $res && file_exists("../../../main.inc.php")) + $res=@include("../../../main.inc.php"); // For "custom" directory + +require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinterrec.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; + +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +if (! empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +} +if (! empty($conf->contrat->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcontract.class.php'; +} + + +$langs->load('bills'); +$langs->load('compta'); +$langs->load('admin'); +$langs->load("interventions"); + +// Security check +$id=(GETPOST('fichinterid', 'int')?GETPOST('fichinterid', 'int'):GETPOST('id', 'int')); +$action=GETPOST('action', 'alpha'); +if ($user->societe_id) $socid=$user->societe_id; +$objecttype = 'fichinter_rec'; +if ($action == "create" || $action == "add") $objecttype = ''; +$result = restrictedArea($user, 'ficheinter', $id, $objecttype); + +if ($page == -1) + $page = 0 ; + +$limit = GETPOST('limit')?GETPOST('limit', 'int'):$conf->liste_limit; +$offset = $limit * $page ; + +if ($sortorder == "") + $sortorder="DESC"; + +if ($sortfield == "") + $sortfield="f.datec"; + +$object = new FichinterRec($db); + + +$arrayfields=array( + 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), + 'f.fk_contrat'=>array('label'=>$langs->trans("Contract"), 'checked'=>1), + 'f.duree'=>array('label'=>$langs->trans("Duration"), 'checked'=>1), + 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), + 'f.frequency'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), + 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1), + 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1), + 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1), + 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), +); + + +/* + * Actions + */ + + +// Create predefined intervention +if ($action == 'add') { + if (! GETPOST('titre')) { + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors'); + $action = "create"; + $error++; + } + + if (! GETPOST('socid')) { + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Customer")), null, 'errors'); + $action = "create"; + $error++; + } + + // gestion des fréquences et des échéances + $frequency=GETPOST('frequency', 'int'); + $reyear=GETPOST('reyear'); + $remonth=GETPOST('remonth'); + $reday=GETPOST('reday'); + $rehour=GETPOST('rehour'); + $remin=GETPOST('remin'); + $nb_gen_max = (GETPOST('nb_gen_max', 'int')?GETPOST('nb_gen_max', 'int'):0); + if (GETPOST('frequency')) { + if (empty($reyear) || empty($remonth) || empty($reday)) { + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); + $action = "create"; + $error++; + } + if ($nb_gen_max === '') { + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("MaxPeriodNumber")), null, 'errors'); + $action = "create"; + $error++; + } + } + + if (! $error) { + $object->id_origin = $id; + $object->titre = GETPOST('titre', 'alpha'); + $object->description = GETPOST('description', 'alpha'); + $object->socid = GETPOST('socid', 'alpha'); + $object->fk_project = GETPOST('projectid', 'int'); + $object->fk_contract = GETPOST('contractid', 'int'); + + $object->frequency = $frequency; + $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); + $object->nb_gen_max = $nb_gen_max; + $object->auto_validate = GETPOST('auto_validate', 'int'); + + $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); + $object->date_when = $date_next_execution; + + if ($object->create($user) > 0) { + $id = $object->id; + $action = ''; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; + } + } +} elseif ($action == 'createfrommodel') { + $newinter = new fichinter($db); + + // on récupère les enregistrements + $object->fetch($id); + + + // on transfert les données de l'un vers l'autre + if ($object->socid > 0) { + $newinter->socid=$object->socid; + $newinter->fk_projet=$object->fk_projet; + $newinter->fk_contrat=$object->fk_contrat; + } else + $newinter->socid=GETPOST("socid"); + + $newinter->entity=$object->entity; + $newinter->duree=$object->duree; + + $newinter->description=$object->description; + $newinter->note_private=$object->note_private; + $newinter->note_public=$object->note_public; + + // on créer un nouvelle intervention + $extrafields = new ExtraFields($db); + $extralabels = $extrafields->fetch_name_optionals_label($newinter->table_element); + $array_options = $extrafields->getOptionalsFromPost($extralabels); + $newinter->array_options = $array_options; + + $newfichinterid = $newinter->create($user); + + if ($newfichinterid > 0) { + // on ajoute les lignes de détail ensuite + foreach ($object->lines as $ficheinterligne) + $newinter->addline($user, $newfichinterid, $ficheinterligne->desc, "", $ficheinterligne->duree, ''); + + // on update le nombre d'inter crée à partir du modèle + $object->updateNbGenDone(); + //on redirige vers la fiche d'intervention nouvellement crée + header('Location: '.DOL_URL_ROOT.'/fichinter/card.php?id='.$newfichinterid); + exit; + } else { + setEventMessages($newinter->error, $newinter->errors, 'errors'); + $action=''; + } +} elseif ($action == 'delete' && $user->rights->ficheinter->supprimer) { + // delete modele + $object->fetch($id); + $object->delete(); + $id = 0 ; + header('Location: '.$_SERVER["PHP_SELF"]); + exit; +} elseif ($action == 'setfrequency' && $user->rights->ficheinter->creer) { + // Set frequency and unit frequency + $object->fetch($id); + $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); +} elseif ($action == 'setdate_when' && $user->rights->ficheinter->creer) { + // Set next date of execution + $object->fetch($id); + $date = dol_mktime( + GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, + GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear') + ); + if (!empty($date)) $object->setNextDate($date); +} elseif ($action == 'setnb_gen_max' && $user->rights->ficheinter->creer) { +// Set max period + $object->fetch($id); + $object->setMaxPeriod(GETPOST('nb_gen_max', 'int')); +} + + +/* + * View + */ + +llxHeader('', $langs->trans("RepeatableInterventional"), 'ch-fichinter.html#s-fac-fichinter-rec'); + +$form = new Form($db); +$companystatic = new Societe($db); +if (! empty($conf->contrat->enabled)) + $contratstatic = new Contrat($db); +if (! empty($conf->projet->enabled)) + $projectstatic = new Project($db); + +$now = dol_now(); +$tmparray=dol_getdate($now); +$today = dol_mktime( + 23, 59, 59, + $tmparray['mon'], $tmparray['mday'], $tmparray['year'] +); // Today is last second of current day + + + +/* + * Create mode + */ +if ($action == 'create') { + print load_fiche_titre($langs->trans("CreateRepeatableIntervention"), '', 'title_commercial.png'); + + $object = new Fichinter($db); // Source invoice + //$object = new Managementfichinter($db); // Source invoice + + if ($object->fetch($id, $ref) > 0) { + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + $rowspan=4; + if (! empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++; + if (! empty($conf->contrat->enabled) && $object->fk_contrat > 0) $rowspan++; + + print ''; + + $object->fetch_thirdparty(); + + // Third party + print ''; + + // Title + print ''; + + // Note + print ''; + + // Author + print ""; + + if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { + // Duration + print ''; + print ''; + print ''; + } + + // Project + if (! empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); + print ""; + } + + // Contrat + if (! empty($conf->contrat->enabled)) { + $formcontract = new FormContract($db); + print ""; + } + print "
'.$langs->trans("Customer").''; + print $form->select_company($object->thirdparty->id, 'socid', '', 0, 1); + +// .$object->thirdparty->getNomUrl(1,'customer'). + print ''; + print $langs->trans("Comment"); + print '
'.$langs->trans("Title").''; + print ''; + print ''; + print ''; + print '
".$langs->trans("Author")."".$user->getFullName($langs)."
'.$langs->trans("TotalDuration").''.convertSecondToTime( + $object->duration, 'all', + $conf->global->MAIN_DURATION_OF_WORKDAY + ).'
".$langs->trans("Project").""; + $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project; + + $numprojet = $formproject->select_projects( + $object->thirdparty->id, $projectid, 'projectid', + 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '' + ); + print '   '; + print $langs->trans("AddProject").''; + print "
".$langs->trans("Contract").""; + $contractid = GETPOST('contractid')?GETPOST('contractid'):$object->fk_contract; + $numcontract = $formcontract->select_contract($object->thirdparty->id, $contractid, 'contracttid'); + print "
"; + + print '

'; + + /// frequency & duration + // Autogeneration + $title = $langs->trans("Recurrence"); + print load_fiche_titre($title, '', 'calendar'); + + print ''; + + // Frequency + print '"; + + // First date of execution for cron + print ""; + + // Number max of generation + print ""; + + print "
'; + print $form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency')); + print ""; + print " "; + print $form->selectarray( + 'unit_frequency', + array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), + (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m') + ); + print "
".$langs->trans('NextDateToExecution').""; + if ($date_next_execution != "") + $date_next_execution = (GETPOST('remonth') ? dol_mktime( + 12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear') + ) : -1); + print $form->select_date($date_next_execution, '', 1, 1, '', "add", 1, 1, 1); + print "
".$langs->trans("MaxPeriodNumber").""; + print ''; + print "
"; + + print '
'; + + $title = $langs->trans("ProductsAndServices"); + if (empty($conf->service->enabled)) + $title = $langs->trans("Products"); + else if (empty($conf->product->enabled)) + $title = $langs->trans("Services"); + + print load_fiche_titre($title, '', ''); + + /* + * Invoice lines + */ + print ''; + print ''; + + print "
'; + + $sql = 'SELECT l.*'; + $sql.= " FROM ".MAIN_DB_PREFIX."fichinterdet as l"; + $sql.= " WHERE l.fk_fichinter= ".$object->id; + $sql.= " AND l.fk_product is null "; + $sql.= " ORDER BY l.rang"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; $total = 0; + + echo ''; + if ($num) { + print ''; + print ''; + print ''; + print "\n"; + } + $var=true; + while ($i < $num) { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; + + // Show product and description + + print ''; + print ""; + + $i++; + } + $db->free($result); + + } else + print $db->error(); + print "
'.$langs->trans("Description").''.$langs->trans("Duration").'
'; + print ''; // ancre pour retourner sur la ligne + + $text = img_object($langs->trans('Service'), 'service'); + + print $text.' '.nl2br($objp->description); + + // Qty + print ''.convertSecondToTime($objp->duree).'
"; + + print '
\n"; + + dol_fiche_end(); + + print '
'; + print '     '; + print ''; + print '
'; + print "
\n"; + } + else + dol_print_error('', "Error, no invoice ".$object->id); + +} elseif ($action == 'selsocforcreatefrommodel') { + print load_fiche_titre($langs->trans("CreateRepeatableIntervention"), '', 'title_commercial.png'); + dol_fiche_head(''); + + print '
'; + print ''; + print ''; + print '
'.$langs->trans("ThirdParty").''; + print $form->select_company('', 'socid', '', 1, 1); + print '
'; + + dol_fiche_end(); + + print '
'; + print ''; + print ''; + print ''; + print '
'; + + print '
'; +} else { + /* + * View mode + * + */ + if ($id > 0) { + if ($object->fetch($id) > 0) { + $object->fetch_thirdparty(); + + $author = new User($db); + $author->fetch($object->user_author); + + $head = fichinter_rec_prepare_head($object); + + dol_fiche_head($head, 'card', $langs->trans("PredefinedInterventional"), 0, 'intervention'); + + // Intervention card + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref='
'; + // Thirdparty + + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->ficheinter->creer) { + if ($action != 'classify') { + $morehtmlref.=''; + $morehtmlref.=img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + } + if ($action == 'classify') { + + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects( + $object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1 + ); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project( + $_SERVER['PHP_SELF'].'?id='.$object->id, + $object->socid, $object->fk_project, + 'none', 0, 0, 0, 1 + ); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.='trans('ShowProject').'">'; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + print '
'; + + print ''; + + print ""; + + if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { + // Duration + print ''; + print ''; + } + + print '"; + + // Contrat + if (! empty($conf->contrat->enabled)) { + $langs->load('contrat'); + print ''; + print ''; + print ''; + + } + print "
".$langs->trans("Author").''.$author->getFullName($langs)."
'.$langs->trans("TotalDuration").''; + print convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + print '
'.$langs->trans("Description").''.nl2br($object->description)."
'; + + print ''; + if ($action != 'contrat') { + print ''; + } + print '
'; + print $langs->trans('Contract'); + print 'id.'">'; + print img_edit($langs->trans('SetContract'), 1); + print '
'; + print '
'; + if ($action == 'contrat') { + $formcontract= new Formcontract($db); + $formcontract->formSelectContract( + $_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, + $object->fk_contrat, 'contratid', 0, 1 + ); + } else { + if ($object->fk_contrat) { + $contratstatic = new Contrat($db); + $contratstatic->fetch($object->fk_contrat); + print $contratstatic->getNomUrl(0, '', 1); + } else + print " "; + + } + print '
"; + print '
'; + + print '
'; + print '
'; + print '
'; + + print ''; + + $title = $langs->trans("Recurrence"); + print load_fiche_titre($title, '', 'calendar'); + + print '
'; + + // if "frequency" is empty or = 0, the reccurence is disabled + print ''; + + // Date when + print ''; + print ''; + + // Max period / Rest period + print ''; + print ''; + + print '
'; + print ''; + if ($action != 'editfrequency' && $user->rights->ficheinter->creer) { + print ''; + } + print '
'; + print $langs->trans('Frequency'); + print ''; + print img_edit($langs->trans('Edit'), 1) . '
'; + print '
'; + if ($action == 'editfrequency') { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print " "; + print $form->selectarray( + 'unit_frequency', + array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), + ($object->unit_frequency?$object->unit_frequency:'m') + ); + print '
'; + } else { + if ($object->frequency > 0) + print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); + else + print $langs->trans("NotARecurringInterventionalTemplate"); + } + print '
'; + if ( $user->rights->ficheinter->creer && ($action == 'date_when' || $object->frequency > 0)) { + print $form->editfieldkey( + $langs->trans("NextDateToExecution"), 'date_when', $object->date_when, + $object, $user->rights->facture->creer, 'day' + ); + } else { + print $langs->trans("NextDateToExecution"); + } + print ''; + if ($action == 'date_when' || $object->frequency > 0) { + print $form->editfieldval( + $langs->trans("NextDateToExecution"), 'date_when', $object->date_when, + $object, $user->rights->facture->creer, 'day' + ); + } + print '
'; + if ($user->rights->ficheinter->creer && ($action == 'nb_gen_max' || $object->frequency > 0)) { + print $form->editfieldkey( + $langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, + $object, $user->rights->facture->creer + ); + } else + print $langs->trans("MaxPeriodNumber"); + + print ''; + if ($action == 'nb_gen_max' || $object->frequency > 0) { + print $form->editfieldval( + $langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', + $object, $user->rights->facture->creer + ); + } + else + print ''; + + print '
'; + + // Frequencry/Recurring section + if ($object->frequency > 0) { + print '
'; + if (empty($conf->cron->enabled)) { + $txtinfoadmin=$langs->trans( + "EnableAndSetupModuleCron", + $langs->transnoentitiesnoconv("Module2300Name") + ); + print info_admin($txtinfoadmin); + } + print '
'; + print ''; + + // Nb of generation already done + print ''; + print ''; + print ''; + + // Date last + print ''; + print ''; + print '
'.$langs->trans("NbOfGenerationDone").''; + print $object->nb_gen_done?$object->nb_gen_done:'0'; + print '
'; + print $langs->trans("DateLastGeneration"); + print ''; + print dol_print_date($object->date_last_gen, 'dayhour'); + print '
'; + print '
'; + } + + print '
'; + print '
'; + print '
'; + + print '

'; + + /* + * Lines + */ + + $title = $langs->trans("ProductsAndServices"); + if (empty($conf->service->enabled)) + $title = $langs->trans("Products"); + else if (empty($conf->product->enabled)) + $title = $langs->trans("Services"); + + print load_fiche_titre($title); + + print ''; + print ''; + print ''; + print ''; + print ''; + + $num = count($object->lines); + $i = 0; + $var=true; + while ($i < $num) { + $var=!$var; + + // Show product and description + if (isset($object->lines[$i]->product_type)) + $type=$object->lines[$i]->product_type; + else + $object->lines[$i]->fk_product_type; + // Try to enhance type detection using date_start and date_end for free lines when type + // was not saved. + if (! empty($objp->date_start)) $type=1; + if (! empty($objp->date_end)) $type=1; + + // Show line + print ""; + print ''; + + print ''; + print "\n"; + $i++; + } + print '
'.$langs->trans("Description").''.$langs->trans("Duration").'
'; + $text = img_object($langs->trans('Service'), 'service'); + print $text.' '.nl2br($object->lines[$i]->desc); + print ''.convertSecondToTime($object->lines[$i]->duree).'
'; + + /** + * Barre d'actions + */ + print '
'; + + if ($user->rights->ficheinter->creer) { + print ''; + } + + if ($user->rights->ficheinter->supprimer) { + print ''; + } + print '
'; + } else + print $langs->trans("ErrorRecordNotFound"); + + } else { + /* + * List mode + */ + $sql = "SELECT f.rowid as fich_rec, s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, "; + $sql.= " f.duree, f.fk_contrat, f.fk_projet, f.frequency, f.nb_gen_done, f.nb_gen_max,"; + $sql.= " f.date_last_gen, f.date_when, f.datec"; + + $sql.= " FROM ".MAIN_DB_PREFIX."fichinter_rec as f"; + $sql.= " , ".MAIN_DB_PREFIX."societe as s "; + if (! $user->rights->societe->client->voir && ! $socid) { + $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql.= " WHERE f.fk_soc = s.rowid"; + $sql.= " AND f.entity = ".$conf->entity; + if ($socid) $sql .= " AND s.rowid = ".$socid; + if (! $user->rights->societe->client->voir && ! $socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($search_ref) $sql .= natural_search('f.titre', $search_ref); + if ($search_societe) $sql .= natural_search('s.nom', $search_societe); + if ($search_frequency == '1') $sql.= ' AND f.frequency > 0'; + if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)'; + + + //$sql .= " ORDER BY $sortfield $sortorder, rowid DESC "; + // $sql .= $db->plimit($limit + 1, $offset); + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + print_barre_liste( + $langs->trans("RepeatableInterventional"), $page, + $_SERVER['PHP_SELF'], "&socid=$socid", $sortfield, $sortorder, + '', $num, '', 'title_commercial.png' + ); + + print $langs->trans("ToCreateAPredefinedInterventional").'

'; + + $i = 0; + print ''; + print ''; + print_liste_field_titre( + $langs->trans("Ref"), $_SERVER['PHP_SELF'], "f.titre", "", "", + 'width="200px" align="left"', $sortfiled, $sortorder + ); + + print_liste_field_titre( + $langs->trans("Company"), $_SERVER['PHP_SELF'], "s.nom", "", "", + 'width="200px" align="left"', $sortfiled, $sortorder + ); + if (! empty($conf->contrat->enabled)) + print_liste_field_titre( + $langs->trans("Contract"), $_SERVER['PHP_SELF'], + "f.fk_contrat", "", "", + 'width="100px" align="left"', $sortfiled, $sortorder + ); + + if (! empty($conf->projet->enabled)) + print_liste_field_titre( + $langs->trans("Project"), $_SERVER['PHP_SELF'], + "f.fk_project", "", "", + 'width="100px" align="left"', $sortfiled, $sortorder + ); + print_liste_field_titre( + $langs->trans("Duration"), $_SERVER['PHP_SELF'], + 'f.duree', '', '', + 'width="50px" align="right"', $sortfiled, $sortorder + ); + // Recurring or not + print_liste_field_titre( + $langs->trans("Frequency"), $_SERVER['PHP_SELF'], + "f.frequency", "", "", + 'width="100px" align="center"', $sortfiled, $sortorder + ); + print_liste_field_titre( + $langs->trans("NbOfGenerationDone"), $_SERVER['PHP_SELF'], + "f.nb_gen_done", "", "", + 'width="100px" align="center"', $sortfiled, $sortorder + ); + + print_liste_field_titre( + $langs->trans("DateLastGeneration"), $_SERVER['PHP_SELF'], + "f.date_last_gen", "", "", + 'width="100px" align="center"', $sortfiled, $sortorder + ); + print_liste_field_titre( + $langs->trans("NextDateToIntervention"), $_SERVER['PHP_SELF'], + "f.date_when", "", "", + 'width="100px" align="center"', $sortfiled, $sortorder + ); + print ''; + print "\n"; + + +// les filtres à faire ensuite + + if ($num > 0) { + $var=true; + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($resql); + $var=!$var; + + print ""; + print '\n"; + if ($objp->socid) { + $companystatic->id=$objp->socid; + $companystatic->name=$objp->name; + print ''; + } else + print ''; + + if (! empty($conf->contrat->enabled)) { + print ''; + } + if (! empty($conf->projet->enabled)) { + print ''; + } + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + } else { + print ''.$langs->trans('NA').''; + print ''; + print ''; + print ''; + } + + if ($user->rights->ficheinter->creer) { + // Action column + print '"; + + print "\n"; + $i++; + } + } + } else + print ''; + + print "
'; + print img_object($langs->trans("ShowIntervention"), "intervention").' '.$objp->titre; + print "'.$companystatic->getNomUrl(1, 'customer').''.$langs->trans("None").''; + if ($objp->fk_contrat >0) { + $contratstatic->fetch($objp->fk_contrat); + print $contratstatic->getNomUrl(1); + } + print ''; + if ($objp->fk_project >0) { + $projectstatic->fecth($objp->fk_projet); + print $projectstatic->getNomUrl(1); + } + print ''.convertSecondToTime($objp->duree).''.yn($objp->frequency?1:0).''; + if ($objp->frequency) { + print $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') ; + print ''; + print dol_print_date($db->jdate($objp->date_last_gen), 'day') ; + print ''; + print dol_print_date($db->jdate($objp->date_when), 'day'); + print ''; + print ''.$langs->trans('NA').''; + print ''; + print ''.$langs->trans('NA').''; + print ''; + if ($user->rights->ficheinter->creer) { + if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { + print ''; + print $langs->trans("CreateFichInter").''; + } else + print $langs->trans("DateIsNotEnough"); + } else + print " "; + + print "
'.$langs->trans("NoneF").'
"; + $db->free($resql); + } else + dol_print_error($db); + } +} +llxFooter(); +$db->close(); From e0c1e330125287e719cd96cd27f09529d50474c7 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Wed, 30 May 2018 00:20:31 +0200 Subject: [PATCH 036/228] NEW: ADD url to see the last version of a external module --- htdocs/admin/modules.php | 9 ++++++++- .../template/core/modules/modMyModule.class.php | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 10a9ccb5fc3..4b9de2568c7 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -7,7 +7,8 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Raphaël Doursenaud - * + * Copyright (C) 2018 Nicolas ZABOURI + * * 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 @@ -666,6 +667,12 @@ if ($mode == 'common') // Version print ''; print $versiontrans; + if (!empty($objMod->url_last_version)) { + $newversion = file_get_contents($objMod->url_last_version); + if (version_compare($newversion, $versiontrans) > 0) { + print " $newversion"; + } + } print "\n"; // Activate/Disable and Setup (2 columns) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 0ca707daa1c..1a3d8569dc8 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -73,6 +74,9 @@ class modMyModule extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' $this->version = '1.0'; + + //Url to the file with your last numberversion of this module + $this->url_last_version = 'http://www.example.com/versionmodule.txt'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. From 7c57b360a301476c7451c1a9f09cac440d2645c1 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Wed, 30 May 2018 13:45:17 +0200 Subject: [PATCH 037/228] Auto stash before merge of "develop" and "Dolibarr/develop" --- htdocs/modulebuilder/admin/setup.php | 159 +++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 htdocs/modulebuilder/admin/setup.php diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php new file mode 100644 index 00000000000..f84bf8989ad --- /dev/null +++ b/htdocs/modulebuilder/admin/setup.php @@ -0,0 +1,159 @@ + + * + * 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/modulebuilder/admin/setup.php + * \ingroup modulebuilder + * \brief Page setup for modulebuilder module + */ +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; + +global $conf,$langs,$user, $db; +$langs->loadLangs(array("admin", "other", "modulebuilder")); + +if (!$user->admin || empty($conf->modulebuilder->enabled)) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + +/* + * Actions + */ +if($action=="update"){ + $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README'), 'chaine', 0, '', $conf->entity); + if ($res1 < 0) + { + setEventMessages('ErrorFailedToSaveDate', null, 'errors'); + $db->rollback(); + } + else + { + setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); + $db->commit(); + } +} + +if (preg_match('/set_(.*)/', $action, $reg)) { + $code = $reg[1]; + $values = GETPOST($code); + if (is_array($values)) + $values = implode(',', $values); + + if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } +} + +if (preg_match('/del_(.*)/', $action, $reg)) { + $code = $reg[1]; + if (dolibarr_del_const($db, $code, 0) > 0) { + Header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } +} + + +/* + * View + */ + +$form = new Form($db); + +llxHeader('', $langs->trans("ModulebuilderSetup")); + +$linkback = ''; +if (GETPOST('withtab', 'alpha')) { + $linkback = '' . $langs->trans("BackToModuleList") . ''; +} + +print load_fiche_titre($langs->trans("ModuleSetup") . ' ' . $langs->trans('Modulebuilder'), $linkback); + +if (GETPOST('withtab', 'alpha')) { + dol_fiche_head($head, 'modulebuilder', '', -1); +} + + +print '' . $langs->trans("ModuleBuilderDesc") . "
\n"; + +print '
'; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + +print ''; +print ''; +print ''; + + + +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; +print ''; +print '
' . $langs->trans("Key") . '' . $langs->trans("Value") . '
' . $langs->trans("UseAboutPage") . ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MODULEBUILDER_USE_ABOUT'); +} else { + if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) { + print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + } else { + print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + } +} +print '
' . $langs->trans("UseDocFolder") . ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MODULEBUILDER_USE_DOCFOLDER'); +} else { + if (empty($conf->global->MODULEBUILDER_USE_DOCFOLDER)) { + print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + } else { + print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + } +} +print '
' . $langs->trans("UseSpecificReadme") . ''; +print ''; +print '
'; +print ''; +print '
'; + +if (GETPOST('withtab', 'alpha')) { + dol_fiche_end(); +} + +print '

'; + +llxFooter(); +$db->close(); From 78b3067de352644dd00359a691d64e4258be98d2 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Wed, 30 May 2018 13:54:43 +0200 Subject: [PATCH 038/228] NEW: ADD admin page for modulebuilder ADD custom README ADD choice to generate about page and documentation folder --- htdocs/core/modules/modModuleBuilder.class.php | 3 ++- htdocs/langs/en_US/modulebuilder.lang | 5 ++++- htdocs/modulebuilder/admin/setup.php | 2 +- htdocs/modulebuilder/index.php | 12 ++++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 2c7b917d6d2..d5c333c4ade 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -59,7 +60,7 @@ class modModuleBuilder extends DolibarrModules // Config pages //------------- - $this->config_page_url = array(); + $this->config_page_url = array('setup@modulebuilder'); // Dependancies //------------- diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 6638e1fa674..ed3a872d3c6 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -94,4 +94,7 @@ YouCanUseTranslationKey=You can use here a key that is the translation key found DropTableIfEmpty=(Delete table if empty) TableDoesNotExists=The table %s does not exists TableDropped=Table %s deleted -InitStructureFromExistingTable=Build the structure array string of an existing table \ No newline at end of file +InitStructureFromExistingTable=Build the structure array string of an existing table +UseAboutPage=Disallow the about page +UseDocFolder=Disallow the documentation folder +UseSpecificReadme=Use a specific ReadMe \ No newline at end of file diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index f84bf8989ad..5bc1fb7c206 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -73,7 +73,7 @@ if (preg_match('/del_(.*)/', $action, $reg)) { } } - + /* * View */ diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index e844793b601..1d0c7960fda 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -120,6 +120,13 @@ if ($dirins && $action == 'initmodule' && $modulename) setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); } } + + if(!empty($conf->global->MODULEBUILDER_USE_ABOUT)){ + dol_delete_file($destdir.'/admin/about.php'); + } + if(!empty($conf->global->MODULEBUILDER_USE_DOCFOLDER)){ + dol_delete_dir($destdir.'/doc/'); + } // Delete some files dol_delete_file($destdir.'/myobject_card.php'); @@ -165,6 +172,11 @@ if ($dirins && $action == 'initmodule' && $modulename) setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); } } + + if(!empty($conf->global->MODULEBUILDER_SPECIFIC_README)){ + dol_delete_file($destdir.'/README.md'); + file_put_contents($destdir.'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README); + } } if (! $error) From 0f9fa09d3f0a33bc6c87cfe02e41772b21f806dd Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Thu, 31 May 2018 09:13:18 +0200 Subject: [PATCH 039/228] Fix after the comment --- htdocs/admin/modules.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 4b9de2568c7..b466a3cba54 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -667,10 +667,15 @@ if ($mode == 'common') // Version print ''; print $versiontrans; - if (!empty($objMod->url_last_version)) { - $newversion = file_get_contents($objMod->url_last_version); - if (version_compare($newversion, $versiontrans) > 0) { - print " $newversion"; + if(!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)){ + require_once(DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'); + if (!empty($objMod->url_last_version)) { + $newversion = getURLContent($objMod->url_last_version); + if(isset($newversion['content'])){ + if (version_compare($newversion['content'], $versiontrans) > 0) { + print " ".$newversion['content'].""; + } + } } } print "\n"; From 083acb1af578c7e9150b0773a1bf100ba3423ba8 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Thu, 7 Jun 2018 16:24:45 +0100 Subject: [PATCH 040/228] Added MAIN_DOCUMENTS_DESCRIPTION_FIRST option to allow desc to appear before product/service label in documents --- htdocs/core/lib/pdf.lib.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index b0cda2ecd6a..ad2b1066fbd 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1228,7 +1228,17 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl { if ($idprod) { - if (empty($hidedesc)) $libelleproduitservice.=$desc; + if (empty($hidedesc)) + { + if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) + { + $libelleproduitservice=$desc."\n".$libelleproduitservice; + } + else + { + $libelleproduitservice.=$desc; + } + } } else { From 74d92dd91f35a70cfec0c9806c02798ddc94930b Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Mon, 11 Jun 2018 23:09:12 +0100 Subject: [PATCH 041/228] New: Optiopn to see line numbers in modules page --- htdocs/admin/modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 588bdb856db..df1cd2a61f4 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -637,6 +637,7 @@ if ($mode == 'common') } print ''."\n"; + if(!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) print ''.++$linenum.''; // Picto + Name of module print ' '; From 933a6a5ba353306fc599a27c8918ed6ff487353d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Jun 2018 22:11:44 +0200 Subject: [PATCH 042/228] Update html.formcontract.class.php --- htdocs/core/class/html.formcontract.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 01ebe66666b..a3a3696e5f4 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -57,7 +57,7 @@ class FormContract global $db,$user,$conf,$langs; $hideunselectables = false; - if (! empty($conf->global->SELECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; // Search all contacts $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; From e18717aa8575bbc78ee334c3917c73dd470743e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Jun 2018 22:12:16 +0200 Subject: [PATCH 043/228] Update html.formprojet.class.php --- htdocs/core/class/html.formprojet.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 75ccc1d8245..f437920caf9 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -143,7 +143,7 @@ class FormProjets $outarray=array(); $hideunselectables = false; - if (! empty($conf->global->SELECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; $projectsListId = false; if (empty($user->rights->projet->all->lire)) @@ -318,7 +318,7 @@ class FormProjets $out=''; $hideunselectables = false; - if (! empty($conf->global->SELECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; if (empty($projectsListId)) { From 72449ddef4be0bb5150eebc04c02ef02459b7e3f Mon Sep 17 00:00:00 2001 From: atm-greg Date: Fri, 15 Jun 2018 16:55:23 +0200 Subject: [PATCH 044/228] add hooks on stock replenish --- htdocs/product/stock/replenish.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 5a61e8b2a98..27a60b09257 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -43,6 +43,9 @@ if ($user->societe_id) { } $result=restrictedArea($user,'produit|service'); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('stockreplenishlist', 'globalcard')); + //checks if a product has been ordered $action = GETPOST('action','alpha'); @@ -87,6 +90,9 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) $usevirtualstock=0; if ($mode == 'virtual') $usevirtualstock=1; +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); /* * Actions @@ -670,6 +676,11 @@ while ($i < ($limit ? min($num, $limit) : $num)) } $i++; } + +$parameters=array('sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + print ''; print ''; From 2cdae2ec98d09f15f9c5e18e658d183b82d77085 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 18 Jun 2018 11:30:38 +0200 Subject: [PATCH 045/228] remove globalcard context --- htdocs/product/stock/replenish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 27a60b09257..b2386c4b8a1 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -44,7 +44,7 @@ if ($user->societe_id) { $result=restrictedArea($user,'produit|service'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('stockreplenishlist', 'globalcard')); +$hookmanager->initHooks(array('stockreplenishlist')); //checks if a product has been ordered From 3b33dad8fdb41cdb09f77aade27c98f437cae4ee Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Wed, 20 Jun 2018 14:40:32 +0200 Subject: [PATCH 046/228] Add supplier ref Hi In all common case the supplier send a receipt with the parcel on which is writen his product ref (because this is his reference) with the quantity in the parcel and if he is smart/nice our reference. By adding the supplier ref column the supplier order dispatch is easier. Tks. --- htdocs/fourn/commande/dispatch.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 5b4adc39638..2c4fbe9e799 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -492,7 +492,7 @@ if ($id > 0 || ! empty($ref)) { $db->free($resql); } - $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, SUM(l.qty) as qty,"; + $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, SUM(l.qty) as qty, l.ref AS sref,"; $sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse"; $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid"; @@ -514,6 +514,7 @@ if ($id > 0 || ! empty($ref)) { print ''; print ''; print ''; + print '' . $langs->trans("SupplierRef") . ''; print '' . $langs->trans("QtyOrdered") . ''; print '' . $langs->trans("QtyDispatchedShort") . ''; print '' . $langs->trans("QtyToDispatchShort") . ''; @@ -590,6 +591,9 @@ if ($id > 0 || ! empty($ref)) { if (! empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc = price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU'); + // Supplier ref + print ''.$objp->sref.''; + // Qty ordered print '' . $objp->qty . ''; From 668608db5ee389e46cdf485892dda39cbdd00602 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Jun 2018 18:26:44 +0200 Subject: [PATCH 047/228] Fix error message with old usage of childtables --- htdocs/core/class/commonobject.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 97942687fe4..a165704c058 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3322,7 +3322,14 @@ abstract class CommonObject $langs->load("errors"); //print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild; $haschild += $obj->nb; - $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname)); + if (is_numeric($elementname)) // old usage + { + $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table); + } + else // new usage: $elementname=Translation key + { + $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname)); + } break; // We found at least one, we stop here } } From a0e97c7640cdb7393f6ab67d7256c88c1935508e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Jun 2018 01:31:53 +0200 Subject: [PATCH 048/228] Option to solve autovalidation --- htdocs/contrat/class/contrat.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 24fbabb7772..640793b7f37 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -407,7 +407,10 @@ class Contrat extends CommonObject $this->fetch_thirdparty(); // A contract is validated so we can move thirdparty to status customer - $result=$this->thirdparty->set_as_client(); + if (empty($conf->global->CONTRACT_DISABLE_AUTOSET_AS_CLIENT_ON_CONTRACT_VALIDATION)) + { + $result=$this->thirdparty->set_as_client(); + } // Define new ref if ($force_number) From 62f2108101b98d50853cde4617a41f85817858d9 Mon Sep 17 00:00:00 2001 From: "STAGIAIRE-PC\\Pierre" Date: Wed, 27 Jun 2018 10:33:57 +0200 Subject: [PATCH 049/228] ajout de la gestion des comptes bancaires des tiers via l'api --- .../societe/class/api_thirdparties.class.php | 172 ++++++++++++++++++ .../class/companybankaccount.class.php | 57 ++++++ 2 files changed, 229 insertions(+) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 73c782ddf7c..fa2c44078cd 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -996,6 +996,178 @@ class Thirdparties extends DolibarrApi return $result; } + /** + * Get CompanyBankAccount objects for thirdparty + * + * @param int $socid + * + * @return array + */ + function getCompanyBankAccount($socid){ + + global $db, $conf; + + if(! DolibarrApiAccess::$user->rights->facture->lire) { + throw new RestException(401); + } + if(empty($socid)) { + throw new RestException(400, 'Thirdparty ID is mandatory'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$socid)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + /** + * On requete sur tous les enregistrements qui ont comme fk_soc, la société passée en paramètre + */ + + $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; + $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($socid) $sql.= " WHERE fk_soc = ".$socid." "; + + + $result = $db->query($sql); + + if($result->num_rows == 0 ){ + throw new RestException(404, 'Account not found'); + } + + $i=0; + + $accounts =[]; + + if ($result) + { + $num = $db->num_rows($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); + $account = new CompanyBankAccount($db); + if($account->fetch($obj->rowid)) { + $accounts[] = $account; + } + $i++; + } + } + else{ + throw new RestException(404, 'Account not found'); + } + + + $fields = ['socid', 'default_rib', 'frstrecur', '1000110000001', 'datec', 'datem', 'label', 'bank', 'bic', 'iban', 'id']; + + $returnAccounts = []; + + foreach($accounts as $account){ + $object= []; + foreach($account as $key => $value) + if(in_array($key, $fields)){ + $object[$key] = $value; + + } + $returnAccounts[] = $object; + } + + return $returnAccounts; + } + + + /** + * Create CompanyBankAccount object for thirdparty + * @param int $socid id de l'entreprise + * @param array $request_data Request datas + * + * @return object ID of thirdparty + * + * @url POST {socid}/CompanyBankAccount + */ + function createCompanyBankAccount($socid, $request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + + $account = new CompanyBankAccount($this->db); + + $account->socid = $socid; + + foreach($request_data as $field => $value) { + $account->$field = $value; + } + + if ($account->create(DolibarrApiAccess::$user) < 0) + throw new RestException(500, 'Error creating Company Bank account'); + + + if ($account->update(DolibarrApiAccess::$user) < 0) + throw new RestException(500, 'Error updating values'); + + return $account; + } + + + /** + * Update CompanyBankAccount object for thirdparty + * @param int $id Id du compte + * @param int $socid + * @param array $request_data Request datas + * + * @return object ID of thirdparty + * + * @url PUT {socid}/CompanyBankAccount/{id} + */ + function updateCompanyBankAccount($socid, $id, $request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + + $account = new CompanyBankAccount($this->db); + + $account->fetchFromApi($id, $socid); + + + + if($account->socid != $socid){ + throw new RestException(401); + } + + + foreach($request_data as $field => $value) { + $account->$field = $value; + } + + if ($account->update(DolibarrApiAccess::$user) < 0) + throw new RestException(500, 'Error updating values'); + + return $account; + } + + /** + * @param int $id Id du compte + * @param int $socid Id de l'entreprise + * + * @return int -1 si erreur 1 si suppression + * + * @url DELETE {socid}/CompanyBankAccount/{id} + */ + function deleteCompanyBankAccount($id, $socid){ + + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + + $account = new CompanyBankAccount($this->db); + + $account->fetch($id); + + if(!$account->socid == $socid) + throw new RestException(401); + + return $account->delete(DolibarrApiAccess::$user); + } /** diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 187f7c5ec65..68dd8f51c3b 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -250,6 +250,63 @@ class CompanyBankAccount extends Account } } + /** + * Load record from database for the API + * + * @param int $id Id of record + * @param int $socid Id of company. If this is filled, function will return the first default RIB of company + * @return int <0 if KO, >0 if OK + */ + function fetchFromApi($id, $socid=0) + { + if (empty($id) && empty($socid)) return -1; + + $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; + $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql.= " WHERE rowid = ".$id; + if ($socid) $sql.= " AND fk_soc = ".$socid; + + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref + + $this->id = $obj->rowid; + $this->type = $obj->type; + $this->socid = $obj->fk_soc; + $this->bank = $obj->bank; + $this->code_banque = $obj->code_banque; + $this->code_guichet = $obj->code_guichet; + $this->number = $obj->number; + $this->cle_rib = $obj->cle_rib; + $this->bic = $obj->bic; + $this->iban = $obj->iban; + $this->domiciliation = $obj->domiciliation; + $this->proprio = $obj->proprio; + $this->owner_address = $obj->owner_address; + $this->label = $obj->label; + $this->default_rib = $obj->default_rib; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); + $this->rum = $obj->rum; + $this->frstrecur = $obj->frstrecur; + } + $this->db->free($resql); + + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } + /** * Delete a rib from database * From a94eeaa5005e71a41e5a413b86c22e8f5f0c3624 Mon Sep 17 00:00:00 2001 From: "STAGIAIRE-PC\\Pierre" Date: Wed, 27 Jun 2018 10:53:45 +0200 Subject: [PATCH 050/228] adding the possibility to personnalize ent_to_end and ustrd of a bank levy --- htdocs/admin/prelevement.php | 12 ++++++++++++ .../prelevement/class/bonprelevement.class.php | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 6fd40cf2825..7b7bbd8e2b4 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -221,6 +221,18 @@ print $form->select_dolusers($conf->global->PRELEVEMENT_USER, 'PRELEVEMENT_USER' print ''; print ''; +//EntToEnd +print ''.$langs->trans("END_TO_END").''; +print ''; +print ''; +print ''; + +//USTRD +print ''.$langs->trans("USTRD").''; +print ''; +print ''; +print ''; + print ''; print '
'; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 245b25be3b6..a6b0ec84317 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1575,7 +1575,8 @@ class BonPrelevement extends CommonObject $XML_DEBITOR =''; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + $XML_DEBITOR .=' '.(($conf->global->END_TO_END != "" ) ? $conf->global->END_TO_END : ('AS-'.dol_trunc($row_facnumber,20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.round($row_somme, 2).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; @@ -1607,7 +1608,8 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; // $XML_DEBITOR .=' '.($row_facnumber.'/'.$Rowing.'/'.$Rum).''.$CrLf; - $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).''.$CrLf; // 140 max + // $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).''.$CrLf; // 140 max + $XML_DEBITOR .=' '.(($conf->global->USTRD != "" ) ? $conf->global->USTRD : dol_trunc($row_facnumber, 135) ).''.$CrLf; // 140 max $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; return $XML_DEBITOR; From 8a780b3910a0c94faa5008b3127c409dfecb7805 Mon Sep 17 00:00:00 2001 From: "STAGIAIRE-PC\\Pierre" Date: Wed, 27 Jun 2018 11:01:20 +0200 Subject: [PATCH 051/228] Code refactorisation --- .../societe/class/api_thirdparties.class.php | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index fa2c44078cd..3faf2f14994 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -999,7 +999,7 @@ class Thirdparties extends DolibarrApi /** * Get CompanyBankAccount objects for thirdparty * - * @param int $socid + * @param int $socid Thirdparty id * * @return array */ @@ -1019,7 +1019,7 @@ class Thirdparties extends DolibarrApi } /** - * On requete sur tous les enregistrements qui ont comme fk_soc, la société passée en paramètre + * We select all the records that match the socid */ $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; @@ -1076,14 +1076,14 @@ class Thirdparties extends DolibarrApi /** * Create CompanyBankAccount object for thirdparty - * @param int $socid id de l'entreprise + * @param int $socid thirdparty id * @param array $request_data Request datas * * @return object ID of thirdparty * * @url POST {socid}/CompanyBankAccount */ - function createCompanyBankAccount($socid, $request_data = NULL) + function createCompanyBankAccount($socid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); @@ -1110,15 +1110,16 @@ class Thirdparties extends DolibarrApi /** * Update CompanyBankAccount object for thirdparty - * @param int $id Id du compte - * @param int $socid + * + * @param int $socid Thirdparty id + * @param int $id CompanyBankAccount's id * @param array $request_data Request datas * * @return object ID of thirdparty * * @url PUT {socid}/CompanyBankAccount/{id} */ - function updateCompanyBankAccount($socid, $id, $request_data = NULL) + function updateCompanyBankAccount($socid, $id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); @@ -1146,10 +1147,10 @@ class Thirdparties extends DolibarrApi } /** - * @param int $id Id du compte - * @param int $socid Id de l'entreprise + * @param int $id CompanyBankAccount's id + * @param int $socid Thirdparty id * - * @return int -1 si erreur 1 si suppression + * @return int -1 if error 1 if correct deletion * * @url DELETE {socid}/CompanyBankAccount/{id} */ From 19eaa3df669ade3f013ab4a897750cba0a28c952 Mon Sep 17 00:00:00 2001 From: "STAGIAIRE-PC\\Pierre" Date: Wed, 27 Jun 2018 11:29:46 +0200 Subject: [PATCH 052/228] =?UTF-8?q?ajout=20de=20la=20modification=20dans?= =?UTF-8?q?=20la=20base=20de=20donn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/prelevement.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 7b7bbd8e2b4..56e1e7f2039 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -80,6 +80,16 @@ if ($action == "set") $res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"),'chaine',0,'',$conf->entity); if (! $res > 0) $error++; } + if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END")=="") + { + $res = dolibarr_set_const($db, "END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"),'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD")=="") + { + $res = dolibarr_set_const($db, "USTRD", GETPOST("PRELEVEMENT_USTRD"),'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } if (! $error) { From a952b46d8b58c312ab3b39adb78d89dd9cb3b450 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 27 Jun 2018 12:37:31 +0200 Subject: [PATCH 053/228] clean and update code --- htdocs/install/repair.php | 1 - htdocs/livraison/card.php | 3 --- htdocs/loan/index.php | 2 -- htdocs/margin/admin/margin.php | 5 ----- htdocs/margin/agentMargins.php | 3 --- htdocs/printing/admin/printing.php | 4 ---- htdocs/product/admin/product.php | 8 -------- htdocs/product/admin/product_tools.php | 2 -- htdocs/product/canvas/product/tpl/list.tpl.php | 3 +-- htdocs/product/composition/card.php | 2 -- htdocs/product/fournisseurs.php | 3 --- htdocs/product/index.php | 4 ---- htdocs/product/stock/massstockmove.php | 4 ---- htdocs/product/stock/productlot_list.php | 2 -- htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php | 3 +-- 15 files changed, 2 insertions(+), 47 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 896d6964bdd..97f9a71bb87 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -648,7 +648,6 @@ if ($ok && GETPOST('clean_orphelin_dir','alpha')) $object_instance=new ChargeSociales($db); } - $var=true; foreach($filearray as $key => $file) { if (!is_dir($file['name']) diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index d6cefb24d83..072c53aa3cb 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -604,11 +604,8 @@ else print ''.$langs->trans("QtyReceived").''; print "\n"; } - $var=true; while ($i < $num_prod) { - - print ''; if ($object->lines[$i]->fk_product > 0) { diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index 03e3ab482f4..660189fbc9d 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -104,7 +104,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); @@ -167,7 +166,6 @@ if ($resql) $loan_static->ref = $obj->rowid; $loan_static->label = $obj->label; - $var = !$var; print ''; // Ref diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index d37dfe0c83b..eaa53aa8490 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -129,11 +129,9 @@ print ''.$langs->trans("Value").''."\n"; print ''.$langs->trans("Description").''."\n"; print ''; -$var=true; $form = new Form($db); // GLOBAL DISCOUNT MANAGEMENT - print ''; print ''; print ""; @@ -165,7 +163,6 @@ print ''; print ''; // DISPLAY MARGIN RATES - print ''; print ''.$langs->trans("DisplayMarginRates").''; print ''; @@ -189,7 +186,6 @@ print ''.$langs->trans('MarginRate').' = '.$langs->trans('Margin').' / '.$la print ''; // DISPLAY MARK RATES - print ''; print ''.$langs->trans("DisplayMarkRates").''; print ''; @@ -259,7 +255,6 @@ print ''; print ''; // INTERNAL CONTACT TYPE USED AS COMMERCIAL AGENT - print '
'; print ''; print ""; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 2e80fe5ced2..8c62b4dd6fe 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -208,7 +208,6 @@ if ($result) if ($num > 0) { - $var=true; while ($i < $num /*&& $i < $conf->liste_limit*/) { @@ -229,8 +228,6 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - - print ''; if ($agentid > 0) { $companystatic->id=$objp->socid; diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 96b9cad3849..96dd916290e 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -127,7 +127,6 @@ if ($mode == 'setup' && $user->admin) print $langs->trans("PrintingDriverDesc".$driver)."

\n"; print ''."\n"; - $var=true; print ''; print ''; print ''; @@ -146,7 +145,6 @@ if ($mode == 'setup' && $user->admin) $submit_enabled=0; foreach ($printer->conf as $key) { - switch ($key['type']) { case "text": case "password": @@ -248,7 +246,6 @@ if ($mode == 'config' && $user->admin) print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'."\n"; - $var=true; print ''; print ''; print ''; @@ -333,7 +330,6 @@ if ($mode == 'userconf' && $user->admin) print $langs->trans('PrintUserConfDesc'.$driver)."

\n"; print '
'.$langs->trans("Description").''.$langs->trans("Active").'
'; - $var=true; print ''; print ''; print ''; diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index bb214ffc06a..2e57e452928 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -401,7 +401,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -438,7 +437,6 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - $var = !$var; print '\n"; + $i++; +>>>>>>> 1d08002 Fix: remove old code of canvas } + + $db->free($resql); + + print "
'.$langs->trans("User").''.$langs->trans("PrintModule").'
'; print (empty($module->name)?$name:$module->name); print "\n"; @@ -524,12 +522,10 @@ print "
"; print load_fiche_titre($langs->trans("ProductOtherConf"), '', ''); - print ''; print ''; print ''; -$var=true; print ''; print ''; print ''."\n"; @@ -569,7 +565,6 @@ print ''; // multiprix nombre de prix a proposer if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - print ''; print ''; print ''; @@ -611,7 +606,6 @@ print ''; if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { - print ''; print ''; print ''; @@ -619,7 +613,6 @@ if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) } // Visualiser description produit dans les formulaires activation/desactivation - print ''; print ''; print ''; // View product description in thirdparty language if (! empty($conf->global->MAIN_MULTILANGS)) { - print ''; print ''; print '> + $value) { foreach($fieldlist as $field) { diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index a1cd63eea12..c3f568a958c 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -551,7 +551,6 @@ if ($id > 0 || ! empty($ref)) { $num = $db->num_rows($resql); $i=0; - $var=true; if($num == 0) print ''; @@ -655,7 +654,6 @@ if ($id > 0 || ! empty($ref)) print ''; } - } } diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index b2713d65304..ddda73d0add 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -759,12 +759,9 @@ SCRIPT; if (is_array($product_fourn_list)) { - $var=true; foreach($product_fourn_list as $productfourn) { - - print ''; // Supplier diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 9f11813fdee..89330618879 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -457,8 +457,6 @@ function activitytrim($product_type) } $i = 0; - $var=true; - while ($i < $num) { $objp = $db->fetch_object($result); @@ -466,7 +464,6 @@ function activitytrim($product_type) { if ($trim1+$trim2+$trim3+$trim4 > 0) { - print ''; print ''; print ''; @@ -500,7 +497,6 @@ function activitytrim($product_type) } if ($trim1+$trim2+$trim3+$trim4 > 0) { - print ''; print ''; print ''; diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index eae89aca648..51692a3e9a1 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -334,8 +334,6 @@ $buttonrecordnoent=$langs->transnoentitiesnoconv("RecordMovement"); print ''.$langs->trans("SelectProductInAndOutWareHouse",$titletoaddnoent,$buttonrecordnoent).'
'; print '
'."\n"; -$var=true; - // Form to add a line print ''; print ''; @@ -402,8 +400,6 @@ print ''; foreach($listofdata as $key => $val) { - - $productstatic->fetch($val['id_product']); $warehousestatics->fetch($val['id_sw']); $warehousestatict->fetch($val['id_tw']); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 7c15b3fa7c5..08289ec11e4 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -396,14 +396,12 @@ if ($resql) $productlot = new Productlot($db); $i=0; - $var=true; $totalarray=array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); if ($obj) { - $var = !$var; $productlot->id = $obj->rowid; $productlot->batch = $obj->batch; diff --git a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php index ca604e61fcc..794ed96f3ec 100644 --- a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php @@ -36,12 +36,11 @@ $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $total=0; $ilink=0; -$var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass=($var?'pair':'impair'); + $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> From 0490807f9b77727663b5e8f9c5c1e58e01311a77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Jun 2018 18:36:08 +0200 Subject: [PATCH 054/228] Prepare 9.0 --- htdocs/filefunc.inc.php | 2 +- .../install/mysql/migration/8.0.0-9.0.0.sql | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 htdocs/install/mysql/migration/8.0.0-9.0.0.sql diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index dece376cc5a..ce83e3a3460 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','8.0.0-beta'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','9.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql new file mode 100644 index 00000000000..80b67dc0eea --- /dev/null +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -0,0 +1,32 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 8.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. + + + + From f5ea1305629ca444f8ced7128354283d90f5df0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Jun 2018 18:39:24 +0200 Subject: [PATCH 055/228] Prepare v9 --- htdocs/install/check.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 10ff1b603bb..09f38fdf452 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -436,7 +436,8 @@ else array('from'=>'4.0.0', 'to'=>'5.0.0'), array('from'=>'5.0.0', 'to'=>'6.0.0'), array('from'=>'6.0.0', 'to'=>'7.0.0'), - array('from'=>'7.0.0', 'to'=>'8.0.0') + array('from'=>'7.0.0', 'to'=>'8.0.0'), + array('from'=>'8.0.0', 'to'=>'9.0.0') ); $count=0; From 60c62895bf8bb4a1da8eeb0dcf1f6fb252faa7c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Jun 2018 19:13:23 +0200 Subject: [PATCH 056/228] WIP Can add tooltips on extrafields --- htdocs/core/class/extrafields.class.php | 38 +++++++++++-------- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- .../install/mysql/migration/8.0.0-9.0.0.sql | 1 + .../install/mysql/tables/llx_extrafields.sql | 1 + 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 839528ddc20..174e01bf74c 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -156,14 +156,14 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param string $list Visibilty ('0'=never visible, '1'=visible on list+forms, '2'=list only, '3'=form only or 'eval string') - * @param int $notused Deprecated. + * @param string $help Text with help tooltip * @param string $computed Computed value * @param string $entity Entity of extrafields (for multicompany modules) * @param string $langfile Language file * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $computed='', $entity='', $langfile='', $enabled='1') + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $computed='', $entity='', $langfile='', $enabled='1') { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -174,13 +174,13 @@ class ExtraFields // Create field into database except for separator type which is not stored in database if ($type != 'separate') { - $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed); + $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed, $help); } $err1=$this->errno; if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') { // Add declaration of field into table - $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $notused, $default_value, $computed, $entity, $langfile, $enabled); + $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled); $err2=$this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { @@ -300,7 +300,7 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param string $list Visibily - * @param int $notused Deprecated. + * @param string $help Help on tooltip * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value * @param string $entity Entity of extrafields @@ -308,7 +308,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1') + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $default='', $computed='',$entity='', $langfile='', $enabled='1') { global $conf,$user; @@ -357,7 +357,8 @@ class ExtraFields $sql.= " fk_user_author,"; $sql.= " fk_user_modif,"; $sql.= " datec,"; - $sql.= " enabled"; + $sql.= " enabled,"; + $sql.= " help"; $sql.= " )"; $sql.= " VALUES('".$attrname."',"; $sql.= " '".$this->db->escape($label)."',"; @@ -378,7 +379,8 @@ class ExtraFields $sql .= " " . $user->id . ","; $sql .= " " . $user->id . ","; $sql .= "'" . $this->db->idate(dol_now()) . "',"; - $sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1"); + $sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1").","; + $sql.= " ".($help?"'".$this->db->escape($help)."'":"null"); $sql.=')'; dol_syslog(get_class($this)."::create_label", LOG_DEBUG); @@ -508,7 +510,7 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param string $list Visibility - * @param int $notused Deprecated. + * @param string $help Help on tooltip * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value * @param string $entity Entity of extrafields @@ -516,7 +518,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int >0 if OK, <=0 if KO */ - function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $notused=0, $default='', $computed='', $entity='', $langfile='', $enabled='1') + function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $help='', $default='', $computed='', $entity='', $langfile='', $enabled='1') { if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; @@ -566,7 +568,7 @@ class ExtraFields { if ($label) { - $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$notused,$default,$computed,$entity,$langfile,$enabled); + $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$help,$default,$computed,$entity,$langfile,$enabled); } if ($result > 0) { @@ -617,7 +619,7 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param string $list Visiblity - * @param int $notused Deprecated. + * @param string $help Help on tooltip. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value * @param string $entity Entity of extrafields @@ -625,7 +627,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1') + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$help='',$default='',$computed='',$entity='',$langfile='',$enabled='1') { global $conf, $user; dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled); @@ -684,7 +686,8 @@ class ExtraFields $sql.= " fk_user_author,"; $sql.= " fk_user_modif,"; $sql.= " datec,"; - $sql.= " enabled"; + $sql.= " enabled,"; + $sql.= " help"; $sql.= ") VALUES ("; $sql.= "'".$attrname."',"; $sql.= " ".($entity===''?$conf->entity:$entity).","; @@ -705,7 +708,8 @@ class ExtraFields $sql .= " " . $user->id . ","; $sql .= " " . $user->id . ","; $sql .= "'" . $this->db->idate(dol_now()) . "',"; - $sql .= "'" . $this->db->escape($enabled). "'"; + $sql .= "'" . $this->db->escape($enabled). "',"; + $sql.= " ".($help?"'".$this->db->escape($help)."'":"null"); $sql.= ")"; $resql2=$this->db->query($sql); @@ -769,7 +773,7 @@ class ExtraFields // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled,help"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element @@ -824,6 +828,7 @@ class ExtraFields $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]); $this->attributes[$tab->elementtype]['enabled'][$tab->name]=$tab->enabled; + $this->attributes[$tab->elementtype]['help'][$tab->name]=$tab->help; $this->attributes[$tab->elementtype]['loaded']=1; } @@ -881,6 +886,7 @@ class ExtraFields $perms=dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); $langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key]; $list=dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); + $help=$this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else // Old usage diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 7253474c36b..777bd4b4d15 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -98,7 +98,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] //var_dump($action);exit; if ((! empty($action) && ($action == 'create' || $action == 'edit')) && ! empty($extrafields->attributes[$object->table_element]['required'][$key])) print ' fieldrequired'; print '">'; - if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) print $form->textwithpicto($langs->trans($label), $extrafields->attributes[$object->table_element]['help'][$key]); + if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) print $form->textwithpicto($langs->trans($label), $langs->trans($extrafields->attributes[$object->table_element]['help'][$key])); else print $langs->trans($label); print ''; diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 80b67dc0eea..a0a22074079 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -29,4 +29,5 @@ +ALTER TABLE llx_extrafields ADD COLUMN help text NULL; diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index 9acf239ee64..1a85fc28a5a 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -37,6 +37,7 @@ create table llx_extrafields param text, -- extra parameters to define possible values of field list varchar(255) DEFAULT '1', -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing langs varchar(64), -- example: fileofmymodule@mymodule + help text, -- to store help tooltip fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change datec datetime, -- date de creation From 3b4fca6756025dd0009e0dfed9960a127b3735dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Jun 2018 00:19:43 +0200 Subject: [PATCH 057/228] Fix param dol_invisible_topmenu --- htdocs/main.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0d724e1ce5c..770d35d1ab3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1059,7 +1059,7 @@ if (! function_exists("llxHeader")) print '' . "\n"; // top menu and left menu area - if (empty($conf->dol_hide_topmenu)) + if (empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu','int')) { top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); } @@ -1467,11 +1467,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a /* * Top menu */ - if (empty($conf->dol_hide_topmenu) && (! defined('NOREQUIREMENU') || ! constant('NOREQUIREMENU'))) + if ((empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu','int')) && (! defined('NOREQUIREMENU') || ! constant('NOREQUIREMENU'))) { print "\n".''."\n"; - print '
'; + print '
'; // Show menu entries print '
'."\n"; From 41a516f1c476abade8fddf6ee3cb5b873ee8f301 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 29 Jun 2018 11:48:54 +0200 Subject: [PATCH 058/228] New parameter to transform select into multiselect --- htdocs/core/class/html.form.class.php | 63 +++++++++++++++++---------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9a9d3279e03..99f567f5434 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1001,9 +1001,10 @@ class Form * @param string $selected_input_value Value of preselected input text (for use with ajax) * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) * @param array $ajaxoptions Options for ajax_autocompleter + * @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter) * @return string HTML string with select box for thirdparty. */ - function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='', $selected_input_value='', $hidelabel=1, $ajaxoptions=array()) + function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='', $selected_input_value='', $hidelabel=1, $ajaxoptions=array(), $multiple=false) { global $conf,$user,$langs; @@ -1040,7 +1041,7 @@ class Form else { // Immediate load of all database - $out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam); + $out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple); } return $out; @@ -1062,16 +1063,20 @@ class Form * @param int $limit Limit number of answers * @param string $morecss Add more css styles to the SELECT component * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container + * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string HTML string with */ - function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty='', $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='') + function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty='', $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='', $multiple=false) { global $conf,$user,$langs; $out=''; $num=0; $outarray=array(); - + + if ($selected === '') $selected = array(); + else if (!is_array($selected)) $selected = array($selected); + // Clean $filter that may contains sql conditions so sql code if (function_exists('test_sql_and_script_inject')) $filter = test_sql_and_script_inject($filter, 3); @@ -1120,7 +1125,7 @@ class Form } // Construct $out and $outarray - $out.= ''."\n"; $textifempty=''; // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. @@ -1169,7 +1174,7 @@ class Form if (empty($outputmode)) { - if ($selected > 0 && $selected == $obj->rowid) + if (in_array($obj->rowid,$selected)) { $out.= ''; } @@ -1320,15 +1325,19 @@ class Form * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @param string $htmlid Html id to use instead of htmlname + * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return int <0 if KO, Nb of contact in list if OK */ - function selectcontacts($socid, $selected='', $htmlname='contactid', $showempty=0, $exclude='', $limitto='', $showfunction=0, $moreclass='', $options_only=false, $showsoc=0, $forcecombo=0, $events=array(), $moreparam='', $htmlid='') + function selectcontacts($socid, $selected='', $htmlname='contactid', $showempty=0, $exclude='', $limitto='', $showfunction=0, $moreclass='', $options_only=false, $showsoc=0, $forcecombo=0, $events=array(), $moreparam='', $htmlid='', $multiple=false) { global $conf,$langs; $langs->load('companies'); if (empty($htmlid)) $htmlid = $htmlname; + + if ($selected === '') $selected = array(); + else if (!is_array($selected)) $selected = array($selected); $out=''; // On recherche les societes @@ -1353,9 +1362,9 @@ class Form $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); } - if ($htmlname != 'none' || $options_only) $out.= ''; + if ($showempty == 1 && !$multiple) $out.= ''; + if ($showempty == 2) $out.= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -1363,7 +1372,6 @@ class Form include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contactstatic=new Contact($this->db); - if (!is_array($selected)) $selected = array($selected); while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -1413,7 +1421,7 @@ class Form } else { - $out.= ''; + $out.= ''; } if ($htmlname != 'none' || $options_only) { @@ -1469,16 +1477,20 @@ class Form * @param string $morecss More css * @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on). * @param int $outputmode 0=HTML select string, 1=Array + * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string HTML select string * @see select_dolgroups */ - function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity='0', $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0, $outputmode=0) + function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity='0', $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0, $outputmode=0, $multiple=false) { global $conf,$user,$langs; - + // If no preselected user defined, we take current user if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id; + if ($selected === '') $selected = array(); + else if (!is_array($selected)) $selected = array($selected); + $excludeUsers=null; $includeUsers=null; @@ -1551,12 +1563,12 @@ class Form $out .= ajax_combobox($htmlname); // do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined - $out.= ''; + if ($show_empty && !$multiple) $out.= ''."\n"; + if ($show_every) $out.= ''."\n"; $userstatic=new User($this->db); - + while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -1568,7 +1580,7 @@ class Form $disableline=''; if (is_array($enableonly) && count($enableonly) && ! in_array($obj->rowid,$enableonly)) $disableline=($enableonlytext?$enableonlytext:'1'); - if ((is_object($selected) && $selected->id == $obj->rowid) || (! is_object($selected) && $selected == $obj->rowid)) + if ((is_object($selected) && $selected->id == $obj->rowid) || (! is_object($selected) && in_array($obj->rowid,$selected) )) { $out.= '
'."\n"; - if(!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) print ''; + if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) print ''; // Picto + Name of module print ' - +stock->enabled)) { ?> diff --git a/htdocs/product/canvas/product/tpl/card_edit.tpl.php b/htdocs/product/canvas/product/tpl/card_edit.tpl.php index 6c13bddb6a1..8210cde95f3 100644 --- a/htdocs/product/canvas/product/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_edit.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 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 @@ -65,7 +65,7 @@ dol_htmloutput_errors($object->error,$object->errors); - +stock->enabled)) { ?> diff --git a/htdocs/product/canvas/product/tpl/card_view.tpl.php b/htdocs/product/canvas/product/tpl/card_view.tpl.php index 921cef87200..61964399e1c 100644 --- a/htdocs/product/canvas/product/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_view.tpl.php @@ -63,16 +63,6 @@ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - - - - - - - - - - diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 4758f0de08a..827360a7e9d 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -122,20 +122,6 @@ class ActionsCardService $this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,''); } - if ($action == 'create' || $action == 'edit') - { - // Status - $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - $this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->status); - - //To Buy - $statutarray=array('1' => $langs->trans("Yes"), '0' => $langs->trans("No")); - $this->tpl['tobuy'] = $form->selectarray('tobuy',$statutarray,$this->status_buy); - - $this->tpl['description'] = $this->description; - $this->tpl['note'] = $this->note; - } - if ($action == 'view') { $head = product_prepare_head($this->object); @@ -182,10 +168,13 @@ class ActionsCardService { // Status $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - $this->tpl['status'] = $form->selectarray('statut',$statutarray,$_POST["statut"]); + $this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->object->status); $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); - $this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]); + $this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$this->object->status_buy); + + $this->tpl['description'] = $this->description; + $this->tpl['note'] = $this->note; // Duration unit // TODO creer fonction @@ -203,10 +192,6 @@ class ActionsCardService if ($action == 'view') { - // Status - $this->tpl['status'] = $this->object->getLibStatut(2,0); - $this->tpl['status_buy'] = $this->object->getLibStatut(2,1); - // Photo $this->tpl['nblignes'] = 4; if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity])) diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index b9dc10fd5dc..443e9ee7401 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 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 @@ -62,7 +62,7 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe - + diff --git a/htdocs/product/canvas/service/tpl/card_edit.tpl.php b/htdocs/product/canvas/service/tpl/card_edit.tpl.php index 6fc3bf3273a..ccbe1131120 100644 --- a/htdocs/product/canvas/service/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_edit.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 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 @@ -62,7 +62,7 @@ dol_htmloutput_errors($object->error,$object->errors); - + diff --git a/htdocs/product/canvas/service/tpl/card_view.tpl.php b/htdocs/product/canvas/service/tpl/card_view.tpl.php index 0ce5252b053..5826d78583f 100644 --- a/htdocs/product/canvas/service/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_view.tpl.php @@ -63,16 +63,6 @@ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - - - - - - - - - - From 96faf7cb0f1a139a73b59f48d4f53875605a60c3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 20 Jun 2018 11:23:33 +0200 Subject: [PATCH 072/228] Fix: use the new title --- htdocs/product/canvas/product/tpl/card_create.tpl.php | 5 ++++- htdocs/product/canvas/product/tpl/card_edit.tpl.php | 4 +++- htdocs/product/canvas/service/tpl/card_create.tpl.php | 5 ++++- htdocs/product/canvas/service/tpl/card_edit.tpl.php | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index d3c29f32e2e..dbaaed35319 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -30,7 +30,10 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe -trans("Product")); ?> +trans("NewProduct"),'','title_products.png'); +dol_fiche_head(''); +?> error)?'':$object->error),$object->errors); ?> diff --git a/htdocs/product/canvas/product/tpl/card_edit.tpl.php b/htdocs/product/canvas/product/tpl/card_edit.tpl.php index 8210cde95f3..f114020a4bc 100644 --- a/htdocs/product/canvas/product/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_edit.tpl.php @@ -31,7 +31,9 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe trans("Product")); +$head=product_prepare_head($object); +$titre=$langs->trans("CardProduct".$object->type); +dol_fiche_head($head, 'card', $titre, 0, 'product'); dol_htmloutput_errors($object->error,$object->errors); ?> diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index 443e9ee7401..f748edc03e6 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -30,7 +30,10 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe -trans("Service")); ?> +trans("NewService"),'','title_products.png'); +dol_fiche_head(''); +?> control->tpl['error'],$this->control->tpl['errors']); ?> diff --git a/htdocs/product/canvas/service/tpl/card_edit.tpl.php b/htdocs/product/canvas/service/tpl/card_edit.tpl.php index ccbe1131120..969ce3de2da 100644 --- a/htdocs/product/canvas/service/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_edit.tpl.php @@ -31,7 +31,9 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe trans("Service")); +$head=product_prepare_head($object); +$titre=$langs->trans("CardProduct".$object->type); +dol_fiche_head($head, 'card', $titre, 0, 'service'); dol_htmloutput_errors($object->error,$object->errors); ?> From 718cbce8eb3e3971790ea29f0d898e5624a91b47 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 22 Jun 2018 15:05:23 +0200 Subject: [PATCH 073/228] Fix: use "visible" field name instead "checked" --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_c_field_list.sql | 2 +- htdocs/product/canvas/product/actions_card_product.class.php | 4 ++-- htdocs/product/canvas/service/actions_card_service.class.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 6fda9998bed..ec6940e1441 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -102,7 +102,7 @@ ALTER TABLE llx_c_type_fees ADD COLUMN type integer DEFAULT 0; ALTER TABLE llx_c_ecotaxe CHANGE COLUMN libelle label varchar(255); -ALTER TABLE llx_c_field_list ADD COLUMN checked tinyint DEFAULT 0 NOT NULL AFTER search; +ALTER TABLE llx_c_field_list ADD COLUMN visible tinyint DEFAULT 1 NOT NULL AFTER search; ALTER TABLE llx_product_fournisseur_price DROP COLUMN unitcharges; diff --git a/htdocs/install/mysql/tables/llx_c_field_list.sql b/htdocs/install/mysql/tables/llx_c_field_list.sql index 17f8ef7356c..21adba42cfa 100644 --- a/htdocs/install/mysql/tables/llx_c_field_list.sql +++ b/htdocs/install/mysql/tables/llx_c_field_list.sql @@ -33,7 +33,7 @@ create table llx_c_field_list align varchar(6) DEFAULT 'left', -- align (left,center,right) sort tinyint DEFAULT 1 NOT NULL, -- add sort field search tinyint DEFAULT 0 NOT NULL, -- add search field - checked tinyint DEFAULT 0 NOT NULL, -- show or hide field by default + visible tinyint DEFAULT 1 NOT NULL, -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only enabled varchar(255) DEFAULT 1, -- Condition to show or hide rang integer DEFAULT 0 diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 1ea02816043..a6a182fc64f 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -253,7 +253,7 @@ class ActionsCardProduct $this->field_list = array(); - $sql = "SELECT rowid, name, alias, title, align, sort, search, checked, enabled, rang"; + $sql = "SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang"; $sql.= " FROM ".MAIN_DB_PREFIX."c_field_list"; $sql.= " WHERE element = '".$this->db->escape($this->fieldListName)."'"; $sql.= " AND entity = ".$conf->entity; @@ -278,7 +278,7 @@ class ActionsCardProduct $fieldlist["align"] = $obj->align; $fieldlist["sort"] = $obj->sort; $fieldlist["search"] = $obj->search; - $fieldlist["checked"] = $obj->checked; + $fieldlist["visible"] = $obj->visible; $fieldlist["enabled"] = verifCond($obj->enabled); $fieldlist["order"] = $obj->rang; diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 827360a7e9d..108c6ccb748 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -232,7 +232,7 @@ class ActionsCardService $this->field_list = array(); - $sql = "SELECT rowid, name, alias, title, align, sort, search, checked, enabled, rang"; + $sql = "SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang"; $sql.= " FROM ".MAIN_DB_PREFIX."c_field_list"; $sql.= " WHERE element = '".$this->db->escape($this->fieldListName)."'"; $sql.= " AND entity = ".$conf->entity; @@ -257,7 +257,7 @@ class ActionsCardService $fieldlist["align"] = $obj->align; $fieldlist["sort"] = $obj->sort; $fieldlist["search"] = $obj->search; - $fieldlist["checked"] = $obj->checked; + $fieldlist["visible"] = $obj->visible; $fieldlist["enabled"] = verifCond($obj->enabled); $fieldlist["order"] = $obj->rang; From 62a55e10b7c818ea431470eec8cecbd564917117 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 22 Jun 2018 15:26:07 +0200 Subject: [PATCH 074/228] Fix: remove not used list template --- htdocs/core/class/canvas.class.php | 4 +- .../product/canvas/product/tpl/list.tpl.php | 108 ------------------ .../product/canvas/service/tpl/list.tpl.php | 107 ----------------- 3 files changed, 2 insertions(+), 217 deletions(-) delete mode 100644 htdocs/product/canvas/product/tpl/list.tpl.php delete mode 100644 htdocs/product/canvas/service/tpl/list.tpl.php diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 942123966fa..d9c496add4f 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -145,7 +145,7 @@ class Canvas { if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.((!empty($this->card) && $this->card != 'list')?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; + if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; else return 0; } @@ -161,7 +161,7 @@ class Canvas global $db, $conf, $langs, $user, $canvas; global $form, $formfile; - include $this->template_dir.((!empty($this->card) && $this->card != 'list')?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template + include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template } diff --git a/htdocs/product/canvas/product/tpl/list.tpl.php b/htdocs/product/canvas/product/tpl/list.tpl.php deleted file mode 100644 index e5c315e8148..00000000000 --- a/htdocs/product/canvas/product/tpl/list.tpl.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) -{ - print "Error, template page can't be called as URL"; - exit; -} - -?> - - - -
'.$langs->trans("Parameters").'
'.$langs->trans("MultiPricesNumPrices").'
'.$langs->trans("NumberOfProductShowInSelect").'
'.$langs->trans("ViewProductDescInFormAbility").''; @@ -652,7 +645,6 @@ print '
'.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").''; diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 291aba9bcf1..ed4480aeaa2 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -294,8 +294,6 @@ if (empty($mysoc->country_code)) else { - $var=true; - print ''; print ''; print ''; diff --git a/htdocs/product/canvas/product/tpl/list.tpl.php b/htdocs/product/canvas/product/tpl/list.tpl.php index e5c315e8148..070f58dd481 100644 --- a/htdocs/product/canvas/product/tpl/list.tpl.php +++ b/htdocs/product/canvas/product/tpl/list.tpl.php @@ -89,10 +89,9 @@ if (empty($conf) || ! is_object($conf)) -
'.$langs->trans("NoMatchFound").'
'.$tmpyear.''.price($trim1).''.price($trim2).'
'.$tmpyear.''.price($trim1).''.price($trim2).'
'.++$linenum.''.++$linenum.''; From 7984316142b6b122ceaecd00dadd7c81572dcb6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jun 2018 01:20:44 +0200 Subject: [PATCH 062/228] Update 7.0.0-8.0.0.sql --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index d259da1fe55..471b73b894b 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -44,7 +44,6 @@ ALTER TABLE llx_website_page ADD COLUMN type_container varchar(16) NOT NULL DEFA DROP TABLE llx_c_accountancy_category; DROP TABLE llx_c_accountingaccount; - update llx_propal set fk_statut = 1 where fk_statut = -1; ALTER TABLE llx_inventory ADD COLUMN fk_user_creat integer; @@ -81,7 +80,6 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE -- For 8.0 -ALTER TABLE llx_user ADD COLUMN dateemploymentend date after dateemployment; -- delete old permission no more used From 202ab93c5f4c60176df63c992d275c39b83c4c19 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jun 2018 01:20:57 +0200 Subject: [PATCH 063/228] Update 7.0.0-8.0.0.sql --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 471b73b894b..a57e02455cc 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -79,9 +79,6 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE -- For 8.0 - - - -- delete old permission no more used DELETE FROM llx_rights_def WHERE perms = 'main' and module = 'commercial'; From 7fab2ca1f813abbf5986ff200a94a08363459fde Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jun 2018 01:26:33 +0200 Subject: [PATCH 064/228] Add new field --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index a0a22074079..37fc3c2ac0c 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -31,3 +31,7 @@ ALTER TABLE llx_extrafields ADD COLUMN help text NULL; + +ALTER TABLE llx_user ADD COLUMN dateemploymentend date after dateemployment; + + From 0f62408700832ceb2b11742c49864c87f8e01447 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jun 2018 01:34:51 +0200 Subject: [PATCH 065/228] Remove duplicated code --- .../societe/class/api_thirdparties.class.php | 37 +++++------ .../class/companybankaccount.class.php | 66 +++---------------- 2 files changed, 26 insertions(+), 77 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 0922c8cfa11..42ff31af66a 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -999,9 +999,9 @@ class Thirdparties extends DolibarrApi } /** * Get CompanyBankAccount objects for thirdparty - * + * * @param int $socid Thirdparty id - * + * * @return array */ function getCompanyBankAccount($socid){ @@ -1028,12 +1028,12 @@ class Thirdparties extends DolibarrApi $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; if ($socid) $sql.= " WHERE fk_soc = ".$socid." "; - + $result = $db->query($sql); if($result->num_rows == 0 ){ throw new RestException(404, 'Account not found'); - } + } $i=0; @@ -1055,7 +1055,7 @@ class Thirdparties extends DolibarrApi else{ throw new RestException(404, 'Account not found'); } - + $fields = ['socid', 'default_rib', 'frstrecur', '1000110000001', 'datec', 'datem', 'label', 'bank', 'bic', 'iban', 'id']; @@ -1069,19 +1069,19 @@ class Thirdparties extends DolibarrApi } $returnAccounts[] = $object; - } + } return $returnAccounts; } - + /** * Create CompanyBankAccount object for thirdparty * @param int $socid thirdparty id * @param array $request_data Request datas - * + * * @return object ID of thirdparty - * + * * @url POST {socid}/CompanyBankAccount */ function createCompanyBankAccount($socid, $request_data = null) @@ -1104,20 +1104,20 @@ class Thirdparties extends DolibarrApi if ($account->update(DolibarrApiAccess::$user) < 0) throw new RestException(500, 'Error updating values'); - + return $account; } /** * Update CompanyBankAccount object for thirdparty - * + * * @param int $socid Thirdparty id * @param int $id CompanyBankAccount's id * @param array $request_data Request datas - * + * * @return object ID of thirdparty - * + * * @url PUT {socid}/CompanyBankAccount/{id} */ function updateCompanyBankAccount($socid, $id, $request_data = null) @@ -1128,14 +1128,13 @@ class Thirdparties extends DolibarrApi $account = new CompanyBankAccount($this->db); - $account->fetchFromApi($id, $socid); - + $account->fetch($id, $socid, -1, ''); if($account->socid != $socid){ throw new RestException(401); } - + foreach($request_data as $field => $value) { $account->$field = $value; @@ -1143,16 +1142,16 @@ class Thirdparties extends DolibarrApi if ($account->update(DolibarrApiAccess::$user) < 0) throw new RestException(500, 'Error updating values'); - + return $account; } /** * @param int $id CompanyBankAccount's id * @param int $socid Thirdparty id - * + * * @return int -1 if error 1 if correct deletion - * + * * @url DELETE {socid}/CompanyBankAccount/{id} */ function deleteCompanyBankAccount($id, $socid){ diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 68dd8f51c3b..ae7424af1bb 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -197,10 +197,12 @@ class CompanyBankAccount extends Account * Load record from database * * @param int $id Id of record - * @param int $socid Id of company. If this is filled, function will return the first default RIB of company + * @param int $socid Id of company. If this is filled, function will return the first entry found (matching $default and $type) + * @param int $default If id of company filled, we say if we want first record among all (-1), default record (1) or non default record (0) + * @param int $type If id of company filled, we say if we want record of this type only * @return int <0 if KO, >0 if OK */ - function fetch($id, $socid=0) + function fetch($id, $socid=0, $default=1, $type='ban') { if (empty($id) && empty($socid)) return -1; @@ -208,64 +210,12 @@ class CompanyBankAccount extends Account $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; if ($id) $sql.= " WHERE rowid = ".$id; - if ($socid) $sql.= " WHERE fk_soc = ".$socid." AND default_rib = 1 AND type ='ban'"; - - $resql = $this->db->query($sql); - if ($resql) + if ($socid) { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); - - $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref - - $this->id = $obj->rowid; - $this->type = $obj->type; - $this->socid = $obj->fk_soc; - $this->bank = $obj->bank; - $this->code_banque = $obj->code_banque; - $this->code_guichet = $obj->code_guichet; - $this->number = $obj->number; - $this->cle_rib = $obj->cle_rib; - $this->bic = $obj->bic; - $this->iban = $obj->iban; - $this->domiciliation = $obj->domiciliation; - $this->proprio = $obj->proprio; - $this->owner_address = $obj->owner_address; - $this->label = $obj->label; - $this->default_rib = $obj->default_rib; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->datem); - $this->rum = $obj->rum; - $this->frstrecur = $obj->frstrecur; - } - $this->db->free($resql); - - return 1; + $sql.= " WHERE fk_soc = ".$socid; + if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default); + if ($type) $sql.= " AND type ='".$this->db->escape($type)."'"; } - else - { - dol_print_error($this->db); - return -1; - } - } - - /** - * Load record from database for the API - * - * @param int $id Id of record - * @param int $socid Id of company. If this is filled, function will return the first default RIB of company - * @return int <0 if KO, >0 if OK - */ - function fetchFromApi($id, $socid=0) - { - if (empty($id) && empty($socid)) return -1; - - $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE rowid = ".$id; - if ($socid) $sql.= " AND fk_soc = ".$socid; $resql = $this->db->query($sql); if ($resql) From f998f64db0c7934a83f26ba333dd9309bbc8fba4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 18 Jun 2018 15:48:51 +0200 Subject: [PATCH 066/228] Works on use new list engine instead template for canvas Conflicts: htdocs/product/list.php --- htdocs/core/lib/security.lib.php | 3 +-- htdocs/product/card.php | 2 +- htdocs/product/list.php | 12 ++++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d157cafd5f8..f7ce5712c76 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -174,11 +174,10 @@ function dol_verifyHash($chain, $hash, $type='0') * @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'level1|level2'. * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) - * @param Canvas $objcanvas Object canvas * @return int Always 1, die process if not allowed * @see dol_check_secure_access_document */ -function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null) +function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') { global $db, $conf; global $hookmanager; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 39a5697ad72..b01aa8bc3f1 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -112,7 +112,7 @@ if (! empty($canvas)) // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($id) ? 'rowid' : 'ref'); -$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype,$objcanvas); +$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productcard','globalcard')); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index d1ea3d08a4c..884034453f7 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2013-2016 Juanjo Menent * Copyright (C) 2013-2015 Raphaël Doursenaud @@ -104,19 +104,19 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search if (empty($action)) $action='list'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$canvas=GETPOST("canvas"); +/*$canvas=GETPOST("canvas"); $objcanvas=null; if (! empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db,$action); $objcanvas->getCanvas('product','list',$canvas); -} +}*/ // Security check -if ($search_type=='0') $result=restrictedArea($user,'produit','','','','','',$objcanvas); -else if ($search_type=='1') $result=restrictedArea($user,'service','','','','','',$objcanvas); -else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas); +if ($search_type=='0') $result=restrictedArea($user,'produit'); +else if ($search_type=='1') $result=restrictedArea($user,'service'); +else $result=restrictedArea($user,'produit|service'); // Define virtualdiffersfromphysical $virtualdiffersfromphysical=0; From e392610f46793186d87fa57420bce3cb00282a54 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 19 Jun 2018 18:55:05 +0200 Subject: [PATCH 067/228] Fix: missing banner --- .../canvas/product/tpl/card_view.tpl.php | 17 +++++++++++++++-- .../canvas/service/tpl/card_view.tpl.php | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/htdocs/product/canvas/product/tpl/card_view.tpl.php b/htdocs/product/canvas/product/tpl/card_view.tpl.php index 44b1f96203b..921cef87200 100644 --- a/htdocs/product/canvas/product/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_view.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 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 @@ -27,7 +27,20 @@ $object=$GLOBALS['object']; ?> -trans("Product"); ?> +trans("CardProduct".$object->type); + +dol_fiche_head($head, 'card', $titre, -1, 'product'); + +$linkback = ''.$langs->trans("BackToList").''; +$object->next_prev_filter=" fk_product_type = ".$object->type; + +$shownav = 1; +if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + +dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); +?> error,$object->errors); ?> diff --git a/htdocs/product/canvas/service/tpl/card_view.tpl.php b/htdocs/product/canvas/service/tpl/card_view.tpl.php index fc129132dee..0ce5252b053 100644 --- a/htdocs/product/canvas/service/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_view.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 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 @@ -27,7 +27,20 @@ $object=$GLOBALS['object']; ?> -trans("Service"); ?> +trans("CardProduct".$object->type); + +dol_fiche_head($head, 'card', $titre, -1, 'service'); + +$linkback = ''.$langs->trans("BackToList").''; +$object->next_prev_filter=" fk_product_type = ".$object->type; + +$shownav = 1; +if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + +dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); +?> error,$object->errors); ?> From 3a26443546d7a62cfd79f472a84f8f0e8f8b0ade Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 19 Jun 2018 19:24:40 +0200 Subject: [PATCH 068/228] Fix: remove unused code Conflicts: htdocs/product/list.php --- htdocs/core/class/canvas.class.php | 6 +- htdocs/product/list.php | 352 ++++++++++++++++++++++++++++- 2 files changed, 353 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 6851c124743..942123966fa 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * Copyright (C) 2011 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -145,7 +145,7 @@ class Canvas { if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; + if (file_exists($this->template_dir.((!empty($this->card) && $this->card != 'list')?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; else return 0; } @@ -161,7 +161,7 @@ class Canvas global $db, $conf, $langs, $user, $canvas; global $form, $formfile; - include $this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template + include $this->template_dir.((!empty($this->card) && $this->card != 'list')?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 884034453f7..63713846614 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -104,14 +104,14 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search if (empty($action)) $action='list'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -/*$canvas=GETPOST("canvas"); +$canvas=GETPOST("canvas"); $objcanvas=null; if (! empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db,$action); $objcanvas->getCanvas('product','list',$canvas); -}*/ +} // Security check if ($search_type=='0') $result=restrictedArea($user,'produit'); @@ -693,6 +693,7 @@ if ($resql) $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; $sql.= " LIMIT 1"; +<<<<<<< 8.0_canvas $result = $db->query($sql); if ($result) { @@ -716,6 +717,341 @@ if ($resql) $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock +======= + llxHeader('',$title,$helpurl,''); + + // Displays product removal confirmation + if (GETPOST('delprod')) { + setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); + } + + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($sall) $param.="&sall=".urlencode($sall); + if ($search_categ > 0) $param.="&search_categ=".urlencode($search_categ); + if ($search_ref) $param="&search_ref=".urlencode($search_ref); + if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_barcode) $param.=($search_barcode?"&search_barcode=".urlencode($search_barcode):""); + if ($search_label) $param.="&search_label=".urlencode($search_label); + if ($search_tosell != '') $param.="&search_tosell=".urlencode($search_tosell); + if ($search_tobuy != '') $param.="&search_tobuy=".urlencode($search_tobuy); + if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); + if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); + if ($type != '') $param.='&type='.urlencode($type); + if ($search_type != '') $param.='&search_type='.urlencode($search_type); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); + if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + // List of mass actions available + $arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), + ); + if ($user->rights->produit->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); + if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + + $newcardbutton=''; + $rightskey='produit'; + if($type == Product::TYPE_SERVICE) $rightskey='service'; + if($user->rights->{$rightskey}->creer) + { + $label='NewProduct'; + if($type == Product::TYPE_SERVICE) $label='NewService'; + $newcardbutton=''.$langs->trans($label).''; + $newcardbutton.= ''; + $newcardbutton.= ''; + } + + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (empty($arrayfields['p.fk_product_type']['checked'])) print ''; + + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit); + + $topicmail="Information"; + $modelmail="product"; + $objecttmp=new Product($db); + $trackid='prod'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + if (! empty($catid)) + { + print "
"; + $c = new Categorie($db); + $ways = $c->print_all_ways(' > ','product/list.php'); + print " > ".$ways[0]."
\n"; + print "

"; + } + + if ($sall) + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + } + + // Filter on categories + $moreforfilter=''; + if (! empty($conf->categorie->enabled)) + { + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); + $moreforfilter.='
'; + } + + //Show/hide child products. Hidden by default + if (!empty($conf->variants->enabled) && $search_type === 0) { + $moreforfilter.='
'; + $moreforfilter.= ''; + $moreforfilter.= ' '; + $moreforfilter.='
'; + } + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; + else $moreforfilter=$hookmanager->resPrint; + + if ($moreforfilter) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + + print '
'; + print ''."\n"; + + // Lines with input filters + print ''; + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + } + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.label']['checked'])) + { + print ''; + } + // Type + if (! empty($arrayfields['p.fk_product_type']['checked'])) + { + print ''; + } + // Barcode + if (! empty($arrayfields['p.barcode']['checked'])) + { + print ''; + } + // Duration + if (! empty($arrayfields['p.duration']['checked'])) + { + print ''; + } + // Sell price + if (! empty($arrayfields['p.sellprice']['checked'])) + { + print ''; + } + // Minimum buying Price + if (! empty($arrayfields['p.minbuyprice']['checked'])) + { + print ''; + } + // Number buying Price + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + } + // WAP + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + } + // Limit for alert + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + { + print ''; + } + // Desired stock + if (! empty($arrayfields['p.desiredstock']['checked'])) + { + print ''; + } + // Stock + if (! empty($arrayfields['p.stock']['checked'])) print ''; + // Stock + if (! empty($arrayfields['stock_virtual']['checked'])) print ''; + // To batch + if (! empty($arrayfields['p.tobatch']['checked'])) print ''; + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['p.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['p.tms']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.tosell']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.tobuy']['checked'])) + { + print ''; + } + print ''; + + print ''; + + print ''; + if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; + + + $product_static=new Product($db); + $product_fourn =new ProductFournisseur($db); + + $i = 0; + $totalarray=array(); + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active +>>>>>>> edae0b4 Fix: remove unused code + { +<<<<<<< 8.0_canvas + if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service + { + $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() +======= + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$obj->rowid; + $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; + $sql.= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if (! empty($objtp->label)) $obj->label = $objtp->label; +>>>>>>> edae0b4 Fix: remove unused code + } + } + +<<<<<<< 8.0_canvas +======= + $product_static->id = $obj->rowid; + $product_static->ref = $obj->ref; + $product_static->ref_fourn = $obj->ref_supplier; + $product_static->label = $obj->label; + $product_static->type = $obj->fk_product_type; + $product_static->status_buy = $obj->tobuy; + $product_static->status = $obj->tosell; + $product_static->status_batch = $obj->tobatch; + $product_static->entity = $obj->entity; + $product_static->pmp = $obj->pmp; + $product_static->accountancy_code_sell = $obj->accountancy_code_sell; + $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock { if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service @@ -723,10 +1059,18 @@ if ($resql) $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() } } +>>>>>>> edae0b4 Fix: remove unused code +<<<<<<< 8.0_canvas + print ''; +======= +>>>>>>> edae0b4 Fix: remove unused code +<<<<<<< 8.0_canvas +======= print ''; +>>>>>>> edae0b4 Fix: remove unused code // Ref if (! empty($arrayfields['p.ref']['checked'])) { @@ -973,6 +1317,10 @@ if ($resql) print "
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); + print $form->selectarray('search_type', $array, $search_type); + print ''; + print ''; + print ''; + print ' '; + print ''; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print '  '.$form->selectyesno($search_tobatch, '', '', '', 1).''; + print ''; + print ''; + print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); + print ''; + print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
"; print "
"; +<<<<<<< 8.0_canvas +======= + print ''; +>>>>>>> edae0b4 Fix: remove unused code } print ''; } From 4c90ff9917433bc06271a06f2982edc05b4a7f51 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 19 Jun 2018 19:47:53 +0200 Subject: [PATCH 069/228] NEW add "checked" field for new list engine compatibility --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_c_field_list.sql | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 7ca1d16d67e..6fda9998bed 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -102,6 +102,8 @@ ALTER TABLE llx_c_type_fees ADD COLUMN type integer DEFAULT 0; ALTER TABLE llx_c_ecotaxe CHANGE COLUMN libelle label varchar(255); +ALTER TABLE llx_c_field_list ADD COLUMN checked tinyint DEFAULT 0 NOT NULL AFTER search; + ALTER TABLE llx_product_fournisseur_price DROP COLUMN unitcharges; ALTER TABLE llx_societe ADD COLUMN fk_entrepot integer DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_c_field_list.sql b/htdocs/install/mysql/tables/llx_c_field_list.sql index b22f98b52ec..17f8ef7356c 100644 --- a/htdocs/install/mysql/tables/llx_c_field_list.sql +++ b/htdocs/install/mysql/tables/llx_c_field_list.sql @@ -1,5 +1,5 @@ -- ======================================================================== --- Copyright (C) 2010 Regis Houssin +-- Copyright (C) 2010-2018 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 @@ -33,6 +33,7 @@ create table llx_c_field_list align varchar(6) DEFAULT 'left', -- align (left,center,right) sort tinyint DEFAULT 1 NOT NULL, -- add sort field search tinyint DEFAULT 0 NOT NULL, -- add search field + checked tinyint DEFAULT 0 NOT NULL, -- show or hide field by default enabled varchar(255) DEFAULT 1, -- Condition to show or hide rang integer DEFAULT 0 From ebfd1846a3473b743cd862c0b36b0f018f85f29b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 19 Jun 2018 20:07:00 +0200 Subject: [PATCH 070/228] Fix: add new field "checked" --- htdocs/product/canvas/product/actions_card_product.class.php | 5 +++-- htdocs/product/canvas/service/actions_card_service.class.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 3c0fc4d2b2f..379b80fd1eb 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 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 @@ -268,7 +268,7 @@ class ActionsCardProduct $this->field_list = array(); - $sql = "SELECT rowid, name, alias, title, align, sort, search, enabled, rang"; + $sql = "SELECT rowid, name, alias, title, align, sort, search, checked, enabled, rang"; $sql.= " FROM ".MAIN_DB_PREFIX."c_field_list"; $sql.= " WHERE element = '".$this->db->escape($this->fieldListName)."'"; $sql.= " AND entity = ".$conf->entity; @@ -293,6 +293,7 @@ class ActionsCardProduct $fieldlist["align"] = $obj->align; $fieldlist["sort"] = $obj->sort; $fieldlist["search"] = $obj->search; + $fieldlist["checked"] = $obj->checked; $fieldlist["enabled"] = verifCond($obj->enabled); $fieldlist["order"] = $obj->rang; diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index af227e54b0b..4758f0de08a 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 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 @@ -247,7 +247,7 @@ class ActionsCardService $this->field_list = array(); - $sql = "SELECT rowid, name, alias, title, align, sort, search, enabled, rang"; + $sql = "SELECT rowid, name, alias, title, align, sort, search, checked, enabled, rang"; $sql.= " FROM ".MAIN_DB_PREFIX."c_field_list"; $sql.= " WHERE element = '".$this->db->escape($this->fieldListName)."'"; $sql.= " AND entity = ".$conf->entity; @@ -272,6 +272,7 @@ class ActionsCardService $fieldlist["align"] = $obj->align; $fieldlist["sort"] = $obj->sort; $fieldlist["search"] = $obj->search; + $fieldlist["checked"] = $obj->checked; $fieldlist["enabled"] = verifCond($obj->enabled); $fieldlist["order"] = $obj->rang; From 5b491a4d57f89b072b21246b6e99d558df846cd8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 20 Jun 2018 10:59:46 +0200 Subject: [PATCH 071/228] Fix: remove duplicate code --- .../product/actions_card_product.class.php | 25 ++++--------------- .../canvas/product/tpl/card_create.tpl.php | 4 +-- .../canvas/product/tpl/card_edit.tpl.php | 4 +-- .../canvas/product/tpl/card_view.tpl.php | 10 -------- .../service/actions_card_service.class.php | 25 ++++--------------- .../canvas/service/tpl/card_create.tpl.php | 4 +-- .../canvas/service/tpl/card_edit.tpl.php | 4 +-- .../canvas/service/tpl/card_view.tpl.php | 10 -------- 8 files changed, 18 insertions(+), 68 deletions(-) diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 379b80fd1eb..1ea02816043 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -123,20 +123,6 @@ class ActionsCardProduct $this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,''); } - if ($action == 'create' || $action == 'edit') - { - // Status - $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - $this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->status); - - //To Buy - $statutarray=array('1' => $langs->trans("Yes"), '0' => $langs->trans("No")); - $this->tpl['tobuy'] = $form->selectarray('tobuy',$statutarray,$this->status_buy); - - $this->tpl['description'] = $this->description; - $this->tpl['note'] = $this->note; - } - if ($action == 'view') { $head = product_prepare_head($this->object); @@ -180,10 +166,13 @@ class ActionsCardProduct { // Status $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - $this->tpl['status'] = $form->selectarray('statut',$statutarray,$_POST["statut"]); + $this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->object->status); $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); - $this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]); + $this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$this->object->status_buy); + + $this->tpl['description'] = $this->description; + $this->tpl['note'] = $this->note; // Finished $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); @@ -208,10 +197,6 @@ class ActionsCardProduct if ($action == 'view') { - // Status - $this->tpl['status'] = $this->object->getLibStatut(2,0); - $this->tpl['status_buy'] = $this->object->getLibStatut(2,1); - // Photo $this->tpl['nblignes'] = 4; if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity])) diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index bc4b5409688..d3c29f32e2e 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 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 @@ -65,7 +65,7 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe
trans("Status").' ('.$langs->trans("Buy").')'; ?>selectarray('statut_buy',$statutarray,$object->status_tobuy); ?>selectarray('statut_buy',$statutarray,$object->status_buy); ?>
trans("Status").' ('.$langs->trans("Buy").')'; ?>selectarray('statut_buy',$statutarray,$object->status_tobuy); ?>selectarray('statut_buy',$statutarray,$object->status_buy); ?>
trans("Status").' ('.$langs->trans("Sell").')'; ?>status; ?>
trans("Status").' ('.$langs->trans("Buy").')'; ?>status_buy; ?>
trans("Description"); ?> description; ?>
trans("Status").' ('.$langs->trans("Buy").')'; ?>selectarray('statut_buy',$statutarray,$object->status_tobuy); ?>selectarray('statut_buy',$statutarray,$object->status_buy); ?>
trans("Duration"); ?>
trans("Status").' ('.$langs->trans("Buy").')'; ?>selectarray('statut_buy',$statutarray,$object->status_tobuy); ?>selectarray('statut_buy',$statutarray,$object->status_buy); ?>
trans("Duration"); ?>
trans("Status").' ('.$langs->trans("Sell").')'; ?>status; ?>
trans("Status").' ('.$langs->trans("Buy").')'; ?>status_buy; ?>
trans("Description"); ?> description; ?>
- - - - -
- - -
-
- -
" method="post" name="formulaire"> - - - - - - - - - - - - - - - - - - - - - - - $searchfield) { - if ($searchfield['enabled']) { - if ($searchfield['search']) { ?> - - '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; - } else { ?> - - - - - - - - > - $value) { - foreach($fieldlist as $field) { - if ($field['alias'] == $key) { ?> - - - - - -
- ?sortfield=&sortorder=asc&begin=&tosell=&canvas=default&fourn_id=&snom=&sref="> - A-Z - - ?sortfield=&sortorder=desc&begin=&tosell=&canvas=default&fourn_id=&snom=&sref="> - Z-A - -
 
-
- - \ No newline at end of file diff --git a/htdocs/product/canvas/service/tpl/list.tpl.php b/htdocs/product/canvas/service/tpl/list.tpl.php deleted file mode 100644 index ef6d461fc5c..00000000000 --- a/htdocs/product/canvas/service/tpl/list.tpl.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) -{ - print "Error, template page can't be called as URL"; - exit; -} - -?> - - - - - - - - -
- - -
-
- -
" method="post" name="formulaire"> - - - - - - - - - - - - - - - - - - - - - - - $searchfield) { - if ($searchfield['enabled']) { - if ($searchfield['search']) { ?> - - '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; - } else { ?> - - - - - - - - - $value) { - foreach($fieldlist as $field) { - if ($field['alias'] == $key) { ?> - - - - - -
- ?sortfield=&sortorder=asc&begin=&tosell=&canvas=default&fourn_id=&snom=&sref="> - A-Z - - ?sortfield=&sortorder=desc&begin=&tosell=&canvas=default&fourn_id=&snom=&sref="> - Z-A - -
 
-
- - \ No newline at end of file From debec3d17585dd8fcc0b62056610e81d281e5b3b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 22 Jun 2018 15:43:22 +0200 Subject: [PATCH 075/228] Fix: remove old code of canvas Conflicts: htdocs/product/list.php --- htdocs/product/list.php | 528 ++++++++++++++++++++++++++++++++-------- 1 file changed, 426 insertions(+), 102 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 63713846614..43dcb82b366 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -450,182 +450,470 @@ if ($resql) print "
"; } - if (! empty($canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$canvas.'/actions_card_'.$canvas.'.class.php')) + if ($sall) { - $fieldlist = $object->field_list; - $datas = $object->list_datas; - $picto='title.png'; - $title_picto = img_picto('',$picto); - $title_text = $title; - - // Default templates directory - $template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/'.$canvas.'/tpl/'; - // Check if a custom template is present - if (file_exists(DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/list.tpl.php')) - { - $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/'; - } - - include $template_dir.'list.tpl.php'; // Include native PHP templates + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - else + + // Filter on categories + $moreforfilter=''; + if (! empty($conf->categorie->enabled)) { - if ($sall) + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); + $moreforfilter.='
'; + } + + //Show/hide child products. Hidden by default + if (!empty($conf->variants->enabled) && $search_type === 0) { + $moreforfilter.='
'; + $moreforfilter.= ''; + $moreforfilter.= ' '; + $moreforfilter.='
'; + } + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; + else $moreforfilter=$hookmanager->resPrint; + + if ($moreforfilter) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + + print '
'; + print ''."\n"; + + // Lines with input filters + print ''; + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + } + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.label']['checked'])) + { + print ''; + } + // Type + if (! empty($arrayfields['p.fk_product_type']['checked'])) + { + print ''; + } + // Barcode + if (! empty($arrayfields['p.barcode']['checked'])) + { + print ''; + } + // Duration + if (! empty($arrayfields['p.duration']['checked'])) + { + print ''; + } + // Sell price + if (! empty($arrayfields['p.sellprice']['checked'])) + { + print ''; + } + // Minimum buying Price + if (! empty($arrayfields['p.minbuyprice']['checked'])) + { + print ''; + } + // Number buying Price + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + } + // WAP + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + } + // Limit for alert + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + { + print ''; + } + // Desired stock + if (! empty($arrayfields['p.desiredstock']['checked'])) + { + print ''; + } + // Stock + if (! empty($arrayfields['p.stock']['checked'])) print ''; + // Stock + if (! empty($arrayfields['stock_virtual']['checked'])) print ''; + // To batch + if (! empty($arrayfields['p.tobatch']['checked'])) print ''; + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['p.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['p.tms']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.tosell']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.tobuy']['checked'])) + { + print ''; + } + print ''; + + print ''; + + print ''; + if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; + + + $product_static=new Product($db); + $product_fourn =new ProductFournisseur($db); + + $i = 0; + $totalarray=array(); + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$obj->rowid; + $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; + $sql.= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if (! empty($objtp->label)) $obj->label = $objtp->label; + } } - // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) + $product_static->id = $obj->rowid; + $product_static->ref = $obj->ref; + $product_static->ref_fourn = $obj->ref_supplier; + $product_static->label = $obj->label; + $product_static->type = $obj->fk_product_type; + $product_static->status_buy = $obj->tobuy; + $product_static->status = $obj->tosell; + $product_static->status_batch = $obj->tobatch; + $product_static->entity = $obj->entity; + $product_static->pmp = $obj->pmp; + $product_static->accountancy_code_sell = $obj->accountancy_code_sell; + $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + + if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); - $moreforfilter.='
'; + if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service + { + $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() + } } - //Show/hide child products. Hidden by default - if (!empty($conf->variants->enabled) && $search_type === 0) { - $moreforfilter.='
'; - $moreforfilter.= ''; - $moreforfilter.= ' '; - $moreforfilter.='
'; - } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; - else $moreforfilter=$hookmanager->resPrint; + print ''; - if ($moreforfilter) - { - print '
'; - print $moreforfilter; - print '
'; - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - - print '
'; - print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); + print $form->selectarray('search_type', $array, $search_type); + print ''; + print ''; + print ''; + print ' '; + print ''; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print '  '.$form->selectyesno($search_tobatch, '', '', '', 1).''; + print ''; + print ''; + print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); + print ''; + print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'."\n"; - - // Lines with input filters - print ''; + // Ref if (! empty($arrayfields['p.ref']['checked'])) { - print ''; + print '\n"; + if (! $i) $totalarray['nbfield']++; } + // Ref supplier if (! empty($arrayfields['pfp.ref_fourn']['checked'])) { - print ''; + print '\n"; + if (! $i) $totalarray['nbfield']++; } + // Label if (! empty($arrayfields['p.label']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } + // Type if (! empty($arrayfields['p.fk_product_type']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } + // Barcode if (! empty($arrayfields['p.barcode']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } + // Duration if (! empty($arrayfields['p.duration']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } + // Sell price if (! empty($arrayfields['p.sellprice']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } - // Minimum buying Price + + // Better buy price if (! empty($arrayfields['p.minbuyprice']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } - // Number buying Price + + // Number of buy prices if (! empty($arrayfields['p.numbuyprice']['checked'])) { - print ''; } + // WAP if (! empty($arrayfields['p.pmp']['checked'])) { - print ''; } - // Limit for alert + + // Limit alert if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } // Desired stock if (! empty($arrayfields['p.desiredstock']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; + } + // Stock real + if (! empty($arrayfields['p.stock']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Stock virtual + if (! empty($arrayfields['stock_virtual']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Lot/Serial + if (! empty($arrayfields['p.tobatch']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; } - // Stock - if (! empty($arrayfields['p.stock']['checked'])) print ''; - // Stock - if (! empty($arrayfields['stock_virtual']['checked'])) print ''; - // To batch - if (! empty($arrayfields['p.tobatch']['checked'])) print ''; // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['p.datec']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['p.tms']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } + + // Status (to sell) if (! empty($arrayfields['p.tosell']['checked'])) { +<<<<<<< 8.0_canvas print ''; @@ -1305,14 +1593,41 @@ if ($resql) $selected=0; if (in_array($obj->rowid, $arrayofselected)) $selected=1; print ''; +======= + print ''; if (! $i) $totalarray['nbfield']++; - - print "\n"; - $i++; } + // Status (to buy) + if (! empty($arrayfields['p.tobuy']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action + print ''; + if (! $i) $totalarray['nbfield']++; +<<<<<<< 8.0_canvas $db->free($resql); print "
'; - print ''; - print ''; + print $product_static->getNomUrl(1); + print "'; - print ''; - print ''; + print $product_static->getNomUrl(1); + print "'; - print ''; - print ''.dol_trunc($obj->label,40).''; - $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); - print $form->selectarray('search_type', $array, $search_type); - print ''.$obj->fk_product_type.''; - print ''; - print ''.$obj->barcode.''; - print ' '; + print ''; + if (preg_match('/([^a-z]+)[a-z]/i',$obj->duration)) + { + if (preg_match('/([^a-z]+)y/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); + elseif (preg_match('/([^a-z]+)m/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); + elseif (preg_match('/([^a-z]+)w/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); + elseif (preg_match('/([^a-z]+)d/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); + //elseif (preg_match('/([^a-z]+)h/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); + else print $obj->duration; + } print ''; + print ''; + if ($obj->tosell) + { + if ($obj->price_base_type == 'TTC') print price($obj->price_ttc).' '.$langs->trans("TTC"); + else print price($obj->price).' '.$langs->trans("HT"); + } print ''; - print ' '; + print ''; + if ($obj->tobuy && $obj->minsellprice != '') + { + //print price($obj->minsellprice).' '.$langs->trans("HT"); + if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) + { + if ($product_fourn->product_fourn_price_id > 0) + { + if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + { + $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); + print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); + } + else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); + } + } + } print ''; - print ' '; + print ''; + if ($obj->tobuy) + { + if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) + { + $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + print $form->textwithpicto(count($productFournList),$htmltext); + } + } print ''; - print ' '; + print ''; + print price($product_static->pmp, 1, $langs); print ''; - print ' '; + print ''; + if ($obj->fk_product_type != 1) + { + print $obj->seuil_stock_alerte; + } print ''; - print ' '; + print ''; + if ($obj->fk_product_type != 1) + { + print $obj->desiredstock; + } print ''; + if ($obj->fk_product_type != 1) + { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + print $product_static->stock_reel; + } + print ''; + if ($obj->fk_product_type != 1) + { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + print $product_static->stock_theorique; + } + print ''; + print yn($obj->tobatch); + print '  '.$form->selectyesno($search_tobatch, '', '', '', 1).''.$obj->accountancy_code_sell.''.$obj->accountancy_code_buy.''; + print ''; + print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); print ''; + print ''; + print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); print ''; print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); print ''; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); + } else { + print $product_static->LibStatut($obj->tosell,5,0); +>>>>>>> 1d08002 Fix: remove old code of canvas } print '
'; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + } else { + print $product_static->LibStatut($obj->tobuy,5,1); + } + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
"; @@ -1321,7 +1636,16 @@ if ($resql) ======= print ''; >>>>>>> edae0b4 Fix: remove unused code +======= + print "
"; + print ""; print ''; } else From f3d213bab8f149b3a05aa0cbac5336beadcd83ba Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 30 Jun 2018 11:05:00 +0200 Subject: [PATCH 076/228] Fix: remove old code --- htdocs/product/list.php | 703 +--------------------------------------- 1 file changed, 5 insertions(+), 698 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 43dcb82b366..47135d22a15 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur - * Copyright (C) 2005-2018 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2013-2016 Juanjo Menent * Copyright (C) 2013-2015 Raphaël Doursenaud @@ -114,9 +114,9 @@ if (! empty($canvas)) } // Security check -if ($search_type=='0') $result=restrictedArea($user,'produit'); -else if ($search_type=='1') $result=restrictedArea($user,'service'); -else $result=restrictedArea($user,'produit|service'); +if ($search_type=='0') $result=restrictedArea($user,'produit','','','','','',$objcanvas); +else if ($search_type=='1') $result=restrictedArea($user,'service','','','','','',$objcanvas); +else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas); // Define virtualdiffersfromphysical $virtualdiffersfromphysical=0; @@ -453,7 +453,7 @@ if ($resql) if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; } // Filter on categories @@ -913,693 +913,11 @@ if ($resql) // Status (to sell) if (! empty($arrayfields['p.tosell']['checked'])) { -<<<<<<< 8.0_canvas - print ''; - print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); - print ''; - } - if (! empty($arrayfields['p.tobuy']['checked'])) - { - print ''; - print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); - print ''; - } - print ''; - $searchpicto=$form->showFilterButtons(); - print $searchpicto; - print ''; - - print ''; - - print ''; - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - - - $product_static=new Product($db); - $product_fourn =new ProductFournisseur($db); - - $i = 0; - $totalarray=array(); - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); - - // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active - { - $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$obj->rowid; - $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; - $sql.= " LIMIT 1"; - -<<<<<<< 8.0_canvas - $result = $db->query($sql); - if ($result) - { - $objtp = $db->fetch_object($result); - if (! empty($objtp->label)) $obj->label = $objtp->label; - } - } - - $product_static->id = $obj->rowid; - $product_static->ref = $obj->ref; - $product_static->ref_fourn = $obj->ref_supplier; - $product_static->label = $obj->label; - $product_static->type = $obj->fk_product_type; - $product_static->status_buy = $obj->tobuy; - $product_static->status = $obj->tosell; - $product_static->status_batch = $obj->tobatch; - $product_static->entity = $obj->entity; - $product_static->pmp = $obj->pmp; - $product_static->accountancy_code_sell = $obj->accountancy_code_sell; - $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; - $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; - $product_static->accountancy_code_buy = $obj->accountancy_code_buy; - - if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock -======= - llxHeader('',$title,$helpurl,''); - - // Displays product removal confirmation - if (GETPOST('delprod')) { - setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); - } - - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($search_categ > 0) $param.="&search_categ=".urlencode($search_categ); - if ($search_ref) $param="&search_ref=".urlencode($search_ref); - if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_barcode) $param.=($search_barcode?"&search_barcode=".urlencode($search_barcode):""); - if ($search_label) $param.="&search_label=".urlencode($search_label); - if ($search_tosell != '') $param.="&search_tosell=".urlencode($search_tosell); - if ($search_tobuy != '') $param.="&search_tobuy=".urlencode($search_tobuy); - if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); - if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); - if ($type != '') $param.='&type='.urlencode($type); - if ($search_type != '') $param.='&search_type='.urlencode($search_type); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); - if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - - // List of mass actions available - $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), - ); - if ($user->rights->produit->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - - $newcardbutton=''; - $rightskey='produit'; - if($type == Product::TYPE_SERVICE) $rightskey='service'; - if($user->rights->{$rightskey}->creer) - { - $label='NewProduct'; - if($type == Product::TYPE_SERVICE) $label='NewService'; - $newcardbutton=''.$langs->trans($label).''; - $newcardbutton.= ''; - $newcardbutton.= ''; - } - - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (empty($arrayfields['p.fk_product_type']['checked'])) print ''; - - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit); - - $topicmail="Information"; - $modelmail="product"; - $objecttmp=new Product($db); - $trackid='prod'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - - if (! empty($catid)) - { - print "
"; - $c = new Categorie($db); - $ways = $c->print_all_ways(' > ','product/list.php'); - print " > ".$ways[0]."
\n"; - print "

"; - } - - if ($sall) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); - } - - // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) - { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); - $moreforfilter.='
'; - } - - //Show/hide child products. Hidden by default - if (!empty($conf->variants->enabled) && $search_type === 0) { - $moreforfilter.='
'; - $moreforfilter.= ''; - $moreforfilter.= ' '; - $moreforfilter.='
'; - } - - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; - else $moreforfilter=$hookmanager->resPrint; - - if ($moreforfilter) - { - print '
'; - print $moreforfilter; - print '
'; - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - - print '
'; - print ''."\n"; - - // Lines with input filters - print ''; - if (! empty($arrayfields['p.ref']['checked'])) - { - print ''; - } - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.label']['checked'])) - { - print ''; - } - // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) - { - print ''; - } - // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) - { - print ''; - } - // Duration - if (! empty($arrayfields['p.duration']['checked'])) - { - print ''; - } - // Sell price - if (! empty($arrayfields['p.sellprice']['checked'])) - { - print ''; - } - // Minimum buying Price - if (! empty($arrayfields['p.minbuyprice']['checked'])) - { - print ''; - } - // Number buying Price - if (! empty($arrayfields['p.numbuyprice']['checked'])) - { - print ''; - } - // WAP - if (! empty($arrayfields['p.pmp']['checked'])) - { - print ''; - } - // Limit for alert - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) - { - print ''; - } - // Desired stock - if (! empty($arrayfields['p.desiredstock']['checked'])) - { - print ''; - } - // Stock - if (! empty($arrayfields['p.stock']['checked'])) print ''; - // Stock - if (! empty($arrayfields['stock_virtual']['checked'])) print ''; - // To batch - if (! empty($arrayfields['p.tobatch']['checked'])) print ''; - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['p.datec']['checked'])) - { - print ''; - } - // Date modification - if (! empty($arrayfields['p.tms']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.tosell']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.tobuy']['checked'])) - { - print ''; - } - print ''; - - print ''; - - print ''; - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - - - $product_static=new Product($db); - $product_fourn =new ProductFournisseur($db); - - $i = 0; - $totalarray=array(); - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); - - // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active ->>>>>>> edae0b4 Fix: remove unused code - { -<<<<<<< 8.0_canvas - if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service - { - $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() -======= - $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$obj->rowid; - $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; - $sql.= " LIMIT 1"; - - $result = $db->query($sql); - if ($result) - { - $objtp = $db->fetch_object($result); - if (! empty($objtp->label)) $obj->label = $objtp->label; ->>>>>>> edae0b4 Fix: remove unused code - } - } - -<<<<<<< 8.0_canvas -======= - $product_static->id = $obj->rowid; - $product_static->ref = $obj->ref; - $product_static->ref_fourn = $obj->ref_supplier; - $product_static->label = $obj->label; - $product_static->type = $obj->fk_product_type; - $product_static->status_buy = $obj->tobuy; - $product_static->status = $obj->tosell; - $product_static->status_batch = $obj->tobatch; - $product_static->entity = $obj->entity; - $product_static->pmp = $obj->pmp; - $product_static->accountancy_code_sell = $obj->accountancy_code_sell; - $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; - $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; - $product_static->accountancy_code_buy = $obj->accountancy_code_buy; - - if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock - { - if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service - { - $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() - } - } ->>>>>>> edae0b4 Fix: remove unused code - -<<<<<<< 8.0_canvas - print ''; -======= ->>>>>>> edae0b4 Fix: remove unused code - -<<<<<<< 8.0_canvas -======= - print ''; - ->>>>>>> edae0b4 Fix: remove unused code - // Ref - if (! empty($arrayfields['p.ref']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } - // Ref supplier - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } - // Label - if (! empty($arrayfields['p.label']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Duration - if (! empty($arrayfields['p.duration']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Sell price - if (! empty($arrayfields['p.sellprice']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Better buy price - if (! empty($arrayfields['p.minbuyprice']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Number of buy prices - if (! empty($arrayfields['p.numbuyprice']['checked'])) - { - print ''; - } - - // WAP - if (! empty($arrayfields['p.pmp']['checked'])) - { - print ''; - } - - // Limit alert - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Desired stock - if (! empty($arrayfields['p.desiredstock']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Stock real - if (! empty($arrayfields['p.stock']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Stock virtual - if (! empty($arrayfields['stock_virtual']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Lot/Serial - if (! empty($arrayfields['p.tobatch']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['p.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['p.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Status (to sell) - if (! empty($arrayfields['p.tosell']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status (to buy) - if (! empty($arrayfields['p.tobuy']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Action - print ''; if (! $i) $totalarray['nbfield']++; @@ -1627,19 +945,8 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; -<<<<<<< 8.0_canvas - $db->free($resql); - - print "
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); - print $form->selectarray('search_type', $array, $search_type); - print ''; - print ''; - print ''; - print ' '; - print ''; - print ''; - print ' '; - print ''; - print ' '; - print ''; - print ' '; - print ''; - print ' '; - print ''; - print ' '; - print '  '.$form->selectyesno($search_tobatch, '', '', '', 1).''; - print ''; - print ''; - print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); - print ''; - print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); - print ''; - $searchpicto=$form->showFilterButtons(); - print $searchpicto; - print '
'; - print $product_static->getNomUrl(1); - print "'; - print $product_static->getNomUrl(1); - print "'.dol_trunc($obj->label,40).''.$obj->fk_product_type.''.$obj->barcode.''; - if (preg_match('/([^a-z]+)[a-z]/i',$obj->duration)) - { - if (preg_match('/([^a-z]+)y/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([^a-z]+)m/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([^a-z]+)w/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); - elseif (preg_match('/([^a-z]+)d/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); - //elseif (preg_match('/([^a-z]+)h/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); - else print $obj->duration; - } - print ''; - if ($obj->tosell) - { - if ($obj->price_base_type == 'TTC') print price($obj->price_ttc).' '.$langs->trans("TTC"); - else print price($obj->price).' '.$langs->trans("HT"); - } - print ''; - if ($obj->tobuy && $obj->minsellprice != '') - { - //print price($obj->minsellprice).' '.$langs->trans("HT"); - if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) - { - if ($product_fourn->product_fourn_price_id > 0) - { - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) - { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); - } - else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); - } - } - } - print ''; - if ($obj->tobuy) - { - if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) - { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); - print $form->textwithpicto(count($productFournList),$htmltext); - } - } - print ''; - print price($product_static->pmp, 1, $langs); - print ''; - if ($obj->fk_product_type != 1) - { - print $obj->seuil_stock_alerte; - } - print ''; - if ($obj->fk_product_type != 1) - { - print $obj->desiredstock; - } - print ''; - if ($obj->fk_product_type != 1) - { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - print $product_static->stock_reel; - } - print ''; - if ($obj->fk_product_type != 1) - { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - print $product_static->stock_theorique; - } - print ''; - print yn($obj->tobatch); - print ''.$obj->accountancy_code_sell.''.$obj->accountancy_code_buy.''; - print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); - print ''; - print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); - print ''; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); - } else { - print $product_static->LibStatut($obj->tosell,5,0); - } - print ''; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); - } else { - print $product_static->LibStatut($obj->tobuy,5,1); - } - print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; -======= print ''; if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { print $product_static->LibStatut($obj->tosell,5,0); ->>>>>>> 1d08002 Fix: remove old code of canvas } print '
"; - print "
"; -<<<<<<< 8.0_canvas -======= - print '
'; ->>>>>>> edae0b4 Fix: remove unused code -======= print "\n"; $i++; ->>>>>>> 1d08002 Fix: remove old code of canvas } $db->free($resql); From 640f7697e4fbd46d4975ca0714a9a0dab0264ab0 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 30 Jun 2018 11:45:49 +0200 Subject: [PATCH 077/228] update code --- htdocs/core/modules/action/rapport.pdf.php | 9 +++---- .../core/modules/bank/doc/pdf_ban.modules.php | 8 +++--- .../modules/cheque/doc/pdf_blochet.class.php | 21 +++++++-------- .../fichinter/doc/pdf_soleil.modules.php | 8 +++--- .../modules/member/doc/pdf_standard.class.php | 9 +++---- .../doc/pdf_standardlabel.class.php | 8 +++--- .../printsheet/doc/pdf_tcpdflabel.class.php | 8 +++--- .../product/doc/pdf_standard.modules.php | 25 +++++++----------- .../project/doc/pdf_baleine.modules.php | 8 +++--- .../project/doc/pdf_beluga.modules.php | 8 +++--- .../project/doc/pdf_timespent.modules.php | 8 +++--- .../modules/propale/doc/pdf_azur.modules.php | 18 +++++-------- .../stock/doc/pdf_standard.modules.php | 26 +++++++------------ .../stock/doc/pdf_stdmovement.modules.php | 26 +++++++------------ 14 files changed, 69 insertions(+), 121 deletions(-) diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index 504164cd431..7dec29e5189 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -99,12 +99,9 @@ class CommActionRapport if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products")); $dir = $conf->agenda->dir_temp."/"; $file = $dir . "actions-".$this->month."-".$this->year.".pdf"; diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 9941742d8d7..710d996757c 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -99,11 +99,9 @@ class pdf_ban extends ModeleBankAccountDoc if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("projects"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); if ($conf->bank->dir_output) { diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 1e539a2019f..5cb8fbe397e 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -44,9 +44,9 @@ class BordereauChequeBlochet extends ModeleChequeReceipts function __construct($db) { global $conf,$langs,$mysoc; - - $langs->load("main"); - $langs->load("bills"); + + // Load traductions files requiredby by page + $langs->loadLangs(array("main", "bills")); $this->db = $db; $this->name = "blochet"; @@ -91,12 +91,9 @@ class BordereauChequeBlochet extends ModeleChequeReceipts // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO $sav_charset_output=$outputlangs->charset_output; if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); - $outputlangs->load("compta"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta")); $dir = $_dir . "/".get_exdir($number,0,1,0,$object,'cheque').$number; @@ -213,9 +210,9 @@ class BordereauChequeBlochet extends ModeleChequeReceipts { global $langs; $default_font_size = pdf_getPDFFontSize($outputlangs); - - $outputlangs->load("compta"); - $outputlangs->load("banks"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("compta", "banks"")); $title = $outputlangs->transnoentities("CheckReceipt"); $pdf->SetFont('','B', $default_font_size); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index aa7ed05070b..af68e2fec4d 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -495,11 +495,9 @@ class pdf_soleil extends ModelePDFFicheinter { global $conf,$langs; $default_font_size = pdf_getPDFFontSize($outputlangs); - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("interventions"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "interventions")); pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 4d08be83a43..49acce1e2d6 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -323,12 +323,9 @@ class pdf_standard extends CommonStickerGenerator if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("admin"); - $outputlangs->load("members"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members")); if (empty($mode) || $mode == 'member') { diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index 78898735f0c..d76b397ace8 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -254,11 +254,9 @@ class pdf_standardlabel extends CommonStickerGenerator if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("admin"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "admin")); $title=$outputlangs->transnoentities('Labels'); $keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name); diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index faa62d45431..e527c8faaca 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -295,11 +295,9 @@ class pdf_tcpdflabel extends CommonStickerGenerator if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("admin"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "admin")); $title=$outputlangs->transnoentities('Labels'); $keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name); diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 032f75f0d65..7e53bab7133 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -87,9 +87,9 @@ class pdf_standard extends ModelePDFProduct public function __construct($db) { global $conf,$langs,$mysoc; - - $langs->load("main"); - $langs->load("companies"); + + // Load traductions files requiredby by page + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "standard"; @@ -135,14 +135,9 @@ class pdf_standard extends ModelePDFProduct if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); - $outputlangs->load("orders"); - $outputlangs->load("deliveries"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); $nblignes = count($object->lines); @@ -687,12 +682,10 @@ class pdf_standard extends ModelePDFProduct function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") { global $conf,$langs,$hookmanager; + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders")); - $outputlangs->load("main"); - $outputlangs->load("bills"); - $outputlangs->load("propal"); - $outputlangs->load("companies"); - $outputlangs->load("orders"); $default_font_size = pdf_getPDFFontSize($outputlangs); if ($object->type == 1) $titlekey='ServiceSheet'; diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index baa38e8ad2d..ed1edd2a19e 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -108,11 +108,9 @@ class pdf_baleine extends ModelePDFProjects if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("projects"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); if ($conf->projet->dir_output) { diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 4f1d9179aa1..b487c211376 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -126,11 +126,9 @@ class pdf_beluga extends ModelePDFProjects if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("projects"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); if ($conf->projet->dir_output) { diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index c7f23df52e3..6bcfe287b70 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -107,11 +107,9 @@ class pdf_timespent extends ModelePDFProjects if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("projects"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); if ($conf->projet->dir_output) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 6e72e757fb6..8c54aa48bda 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -160,13 +160,9 @@ class pdf_azur extends ModelePDFPropales if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("propal"); - $outputlangs->load("products"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "propal", "products")); $nblignes = count($object->lines); @@ -1377,11 +1373,9 @@ class pdf_azur extends ModelePDFPropales function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; - - $outputlangs->load("main"); - $outputlangs->load("bills"); - $outputlangs->load("propal"); - $outputlangs->load("companies"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "propal", "companies", "bills")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 5825bd693f5..66ad1413dcd 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -87,9 +87,9 @@ class pdf_standard extends ModelePDFStock public function __construct($db) { global $conf,$langs,$mysoc; - - $langs->load("main"); - $langs->load("companies"); + + // Load traductions files requiredby by page + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "standard"; @@ -164,14 +164,9 @@ class pdf_standard extends ModelePDFStock if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("stocks"); - $outputlangs->load("orders"); - $outputlangs->load("deliveries"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries")); $nblignes = count($object->lines); @@ -919,13 +914,10 @@ class pdf_standard extends ModelePDFStock function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") { global $conf,$langs,$db,$hookmanager; + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks")); - $outputlangs->load("main"); - $outputlangs->load("bills"); - $outputlangs->load("propal"); - $outputlangs->load("companies"); - $outputlangs->load("orders"); - $outputlangs->load("stocks"); $default_font_size = pdf_getPDFFontSize($outputlangs); if ($object->type == 1) $titlekey='ServiceSheet'; diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index f8844a275e5..5f8a62a90c6 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -88,9 +88,9 @@ class pdf_stdmovement extends ModelePDFMovement public function __construct($db) { global $conf,$langs,$mysoc; - - $langs->load("main"); - $langs->load("companies"); + + // Load traductions files requiredby by page + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "stdmouvement"; @@ -167,14 +167,9 @@ class pdf_stdmovement extends ModelePDFMovement if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("stocks"); - $outputlangs->load("orders"); - $outputlangs->load("deliveries"); + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries")); /** * TODO: get from object @@ -921,13 +916,10 @@ class pdf_stdmovement extends ModelePDFMovement function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") { global $conf,$langs,$db,$hookmanager; + + // Load traductions files requiredby by page + $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks")); - $outputlangs->load("main"); - $outputlangs->load("bills"); - $outputlangs->load("propal"); - $outputlangs->load("companies"); - $outputlangs->load("orders"); - $outputlangs->load("stocks"); $default_font_size = pdf_getPDFFontSize($outputlangs); if ($object->type == 1) $titlekey='ServiceSheet'; From 982a1ffbafecaa861238982c41bd5dbe6a271393 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jun 2018 14:22:05 +0200 Subject: [PATCH 078/228] NEW Automatic position of scroll when creating an extrafield --- htdocs/admin/agenda_extrafields.php | 4 ++-- htdocs/admin/bank_extrafields.php | 4 ++-- htdocs/admin/expedition_extrafields.php | 4 ++-- htdocs/admin/expeditiondet_extrafields.php | 4 ++-- htdocs/admin/expensereport_extrafields.php | 4 ++-- htdocs/admin/livraison_extrafields.php | 4 ++-- htdocs/admin/livraisondet_extrafields.php | 4 ++-- htdocs/admin/order_extrafields.php | 4 ++-- htdocs/admin/orderdet_extrafields.php | 4 ++-- htdocs/admin/resource_extrafields.php | 4 ++-- htdocs/admin/supplierinvoice_extrafields.php | 4 ++-- htdocs/admin/supplierinvoicedet_extrafields.php | 4 ++-- htdocs/admin/supplierorder_extrafields.php | 4 ++-- htdocs/admin/supplierorderdet_extrafields.php | 4 ++-- htdocs/categories/admin/categorie_extrafields.php | 4 ++-- htdocs/comm/admin/propaldet_extrafields.php | 4 ++-- htdocs/compta/facture/admin/facture_cust_extrafields.php | 4 ++-- .../compta/facture/admin/facture_rec_cust_extrafields.php | 4 ++-- htdocs/compta/facture/admin/facturedet_cust_extrafields.php | 4 ++-- .../facture/admin/facturedet_rec_cust_extrafields.php | 4 ++-- htdocs/contrat/admin/contract_extrafields.php | 4 ++-- htdocs/contrat/admin/contractdet_extrafields.php | 6 +++--- htdocs/fichinter/admin/fichinter_extrafields.php | 6 +++--- htdocs/fichinter/admin/fichinterdet_extrafields.php | 6 +++--- htdocs/product/admin/product_extrafields.php | 6 +++--- htdocs/product/admin/product_lot_extrafields.php | 6 +++--- htdocs/societe/admin/contact_extrafields.php | 6 +++--- htdocs/societe/admin/societe_extrafields.php | 6 +++--- .../admin/supplier_proposaldet_extrafields.php | 6 +++--- htdocs/user/admin/group_extrafields.php | 4 ++-- htdocs/user/admin/user_extrafields.php | 4 ++-- 31 files changed, 70 insertions(+), 70 deletions(-) diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index fadb144b883..69e834e22e2 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -85,7 +85,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -98,7 +98,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 19446092923..99b8d09f277 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -82,7 +82,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -95,7 +95,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/expedition_extrafields.php b/htdocs/admin/expedition_extrafields.php index af49e5bf064..12365f1801d 100644 --- a/htdocs/admin/expedition_extrafields.php +++ b/htdocs/admin/expedition_extrafields.php @@ -87,7 +87,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -100,7 +100,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/expeditiondet_extrafields.php b/htdocs/admin/expeditiondet_extrafields.php index 5567e9480e8..89b270d10fc 100644 --- a/htdocs/admin/expeditiondet_extrafields.php +++ b/htdocs/admin/expeditiondet_extrafields.php @@ -88,7 +88,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -101,7 +101,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 8db81edb869..99d1bd0e8da 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -83,7 +83,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -96,7 +96,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/livraison_extrafields.php b/htdocs/admin/livraison_extrafields.php index 6ccf798bc93..c9fed1c6554 100644 --- a/htdocs/admin/livraison_extrafields.php +++ b/htdocs/admin/livraison_extrafields.php @@ -87,7 +87,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -100,7 +100,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/livraisondet_extrafields.php b/htdocs/admin/livraisondet_extrafields.php index 431d5c3c170..921e9cfee41 100644 --- a/htdocs/admin/livraisondet_extrafields.php +++ b/htdocs/admin/livraisondet_extrafields.php @@ -88,7 +88,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -101,7 +101,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index 361fc5b67bb..a8031c915a9 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -85,7 +85,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -98,7 +98,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index c75551cf9f0..2e1b00025cd 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -86,7 +86,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -99,7 +99,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index 8193d146aaa..722e5d88a9c 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -84,7 +84,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -97,7 +97,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 7e913772e2c..16da8bf7a5c 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -91,7 +91,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -104,7 +104,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index d8156d54779..4ca9fd516d7 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -87,7 +87,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -100,7 +100,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index 30cf4d983e4..58c0408510d 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -85,7 +85,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -98,7 +98,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 85106bf84f0..7dfaa02545e 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -86,7 +86,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -99,7 +99,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 3fd7d1c69b5..3fbd29a640b 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -79,7 +79,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -92,7 +92,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index 49784228fe6..0816a4c035c 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -86,7 +86,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -99,7 +99,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index 2c676e399de..4e44774e0c4 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -80,7 +80,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -93,7 +93,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 18aa3c99442..54d3da8e18a 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index 2b90ae7fe05..c2490da4f42 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 97f8b78b195..28c70ea9024 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index b9b0d51c162..d19c91e0bf2 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print '

'; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php index 42a8ed589d7..af2585eaf3a 100644 --- a/htdocs/contrat/admin/contractdet_extrafields.php +++ b/htdocs/contrat/admin/contractdet_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,8 +94,8 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } diff --git a/htdocs/fichinter/admin/fichinter_extrafields.php b/htdocs/fichinter/admin/fichinter_extrafields.php index 40fd63d7639..bcda9b4847b 100644 --- a/htdocs/fichinter/admin/fichinter_extrafields.php +++ b/htdocs/fichinter/admin/fichinter_extrafields.php @@ -80,7 +80,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -93,8 +93,8 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php index eab70d5d585..8046ef41a18 100644 --- a/htdocs/fichinter/admin/fichinterdet_extrafields.php +++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,8 +94,8 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } diff --git a/htdocs/product/admin/product_extrafields.php b/htdocs/product/admin/product_extrafields.php index 849b346244d..7da3e800468 100644 --- a/htdocs/product/admin/product_extrafields.php +++ b/htdocs/product/admin/product_extrafields.php @@ -94,7 +94,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -107,8 +107,8 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } diff --git a/htdocs/product/admin/product_lot_extrafields.php b/htdocs/product/admin/product_lot_extrafields.php index be3651344ff..23e87d23476 100644 --- a/htdocs/product/admin/product_lot_extrafields.php +++ b/htdocs/product/admin/product_lot_extrafields.php @@ -84,7 +84,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -97,8 +97,8 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } diff --git a/htdocs/societe/admin/contact_extrafields.php b/htdocs/societe/admin/contact_extrafields.php index 4facdd11ea1..6a359232a16 100644 --- a/htdocs/societe/admin/contact_extrafields.php +++ b/htdocs/societe/admin/contact_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,8 +94,8 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } diff --git a/htdocs/societe/admin/societe_extrafields.php b/htdocs/societe/admin/societe_extrafields.php index 06dc57677f5..11131eb25af 100644 --- a/htdocs/societe/admin/societe_extrafields.php +++ b/htdocs/societe/admin/societe_extrafields.php @@ -82,7 +82,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -95,7 +95,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; @@ -108,7 +108,7 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && ! empty($attrname)) { - print "
"; + print '
'; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; diff --git a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php index 1acf85b45a3..1f5b9582558 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php @@ -113,7 +113,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -126,8 +126,8 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } diff --git a/htdocs/user/admin/group_extrafields.php b/htdocs/user/admin/group_extrafields.php index 0dd5cf9ce7e..9f431909957 100644 --- a/htdocs/user/admin/group_extrafields.php +++ b/htdocs/user/admin/group_extrafields.php @@ -82,7 +82,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -95,7 +95,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/user/admin/user_extrafields.php b/htdocs/user/admin/user_extrafields.php index bf704af2003..ff07845f92d 100644 --- a/htdocs/user/admin/user_extrafields.php +++ b/htdocs/user/admin/user_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; From edd2e12b8d84d161295ab1d205e74a4b08a8d613 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jun 2018 14:35:33 +0200 Subject: [PATCH 079/228] css --- htdocs/langs/en_US/modulebuilder.lang | 1 + htdocs/modulebuilder/index.php | 38 +++++++++++++-------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index ed3a872d3c6..460cdce63c2 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -74,6 +74,7 @@ NoWidget=No widget GoToApiExplorer=Go to API explorer ListOfMenusEntries=List of menu entries ListOfPermissionsDefined=List of defined permissions +SeeExamples=See examples here EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) VisibleDesc=Is the field visible ? (Examples: 0=Never visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only. Using a negative value means field is not shown by default on list but can be selected for viewing) IsAMeasureDesc=Can the value of field be cumulated to get a total into list ? (Examples: 1 or 0) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1d0c7960fda..5350fd170f1 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -120,7 +120,7 @@ if ($dirins && $action == 'initmodule' && $modulename) setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); } } - + if(!empty($conf->global->MODULEBUILDER_USE_ABOUT)){ dol_delete_file($destdir.'/admin/about.php'); } @@ -172,7 +172,7 @@ if ($dirins && $action == 'initmodule' && $modulename) setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); } } - + if(!empty($conf->global->MODULEBUILDER_SPECIFIC_README)){ dol_delete_file($destdir.'/README.md'); file_put_contents($destdir.'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README); @@ -1680,24 +1680,24 @@ elseif (! empty($module)) print '
'; print ''; print ''; - print ''; - print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; // We must use $reflectorpropdefault['fields'] to get list of fields because $tmpobjet->fields may have been From 598f90486f1836f765bcedcfa9de933cba1103bc Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 30 Jun 2018 17:03:00 +0200 Subject: [PATCH 080/228] Fix: syntax error (Travis) --- htdocs/fichinter/card.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 88ceffcc7aa..c5ff6d18ddc 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2011-2017 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2018 Ferran Marcet @@ -1646,9 +1646,8 @@ else if ($id > 0 || ! empty($ref)) // create interventional model if ($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) { print ''; + print ''.$langs->trans("ChangeIntoRepeatableInterventional").''; + print ''; } // Proposal From 751ddb46d271975239632513412df181a881f58b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jun 2018 18:31:32 +0200 Subject: [PATCH 081/228] Update pdf_blochet.class.php --- htdocs/core/modules/cheque/doc/pdf_blochet.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 5cb8fbe397e..097cd336c94 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -212,7 +212,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $default_font_size = pdf_getPDFFontSize($outputlangs); // Load traductions files requiredby by page - $outputlangs->loadLangs(array("compta", "banks"")); + $outputlangs->loadLangs(array("compta", "banks")); $title = $outputlangs->transnoentities("CheckReceipt"); $pdf->SetFont('','B', $default_font_size); From e06eb9e2fce526ec15f99d6339fbab00b8018e98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jun 2018 18:38:23 +0200 Subject: [PATCH 082/228] Fix phpcs --- htdocs/core/modules/holiday/mod_holiday_immaculate.php | 8 ++++---- htdocs/core/modules/holiday/mod_holiday_madonna.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index 1355ba90302..a00c3825f47 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -121,12 +121,12 @@ class mod_holiday_immaculate extends ModelNumRefHolidays /** * Return next value * - * @param Societe $objsoc third party object - * @param Object $objforref contract object + * @param User $fuser User object + * @param Object $objforref Holiday object * @return string Value if OK, 0 if KO */ - function holiday_get_num($user, $objforref) + function holiday_get_num($fuser, $objforref) { - return $this->getNextValue($user, $objforref); + return $this->getNextValue($fuser, $objforref); } } diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index b5848263c98..3b77230f77f 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -136,13 +136,13 @@ class mod_holiday_madonna extends ModelNumRefHolidays /** * Return next value * - * @param Societe $objsoc third party object - * @param Object $objforref contract object + * @param User $fuser User object + * @param Object $objforref Holiday object * @return string Value if OK, 0 if KO */ - function holiday_get_num($objsoc,$objforref) + function holiday_get_num($fuser,$objforref) { - return $this->getNextValue($objsoc,$objforref); + return $this->getNextValue($fuser,$objforref); } } From 00cee4a88ce256223226c867dd0568e9e3490707 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 00:00:07 +0200 Subject: [PATCH 083/228] Fix travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 51b62e240e9..b68dad91a69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -334,6 +334,9 @@ script: php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log php upgrade2.php 7.0.0 8.0.0 MAIN_MODULE_TICKETSUP > $TRAVIS_BUILD_DIR/upgrade700800-2.log php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log + php upgrade.php 8.0.0 9.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade800900.log + php upgrade2.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-2.log + php step5.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-3.log cd - set +e echo From e6bec412ac76a938b992029e47c090a5770b25f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 00:56:32 +0200 Subject: [PATCH 084/228] Show logs --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b68dad91a69..667f0b4794c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -354,8 +354,8 @@ script: set +e - | - #echo "Output dolibarr.log" - #cat documents/dolibarr.log + echo "Output 50 latest lines of dolibarr.log" + tail -n 50 documents/dolibarr.log after_script: - | From bd5729f9411098852f6fd917a744a62fb66961b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 11:59:06 +0200 Subject: [PATCH 085/228] Test travis --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 667f0b4794c..18925189f86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -349,12 +349,14 @@ script: - | echo "Unit testing" # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. - set -e + set +e phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php + phpunitresult=$? + echo "Phpunit return code = $phpunitresult set +e - | - echo "Output 50 latest lines of dolibarr.log" + echo Output 50 latest lines of dolibarr.log" tail -n 50 documents/dolibarr.log after_script: From 43c5d7abdc6532506ce5a66a8a374d0d2c5bda3f Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 1 Jul 2018 17:33:35 +0200 Subject: [PATCH 086/228] add holliday_admin_prepare_head sorry eldy i forget it --- htdocs/core/lib/holiday.lib.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index 56d19d0e0f1..b0653968c5f 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -61,3 +61,32 @@ function holiday_prepare_head($object) return $head; } + + +/** + * Return array head with list of tabs to view object informations + * + * @return array head + */ +function holiday_admin_prepare_head() +{ + global $db, $langs, $conf, $user; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/admin/holiday.php'; + $head[$h][1] = $langs->trans("Setup"); + $head[$h][2] = 'holiday'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin','remove'); + + return $head; +} From 0297290365a2b5d0265e6ec1e11b94e24a700dfa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 21:13:29 +0200 Subject: [PATCH 087/228] Travis test --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18925189f86..f1d89de1bf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -381,10 +381,11 @@ after_failure: # Apache log file sudo cat /var/log/apache2/error.log # Dolibarr log file - cat documents/dolibarr.log if [ "$DEBUG" = true ]; then + echo Output 50 latest lines of dolibarr.log" + tail -n 50 documents/dolibarr.log # MariaDB log file - sudo cat /var/log/mysql/error.log + sudo tail -n 50 /var/log/mysql/error.log # TODO: PostgreSQL log file echo fi From 2872cf0c2aa66abfde1ce0fe7de6f0c7d1779992 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 21:16:36 +0200 Subject: [PATCH 088/228] Fix travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f1d89de1bf3..00ff65a91fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -383,7 +383,7 @@ after_failure: # Dolibarr log file if [ "$DEBUG" = true ]; then echo Output 50 latest lines of dolibarr.log" - tail -n 50 documents/dolibarr.log + tail -n 50 documents/dolibarr.log # MariaDB log file sudo tail -n 50 /var/log/mysql/error.log # TODO: PostgreSQL log file From c0eac8600d020cafac6d7c23475bee24803cfa2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 22:41:09 +0200 Subject: [PATCH 089/228] Test travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00ff65a91fb..14d1779b605 100644 --- a/.travis.yml +++ b/.travis.yml @@ -239,7 +239,7 @@ before_script: echo "Create documents directory and set permissions" # and admin/temp subdirectory needed for unit tests mkdir -p documents/admin/temp - echo "first line" > documents/dolibarr.log + echo "***** First line of dolibarr.log" > documents/dolibarr.log echo @@ -357,7 +357,7 @@ script: - | echo Output 50 latest lines of dolibarr.log" - tail -n 50 documents/dolibarr.log + tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log after_script: - | @@ -383,7 +383,7 @@ after_failure: # Dolibarr log file if [ "$DEBUG" = true ]; then echo Output 50 latest lines of dolibarr.log" - tail -n 50 documents/dolibarr.log + tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log # MariaDB log file sudo tail -n 50 /var/log/mysql/error.log # TODO: PostgreSQL log file From 26306c90f4a0feea2ffa6144aec115aa22d11c16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 22:46:54 +0200 Subject: [PATCH 090/228] Better log --- .travis.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14d1779b605..0709baef38c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -372,19 +372,23 @@ after_success: after_failure: - | - echo Failure - # This part of code seems to be never executed, error or not ??? - echo "Debugging informations" + echo Failure detected, so we show samples of log to help diagnose + # This part of code is executed only if previous commande that fails are enclosed with set +e # Upgrade log files - cat *.log - echo "Debugging informations" + for ficlog in `ls $TRAVIS_BUILD_DIR/*.log` + do + echo "Debugging informations for file $ficlog" + cat $ficlog + done + echo "Debugging informations for file apache error.log" # Apache log file sudo cat /var/log/apache2/error.log # Dolibarr log file if [ "$DEBUG" = true ]; then - echo Output 50 latest lines of dolibarr.log" + echo "Debugging informations for file dolibarr.log (latest 50 lines)" tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log # MariaDB log file + echo "Debugging informations for file mysql error.log" sudo tail -n 50 /var/log/mysql/error.log # TODO: PostgreSQL log file echo From c92d3419967b5006e19e28ea694d0015ab3127be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 22:56:23 +0200 Subject: [PATCH 091/228] Test travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0709baef38c..95b7441fe64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -357,6 +357,7 @@ script: - | echo Output 50 latest lines of dolibarr.log" + ls $TRAVIS_BUILD_DIR/documents tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log after_script: @@ -378,7 +379,7 @@ after_failure: for ficlog in `ls $TRAVIS_BUILD_DIR/*.log` do echo "Debugging informations for file $ficlog" - cat $ficlog + #cat $ficlog done echo "Debugging informations for file apache error.log" # Apache log file From 216df5622fd264ad8152c71ae114d71dde1c0a9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 23:00:10 +0200 Subject: [PATCH 092/228] Test travis --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 95b7441fe64..ec95a973cdd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -238,8 +238,9 @@ before_script: - | echo "Create documents directory and set permissions" # and admin/temp subdirectory needed for unit tests - mkdir -p documents/admin/temp - echo "***** First line of dolibarr.log" > documents/dolibarr.log + mkdir -p $TRAVIS_BUILD_DIR/documents/admin/temp + sudo chmod -R a+rwx $TRAVIS_BUILD_DIR/documents + echo "***** First line of dolibarr.log" > $TRAVIS_BUILD_DIR/documents/dolibarr.log echo From c03d7b97db49478892f749071ecc8904723a62fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 23:14:03 +0200 Subject: [PATCH 093/228] Test travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec95a973cdd..ee5698920dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -353,7 +353,7 @@ script: set +e phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php phpunitresult=$? - echo "Phpunit return code = $phpunitresult + echo "Phpunit return code = $phpunitresult" set +e - | @@ -382,11 +382,11 @@ after_failure: echo "Debugging informations for file $ficlog" #cat $ficlog done - echo "Debugging informations for file apache error.log" # Apache log file + echo "Debugging informations for file apache error.log" sudo cat /var/log/apache2/error.log - # Dolibarr log file if [ "$DEBUG" = true ]; then + # Dolibarr log file echo "Debugging informations for file dolibarr.log (latest 50 lines)" tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log # MariaDB log file From a04055dc4703b0c62042fc299abdf45d047cb79b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 23:17:12 +0200 Subject: [PATCH 094/228] Fix travis --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee5698920dc..10b87d94ce8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -363,9 +363,8 @@ script: after_script: - | - # Dolibarr log file - #echo "After script" - #cat documents/dolibarr.log + #echo "After script - Debugging informations for file dolibarr.log (latest 50 lines)" + #tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log after_success: From 41e1370f7ae6b3e6eb0a400c1c9b5b88d520deae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 23:27:27 +0200 Subject: [PATCH 095/228] Fix travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 10b87d94ce8..c6c5fb0ccb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -357,7 +357,7 @@ script: set +e - | - echo Output 50 latest lines of dolibarr.log" + echo "Output 50 latest lines of dolibarr.log" ls $TRAVIS_BUILD_DIR/documents tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log From 884e8cee905ef7494a941d81ed76b8bc6d4b7deb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 23:39:14 +0200 Subject: [PATCH 096/228] Test travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c6c5fb0ccb5..ea31a6cbe28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -350,7 +350,7 @@ script: - | echo "Unit testing" # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. - set +e + set -e phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php phpunitresult=$? echo "Phpunit return code = $phpunitresult" @@ -363,8 +363,8 @@ script: after_script: - | - #echo "After script - Debugging informations for file dolibarr.log (latest 50 lines)" - #tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log + echo "After script - Debugging informations for file dolibarr.log (latest 50 lines)" + tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log after_success: From 93184c5f6666cb4d3b7f3860ef88cfd145cec537 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Jul 2018 23:57:54 +0200 Subject: [PATCH 097/228] Fix travis --- .travis.yml | 14 ++------------ htdocs/core/modules/modSupplierProposal.class.php | 2 +- test/phpunit/SupplierProposalTest.php | 6 +++++- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea31a6cbe28..90a9f6355cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -341,11 +341,6 @@ script: cd - set +e echo - #cat $TRAVIS_BUILD_DIR/upgrade400500-2.log - #cat $TRAVIS_BUILD_DIR/upgrade500600.log - #cat $TRAVIS_BUILD_DIR/upgrade500600-2.log - #cat $TRAVIS_BUILD_DIR/upgrade500600-3.log - #cat /tmp/dolibarr_install.log - | echo "Unit testing" @@ -356,17 +351,12 @@ script: echo "Phpunit return code = $phpunitresult" set +e -- | - echo "Output 50 latest lines of dolibarr.log" - ls $TRAVIS_BUILD_DIR/documents - tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log - after_script: - | - echo "After script - Debugging informations for file dolibarr.log (latest 50 lines)" + echo "After script - Output 50 latest lines of dolibarr.log" + ls $TRAVIS_BUILD_DIR/documents tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log - after_success: - | echo Success diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 34584ea3ffa..7b2a378019d 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -32,7 +32,7 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; /** - * Class to describe and enable module AskPriceSupllier + * Class to describe and enable module SupplierProposal */ class modSupplierProposal extends DolibarrModules { diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index ee4729ed47f..292bba71497 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -134,6 +134,8 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; + $user->rights->supplier_proposal->creer = 1; // Not set after the reload of module done in 7.0 + $localobject=new SupplierProposal($this->savdb); $localobject->initAsSpecimen(); $result=$localobject->create($user); @@ -210,7 +212,9 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $result=$localobject->valid($user); + $user->rights->supplier_proposal->creer = 1; // Not set after the reload of module done in 7.0 + + $result=$localobject->valid($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); From 7e7d419e2d620108b5fa3092c5d07bca711d323d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Jul 2018 08:43:08 +0200 Subject: [PATCH 098/228] Test travis --- test/phpunit/SupplierProposalTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index 292bba71497..dd7d6a5777f 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -134,6 +134,8 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; + var_dump($conf->supplier_proposal->enabled); + var_dump($user->rights->supplier_proposal); $user->rights->supplier_proposal->creer = 1; // Not set after the reload of module done in 7.0 $localobject=new SupplierProposal($this->savdb); From fec9a96ad16bdc49c607476f5f9a68a7f85e32c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Jul 2018 09:34:34 +0200 Subject: [PATCH 099/228] Fix travis --- htdocs/user/class/user.class.php | 28 +++++++++++++++------------ test/phpunit/SupplierProposalTest.php | 13 ++++++------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index c89fb3e904b..f83b2e85e72 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -137,7 +137,7 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; - + public $fields=array( 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), @@ -434,7 +434,7 @@ class User extends CommonObject /** * Add a right to the user * - * @param int $rid id of permission to add + * @param int $rid Id of permission to add or 0 to add several permissions * @param string $allmodule Add all permissions of module $allmodule * @param string $allperms Add all permissions of module $allmodule, subperms $allperms only * @param int $entity Entity to use @@ -679,24 +679,28 @@ class User extends CommonObject /** * Load permissions granted to user into object user * - * @param string $moduletag Limit permission for a particular module ('' by default means load all permissions) + * @param string $moduletag Limit permission for a particular module ('' by default means load all permissions) + * @param int $forcereload Force reload of permissions even if they were already loaded (ignore cache) * @return void * @see clearrights, delrights, addrights */ - function getrights($moduletag='') + function getrights($moduletag='', $forcereload=0) { global $conf; - if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) + if (empty($forcereload)) { - // Le fichier de ce module est deja charge - return; - } + if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) + { + // Rights for this module are already loaded, so we leave + return; + } - if ($this->all_permissions_are_loaded) - { - // Si les permissions ont deja ete charge pour ce user, on quitte - return; + if ($this->all_permissions_are_loaded) + { + // We already loaded all rights for this user, so we leave + return; + } } // Recuperation des droits utilisateurs + recuperation des droits groupes diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index dd7d6a5777f..13e715ff8f5 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -31,7 +31,7 @@ require_once dirname(__FILE__).'/../../htdocs/supplier_proposal/class/supplier_p if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; + print "Load permissions for user nb 1 (that should be admin)\n"; $user->fetch(1); //$user->addrights(0, 'supplier_proposal'); @@ -110,7 +110,12 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; //print $db->getVersion()."\n"; + + // Set permission not set by default sql sample + $user->addrights(0, 'supplier_proposal'); + $user->getrights('supplier_proposal', 1); } + /** * End phpunit tests * @@ -134,10 +139,6 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - var_dump($conf->supplier_proposal->enabled); - var_dump($user->rights->supplier_proposal); - $user->rights->supplier_proposal->creer = 1; // Not set after the reload of module done in 7.0 - $localobject=new SupplierProposal($this->savdb); $localobject->initAsSpecimen(); $result=$localobject->create($user); @@ -214,8 +215,6 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $user->rights->supplier_proposal->creer = 1; // Not set after the reload of module done in 7.0 - $result=$localobject->valid($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; From dc69960b00217869c8ec3145b86f229989486d03 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Jul 2018 12:17:34 +0200 Subject: [PATCH 100/228] Code comment --- htdocs/core/class/discount.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 5cb7d3e6882..9fc1921aa60 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -509,11 +509,11 @@ class DiscountAbsolute } /** - * Return amount (with tax) of all credit notes and deposits invoices used by invoice as a payment + * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment * * @param CommonInvoice $invoice Object invoice * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + * @return int <0 if KO, Sum of credit notes and excess received amount otherwise */ function getSumCreditNotesUsed($invoice, $multicurrency=0) { From 8497f56a0413cd79febedecf9fa2632c05605d40 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 2 Jul 2018 12:35:06 +0200 Subject: [PATCH 101/228] update description code --- .../commande/doc/pdf_einstein.modules.php | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 14e0f6cc155..00f084893f7 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -68,24 +68,55 @@ class pdf_einstein extends ModelePDFCommandes /** * @var array() Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.3 = array(5, 3) + * e.g.: PHP ≥ 5.4 = array(5, 4) */ - public $phpmin = array(5, 2); + public $phpmin = array(5, 4); /** * Dolibarr version of the loaded document * @public string */ public $version = 'dolibarr'; - + + /** + * @var int page_largeur + */ public $page_largeur; + + /** + * @var int page_hauteur + */ public $page_hauteur; + + /** + * @var array format + */ public $format; + + /** + * @var int marge_gauche + */ public $marge_gauche; + + /** + * @var int marge_droite + */ public $marge_droite; + + /** + * @var int marge_haute + */ public $marge_haute; + + /** + * @var int marge_basse + */ public $marge_basse; - + + /** + * Issuer + * @var Societe + */ public $emetteur; // Objet societe qui emet From f43cce34c8d389c88edb0a95e9230f2005e0207b Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 2 Jul 2018 13:34:21 +0200 Subject: [PATCH 102/228] update code comment --- .../contract/doc/pdf_strato.modules.php | 77 +++++++++++++++---- .../doc/pdf_aurore.modules.php | 4 +- 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 9fa86d24a19..f43ec0907ca 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -39,21 +39,72 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class pdf_strato extends ModelePDFContract { - var $db; - var $name; - var $description; - var $type; + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; - var $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; /** * Issuer diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index bca4ae8425f..5f971cab2d1 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -60,9 +60,9 @@ class pdf_aurore extends ModelePDFSupplierProposal /** * @var array() Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.3 = array(5, 3) + * e.g.: PHP ≥ 5.4 = array(5, 4) */ - public $phpmin = array(5, 2); + public $phpmin = array(5, 4); /** * Dolibarr version of the loaded document From 74c45fa8766e04d41daf6fd50e70ff6913eb6a2e Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 2 Jul 2018 14:30:30 +0200 Subject: [PATCH 103/228] update code comment --- .../expedition/doc/pdf_merou.modules.php | 77 ++++++++++++++++++- .../expedition/doc/pdf_rouget.modules.php | 75 +++++++++++++++++- 2 files changed, 147 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 9a496cb5589..c4c665de56d 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -33,11 +33,82 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** - * Classe permettant de generer les borderaux envoi au modele Merou + * Class to build sending documents with model Merou */ class pdf_merou extends ModelePdfExpedition { - var $emetteur; // Objet societe qui emet + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe + */ + public $emetteur; /** @@ -65,7 +136,7 @@ class pdf_merou extends ModelePdfExpedition $this->option_logo = 1; - // Recupere emmetteur + // Get source company $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 683a5e13124..aad7fd07c1b 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -32,11 +32,82 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** - * Classe permettant de generer les borderaux envoi au modele Rouget + * Class to build sending documents with model Rouget */ class pdf_rouget extends ModelePdfExpedition { - var $emetteur; // Objet societe qui emet + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe + */ + public $emetteur; // Objet societe qui emet /** From 0aa58537bb2bd31684b4cf77acd3fd43dcd18602 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 2 Jul 2018 15:07:00 +0200 Subject: [PATCH 104/228] update code comment --- .../doc/pdf_standard.modules.php | 62 +++++++++++--- .../modules/facture/doc/pdf_crabe.modules.php | 39 ++++++++- .../fichinter/doc/pdf_soleil.modules.php | 83 ++++++++++++++++--- 3 files changed, 156 insertions(+), 28 deletions(-) diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 3244bb25340..539830cdc71 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -58,18 +58,58 @@ class pdf_standard extends ModeleExpenseReport */ public $type; - var $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; - - var $emetteur; // Objet societe qui emet + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe + */ + public $emetteur; // Objet societe qui emet /** diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index bbb9475b710..149a457286d 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -69,24 +69,55 @@ class pdf_crabe extends ModelePDFFactures /** * @var array() Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.3 = array(5, 3) + * e.g.: PHP ≥ 5.4 = array(5, 4) */ - public $phpmin = array(5, 2); - + public $phpmin = array(5, 4); + /** * Dolibarr version of the loaded document * @public string */ public $version = 'dolibarr'; + /** + * @var int page_largeur + */ public $page_largeur; + + /** + * @var int page_hauteur + */ public $page_hauteur; + + /** + * @var array format + */ public $format; + + /** + * @var int marge_gauche + */ public $marge_gauche; + + /** + * @var int marge_droite + */ public $marge_droite; + + /** + * @var int marge_haute + */ public $marge_haute; + + /** + * @var int marge_basse + */ public $marge_basse; - + + /** + * Issuer + * @var Societe + */ public $emetteur; // Objet societe qui emet /** diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index aa7ed05070b..26dc08ceb77 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -38,21 +38,78 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; */ class pdf_soleil extends ModelePDFFicheinter { - var $db; - var $name; - var $description; - var $type; + /** + * @var DoliDb Database handler + */ + public $db; - var $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; + /** + * @var string model name + */ + public $name; - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe + */ + public $emetteur; // Objet societe qui emet /** * Constructor From 2023a58397c7ad1bb408cd13975dc1a10a72ccc4 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 2 Jul 2018 17:32:42 +0200 Subject: [PATCH 105/228] fix : Typo --- htdocs/modulebuilder/template/class/myobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index ac2347b723d..c6cd6fae901 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -83,7 +83,7 @@ class MyObject extends CommonObject 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), - 'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>0, 'position'=>60), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), From dfc42e56d34c56a5895aa005c3c51f753604dfca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Jul 2018 17:15:52 +0200 Subject: [PATCH 106/228] Better log --- htdocs/install/upgrade2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index b7d18e8163a..f34321bc6f1 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -77,7 +77,7 @@ if ($dolibarr_main_db_type == 'pgsql') $choix=2; if ($dolibarr_main_db_type == 'mssql') $choix=3; -dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page"); +dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page ".$versionfrom." ".$versionto); if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); From 275f9815456a0f616ddb8a90abcba8167ebe2ad7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Jul 2018 20:08:55 +0200 Subject: [PATCH 107/228] FIX for migration from old versions --- htdocs/core/modules/DolibarrModules.class.php | 33 ++++++++++++------- .../modules/modSupplierProposal.class.php | 2 +- htdocs/install/upgrade2.php | 26 +++++++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 527bf945547..562f9eed374 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1671,11 +1671,12 @@ class DolibarrModules // Can not be abstract, because we need to insta // Search if perm already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " WHERE id = ".$r_id." AND entity = ".$entity; + $resqlselect=$this->db->query($sql); if ($resqlselect) { - $obj = $this->db->fetch_object($resqlselect); - if ($obj->nb == 0) + $objcount = $this->db->fetch_object($resqlselect); + if ($objcount && $objcount->nb == 0) { if (dol_strlen($r_perms) ) { @@ -1739,23 +1740,33 @@ class DolibarrModules // Can not be abstract, because we need to insta { $obj2=$this->db->fetch_object($resqlseladmin); dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid); + $tmpuser=new User($this->db); - $tmpuser->fetch($obj2->rowid); - if (!empty($tmpuser->id)) { + $result = $tmpuser->fetch($obj2->rowid); + if ($result > 0) { $tmpuser->addrights($r_id, '', '', 0, 1); } + else + { + dol_syslog(get_class($this)."::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR); + } $i++; } - if (! empty($user->admin)) // Reload permission for current user if defined - { - // We reload permissions - $user->clearrights(); - $user->getrights(); - } } - else dol_print_error($this->db); + else + { + dol_print_error($this->db); + } } } + + if ($reinitadminperms && ! empty($user->admin)) // Reload permission for current user if defined + { + // We reload permissions + $user->clearrights(); + $user->getrights(); + } + } $this->db->free($resql); } diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 7b2a378019d..fa7553fd6df 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -246,7 +246,7 @@ class modSupplierProposal extends DolibarrModules public function remove($options = '') { $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" + "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" // To delete/clean deprecated entries ); return $this->_remove($sql, $options); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index f34321bc6f1..628f4dfc734 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -192,6 +192,32 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 $versiontoarray=explode('.',$versionto); $versionranarray=explode('.',DOL_VERSION); + + // Force to execute this at begin to avoid the new core code into Dolibarr to be broken. + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN birth date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemployment date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemploymentend date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_range integer'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_c_exp_tax_cat integer'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN langs varchar(24)'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fieldcomputed text'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fielddefault varchar(255)'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX."extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'"; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN help text'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL'; + $db->query($sql, 1); + + $afterversionarray=explode('.','2.0.0'); $beforeversionarray=explode('.','2.7.9'); if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) From 8dcf7267f38f7a6b5c47a5dbd66b6acb794e6b03 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Jul 2018 20:09:46 +0200 Subject: [PATCH 108/228] Code comment --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8affb857593..e547b304e23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -207,8 +207,7 @@ before_script: mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql fi if [ "$DB" = 'postgresql' ]; then - #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr + #pgloader mysql://root:pass@127.0.0.1/dolibarr_35 postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dev pgloader mysql://root@127.0.0.1/travis postgresql:///travis fi # TODO: SQLite From fb6ffd8e586a6f895f0859d4c60517ee1bc036b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Jul 2018 20:44:39 +0200 Subject: [PATCH 109/228] Reduce size of log file --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e547b304e23..5e3f1511266 100644 --- a/.travis.yml +++ b/.travis.yml @@ -340,7 +340,7 @@ script: cd - set +e echo - cat /tmp/dolibarr_install.log + #cat /tmp/dolibarr_install.log - | echo "Unit testing" From ca13d7b560cb3feea5ead5abe5fc4e5ab6882518 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 3 Jul 2018 21:46:20 +0200 Subject: [PATCH 110/228] NEW possibility to add all rights of all modules in one time --- htdocs/user/class/user.class.php | 39 ++++++++++++++++++++------ htdocs/user/class/usergroup.class.php | 40 +++++++++++++++++++++------ htdocs/user/group/perms.php | 9 +++++- htdocs/user/perms.php | 9 +++++- 4 files changed, 78 insertions(+), 19 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 5b7416dbaa6..d637bdff632 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -135,7 +135,7 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; - + public $fields=array( 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), @@ -484,8 +484,15 @@ class User extends CommonObject // Where pour la liste des droits a ajouter if (! empty($allmodule)) { - $whereforadd="module='".$this->db->escape($allmodule)."'"; - if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'"; + if ($allmodule == 'allmodules') + { + $whereforadd='allmodules'; + } + else + { + $whereforadd="module='".$this->db->escape($allmodule)."'"; + if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'"; + } } } @@ -495,8 +502,10 @@ class User extends CommonObject //print "$module-$perms-$subperms"; $sql = "SELECT id"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; - $sql.= " WHERE ".$whereforadd; - $sql.= " AND entity = ".$entity; + $sql.= " WHERE entity = ".$entity; + if (! empty($whereforadd) && $whereforadd != 'allmodules') { + $sql.= " AND ".$whereforadd; + } $result=$this->db->query($sql); if ($result) @@ -597,8 +606,18 @@ class User extends CommonObject else { // On a demande suppression d'un droit sur la base d'un nom de module ou perms // Where pour la liste des droits a supprimer - if (! empty($allmodule)) $wherefordel="module='".$this->db->escape($allmodule)."'"; - if (! empty($allperms)) $wherefordel=" AND perms='".$this->db->escape($allperms)."'"; + if (! empty($allmodule)) + { + if ($allmodule == 'allmodules') + { + $wherefordel='allmodules'; + } + else + { + $wherefordel="module='".$this->db->escape($allmodule)."'"; + if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'"; + } + } } // Suppression des droits selon critere defini dans wherefordel @@ -607,8 +626,10 @@ class User extends CommonObject //print "$module-$perms-$subperms"; $sql = "SELECT id"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; - $sql.= " WHERE $wherefordel"; - $sql.= " AND entity = ".$entity; + $sql.= " WHERE entity = ".$entity; + if (! empty($wherefordel) && $wherefordel != 'allmodules') { + $sql.= " AND ".$wherefordel; + } $result=$this->db->query($sql); if ($result) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 2400c855a6d..882e9111b5d 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -308,8 +308,18 @@ class UserGroup extends CommonObject } else { // Where pour la liste des droits a ajouter - if (! empty($allmodule)) $whereforadd="module='".$this->db->escape($allmodule)."'"; - if (! empty($allperms)) $whereforadd=" AND perms='".$this->db->escape($allperms)."'"; + if (! empty($allmodule)) + { + if ($allmodule == 'allmodules') + { + $whereforadd='allmodules'; + } + else + { + $whereforadd="module='".$this->db->escape($allmodule)."'"; + if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'"; + } + } } // Ajout des droits de la liste whereforadd @@ -318,8 +328,10 @@ class UserGroup extends CommonObject //print "$module-$perms-$subperms"; $sql = "SELECT id"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; - $sql.= " WHERE $whereforadd"; - $sql.= " AND entity = ".$entity; + $sql.= " WHERE entity = ".$entity; + if (! empty($whereforadd) && $whereforadd != 'allmodules') { + $sql.= " AND ".$whereforadd; + } $result=$this->db->query($sql); if ($result) @@ -422,8 +434,18 @@ class UserGroup extends CommonObject } else { // Where pour la liste des droits a supprimer - if (! empty($allmodule)) $wherefordel="module='".$this->db->escape($allmodule)."'"; - if (! empty($allperms)) $wherefordel=" AND perms='".$this->db->escape($allperms)."'"; + if (! empty($allmodule)) + { + if ($allmodule == 'allmodules') + { + $wherefordel='allmodules'; + } + else + { + $wherefordel="module='".$this->db->escape($allmodule)."'"; + if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'"; + } + } } // Suppression des droits de la liste wherefordel @@ -432,8 +454,10 @@ class UserGroup extends CommonObject //print "$module-$perms-$subperms"; $sql = "SELECT id"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; - $sql.= " WHERE $wherefordel"; - $sql.= " AND entity = ".$entity; + $sql.= " WHERE entity = ".$entity; + if (! empty($wherefordel) && $wherefordel != 'allmodules') { + $sql.= " AND ".$wherefordel; + } $result=$this->db->query($sql); if ($result) diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index c1f8d1fe5b0..0d019b1226c 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -231,7 +231,14 @@ if ($object->id > 0) print '
'.$langs->trans("Property"); - print ' ('.$langs->trans("Example").')'; - print ''; + print ''.$langs->trans("Property"); + print ' ('.$langs->trans("SeeExamples").')'; + print ''; print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); - print ''; - print ''.$langs->trans("Type").''.$form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")).''.$form->textwithpicto($langs->trans("NotNull"), $langs->trans("NotNullDesc")).''.$langs->trans("DefaultValue").''.$langs->trans("DatabaseIndex").''.$langs->trans("Position").''.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).''.$langs->trans("Comment").''.$langs->trans("Type").''; + print ''.$form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")).''.$form->textwithpicto($langs->trans("NotNull"), $langs->trans("NotNullDesc")).''.$langs->trans("DefaultValue").''.$langs->trans("DatabaseIndex").''.$langs->trans("Position").''.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).''.$langs->trans("Comment").'
'; print ''; print ''; - if ($caneditperms) print ''; + if ($caneditperms) + { + print ''; + } print ''; print ''; print ''; diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 0a8e2bbbb80..30b988d3b22 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -260,7 +260,14 @@ print "\n"; print '
'.$langs->trans("Module").' '; + print ''.$langs->trans("All").""; + print '/'; + print ''.$langs->trans("None").""; + print ' '.$langs->trans("Permissions").'
'; print ''; print ''; -if ($caneditperms) print ''; +if ($caneditperms && empty($objMod->rights_admin_allowed) || empty($object->admin)) +{ + print ''; +} print ''; print ''; print ''."\n"; From a2f517685ef8513e38a6c82cfb17cee8ddbbcbfb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Jul 2018 10:21:42 +0200 Subject: [PATCH 111/228] Fix pgsql migration --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 6bc8594a826..fb890d14375 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -467,10 +467,13 @@ ALTER TABLE llx_extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'; ALTER TABLE llx_extrafields ADD COLUMN tms timestamp; -- We fix value of 'list' from 0 to 1 for all extrafields created before this migration -UPDATE llx_extrafields SET list = 1 WHERE list = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL; -UPDATE llx_extrafields SET list = 3 WHERE type = 'separate' AND list != 3; +--VMYSQL4.1 UPDATE llx_extrafields SET list = 1 WHERE list = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL; +--VMYSQL4.1 UPDATE llx_extrafields SET list = 3 WHERE type = 'separate' AND list <> 3; +--VPGSQL8.2 UPDATE llx_extrafields SET list = 1 WHERE list::integer = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL; +--VPGSQL8.2 UPDATE llx_extrafields SET list = 3 WHERE type = 'separate' AND list::integer <> 3; -ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1; +--VMYSQL4.1 ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1; +--VPGSQL8.2 ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1 USING list::integer; --VPGSQL8.2 ALTER TABLE llx_extrafields ALTER COLUMN list SET DEFAULT 1; ALTER TABLE llx_extrafields MODIFY COLUMN langs varchar(64); From 91b7ee5fc2d96d4b9c7247b5447a6893b54ea05c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Jul 2018 11:07:28 +0200 Subject: [PATCH 112/228] NEW Add function isValidMXRecord --- htdocs/core/lib/functions.lib.php | 29 +++++++++++++++++++++++++++++ test/phpunit/FunctionsLibTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 54bbbc837a1..51e64c22878 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2782,6 +2782,35 @@ function isValidEmail($address, $acceptsupervisorkey=0) return false; } +/** + * Return if the domain name has a valid MX record. + * WARNING: This need function idn_to_ascii, checkdnsrr and getmxrr + * + * @param string $domain Domain name (Ex: "yahoo.com", "yhaoo.com", "dolibarr.fr") + * @return int -1 if error (function not available), 0=Not valid, 1=Valid + */ +function isValidMXRecord($domain) +{ + if (function_exists('idn_to_ascii') && function_exists('checkdnsrr')) + { + if (! checkdnsrr(idn_to_ascii($domain), 'MX')) + { + return 0; + } + if (function_exists('getmxrr')) + { + $mxhosts=array(); + $weight=array(); + getmxrr(idn_to_ascii($domain), $mxhosts, $weight); + if (count($mxhosts) > 1) return 1; + if (count($mxhosts) == 1 && ! empty($mxhosts[0])) return 1; + + return 0; + } + } + return -1; +} + /** * Return true if phone number syntax is ok * TODO Decide what to do with this diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 71b39fc6e51..c72daec989e 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -122,6 +122,31 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase + /** + * testIsValidMXRecord + * + * @return void + */ + public function testIsValidMXRecord() + { + // Nb of line is same than entry text + + $input="yahoo.com"; + $result=isValidMXRecord($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(1, $result); + + $input="yhaoo.com"; + $result=isValidMXRecord($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(0, $result); + + $input="dolibarr.fr"; + $result=isValidMXRecord($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(0, $result); + } + /** * testDolGetFirstLineOfText * From afd3868a8a8e70d27eab5468ba8a46a5202639b3 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 4 Jul 2018 14:38:56 +0200 Subject: [PATCH 113/228] docs: complete comments --- .../livraison/doc/pdf_typhon.modules.php | 91 +++++++++++++++---- .../project/doc/pdf_baleine.modules.php | 73 ++++++++++++++- 2 files changed, 145 insertions(+), 19 deletions(-) diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 6b0bb759a19..f3329fa9b18 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -35,27 +35,82 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** - * Classe permettant de generer les bons de livraison au modele Typho + * Class to build Delivery Order documents with typhon model */ class pdf_typhon extends ModelePDFDeliveryOrder { - var $db; - var $name; - var $description; - var $type; - - var $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; - - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; - - var $emetteur; // Objet societe qui emet + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe + */ + public $emetteur; // Objet societe qui emet /** * Constructor diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index baa38e8ad2d..384d192e1ed 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -38,7 +38,78 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; class pdf_baleine extends ModelePDFProjects { - var $emetteur; // Objet societe qui emet + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe + */ + public $emetteur; // Objet societe qui emet /** * Constructor From d796199ed0c32d5046c2b623bd5026ab37b6a5f6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 4 Jul 2018 14:48:00 +0200 Subject: [PATCH 114/228] Fix: avoid warning with multicompany tranverse mode --- htdocs/user/card.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e5c24fbac04..d59a7ef63b7 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1190,8 +1190,11 @@ else $res=$object->fetch_optionals(); // Check if user has rights - $object->getrights(); - if (empty($object->nb_rights) && $object->statut != 0) setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings'); + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + $object->getrights(); + if (empty($object->nb_rights) && $object->statut != 0) setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings'); + } // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon @@ -1731,7 +1734,7 @@ else } } } - + print "\n"; From 1cc73ae8cad7428c9f81b45d9a3774a61b802c48 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 5 Jul 2018 10:16:20 +0200 Subject: [PATCH 115/228] docs: complete comments --- .../modules/propale/doc/pdf_azur.modules.php | 95 +++++++++++++++---- 1 file changed, 77 insertions(+), 18 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 6e72e757fb6..803323edbf1 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -40,24 +40,83 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_azur extends ModelePDFPropales { - var $db; - var $name; - var $description; - var $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template - var $type; - - var $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; - - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; - - var $emetteur; // Objet societe qui emet + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Objet societe qui emet + */ + public $emetteur; /** From 30cff2bb369b6ea31a8629d693253e3359bfeab7 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Thu, 5 Jul 2018 11:52:41 +0200 Subject: [PATCH 116/228] ADD check user's rights --- htdocs/comm/action/class/actioncomm.class.php | 12 +- htdocs/commande/class/commande.class.php | 8 + htdocs/compta/bank/class/account.class.php | 11 +- htdocs/compta/facture/class/facture.class.php | 8611 ++++++++--------- htdocs/user/class/user.class.php | 15 +- 5 files changed, 4163 insertions(+), 4494 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 0c7ad11cb3c..c6ec428e68f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -4,7 +4,8 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2017 Juanjo Menent * Copyright (C) 2015 Marcos García - * + * Copyright (C) 2018 Nicolas ZABOURI + * * 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 @@ -1220,7 +1221,10 @@ class ActionComm extends CommonObject if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $label = $this->label; + if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id)) + $option = 'nolink'; + + $label = $this->label; if (empty($label)) $label=$this->libelle; // For backward compatibility $result=''; @@ -1286,6 +1290,10 @@ class ActionComm extends CommonObject $linkstart.=$linkclose.'>'; $linkend=''; + if ($option == 'nolink') { + $linkstart = ''; + $linkend = ''; + } //print 'rrr'.$this->libelle.'rrr'.$this->label.'rrr'.$withpicto; if ($withpicto == 2) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 17e4387c4de..dfeda472890 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3422,6 +3422,9 @@ class Commande extends CommonOrder if (! empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; else $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id; + if (!$user->rights->commande->lire) + $option = 'nolink'; + if ($option !== 'nolink') { // Add param to save lastsearch_values or not @@ -3465,6 +3468,11 @@ class Commande extends CommonOrder $linkstart.=$linkclose.'>'; $linkend=''; + if ($option == 'nolink') { + $linkstart = ''; + $linkend = ''; + } + $result .= $linkstart; if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.= $this->ref; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7228214e51c..117621d9197 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1301,13 +1301,17 @@ class Account extends CommonObject */ function getNomUrl($withpicto=0, $mode='', $option='', $save_lastsearch_value=-1, $notooltip=0) { - global $conf, $langs; + global $conf, $langs, $user; $result=''; $label = '' . $langs->trans("ShowAccount") . ''; $label .= '
' . $langs->trans('BankAccount') . ': ' . $this->label; $label .= '
' . $langs->trans('AccountNumber') . ': ' . $this->number; $label .= '
' . $langs->trans("AccountCurrency") . ': ' . $this->currency_code; + + if (!$user->rights->accounting->read || !empty($user->socid)) + $option = 'nolink'; + if (! empty($conf->accounting->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -1338,6 +1342,11 @@ class Account extends CommonObject $linkstart = 'ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c6e43206c78..919cd686d81 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1,4 +1,5 @@ * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio @@ -33,133 +34,130 @@ */ /** - * \file htdocs/compta/facture/class/facture.class.php - * \ingroup facture - * \brief File of class to manage invoices + * \file htdocs/compta/facture/class/facture.class.php + * \ingroup facture + * \brief File of class to manage invoices */ +include_once DOL_DOCUMENT_ROOT . '/core/class/commoninvoice.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobjectline.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT . '/margin/lib/margins.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php'; -include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; - -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) + require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; /** - * Class to manage invoices + * Class to manage invoices */ -class Facture extends CommonInvoice -{ - public $element='facture'; - public $table_element='facture'; - public $table_element_line = 'facturedet'; - public $fk_element = 'fk_facture'; - public $picto='bill'; - /** - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - * @var int - */ - public $ismultientitymanaged = 1; - /** - * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user - * @var integer - */ - public $restrictiononfksoc = 1; +class Facture extends CommonInvoice { - /** - * {@inheritdoc} - */ - protected $table_ref_field = 'facnumber'; + public $element = 'facture'; + public $table_element = 'facture'; + public $table_element_line = 'facturedet'; + public $fk_element = 'fk_facture'; + public $picto = 'bill'; - public $socid; + /** + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + public $ismultientitymanaged = 1; - public $author; - public $fk_user_author; - public $fk_user_valid; - public $date; // Date invoice - public $date_creation; // Creation date - public $date_validation; // Validation date - public $datem; - public $ref_client; - public $ref_int; - //Check constants for types - public $type = self::TYPE_STANDARD; + /** + * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user + * @var integer + */ + public $restrictiononfksoc = 1; - //var $amount; - public $remise_absolue; - public $remise_percent; - public $total_ht=0; - public $total_tva=0; - public $total_localtax1=0; - public $total_localtax2=0; - public $total_ttc=0; - public $revenuestamp; + /** + * {@inheritdoc} + */ + protected $table_ref_field = 'facnumber'; + public $socid; + public $author; + public $fk_user_author; + public $fk_user_valid; + public $date; // Date invoice + public $date_creation; // Creation date + public $date_validation; // Validation date + public $datem; + public $ref_client; + public $ref_int; + //Check constants for types + public $type = self::TYPE_STANDARD; + //var $amount; + public $remise_absolue; + public $remise_percent; + public $total_ht = 0; + public $total_tva = 0; + public $total_localtax1 = 0; + public $total_localtax2 = 0; + public $total_ttc = 0; + public $revenuestamp; + //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon + //! Fermeture alors que aucun paiement: replaced (si remplace), abandon + public $close_code; + //! Commentaire si mis a paye sans paiement complet + public $close_note; + //! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) + public $paye; + //! id of source invoice if replacement invoice or credit note + public $fk_facture_source; + public $linked_objects = array(); + public $date_lim_reglement; + public $cond_reglement_code; // Code in llx_c_paiement + public $mode_reglement_code; // Code in llx_c_paiement + public $fk_bank; // Field to store bank id to use when payment mode is withdraw + /** + * @deprecated + */ + public $products = array(); - //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon - //! Fermeture alors que aucun paiement: replaced (si remplace), abandon - public $close_code; - //! Commentaire si mis a paye sans paiement complet - public $close_note; - //! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) - public $paye; - //! id of source invoice if replacement invoice or credit note - public $fk_facture_source; - public $linked_objects=array(); - public $date_lim_reglement; - public $cond_reglement_code; // Code in llx_c_paiement - public $mode_reglement_code; // Code in llx_c_paiement - public $fk_bank; // Field to store bank id to use when payment mode is withdraw - /** - * @deprecated - */ - public $products=array(); - /** - * @var FactureLigne[] - */ - public $lines=array(); - public $line; - public $extraparams=array(); - public $specimen; + /** + * @var FactureLigne[] + */ + public $lines = array(); + public $line; + public $extraparams = array(); + public $specimen; + public $fac_rec; + // Multicurrency + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_tx; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; - public $fac_rec; + /** + * @var int Situation cycle reference number + */ + public $situation_cycle_ref; - // Multicurrency - public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_tx; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + /** + * @var int Situation counter inside the cycle + */ + public $situation_counter; - /** - * @var int Situation cycle reference number - */ - public $situation_cycle_ref; + /** + * @var int Final situation flag + */ + public $situation_final; - /** - * @var int Situation counter inside the cycle - */ - public $situation_counter; + /** + * @var array Table of previous situations + */ + public $tab_previous_situation_invoice = array(); - /** - * @var int Final situation flag - */ - public $situation_final; - - /** - * @var array Table of previous situations - */ - public $tab_previous_situation_invoice=array(); - - /** - * @var array Table of next situations - */ - public $tab_next_situation_invoice=array(); - - public $oldcopy; + /** + * @var array Table of next situations + */ + public $tab_next_situation_invoice = array(); + public $oldcopy; /** * Standard invoice @@ -186,4663 +184,4298 @@ class Facture extends CommonInvoice */ const TYPE_PROFORMA = 4; - /** - * Situation invoice - */ - const TYPE_SITUATION = 5; + /** + * Situation invoice + */ + const TYPE_SITUATION = 5; - /** - * Draft - */ - const STATUS_DRAFT = 0; + /** + * Draft + */ + const STATUS_DRAFT = 0; - /** - * Validated (need to be paid) - */ - const STATUS_VALIDATED = 1; + /** + * Validated (need to be paid) + */ + const STATUS_VALIDATED = 1; - /** - * Classified paid. - * If paid partially, $this->close_code can be: - * - CLOSECODE_DISCOUNTVAT - * - CLOSECODE_BADDEBT - * If paid completelly, this->close_code will be null - */ - const STATUS_CLOSED = 2; + /** + * Classified paid. + * If paid partially, $this->close_code can be: + * - CLOSECODE_DISCOUNTVAT + * - CLOSECODE_BADDEBT + * If paid completelly, this->close_code will be null + */ + const STATUS_CLOSED = 2; - /** - * Classified abandoned and no payment done. - * $this->close_code can be: - * - CLOSECODE_BADDEBT - * - CLOSECODE_ABANDONED - * - CLOSECODE_REPLACED - */ - const STATUS_ABANDONED = 3; + /** + * Classified abandoned and no payment done. + * $this->close_code can be: + * - CLOSECODE_BADDEBT + * - CLOSECODE_ABANDONED + * - CLOSECODE_REPLACED + */ + const STATUS_ABANDONED = 3; + const CLOSECODE_DISCOUNTVAT = 'discount_vat'; // Abandonned remain - escompte + const CLOSECODE_BADDEBT = 'badcustomer'; // Abandonned - bad + const CLOSECODE_ABANDONED = 'abandon'; // Abandonned - other + const CLOSECODE_REPLACED = 'replaced'; // Closed after doing a replacement invoice - const CLOSECODE_DISCOUNTVAT = 'discount_vat'; // Abandonned remain - escompte - const CLOSECODE_BADDEBT = 'badcustomer'; // Abandonned - bad - const CLOSECODE_ABANDONED = 'abandon'; // Abandonned - other - const CLOSECODE_REPLACED = 'replaced'; // Closed after doing a replacement invoice + /** + * Constructor + * + * @param DoliDB $db Database handler + */ - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } + function __construct($db) { + $this->db = $db; + } - /** - * Create invoice in database. - * Note: this->ref can be set or empty. If empty, we will use "(PROV999)" - * Note: this->fac_rec must be set to create invoice from a recurring invoice - * - * @param User $user Object user that create - * @param int $notrigger 1=Does not execute triggers, 0 otherwise - * @param int $forceduedate 1=Do not recalculate due date from payment condition but force it with value - * @return int <0 if KO, >0 if OK - */ - function create(User $user, $notrigger=0, $forceduedate=0) - { - global $langs,$conf,$mysoc,$hookmanager; - $error=0; + /** + * Create invoice in database. + * Note: this->ref can be set or empty. If empty, we will use "(PROV999)" + * Note: this->fac_rec must be set to create invoice from a recurring invoice + * + * @param User $user Object user that create + * @param int $notrigger 1=Does not execute triggers, 0 otherwise + * @param int $forceduedate 1=Do not recalculate due date from payment condition but force it with value + * @return int <0 if KO, >0 if OK + */ + function create(User $user, $notrigger = 0, $forceduedate = 0) { + global $langs, $conf, $mysoc, $hookmanager; + $error = 0; - // Clean parameters - if (empty($this->type)) $this->type = self::TYPE_STANDARD; - $this->ref_client=trim($this->ref_client); - $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated - $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); - $this->note_public=trim($this->note_public); - if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; - $this->brouillon = 1; - if (empty($this->entity)) $this->entity = $conf->entity; + // Clean parameters + if (empty($this->type)) + $this->type = self::TYPE_STANDARD; + $this->ref_client = trim($this->ref_client); + $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); + $this->note_public = trim($this->note_public); + if (!$this->cond_reglement_id) + $this->cond_reglement_id = 0; + if (!$this->mode_reglement_id) + $this->mode_reglement_id = 0; + $this->brouillon = 1; + if (empty($this->entity)) + $this->entity = $conf->entity; - // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); - else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); - if (empty($this->fk_multicurrency)) - { - $this->multicurrency_code = $conf->currency; - $this->fk_multicurrency = 0; - $this->multicurrency_tx = 1; - } + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) + list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + else + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } - dol_syslog(get_class($this)."::create user=".$user->id." date=".$this->date); + dol_syslog(get_class($this) . "::create user=" . $user->id . " date=" . $this->date); - // Check parameters - if (empty($this->date)) - { - $this->error="Try to create an invoice with an empty parameter (date)"; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -3; - } - $soc = new Societe($this->db); - $result=$soc->fetch($this->socid); - if ($result < 0) - { - $this->error="Failed to fetch company: ".$soc->error; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -2; - } + // Check parameters + if (empty($this->date)) { + $this->error = "Try to create an invoice with an empty parameter (date)"; + dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR); + return -3; + } + $soc = new Societe($this->db); + $result = $soc->fetch($this->socid); + if ($result < 0) { + $this->error = "Failed to fetch company: " . $soc->error; + dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR); + return -2; + } - $now=dol_now(); + $now = dol_now(); - $this->db->begin(); + $this->db->begin(); - $originaldatewhen=null; - $nextdatewhen=null; - $previousdaynextdatewhen=null; + $originaldatewhen = null; + $nextdatewhen = null; + $previousdaynextdatewhen = null; - // Create invoice from a template invoice - if ($this->fac_rec > 0) - { - $this->fk_fac_rec_source = $this->fac_rec; + // Create invoice from a template invoice + if ($this->fac_rec > 0) { + $this->fk_fac_rec_source = $this->fac_rec; - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; - $_facrec = new FactureRec($this->db); - $result=$_facrec->fetch($this->fac_rec); - $result=$_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds + require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php'; + $_facrec = new FactureRec($this->db); + $result = $_facrec->fetch($this->fac_rec); + $result = $_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds + // Define some dates + $originaldatewhen = $_facrec->date_when; + $nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); + $previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd'); - // Define some dates - $originaldatewhen = $_facrec->date_when; - $nextdatewhen=dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); - $previousdaynextdatewhen=dol_time_plus_duree($nextdatewhen, -1, 'd'); + $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template + $this->entity = $_facrec->entity; // Invoice created in same entity than template + // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI + $this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project; + $this->note_public = GETPOST('note_public', 'none') ? GETPOST('note_public', 'none') : $_facrec->note_public; + $this->note_private = GETPOST('note_private', 'none') ? GETPOST('note_private', 'none') : $_facrec->note_private; + $this->modelpdf = GETPOST('model', 'alpha') ? GETPOST('model', 'apha') : $_facrec->modelpdf; + $this->cond_reglement_id = GETPOST('cond_reglement_id', 'int') > 0 ? ((int) GETPOST('cond_reglement_id', 'int')) : $_facrec->cond_reglement_id; + $this->mode_reglement_id = GETPOST('mode_reglement_id', 'int') > 0 ? ((int) GETPOST('mode_reglement_id', 'int')) : $_facrec->mode_reglement_id; + $this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account; - $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template - $this->entity = $_facrec->entity; // Invoice created in same entity than template + // Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result + $this->total_ht = $_facrec->total_ht; + $this->total_ttc = $_facrec->total_ttc; - // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI - $this->fk_project = GETPOST('projectid','int') > 0 ? ((int) GETPOST('projectid','int')) : $_facrec->fk_project; - $this->note_public = GETPOST('note_public','none') ? GETPOST('note_public','none') : $_facrec->note_public; - $this->note_private = GETPOST('note_private','none') ? GETPOST('note_private','none') : $_facrec->note_private; - $this->modelpdf = GETPOST('model','alpha') ? GETPOST('model','apha') : $_facrec->modelpdf; - $this->cond_reglement_id = GETPOST('cond_reglement_id','int') > 0 ? ((int) GETPOST('cond_reglement_id','int')) : $_facrec->cond_reglement_id; - $this->mode_reglement_id = GETPOST('mode_reglement_id','int') > 0 ? ((int) GETPOST('mode_reglement_id','int')) : $_facrec->mode_reglement_id; - $this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account; + // Fields always coming from template + $this->remise_absolue = $_facrec->remise_absolue; + $this->remise_percent = $_facrec->remise_percent; + $this->fk_incoterms = $_facrec->fk_incoterms; + $this->location_incoterms = $_facrec->location_incoterms; - // Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result - $this->total_ht = $_facrec->total_ht; - $this->total_ttc = $_facrec->total_ttc; + // Clean parameters + if (!$this->type) + $this->type = self::TYPE_STANDARD; + $this->ref_client = trim($this->ref_client); + $this->note_public = trim($this->note_public); + $this->note_private = trim($this->note_private); + $this->note_private = dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); - // Fields always coming from template - $this->remise_absolue = $_facrec->remise_absolue; - $this->remise_percent = $_facrec->remise_percent; - $this->fk_incoterms = $_facrec->fk_incoterms; - $this->location_incoterms= $_facrec->location_incoterms; + $this->array_options = $_facrec->array_options; - // Clean parameters - if (! $this->type) $this->type = self::TYPE_STANDARD; - $this->ref_client=trim($this->ref_client); - $this->note_public=trim($this->note_public); - $this->note_private=trim($this->note_private); - $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + //if (! $this->remise) $this->remise = 0; + if (!$this->mode_reglement_id) + $this->mode_reglement_id = 0; + $this->brouillon = 1; - $this->array_options=$_facrec->array_options; + $this->linked_objects = $_facrec->linkedObjectsIds; - //if (! $this->remise) $this->remise = 0; - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; - $this->brouillon = 1; + $forceduedate = $this->calculate_date_lim_reglement(); - $this->linked_objects = $_facrec->linkedObjectsIds; - - $forceduedate = $this->calculate_date_lim_reglement(); - - // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice - if ($_facrec->frequency > 0) - { - dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); - if (empty($_facrec->date_when)) $_facrec->date_when = $now; + // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice + if ($_facrec->frequency > 0) { + dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); + if (empty($_facrec->date_when)) + $_facrec->date_when = $now; $next_date = $_facrec->getNextDate(); // Calculate next date $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. - $result = $_facrec->setNextDate($next_date,1); - } + $result = $_facrec->setNextDate($next_date, 1); + } - // Define lang of customer - $outputlangs = $langs; - $newlang=''; + // Define lang of customer + $outputlangs = $langs; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang=$this->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang=$this->default_lang; // for thirdparty - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) + $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) + $newlang = $this->default_lang; // for thirdparty + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $this); - $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'); - $substitutionarray['__INVOICE_MONTH__'] = dol_print_date($this->date, '%m'); - $substitutionarray['__INVOICE_NEXT_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'); - $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B'); - $substitutionarray['__INVOICE_MONTH_TEXT__'] = dol_print_date($this->date, '%B'); - $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B'); - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); - $substitutionarray['__INVOICE_YEAR__'] = dol_print_date($this->date, '%Y'); - $substitutionarray['__INVOICE_NEXT_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); - // Only for tempalte invoice - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = dol_print_date($originaldatewhen, 'dayhour'); - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($nextdatewhen, 'dayhour'); - $substitutionarray['__INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($previousdaynextdatewhen, 'dayhour'); + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $this); + $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'); + $substitutionarray['__INVOICE_MONTH__'] = dol_print_date($this->date, '%m'); + $substitutionarray['__INVOICE_NEXT_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'); + $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B'); + $substitutionarray['__INVOICE_MONTH_TEXT__'] = dol_print_date($this->date, '%B'); + $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B'); + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); + $substitutionarray['__INVOICE_YEAR__'] = dol_print_date($this->date, '%Y'); + $substitutionarray['__INVOICE_NEXT_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); + // Only for tempalte invoice + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = dol_print_date($originaldatewhen, 'dayhour'); + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($nextdatewhen, 'dayhour'); + $substitutionarray['__INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($previousdaynextdatewhen, 'dayhour'); - //var_dump($substitutionarray);exit; + //var_dump($substitutionarray);exit; - $substitutionisok=true; - complete_substitutions_array($substitutionarray, $outputlangs); + $substitutionisok = true; + complete_substitutions_array($substitutionarray, $outputlangs); - $this->note_public=make_substitutions($this->note_public,$substitutionarray); - $this->note_private=make_substitutions($this->note_private,$substitutionarray); - } + $this->note_public = make_substitutions($this->note_public, $substitutionarray); + $this->note_private = make_substitutions($this->note_private, $substitutionarray); + } - // Define due date if not already defined - $datelim=(empty($forceduedate)?$this->calculate_date_lim_reglement():$forceduedate); + // Define due date if not already defined + $datelim = (empty($forceduedate) ? $this->calculate_date_lim_reglement() : $forceduedate); - // Insert into database - $socid = $this->socid; + // Insert into database + $socid = $this->socid; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture ("; - $sql.= " facnumber"; - $sql.= ", entity"; - $sql.= ", ref_ext"; - $sql.= ", type"; - $sql.= ", fk_soc"; - $sql.= ", datec"; - $sql.= ", remise_absolue"; - $sql.= ", remise_percent"; - $sql.= ", datef"; - $sql.= ", date_pointoftax"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", ref_client, ref_int"; - $sql.= ", fk_account"; - $sql.= ", fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; - $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; - $sql.= ", situation_cycle_ref, situation_counter, situation_final"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ", fk_multicurrency"; - $sql.= ", multicurrency_code"; - $sql.= ", multicurrency_tx"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= "'(PROV)'"; - $sql.= ", ".$this->entity; - $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", '".$this->db->escape($this->type)."'"; - $sql.= ", '".$socid."'"; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL'); - $sql.= ", ".($this->remise_percent>0?$this->remise_percent:'NULL'); - $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ", ".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null'); - $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); - $sql.= ", ".($this->fk_fac_rec_source?"'".$this->db->escape($this->fk_fac_rec_source)."'":"null"); - $sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); - $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); - $sql.= ", ".($this->fk_project?$this->fk_project:"null"); - $sql.= ", ".$this->cond_reglement_id; - $sql.= ", ".$this->mode_reglement_id; - $sql.= ", '".$this->db->idate($datelim)."', '".$this->db->escape($this->modelpdf)."'"; - $sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"); - $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); - $sql.= ", ".($this->situation_final?$this->situation_final:0); - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".(double) $this->multicurrency_tx; - $sql.=")"; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "facture ("; + $sql .= " facnumber"; + $sql .= ", entity"; + $sql .= ", ref_ext"; + $sql .= ", type"; + $sql .= ", fk_soc"; + $sql .= ", datec"; + $sql .= ", remise_absolue"; + $sql .= ", remise_percent"; + $sql .= ", datef"; + $sql .= ", date_pointoftax"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", ref_client, ref_int"; + $sql .= ", fk_account"; + $sql .= ", fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; + $sql .= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; + $sql .= ", situation_cycle_ref, situation_counter, situation_final"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", multicurrency_tx"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= "'(PROV)'"; + $sql .= ", " . $this->entity; + $sql .= ", " . ($this->ref_ext ? "'" . $this->db->escape($this->ref_ext) . "'" : "null"); + $sql .= ", '" . $this->db->escape($this->type) . "'"; + $sql .= ", '" . $socid . "'"; + $sql .= ", '" . $this->db->idate($now) . "'"; + $sql .= ", " . ($this->remise_absolue > 0 ? $this->remise_absolue : 'NULL'); + $sql .= ", " . ($this->remise_percent > 0 ? $this->remise_percent : 'NULL'); + $sql .= ", '" . $this->db->idate($this->date) . "'"; + $sql .= ", " . (strval($this->date_pointoftax) != '' ? "'" . $this->db->idate($this->date_pointoftax) . "'" : 'null'); + $sql .= ", " . ($this->note_private ? "'" . $this->db->escape($this->note_private) . "'" : "null"); + $sql .= ", " . ($this->note_public ? "'" . $this->db->escape($this->note_public) . "'" : "null"); + $sql .= ", " . ($this->ref_client ? "'" . $this->db->escape($this->ref_client) . "'" : "null"); + $sql .= ", " . ($this->ref_int ? "'" . $this->db->escape($this->ref_int) . "'" : "null"); + $sql .= ", " . ($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", " . ($this->fk_fac_rec_source ? "'" . $this->db->escape($this->fk_fac_rec_source) . "'" : "null"); + $sql .= ", " . ($this->fk_facture_source ? "'" . $this->db->escape($this->fk_facture_source) . "'" : "null"); + $sql .= ", " . ($user->id > 0 ? "'" . $user->id . "'" : "null"); + $sql .= ", " . ($this->fk_project ? $this->fk_project : "null"); + $sql .= ", " . $this->cond_reglement_id; + $sql .= ", " . $this->mode_reglement_id; + $sql .= ", '" . $this->db->idate($datelim) . "', '" . $this->db->escape($this->modelpdf) . "'"; + $sql .= ", " . ($this->situation_cycle_ref ? "'" . $this->db->escape($this->situation_cycle_ref) . "'" : "null"); + $sql .= ", " . ($this->situation_counter ? "'" . $this->db->escape($this->situation_counter) . "'" : "null"); + $sql .= ", " . ($this->situation_final ? $this->situation_final : 0); + $sql .= ", " . (int) $this->fk_incoterms; + $sql .= ", '" . $this->db->escape($this->location_incoterms) . "'"; + $sql .= ", " . (int) $this->fk_multicurrency; + $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'"; + $sql .= ", " . (double) $this->multicurrency_tx; + $sql .= ")"; - $resql=$this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture'); + $resql = $this->db->query($sql); + if ($resql) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . 'facture'); - // Update ref with new one - $this->ref='(PROV'.$this->id.')'; - $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; + // Update ref with new one + $this->ref = '(PROV' . $this->id . ')'; + $sql = 'UPDATE ' . MAIN_DB_PREFIX . "facture SET facnumber='" . $this->db->escape($this->ref) . "' WHERE rowid=" . $this->id; - $resql=$this->db->query($sql); - if (! $resql) $error++; + $resql = $this->db->query($sql); + if (!$resql) + $error++; - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects - { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds - } + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) { // To use new linkedObjectsIds instead of old linked_objects + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + } - // Add object linked - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) - { - foreach($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) - { - $this->error=$this->db->lasterror(); - $error++; - } - } - } - else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) - { - $this->error=$this->db->lasterror(); - $error++; - } - } - } - } + // Add object linked + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { + foreach ($this->linked_objects as $origin => $tmp_origin_id) { + if (is_array($tmp_origin_id)) { // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + foreach ($tmp_origin_id as $origin_id) { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else { // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) { + $this->error = $this->db->lasterror(); + $error++; + } + } + } + } - // Propagate contacts - if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object - { - $originforcontact = $this->origin; - $originidforcontact = $this->origin_id; - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order - { - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; - $exp = new Expedition($this->db); - $exp->fetch($this->origin_id); - $exp->fetchObjectLinked(); - if (count($exp->linkedObjectsIds['commande']) > 0) - { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value) - { - $originforcontact = 'commande'; - if (is_object($value)) $originidforcontact = $value->id; - else $originidforcontact = $value; - break; // We take first one - } - } - } + // Propagate contacts + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) { // Get contact from origin object + $originforcontact = $this->origin; + $originidforcontact = $this->origin_id; + if ($originforcontact == 'shipping') { // shipment and order share the same contacts. If creating from shipment we take data of order + require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + $exp = new Expedition($this->db); + $exp->fetch($this->origin_id); + $exp->fetchObjectLinked(); + if (count($exp->linkedObjectsIds['commande']) > 0) { + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { + $originforcontact = 'commande'; + if (is_object($value)) + $originidforcontact = $value->id; + else + $originidforcontact = $value; + break; // We take first one + } + } + } - $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; + $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM " . MAIN_DB_PREFIX . "element_contact as ec, " . MAIN_DB_PREFIX . "c_type_contact as ctc"; + $sqlcontact .= " WHERE element_id = " . $originidforcontact . " AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '" . $originforcontact . "'"; - $resqlcontact = $this->db->query($sqlcontact); - if ($resqlcontact) - { - while($objcontact = $this->db->fetch_object($resqlcontact)) - { - //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object - } - } - else dol_print_error($resqlcontact); - } + $resqlcontact = $this->db->query($sqlcontact); + if ($resqlcontact) { + while ($objcontact = $this->db->fetch_object($resqlcontact)) { + //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + } + } else + dol_print_error($resqlcontact); + } - /* - * Insert lines of invoices, if not from template invoice, into database - */ - if (! $error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) - { - $fk_parent_line = 0; + /* + * Insert lines of invoices, if not from template invoice, into database + */ + if (!$error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) { // If this->lines is array of InvoiceLines (preferred mode) + $fk_parent_line = 0; - dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects"); - foreach ($this->lines as $i => $val) - { - $newinvoiceline=$this->lines[$i]; - $newinvoiceline->fk_facture=$this->id; + dol_syslog("There is " . count($this->lines) . " lines that are invoice lines objects"); + foreach ($this->lines as $i => $val) { + $newinvoiceline = $this->lines[$i]; + $newinvoiceline->fk_facture = $this->id; - $newinvoiceline->origin = $this->lines[$i]->element; - $newinvoiceline->origin_id = $this->lines[$i]->id; + $newinvoiceline->origin = $this->lines[$i]->element; + $newinvoiceline->origin_id = $this->lines[$i]->id; - // Auto set date of service ? - if ($this->lines[$i]->date_start_fill == 1 && $originaldatewhen) // $originaldatewhen is defined when generating from recurring invoice only - { - $newinvoiceline->date_start = $originaldatewhen; - } - if ($this->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) // $previousdaynextdatewhen is defined when generating from recurring invoice only - { - $newinvoiceline->date_end = $previousdaynextdatewhen; - } + // Auto set date of service ? + if ($this->lines[$i]->date_start_fill == 1 && $originaldatewhen) { // $originaldatewhen is defined when generating from recurring invoice only + $newinvoiceline->date_start = $originaldatewhen; + } + if ($this->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) { // $previousdaynextdatewhen is defined when generating from recurring invoice only + $newinvoiceline->date_end = $previousdaynextdatewhen; + } - if ($result >= 0) - { - // Reset fk_parent_line for no child products and special product - if (($newinvoiceline->product_type != 9 && empty($newinvoiceline->fk_parent_line)) || $newinvoiceline->product_type == 9) { - $fk_parent_line = 0; - } + if ($result >= 0) { + // Reset fk_parent_line for no child products and special product + if (($newinvoiceline->product_type != 9 && empty($newinvoiceline->fk_parent_line)) || $newinvoiceline->product_type == 9) { + $fk_parent_line = 0; + } - $newinvoiceline->fk_parent_line=$fk_parent_line; + $newinvoiceline->fk_parent_line = $fk_parent_line; - if($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except){ + if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { $discount = new DiscountAbsolute($this->db); $discount->fetch($newinvoiceline->fk_remise_except); - $discountId = $soc->set_remise_except($discount->amount_ht, $user, $discount->description, $discount->tva_tx); - $newinvoiceline->fk_remise_except = $discountId; + $discountId = $soc->set_remise_except($discount->amount_ht, $user, $discount->description, $discount->tva_tx); + $newinvoiceline->fk_remise_except = $discountId; } - $result=$newinvoiceline->insert(); + $result = $newinvoiceline->insert(); - // Defined the new fk_parent_line - if ($result > 0 && $newinvoiceline->product_type == 9) { - $fk_parent_line = $result; - } - } - if ($result < 0) - { - $this->error=$newinvoiceline->error; - $error++; - break; - } - } - } - elseif (! $error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays - { - $fk_parent_line = 0; + // Defined the new fk_parent_line + if ($result > 0 && $newinvoiceline->product_type == 9) { + $fk_parent_line = $result; + } + } + if ($result < 0) { + $this->error = $newinvoiceline->error; + $error++; + break; + } + } + } elseif (!$error && empty($this->fac_rec)) { // If this->lines is an array of invoice line arrays + $fk_parent_line = 0; - dol_syslog("There is ".count($this->lines)." lines that are array lines"); + dol_syslog("There is " . count($this->lines) . " lines that are array lines"); - foreach ($this->lines as $i => $val) - { - $line = $this->lines[$i]; + foreach ($this->lines as $i => $val) { + $line = $this->lines[$i]; - // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array - //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. - if (! is_object($line)) $line = (object) $line; + // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array + //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. + if (!is_object($line)) + $line = (object) $line; - if ($result >= 0) - { - // Reset fk_parent_line for no child products and special product - if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { - $fk_parent_line = 0; - } + if ($result >= 0) { + // Reset fk_parent_line for no child products and special product + if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { + $fk_parent_line = 0; + } - // Complete vat rate with code - $vatrate = $line->tva_tx; - if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; + // Complete vat rate with code + $vatrate = $line->tva_tx; + if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) + $vatrate .= ' (' . $line->vat_src_code . ')'; - $result = $this->addline( - $line->desc, - $line->subprice, - $line->qty, - $vatrate, - $line->localtax1_tx, - $line->localtax2_tx, - $line->fk_product, - $line->remise_percent, - $line->date_start, - $line->date_end, - $line->fk_code_ventilation, - $line->info_bits, - $line->fk_remise_except, - 'HT', - 0, - $line->product_type, - $line->rang, - $line->special_code, - $this->element, - $line->id, - $fk_parent_line, - $line->fk_fournprice, - $line->pa_ht, - $line->label, - $line->array_options, - $line->situation_percent, - $line->fk_prev_id, - $line->fk_unit, - $line->pu_ht_devise - ); - if ($result < 0) - { - $this->error=$this->db->lasterror(); - dol_print_error($this->db); - $this->db->rollback(); - return -1; - } + $result = $this->addline( + $line->desc, $line->subprice, $line->qty, $vatrate, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, $line->date_start, $line->date_end, $line->fk_code_ventilation, $line->info_bits, $line->fk_remise_except, 'HT', 0, $line->product_type, $line->rang, $line->special_code, $this->element, $line->id, $fk_parent_line, $line->fk_fournprice, $line->pa_ht, $line->label, $line->array_options, $line->situation_percent, $line->fk_prev_id, $line->fk_unit, $line->pu_ht_devise + ); + if ($result < 0) { + $this->error = $this->db->lasterror(); + dol_print_error($this->db); + $this->db->rollback(); + return -1; + } - // Defined the new fk_parent_line - if ($result > 0 && $line->product_type == 9) { - $fk_parent_line = $result; - } - } - } - } + // Defined the new fk_parent_line + if ($result > 0 && $line->product_type == 9) { + $fk_parent_line = $result; + } + } + } + } - /* - * Insert lines of predefined invoices - */ - if (! $error && $this->fac_rec > 0) - { - foreach ($_facrec->lines as $i => $val) - { - if ($_facrec->lines[$i]->fk_product) - { - $prod = new Product($this->db); - $res=$prod->fetch($_facrec->lines[$i]->fk_product); - } + /* + * Insert lines of predefined invoices + */ + if (!$error && $this->fac_rec > 0) { + foreach ($_facrec->lines as $i => $val) { + if ($_facrec->lines[$i]->fk_product) { + $prod = new Product($this->db); + $res = $prod->fetch($_facrec->lines[$i]->fk_product); + } - // For line from template invoice, we use data from template invoice - /* - $tva_tx = get_default_tva($mysoc,$soc,$prod->id); - $tva_npr = get_default_npr($mysoc,$soc,$prod->id); - if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx=get_localtax($tva_tx,1,$soc,$mysoc,$tva_npr); - $localtax2_tx=get_localtax($tva_tx,2,$soc,$mysoc,$tva_npr); - */ - $tva_tx = $_facrec->lines[$i]->tva_tx.($_facrec->lines[$i]->vat_src_code ? '('.$_facrec->lines[$i]->vat_src_code.')' : ''); - $tva_npr = $_facrec->lines[$i]->info_bits; - if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; - $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; + // For line from template invoice, we use data from template invoice + /* + $tva_tx = get_default_tva($mysoc,$soc,$prod->id); + $tva_npr = get_default_npr($mysoc,$soc,$prod->id); + if (empty($tva_tx)) $tva_npr=0; + $localtax1_tx=get_localtax($tva_tx,1,$soc,$mysoc,$tva_npr); + $localtax2_tx=get_localtax($tva_tx,2,$soc,$mysoc,$tva_npr); + */ + $tva_tx = $_facrec->lines[$i]->tva_tx . ($_facrec->lines[$i]->vat_src_code ? '(' . $_facrec->lines[$i]->vat_src_code . ')' : ''); + $tva_npr = $_facrec->lines[$i]->info_bits; + if (empty($tva_tx)) + $tva_npr = 0; + $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; + $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; - $result_insert = $this->addline( - $_facrec->lines[$i]->desc, - $_facrec->lines[$i]->subprice, - $_facrec->lines[$i]->qty, - $tva_tx, - $localtax1_tx, - $localtax2_tx, - $_facrec->lines[$i]->fk_product, - $_facrec->lines[$i]->remise_percent, - ($_facrec->lines[$i]->date_start_fill == 1 && $originaldatewhen)?$originaldatewhen:'', - ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen)?$previousdaynextdatewhen:'', - 0, - $tva_npr, - '', - 'HT', - 0, - $_facrec->lines[$i]->product_type, - $_facrec->lines[$i]->rang, - $_facrec->lines[$i]->special_code, - '', - 0, - 0, - null, - 0, - $_facrec->lines[$i]->label, - empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, - $_facrec->lines[$i]->situation_percent, - '', - $_facrec->lines[$i]->fk_unit, - $_facrec->lines[$i]->pu_ht_devise - ); + $result_insert = $this->addline( + $_facrec->lines[$i]->desc, $_facrec->lines[$i]->subprice, $_facrec->lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $_facrec->lines[$i]->fk_product, $_facrec->lines[$i]->remise_percent, ($_facrec->lines[$i]->date_start_fill == 1 && $originaldatewhen) ? $originaldatewhen : '', ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) ? $previousdaynextdatewhen : '', 0, $tva_npr, '', 'HT', 0, $_facrec->lines[$i]->product_type, $_facrec->lines[$i]->rang, $_facrec->lines[$i]->special_code, '', 0, 0, null, 0, $_facrec->lines[$i]->label, empty($_facrec->lines[$i]->array_options) ? null : $_facrec->lines[$i]->array_options, $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit, $_facrec->lines[$i]->pu_ht_devise + ); - if ( $result_insert < 0) - { - $error++; - $this->error=$this->db->error(); - break; - } - } - } + if ($result_insert < 0) { + $error++; + $this->error = $this->db->error(); + break; + } + } + } - if (! $error) - { + if (!$error) { - $result=$this->update_price(1); - if ($result > 0) - { - $action='create'; + $result = $this->update_price(1); + if ($result > 0) { + $action = 'create'; - // Actions on extra fields - if (! $error) - { - $result=$this->insertExtraFields(); - if ($result < 0) $error++; - } + // Actions on extra fields + if (!$error) { + $result = $this->insertExtraFields(); + if ($result < 0) + $error++; + } - if (! $error && ! $notrigger) - { - // Call trigger - $result=$this->call_trigger('BILL_CREATE',$user); - if ($result < 0) $error++; - // End call triggers - } + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('BILL_CREATE', $user); + if ($result < 0) + $error++; + // End call triggers + } - if (! $error) - { - $this->db->commit(); - return $this->id; - } - else - { - $this->db->rollback(); - return -4; - } - } - else - { - $this->error=$langs->trans('FailedToUpdatePrice'); - $this->db->rollback(); - return -3; - } - } - else - { - dol_syslog(get_class($this)."::create error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -2; - } - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } + if (!$error) { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -4; + } + } else { + $this->error = $langs->trans('FailedToUpdatePrice'); + $this->db->rollback(); + return -3; + } + } else { + dol_syslog(get_class($this) . "::create error " . $this->error, LOG_ERR); + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } + /** + * Create a new invoice in database from current invoice + * + * @param User $user Object user that ask creation + * @param int $invertdetail Reverse sign of amounts for lines + * @return int <0 if KO, >0 if OK + */ + function createFromCurrent(User $user, $invertdetail = 0) { + global $conf; - /** - * Create a new invoice in database from current invoice - * - * @param User $user Object user that ask creation - * @param int $invertdetail Reverse sign of amounts for lines - * @return int <0 if KO, >0 if OK - */ - function createFromCurrent(User $user, $invertdetail=0) - { - global $conf; + // Charge facture source + $facture = new Facture($this->db); - // Charge facture source - $facture=new Facture($this->db); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); - // Retreive all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - - if(!empty($this->array_options)){ - $facture->array_options = $this->array_options; + if (!empty($this->array_options)) { + $facture->array_options = $this->array_options; } - foreach($this->lines as &$line){ - $line->fetch_optionals();//fetch extrafields + foreach ($this->lines as &$line) { + $line->fetch_optionals(); //fetch extrafields } - $facture->fk_facture_source = $this->fk_facture_source; - $facture->type = $this->type; - $facture->socid = $this->socid; - $facture->date = $this->date; - $facture->date_pointoftax = $this->date_pointoftax; - $facture->note_public = $this->note_public; - $facture->note_private = $this->note_private; - $facture->ref_client = $this->ref_client; - $facture->modelpdf = $this->modelpdf; - $facture->fk_project = $this->fk_project; - $facture->cond_reglement_id = $this->cond_reglement_id; - $facture->mode_reglement_id = $this->mode_reglement_id; - $facture->remise_absolue = $this->remise_absolue; - $facture->remise_percent = $this->remise_percent; + $facture->fk_facture_source = $this->fk_facture_source; + $facture->type = $this->type; + $facture->socid = $this->socid; + $facture->date = $this->date; + $facture->date_pointoftax = $this->date_pointoftax; + $facture->note_public = $this->note_public; + $facture->note_private = $this->note_private; + $facture->ref_client = $this->ref_client; + $facture->modelpdf = $this->modelpdf; + $facture->fk_project = $this->fk_project; + $facture->cond_reglement_id = $this->cond_reglement_id; + $facture->mode_reglement_id = $this->mode_reglement_id; + $facture->remise_absolue = $this->remise_absolue; + $facture->remise_percent = $this->remise_percent; - $facture->origin = $this->origin; - $facture->origin_id = $this->origin_id; + $facture->origin = $this->origin; + $facture->origin_id = $this->origin_id; - $facture->lines = $this->lines; // Tableau des lignes de factures - $facture->products = $this->lines; // Tant que products encore utilise - $facture->situation_counter = $this->situation_counter; - $facture->situation_cycle_ref=$this->situation_cycle_ref; - $facture->situation_final = $this->situation_final; + $facture->lines = $this->lines; // Tableau des lignes de factures + $facture->products = $this->lines; // Tant que products encore utilise + $facture->situation_counter = $this->situation_counter; + $facture->situation_cycle_ref = $this->situation_cycle_ref; + $facture->situation_final = $this->situation_final; - // Loop on each line of new invoice - foreach($facture->lines as $i => $tmpline) - { - $facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid; - if ($invertdetail) - { - $facture->lines[$i]->subprice = -$facture->lines[$i]->subprice; - $facture->lines[$i]->total_ht = -$facture->lines[$i]->total_ht; - $facture->lines[$i]->total_tva = -$facture->lines[$i]->total_tva; - $facture->lines[$i]->total_localtax1 = -$facture->lines[$i]->total_localtax1; - $facture->lines[$i]->total_localtax2 = -$facture->lines[$i]->total_localtax2; - $facture->lines[$i]->total_ttc = -$facture->lines[$i]->total_ttc; - } - } + // Loop on each line of new invoice + foreach ($facture->lines as $i => $tmpline) { + $facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid; + if ($invertdetail) { + $facture->lines[$i]->subprice = -$facture->lines[$i]->subprice; + $facture->lines[$i]->total_ht = -$facture->lines[$i]->total_ht; + $facture->lines[$i]->total_tva = -$facture->lines[$i]->total_tva; + $facture->lines[$i]->total_localtax1 = -$facture->lines[$i]->total_localtax1; + $facture->lines[$i]->total_localtax2 = -$facture->lines[$i]->total_localtax2; + $facture->lines[$i]->total_ttc = -$facture->lines[$i]->total_ttc; + } + } - dol_syslog(get_class($this)."::createFromCurrent invertdetail=".$invertdetail." socid=".$this->socid." nboflines=".count($facture->lines)); + dol_syslog(get_class($this) . "::createFromCurrent invertdetail=" . $invertdetail . " socid=" . $this->socid . " nboflines=" . count($facture->lines)); - $facid = $facture->create($user); - if ($facid <= 0) - { - $this->error=$facture->error; - $this->errors=$facture->errors; - } - elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) - { - $this->fetchObjectLinked('', '', $facture->id, 'facture'); + $facid = $facture->create($user); + if ($facid <= 0) { + $this->error = $facture->error; + $this->errors = $facture->errors; + } elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) { + $this->fetchObjectLinked('', '', $facture->id, 'facture'); - foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) - { - foreach ($Tfk_object as $fk_object) - { - $facture->add_object_linked($typeObject, $fk_object); - } - } + foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) { + foreach ($Tfk_object as $fk_object) { + $facture->add_object_linked($typeObject, $fk_object); + } + } - $facture->add_object_linked('facture', $this->fk_facture_source); - } + $facture->add_object_linked('facture', $this->fk_facture_source); + } - return $facid; - } + return $facid; + } + /** + * Load an object from its id and create a new one in database + * + * @param int $socid Id of thirdparty + * @return int New id of clone + */ + function createFromClone($socid = 0) { + global $user, $hookmanager; - /** - * Load an object from its id and create a new one in database - * - * @param int $socid Id of thirdparty - * @return int New id of clone - */ - function createFromClone($socid=0) - { - global $user,$hookmanager; + $error = 0; - $error=0; + $this->context['createfromclone'] = 'createfromclone'; - $this->context['createfromclone'] = 'createfromclone'; + $this->db->begin(); - $this->db->begin(); + // get extrafields so they will be clone + foreach ($this->lines as $line) + $line->fetch_optionals($line->rowid); - // get extrafields so they will be clone - foreach($this->lines as $line) - $line->fetch_optionals($line->rowid); - - // Load source object - $objFrom = clone $this; + // Load source object + $objFrom = clone $this; - // Change socid if needed - if (! empty($socid) && $socid != $this->socid) - { - $objsoc = new Societe($this->db); + // Change socid if needed + if (!empty($socid) && $socid != $this->socid) { + $objsoc = new Societe($this->db); - if ($objsoc->fetch($socid)>0) - { - $this->socid = $objsoc->id; - $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $this->fk_project = ''; - $this->fk_delivery_address = ''; - } + if ($objsoc->fetch($socid) > 0) { + $this->socid = $objsoc->id; + $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $this->fk_project = ''; + $this->fk_delivery_address = ''; + } - // TODO Change product price if multi-prices - } + // TODO Change product price if multi-prices + } - $this->id=0; - $this->statut= self::STATUS_DRAFT; + $this->id = 0; + $this->statut = self::STATUS_DRAFT; - // Clear fields - $this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box - $this->user_author = $user->id; - $this->user_valid = ''; - $this->fk_facture_source = 0; - $this->date_creation = ''; - $this->date_validation = ''; - $this->ref_client = ''; - $this->close_code = ''; - $this->close_note = ''; - $this->products = $this->lines; // Tant que products encore utilise + // Clear fields + $this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box + $this->user_author = $user->id; + $this->user_valid = ''; + $this->fk_facture_source = 0; + $this->date_creation = ''; + $this->date_validation = ''; + $this->ref_client = ''; + $this->close_code = ''; + $this->close_note = ''; + $this->products = $this->lines; // Tant que products encore utilise + // Loop on each line of new invoice + foreach ($this->lines as $i => $line) { + if (($this->lines[$i]->info_bits & 0x02) == 0x02) { // We do not clone line of discounts + unset($this->lines[$i]); + unset($this->products[$i]); // Tant que products encore utilise + } + } - // Loop on each line of new invoice - foreach($this->lines as $i => $line) - { - if (($this->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts - { - unset($this->lines[$i]); - unset($this->products[$i]); // Tant que products encore utilise - } - } + // Create clone + $result = $this->create($user); + if ($result < 0) + $error++; + else { + // copy internal contacts + if ($this->copy_linked_contact($objFrom, 'internal') < 0) + $error++; - // Create clone - $result=$this->create($user); - if ($result < 0) $error++; - else { - // copy internal contacts - if ($this->copy_linked_contact($objFrom, 'internal') < 0) - $error++; + // copy external contacts if same company + elseif ($objFrom->socid == $this->socid) { + if ($this->copy_linked_contact($objFrom, 'external') < 0) + $error++; + } + } - // copy external contacts if same company - elseif ($objFrom->socid == $this->socid) - { - if ($this->copy_linked_contact($objFrom, 'external') < 0) - $error++; - } - } + if (!$error) { + // Hook of thirdparty module + if (is_object($hookmanager)) { + $parameters = array('objFrom' => $objFrom); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) + $error++; + } + } - if (! $error) - { - // Hook of thirdparty module - if (is_object($hookmanager)) - { - $parameters=array('objFrom'=>$objFrom); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; - } - } + unset($this->context['createfromclone']); - unset($this->context['createfromclone']); + // End + if (!$error) { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -1; + } + } - // End - if (! $error) - { - $this->db->commit(); - return $this->id; - } - else - { - $this->db->rollback(); - return -1; - } - } + /** + * Load an object from an order and create a new invoice into database + * + * @param Object $object Object source + * @param User $user Object user + * @return int <0 if KO, 0 if nothing done, 1 if OK + */ + function createFromOrder($object, User $user) { + global $hookmanager; - /** - * Load an object from an order and create a new invoice into database - * - * @param Object $object Object source - * @param User $user Object user - * @return int <0 if KO, 0 if nothing done, 1 if OK - */ - function createFromOrder($object, User $user) - { - global $hookmanager; + $error = 0; - $error=0; + // Closed order + $this->date = dol_now(); + $this->source = 0; - // Closed order - $this->date = dol_now(); - $this->source = 0; + $num = count($object->lines); + for ($i = 0; $i < $num; $i++) { + $line = new FactureLigne($this->db); - $num=count($object->lines); - for ($i = 0; $i < $num; $i++) - { - $line = new FactureLigne($this->db); + $line->libelle = $object->lines[$i]->libelle; + $line->label = $object->lines[$i]->label; + $line->desc = $object->lines[$i]->desc; + $line->subprice = $object->lines[$i]->subprice; + $line->total_ht = $object->lines[$i]->total_ht; + $line->total_tva = $object->lines[$i]->total_tva; + $line->total_localtax1 = $object->lines[$i]->total_localtax1; + $line->total_localtax2 = $object->lines[$i]->total_localtax2; + $line->total_ttc = $object->lines[$i]->total_ttc; + $line->vat_src_code = $object->lines[$i]->vat_src_code; + $line->tva_tx = $object->lines[$i]->tva_tx; + $line->localtax1_tx = $object->lines[$i]->localtax1_tx; + $line->localtax2_tx = $object->lines[$i]->localtax2_tx; + $line->qty = $object->lines[$i]->qty; + $line->fk_remise_except = $object->lines[$i]->fk_remise_except; + $line->remise_percent = $object->lines[$i]->remise_percent; + $line->fk_product = $object->lines[$i]->fk_product; + $line->info_bits = $object->lines[$i]->info_bits; + $line->product_type = $object->lines[$i]->product_type; + $line->rang = $object->lines[$i]->rang; + $line->special_code = $object->lines[$i]->special_code; + $line->fk_parent_line = $object->lines[$i]->fk_parent_line; + $line->fk_unit = $object->lines[$i]->fk_unit; + $line->date_start = $object->lines[$i]->date_start; + $line->date_end = $object->lines[$i]->date_end; - $line->libelle = $object->lines[$i]->libelle; - $line->label = $object->lines[$i]->label; - $line->desc = $object->lines[$i]->desc; - $line->subprice = $object->lines[$i]->subprice; - $line->total_ht = $object->lines[$i]->total_ht; - $line->total_tva = $object->lines[$i]->total_tva; - $line->total_localtax1 = $object->lines[$i]->total_localtax1; - $line->total_localtax2 = $object->lines[$i]->total_localtax2; - $line->total_ttc = $object->lines[$i]->total_ttc; - $line->vat_src_code = $object->lines[$i]->vat_src_code; - $line->tva_tx = $object->lines[$i]->tva_tx; - $line->localtax1_tx = $object->lines[$i]->localtax1_tx; - $line->localtax2_tx = $object->lines[$i]->localtax2_tx; - $line->qty = $object->lines[$i]->qty; - $line->fk_remise_except = $object->lines[$i]->fk_remise_except; - $line->remise_percent = $object->lines[$i]->remise_percent; - $line->fk_product = $object->lines[$i]->fk_product; - $line->info_bits = $object->lines[$i]->info_bits; - $line->product_type = $object->lines[$i]->product_type; - $line->rang = $object->lines[$i]->rang; - $line->special_code = $object->lines[$i]->special_code; - $line->fk_parent_line = $object->lines[$i]->fk_parent_line; - $line->fk_unit = $object->lines[$i]->fk_unit; - $line->date_start = $object->lines[$i]->date_start; - $line->date_end = $object->lines[$i]->date_end; - - $line->fk_fournprice = $object->lines[$i]->fk_fournprice; - $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); - $line->pa_ht = $marginInfos[0]; + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; + $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); + $line->pa_ht = $marginInfos[0]; // get extrafields from original line - $object->lines[$i]->fetch_optionals(); - foreach($object->lines[$i]->array_options as $options_key => $value) - $line->array_options[$options_key] = $value; + $object->lines[$i]->fetch_optionals(); + foreach ($object->lines[$i]->array_options as $options_key => $value) + $line->array_options[$options_key] = $value; - $this->lines[$i] = $line; - } + $this->lines[$i] = $line; + } - $this->socid = $object->socid; - $this->fk_project = $object->fk_project; - $this->cond_reglement_id = $object->cond_reglement_id; - $this->mode_reglement_id = $object->mode_reglement_id; - $this->availability_id = $object->availability_id; - $this->demand_reason_id = $object->demand_reason_id; - $this->date_livraison = $object->date_livraison; - $this->fk_delivery_address = $object->fk_delivery_address; - $this->contact_id = $object->contactid; - $this->ref_client = $object->ref_client; - $this->note_private = $object->note_private; - $this->note_public = $object->note_public; + $this->socid = $object->socid; + $this->fk_project = $object->fk_project; + $this->cond_reglement_id = $object->cond_reglement_id; + $this->mode_reglement_id = $object->mode_reglement_id; + $this->availability_id = $object->availability_id; + $this->demand_reason_id = $object->demand_reason_id; + $this->date_livraison = $object->date_livraison; + $this->fk_delivery_address = $object->fk_delivery_address; + $this->contact_id = $object->contactid; + $this->ref_client = $object->ref_client; + $this->note_private = $object->note_private; + $this->note_public = $object->note_public; - $this->origin = $object->element; - $this->origin_id = $object->id; + $this->origin = $object->element; + $this->origin_id = $object->id; // get extrafields from original line - $object->fetch_optionals($object->id); - foreach($object->array_options as $options_key => $value) - $this->array_options[$options_key] = $value; + $object->fetch_optionals($object->id); + foreach ($object->array_options as $options_key => $value) + $this->array_options[$options_key] = $value; - // Possibility to add external linked objects with hooks - $this->linked_objects[$this->origin] = $this->origin_id; - if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) - { - $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); - } + // Possibility to add external linked objects with hooks + $this->linked_objects[$this->origin] = $this->origin_id; + if (!empty($object->other_linked_objects) && is_array($object->other_linked_objects)) { + $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); + } - $ret = $this->create($user); + $ret = $this->create($user); - if ($ret > 0) - { - // Actions hooked (by external module) - $hookmanager->initHooks(array('invoicedao')); + if ($ret > 0) { + // Actions hooked (by external module) + $hookmanager->initHooks(array('invoicedao')); - $parameters=array('objFrom'=>$object); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; + $parameters = array('objFrom' => $object); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) + $error++; - if (! $error) - { - return 1; - } - else return -1; - } - else return -1; - } + if (!$error) { + return 1; + } else + return -1; + } else + return -1; + } - /** - * Return link to download file from a direct external access - * - * @param int $withpicto Add download picto into link - * @return string HTML link to file - */ - function getDirectExternalLink($withpicto=0) - { - global $dolibarr_main_url_root; + /** + * Return link to download file from a direct external access + * + * @param int $withpicto Add download picto into link + * @return string HTML link to file + */ + function getDirectExternalLink($withpicto = 0) { + global $dolibarr_main_url_root; - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + // Define $urlwithroot + $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + // TODO Read into ecmfile table to get entry and hash exists (PS: If not found, add it) + include_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php'; + $ecmfile = new EcmFiles($this->db); + //$result = $ecmfile->get(); - // TODO Read into ecmfile table to get entry and hash exists (PS: If not found, add it) - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($this->db); - //$result = $ecmfile->get(); + $hashp = 'todo'; + return '' . $this->ref . ''; + } - $hashp='todo'; - return ''.$this->ref.''; - } - - /** - * Return clicable link of object (with eventually picto) - * - * @param int $withpicto Add picto into link - * @param string $option Where point the link - * @param int $max Maxlength of ref - * @param int $short 1=Return just URL - * @param string $moretitle Add more text to title tooltip + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param string $option Where point the link + * @param int $max Maxlength of ref + * @param int $short 1=Return just URL + * @param string $moretitle Add more text to title tooltip * @param int $notooltip 1=Disable tooltip * @param int $addlinktonotes 1=Add link to notes * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $moretitle='', $notooltip=0, $addlinktonotes=0, $save_lastsearch_value=-1) - { - global $langs, $conf, $user, $form; + * @return string String with URL + */ + function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1) { + global $langs, $conf, $user, $form; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) + $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; - if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; - else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; + if ($option == 'withdraw') + $url = DOL_URL_ROOT . '/compta/facture/prelevement.php?facid=' . $this->id; + else + $url = DOL_URL_ROOT . '/compta/facture/card.php?facid=' . $this->id; - if ($short) return $url; + if (!$user->rights->facture->lire) + $option = 'nolink'; - if ($option !== 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; - } + if ($short) + return $url; - $picto='bill'; - if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice - if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note - if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice - $label=''; + if ($option !== 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) + $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) + $url .= '&save_lastsearch_values=1'; + } + + $picto = 'bill'; + if ($this->type == self::TYPE_REPLACEMENT) + $picto .= 'r'; // Replacement invoice + if ($this->type == self::TYPE_CREDIT_NOTE) + $picto .= 'a'; // Credit note + if ($this->type == self::TYPE_DEPOSIT) + $picto .= 'd'; // Deposit invoice + $label = ''; if ($user->rights->facture->lire) { $label = '' . $langs->trans("ShowInvoice") . ''; - if (! empty($this->ref)) - $label .= '
'.$langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->ref_client)) + if (!empty($this->ref)) + $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; + if (!empty($this->ref_client)) $label .= '
' . $langs->trans('RefCustomer') . ': ' . $this->ref_client; - if (! empty($this->total_ht)) - $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_tva)) - $label.= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_localtax1)) - $label.= '
' . $langs->trans('LT1') . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_localtax2)) - $label.= '
' . $langs->trans('LT2') . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_ttc)) - $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; - if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; - if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; - if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; - if ($moretitle) $label.=' - '.$moretitle; + if (!empty($this->total_ht)) + $label .= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_tva)) + $label .= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_localtax1)) + $label .= '
' . $langs->trans('LT1') . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_localtax2)) + $label .= '
' . $langs->trans('LT2') . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_ttc)) + $label .= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + if ($this->type == self::TYPE_REPLACEMENT) + $label = $langs->transnoentitiesnoconv("ShowInvoiceReplace") . ': ' . $this->ref; + if ($this->type == self::TYPE_CREDIT_NOTE) + $label = $langs->transnoentitiesnoconv("ShowInvoiceAvoir") . ': ' . $this->ref; + if ($this->type == self::TYPE_DEPOSIT) + $label = $langs->transnoentitiesnoconv("ShowInvoiceDeposit") . ': ' . $this->ref; + if ($this->type == self::TYPE_SITUATION) + $label = $langs->transnoentitiesnoconv("ShowInvoiceSituation") . ': ' . $this->ref; + if ($moretitle) + $label .= ' - ' . $moretitle; } - $linkclose=''; - if (empty($notooltip) && $user->rights->facture->lire) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowInvoice"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; - } - - $linkstart=''; - $linkend=''; - - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref,$max):$this->ref); - $result .= $linkend; - - if ($addlinktonotes) - { - $txttoshow=($user->societe_id>0?$this->note_public:$this->note_private); - if ($txttoshow) - { - $notetoshow=$langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow,1); - $result.=' '; - $result.=''.img_picto('','object_generic').''; - //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); - //$result.=''; - $result.=''; - } - } - - return $result; - } - - /** - * Get object and lines from database - * - * @param int $rowid Id of object to load - * @param string $ref Reference of invoice - * @param string $ref_ext External reference of invoice - * @param int $ref_int Internal reference of other object - * @param bool $fetch_situation Fetch the previous and next situation in $tab_previous_situation_invoice and $tab_next_situation_invoice - * @return int >0 if OK, <0 if KO, 0 if not found - */ - function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false) - { - global $conf; - - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - - $sql = 'SELECT f.rowid,f.entity,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; - $sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; - $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; - $sql.= ', f.datef as df, f.date_pointoftax'; - $sql.= ', f.date_lim_reglement as dlr'; - $sql.= ', f.datec as datec'; - $sql.= ', f.date_valid as datev'; - $sql.= ', f.tms as datem'; - $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc'; - $sql.= ', f.fk_facture_source'; - $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; - $sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; - $sql.= ', f.fk_account'; - $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; - $sql.= ', f.fk_incoterms, f.location_incoterms'; - $sql.= ", i.libelle as libelle_incoterms"; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; - - if ($rowid) $sql.= " WHERE f.rowid=".$rowid; - else $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; // Dont't use entity if you use rowid - - if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; - - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - $this->entity = $obj->entity; - - $this->ref = $obj->facnumber; - $this->ref_client = $obj->ref_client; - $this->ref_ext = $obj->ref_ext; - $this->ref_int = $obj->ref_int; - $this->type = $obj->type; - $this->date = $this->db->jdate($obj->df); - $this->date_pointoftax = $this->db->jdate($obj->date_pointoftax); - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_validation = $this->db->jdate($obj->datev); - $this->datem = $this->db->jdate($obj->datem); - $this->remise_percent = $obj->remise_percent; - $this->remise_absolue = $obj->remise_absolue; - $this->total_ht = $obj->total; - $this->total_tva = $obj->tva; - $this->total_localtax1 = $obj->localtax1; - $this->total_localtax2 = $obj->localtax2; - $this->total_ttc = $obj->total_ttc; - $this->revenuestamp = $obj->revenuestamp; - $this->paye = $obj->paye; - $this->close_code = $obj->close_code; - $this->close_note = $obj->close_note; - $this->socid = $obj->fk_soc; - $this->statut = $obj->fk_statut; - $this->date_lim_reglement = $this->db->jdate($obj->dlr); - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->mode_reglement_code = $obj->mode_reglement_code; - $this->mode_reglement = $obj->mode_reglement_libelle; - $this->cond_reglement_id = $obj->fk_cond_reglement; - $this->cond_reglement_code = $obj->cond_reglement_code; - $this->cond_reglement = $obj->cond_reglement_libelle; - $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; - $this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null; - $this->fk_project = $obj->fk_projet; - $this->fk_facture_source = $obj->fk_facture_source; - $this->note = $obj->note_private; // deprecated - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->user_author = $obj->fk_user_author; - $this->user_valid = $obj->fk_user_valid; - $this->modelpdf = $obj->model_pdf; - $this->last_main_doc = $obj->last_main_doc; - $this->situation_cycle_ref = $obj->situation_cycle_ref; - $this->situation_counter = $obj->situation_counter; - $this->situation_final = $obj->situation_final; - $this->extraparams = (array) json_decode($obj->extraparams, true); - - //Incoterms - $this->fk_incoterms = $obj->fk_incoterms; - $this->location_incoterms = $obj->location_incoterms; - $this->libelle_incoterms = $obj->libelle_incoterms; - - // Multicurrency - $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; - $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - - if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) - { - $this->fetchPreviousNextSituationInvoice(); - } - - if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; - - // Retreive all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - - /* - * Lines - */ - - $this->lines = array(); - - $result=$this->fetch_lines(); - if ($result < 0) - { - $this->error=$this->db->error(); - return -3; - } - return 1; - } - else - { - $this->error='Bill with id='.$rowid.' or ref='.$ref.' or ref_ext='.$ref_ext.' not found'; - dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); - return 0; - } - } - else - { - $this->error=$this->db->error(); - return -1; - } - } - - - /** - * Load all detailed lines into this->lines - * - * @return int 1 if OK, < 0 if KO - */ - function fetch_lines() - { - $this->lines=array(); - - $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql.= ' l.situation_percent, l.fk_prev_id,'; - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; - $sql.= ' l.rang, l.special_code,'; - $sql.= ' l.date_start as date_start, l.date_end as date_end,'; - $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; - $sql.= ' l.fk_unit,'; - $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql.= ' WHERE l.fk_facture = '.$this->id; - $sql.= ' ORDER BY l.rang, l.rowid'; - - dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) - { - $objp = $this->db->fetch_object($result); - $line = new FactureLigne($this->db); - - $line->id = $objp->rowid; - $line->rowid = $objp->rowid; // deprecated - $line->fk_facture = $objp->fk_facture; - $line->label = $objp->custom_label; // deprecated - $line->desc = $objp->description; // Description line - $line->description = $objp->description; // Description line - $line->product_type = $objp->product_type; // Type of line - $line->ref = $objp->product_ref; // Ref product - $line->product_ref = $objp->product_ref; // Ref product - $line->libelle = $objp->product_label; // TODO deprecated - $line->product_label = $objp->product_label; // Label product - $line->product_desc = $objp->product_desc; // Description product - $line->fk_product_type = $objp->fk_product_type; // Type of product - $line->qty = $objp->qty; - $line->subprice = $objp->subprice; - - $line->vat_src_code = $objp->vat_src_code; - $line->tva_tx = $objp->tva_tx; - $line->localtax1_tx = $objp->localtax1_tx; - $line->localtax2_tx = $objp->localtax2_tx; - $line->localtax1_type = $objp->localtax1_type; - $line->localtax2_type = $objp->localtax2_type; - $line->remise_percent = $objp->remise_percent; - $line->fk_remise_except = $objp->fk_remise_except; - $line->fk_product = $objp->fk_product; - $line->date_start = $this->db->jdate($objp->date_start); - $line->date_end = $this->db->jdate($objp->date_end); - $line->date_start = $this->db->jdate($objp->date_start); - $line->date_end = $this->db->jdate($objp->date_end); - $line->info_bits = $objp->info_bits; - $line->total_ht = $objp->total_ht; - $line->total_tva = $objp->total_tva; - $line->total_localtax1 = $objp->total_localtax1; - $line->total_localtax2 = $objp->total_localtax2; - $line->total_ttc = $objp->total_ttc; - $line->code_ventilation = $objp->fk_code_ventilation; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; - $line->marge_tx = $marginInfos[1]; - $line->marque_tx = $marginInfos[2]; - $line->rang = $objp->rang; - $line->special_code = $objp->special_code; - $line->fk_parent_line = $objp->fk_parent_line; - $line->situation_percent= $objp->situation_percent; - $line->fk_prev_id = $objp->fk_prev_id; - $line->fk_unit = $objp->fk_unit; - - // Accountancy - $line->fk_accounting_account = $objp->fk_code_ventilation; - - // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; - $line->multicurrency_subprice = $objp->multicurrency_subprice; - $line->multicurrency_total_ht = $objp->multicurrency_total_ht; - $line->multicurrency_total_tva = $objp->multicurrency_total_tva; - $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - - // TODO Fetch optional like done in fetch line of facture_rec ? - - $this->lines[$i] = $line; - - $i++; - } - $this->db->free($result); - return 1; - } - else - { - $this->error=$this->db->error(); - return -3; - } - } - - /** - * Fetch previous and next situations invoices - * - * @return void - */ - function fetchPreviousNextSituationInvoice() - { - global $conf; - - $this->tab_previous_situation_invoice = array(); - $this->tab_next_situation_invoice = array(); - - $sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture WHERE rowid <> '.$this->id.' AND entity = '.$conf->entity.' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref.' ORDER BY situation_counter ASC'; - - dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG); - $result = $this->db->query($sql); - if ($result && $this->db->num_rows($result) > 0) - { - while ($objp = $this->db->fetch_object($result)) - { - $invoice = new Facture($this->db); - if ($invoice->fetch($objp->rowid) > 0) - { - if ($objp->situation_counter < $this->situation_counter - || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes - ) - { - $this->tab_previous_situation_invoice[] = $invoice; - } - else - { - $this->tab_next_situation_invoice[] = $invoice; - } - } - } - } - - } - - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - function update(User $user, $notrigger=0) - { - $error=0; - - // Clean parameters - if (empty($this->type)) $this->type= self::TYPE_STANDARD; - if (isset($this->facnumber)) $this->facnumber=trim($this->ref); - if (isset($this->ref_client)) $this->ref_client=trim($this->ref_client); - if (isset($this->increment)) $this->increment=trim($this->increment); - if (isset($this->close_code)) $this->close_code=trim($this->close_code); - if (isset($this->close_note)) $this->close_note=trim($this->close_note); - if (isset($this->note) || isset($this->note_private)) $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated - if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); - if (isset($this->import_key)) $this->import_key=trim($this->import_key); - - // Check parameters - // Put here code to add control on parameters values - - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET"; - $sql.= " facnumber=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " type=".(isset($this->type)?$this->db->escape($this->type):"null").","; - $sql.= " ref_client=".(isset($this->ref_client)?"'".$this->db->escape($this->ref_client)."'":"null").","; - $sql.= " increment=".(isset($this->increment)?"'".$this->db->escape($this->increment)."'":"null").","; - $sql.= " fk_soc=".(isset($this->socid)?$this->db->escape($this->socid):"null").","; - $sql.= " datec=".(strval($this->date_creation)!='' ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; - $sql.= " datef=".(strval($this->date)!='' ? "'".$this->db->idate($this->date)."'" : 'null').","; - $sql.= " date_pointoftax=".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; - $sql.= " date_valid=".(strval($this->date_validation)!='' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; - $sql.= " paye=".(isset($this->paye)?$this->db->escape($this->paye):"null").","; - $sql.= " remise_percent=".(isset($this->remise_percent)?$this->db->escape($this->remise_percent):"null").","; - $sql.= " remise_absolue=".(isset($this->remise_absolue)?$this->db->escape($this->remise_absolue):"null").","; - $sql.= " close_code=".(isset($this->close_code)?"'".$this->db->escape($this->close_code)."'":"null").","; - $sql.= " close_note=".(isset($this->close_note)?"'".$this->db->escape($this->close_note)."'":"null").","; - $sql.= " tva=".(isset($this->total_tva)?$this->total_tva:"null").","; - $sql.= " localtax1=".(isset($this->total_localtax1)?$this->total_localtax1:"null").","; - $sql.= " localtax2=".(isset($this->total_localtax2)?$this->total_localtax2:"null").","; - $sql.= " total=".(isset($this->total_ht)?$this->total_ht:"null").","; - $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").","; - $sql.= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '')?$this->db->escape($this->revenuestamp):"null").","; - $sql.= " fk_statut=".(isset($this->statut)?$this->db->escape($this->statut):"null").","; - $sql.= " fk_user_author=".(isset($this->user_author)?$this->db->escape($this->user_author):"null").","; - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->db->escape($this->fk_user_valid):"null").","; - $sql.= " fk_facture_source=".(isset($this->fk_facture_source)?$this->db->escape($this->fk_facture_source):"null").","; - $sql.= " fk_projet=".(isset($this->fk_project)?$this->db->escape($this->fk_project):"null").","; - $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->db->escape($this->cond_reglement_id):"null").","; - $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->db->escape($this->mode_reglement_id):"null").","; - $sql.= " date_lim_reglement=".(strval($this->date_lim_reglement)!='' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; - $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; - $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; - $sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter)); - $sql.= " WHERE rowid=".$this->id; - - $this->db->begin(); - - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); - } - - if (! $error) - { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('BILL_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers - } - } - - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } - - - /** - * Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount) - * - * @param int $idremise Id of absolute discount - * @return int >0 if OK, <0 if KO - */ - function insert_discount($idremise) - { - global $langs; - - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - - $this->db->begin(); - - $remise=new DiscountAbsolute($this->db); - $result=$remise->fetch($idremise); - - if ($result > 0) - { - if ($remise->fk_facture) // Protection against multiple submission - { - $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); - $this->db->rollback(); - return -5; - } - - $facligne=new FactureLigne($this->db); - $facligne->fk_facture=$this->id; - $facligne->fk_remise_except=$remise->id; - $facligne->desc=$remise->description; // Description ligne - $facligne->vat_src_code=$remise->vat_src_code; - $facligne->tva_tx=$remise->tva_tx; - $facligne->subprice = -$remise->amount_ht; - $facligne->fk_product=0; // Id produit predefini - $facligne->qty=1; - $facligne->remise_percent=0; - $facligne->rang=-1; - $facligne->info_bits=2; - - // Get buy/cost price of invoice that is source of discount - if ($remise->fk_facture_source > 0) - { - $srcinvoice=new Facture($this->db); - $srcinvoice->fetch($remise->fk_facture_source); - $totalcostpriceofinvoice=0; - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject - $formmargin=new FormMargin($this->db); - $arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false); - $facligne->pa_ht = $arraytmp['pa_total']; - } - - $facligne->total_ht = -$remise->amount_ht; - $facligne->total_tva = -$remise->amount_tva; - $facligne->total_ttc = -$remise->amount_ttc; - - $facligne->multicurrency_subprice = -$remise->multicurrency_subprice; - $facligne->multicurrency_total_ht = -$remise->multicurrency_total_ht; - $facligne->multicurrency_total_tva = -$remise->multicurrency_total_tva; - $facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc; - - $lineid=$facligne->insert(); - if ($lineid > 0) - { - $result=$this->update_price(1); - if ($result > 0) - { - // Create link between discount and invoice line - $result=$remise->link_to_invoice($lineid,0); - if ($result < 0) - { - $this->error=$remise->error; - $this->db->rollback(); - return -4; - } - - $this->db->commit(); - return 1; - } - else - { - $this->error=$facligne->error; - $this->db->rollback(); - return -1; - } - } - else - { - $this->error=$facligne->error; - $this->db->rollback(); - return -2; - } - } - else - { - $this->db->rollback(); - return -3; - } - } - - /** - * Set customer ref - * - * @param string $ref_client Customer ref - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >0 if OK - */ - function set_ref_client($ref_client, $notrigger=0) - { - global $user; - - $error=0; - - $this->db->begin(); - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - if (empty($ref_client)) - $sql .= ' SET ref_client = NULL'; - else - $sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\''; - $sql .= ' WHERE rowid = '.$this->id; - - dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); - $resql=$this->db->query($sql); - if (!$resql) - { - $this->errors[]=$this->db->error(); - $error++; - } - - if (! $error) - { - $this->ref_client = $ref_client; - } - - if (! $notrigger && empty($error)) - { - // Call trigger - $result=$this->call_trigger('BILL_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers - } - - if (! $error) - { - - $this->ref_client = $ref_client; - - $this->db->commit(); - return 1; - } - else - { - foreach($this->errors as $errmsg) - { - dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - } - - /** - * Delete invoice - * - * @param User $user User making the deletion. - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @param int $idwarehouse Id warehouse to use for stock change. - * @return int <0 if KO, 0=Refused, >0 if OK - */ - function delete($user, $notrigger=0, $idwarehouse=-1) - { - global $langs,$conf; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $rowid=$this->id; - - dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG); - - // Test to avoid invoice deletion (allowed if draft) - $result = $this->is_erasable(); - - if ($result <= 0) return 0; - - $error=0; - - $this->db->begin(); - - if (! $error && ! $notrigger) - { - // Call trigger - $result=$this->call_trigger('BILL_DELETE',$user); - if ($result < 0) $error++; - // End call triggers - } - - // Removed extrafields - if (! $error) { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error deleteExtraFields ".$this->error, LOG_ERR); - } - } - - if (! $error) - { - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; - } - - if (! $error) - { - // If invoice was converted into a discount not yet consumed, we remove discount - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' WHERE fk_facture_source = '.$rowid; - $sql.= ' AND fk_facture_line IS NULL'; - $resql=$this->db->query($sql); - - // If invoice has consumned discounts - $this->fetch_lines(); - $list_rowid_det=array(); - foreach($this->lines as $key => $invoiceline) - { - $list_rowid_det[]=$invoiceline->rowid; - } - - // Consumned discounts are freed - if (count($list_rowid_det)) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture = NULL, fk_facture_line = NULL'; - $sql.= ' WHERE fk_facture_line IN ('.join(',',$list_rowid_det).')'; - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (! $this->db->query($sql)) - { - $this->error=$this->db->error()." sql=".$sql; - $this->db->rollback(); - return -5; - } - } - - // If we decrement stock on invoice validation, we increment - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse!=-1) - { - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; - $langs->load("agenda"); - - $num=count($this->lines); - for ($i = 0; $i < $num; $i++) - { - if ($this->lines[$i]->fk_product > 0) - { - $mouvP = new MouvementStock($this->db); - $mouvP->origin = &$this; - // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); - else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value - } - } - } - - - // Delete invoice line - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid; - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - - if ($this->db->query($sql) && $this->delete_linked_contact()) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid; - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - - $resql=$this->db->query($sql); - if ($resql) - { - // On efface le repertoire de pdf provisoire - $ref = dol_sanitizeFileName($this->ref); - if ($conf->facture->dir_output && !empty($this->ref)) - { - $dir = $conf->facture->dir_output . "/" . $ref; - $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; - if (file_exists($file)) // We must delete all files before deleting directory - { - $ret=dol_delete_preview($this); - - if (! dol_delete_file($file,0,0,0,$this)) // For triggers - { - $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); - $this->db->rollback(); - return 0; - } - } - if (file_exists($dir)) - { - if (! dol_delete_dir_recursive($dir)) // For remove dir and meta - { - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); - $this->db->rollback(); - return 0; - } - } - } - - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -6; - } - } - else - { - $this->error=$this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -4; - } - } - else - { - $this->db->rollback(); - return -2; - } - } - - /** - * Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1 - * ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 - * - * @param User $user Objet utilisateur qui modifie - * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple) - * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) - * @return int <0 if KO, >0 if OK - */ - function set_paid($user, $close_code='', $close_note='') - { - $error=0; - - if ($this->paye != 1) - { - $this->db->begin(); - - dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; - $sql.= ' fk_statut='.self::STATUS_CLOSED; - if (! $close_code) $sql.= ', paye=1'; - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; - $sql.= ' WHERE rowid = '.$this->id; - - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result=$this->call_trigger('BILL_PAYED',$user); - if ($result < 0) $error++; - // End call triggers - } - else - { - $error++; - $this->error=$this->db->lasterror(); - } - - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - } - else - { - return 0; - } - } - - - /** - * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED - * Fonction utilisee quand un paiement prelevement est refuse, - * ou quand une facture annulee et reouverte. - * - * @param User $user Object user that change status - * @return int <0 if KO, >0 if OK - */ - function set_unpaid($user) - { - $error=0; - - $this->db->begin(); - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null'; - $sql.= ' WHERE rowid = '.$this->id; - - dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result=$this->call_trigger('BILL_UNPAYED',$user); - if ($result < 0) $error++; - // End call triggers - } - else - { - $error++; - $this->error=$this->db->error(); - dol_print_error($this->db); - } - - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - } - - - /** - * Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL - * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because - * of no payment even if merchandises were sent). - * - * @param User $user Object user making change - * @param string $close_code Code of closing invoice (CLOSECODE_REPLACED, CLOSECODE_...) - * @param string $close_note Comment - * @return int <0 if KO, >0 if OK - */ - function set_canceled($user, $close_code='', $close_note='') - { - - dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG); - - $this->db->begin(); - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; - $sql.= ' fk_statut='.self::STATUS_ABANDONED; - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; - $sql.= ' WHERE rowid = '.$this->id; - - $resql = $this->db->query($sql); - if ($resql) - { - // On desaffecte de la facture les remises liees - // car elles n'ont pas ete utilisees vu que la facture est abandonnee. - $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture = NULL'; - $sql.= ' WHERE fk_facture = '.$this->id; - - $resql=$this->db->query($sql); - if ($resql) - { - // Call trigger - $result=$this->call_trigger('BILL_CANCEL',$user); - if ($result < 0) - { - $this->db->rollback(); - return -1; - } - // End call triggers - - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - else - { - $this->error=$this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } - - /** - * Tag invoice as validated + call trigger BILL_VALIDATE - * Object must have lines loaded with fetch_lines - * - * @param User $user Object user that validate - * @param string $force_number Reference to force on invoice - * @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease) - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK - */ - function validate($user, $force_number='', $idwarehouse=0, $notrigger=0) - { - global $conf,$langs; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $now=dol_now(); - - $error=0; - dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse); - - // Force to have object complete for checks - $this->fetch_thirdparty(); - $this->fetch_lines(); - - // Check parameters - if (! $this->brouillon) - { - dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); - return 0; - } - if (count($this->lines) <= 0) - { - $langs->load("errors"); - $this->error=$langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); - return -1; - } - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) - { - $this->error='Permission denied'; - dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); - return -1; - } - - $this->db->begin(); - - // Check parameters - if ($this->type == self::TYPE_REPLACEMENT) // si facture de remplacement - { - // Controle que facture source connue - if ($this->fk_facture_source <= 0) - { - $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("InvoiceReplacement")); - $this->db->rollback(); - return -10; - } - - // Charge la facture source a remplacer - $facreplaced=new Facture($this->db); - $result=$facreplaced->fetch($this->fk_facture_source); - if ($result <= 0) - { - $this->error=$langs->trans("ErrorBadInvoice"); - $this->db->rollback(); - return -11; - } - - // Controle que facture source non deja remplacee par une autre - $idreplacement=$facreplaced->getIdReplacingInvoice('validated'); - if ($idreplacement && $idreplacement != $this->id) - { - $facreplacement=new Facture($this->db); - $facreplacement->fetch($idreplacement); - $this->error=$langs->trans("ErrorInvoiceAlreadyReplaced",$facreplaced->ref,$facreplacement->ref); - $this->db->rollback(); - return -12; - } - - $result=$facreplaced->set_canceled($user, self::CLOSECODE_REPLACED, ''); - if ($result < 0) - { - $this->error=$facreplaced->error; - $this->db->rollback(); - return -13; - } - } - - // Define new ref - if ($force_number) - { - $num = $force_number; - } - else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life - { - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date - { - $this->date=dol_now(); - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); - } - $num = $this->getNextNumRef($this->thirdparty); - } - else - { - $num = $this->ref; - } - $this->newref = $num; - - if ($num) - { - $this->update_price(1); - - // Validate - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date - { - $sql.= ", datef='".$this->db->idate($this->date)."'"; - $sql.= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; - } - $sql.= ' WHERE rowid = '.$this->id; - - dol_syslog(get_class($this)."::validate", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - dol_print_error($this->db); - $error++; - } - - // On verifie si la facture etait une provisoire - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) - { - // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne - } - - if (! $error) - { - // Define third party as a customer - $result=$this->thirdparty->set_as_client(); - - // Si active on decremente le produit principal et ses composants a la validation de facture - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) - { - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; - $langs->load("agenda"); - - // Loop on each line - $cpt=count($this->lines); - for ($i = 0; $i < $cpt; $i++) - { - if ($this->lines[$i]->fk_product > 0) - { - $mouvP = new MouvementStock($this->db); - $mouvP->origin = &$this; - // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num)); - else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); - if ($result < 0) { - $error++; - $this->error = $mouvP->error; - } - } - } - } - } - - // Trigger calls - if (! $error && ! $notrigger) - { - // Call trigger - $result=$this->call_trigger('BILL_VALIDATE',$user); - if ($result < 0) $error++; - // End call triggers - } - - if (! $error) - { - $this->oldref = $this->ref; - - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { - // Rename of object directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->facture->dir_output.'/'.$oldref; - $dirdest = $conf->facture->dir_output.'/'.$newref; - if (file_exists($dirsource)) - { - dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); - - if (@rename($dirsource, $dirdest)) - { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); - foreach($listoffiles as $fileentry) - { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } - } - } - } - } - - if (! $error && !$this->is_last_in_cycle()) - { - if (! $this->updatePriceNextInvoice($langs)) - { - $error++; - } - } - - // Set new ref and define current statut - if (! $error) - { - $this->ref = $num; - $this->facnumber=$num; - $this->statut= self::STATUS_VALIDATED; - $this->brouillon=0; - $this->date_validation=$now; - $i = 0; - - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - $final = true; - $nboflines = count($this->lines); - while (($i < $nboflines) && $final) { - $final = ($this->lines[$i]->situation_percent == 100); - $i++; - } - - if (empty($final)) $this->situation_final = 0; - else $this->situation_final = 1; - - $this->setFinal($user); - - } - } - } - else - { - $error++; - } - - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - } - - /** - * Update price of next invoice - * - * @param Translate $langs Translate object - * @return bool false if KO, true if OK - */ - function updatePriceNextInvoice(&$langs) - { - foreach ($this->tab_next_situation_invoice as $next_invoice) - { - $is_last = $next_invoice->is_last_in_cycle(); - - if ($next_invoice->brouillon && $is_last != 1) - { - $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); - return false; - } - - $next_invoice->brouillon = 1; - foreach ($next_invoice->lines as $line) - { - $result = $next_invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, - $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, - $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, - $line->fk_unit); - - if ($result < 0) - { - $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); - return false; - } - } - - break; // Only the next invoice and not each next invoice - } - - return true; - } - - /** - * Set draft status - * - * @param User $user Object user that modify - * @param int $idwarehouse Id warehouse to use for stock change. - * @return int <0 if KO, >0 if OK - */ - function set_draft($user,$idwarehouse=-1) - { - global $conf,$langs; - - $error=0; - - if ($this->statut == self::STATUS_DRAFT) - { - dol_syslog(get_class($this)."::set_draft already draft status", LOG_WARNING); - return 0; - } - - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $sql.= " SET fk_statut = ".self::STATUS_DRAFT; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::set_draft", LOG_DEBUG); - $result=$this->db->query($sql); - if ($result) - { - // Si on decremente le produit principal et ses composants a la validation de facture, on réincrement - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) - { - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; - $langs->load("agenda"); - - $num=count($this->lines); - for ($i = 0; $i < $num; $i++) - { - if ($this->lines[$i]->fk_product > 0) - { - $mouvP = new MouvementStock($this->db); - $mouvP->origin = &$this; - // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); - else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value - } - } - } - - if ($error == 0) - { - $old_statut=$this->statut; - $this->brouillon = 1; - $this->statut = self::STATUS_DRAFT; - // Call trigger - $result=$this->call_trigger('BILL_UNVALIDATE',$user); - if ($result < 0) - { - $error++; - $this->statut=$old_statut; - $this->brouillon=0; - } - // End call triggers - } else { - $this->db->rollback(); - return -1; - } - - if ($error == 0) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } - - - /** - * Add an invoice line into database (linked to product/service or not). - * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel - * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini - * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) - * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) - * - * @param string $desc Description of line - * @param double $pu_ht Unit price without tax (> 0 even for credit note) - * @param double $qty Quantity - * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') - * @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) - * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) - * @param int $fk_product Id of predefined product/service - * @param double $remise_percent Percent of discount on line - * @param int $date_start Date start of service - * @param int $date_end Date end of service - * @param int $ventil Code of dispatching into accountancy - * @param int $info_bits Bits de type de lignes - * @param int $fk_remise_except Id discount used - * @param string $price_base_type 'HT' or 'TTC' - * @param double $pu_ttc Unit price with tax (> 0 even for credit note) - * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. - * @param int $rang Position of line - * @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 - * @param int $fk_fournprice Supplier price id (to calculate margin) or '' - * @param int $pa_ht Buying price of line (to calculate margin) or '' - * @param string $label Label of the line (deprecated, do not use) - * @param array $array_options extrafields array - * @param int $situation_percent Situation advance percentage - * @param int $fk_prev_id Previous situation line id reference - * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in currency - * @return int <0 if KO, Id of line if OK - */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id=0, $fk_unit = null, $pu_ht_devise = 0) - { - // Deprecation warning - if ($label) { - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); - //var_dump(debug_backtrace(false));exit; - } - - global $mysoc, $conf, $langs; - - dol_syslog(get_class($this)."::addline id=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG); - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - - // Clean parameters - if (empty($remise_percent)) $remise_percent=0; - if (empty($qty)) $qty=0; - if (empty($info_bits)) $info_bits=0; - if (empty($rang)) $rang=0; - if (empty($ventil)) $ventil=0; - if (empty($txtva)) $txtva=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; - if (empty($fk_prev_id)) $fk_prev_id = 'null'; - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); - - // Clean vat code - $vat_src_code=''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } - - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - $pu_ht=price2num($pu_ht); - $pu_ht_devise=price2num($pu_ht_devise); - $pu_ttc=price2num($pu_ttc); - $pa_ht=price2num($pa_ht); - $txtva=price2num($txtva); - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); - - if ($price_base_type=='HT') - { - $pu=$pu_ht; - } - else - { - $pu=$pu_ttc; - } - - // Check parameters - if ($type < 0) return -1; - - if (! empty($this->brouillon)) - { - $this->db->begin(); - - $product_type=$type; - if (!empty($fk_product)) - { - $product=new Product($this->db); - $result=$product->fetch($fk_product); - $product_type=$product->type; - - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { - $langs->load("errors"); - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); - $this->db->rollback(); - return -3; - } - } - - // Calcul du total TTC et de la TVA pour la ligne a partir de - // qty, pu, remise_percent et txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); - - $total_ht = $tabprice[0]; - $total_tva = $tabprice[1]; - $total_ttc = $tabprice[2]; - $total_localtax1 = $tabprice[9]; - $total_localtax2 = $tabprice[10]; - $pu_ht = $tabprice[3]; - - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; - $multicurrency_total_tva = $tabprice[17]; - $multicurrency_total_ttc = $tabprice[18]; - $pu_ht_devise = $tabprice[19]; - - // Rank to use - $rangtouse = $rang; - if ($rangtouse == -1) - { - $rangmax = $this->line_max($fk_parent_line); - $rangtouse = $rangmax + 1; - } - - // Insert line - $this->line=new FactureLigne($this->db); - - $this->line->context = $this->context; - - $this->line->fk_facture=$this->id; - $this->line->label=$label; // deprecated - $this->line->desc=$desc; - - $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise - - $this->line->vat_src_code=$vat_src_code; - $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); - $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); - $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; - - $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); // For credit note and if qty is negative, total is negative - $this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); // For credit note and if qty is negative, total is negative - $this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1); // For credit note and if qty is negative, total is negative - $this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2); // For credit note and if qty is negative, total is negative - - $this->line->fk_product=$fk_product; - $this->line->product_type=$product_type; - $this->line->remise_percent=$remise_percent; - $this->line->date_start=$date_start; - $this->line->date_end=$date_end; - $this->line->ventil=$ventil; - $this->line->rang=$rangtouse; - $this->line->info_bits=$info_bits; - $this->line->fk_remise_except=$fk_remise_except; - - $this->line->special_code=$special_code; - $this->line->fk_parent_line=$fk_parent_line; - $this->line->origin=$origin; - $this->line->origin_id=$origin_id; - $this->line->situation_percent = $situation_percent; - $this->line->fk_prev_id = $fk_prev_id; - $this->line->fk_unit=$fk_unit; - - // infos marge - $this->line->fk_fournprice = $fk_fournprice; - $this->line->pa_ht = $pa_ht; - - // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; - } - - $result=$this->line->insert(); - if ($result > 0) - { - // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); - - // Mise a jour informations denormalisees au niveau de la facture meme - $result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. - - if ($result > 0) - { - $this->db->commit(); - return $this->line->id; - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } - else - { - $this->error=$this->line->error; - $this->db->rollback(); - return -2; - } - } - else - { - dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR); - return -3; - } - } - - /** - * Update a detail line - * - * @param int $rowid Id of line to update - * @param string $desc Description of line - * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines) - * @param double $qty Quantity - * @param double $remise_percent Pourcentage de remise de la ligne - * @param int $date_start Date de debut de validite du service - * @param int $date_end Date de fin de validite du service - * @param double $txtva VAT Rate (Can be '8.5', '8.5 (ABC)') - * @param double $txlocaltax1 Local tax 1 rate - * @param double $txlocaltax2 Local tax 2 rate - * @param string $price_base_type HT or TTC - * @param int $info_bits Miscellaneous informations - * @param int $type Type of line (0=product, 1=service) - * @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 - * @param int $pa_ht Price (without tax) of product when it was bought - * @param string $label Label of the line (deprecated, do not use) - * @param int $special_code Special code (also used by externals modules!) - * @param array $array_options extrafields array - * @param int $situation_percent Situation advance percentage - * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in currency - * @param int $notrigger disable line update trigger - * @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= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0, $notrigger=0) - { - global $conf,$user; - // Deprecation warning - if ($label) { - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); - } - - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - - global $mysoc,$langs; - - dol_syslog(get_class($this)."::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); - - if ($this->brouillon) - { - if (!$this->is_last_in_cycle() && empty($this->error)) - { - if (!$this->checkProgressLine($rowid, $situation_percent)) - { - if (!$this->error) $this->error=$langs->trans('invoiceLineProgressError'); - return -3; - } - } - - $this->db->begin(); - - // 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; - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - - $remise_percent = price2num($remise_percent); - $qty = price2num($qty); - $pu = price2num($pu); - $pu_ht_devise = price2num($pu_ht_devise); - $pa_ht = price2num($pa_ht); - $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); - - // Check parameters - if ($type < 0) return -1; - - // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - - $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); - - // Clean vat code - $vat_src_code=''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } - - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); - - $total_ht = $tabprice[0]; - $total_tva = $tabprice[1]; - $total_ttc = $tabprice[2]; - $total_localtax1=$tabprice[9]; - $total_localtax2=$tabprice[10]; - $pu_ht = $tabprice[3]; - $pu_tva = $tabprice[4]; - $pu_ttc = $tabprice[5]; - - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; - $multicurrency_total_tva = $tabprice[17]; - $multicurrency_total_ttc = $tabprice[18]; - $pu_ht_devise = $tabprice[19]; - - // Old properties: $price, $remise (deprecated) - $price = $pu; - $remise = 0; - if ($remise_percent > 0) - { - $remise = round(($pu * $remise_percent / 100),2); - $price = ($pu - $remise); - } - $price = price2num($price); - - //Fetch current line from the database and then clone the object and set it in $oldline property - $line = new FactureLigne($this->db); - $line->fetch($rowid); - - if (!empty($line->fk_product)) - { - $product=new Product($this->db); - $result=$product->fetch($line->fk_product); - $product_type=$product->type; - - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { - $langs->load("errors"); - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); - $this->db->rollback(); - return -3; - } - } - - $staticline = clone $line; - - $line->oldline = $staticline; - $this->line = $line; - $this->line->context = $this->context; - - // Reorder if fk_parent_line change - if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) - { - $rangmax = $this->line_max($fk_parent_line); - $this->line->rang = $rangmax + 1; - } - - $this->line->rowid = $rowid; - $this->line->label = $label; - $this->line->desc = $desc; - $this->line->qty = ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative - - $this->line->vat_src_code = $vat_src_code; - $this->line->tva_tx = $txtva; - $this->line->localtax1_tx = $txlocaltax1; - $this->line->localtax2_tx = $txlocaltax2; - $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; - - $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->date_start = $date_start; - $this->line->date_end = $date_end; - $this->line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); - $this->line->info_bits = $info_bits; - $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; - $this->line->situation_percent = $situation_percent; - $this->line->fk_unit = $fk_unit; - - $this->line->fk_fournprice = $fk_fournprice; - $this->line->pa_ht = $pa_ht; - - // Multicurrency - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; - } - - $result=$this->line->update($user, $notrigger); - if ($result > 0) - { - // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); - - // Mise a jour info denormalisees au niveau facture - $this->update_price(1); - $this->db->commit(); - return $result; - } - else - { - $this->error=$this->line->error; - $this->db->rollback(); - return -1; - } - } - else - { - $this->error="Invoice statut makes operation forbidden"; - return -2; - } - } - - /** - * Check if the percent edited is lower of next invoice line - * - * @param int $idline id of line to check - * @param float $situation_percent progress percentage need to be test - * @return false if KO, true if OK - */ - function checkProgressLine($idline, $situation_percent) - { - $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd - INNER JOIN '.MAIN_DB_PREFIX.'facture f ON (fd.fk_facture = f.rowid) - WHERE fd.fk_prev_id = '.$idline.' - AND f.fk_statut <> 0'; - - $result = $this->db->query($sql); - if (! $result) - { - $this->error=$this->db->error(); - return false; - } - - $obj = $this->db->fetch_object($result); - - if ($obj === null) return true; - else return $situation_percent < $obj->situation_percent; - } - - /** - * Update invoice line with percentage - * - * @param FactureLigne $line Invoice line - * @param int $percent Percentage - * @return void - */ - function update_percent($line, $percent) - { - global $mysoc,$user; - - include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'); - - // Cap percentages to 100 - if ($percent > 100) $percent = 100; - $line->situation_percent = $percent; - $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $percent); - $line->total_ht = $tabprice[0]; - $line->total_tva = $tabprice[1]; - $line->total_ttc = $tabprice[2]; - $line->total_localtax1 = $tabprice[9]; - $line->total_localtax2 = $tabprice[10]; - $line->multicurrency_total_ht = $tabprice[16]; - $line->multicurrency_total_tva = $tabprice[17]; - $line->multicurrency_total_ttc = $tabprice[18]; - $line->update($user); - $this->update_price(1); - $this->db->commit(); - } - - /** - * Delete line in database - * - * @param int $rowid Id of line to delete - * @return int <0 if KO, >0 if OK - */ - function deleteline($rowid) - { - global $user; - - dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); - - if (! $this->brouillon) - { - $this->error='ErrorDeleteLineNotAllowedByObjectStatus'; - return -1; - } - - $this->db->begin(); - - // Libere remise liee a ligne de facture - $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture_line = NULL'; - $sql.= ' WHERE fk_facture_line = '.$rowid; - - dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); - $result = $this->db->query($sql); - if (! $result) - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - - $line=new FactureLigne($this->db); - - $line->context = $this->context; - - // For triggers - $result = $line->fetch($rowid); - if (! ($result > 0)) dol_print_error($this->db, $line->error, $line->errors); - - if ($line->delete($user) > 0) - { - $result=$this->update_price(1); - - if ($result > 0) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } - } - else - { - $this->db->rollback(); - $this->error=$line->error; - return -1; - } - } - - /** - * Set percent discount - * - * @param User $user User that set discount - * @param double $remise Discount - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if ko, >0 if ok - */ - function set_remise($user, $remise, $notrigger=0) - { - // Clean parameters - if (empty($remise)) $remise=0; - - if ($user->rights->facture->creer) - { - $remise=price2num($remise); - - $error=0; - - $this->db->begin(); - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET remise_percent = '.$remise; - $sql.= ' WHERE rowid = '.$this->id; - $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; - - dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); - if (!$resql) - { - $this->errors[]=$this->db->error(); - $error++; - } - - if (! $notrigger && empty($error)) - { - // Call trigger - $result=$this->call_trigger('BILL_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers - } - - if (! $error) - { - $this->remise_percent = $remise; - $this->update_price(1); - - $this->db->commit(); - return 1; - } - else - { - foreach($this->errors as $errmsg) - { - dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - } - } - - - /** - * Set absolute discount - * - * @param User $user User that set discount - * @param double $remise Discount - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >0 if OK - */ - function set_remise_absolue($user, $remise, $notrigger=0) - { - if (empty($remise)) $remise=0; - - if ($user->rights->facture->creer) - { - $error=0; - - $this->db->begin(); - - $remise=price2num($remise); - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET remise_absolue = '.$remise; - $sql.= ' WHERE rowid = '.$this->id; - $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; - - dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); - if (!$resql) - { - $this->errors[]=$this->db->error(); - $error++; - } - - if (! $error) - { - $this->oldcopy= clone $this; - $this->remise_absolue = $remise; - $this->update_price(1); - } - - if (! $notrigger && empty($error)) - { - // Call trigger - $result=$this->call_trigger('BILL_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers - } - - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - foreach($this->errors as $errmsg) - { - dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - } - } - - /** - * Return next reference of customer invoice not already used (or last reference) - * according to numbering module defined into constant FACTURE_ADDON - * - * @param Societe $soc object company - * @param string $mode 'next' for next value or 'last' for last value - * @return string free ref or last ref - */ - function getNextNumRef($soc,$mode='next') - { - global $conf, $langs; - $langs->load("bills"); - - // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON='mod_facture_terre'; - else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre'; - else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure'; - - if (! empty($conf->global->FACTURE_ADDON)) - { - dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG); - - $mybool=false; - - $file = $conf->global->FACTURE_ADDON.".php"; - $classname = $conf->global->FACTURE_ADDON; - - // Include file with class - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - - foreach ($dirmodels as $reldir) { - - $dir = dol_buildpath($reldir."core/modules/facture/"); - - // Load file with numbering class (if found) - if (is_file($dir.$file) && is_readable($dir.$file)) - { - $mybool |= include_once $dir . $file; - } - } - - // For compatibility - if (! $mybool) - { - $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; - $classname = "mod_facture_".$conf->global->FACTURE_ADDON; - $classname = preg_replace('/\-.*$/','',$classname); - // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/facture/"; - - // Load file with numbering class (if found) - if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir . $file; - } - } - } - - if (! $mybool) - { - dol_print_error('',"Failed to include file ".$file); - return ''; - } - - $obj = new $classname(); - $numref = ""; - $numref = $obj->getNextValue($soc,$this,$mode); - - /** - * $numref can be empty in case we ask for the last value because if there is no invoice created with the - * set up mask. - */ - if ($mode != 'last' && !$numref) { - $this->error=$obj->error; - //dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); - return ""; - } - - return $numref; - } - else - { - $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); - return ""; - } - } - - /** - * Load miscellaneous information for tab "Info" - * - * @param int $id Id of object to load - * @return void - */ - function info($id) - { - $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; - $sql.= ' fk_user_author, fk_user_valid'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c'; - $sql.= ' WHERE c.rowid = '.$id; - - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if ($obj->fk_user_valid) - { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); // Should be in log table - } - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } - - - /** - * Return list of invoices (eventually filtered on a user) into an array - * - * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) - * @param int $draft 0=not draft, 1=draft - * @param User $excluser Objet user to exclude - * @param int $socid Id third pary - * @param int $limit For pagination - * @param int $offset For pagination - * @param string $sortfield Sort criteria - * @param string $sortorder Sort order - * @return int -1 if KO, array with result if OK - */ - function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='f.datef,f.rowid', $sortorder='DESC') - { - global $conf,$user; - - $ga = array(); - - $sql = "SELECT s.rowid, s.nom as name, s.client,"; - $sql.= " f.rowid as fid, f.facnumber as ref, f.datef as df"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND f.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) //restriction - { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - } - if ($socid) $sql.= " AND s.rowid = ".$socid; - if ($draft) $sql.= " AND f.fk_statut = ".self::STATUS_DRAFT; - if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id; - $sql.= $this->db->order($sortfield,$sortorder); - $sql.= $this->db->plimit($limit,$offset); - - $result=$this->db->query($sql); - if ($result) - { - $numc = $this->db->num_rows($result); - if ($numc) - { - $i = 0; - while ($i < $numc) - { - $obj = $this->db->fetch_object($result); - - if ($shortlist == 1) - { - $ga[$obj->fid] = $obj->ref; - } - else if ($shortlist == 2) - { - $ga[$obj->fid] = $obj->ref.' ('.$obj->name.')'; - } - else - { - $ga[$i]['id'] = $obj->fid; - $ga[$i]['ref'] = $obj->ref; - $ga[$i]['name'] = $obj->name; - } - $i++; - } - } - return $ga; - } - else - { - dol_print_error($this->db); - return -1; - } - } - - - /** - * Return list of invoices qualified to be replaced by another invoice. - * Invoices matching the following rules are returned: - * (Status validated or abandonned for a reason 'other') + not payed + no payment at all + not already replaced - * - * @param int $socid Id thirdparty - * @return array Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) - */ - function list_replacable_invoices($socid=0) - { - global $conf; - - $return = array(); - - $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut,"; - $sql.= " ff.rowid as rowidnext"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; - $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.paye = 0"; // Pas classee payee completement - $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait - $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; - $sql.= " ORDER BY f.facnumber"; - - dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - while ($obj=$this->db->fetch_object($resql)) - { - $return[$obj->rowid]=array( 'id' => $obj->rowid, - 'ref' => $obj->facnumber, - 'status' => $obj->fk_statut); - } - //print_r($return); - return $return; - } - else - { - $this->error=$this->db->error(); - return -1; - } - } - - - /** - * Return list of invoices qualified to be corrected by a credit note. - * Invoices matching the following rules are returned: - * (validated + payment on process) or classified (payed completely or payed partiely) + not already replaced + not already a credit note - * - * @param int $socid Id thirdparty - * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) - */ - function list_qualified_avoir_invoices($socid=0) - { - global $conf; - - $return = array(); - - - $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; - $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; - // $sql.= " WHERE f.fk_statut >= 1"; - // $sql.= " AND (f.paye = 1"; // Classee payee completement - // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement - $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement - $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - - if($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE){ - // Select the last situation invoice - $sqlSit = 'SELECT MAX(fs.rowid)'; - $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; - $sqlSit.= " WHERE fs.entity = ".$conf->entity; - $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; - $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; - $sqlSit.= " GROUP BY fs.situation_cycle_ref"; - $sqlSit.= " ORDER BY fs.situation_counter"; - $sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir - } - else - { - $sql.= " AND f.type != ".self::TYPE_SITUATION ; // Type non 5 si facture non avoir - } - - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; - $sql.= " ORDER BY f.facnumber"; - - dol_syslog(get_class($this)."::list_qualified_avoir_invoices", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - while ($obj=$this->db->fetch_object($resql)) - { - $qualified=0; - if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1; - if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1; - if ($qualified) - { - //$ref=$obj->facnumber; - $paymentornot=($obj->fk_paiement?1:0); - $return[$obj->rowid]=array('ref'=>$obj->facnumber,'status'=>$obj->fk_statut,'type'=>$obj->type,'paye'=>$obj->paye,'paymentornot'=>$paymentornot); - } - } - - return $return; - } - else - { - $this->error=$this->db->error(); - return -1; - } - } - - - /** - * Create a withdrawal request for a standing order. - * Use the remain to pay excluding all existing open direct debit requests. - * - * @param User $fuser User asking the direct debit transfer - * @param float $amount Amount we request direct debit for - * @return int <0 if KO, >0 if OK - */ - function demande_prelevement($fuser, $amount=0) - { - - $error=0; - - dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - - if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) - { - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; - $bac = new CompanyBankAccount($this->db); - $bac->fetch(0,$this->socid); - - $sql = 'SELECT count(*)'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - $sql.= ' WHERE fk_facture = '.$this->id; - $sql.= ' AND traite = 0'; - - dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $row = $this->db->fetch_row($resql); - if ($row[0] == 0) - { - $now=dol_now(); - - $totalpaye = $this->getSommePaiement(); - $totalcreditnotes = $this->getSumCreditNotesUsed(); - $totaldeposits = $this->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; - - // We can also use bcadd to avoid pb with floating points - // For example print 239.2 - 229.3 - 9.9; does not return 0. - //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); - //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT'); - - if (is_numeric($amount) && $amount != 0) - { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - $sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)'; - $sql .= ' VALUES ('.$this->id; - $sql .= ",'".price2num($amount)."'"; - $sql .= ",'".$this->db->idate($now)."'"; - $sql .= ",".$fuser->id; - $sql .= ",'".$bac->code_banque."'"; - $sql .= ",'".$bac->code_guichet."'"; - $sql .= ",'".$bac->number."'"; - $sql .= ",'".$bac->cle_rib."')"; - - dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this).'::demandeprelevement Erreur'); - $error++; - } - } - else - { - $this->error='WithdrawRequestErrorNilAmount'; - dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount'); - $error++; - } - - if (! $error) - { - // Force payment mode of invoice to withdraw - $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); - if ($payment_mode_id > 0) - { - $result=$this->setPaymentMethods($payment_mode_id); - } - } - - if ($error) return -1; - return 1; - } - else - { - $this->error="A request already exists"; - dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); - return 0; - } + $linkclose = ''; + if (empty($notooltip) && $user->rights->facture->lire) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowInvoice"); + $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; } - else - { - $this->error=$this->db->error(); - dol_syslog(get_class($this).'::demandeprelevement Erreur -2'); - return -2; + $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"'; + $linkclose .= ' class="classfortooltip"'; + } + + $linkstart = ''; + $linkend = ''; + + if ($option == 'nolink') { + $linkstart = ''; + $linkend = ''; + } + + $result .= $linkstart; + if ($withpicto) + $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="' . (($withpicto != 2) ? 'paddingright ' : '') . 'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) + $result .= ($max ? dol_trunc($this->ref, $max) : $this->ref); + $result .= $linkend; + + if ($addlinktonotes) { + $txttoshow = ($user->societe_id > 0 ? $this->note_public : $this->note_private); + if ($txttoshow) { + $notetoshow = $langs->trans("ViewPrivateNote") . ':
' . dol_string_nohtmltag($txttoshow, 1); + $result .= ' '; + $result .= '' . img_picto('', 'object_generic') . ''; + //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); + //$result.=''; + $result .= ''; } } + + return $result; + } + + /** + * Get object and lines from database + * + * @param int $rowid Id of object to load + * @param string $ref Reference of invoice + * @param string $ref_ext External reference of invoice + * @param int $ref_int Internal reference of other object + * @param bool $fetch_situation Fetch the previous and next situation in $tab_previous_situation_invoice and $tab_next_situation_invoice + * @return int >0 if OK, <0 if KO, 0 if not found + */ + function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_situation = false) { + global $conf; + + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) + return -1; + + $sql = 'SELECT f.rowid,f.entity,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; + $sql .= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; + $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; + $sql .= ', f.datef as df, f.date_pointoftax'; + $sql .= ', f.date_lim_reglement as dlr'; + $sql .= ', f.datec as datec'; + $sql .= ', f.date_valid as datev'; + $sql .= ', f.tms as datem'; + $sql .= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc'; + $sql .= ', f.fk_facture_source'; + $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; + $sql .= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; + $sql .= ', f.fk_account'; + $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; + $sql .= ', f.fk_incoterms, f.location_incoterms'; + $sql .= ", i.libelle as libelle_incoterms"; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture as f'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as p ON f.fk_mode_reglement = p.id'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_incoterms as i ON f.fk_incoterms = i.rowid'; + + if ($rowid) + $sql .= " WHERE f.rowid=" . $rowid; else - { - $this->error="Status of invoice does not allow this"; - dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id"); + $sql .= ' WHERE f.entity IN (' . getEntity('facture') . ')'; // Dont't use entity if you use rowid + + if ($ref) + $sql .= " AND f.facnumber='" . $this->db->escape($ref) . "'"; + if ($ref_ext) + $sql .= " AND f.ref_ext='" . $this->db->escape($ref_ext) . "'"; + if ($ref_int) + $sql .= " AND f.ref_int='" . $this->db->escape($ref_int) . "'"; + + dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + + $this->id = $obj->rowid; + $this->entity = $obj->entity; + + $this->ref = $obj->facnumber; + $this->ref_client = $obj->ref_client; + $this->ref_ext = $obj->ref_ext; + $this->ref_int = $obj->ref_int; + $this->type = $obj->type; + $this->date = $this->db->jdate($obj->df); + $this->date_pointoftax = $this->db->jdate($obj->date_pointoftax); + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_validation = $this->db->jdate($obj->datev); + $this->datem = $this->db->jdate($obj->datem); + $this->remise_percent = $obj->remise_percent; + $this->remise_absolue = $obj->remise_absolue; + $this->total_ht = $obj->total; + $this->total_tva = $obj->tva; + $this->total_localtax1 = $obj->localtax1; + $this->total_localtax2 = $obj->localtax2; + $this->total_ttc = $obj->total_ttc; + $this->revenuestamp = $obj->revenuestamp; + $this->paye = $obj->paye; + $this->close_code = $obj->close_code; + $this->close_note = $obj->close_note; + $this->socid = $obj->fk_soc; + $this->statut = $obj->fk_statut; + $this->date_lim_reglement = $this->db->jdate($obj->dlr); + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement_libelle; + $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->cond_reglement_code = $obj->cond_reglement_code; + $this->cond_reglement = $obj->cond_reglement_libelle; + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + $this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null; + $this->fk_project = $obj->fk_projet; + $this->fk_facture_source = $obj->fk_facture_source; + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->user_author = $obj->fk_user_author; + $this->user_valid = $obj->fk_user_valid; + $this->modelpdf = $obj->model_pdf; + $this->last_main_doc = $obj->last_main_doc; + $this->situation_cycle_ref = $obj->situation_cycle_ref; + $this->situation_counter = $obj->situation_counter; + $this->situation_final = $obj->situation_final; + $this->extraparams = (array) json_decode($obj->extraparams, true); + + //Incoterms + $this->fk_incoterms = $obj->fk_incoterms; + $this->location_incoterms = $obj->location_incoterms; + $this->libelle_incoterms = $obj->libelle_incoterms; + + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + + if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) { + $this->fetchPreviousNextSituationInvoice(); + } + + if ($this->statut == self::STATUS_DRAFT) + $this->brouillon = 1; + + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + + /* + * Lines + */ + + $this->lines = array(); + + $result = $this->fetch_lines(); + if ($result < 0) { + $this->error = $this->db->error(); + return -3; + } + return 1; + } else { + $this->error = 'Bill with id=' . $rowid . ' or ref=' . $ref . ' or ref_ext=' . $ref_ext . ' not found'; + dol_syslog(get_class($this) . "::fetch Error " . $this->error, LOG_ERR); + return 0; + } + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Load all detailed lines into this->lines + * + * @return int 1 if OK, < 0 if KO + */ + function fetch_lines() { + $this->lines = array(); + + $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; + $sql .= ' l.situation_percent, l.fk_prev_id,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; + $sql .= ' l.rang, l.special_code,'; + $sql .= ' l.date_start as date_start, l.date_end as date_end,'; + $sql .= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; + $sql .= ' l.fk_unit,'; + $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facturedet as l'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.fk_facture = ' . $this->id; + $sql .= ' ORDER BY l.rang, l.rowid'; + + dol_syslog(get_class($this) . '::fetch_lines', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $this->db->fetch_object($result); + $line = new FactureLigne($this->db); + + $line->id = $objp->rowid; + $line->rowid = $objp->rowid; // deprecated + $line->fk_facture = $objp->fk_facture; + $line->label = $objp->custom_label; // deprecated + $line->desc = $objp->description; // Description line + $line->description = $objp->description; // Description line + $line->product_type = $objp->product_type; // Type of line + $line->ref = $objp->product_ref; // Ref product + $line->product_ref = $objp->product_ref; // Ref product + $line->libelle = $objp->product_label; // TODO deprecated + $line->product_label = $objp->product_label; // Label product + $line->product_desc = $objp->product_desc; // Description product + $line->fk_product_type = $objp->fk_product_type; // Type of product + $line->qty = $objp->qty; + $line->subprice = $objp->subprice; + + $line->vat_src_code = $objp->vat_src_code; + $line->tva_tx = $objp->tva_tx; + $line->localtax1_tx = $objp->localtax1_tx; + $line->localtax2_tx = $objp->localtax2_tx; + $line->localtax1_type = $objp->localtax1_type; + $line->localtax2_type = $objp->localtax2_type; + $line->remise_percent = $objp->remise_percent; + $line->fk_remise_except = $objp->fk_remise_except; + $line->fk_product = $objp->fk_product; + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); + $line->info_bits = $objp->info_bits; + $line->total_ht = $objp->total_ht; + $line->total_tva = $objp->total_tva; + $line->total_localtax1 = $objp->total_localtax1; + $line->total_localtax2 = $objp->total_localtax2; + $line->total_ttc = $objp->total_ttc; + $line->code_ventilation = $objp->fk_code_ventilation; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; + $line->rang = $objp->rang; + $line->special_code = $objp->special_code; + $line->fk_parent_line = $objp->fk_parent_line; + $line->situation_percent = $objp->situation_percent; + $line->fk_prev_id = $objp->fk_prev_id; + $line->fk_unit = $objp->fk_unit; + + // Accountancy + $line->fk_accounting_account = $objp->fk_code_ventilation; + + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + + // TODO Fetch optional like done in fetch line of facture_rec ? + + $this->lines[$i] = $line; + + $i++; + } + $this->db->free($result); + return 1; + } else { + $this->error = $this->db->error(); return -3; } } - /** - * Supprime une demande de prelevement - * - * @param User $fuser User making delete - * @param int $did id de la demande a supprimer - * @return int <0 if OK, >0 if KO - */ - function demande_prelevement_delete($fuser, $did) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - $sql .= ' WHERE rowid = '.$did; - $sql .= ' AND traite = 0'; - if ( $this->db->query($sql) ) - { - return 0; - } - else - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error); - return -1; - } - } + /** + * Fetch previous and next situations invoices + * + * @return void + */ + function fetchPreviousNextSituationInvoice() { + global $conf; + + $this->tab_previous_situation_invoice = array(); + $this->tab_next_situation_invoice = array(); + + $sql = 'SELECT rowid, situation_counter FROM ' . MAIN_DB_PREFIX . 'facture WHERE rowid <> ' . $this->id . ' AND entity = ' . $conf->entity . ' AND situation_cycle_ref = ' . (int) $this->situation_cycle_ref . ' ORDER BY situation_counter ASC'; + + dol_syslog(get_class($this) . '::fetchPreviousNextSituationInvoice ', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result && $this->db->num_rows($result) > 0) { + while ($objp = $this->db->fetch_object($result)) { + $invoice = new Facture($this->db); + if ($invoice->fetch($objp->rowid) > 0) { + if ($objp->situation_counter < $this->situation_counter || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes + ) { + $this->tab_previous_situation_invoice[] = $invoice; + } else { + $this->tab_next_situation_invoice[] = $invoice; + } + } + } + } + } + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update(User $user, $notrigger = 0) { + $error = 0; + + // Clean parameters + if (empty($this->type)) + $this->type = self::TYPE_STANDARD; + if (isset($this->facnumber)) + $this->facnumber = trim($this->ref); + if (isset($this->ref_client)) + $this->ref_client = trim($this->ref_client); + if (isset($this->increment)) + $this->increment = trim($this->increment); + if (isset($this->close_code)) + $this->close_code = trim($this->close_code); + if (isset($this->close_note)) + $this->close_note = trim($this->close_note); + if (isset($this->note) || isset($this->note_private)) + $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + if (isset($this->note) || isset($this->note_private)) + $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); + if (isset($this->note_public)) + $this->note_public = trim($this->note_public); + if (isset($this->modelpdf)) + $this->modelpdf = trim($this->modelpdf); + if (isset($this->import_key)) + $this->import_key = trim($this->import_key); + + // Check parameters + // Put here code to add control on parameters values + // Update request + $sql = "UPDATE " . MAIN_DB_PREFIX . "facture SET"; + $sql .= " facnumber=" . (isset($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : "null") . ","; + $sql .= " type=" . (isset($this->type) ? $this->db->escape($this->type) : "null") . ","; + $sql .= " ref_client=" . (isset($this->ref_client) ? "'" . $this->db->escape($this->ref_client) . "'" : "null") . ","; + $sql .= " increment=" . (isset($this->increment) ? "'" . $this->db->escape($this->increment) . "'" : "null") . ","; + $sql .= " fk_soc=" . (isset($this->socid) ? $this->db->escape($this->socid) : "null") . ","; + $sql .= " datec=" . (strval($this->date_creation) != '' ? "'" . $this->db->idate($this->date_creation) . "'" : 'null') . ","; + $sql .= " datef=" . (strval($this->date) != '' ? "'" . $this->db->idate($this->date) . "'" : 'null') . ","; + $sql .= " date_pointoftax=" . (strval($this->date_pointoftax) != '' ? "'" . $this->db->idate($this->date_pointoftax) . "'" : 'null') . ","; + $sql .= " date_valid=" . (strval($this->date_validation) != '' ? "'" . $this->db->idate($this->date_validation) . "'" : 'null') . ","; + $sql .= " paye=" . (isset($this->paye) ? $this->db->escape($this->paye) : "null") . ","; + $sql .= " remise_percent=" . (isset($this->remise_percent) ? $this->db->escape($this->remise_percent) : "null") . ","; + $sql .= " remise_absolue=" . (isset($this->remise_absolue) ? $this->db->escape($this->remise_absolue) : "null") . ","; + $sql .= " close_code=" . (isset($this->close_code) ? "'" . $this->db->escape($this->close_code) . "'" : "null") . ","; + $sql .= " close_note=" . (isset($this->close_note) ? "'" . $this->db->escape($this->close_note) . "'" : "null") . ","; + $sql .= " tva=" . (isset($this->total_tva) ? $this->total_tva : "null") . ","; + $sql .= " localtax1=" . (isset($this->total_localtax1) ? $this->total_localtax1 : "null") . ","; + $sql .= " localtax2=" . (isset($this->total_localtax2) ? $this->total_localtax2 : "null") . ","; + $sql .= " total=" . (isset($this->total_ht) ? $this->total_ht : "null") . ","; + $sql .= " total_ttc=" . (isset($this->total_ttc) ? $this->total_ttc : "null") . ","; + $sql .= " revenuestamp=" . ((isset($this->revenuestamp) && $this->revenuestamp != '') ? $this->db->escape($this->revenuestamp) : "null") . ","; + $sql .= " fk_statut=" . (isset($this->statut) ? $this->db->escape($this->statut) : "null") . ","; + $sql .= " fk_user_author=" . (isset($this->user_author) ? $this->db->escape($this->user_author) : "null") . ","; + $sql .= " fk_user_valid=" . (isset($this->fk_user_valid) ? $this->db->escape($this->fk_user_valid) : "null") . ","; + $sql .= " fk_facture_source=" . (isset($this->fk_facture_source) ? $this->db->escape($this->fk_facture_source) : "null") . ","; + $sql .= " fk_projet=" . (isset($this->fk_project) ? $this->db->escape($this->fk_project) : "null") . ","; + $sql .= " fk_cond_reglement=" . (isset($this->cond_reglement_id) ? $this->db->escape($this->cond_reglement_id) : "null") . ","; + $sql .= " fk_mode_reglement=" . (isset($this->mode_reglement_id) ? $this->db->escape($this->mode_reglement_id) : "null") . ","; + $sql .= " date_lim_reglement=" . (strval($this->date_lim_reglement) != '' ? "'" . $this->db->idate($this->date_lim_reglement) . "'" : 'null') . ","; + $sql .= " note_private=" . (isset($this->note_private) ? "'" . $this->db->escape($this->note_private) . "'" : "null") . ","; + $sql .= " note_public=" . (isset($this->note_public) ? "'" . $this->db->escape($this->note_public) . "'" : "null") . ","; + $sql .= " model_pdf=" . (isset($this->modelpdf) ? "'" . $this->db->escape($this->modelpdf) . "'" : "null") . ","; + $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ","; + $sql .= " situation_cycle_ref=" . (empty($this->situation_cycle_ref) ? "null" : $this->db->escape($this->situation_cycle_ref)) . ","; + $sql .= " situation_counter=" . (empty($this->situation_counter) ? "null" : $this->db->escape($this->situation_counter)) . ","; + $sql .= " situation_final=" . (empty($this->situation_counter) ? "0" : $this->db->escape($this->situation_counter)); + $sql .= " WHERE rowid=" . $this->id; + + $this->db->begin(); + + dol_syslog(get_class($this) . "::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error " . $this->db->lasterror(); + } + + if (!$error) { + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILL_MODIFY', $user); + if ($result < 0) + $error++; + // End call triggers + } + } + + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } + + /** + * Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount) + * + * @param int $idremise Id of absolute discount + * @return int >0 if OK, <0 if KO + */ + function insert_discount($idremise) { + global $langs; + + include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + + $this->db->begin(); + + $remise = new DiscountAbsolute($this->db); + $result = $remise->fetch($idremise); + + if ($result > 0) { + if ($remise->fk_facture) { // Protection against multiple submission + $this->error = $langs->trans("ErrorDiscountAlreadyUsed"); + $this->db->rollback(); + return -5; + } + + $facligne = new FactureLigne($this->db); + $facligne->fk_facture = $this->id; + $facligne->fk_remise_except = $remise->id; + $facligne->desc = $remise->description; // Description ligne + $facligne->vat_src_code = $remise->vat_src_code; + $facligne->tva_tx = $remise->tva_tx; + $facligne->subprice = -$remise->amount_ht; + $facligne->fk_product = 0; // Id produit predefini + $facligne->qty = 1; + $facligne->remise_percent = 0; + $facligne->rang = -1; + $facligne->info_bits = 2; + + // Get buy/cost price of invoice that is source of discount + if ($remise->fk_facture_source > 0) { + $srcinvoice = new Facture($this->db); + $srcinvoice->fetch($remise->fk_facture_source); + $totalcostpriceofinvoice = 0; + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; // TODO Move this into commonobject + $formmargin = new FormMargin($this->db); + $arraytmp = $formmargin->getMarginInfosArray($srcinvoice, false); + $facligne->pa_ht = $arraytmp['pa_total']; + } + + $facligne->total_ht = -$remise->amount_ht; + $facligne->total_tva = -$remise->amount_tva; + $facligne->total_ttc = -$remise->amount_ttc; + + $facligne->multicurrency_subprice = -$remise->multicurrency_subprice; + $facligne->multicurrency_total_ht = -$remise->multicurrency_total_ht; + $facligne->multicurrency_total_tva = -$remise->multicurrency_total_tva; + $facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc; + + $lineid = $facligne->insert(); + if ($lineid > 0) { + $result = $this->update_price(1); + if ($result > 0) { + // Create link between discount and invoice line + $result = $remise->link_to_invoice($lineid, 0); + if ($result < 0) { + $this->error = $remise->error; + $this->db->rollback(); + return -4; + } + + $this->db->commit(); + return 1; + } else { + $this->error = $facligne->error; + $this->db->rollback(); + return -1; + } + } else { + $this->error = $facligne->error; + $this->db->rollback(); + return -2; + } + } else { + $this->db->rollback(); + return -3; + } + } + + /** + * Set customer ref + * + * @param string $ref_client Customer ref + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK + */ + function set_ref_client($ref_client, $notrigger = 0) { + global $user; + + $error = 0; + + $this->db->begin(); + + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; + if (empty($ref_client)) + $sql .= ' SET ref_client = NULL'; + else + $sql .= ' SET ref_client = \'' . $this->db->escape($ref_client) . '\''; + $sql .= ' WHERE rowid = ' . $this->id; + + dol_syslog(__METHOD__ . ' this->id=' . $this->id . ', ref_client=' . $ref_client, LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = $this->db->error(); + $error++; + } + + if (!$error) { + $this->ref_client = $ref_client; + } + + if (!$notrigger && empty($error)) { + // Call trigger + $result = $this->call_trigger('BILL_MODIFY', $user); + if ($result < 0) + $error++; + // End call triggers + } + + if (!$error) { + + $this->ref_client = $ref_client; + + $this->db->commit(); + return 1; + } else { + foreach ($this->errors as $errmsg) { + dol_syslog(__METHOD__ . ' Error: ' . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } + } + + /** + * Delete invoice + * + * @param User $user User making the deletion. + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $idwarehouse Id warehouse to use for stock change. + * @return int <0 if KO, 0=Refused, >0 if OK + */ + function delete($user, $notrigger = 0, $idwarehouse = -1) { + global $langs, $conf; + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $rowid = $this->id; + + dol_syslog(get_class($this) . "::delete rowid=" . $rowid . ", ref=" . $this->ref . ", thirdparty=" . $this->thirdparty->name, LOG_DEBUG); + + // Test to avoid invoice deletion (allowed if draft) + $result = $this->is_erasable(); + + if ($result <= 0) + return 0; + + $error = 0; + + $this->db->begin(); + + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('BILL_DELETE', $user); + if ($result < 0) + $error++; + // End call triggers + } + + // Removed extrafields + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this) . "::delete error deleteExtraFields " . $this->error, LOG_ERR); + } + } + + if (!$error) { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) + $error++; + } + + if (!$error) { + // If invoice was converted into a discount not yet consumed, we remove discount + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'societe_remise_except'; + $sql .= ' WHERE fk_facture_source = ' . $rowid; + $sql .= ' AND fk_facture_line IS NULL'; + $resql = $this->db->query($sql); + + // If invoice has consumned discounts + $this->fetch_lines(); + $list_rowid_det = array(); + foreach ($this->lines as $key => $invoiceline) { + $list_rowid_det[] = $invoiceline->rowid; + } + + // Consumned discounts are freed + if (count($list_rowid_det)) { + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except'; + $sql .= ' SET fk_facture = NULL, fk_facture_line = NULL'; + $sql .= ' WHERE fk_facture_line IN (' . join(',', $list_rowid_det) . ')'; + + dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + if (!$this->db->query($sql)) { + $this->error = $this->db->error() . " sql=" . $sql; + $this->db->rollback(); + return -5; + } + } + + // If we decrement stock on invoice validation, we increment + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) { + require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; + $langs->load("agenda"); + + $num = count($this->lines); + for ($i = 0; $i < $num; $i++) { + if ($this->lines[$i]->fk_product > 0) { + $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; + // We decrease stock for product + if ($this->type == self::TYPE_CREDIT_NOTE) + $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); + else + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value + } + } + } - /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Object user - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK - */ - function load_board($user) - { - global $conf, $langs; + // Delete invoice line + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE fk_facture = ' . $rowid; - $clause = " WHERE"; + dol_syslog(get_class($this) . "::delete", LOG_DEBUG); - $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; - $clause = " AND"; - } - $sql.= $clause." f.paye=0"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED; - if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id; + if ($this->db->query($sql) && $this->delete_linked_contact()) { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facture WHERE rowid = ' . $rowid; - $resql=$this->db->query($sql); - if ($resql) - { - $langs->load("bills"); - $now=dol_now(); + dol_syslog(get_class($this) . "::delete", LOG_DEBUG); - $response = new WorkboardResponse(); - $response->warning_delay=$conf->facture->client->warning_delay/60/60/24; - $response->label=$langs->trans("CustomerBillsUnpaid"); - $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills'; - $response->img=img_object('',"bill"); + $resql = $this->db->query($sql); + if ($resql) { + // On efface le repertoire de pdf provisoire + $ref = dol_sanitizeFileName($this->ref); + if ($conf->facture->dir_output && !empty($this->ref)) { + $dir = $conf->facture->dir_output . "/" . $ref; + $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; + if (file_exists($file)) { // We must delete all files before deleting directory + $ret = dol_delete_preview($this); - $generic_facture = new Facture($this->db); + if (!dol_delete_file($file, 0, 0, 0, $this)) { // For triggers + $this->error = $langs->trans("ErrorCanNotDeleteFile", $file); + $this->db->rollback(); + return 0; + } + } + if (file_exists($dir)) { + if (!dol_delete_dir_recursive($dir)) { // For remove dir and meta + $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); + $this->db->rollback(); + return 0; + } + } + } - while ($obj=$this->db->fetch_object($resql)) - { - $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin); - $generic_facture->statut = $obj->fk_statut; + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror() . " sql=" . $sql; + $this->db->rollback(); + return -6; + } + } else { + $this->error = $this->db->lasterror() . " sql=" . $sql; + $this->db->rollback(); + return -4; + } + } else { + $this->db->rollback(); + return -2; + } + } - $response->nbtodo++; + /** + * Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1 + * ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 + * + * @param User $user Objet utilisateur qui modifie + * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple) + * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) + * @return int <0 if KO, >0 if OK + */ + function set_paid($user, $close_code = '', $close_note = '') { + $error = 0; - if ($generic_facture->hasDelay()) { - $response->nbtodolate++; - } - } + if ($this->paye != 1) { + $this->db->begin(); - return $response; - } - else - { - dol_print_error($this->db); - $this->error=$this->db->error(); - return -1; - } - } + dol_syslog(get_class($this) . "::set_paid rowid=" . $this->id, LOG_DEBUG); + + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET'; + $sql .= ' fk_statut=' . self::STATUS_CLOSED; + if (!$close_code) + $sql .= ', paye=1'; + if ($close_code) + $sql .= ", close_code='" . $this->db->escape($close_code) . "'"; + if ($close_note) + $sql .= ", close_note='" . $this->db->escape($close_note) . "'"; + $sql .= ' WHERE rowid = ' . $this->id; + + $resql = $this->db->query($sql); + if ($resql) { + // Call trigger + $result = $this->call_trigger('BILL_PAYED', $user); + if ($result < 0) + $error++; + // End call triggers + } + else { + $error++; + $this->error = $this->db->lasterror(); + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } else { + return 0; + } + } + + /** + * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED + * Fonction utilisee quand un paiement prelevement est refuse, + * ou quand une facture annulee et reouverte. + * + * @param User $user Object user that change status + * @return int <0 if KO, >0 if OK + */ + function set_unpaid($user) { + $error = 0; + + $this->db->begin(); + + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; + $sql .= ' SET paye=0, fk_statut=' . self::STATUS_VALIDATED . ', close_code=null, close_note=null'; + $sql .= ' WHERE rowid = ' . $this->id; + + dol_syslog(get_class($this) . "::set_unpaid", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + // Call trigger + $result = $this->call_trigger('BILL_UNPAYED', $user); + if ($result < 0) + $error++; + // End call triggers + } + else { + $error++; + $this->error = $this->db->error(); + dol_print_error($this->db); + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL + * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because + * of no payment even if merchandises were sent). + * + * @param User $user Object user making change + * @param string $close_code Code of closing invoice (CLOSECODE_REPLACED, CLOSECODE_...) + * @param string $close_note Comment + * @return int <0 if KO, >0 if OK + */ + function set_canceled($user, $close_code = '', $close_note = '') { + + dol_syslog(get_class($this) . "::set_canceled rowid=" . $this->id, LOG_DEBUG); + + $this->db->begin(); + + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET'; + $sql .= ' fk_statut=' . self::STATUS_ABANDONED; + if ($close_code) + $sql .= ", close_code='" . $this->db->escape($close_code) . "'"; + if ($close_note) + $sql .= ", close_note='" . $this->db->escape($close_note) . "'"; + $sql .= ' WHERE rowid = ' . $this->id; + + $resql = $this->db->query($sql); + if ($resql) { + // On desaffecte de la facture les remises liees + // car elles n'ont pas ete utilisees vu que la facture est abandonnee. + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except'; + $sql .= ' SET fk_facture = NULL'; + $sql .= ' WHERE fk_facture = ' . $this->id; + + $resql = $this->db->query($sql); + if ($resql) { + // Call trigger + $result = $this->call_trigger('BILL_CANCEL', $user); + if ($result < 0) { + $this->db->rollback(); + return -1; + } + // End call triggers + + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->error() . " sql=" . $sql; + $this->db->rollback(); + return -1; + } + } else { + $this->error = $this->db->error() . " sql=" . $sql; + $this->db->rollback(); + return -2; + } + } + + /** + * Tag invoice as validated + call trigger BILL_VALIDATE + * Object must have lines loaded with fetch_lines + * + * @param User $user Object user that validate + * @param string $force_number Reference to force on invoice + * @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease) + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK + */ + function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) { + global $conf, $langs; + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $now = dol_now(); + + $error = 0; + dol_syslog(get_class($this) . '::validate user=' . $user->id . ', force_number=' . $force_number . ', idwarehouse=' . $idwarehouse); + + // Force to have object complete for checks + $this->fetch_thirdparty(); + $this->fetch_lines(); + + // Check parameters + if (!$this->brouillon) { + dol_syslog(get_class($this) . "::validate no draft status", LOG_WARNING); + return 0; + } + if (count($this->lines) <= 0) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); + return -1; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) { + $this->error = 'Permission denied'; + dol_syslog(get_class($this) . "::validate " . $this->error . ' MAIN_USE_ADVANCED_PERMS=' . $conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); + return -1; + } + + $this->db->begin(); + + // Check parameters + if ($this->type == self::TYPE_REPLACEMENT) { // si facture de remplacement + // Controle que facture source connue + if ($this->fk_facture_source <= 0) { + $this->error = $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceReplacement")); + $this->db->rollback(); + return -10; + } + + // Charge la facture source a remplacer + $facreplaced = new Facture($this->db); + $result = $facreplaced->fetch($this->fk_facture_source); + if ($result <= 0) { + $this->error = $langs->trans("ErrorBadInvoice"); + $this->db->rollback(); + return -11; + } + + // Controle que facture source non deja remplacee par une autre + $idreplacement = $facreplaced->getIdReplacingInvoice('validated'); + if ($idreplacement && $idreplacement != $this->id) { + $facreplacement = new Facture($this->db); + $facreplacement->fetch($idreplacement); + $this->error = $langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref); + $this->db->rollback(); + return -12; + } + + $result = $facreplaced->set_canceled($user, self::CLOSECODE_REPLACED, ''); + if ($result < 0) { + $this->error = $facreplaced->error; + $this->db->rollback(); + return -13; + } + } + + // Define new ref + if ($force_number) { + $num = $force_number; + } else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date + $this->date = dol_now(); + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); + } + $num = $this->getNextNumRef($this->thirdparty); + } else { + $num = $this->ref; + } + $this->newref = $num; + + if ($num) { + $this->update_price(1); + + // Validate + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; + $sql .= " SET facnumber='" . $num . "', fk_statut = " . self::STATUS_VALIDATED . ", fk_user_valid = " . ($user->id > 0 ? $user->id : "null") . ", date_valid = '" . $this->db->idate($now) . "'"; + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date + $sql .= ", datef='" . $this->db->idate($this->date) . "'"; + $sql .= ", date_lim_reglement='" . $this->db->idate($this->date_lim_reglement) . "'"; + } + $sql .= ' WHERE rowid = ' . $this->id; + + dol_syslog(get_class($this) . "::validate", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + dol_print_error($this->db); + $error++; + } + + // On verifie si la facture etait une provisoire + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) { + // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne + } + + if (!$error) { + // Define third party as a customer + $result = $this->thirdparty->set_as_client(); + + // Si active on decremente le produit principal et ses composants a la validation de facture + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) { + require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; + $langs->load("agenda"); + + // Loop on each line + $cpt = count($this->lines); + for ($i = 0; $i < $cpt; $i++) { + if ($this->lines[$i]->fk_product > 0) { + $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; + // We decrease stock for product + if ($this->type == self::TYPE_CREDIT_NOTE) + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num)); + else + $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); + if ($result < 0) { + $error++; + $this->error = $mouvP->error; + } + } + } + } + } + + // Trigger calls + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('BILL_VALIDATE', $user); + if ($result < 0) + $error++; + // End call triggers + } + + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // Rename of object directory ($this->ref = old ref, $num = new ref) + // to not lose the linked files + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->facture->dir_output . '/' . $oldref; + $dirdest = $conf->facture->dir_output . '/' . $newref; + if (file_exists($dirsource)) { + dol_syslog(get_class($this) . "::validate rename dir " . $dirsource . " into " . $dirdest); + + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->facture->dir_output . '/' . $newref, 'files', 1, '^' . preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^' . preg_quote($oldref, '/') . '/', $newref, $dirsource); + $dirsource = $fileentry['path'] . '/' . $dirsource; + $dirdest = $fileentry['path'] . '/' . $dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + if (!$error && !$this->is_last_in_cycle()) { + if (!$this->updatePriceNextInvoice($langs)) { + $error++; + } + } + + // Set new ref and define current statut + if (!$error) { + $this->ref = $num; + $this->facnumber = $num; + $this->statut = self::STATUS_VALIDATED; + $this->brouillon = 0; + $this->date_validation = $now; + $i = 0; + + if (!empty($conf->global->INVOICE_USE_SITUATION)) { + $final = true; + $nboflines = count($this->lines); + while (($i < $nboflines) && $final) { + $final = ($this->lines[$i]->situation_percent == 100); + $i++; + } + + if (empty($final)) + $this->situation_final = 0; + else + $this->situation_final = 1; + + $this->setFinal($user); + } + } + } + else { + $error++; + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Update price of next invoice + * + * @param Translate $langs Translate object + * @return bool false if KO, true if OK + */ + function updatePriceNextInvoice(&$langs) { + foreach ($this->tab_next_situation_invoice as $next_invoice) { + $is_last = $next_invoice->is_last_in_cycle(); + + if ($next_invoice->brouillon && $is_last != 1) { + $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); + return false; + } + + $next_invoice->brouillon = 1; + foreach ($next_invoice->lines as $line) { + $result = $next_invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + + if ($result < 0) { + $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); + return false; + } + } + + break; // Only the next invoice and not each next invoice + } + + return true; + } + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $idwarehouse Id warehouse to use for stock change. + * @return int <0 if KO, >0 if OK + */ + function set_draft($user, $idwarehouse = -1) { + global $conf, $langs; + + $error = 0; + + if ($this->statut == self::STATUS_DRAFT) { + dol_syslog(get_class($this) . "::set_draft already draft status", LOG_WARNING); + return 0; + } + + $this->db->begin(); + + $sql = "UPDATE " . MAIN_DB_PREFIX . "facture"; + $sql .= " SET fk_statut = " . self::STATUS_DRAFT; + $sql .= " WHERE rowid = " . $this->id; + + dol_syslog(get_class($this) . "::set_draft", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + // Si on decremente le produit principal et ses composants a la validation de facture, on réincrement + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { + require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; + $langs->load("agenda"); + + $num = count($this->lines); + for ($i = 0; $i < $num; $i++) { + if ($this->lines[$i]->fk_product > 0) { + $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; + // We decrease stock for product + if ($this->type == self::TYPE_CREDIT_NOTE) + $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); + else + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value + } + } + } + + if ($error == 0) { + $old_statut = $this->statut; + $this->brouillon = 1; + $this->statut = self::STATUS_DRAFT; + // Call trigger + $result = $this->call_trigger('BILL_UNVALIDATE', $user); + if ($result < 0) { + $error++; + $this->statut = $old_statut; + $this->brouillon = 0; + } + // End call triggers + } else { + $this->db->rollback(); + return -1; + } + + if ($error == 0) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** + * Add an invoice line into database (linked to product/service or not). + * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel + * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini + * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) + * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) + * + * @param string $desc Description of line + * @param double $pu_ht Unit price without tax (> 0 even for credit note) + * @param double $qty Quantity + * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') + * @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) + * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) + * @param int $fk_product Id of predefined product/service + * @param double $remise_percent Percent of discount on line + * @param int $date_start Date start of service + * @param int $date_end Date end of service + * @param int $ventil Code of dispatching into accountancy + * @param int $info_bits Bits de type de lignes + * @param int $fk_remise_except Id discount used + * @param string $price_base_type 'HT' or 'TTC' + * @param double $pu_ttc Unit price with tax (> 0 even for credit note) + * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. + * @param int $rang Position of line + * @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 + * @param int $fk_fournprice Supplier price id (to calculate margin) or '' + * @param int $pa_ht Buying price of line (to calculate margin) or '' + * @param string $label Label of the line (deprecated, do not use) + * @param array $array_options extrafields array + * @param int $situation_percent Situation advance percentage + * @param int $fk_prev_id Previous situation line id reference + * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param double $pu_ht_devise Unit price in currency + * @return int <0 if KO, Id of line if OK + */ + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0) { + // Deprecation warning + if ($label) { + dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + //var_dump(debug_backtrace(false));exit; + } + + global $mysoc, $conf, $langs; + + dol_syslog(get_class($this) . "::addline id=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG); + include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; + + // Clean parameters + if (empty($remise_percent)) + $remise_percent = 0; + if (empty($qty)) + $qty = 0; + if (empty($info_bits)) + $info_bits = 0; + if (empty($rang)) + $rang = 0; + if (empty($ventil)) + $ventil = 0; + if (empty($txtva)) + $txtva = 0; + if (empty($txlocaltax1)) + $txlocaltax1 = 0; + if (empty($txlocaltax2)) + $txlocaltax2 = 0; + if (empty($fk_parent_line) || $fk_parent_line < 0) + $fk_parent_line = 0; + if (empty($fk_prev_id)) + $fk_prev_id = 'null'; + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') + $situation_percent = 100; + + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + + // Clean vat code + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + $pu_ht = price2num($pu_ht); + $pu_ht_devise = price2num($pu_ht_devise); + $pu_ttc = price2num($pu_ttc); + $pa_ht = price2num($pa_ht); + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); + + if ($price_base_type == 'HT') { + $pu = $pu_ht; + } else { + $pu = $pu_ttc; + } + + // Check parameters + if ($type < 0) + return -1; + + if (!empty($this->brouillon)) { + $this->db->begin(); + + $product_type = $type; + if (!empty($fk_product)) { + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; + + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $this->db->rollback(); + return -3; + } + } + + // Calcul du total TTC et de la TVA pour la ligne a partir de + // qty, pu, remise_percent et txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); + + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; + + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; + + // Rank to use + $rangtouse = $rang; + if ($rangtouse == -1) { + $rangmax = $this->line_max($fk_parent_line); + $rangtouse = $rangmax + 1; + } + + // Insert line + $this->line = new FactureLigne($this->db); + + $this->line->context = $this->context; + + $this->line->fk_facture = $this->id; + $this->line->label = $label; // deprecated + $this->line->desc = $desc; + + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + + $this->line->vat_src_code = $vat_src_code; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0); + $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0); + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; + + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative + $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative + $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative + + $this->line->fk_product = $fk_product; + $this->line->product_type = $product_type; + $this->line->remise_percent = $remise_percent; + $this->line->date_start = $date_start; + $this->line->date_end = $date_end; + $this->line->ventil = $ventil; + $this->line->rang = $rangtouse; + $this->line->info_bits = $info_bits; + $this->line->fk_remise_except = $fk_remise_except; + + $this->line->special_code = $special_code; + $this->line->fk_parent_line = $fk_parent_line; + $this->line->origin = $origin; + $this->line->origin_id = $origin_id; + $this->line->situation_percent = $situation_percent; + $this->line->fk_prev_id = $fk_prev_id; + $this->line->fk_unit = $fk_unit; + + // infos marge + $this->line->fk_fournprice = $fk_fournprice; + $this->line->pa_ht = $pa_ht; + + // Multicurrency + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->multicurrency_subprice = $pu_ht_devise; + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; + } + + $result = $this->line->insert(); + if ($result > 0) { + // Reorder if child line + if (!empty($fk_parent_line)) + $this->line_order(true, 'DESC'); + + // Mise a jour informations denormalisees au niveau de la facture meme + $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. + + if ($result > 0) { + $this->db->commit(); + return $this->line->id; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } else { + $this->error = $this->line->error; + $this->db->rollback(); + return -2; + } + } else { + dol_syslog(get_class($this) . "::addline status of order must be Draft to allow use of ->addline()", LOG_ERR); + return -3; + } + } + + /** + * Update a detail line + * + * @param int $rowid Id of line to update + * @param string $desc Description of line + * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines) + * @param double $qty Quantity + * @param double $remise_percent Pourcentage de remise de la ligne + * @param int $date_start Date de debut de validite du service + * @param int $date_end Date de fin de validite du service + * @param double $txtva VAT Rate (Can be '8.5', '8.5 (ABC)') + * @param double $txlocaltax1 Local tax 1 rate + * @param double $txlocaltax2 Local tax 2 rate + * @param string $price_base_type HT or TTC + * @param int $info_bits Miscellaneous informations + * @param int $type Type of line (0=product, 1=service) + * @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 + * @param int $pa_ht Price (without tax) of product when it was bought + * @param string $label Label of the line (deprecated, do not use) + * @param int $special_code Special code (also used by externals modules!) + * @param array $array_options extrafields array + * @param int $situation_percent Situation advance percentage + * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param double $pu_ht_devise Unit price in currency + * @param int $notrigger disable line update trigger + * @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 = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { + global $conf, $user; + // Deprecation warning + if ($label) { + dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + } + + include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; + + global $mysoc, $langs; + + dol_syslog(get_class($this) . "::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); + + if ($this->brouillon) { + if (!$this->is_last_in_cycle() && empty($this->error)) { + if (!$this->checkProgressLine($rowid, $situation_percent)) { + if (!$this->error) + $this->error = $langs->trans('invoiceLineProgressError'); + return -3; + } + } + + $this->db->begin(); + + // 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; + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') + $situation_percent = 100; + + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + $pu = price2num($pu); + $pu_ht_devise = price2num($pu_ht_devise); + $pa_ht = price2num($pa_ht); + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); + + // Check parameters + if ($type < 0) + return -1; + + // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + + // Clean vat code + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); + + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; + + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; + + // Old properties: $price, $remise (deprecated) + $price = $pu; + $remise = 0; + if ($remise_percent > 0) { + $remise = round(($pu * $remise_percent / 100), 2); + $price = ($pu - $remise); + } + $price = price2num($price); + + //Fetch current line from the database and then clone the object and set it in $oldline property + $line = new FactureLigne($this->db); + $line->fetch($rowid); + + if (!empty($line->fk_product)) { + $product = new Product($this->db); + $result = $product->fetch($line->fk_product); + $product_type = $product->type; + + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $this->db->rollback(); + return -3; + } + } + + $staticline = clone $line; + + $line->oldline = $staticline; + $this->line = $line; + $this->line->context = $this->context; + + // Reorder if fk_parent_line change + if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { + $rangmax = $this->line_max($fk_parent_line); + $this->line->rang = $rangmax + 1; + } + + $this->line->rowid = $rowid; + $this->line->label = $label; + $this->line->desc = $desc; + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + + $this->line->vat_src_code = $vat_src_code; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = $txlocaltax1; + $this->line->localtax2_tx = $txlocaltax2; + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; + + $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->date_start = $date_start; + $this->line->date_end = $date_end; + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); + $this->line->total_localtax1 = $total_localtax1; + $this->line->total_localtax2 = $total_localtax2; + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); + $this->line->info_bits = $info_bits; + $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; + $this->line->situation_percent = $situation_percent; + $this->line->fk_unit = $fk_unit; + + $this->line->fk_fournprice = $fk_fournprice; + $this->line->pa_ht = $pa_ht; + + // Multicurrency + $this->line->multicurrency_subprice = $pu_ht_devise; + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; + } + + $result = $this->line->update($user, $notrigger); + if ($result > 0) { + // Reorder if child line + if (!empty($fk_parent_line)) + $this->line_order(true, 'DESC'); + + // Mise a jour info denormalisees au niveau facture + $this->update_price(1); + $this->db->commit(); + return $result; + } + else { + $this->error = $this->line->error; + $this->db->rollback(); + return -1; + } + } else { + $this->error = "Invoice statut makes operation forbidden"; + return -2; + } + } + + /** + * Check if the percent edited is lower of next invoice line + * + * @param int $idline id of line to check + * @param float $situation_percent progress percentage need to be test + * @return false if KO, true if OK + */ + function checkProgressLine($idline, $situation_percent) { + $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd + INNER JOIN ' . MAIN_DB_PREFIX . 'facture f ON (fd.fk_facture = f.rowid) + WHERE fd.fk_prev_id = ' . $idline . ' + AND f.fk_statut <> 0'; + + $result = $this->db->query($sql); + if (!$result) { + $this->error = $this->db->error(); + return false; + } + + $obj = $this->db->fetch_object($result); + + if ($obj === null) + return true; + else + return $situation_percent < $obj->situation_percent; + } + + /** + * Update invoice line with percentage + * + * @param FactureLigne $line Invoice line + * @param int $percent Percentage + * @return void + */ + function update_percent($line, $percent) { + global $mysoc, $user; + + include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'); + + // Cap percentages to 100 + if ($percent > 100) + $percent = 100; + $line->situation_percent = $percent; + $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $percent); + $line->total_ht = $tabprice[0]; + $line->total_tva = $tabprice[1]; + $line->total_ttc = $tabprice[2]; + $line->total_localtax1 = $tabprice[9]; + $line->total_localtax2 = $tabprice[10]; + $line->multicurrency_total_ht = $tabprice[16]; + $line->multicurrency_total_tva = $tabprice[17]; + $line->multicurrency_total_ttc = $tabprice[18]; + $line->update($user); + $this->update_price(1); + $this->db->commit(); + } + + /** + * Delete line in database + * + * @param int $rowid Id of line to delete + * @return int <0 if KO, >0 if OK + */ + function deleteline($rowid) { + global $user; + + dol_syslog(get_class($this) . "::deleteline rowid=" . $rowid, LOG_DEBUG); + + if (!$this->brouillon) { + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; + return -1; + } + + $this->db->begin(); + + // Libere remise liee a ligne de facture + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except'; + $sql .= ' SET fk_facture_line = NULL'; + $sql .= ' WHERE fk_facture_line = ' . $rowid; + + dol_syslog(get_class($this) . "::deleteline", LOG_DEBUG); + $result = $this->db->query($sql); + if (!$result) { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + + $line = new FactureLigne($this->db); + + $line->context = $this->context; + + // For triggers + $result = $line->fetch($rowid); + if (!($result > 0)) + dol_print_error($this->db, $line->error, $line->errors); + + if ($line->delete($user) > 0) { + $result = $this->update_price(1); + + if ($result > 0) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + return -1; + } + } else { + $this->db->rollback(); + $this->error = $line->error; + return -1; + } + } + + /** + * Set percent discount + * + * @param User $user User that set discount + * @param double $remise Discount + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if ko, >0 if ok + */ + function set_remise($user, $remise, $notrigger = 0) { + // Clean parameters + if (empty($remise)) + $remise = 0; + + if ($user->rights->facture->creer) { + $remise = price2num($remise); + + $error = 0; + + $this->db->begin(); + + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; + $sql .= ' SET remise_percent = ' . $remise; + $sql .= ' WHERE rowid = ' . $this->id; + $sql .= ' AND fk_statut = ' . self::STATUS_DRAFT; + + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = $this->db->error(); + $error++; + } + + if (!$notrigger && empty($error)) { + // Call trigger + $result = $this->call_trigger('BILL_MODIFY', $user); + if ($result < 0) + $error++; + // End call triggers + } + + if (!$error) { + $this->remise_percent = $remise; + $this->update_price(1); + + $this->db->commit(); + return 1; + } else { + foreach ($this->errors as $errmsg) { + dol_syslog(__METHOD__ . ' Error: ' . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } + } + } + + /** + * Set absolute discount + * + * @param User $user User that set discount + * @param double $remise Discount + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK + */ + function set_remise_absolue($user, $remise, $notrigger = 0) { + if (empty($remise)) + $remise = 0; + + if ($user->rights->facture->creer) { + $error = 0; + + $this->db->begin(); + + $remise = price2num($remise); + + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; + $sql .= ' SET remise_absolue = ' . $remise; + $sql .= ' WHERE rowid = ' . $this->id; + $sql .= ' AND fk_statut = ' . self::STATUS_DRAFT; + + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = $this->db->error(); + $error++; + } + + if (!$error) { + $this->oldcopy = clone $this; + $this->remise_absolue = $remise; + $this->update_price(1); + } + + if (!$notrigger && empty($error)) { + // Call trigger + $result = $this->call_trigger('BILL_MODIFY', $user); + if ($result < 0) + $error++; + // End call triggers + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + foreach ($this->errors as $errmsg) { + dol_syslog(__METHOD__ . ' Error: ' . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } + } + } + + /** + * Return next reference of customer invoice not already used (or last reference) + * according to numbering module defined into constant FACTURE_ADDON + * + * @param Societe $soc object company + * @param string $mode 'next' for next value or 'last' for last value + * @return string free ref or last ref + */ + function getNextNumRef($soc, $mode = 'next') { + global $conf, $langs; + $langs->load("bills"); + + // Clean parameters (if not defined or using deprecated value) + if (empty($conf->global->FACTURE_ADDON)) + $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + else if ($conf->global->FACTURE_ADDON == 'terre') + $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + else if ($conf->global->FACTURE_ADDON == 'mercure') + $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; + + if (!empty($conf->global->FACTURE_ADDON)) { + dol_syslog("Call getNextNumRef with FACTURE_ADDON = " . $conf->global->FACTURE_ADDON . ", thirdparty=" . $soc->nom . ", type=" . $soc->typent_code, LOG_DEBUG); + + $mybool = false; + + $file = $conf->global->FACTURE_ADDON . ".php"; + $classname = $conf->global->FACTURE_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir . "core/modules/facture/"); + + // Load file with numbering class (if found) + if (is_file($dir . $file) && is_readable($dir . $file)) { + $mybool |= include_once $dir . $file; + } + } + + // For compatibility + if (!$mybool) { + $file = $conf->global->FACTURE_ADDON . "/" . $conf->global->FACTURE_ADDON . ".modules.php"; + $classname = "mod_facture_" . $conf->global->FACTURE_ADDON; + $classname = preg_replace('/\-.*$/', '', $classname); + // Include file with class + foreach ($conf->file->dol_document_root as $dirroot) { + $dir = $dirroot . "/core/modules/facture/"; + + // Load file with numbering class (if found) + if (is_file($dir . $file) && is_readable($dir . $file)) { + $mybool |= include_once $dir . $file; + } + } + } + + if (!$mybool) { + dol_print_error('', "Failed to include file " . $file); + return ''; + } + + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc, $this, $mode); + + /** + * $numref can be empty in case we ask for the last value because if there is no invoice created with the + * set up mask. + */ + if ($mode != 'last' && !$numref) { + $this->error = $obj->error; + //dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); + return ""; + } + + return $numref; + } else { + $langs->load("errors"); + print $langs->trans("Error") . " " . $langs->trans("ErrorModuleSetupNotComplete"); + return ""; + } + } + + /** + * Load miscellaneous information for tab "Info" + * + * @param int $id Id of object to load + * @return void + */ + function info($id) { + $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; + $sql .= ' fk_user_author, fk_user_valid'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture as c'; + $sql .= ' WHERE c.rowid = ' . $id; + + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); // Should be in log table + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Return list of invoices (eventually filtered on a user) into an array + * + * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) + * @param int $draft 0=not draft, 1=draft + * @param User $excluser Objet user to exclude + * @param int $socid Id third pary + * @param int $limit For pagination + * @param int $offset For pagination + * @param string $sortfield Sort criteria + * @param string $sortorder Sort order + * @return int -1 if KO, array with result if OK + */ + function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') { + global $conf, $user; + + $ga = array(); + + $sql = "SELECT s.rowid, s.nom as name, s.client,"; + $sql .= " f.rowid as fid, f.facnumber as ref, f.datef as df"; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= ", sc.fk_soc, sc.fk_user"; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "facture as f"; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql .= " WHERE f.entity = " . $conf->entity; + $sql .= " AND f.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) { //restriction + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; + } + if ($socid) + $sql .= " AND s.rowid = " . $socid; + if ($draft) + $sql .= " AND f.fk_statut = " . self::STATUS_DRAFT; + if (is_object($excluser)) + $sql .= " AND f.fk_user_author <> " . $excluser->id; + $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); + + $result = $this->db->query($sql); + if ($result) { + $numc = $this->db->num_rows($result); + if ($numc) { + $i = 0; + while ($i < $numc) { + $obj = $this->db->fetch_object($result); + + if ($shortlist == 1) { + $ga[$obj->fid] = $obj->ref; + } else if ($shortlist == 2) { + $ga[$obj->fid] = $obj->ref . ' (' . $obj->name . ')'; + } else { + $ga[$i]['id'] = $obj->fid; + $ga[$i]['ref'] = $obj->ref; + $ga[$i]['name'] = $obj->name; + } + $i++; + } + } + return $ga; + } else { + dol_print_error($this->db); + return -1; + } + } + + /** + * Return list of invoices qualified to be replaced by another invoice. + * Invoices matching the following rules are returned: + * (Status validated or abandonned for a reason 'other') + not payed + no payment at all + not already replaced + * + * @param int $socid Id thirdparty + * @return array Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) + */ + function list_replacable_invoices($socid = 0) { + global $conf; + + $return = array(); + + $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut,"; + $sql .= " ff.rowid as rowidnext"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as ff ON f.rowid = ff.fk_facture_source"; + $sql .= " WHERE (f.fk_statut = " . self::STATUS_VALIDATED . " OR (f.fk_statut = " . self::STATUS_ABANDONED . " AND f.close_code = '" . self::CLOSECODE_ABANDONED . "'))"; + $sql .= " AND f.entity = " . $conf->entity; + $sql .= " AND f.paye = 0"; // Pas classee payee completement + $sql .= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait + $sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement + if ($socid > 0) + $sql .= " AND f.fk_soc = " . $socid; + $sql .= " ORDER BY f.facnumber"; + + dol_syslog(get_class($this) . "::list_replacable_invoices", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $return[$obj->rowid] = array('id' => $obj->rowid, + 'ref' => $obj->facnumber, + 'status' => $obj->fk_statut); + } + //print_r($return); + return $return; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Return list of invoices qualified to be corrected by a credit note. + * Invoices matching the following rules are returned: + * (validated + payment on process) or classified (payed completely or payed partiely) + not already replaced + not already a credit note + * + * @param int $socid Id thirdparty + * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) + */ + function list_qualified_avoir_invoices($socid = 0) { + global $conf; + + $return = array(); - /* gestion des contacts d'une facture */ + $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=" . self::TYPE_REPLACEMENT . ")"; + $sql .= " WHERE f.entity = " . $conf->entity; + $sql .= " AND f.fk_statut in (" . self::STATUS_VALIDATED . "," . self::STATUS_CLOSED . ")"; + // $sql.= " WHERE f.fk_statut >= 1"; + // $sql.= " AND (f.paye = 1"; // Classee payee completement + // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement + $sql .= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement + $sql .= " AND f.type != " . self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - /** - * Retourne id des contacts clients de facturation - * - * @return array Liste des id contacts facturation - */ - function getIdBillingContact() - { - return $this->getIdContact('external','BILLING'); - } + if ($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE) { + // Select the last situation invoice + $sqlSit = 'SELECT MAX(fs.rowid)'; + $sqlSit .= " FROM " . MAIN_DB_PREFIX . "facture as fs"; + $sqlSit .= " WHERE fs.entity = " . $conf->entity; + $sqlSit .= " AND fs.type = " . self::TYPE_SITUATION; + $sqlSit .= " AND fs.fk_statut in (" . self::STATUS_VALIDATED . "," . self::STATUS_CLOSED . ")"; + $sqlSit .= " GROUP BY fs.situation_cycle_ref"; + $sqlSit .= " ORDER BY fs.situation_counter"; + $sql .= " AND ( f.type != " . self::TYPE_SITUATION . " OR f.rowid IN (" . $sqlSit . ") )"; // Type non 5 si facture non avoir + } else { + $sql .= " AND f.type != " . self::TYPE_SITUATION; // Type non 5 si facture non avoir + } - /** - * Retourne id des contacts clients de livraison - * - * @return array Liste des id contacts livraison - */ - function getIdShippingContact() - { - return $this->getIdContact('external','SHIPPING'); - } + if ($socid > 0) + $sql .= " AND f.fk_soc = " . $socid; + $sql .= " ORDER BY f.facnumber"; + dol_syslog(get_class($this) . "::list_qualified_avoir_invoices", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $qualified = 0; + if ($obj->fk_statut == self::STATUS_VALIDATED) + $qualified = 1; + if ($obj->fk_statut == self::STATUS_CLOSED) + $qualified = 1; + if ($qualified) { + //$ref=$obj->facnumber; + $paymentornot = ($obj->fk_paiement ? 1 : 0); + $return[$obj->rowid] = array('ref' => $obj->facnumber, 'status' => $obj->fk_statut, 'type' => $obj->type, 'paye' => $obj->paye, 'paymentornot' => $paymentornot); + } + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines - * @return void - */ - function initAsSpecimen($option='') - { - global $langs; + return $return; + } else { + $this->error = $this->db->error(); + return -1; + } + } - $now=dol_now(); - $arraynow=dol_getdate($now); - $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); + /** + * Create a withdrawal request for a standing order. + * Use the remain to pay excluding all existing open direct debit requests. + * + * @param User $fuser User asking the direct debit transfer + * @param float $amount Amount we request direct debit for + * @return int <0 if KO, >0 if OK + */ + function demande_prelevement($fuser, $amount = 0) { + + $error = 0; + + dol_syslog(get_class($this) . "::demande_prelevement", LOG_DEBUG); + + if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) { + require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + $bac = new CompanyBankAccount($this->db); + $bac->fetch(0, $this->socid); + + $sql = 'SELECT count(*)'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'prelevement_facture_demande'; + $sql .= ' WHERE fk_facture = ' . $this->id; + $sql .= ' AND traite = 0'; + + dol_syslog(get_class($this) . "::demande_prelevement", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $row = $this->db->fetch_row($resql); + if ($row[0] == 0) { + $now = dol_now(); + + $totalpaye = $this->getSommePaiement(); + $totalcreditnotes = $this->getSumCreditNotesUsed(); + $totaldeposits = $this->getSumDepositsUsed(); + //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; + // We can also use bcadd to avoid pb with floating points + // For example print 239.2 - 229.3 - 9.9; does not return 0. + //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); + if (empty($amount)) + $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + + if (is_numeric($amount) && $amount != 0) { + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'prelevement_facture_demande'; + $sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)'; + $sql .= ' VALUES (' . $this->id; + $sql .= ",'" . price2num($amount) . "'"; + $sql .= ",'" . $this->db->idate($now) . "'"; + $sql .= "," . $fuser->id; + $sql .= ",'" . $bac->code_banque . "'"; + $sql .= ",'" . $bac->code_guichet . "'"; + $sql .= ",'" . $bac->number . "'"; + $sql .= ",'" . $bac->cle_rib . "')"; + + dol_syslog(get_class($this) . "::demande_prelevement", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this) . '::demandeprelevement Erreur'); + $error++; + } + } else { + $this->error = 'WithdrawRequestErrorNilAmount'; + dol_syslog(get_class($this) . '::demandeprelevement WithdrawRequestErrorNilAmount'); + $error++; + } + + if (!$error) { + // Force payment mode of invoice to withdraw + $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); + if ($payment_mode_id > 0) { + $result = $this->setPaymentMethods($payment_mode_id); + } + } + + if ($error) + return -1; + return 1; + } + else { + $this->error = "A request already exists"; + dol_syslog(get_class($this) . '::demandeprelevement Impossible de creer une demande, demande deja en cours'); + return 0; + } + } else { + $this->error = $this->db->error(); + dol_syslog(get_class($this) . '::demandeprelevement Erreur -2'); + return -2; + } + } else { + $this->error = "Status of invoice does not allow this"; + dol_syslog(get_class($this) . "::demandeprelevement " . $this->error . " $this->statut, $this->paye, $this->mode_reglement_id"); + return -3; + } + } + + /** + * Supprime une demande de prelevement + * + * @param User $fuser User making delete + * @param int $did id de la demande a supprimer + * @return int <0 if OK, >0 if KO + */ + function demande_prelevement_delete($fuser, $did) { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'prelevement_facture_demande'; + $sql .= ' WHERE rowid = ' . $did; + $sql .= ' AND traite = 0'; + if ($this->db->query($sql)) { + return 0; + } else { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this) . '::demande_prelevement_delete Error ' . $this->error); + return -1; + } + } + + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Object user + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + */ + function load_board($user) { + global $conf, $langs; + + $clause = " WHERE"; + + $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; + if (!$user->rights->societe->client->voir && !$user->societe_id) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = " . $user->id; + $clause = " AND"; + } + $sql .= $clause . " f.paye=0"; + $sql .= " AND f.entity = " . $conf->entity; + $sql .= " AND f.fk_statut = " . self::STATUS_VALIDATED; + if ($user->societe_id) + $sql .= " AND f.fk_soc = " . $user->societe_id; + + $resql = $this->db->query($sql); + if ($resql) { + $langs->load("bills"); + $now = dol_now(); + + $response = new WorkboardResponse(); + $response->warning_delay = $conf->facture->client->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("CustomerBillsUnpaid"); + $response->url = DOL_URL_ROOT . '/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills'; + $response->img = img_object('', "bill"); + + $generic_facture = new Facture($this->db); + + while ($obj = $this->db->fetch_object($resql)) { + $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin); + $generic_facture->statut = $obj->fk_statut; + + $response->nbtodo++; + + if ($generic_facture->hasDelay()) { + $response->nbtodolate++; + } + } + + return $response; + } else { + dol_print_error($this->db); + $this->error = $this->db->error(); + return -1; + } + } + + /* gestion des contacts d'une facture */ + + /** + * Retourne id des contacts clients de facturation + * + * @return array Liste des id contacts facturation + */ + function getIdBillingContact() { + return $this->getIdContact('external', 'BILLING'); + } + + /** + * Retourne id des contacts clients de livraison + * + * @return array Liste des id contacts livraison + */ + function getIdShippingContact() { + return $this->getIdContact('external', 'SHIPPING'); + } + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines + * @return void + */ + function initAsSpecimen($option = '') { + global $langs; + + $now = dol_now(); + $arraynow = dol_getdate($now); + $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); // Load array of products prodids - $num_prods = 0; - $prodids = array(); - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; - $resql = $this->db->query($sql); - if ($resql) - { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) - { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } - //Avoid php warning Warning: mt_rand(): max(0) is smaller than min(1) when no product exists - if (empty($num_prods)) { - $num_prods=1; - } + $num_prods = 0; + $prodids = array(); + $sql = "SELECT rowid"; + $sql .= " FROM " . MAIN_DB_PREFIX . "product"; + $sql .= " WHERE entity IN (" . getEntity('product') . ")"; + $resql = $this->db->query($sql); + if ($resql) { + $num_prods = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_prods) { + $i++; + $row = $this->db->fetch_row($resql); + $prodids[$i] = $row[0]; + } + } + //Avoid php warning Warning: mt_rand(): max(0) is smaller than min(1) when no product exists + if (empty($num_prods)) { + $num_prods = 1; + } - // Initialize parameters - $this->id=0; - $this->entity = 1; - $this->ref = 'SPECIMEN'; - $this->specimen=1; - $this->socid = 1; - $this->date = $nownotime; - $this->date_lim_reglement = $nownotime + 3600 * 24 *30; - $this->cond_reglement_id = 1; - $this->cond_reglement_code = 'RECEP'; - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); - $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR - $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; - $this->note='This is a comment (private)'; - $this->fk_incoterms=0; - $this->location_incoterms=''; + // Initialize parameters + $this->id = 0; + $this->entity = 1; + $this->ref = 'SPECIMEN'; + $this->specimen = 1; + $this->socid = 1; + $this->date = $nownotime; + $this->date_lim_reglement = $nownotime + 3600 * 24 * 30; + $this->cond_reglement_id = 1; + $this->cond_reglement_code = 'RECEP'; + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); + $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR + $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + $this->note = 'This is a comment (private)'; + $this->fk_incoterms = 0; + $this->location_incoterms = ''; - if (empty($option) || $option != 'nolines') - { - // Lines - $nbp = 5; - $xnbp = 0; - while ($xnbp < $nbp) - { - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=0; - if ($xnbp == 1) // Qty is negative (product line) - { - $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->qty=-1; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; - $line->multicurrency_total_ht=-200; - $line->multicurrency_total_ttc=-239.2; - $line->multicurrency_total_tva=-39.2; - } - else if ($xnbp == 2) // UP is negative (free line) - { - $line->subprice=-100; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; - $line->remise_percent=0; - $line->multicurrency_total_ht=-200; - $line->multicurrency_total_ttc=-239.2; - $line->multicurrency_total_tva=-39.2; - } - else if ($xnbp == 3) // Discount is 50% (product line) - { - $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=50; - $line->total_ttc=59.8; - $line->total_tva=9.8; - $line->multicurrency_total_ht=100; - $line->multicurrency_total_ttc=119.6; - $line->multicurrency_total_tva=19.6; - $line->remise_percent=50; - } - else // (product line) - { - $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=100; - $line->total_ttc=119.6; - $line->total_tva=19.6; - $line->multicurrency_total_ht=200; - $line->multicurrency_total_ttc=239.2; - $line->multicurrency_total_tva=39.2; - $line->remise_percent=0; - } + if (empty($option) || $option != 'nolines') { + // Lines + $nbp = 5; + $xnbp = 0; + while ($xnbp < $nbp) { + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description") . " " . $xnbp; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 0; + if ($xnbp == 1) { // Qty is negative (product line) + $prodid = mt_rand(1, $num_prods); + $line->fk_product = $prodids[$prodid]; + $line->qty = -1; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; + $line->multicurrency_total_ht = -200; + $line->multicurrency_total_ttc = -239.2; + $line->multicurrency_total_tva = -39.2; + } else if ($xnbp == 2) { // UP is negative (free line) + $line->subprice = -100; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; + $line->remise_percent = 0; + $line->multicurrency_total_ht = -200; + $line->multicurrency_total_ttc = -239.2; + $line->multicurrency_total_tva = -39.2; + } else if ($xnbp == 3) { // Discount is 50% (product line) + $prodid = mt_rand(1, $num_prods); + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 50; + $line->total_ttc = 59.8; + $line->total_tva = 9.8; + $line->multicurrency_total_ht = 100; + $line->multicurrency_total_ttc = 119.6; + $line->multicurrency_total_tva = 19.6; + $line->remise_percent = 50; + } else { // (product line) + $prodid = mt_rand(1, $num_prods); + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 100; + $line->total_ttc = 119.6; + $line->total_tva = 19.6; + $line->multicurrency_total_ht = 200; + $line->multicurrency_total_ttc = 239.2; + $line->multicurrency_total_tva = 39.2; + $line->remise_percent = 0; + } - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; - $this->total_ht += $line->total_ht; - $this->total_tva += $line->total_tva; - $this->total_ttc += $line->total_ttc; + $this->total_ht += $line->total_ht; + $this->total_tva += $line->total_tva; + $this->total_ttc += $line->total_ttc; - $this->multicurrency_total_ht += $line->multicurrency_total_ht; - $this->multicurrency_total_tva += $line->multicurrency_total_tva; - $this->multicurrency_total_ttc += $line->multicurrency_total_ttc; + $this->multicurrency_total_ht += $line->multicurrency_total_ht; + $this->multicurrency_total_tva += $line->multicurrency_total_tva; + $this->multicurrency_total_ttc += $line->multicurrency_total_ttc; - $xnbp++; - } - $this->revenuestamp = 0; + $xnbp++; + } + $this->revenuestamp = 0; - // Add a line "offered" - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." (offered line)"; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=100; - $line->total_ht=0; - $line->total_ttc=0; // 90 * 1.196 - $line->total_tva=0; - $line->multicurrency_total_ht=0; - $line->multicurrency_total_ttc=0; - $line->multicurrency_total_tva=0; - $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + // Add a line "offered" + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description") . " (offered line)"; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 100; + $line->total_ht = 0; + $line->total_ttc = 0; // 90 * 1.196 + $line->total_tva = 0; + $line->multicurrency_total_ht = 0; + $line->multicurrency_total_ttc = 0; + $line->multicurrency_total_tva = 0; + $prodid = mt_rand(1, $num_prods); + $line->fk_product = $prodids[$prodid]; - $this->lines[$xnbp]=$line; - $xnbp++; - } - } + $this->lines[$xnbp] = $line; + $xnbp++; + } + } - /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @return int <0 if KO, >0 if OK - */ - function load_state_board() - { - global $conf, $user; + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @return int <0 if KO, >0 if OK + */ + function load_state_board() { + global $conf, $user; - $this->nb=array(); + $this->nb = array(); - $clause = "WHERE"; + $clause = "WHERE"; - $sql = "SELECT count(f.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; - $clause = "AND"; - } - $sql.= " ".$clause." f.entity = ".$conf->entity; + $sql = "SELECT count(f.rowid) as nb"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON f.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = " . $user->id; + $clause = "AND"; + } + $sql .= " " . $clause . " f.entity = " . $conf->entity; - $resql=$this->db->query($sql); - if ($resql) - { - while ($obj=$this->db->fetch_object($resql)) - { - $this->nb["invoices"]=$obj->nb; - } + $resql = $this->db->query($sql); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $this->nb["invoices"] = $obj->nb; + } $this->db->free($resql); - return 1; - } - else - { - dol_print_error($this->db); - $this->error=$this->db->error(); - return -1; - } - } + return 1; + } else { + dol_print_error($this->db); + $this->error = $this->db->error(); + return -1; + } + } - /** - * Create an array of invoice lines - * - * @return int >0 if OK, <0 if KO - */ - function getLinesArray() - { - return $this->fetch_lines(); - } + /** + * Create an array of invoice lines + * + * @return int >0 if OK, <0 if KO + */ + function getLinesArray() { + return $this->fetch_lines(); + } - /** - * Create a document onto disk according to template module. - * - * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example. - * @param Translate $outputlangs objet lang a utiliser pour traduction - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information - * @return int <0 if KO, >0 if OK - */ - public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) - { - global $conf,$langs; + /** + * Create a document onto disk according to template module. + * + * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example. + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int <0 if KO, >0 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { + global $conf, $langs; - $langs->load("bills"); + $langs->load("bills"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { - $modele = 'crabe'; + $modele = 'crabe'; - if ($this->modelpdf) { - $modele = $this->modelpdf; - } elseif (! empty($conf->global->FACTURE_ADDON_PDF)) { - $modele = $conf->global->FACTURE_ADDON_PDF; - } - } + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (!empty($conf->global->FACTURE_ADDON_PDF)) { + $modele = $conf->global->FACTURE_ADDON_PDF; + } + } - $modelpath = "core/modules/facture/doc/"; + $modelpath = "core/modules/facture/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - } + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } - /** - * Gets the smallest reference available for a new cycle - * - * @return int >= 1 if OK, -1 if error - */ - function newCycle() - { - $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql.= " WHERE f.entity in (".getEntity('facture', 0).")"; - $resql = $this->db->query($sql); - if ($resql) { - if ($resql->num_rows > 0) - { - $res = $this->db->fetch_array($resql); - $ref = $res['max(situation_cycle_ref)']; - $ref++; - } else { - $ref = 1; - } - $this->db->free($resql); - return $ref; - } else { - $this->error = $this->db->lasterror(); - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); - return -1; - } - } + /** + * Gets the smallest reference available for a new cycle + * + * @return int >= 1 if OK, -1 if error + */ + function newCycle() { + $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; + $sql .= " WHERE f.entity in (" . getEntity('facture', 0) . ")"; + $resql = $this->db->query($sql); + if ($resql) { + if ($resql->num_rows > 0) { + $res = $this->db->fetch_array($resql); + $ref = $res['max(situation_cycle_ref)']; + $ref++; + } else { + $ref = 1; + } + $this->db->free($resql); + return $ref; + } else { + $this->error = $this->db->lasterror(); + dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + return -1; + } + } - /** - * Checks if the invoice is the first of a cycle - * - * @return boolean - */ - function is_first() - { - return ($this->situation_counter == 1); - } + /** + * Checks if the invoice is the first of a cycle + * + * @return boolean + */ + function is_first() { + return ($this->situation_counter == 1); + } - /** - * Returns an array containing the previous situations as Facture objects - * - * @return mixed -1 if error, array of previous situations - */ - function get_prev_sits() - { - global $conf; + /** + * Returns an array containing the previous situations as Facture objects + * + * @return mixed -1 if error, array of previous situations + */ + function get_prev_sits() { + global $conf; - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; - $sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref; - $sql .= ' and situation_counter < ' . $this->situation_counter; - $sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity); - $resql = $this->db->query($sql); - $res = array(); - if ($resql && $resql->num_rows > 0) { - while ($row = $this->db->fetch_object($resql)) { - $id = $row->rowid; - $situation = new Facture($this->db); - $situation->fetch($id); - $res[] = $situation; - } - } else { - $this->error = $this->db->error(); - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); - return -1; - } + $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; + $sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref; + $sql .= ' and situation_counter < ' . $this->situation_counter; + $sql .= ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); + $resql = $this->db->query($sql); + $res = array(); + if ($resql && $resql->num_rows > 0) { + while ($row = $this->db->fetch_object($resql)) { + $id = $row->rowid; + $situation = new Facture($this->db); + $situation->fetch($id); + $res[] = $situation; + } + } else { + $this->error = $this->db->error(); + dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + return -1; + } - return $res; - } + return $res; + } - /** - * Sets the invoice as a final situation - * - * @param User $user Object user - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >0 if OK - */ - function setFinal(User $user, $notrigger=0) - { - $error=0; + /** + * Sets the invoice as a final situation + * + * @param User $user Object user + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK + */ + function setFinal(User $user, $notrigger = 0) { + $error = 0; - $this->db->begin(); + $this->db->begin(); - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; - dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); - if (!$resql) - { - $this->errors[]=$this->db->error(); - $error++; - } + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = $this->db->error(); + $error++; + } - if (! $notrigger && empty($error)) - { - // Call trigger - $result=$this->call_trigger('BILL_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers - } + if (!$notrigger && empty($error)) { + // Call trigger + $result = $this->call_trigger('BILL_MODIFY', $user); + if ($result < 0) + $error++; + // End call triggers + } - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - foreach($this->errors as $errmsg) - { - dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - } + if (!$error) { + $this->db->commit(); + return 1; + } else { + foreach ($this->errors as $errmsg) { + dol_syslog(__METHOD__ . ' Error: ' . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } + } - /** - * Checks if the invoice is the last in its cycle - * - * @return bool Last of the cycle status - * - */ - function is_last_in_cycle() - { - global $conf; + /** + * Checks if the invoice is the last in its cycle + * + * @return bool Last of the cycle status + * + */ + function is_last_in_cycle() { + global $conf; - if (!empty($this->situation_cycle_ref)) { - // No point in testing anything if we're not inside a cycle - $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref . ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); - $resql = $this->db->query($sql); + if (!empty($this->situation_cycle_ref)) { + // No point in testing anything if we're not inside a cycle + $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref . ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); + $resql = $this->db->query($sql); - if ($resql && $resql->num_rows > 0) { - $res = $this->db->fetch_array($resql); - $last = $res['max(situation_counter)']; - return ($last == $this->situation_counter); - } else { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); - return false; - } - } else { - return true; - } - } + if ($resql && $resql->num_rows > 0) { + $res = $this->db->fetch_array($resql); + $last = $res['max(situation_counter)']; + return ($last == $this->situation_counter); + } else { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + return false; + } + } else { + return true; + } + } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'facture' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) { + $tables = array( + 'facture' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + } - /** - * Is the customer invoice delayed? - * - * @return bool - */ - public function hasDelay() - { - global $conf; + /** + * Is the customer invoice delayed? + * + * @return bool + */ + public function hasDelay() { + global $conf; - $now = dol_now(); + $now = dol_now(); - // Paid invoices have status STATUS_CLOSED - if ($this->statut != Facture::STATUS_VALIDATED) return false; + // Paid invoices have status STATUS_CLOSED + if ($this->statut != Facture::STATUS_VALIDATED) + return false; + + return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); + } - return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); - } } /** - * Class to manage invoice lines. + * Class to manage invoice lines. * Saved into database table llx_facturedet */ -class FactureLigne extends CommonInvoiceLine -{ - public $element='facturedet'; - public $table_element='facturedet'; +class FactureLigne extends CommonInvoiceLine { - var $oldline; + public $element = 'facturedet'; + public $table_element = 'facturedet'; + var $oldline; + //! From llx_facturedet + //! Id facture + var $fk_facture; + //! Id parent line + var $fk_parent_line; - //! From llx_facturedet - //! Id facture - var $fk_facture; - //! Id parent line - var $fk_parent_line; - /** - * @deprecated - */ - var $label; - //! Description ligne - var $desc; + /** + * @deprecated + */ + var $label; + //! Description ligne + var $desc; + var $localtax1_type; // Local tax 1 type + var $localtax2_type; // Local tax 2 type + var $fk_remise_except; // Link to line into llx_remise_except + var $rang = 0; + var $fk_fournprice; + var $pa_ht; + var $marge_tx; + var $marque_tx; + var $special_code; // Liste d'options non cumulabels: + // 1: frais de port + // 2: ecotaxe + // 3: ?? + var $origin; + var $origin_id; + var $fk_code_ventilation = 0; + var $date_start; + var $date_end; + // Ne plus utiliser + //var $price; // P.U. HT apres remise % de ligne (exemple 80) + //var $remise; // Montant calcule de la remise % sur PU HT (exemple 20) + // From llx_product + /** + * @deprecated + * @see product_ref + */ + var $ref; // Product ref (deprecated) + var $product_ref; // Product ref + /** + * @deprecated + * @see product_label + */ + var $libelle; // Product label (deprecated) + var $product_label; // Product label + var $product_desc; // Description produit + var $skip_update_total; // Skip update price total for special lines - var $localtax1_type; // Local tax 1 type - var $localtax2_type; // Local tax 2 type - var $fk_remise_except; // Link to line into llx_remise_except - var $rang = 0; + /** + * @var int Situation advance percentage + */ + public $situation_percent; - var $fk_fournprice; - var $pa_ht; - var $marge_tx; - var $marque_tx; + /** + * @var int Previous situation line id reference + */ + public $fk_prev_id; + // Multicurrency + var $fk_multicurrency; + var $multicurrency_code; + var $multicurrency_subprice; + var $multicurrency_total_ht; + var $multicurrency_total_tva; + var $multicurrency_total_ttc; - var $special_code; // Liste d'options non cumulabels: - // 1: frais de port - // 2: ecotaxe - // 3: ?? + /** + * Load invoice line from database + * + * @param int $rowid id of invoice line to get + * @return int <0 if KO, >0 if OK + */ + function fetch($rowid) { + $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; + $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; + $sql .= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; + $sql .= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; + $sql .= ' fd.fk_code_ventilation,'; + $sql .= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; + $sql .= ' fd.situation_percent, fd.fk_prev_id,'; + $sql .= ' fd.multicurrency_subprice,'; + $sql .= ' fd.multicurrency_total_ht,'; + $sql .= ' fd.multicurrency_total_tva,'; + $sql .= ' fd.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facturedet as fd'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p ON fd.fk_product = p.rowid'; + $sql .= ' WHERE fd.rowid = ' . $rowid; - var $origin; - var $origin_id; + $result = $this->db->query($sql); + if ($result) { + $objp = $this->db->fetch_object($result); - var $fk_code_ventilation = 0; + $this->rowid = $objp->rowid; + $this->fk_facture = $objp->fk_facture; + $this->fk_parent_line = $objp->fk_parent_line; + $this->label = $objp->custom_label; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; + $this->tva_tx = $objp->tva_tx; + $this->localtax1_tx = $objp->localtax1_tx; + $this->localtax2_tx = $objp->localtax2_tx; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->product_type = $objp->product_type; + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); + $this->info_bits = $objp->info_bits; + $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; + $this->special_code = $objp->special_code; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_localtax1 = $objp->total_localtax1; + $this->total_localtax2 = $objp->total_localtax2; + $this->total_ttc = $objp->total_ttc; + $this->fk_code_ventilation = $objp->fk_code_ventilation; + $this->rang = $objp->rang; + $this->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); + $this->pa_ht = $marginInfos[0]; + $this->marge_tx = $marginInfos[1]; + $this->marque_tx = $marginInfos[2]; - var $date_start; - var $date_end; + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_libelle; // deprecated + $this->product_label = $objp->product_libelle; + $this->product_desc = $objp->product_desc; + $this->fk_unit = $objp->fk_unit; + $this->fk_user_modif = $objp->fk_user_modif; + $this->fk_user_author = $objp->fk_user_author; - // Ne plus utiliser - //var $price; // P.U. HT apres remise % de ligne (exemple 80) - //var $remise; // Montant calcule de la remise % sur PU HT (exemple 20) + $this->situation_percent = $objp->situation_percent; + $this->fk_prev_id = $objp->fk_prev_id; - // From llx_product - /** - * @deprecated - * @see product_ref - */ - var $ref; // Product ref (deprecated) - var $product_ref; // Product ref - /** - * @deprecated - * @see product_label - */ - var $libelle; // Product label (deprecated) - var $product_label; // Product label - var $product_desc; // Description produit + $this->multicurrency_subprice = $objp->multicurrency_subprice; + $this->multicurrency_total_ht = $objp->multicurrency_total_ht; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - var $skip_update_total; // Skip update price total for special lines + $this->db->free($result); - /** - * @var int Situation advance percentage - */ - public $situation_percent; + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * @var int Previous situation line id reference - */ - public $fk_prev_id; + /** + * Insert line into database + * + * @param int $notrigger 1 no triggers + * @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another + * @return int <0 if KO, >0 if OK + */ + function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) { + global $langs, $user, $conf; - // Multicurrency - var $fk_multicurrency; - var $multicurrency_code; - var $multicurrency_subprice; - var $multicurrency_total_ht; - var $multicurrency_total_tva; - var $multicurrency_total_ttc; - - /** - * Load invoice line from database - * - * @param int $rowid id of invoice line to get - * @return int <0 if KO, >0 if OK - */ - function fetch($rowid) - { - $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; - $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; - $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; - $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; - $sql.= ' fd.fk_code_ventilation,'; - $sql.= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; - $sql.= ' fd.situation_percent, fd.fk_prev_id,'; - $sql.= ' fd.multicurrency_subprice,'; - $sql.= ' fd.multicurrency_total_ht,'; - $sql.= ' fd.multicurrency_total_tva,'; - $sql.= ' fd.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; - $sql.= ' WHERE fd.rowid = '.$rowid; - - $result = $this->db->query($sql); - if ($result) - { - $objp = $this->db->fetch_object($result); - - $this->rowid = $objp->rowid; - $this->fk_facture = $objp->fk_facture; - $this->fk_parent_line = $objp->fk_parent_line; - $this->label = $objp->custom_label; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->subprice = $objp->subprice; - $this->vat_src_code = $objp->vat_src_code; - $this->tva_tx = $objp->tva_tx; - $this->localtax1_tx = $objp->localtax1_tx; - $this->localtax2_tx = $objp->localtax2_tx; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->product_type = $objp->product_type; - $this->date_start = $this->db->jdate($objp->date_start); - $this->date_end = $this->db->jdate($objp->date_end); - $this->info_bits = $objp->info_bits; - $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; - $this->special_code = $objp->special_code; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_localtax1 = $objp->total_localtax1; - $this->total_localtax2 = $objp->total_localtax2; - $this->total_ttc = $objp->total_ttc; - $this->fk_code_ventilation = $objp->fk_code_ventilation; - $this->rang = $objp->rang; - $this->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); - $this->pa_ht = $marginInfos[0]; - $this->marge_tx = $marginInfos[1]; - $this->marque_tx = $marginInfos[2]; - - $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_libelle; // deprecated - $this->product_label = $objp->product_libelle; - $this->product_desc = $objp->product_desc; - $this->fk_unit = $objp->fk_unit; - $this->fk_user_modif = $objp->fk_user_modif; - $this->fk_user_author = $objp->fk_user_author; - - $this->situation_percent = $objp->situation_percent; - $this->fk_prev_id = $objp->fk_prev_id; - - $this->multicurrency_subprice = $objp->multicurrency_subprice; - $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva= $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc= $objp->multicurrency_total_ttc; - - $this->db->free($result); - - return 1; - } - else - { - $this->error = $this->db->lasterror(); - return -1; - } - } - - /** - * Insert line into database - * - * @param int $notrigger 1 no triggers - * @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another - * @return int <0 if KO, >0 if OK - */ - function insert($notrigger=0, $noerrorifdiscountalreadylinked=0) - { - global $langs,$user,$conf; - - $error=0; + $error = 0; $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. - dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG); + dol_syslog(get_class($this) . "::insert rang=" . $this->rang, LOG_DEBUG); - // Clean parameters - $this->desc=trim($this->desc); - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->rang)) $this->rang=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->subprice)) $this->subprice=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - if (empty($this->fk_prev_id)) $this->fk_prev_id = 0; - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; + // Clean parameters + $this->desc = trim($this->desc); + if (empty($this->tva_tx)) + $this->tva_tx = 0; + if (empty($this->localtax1_tx)) + $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) + $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) + $this->localtax1_type = 0; + if (empty($this->localtax2_type)) + $this->localtax2_type = 0; + if (empty($this->total_localtax1)) + $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) + $this->total_localtax2 = 0; + if (empty($this->rang)) + $this->rang = 0; + if (empty($this->remise_percent)) + $this->remise_percent = 0; + if (empty($this->info_bits)) + $this->info_bits = 0; + if (empty($this->subprice)) + $this->subprice = 0; + if (empty($this->special_code)) + $this->special_code = 0; + if (empty($this->fk_parent_line)) + $this->fk_parent_line = 0; + if (empty($this->fk_prev_id)) + $this->fk_prev_id = 0; + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') + $this->situation_percent = 100; - if (empty($this->pa_ht)) $this->pa_ht=0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; + if (empty($this->pa_ht)) + $this->pa_ht = 0; + if (empty($this->multicurrency_subprice)) + $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) + $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) + $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) + $this->multicurrency_total_ttc = 0; - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0 && $pa_ht_isemptystring) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { - return $result; - } - else - { - $this->pa_ht = $result; - } - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0 && $pa_ht_isemptystring) { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { + return $result; + } else { + $this->pa_ht = $result; + } + } - // Check parameters - if ($this->product_type < 0) - { - $this->error='ErrorProductTypeMustBe0orMore'; - return -1; - } - if (! empty($this->fk_product)) - { - // Check product exists - $result=Product::isExistingObject('product', $this->fk_product); - if ($result <= 0) - { - $this->error='ErrorProductIdDoesNotExists'; - return -1; - } - } + // Check parameters + if ($this->product_type < 0) { + $this->error = 'ErrorProductTypeMustBe0orMore'; + return -1; + } + if (!empty($this->fk_product)) { + // Check product exists + $result = Product::isExistingObject('product', $this->fk_product); + if ($result <= 0) { + $this->error = 'ErrorProductIdDoesNotExists'; + return -1; + } + } - $this->db->begin(); + $this->db->begin(); - // Insertion dans base de la ligne - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; - $sql.= ' (fk_facture, fk_parent_line, label, description, qty,'; - $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; - $sql.= ' date_start, date_end, fk_code_ventilation, '; - $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; - $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; - $sql.= ' situation_percent, fk_prev_id,'; - $sql.= ' fk_unit, fk_user_author, fk_user_modif,'; - $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql.= ')'; - $sql.= " VALUES (".$this->fk_facture.","; - $sql.= " ".($this->fk_parent_line>0 ? $this->fk_parent_line:"null").","; - $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; - $sql.= " '".$this->db->escape($this->desc)."',"; - $sql.= " ".price2num($this->qty).","; - $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").","; - $sql.= " ".price2num($this->tva_tx).","; - $sql.= " ".price2num($this->localtax1_tx).","; - $sql.= " ".price2num($this->localtax2_tx).","; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; - $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").','; - $sql.= " ".$this->product_type.","; - $sql.= " ".price2num($this->remise_percent).","; - $sql.= " ".price2num($this->subprice).","; - $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").','; - $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").","; - $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").","; - $sql.= ' '.$this->fk_code_ventilation.','; - $sql.= ' '.$this->rang.','; - $sql.= ' '.$this->special_code.','; - $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").','; - $sql.= ' '.price2num($this->pa_ht).','; - $sql.= " '".$this->db->escape($this->info_bits)."',"; - $sql.= " ".price2num($this->total_ht).","; - $sql.= " ".price2num($this->total_tva).","; - $sql.= " ".price2num($this->total_ttc).","; - $sql.= " ".price2num($this->total_localtax1).","; - $sql.= " ".price2num($this->total_localtax2); - $sql.= ", " . $this->situation_percent; - $sql.= ", " . (!empty($this->fk_prev_id)?$this->fk_prev_id:"null"); - $sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", ".$user->id; - $sql.= ", ".$user->id; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".price2num($this->multicurrency_subprice); - $sql.= ", ".price2num($this->multicurrency_total_ht); - $sql.= ", ".price2num($this->multicurrency_total_tva); - $sql.= ", ".price2num($this->multicurrency_total_ttc); - $sql.= ')'; + // Insertion dans base de la ligne + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'facturedet'; + $sql .= ' (fk_facture, fk_parent_line, label, description, qty,'; + $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql .= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; + $sql .= ' date_start, date_end, fk_code_ventilation, '; + $sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; + $sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; + $sql .= ' situation_percent, fk_prev_id,'; + $sql .= ' fk_unit, fk_user_author, fk_user_modif,'; + $sql .= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql .= ')'; + $sql .= " VALUES (" . $this->fk_facture . ","; + $sql .= " " . ($this->fk_parent_line > 0 ? $this->fk_parent_line : "null") . ","; + $sql .= " " . (!empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : "null") . ","; + $sql .= " '" . $this->db->escape($this->desc) . "',"; + $sql .= " " . price2num($this->qty) . ","; + $sql .= " " . (empty($this->vat_src_code) ? "''" : "'" . $this->db->escape($this->vat_src_code) . "'") . ","; + $sql .= " " . price2num($this->tva_tx) . ","; + $sql .= " " . price2num($this->localtax1_tx) . ","; + $sql .= " " . price2num($this->localtax2_tx) . ","; + $sql .= " '" . $this->db->escape($this->localtax1_type) . "',"; + $sql .= " '" . $this->db->escape($this->localtax2_type) . "',"; + $sql .= ' ' . (!empty($this->fk_product) ? $this->fk_product : "null") . ','; + $sql .= " " . $this->product_type . ","; + $sql .= " " . price2num($this->remise_percent) . ","; + $sql .= " " . price2num($this->subprice) . ","; + $sql .= ' ' . (!empty($this->fk_remise_except) ? $this->fk_remise_except : "null") . ','; + $sql .= " " . (!empty($this->date_start) ? "'" . $this->db->idate($this->date_start) . "'" : "null") . ","; + $sql .= " " . (!empty($this->date_end) ? "'" . $this->db->idate($this->date_end) . "'" : "null") . ","; + $sql .= ' ' . $this->fk_code_ventilation . ','; + $sql .= ' ' . $this->rang . ','; + $sql .= ' ' . $this->special_code . ','; + $sql .= ' ' . (!empty($this->fk_fournprice) ? $this->fk_fournprice : "null") . ','; + $sql .= ' ' . price2num($this->pa_ht) . ','; + $sql .= " '" . $this->db->escape($this->info_bits) . "',"; + $sql .= " " . price2num($this->total_ht) . ","; + $sql .= " " . price2num($this->total_tva) . ","; + $sql .= " " . price2num($this->total_ttc) . ","; + $sql .= " " . price2num($this->total_localtax1) . ","; + $sql .= " " . price2num($this->total_localtax2); + $sql .= ", " . $this->situation_percent; + $sql .= ", " . (!empty($this->fk_prev_id) ? $this->fk_prev_id : "null"); + $sql .= ", " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ", " . $user->id; + $sql .= ", " . $user->id; + $sql .= ", " . (int) $this->fk_multicurrency; + $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'"; + $sql .= ", " . price2num($this->multicurrency_subprice); + $sql .= ", " . price2num($this->multicurrency_total_ht); + $sql .= ", " . price2num($this->multicurrency_total_tva); + $sql .= ", " . price2num($this->multicurrency_total_ttc); + $sql .= ')'; - dol_syslog(get_class($this)."::insert", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); - $this->rowid=$this->id; // For backward compatibility + dol_syslog(get_class($this) . "::insert", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . 'facturedet'); + $this->rowid = $this->id; // For backward compatibility - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; + } } - // Si fk_remise_except defini, on lie la remise a la facture - // ce qui la flague comme "consommee". - if ($this->fk_remise_except) - { - $discount=new DiscountAbsolute($this->db); - $result=$discount->fetch($this->fk_remise_except); - if ($result >= 0) - { - // Check if discount was found - if ($result > 0) - { - // Check if discount not already affected to another invoice - if ($discount->fk_facture_line > 0) - { - if (empty($noerrorifdiscountalreadylinked)) - { - $this->error=$langs->trans("ErrorDiscountAlreadyUsed",$discount->id); - dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } - } - else - { - $result=$discount->link_to_invoice($this->rowid,0); - if ($result < 0) - { - $this->error=$discount->error; - dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } - } - } - else - { - $this->error=$langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); - dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } - } - else - { - $this->error=$discount->error; - dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } - } + // Si fk_remise_except defini, on lie la remise a la facture + // ce qui la flague comme "consommee". + if ($this->fk_remise_except) { + $discount = new DiscountAbsolute($this->db); + $result = $discount->fetch($this->fk_remise_except); + if ($result >= 0) { + // Check if discount was found + if ($result > 0) { + // Check if discount not already affected to another invoice + if ($discount->fk_facture_line > 0) { + if (empty($noerrorifdiscountalreadylinked)) { + $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id); + dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } + } else { + $result = $discount->link_to_invoice($this->rowid, 0); + if ($result < 0) { + $this->error = $discount->error; + dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } + } + } else { + $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); + dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } + } else { + $this->error = $discount->error; + dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } + } - if (! $notrigger) - { + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILL_INSERT',$user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } + $result = $this->call_trigger('LINEBILL_INSERT', $user); + if ($result < 0) { + $this->db->rollback(); + return -2; + } // End call triggers - } + } - $this->db->commit(); - return $this->id; + $this->db->commit(); + return $this->id; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -2; - } - } + /** + * Update line into database + * + * @param User $user User object + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user = '', $notrigger = 0) { + global $user, $conf; - /** - * Update line into database - * - * @param User $user User object - * @param int $notrigger Disable triggers - * @return int <0 if KO, >0 if OK - */ - function update($user='',$notrigger=0) - { - global $user,$conf; + $error = 0; - $error=0; + $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. + // Clean parameters + $this->desc = trim($this->desc); + if (empty($this->tva_tx)) + $this->tva_tx = 0; + if (empty($this->localtax1_tx)) + $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) + $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) + $this->localtax1_type = 0; + if (empty($this->localtax2_type)) + $this->localtax2_type = 0; + if (empty($this->total_localtax1)) + $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) + $this->total_localtax2 = 0; + if (empty($this->remise_percent)) + $this->remise_percent = 0; + if (empty($this->info_bits)) + $this->info_bits = 0; + if (empty($this->special_code)) + $this->special_code = 0; + if (empty($this->product_type)) + $this->product_type = 0; + if (empty($this->fk_parent_line)) + $this->fk_parent_line = 0; + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') + $this->situation_percent = 100; + if (empty($this->pa_ht)) + $this->pa_ht = 0; - $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. + if (empty($this->multicurrency_subprice)) + $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) + $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) + $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) + $this->multicurrency_total_ttc = 0; - // Clean parameters - $this->desc=trim($this->desc); - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->product_type)) $this->product_type=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; - if (empty($this->pa_ht)) $this->pa_ht=0; + // Check parameters + if ($this->product_type < 0) + return -1; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0 && $pa_ht_isemptystring) { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { + return $result; + } else { + $this->pa_ht = $result; + } + } - // Check parameters - if ($this->product_type < 0) return -1; - - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0 && $pa_ht_isemptystring) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { - return $result; - } - else - { - $this->pa_ht = $result; - } - } - - $this->db->begin(); + $this->db->begin(); // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql.= " description='".$this->db->escape($this->desc)."'"; - $sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); - $sql.= ", subprice=".price2num($this->subprice).""; - $sql.= ", remise_percent=".price2num($this->remise_percent).""; - if ($this->fk_remise_except) $sql.= ", fk_remise_except=".$this->fk_remise_except; - else $sql.= ", fk_remise_except=null"; - $sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->db->escape($this->vat_src_code))."'"; - $sql.= ", tva_tx=".price2num($this->tva_tx).""; - $sql.= ", localtax1_tx=".price2num($this->localtax1_tx).""; - $sql.= ", localtax2_tx=".price2num($this->localtax2_tx).""; - $sql.= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql.= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql.= ", qty=".price2num($this->qty); - $sql.= ", date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null"); - $sql.= ", date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); - $sql.= ", product_type=".$this->product_type; - $sql.= ", info_bits='".$this->db->escape($this->info_bits)."'"; - $sql.= ", special_code='".$this->db->escape($this->special_code)."'"; - if (empty($this->skip_update_total)) - { - $sql.= ", total_ht=".price2num($this->total_ht); - $sql.= ", total_tva=".price2num($this->total_tva); - $sql.= ", total_ttc=".price2num($this->total_ttc); - $sql.= ", total_localtax1=".price2num($this->total_localtax1); - $sql.= ", total_localtax2=".price2num($this->total_localtax2); + $sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet SET"; + $sql .= " description='" . $this->db->escape($this->desc) . "'"; + $sql .= ", label=" . (!empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : "null"); + $sql .= ", subprice=" . price2num($this->subprice) . ""; + $sql .= ", remise_percent=" . price2num($this->remise_percent) . ""; + if ($this->fk_remise_except) + $sql .= ", fk_remise_except=" . $this->fk_remise_except; + else + $sql .= ", fk_remise_except=null"; + $sql .= ", vat_src_code = '" . (empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code)) . "'"; + $sql .= ", tva_tx=" . price2num($this->tva_tx) . ""; + $sql .= ", localtax1_tx=" . price2num($this->localtax1_tx) . ""; + $sql .= ", localtax2_tx=" . price2num($this->localtax2_tx) . ""; + $sql .= ", localtax1_type='" . $this->db->escape($this->localtax1_type) . "'"; + $sql .= ", localtax2_type='" . $this->db->escape($this->localtax2_type) . "'"; + $sql .= ", qty=" . price2num($this->qty); + $sql .= ", date_start=" . (!empty($this->date_start) ? "'" . $this->db->idate($this->date_start) . "'" : "null"); + $sql .= ", date_end=" . (!empty($this->date_end) ? "'" . $this->db->idate($this->date_end) . "'" : "null"); + $sql .= ", product_type=" . $this->product_type; + $sql .= ", info_bits='" . $this->db->escape($this->info_bits) . "'"; + $sql .= ", special_code='" . $this->db->escape($this->special_code) . "'"; + if (empty($this->skip_update_total)) { + $sql .= ", total_ht=" . price2num($this->total_ht); + $sql .= ", total_tva=" . price2num($this->total_tva); + $sql .= ", total_ttc=" . price2num($this->total_ttc); + $sql .= ", total_localtax1=" . price2num($this->total_localtax1); + $sql .= ", total_localtax2=" . price2num($this->total_localtax2); } - $sql.= ", fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); - $sql.= ", buy_price_ht='".price2num($this->pa_ht)."'"; - $sql.= ", fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); - if (! empty($this->rang)) $sql.= ", rang=".$this->rang; - $sql.= ", situation_percent=" . $this->situation_percent; - $sql.= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", fk_user_modif =".$user->id; + $sql .= ", fk_product_fournisseur_price=" . (!empty($this->fk_fournprice) ? "'" . $this->db->escape($this->fk_fournprice) . "'" : "null"); + $sql .= ", buy_price_ht='" . price2num($this->pa_ht) . "'"; + $sql .= ", fk_parent_line=" . ($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); + if (!empty($this->rang)) + $sql .= ", rang=" . $this->rang; + $sql .= ", situation_percent=" . $this->situation_percent; + $sql .= ", fk_unit=" . (!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ", fk_user_modif =" . $user->id; - // Multicurrency - $sql.= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql.= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql.= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql.= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + // Multicurrency + $sql .= ", multicurrency_subprice=" . price2num($this->multicurrency_subprice) . ""; + $sql .= ", multicurrency_total_ht=" . price2num($this->multicurrency_total_ht) . ""; + $sql .= ", multicurrency_total_tva=" . price2num($this->multicurrency_total_tva) . ""; + $sql .= ", multicurrency_total_ttc=" . price2num($this->multicurrency_total_ttc) . ""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " WHERE rowid = " . $this->rowid; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $this->id=$this->rowid; - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + dol_syslog(get_class($this) . "::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used + $this->id = $this->rowid; + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; + } + } - if (! $error && ! $notrigger) - { + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILL_UPDATE',$user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } + $result = $this->call_trigger('LINEBILL_UPDATE', $user); + if ($result < 0) { + $this->db->rollback(); + return -2; + } // End call triggers - } - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -2; - } - } + } + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -2; + } + } - /** - * Delete line in database - * TODO Add param User $user and notrigger (see skeleton) + /** + * Delete line in database + * TODO Add param User $user and notrigger (see skeleton) * - * @return int <0 if KO, >0 if OK - */ - function delete() - { - global $user; + * @return int <0 if KO, >0 if OK + */ + function delete() { + global $user; - $this->db->begin(); + $this->db->begin(); - // Call trigger - $result=$this->call_trigger('LINEBILL_DELETE',$user); - if ($result < 0) - { - $this->db->rollback(); - return -1; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINEBILL_DELETE', $user); + if ($result < 0) { + $this->db->rollback(); + return -1; + } + // End call triggers - $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if ($this->db->query($sql) ) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet WHERE rowid = " . $this->rowid; + dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + if ($this->db->query($sql)) { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->error() . " sql=" . $sql; + $this->db->rollback(); + return -1; + } + } - /** - * Mise a jour en base des champs total_xxx de ligne de facture - * TODO What is goal of this method ? - * - * @return int <0 if KO, >0 if OK - */ - function update_total() - { - $this->db->begin(); - dol_syslog(get_class($this)."::update_total", LOG_DEBUG); + /** + * Mise a jour en base des champs total_xxx de ligne de facture + * TODO What is goal of this method ? + * + * @return int <0 if KO, >0 if OK + */ + function update_total() { + $this->db->begin(); + dol_syslog(get_class($this) . "::update_total", LOG_DEBUG); - // Clean parameters - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; + // Clean parameters + if (empty($this->total_localtax1)) + $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) + $this->total_localtax2 = 0; - // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql.= " total_ht=".price2num($this->total_ht).""; - $sql.= ",total_tva=".price2num($this->total_tva).""; - $sql.= ",total_localtax1=".price2num($this->total_localtax1).""; - $sql.= ",total_localtax2=".price2num($this->total_localtax2).""; - $sql.= ",total_ttc=".price2num($this->total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + // Mise a jour ligne en base + $sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet SET"; + $sql .= " total_ht=" . price2num($this->total_ht) . ""; + $sql .= ",total_tva=" . price2num($this->total_tva) . ""; + $sql .= ",total_localtax1=" . price2num($this->total_localtax1) . ""; + $sql .= ",total_localtax2=" . price2num($this->total_localtax2) . ""; + $sql .= ",total_ttc=" . price2num($this->total_ttc) . ""; + $sql .= " WHERE rowid = " . $this->rowid; - dol_syslog(get_class($this)."::update_total", LOG_DEBUG); + dol_syslog(get_class($this) . "::update_total", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -2; - } - } + $resql = $this->db->query($sql); + if ($resql) { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -2; + } + } - /** - * Returns situation_percent of the previous line. - * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. - * - * @param int $invoiceid Invoice id - * @return int >= 0 - */ - function get_prev_progress($invoiceid) - { - if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { - return 0; - } else { - // If invoice is a not a situation invoice, this->fk_prev_id is used for something else - $tmpinvoice=new Facture($this->db); + /** + * Returns situation_percent of the previous line. + * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. + * + * @param int $invoiceid Invoice id + * @return int >= 0 + */ + function get_prev_progress($invoiceid) { + if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { + return 0; + } else { + // If invoice is a not a situation invoice, this->fk_prev_id is used for something else + $tmpinvoice = new Facture($this->db); $tmpinvoice->fetch($invoiceid); - if ($tmpinvoice->type != Facture::TYPE_SITUATION) return 0; + if ($tmpinvoice->type != Facture::TYPE_SITUATION) + return 0; + + $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; + $resql = $this->db->query($sql); + if ($resql && $resql->num_rows > 0) { + $res = $this->db->fetch_array($resql); + return $res['situation_percent']; + } else { + $this->error = $this->db->error(); + dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + } + } - $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; - $resql = $this->db->query($sql); - if ($resql && $resql->num_rows > 0) { - $res = $this->db->fetch_array($resql); - return $res['situation_percent']; - } else { - $this->error = $this->db->error(); - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); - $this->db->rollback(); - return -1; - } - } - } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f83b2e85e72..5cf695f6ace 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2136,10 +2136,12 @@ class User extends CommonObject */ function getNomUrl($withpictoimg=0, $option='', $infologin=0, $notooltip=0, $maxlen=24, $hidethirdpartylogo=0, $mode='',$morecss='', $save_lastsearch_value=-1) { - global $langs, $conf, $db, $hookmanager; + global $langs, $conf, $db, $hookmanager, $user; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; + if(!$user->rights->user->user->lire && $user->id !=$this->id) $option='nolink'; + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; $result=''; $label=''; @@ -2271,18 +2273,27 @@ class User extends CommonObject */ function getLoginUrl($withpicto=0,$option='') { - global $langs; + global $langs, $user; $result=''; $linkstart = ''; $linkend=''; + //Check user's rights to see an other user + if((!$user->rights->user->user->lire && $this->id !=$user->id)) $option='nolink'; + if ($option == 'xxx') { $linkstart = ''; $linkend=''; } + + if ($option == 'nolink') + { + $linkstart = ''; + $linkend=''; + } $result.=$linkstart; if ($withpicto) $result.=img_object($langs->trans("ShowUser"), 'user', 'class="paddingright"'); From 4cbe3a5bc78a7a2577a18ebd796508ba13dc725c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 5 Jul 2018 17:01:47 +0200 Subject: [PATCH 117/228] docs: complete comments --- .../pdf/pdf_canelle.modules.php | 90 +++++++++++++++---- 1 file changed, 73 insertions(+), 17 deletions(-) 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 37e0cf64f15..d14a9bdcdc8 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -36,23 +36,79 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_canelle extends ModelePDFSuppliersInvoices { - var $db; - var $name; - var $description; - var $type; - - var $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; - - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; - - var $emetteur; // Objet societe qui emet + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + +/** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Objet societe qui emet + */ + public $emetteur; + /** From 988130d2a14d1db566da382983c4d2dec9c5bad0 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 5 Jul 2018 17:04:11 +0200 Subject: [PATCH 118/228] docs: complete comments --- .../pdf/pdf_muscadet.modules.php | 87 +++++++++++++++---- 1 file changed, 71 insertions(+), 16 deletions(-) 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 8b84f428bde..68a2a8706b5 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -40,23 +40,78 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_muscadet extends ModelePDFSuppliersOrders { - var $db; - var $name; - var $description; - var $type; + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + +/** + * @var string document type + */ + public $type; - var $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; - - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; - - var $emetteur; // Objet societe qui emet + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Objet societe qui emet + */ + public $emetteur; /** From 5011f252c12db7e994fa4d9c89399e56cf918f25 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Thu, 5 Jul 2018 19:00:41 +0200 Subject: [PATCH 119/228] ADD check user's rights --- htdocs/compta/facture/class/facture.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 919cd686d81..6307136899a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -53,7 +53,8 @@ if (!empty($conf->accounting->enabled)) /** * Class to manage invoices */ -class Facture extends CommonInvoice { +class Facture extends CommonInvoice +{ public $element = 'facture'; public $table_element = 'facture'; @@ -227,7 +228,8 @@ class Facture extends CommonInvoice { * @param DoliDB $db Database handler */ - function __construct($db) { + function __construct($db) + { $this->db = $db; } @@ -3868,7 +3870,8 @@ class Facture extends CommonInvoice { * Class to manage invoice lines. * Saved into database table llx_facturedet */ -class FactureLigne extends CommonInvoiceLine { +class FactureLigne extends CommonInvoiceLine +{ public $element = 'facturedet'; public $table_element = 'facturedet'; From 7f137adef96a3a8018ac62dfe56ea35293262a3f Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Fri, 6 Jul 2018 08:07:38 +0200 Subject: [PATCH 120/228] ADD check user's rights --- htdocs/compta/facture/class/facture.class.php | 8058 +++++++++-------- 1 file changed, 4214 insertions(+), 3844 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6307136899a..bb00620d056 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1,5 +1,4 @@ * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio @@ -34,131 +33,133 @@ */ /** - * \file htdocs/compta/facture/class/facture.class.php - * \ingroup facture - * \brief File of class to manage invoices + * \file htdocs/compta/facture/class/facture.class.php + * \ingroup facture + * \brief File of class to manage invoices */ -include_once DOL_DOCUMENT_ROOT . '/core/class/commoninvoice.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobjectline.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT . '/margin/lib/margins.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php'; -if (!empty($conf->accounting->enabled)) - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -if (!empty($conf->accounting->enabled)) - require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; + +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; /** - * Class to manage invoices + * Class to manage invoices */ -class Facture extends CommonInvoice +class Facture extends CommonInvoice { + public $element='facture'; + public $table_element='facture'; + public $table_element_line = 'facturedet'; + public $fk_element = 'fk_facture'; + public $picto='bill'; + /** + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + public $ismultientitymanaged = 1; + /** + * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user + * @var integer + */ + public $restrictiononfksoc = 1; - public $element = 'facture'; - public $table_element = 'facture'; - public $table_element_line = 'facturedet'; - public $fk_element = 'fk_facture'; - public $picto = 'bill'; + /** + * {@inheritdoc} + */ + protected $table_ref_field = 'facnumber'; - /** - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - * @var int - */ - public $ismultientitymanaged = 1; + public $socid; - /** - * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user - * @var integer - */ - public $restrictiononfksoc = 1; + public $author; + public $fk_user_author; + public $fk_user_valid; + public $date; // Date invoice + public $date_creation; // Creation date + public $date_validation; // Validation date + public $datem; + public $ref_client; + public $ref_int; + //Check constants for types + public $type = self::TYPE_STANDARD; - /** - * {@inheritdoc} - */ - protected $table_ref_field = 'facnumber'; - public $socid; - public $author; - public $fk_user_author; - public $fk_user_valid; - public $date; // Date invoice - public $date_creation; // Creation date - public $date_validation; // Validation date - public $datem; - public $ref_client; - public $ref_int; - //Check constants for types - public $type = self::TYPE_STANDARD; - //var $amount; - public $remise_absolue; - public $remise_percent; - public $total_ht = 0; - public $total_tva = 0; - public $total_localtax1 = 0; - public $total_localtax2 = 0; - public $total_ttc = 0; - public $revenuestamp; - //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon - //! Fermeture alors que aucun paiement: replaced (si remplace), abandon - public $close_code; - //! Commentaire si mis a paye sans paiement complet - public $close_note; - //! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) - public $paye; - //! id of source invoice if replacement invoice or credit note - public $fk_facture_source; - public $linked_objects = array(); - public $date_lim_reglement; - public $cond_reglement_code; // Code in llx_c_paiement - public $mode_reglement_code; // Code in llx_c_paiement - public $fk_bank; // Field to store bank id to use when payment mode is withdraw - /** - * @deprecated - */ - public $products = array(); + //var $amount; + public $remise_absolue; + public $remise_percent; + public $total_ht=0; + public $total_tva=0; + public $total_localtax1=0; + public $total_localtax2=0; + public $total_ttc=0; + public $revenuestamp; - /** - * @var FactureLigne[] - */ - public $lines = array(); - public $line; - public $extraparams = array(); - public $specimen; - public $fac_rec; - // Multicurrency - public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_tx; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon + //! Fermeture alors que aucun paiement: replaced (si remplace), abandon + public $close_code; + //! Commentaire si mis a paye sans paiement complet + public $close_note; + //! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) + public $paye; + //! id of source invoice if replacement invoice or credit note + public $fk_facture_source; + public $linked_objects=array(); + public $date_lim_reglement; + public $cond_reglement_code; // Code in llx_c_paiement + public $mode_reglement_code; // Code in llx_c_paiement + public $fk_bank; // Field to store bank id to use when payment mode is withdraw + /** + * @deprecated + */ + public $products=array(); + /** + * @var FactureLigne[] + */ + public $lines=array(); + public $line; + public $extraparams=array(); + public $specimen; - /** - * @var int Situation cycle reference number - */ - public $situation_cycle_ref; + public $fac_rec; - /** - * @var int Situation counter inside the cycle - */ - public $situation_counter; + // Multicurrency + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_tx; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; - /** - * @var int Final situation flag - */ - public $situation_final; + /** + * @var int Situation cycle reference number + */ + public $situation_cycle_ref; - /** - * @var array Table of previous situations - */ - public $tab_previous_situation_invoice = array(); + /** + * @var int Situation counter inside the cycle + */ + public $situation_counter; - /** - * @var array Table of next situations - */ - public $tab_next_situation_invoice = array(); - public $oldcopy; + /** + * @var int Final situation flag + */ + public $situation_final; + + /** + * @var array Table of previous situations + */ + public $tab_previous_situation_invoice=array(); + + /** + * @var array Table of next situations + */ + public $tab_next_situation_invoice=array(); + + public $oldcopy; /** * Standard invoice @@ -185,4300 +186,4669 @@ class Facture extends CommonInvoice */ const TYPE_PROFORMA = 4; - /** - * Situation invoice - */ - const TYPE_SITUATION = 5; + /** + * Situation invoice + */ + const TYPE_SITUATION = 5; - /** - * Draft - */ - const STATUS_DRAFT = 0; + /** + * Draft + */ + const STATUS_DRAFT = 0; - /** - * Validated (need to be paid) - */ - const STATUS_VALIDATED = 1; + /** + * Validated (need to be paid) + */ + const STATUS_VALIDATED = 1; - /** - * Classified paid. - * If paid partially, $this->close_code can be: - * - CLOSECODE_DISCOUNTVAT - * - CLOSECODE_BADDEBT - * If paid completelly, this->close_code will be null - */ - const STATUS_CLOSED = 2; + /** + * Classified paid. + * If paid partially, $this->close_code can be: + * - CLOSECODE_DISCOUNTVAT + * - CLOSECODE_BADDEBT + * If paid completelly, this->close_code will be null + */ + const STATUS_CLOSED = 2; - /** - * Classified abandoned and no payment done. - * $this->close_code can be: - * - CLOSECODE_BADDEBT - * - CLOSECODE_ABANDONED - * - CLOSECODE_REPLACED - */ - const STATUS_ABANDONED = 3; - const CLOSECODE_DISCOUNTVAT = 'discount_vat'; // Abandonned remain - escompte - const CLOSECODE_BADDEBT = 'badcustomer'; // Abandonned - bad - const CLOSECODE_ABANDONED = 'abandon'; // Abandonned - other - const CLOSECODE_REPLACED = 'replaced'; // Closed after doing a replacement invoice + /** + * Classified abandoned and no payment done. + * $this->close_code can be: + * - CLOSECODE_BADDEBT + * - CLOSECODE_ABANDONED + * - CLOSECODE_REPLACED + */ + const STATUS_ABANDONED = 3; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ + const CLOSECODE_DISCOUNTVAT = 'discount_vat'; // Abandonned remain - escompte + const CLOSECODE_BADDEBT = 'badcustomer'; // Abandonned - bad + const CLOSECODE_ABANDONED = 'abandon'; // Abandonned - other + const CLOSECODE_REPLACED = 'replaced'; // Closed after doing a replacement invoice - function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } - /** - * Create invoice in database. - * Note: this->ref can be set or empty. If empty, we will use "(PROV999)" - * Note: this->fac_rec must be set to create invoice from a recurring invoice - * - * @param User $user Object user that create - * @param int $notrigger 1=Does not execute triggers, 0 otherwise - * @param int $forceduedate 1=Do not recalculate due date from payment condition but force it with value - * @return int <0 if KO, >0 if OK - */ - function create(User $user, $notrigger = 0, $forceduedate = 0) { - global $langs, $conf, $mysoc, $hookmanager; - $error = 0; + /** + * Create invoice in database. + * Note: this->ref can be set or empty. If empty, we will use "(PROV999)" + * Note: this->fac_rec must be set to create invoice from a recurring invoice + * + * @param User $user Object user that create + * @param int $notrigger 1=Does not execute triggers, 0 otherwise + * @param int $forceduedate 1=Do not recalculate due date from payment condition but force it with value + * @return int <0 if KO, >0 if OK + */ + function create(User $user, $notrigger=0, $forceduedate=0) + { + global $langs,$conf,$mysoc,$hookmanager; + $error=0; - // Clean parameters - if (empty($this->type)) - $this->type = self::TYPE_STANDARD; - $this->ref_client = trim($this->ref_client); - $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated - $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); - $this->note_public = trim($this->note_public); - if (!$this->cond_reglement_id) - $this->cond_reglement_id = 0; - if (!$this->mode_reglement_id) - $this->mode_reglement_id = 0; - $this->brouillon = 1; - if (empty($this->entity)) - $this->entity = $conf->entity; + // Clean parameters + if (empty($this->type)) $this->type = self::TYPE_STANDARD; + $this->ref_client=trim($this->ref_client); + $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); + $this->note_public=trim($this->note_public); + if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; + if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; + $this->brouillon = 1; + if (empty($this->entity)) $this->entity = $conf->entity; - // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) - list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); - else - $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); - if (empty($this->fk_multicurrency)) { - $this->multicurrency_code = $conf->currency; - $this->fk_multicurrency = 0; - $this->multicurrency_tx = 1; - } + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } - dol_syslog(get_class($this) . "::create user=" . $user->id . " date=" . $this->date); + dol_syslog(get_class($this)."::create user=".$user->id." date=".$this->date); - // Check parameters - if (empty($this->date)) { - $this->error = "Try to create an invoice with an empty parameter (date)"; - dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR); - return -3; - } - $soc = new Societe($this->db); - $result = $soc->fetch($this->socid); - if ($result < 0) { - $this->error = "Failed to fetch company: " . $soc->error; - dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR); - return -2; - } + // Check parameters + if (empty($this->date)) + { + $this->error="Try to create an invoice with an empty parameter (date)"; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -3; + } + $soc = new Societe($this->db); + $result=$soc->fetch($this->socid); + if ($result < 0) + { + $this->error="Failed to fetch company: ".$soc->error; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -2; + } - $now = dol_now(); + $now=dol_now(); - $this->db->begin(); + $this->db->begin(); - $originaldatewhen = null; - $nextdatewhen = null; - $previousdaynextdatewhen = null; + $originaldatewhen=null; + $nextdatewhen=null; + $previousdaynextdatewhen=null; - // Create invoice from a template invoice - if ($this->fac_rec > 0) { - $this->fk_fac_rec_source = $this->fac_rec; + // Create invoice from a template invoice + if ($this->fac_rec > 0) + { + $this->fk_fac_rec_source = $this->fac_rec; - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php'; - $_facrec = new FactureRec($this->db); - $result = $_facrec->fetch($this->fac_rec); - $result = $_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds - // Define some dates - $originaldatewhen = $_facrec->date_when; - $nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); - $previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd'); + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; + $_facrec = new FactureRec($this->db); + $result=$_facrec->fetch($this->fac_rec); + $result=$_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds - $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template - $this->entity = $_facrec->entity; // Invoice created in same entity than template - // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI - $this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project; - $this->note_public = GETPOST('note_public', 'none') ? GETPOST('note_public', 'none') : $_facrec->note_public; - $this->note_private = GETPOST('note_private', 'none') ? GETPOST('note_private', 'none') : $_facrec->note_private; - $this->modelpdf = GETPOST('model', 'alpha') ? GETPOST('model', 'apha') : $_facrec->modelpdf; - $this->cond_reglement_id = GETPOST('cond_reglement_id', 'int') > 0 ? ((int) GETPOST('cond_reglement_id', 'int')) : $_facrec->cond_reglement_id; - $this->mode_reglement_id = GETPOST('mode_reglement_id', 'int') > 0 ? ((int) GETPOST('mode_reglement_id', 'int')) : $_facrec->mode_reglement_id; - $this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account; + // Define some dates + $originaldatewhen = $_facrec->date_when; + $nextdatewhen=dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); + $previousdaynextdatewhen=dol_time_plus_duree($nextdatewhen, -1, 'd'); - // Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result - $this->total_ht = $_facrec->total_ht; - $this->total_ttc = $_facrec->total_ttc; + $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template + $this->entity = $_facrec->entity; // Invoice created in same entity than template - // Fields always coming from template - $this->remise_absolue = $_facrec->remise_absolue; - $this->remise_percent = $_facrec->remise_percent; - $this->fk_incoterms = $_facrec->fk_incoterms; - $this->location_incoterms = $_facrec->location_incoterms; + // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI + $this->fk_project = GETPOST('projectid','int') > 0 ? ((int) GETPOST('projectid','int')) : $_facrec->fk_project; + $this->note_public = GETPOST('note_public','none') ? GETPOST('note_public','none') : $_facrec->note_public; + $this->note_private = GETPOST('note_private','none') ? GETPOST('note_private','none') : $_facrec->note_private; + $this->modelpdf = GETPOST('model','alpha') ? GETPOST('model','apha') : $_facrec->modelpdf; + $this->cond_reglement_id = GETPOST('cond_reglement_id','int') > 0 ? ((int) GETPOST('cond_reglement_id','int')) : $_facrec->cond_reglement_id; + $this->mode_reglement_id = GETPOST('mode_reglement_id','int') > 0 ? ((int) GETPOST('mode_reglement_id','int')) : $_facrec->mode_reglement_id; + $this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account; - // Clean parameters - if (!$this->type) - $this->type = self::TYPE_STANDARD; - $this->ref_client = trim($this->ref_client); - $this->note_public = trim($this->note_public); - $this->note_private = trim($this->note_private); - $this->note_private = dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + // Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result + $this->total_ht = $_facrec->total_ht; + $this->total_ttc = $_facrec->total_ttc; - $this->array_options = $_facrec->array_options; + // Fields always coming from template + $this->remise_absolue = $_facrec->remise_absolue; + $this->remise_percent = $_facrec->remise_percent; + $this->fk_incoterms = $_facrec->fk_incoterms; + $this->location_incoterms= $_facrec->location_incoterms; - //if (! $this->remise) $this->remise = 0; - if (!$this->mode_reglement_id) - $this->mode_reglement_id = 0; - $this->brouillon = 1; + // Clean parameters + if (! $this->type) $this->type = self::TYPE_STANDARD; + $this->ref_client=trim($this->ref_client); + $this->note_public=trim($this->note_public); + $this->note_private=trim($this->note_private); + $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); - $this->linked_objects = $_facrec->linkedObjectsIds; + $this->array_options=$_facrec->array_options; - $forceduedate = $this->calculate_date_lim_reglement(); + //if (! $this->remise) $this->remise = 0; + if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; + $this->brouillon = 1; - // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice - if ($_facrec->frequency > 0) { - dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); - if (empty($_facrec->date_when)) - $_facrec->date_when = $now; + $this->linked_objects = $_facrec->linkedObjectsIds; + + $forceduedate = $this->calculate_date_lim_reglement(); + + // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice + if ($_facrec->frequency > 0) + { + dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); + if (empty($_facrec->date_when)) $_facrec->date_when = $now; $next_date = $_facrec->getNextDate(); // Calculate next date $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. - $result = $_facrec->setNextDate($next_date, 1); - } + $result = $_facrec->setNextDate($next_date,1); + } - // Define lang of customer - $outputlangs = $langs; - $newlang = ''; + // Define lang of customer + $outputlangs = $langs; + $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) - $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) - $newlang = $this->default_lang; // for thirdparty - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang=$this->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang=$this->default_lang; // for thirdparty + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } - // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $this); - $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'); - $substitutionarray['__INVOICE_MONTH__'] = dol_print_date($this->date, '%m'); - $substitutionarray['__INVOICE_NEXT_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'); - $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B'); - $substitutionarray['__INVOICE_MONTH_TEXT__'] = dol_print_date($this->date, '%B'); - $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B'); - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); - $substitutionarray['__INVOICE_YEAR__'] = dol_print_date($this->date, '%Y'); - $substitutionarray['__INVOICE_NEXT_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); - // Only for tempalte invoice - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = dol_print_date($originaldatewhen, 'dayhour'); - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($nextdatewhen, 'dayhour'); - $substitutionarray['__INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($previousdaynextdatewhen, 'dayhour'); + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $this); + $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'); + $substitutionarray['__INVOICE_MONTH__'] = dol_print_date($this->date, '%m'); + $substitutionarray['__INVOICE_NEXT_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'); + $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B'); + $substitutionarray['__INVOICE_MONTH_TEXT__'] = dol_print_date($this->date, '%B'); + $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B'); + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); + $substitutionarray['__INVOICE_YEAR__'] = dol_print_date($this->date, '%Y'); + $substitutionarray['__INVOICE_NEXT_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); + // Only for tempalte invoice + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = dol_print_date($originaldatewhen, 'dayhour'); + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($nextdatewhen, 'dayhour'); + $substitutionarray['__INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($previousdaynextdatewhen, 'dayhour'); - //var_dump($substitutionarray);exit; + //var_dump($substitutionarray);exit; - $substitutionisok = true; - complete_substitutions_array($substitutionarray, $outputlangs); + $substitutionisok=true; + complete_substitutions_array($substitutionarray, $outputlangs); - $this->note_public = make_substitutions($this->note_public, $substitutionarray); - $this->note_private = make_substitutions($this->note_private, $substitutionarray); - } + $this->note_public=make_substitutions($this->note_public,$substitutionarray); + $this->note_private=make_substitutions($this->note_private,$substitutionarray); + } - // Define due date if not already defined - $datelim = (empty($forceduedate) ? $this->calculate_date_lim_reglement() : $forceduedate); + // Define due date if not already defined + $datelim=(empty($forceduedate)?$this->calculate_date_lim_reglement():$forceduedate); - // Insert into database - $socid = $this->socid; + // Insert into database + $socid = $this->socid; - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "facture ("; - $sql .= " facnumber"; - $sql .= ", entity"; - $sql .= ", ref_ext"; - $sql .= ", type"; - $sql .= ", fk_soc"; - $sql .= ", datec"; - $sql .= ", remise_absolue"; - $sql .= ", remise_percent"; - $sql .= ", datef"; - $sql .= ", date_pointoftax"; - $sql .= ", note_private"; - $sql .= ", note_public"; - $sql .= ", ref_client, ref_int"; - $sql .= ", fk_account"; - $sql .= ", fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; - $sql .= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; - $sql .= ", situation_cycle_ref, situation_counter, situation_final"; - $sql .= ", fk_incoterms, location_incoterms"; - $sql .= ", fk_multicurrency"; - $sql .= ", multicurrency_code"; - $sql .= ", multicurrency_tx"; - $sql .= ")"; - $sql .= " VALUES ("; - $sql .= "'(PROV)'"; - $sql .= ", " . $this->entity; - $sql .= ", " . ($this->ref_ext ? "'" . $this->db->escape($this->ref_ext) . "'" : "null"); - $sql .= ", '" . $this->db->escape($this->type) . "'"; - $sql .= ", '" . $socid . "'"; - $sql .= ", '" . $this->db->idate($now) . "'"; - $sql .= ", " . ($this->remise_absolue > 0 ? $this->remise_absolue : 'NULL'); - $sql .= ", " . ($this->remise_percent > 0 ? $this->remise_percent : 'NULL'); - $sql .= ", '" . $this->db->idate($this->date) . "'"; - $sql .= ", " . (strval($this->date_pointoftax) != '' ? "'" . $this->db->idate($this->date_pointoftax) . "'" : 'null'); - $sql .= ", " . ($this->note_private ? "'" . $this->db->escape($this->note_private) . "'" : "null"); - $sql .= ", " . ($this->note_public ? "'" . $this->db->escape($this->note_public) . "'" : "null"); - $sql .= ", " . ($this->ref_client ? "'" . $this->db->escape($this->ref_client) . "'" : "null"); - $sql .= ", " . ($this->ref_int ? "'" . $this->db->escape($this->ref_int) . "'" : "null"); - $sql .= ", " . ($this->fk_account > 0 ? $this->fk_account : 'NULL'); - $sql .= ", " . ($this->fk_fac_rec_source ? "'" . $this->db->escape($this->fk_fac_rec_source) . "'" : "null"); - $sql .= ", " . ($this->fk_facture_source ? "'" . $this->db->escape($this->fk_facture_source) . "'" : "null"); - $sql .= ", " . ($user->id > 0 ? "'" . $user->id . "'" : "null"); - $sql .= ", " . ($this->fk_project ? $this->fk_project : "null"); - $sql .= ", " . $this->cond_reglement_id; - $sql .= ", " . $this->mode_reglement_id; - $sql .= ", '" . $this->db->idate($datelim) . "', '" . $this->db->escape($this->modelpdf) . "'"; - $sql .= ", " . ($this->situation_cycle_ref ? "'" . $this->db->escape($this->situation_cycle_ref) . "'" : "null"); - $sql .= ", " . ($this->situation_counter ? "'" . $this->db->escape($this->situation_counter) . "'" : "null"); - $sql .= ", " . ($this->situation_final ? $this->situation_final : 0); - $sql .= ", " . (int) $this->fk_incoterms; - $sql .= ", '" . $this->db->escape($this->location_incoterms) . "'"; - $sql .= ", " . (int) $this->fk_multicurrency; - $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'"; - $sql .= ", " . (double) $this->multicurrency_tx; - $sql .= ")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture ("; + $sql.= " facnumber"; + $sql.= ", entity"; + $sql.= ", ref_ext"; + $sql.= ", type"; + $sql.= ", fk_soc"; + $sql.= ", datec"; + $sql.= ", remise_absolue"; + $sql.= ", remise_percent"; + $sql.= ", datef"; + $sql.= ", date_pointoftax"; + $sql.= ", note_private"; + $sql.= ", note_public"; + $sql.= ", ref_client, ref_int"; + $sql.= ", fk_account"; + $sql.= ", fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; + $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; + $sql.= ", situation_cycle_ref, situation_counter, situation_final"; + $sql.= ", fk_incoterms, location_incoterms"; + $sql.= ", fk_multicurrency"; + $sql.= ", multicurrency_code"; + $sql.= ", multicurrency_tx"; + $sql.= ")"; + $sql.= " VALUES ("; + $sql.= "'(PROV)'"; + $sql.= ", ".$this->entity; + $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); + $sql.= ", '".$this->db->escape($this->type)."'"; + $sql.= ", '".$socid."'"; + $sql.= ", '".$this->db->idate($now)."'"; + $sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL'); + $sql.= ", ".($this->remise_percent>0?$this->remise_percent:'NULL'); + $sql.= ", '".$this->db->idate($this->date)."'"; + $sql.= ", ".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null'); + $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); + $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); + $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); + $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); + $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); + $sql.= ", ".($this->fk_fac_rec_source?"'".$this->db->escape($this->fk_fac_rec_source)."'":"null"); + $sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); + $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); + $sql.= ", ".($this->fk_project?$this->fk_project:"null"); + $sql.= ", ".$this->cond_reglement_id; + $sql.= ", ".$this->mode_reglement_id; + $sql.= ", '".$this->db->idate($datelim)."', '".$this->db->escape($this->modelpdf)."'"; + $sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"); + $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); + $sql.= ", ".($this->situation_final?$this->situation_final:0); + $sql.= ", ".(int) $this->fk_incoterms; + $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".(double) $this->multicurrency_tx; + $sql.=")"; - $resql = $this->db->query($sql); - if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . 'facture'); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture'); - // Update ref with new one - $this->ref = '(PROV' . $this->id . ')'; - $sql = 'UPDATE ' . MAIN_DB_PREFIX . "facture SET facnumber='" . $this->db->escape($this->ref) . "' WHERE rowid=" . $this->id; + // Update ref with new one + $this->ref='(PROV'.$this->id.')'; + $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; - $resql = $this->db->query($sql); - if (!$resql) - $error++; + $resql=$this->db->query($sql); + if (! $resql) $error++; - if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) { // To use new linkedObjectsIds instead of old linked_objects - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds - } + if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + { + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + } - // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { - foreach ($this->linked_objects as $origin => $tmp_origin_id) { - if (is_array($tmp_origin_id)) { // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - foreach ($tmp_origin_id as $origin_id) { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else { // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) { - $this->error = $this->db->lasterror(); - $error++; - } - } - } - } + // Add object linked + if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) + { + foreach($this->linked_objects as $origin => $tmp_origin_id) + { + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (! $ret) + { + $this->error=$this->db->lasterror(); + $error++; + } + } + } + else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (! $ret) + { + $this->error=$this->db->lasterror(); + $error++; + } + } + } + } - // Propagate contacts - if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) { // Get contact from origin object - $originforcontact = $this->origin; - $originidforcontact = $this->origin_id; - if ($originforcontact == 'shipping') { // shipment and order share the same contacts. If creating from shipment we take data of order - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; - $exp = new Expedition($this->db); - $exp->fetch($this->origin_id); - $exp->fetchObjectLinked(); - if (count($exp->linkedObjectsIds['commande']) > 0) { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { - $originforcontact = 'commande'; - if (is_object($value)) - $originidforcontact = $value->id; - else - $originidforcontact = $value; - break; // We take first one - } - } - } + // Propagate contacts + if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object + { + $originforcontact = $this->origin; + $originidforcontact = $this->origin_id; + if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order + { + require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + $exp = new Expedition($this->db); + $exp->fetch($this->origin_id); + $exp->fetchObjectLinked(); + if (count($exp->linkedObjectsIds['commande']) > 0) + { + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) + { + $originforcontact = 'commande'; + if (is_object($value)) $originidforcontact = $value->id; + else $originidforcontact = $value; + break; // We take first one + } + } + } - $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM " . MAIN_DB_PREFIX . "element_contact as ec, " . MAIN_DB_PREFIX . "c_type_contact as ctc"; - $sqlcontact .= " WHERE element_id = " . $originidforcontact . " AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '" . $originforcontact . "'"; + $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; - $resqlcontact = $this->db->query($sqlcontact); - if ($resqlcontact) { - while ($objcontact = $this->db->fetch_object($resqlcontact)) { - //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object - } - } else - dol_print_error($resqlcontact); - } + $resqlcontact = $this->db->query($sqlcontact); + if ($resqlcontact) + { + while($objcontact = $this->db->fetch_object($resqlcontact)) + { + //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + } + } + else dol_print_error($resqlcontact); + } - /* - * Insert lines of invoices, if not from template invoice, into database - */ - if (!$error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) { // If this->lines is array of InvoiceLines (preferred mode) - $fk_parent_line = 0; + /* + * Insert lines of invoices, if not from template invoice, into database + */ + if (! $error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) + { + $fk_parent_line = 0; - dol_syslog("There is " . count($this->lines) . " lines that are invoice lines objects"); - foreach ($this->lines as $i => $val) { - $newinvoiceline = $this->lines[$i]; - $newinvoiceline->fk_facture = $this->id; + dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects"); + foreach ($this->lines as $i => $val) + { + $newinvoiceline=$this->lines[$i]; + $newinvoiceline->fk_facture=$this->id; - $newinvoiceline->origin = $this->lines[$i]->element; - $newinvoiceline->origin_id = $this->lines[$i]->id; + $newinvoiceline->origin = $this->lines[$i]->element; + $newinvoiceline->origin_id = $this->lines[$i]->id; - // Auto set date of service ? - if ($this->lines[$i]->date_start_fill == 1 && $originaldatewhen) { // $originaldatewhen is defined when generating from recurring invoice only - $newinvoiceline->date_start = $originaldatewhen; - } - if ($this->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) { // $previousdaynextdatewhen is defined when generating from recurring invoice only - $newinvoiceline->date_end = $previousdaynextdatewhen; - } + // Auto set date of service ? + if ($this->lines[$i]->date_start_fill == 1 && $originaldatewhen) // $originaldatewhen is defined when generating from recurring invoice only + { + $newinvoiceline->date_start = $originaldatewhen; + } + if ($this->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) // $previousdaynextdatewhen is defined when generating from recurring invoice only + { + $newinvoiceline->date_end = $previousdaynextdatewhen; + } - if ($result >= 0) { - // Reset fk_parent_line for no child products and special product - if (($newinvoiceline->product_type != 9 && empty($newinvoiceline->fk_parent_line)) || $newinvoiceline->product_type == 9) { - $fk_parent_line = 0; - } + if ($result >= 0) + { + // Reset fk_parent_line for no child products and special product + if (($newinvoiceline->product_type != 9 && empty($newinvoiceline->fk_parent_line)) || $newinvoiceline->product_type == 9) { + $fk_parent_line = 0; + } - $newinvoiceline->fk_parent_line = $fk_parent_line; + $newinvoiceline->fk_parent_line=$fk_parent_line; - if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { + if($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except){ $discount = new DiscountAbsolute($this->db); $discount->fetch($newinvoiceline->fk_remise_except); - $discountId = $soc->set_remise_except($discount->amount_ht, $user, $discount->description, $discount->tva_tx); - $newinvoiceline->fk_remise_except = $discountId; + $discountId = $soc->set_remise_except($discount->amount_ht, $user, $discount->description, $discount->tva_tx); + $newinvoiceline->fk_remise_except = $discountId; } - $result = $newinvoiceline->insert(); + $result=$newinvoiceline->insert(); - // Defined the new fk_parent_line - if ($result > 0 && $newinvoiceline->product_type == 9) { - $fk_parent_line = $result; - } - } - if ($result < 0) { - $this->error = $newinvoiceline->error; - $error++; - break; - } - } - } elseif (!$error && empty($this->fac_rec)) { // If this->lines is an array of invoice line arrays - $fk_parent_line = 0; + // Defined the new fk_parent_line + if ($result > 0 && $newinvoiceline->product_type == 9) { + $fk_parent_line = $result; + } + } + if ($result < 0) + { + $this->error=$newinvoiceline->error; + $error++; + break; + } + } + } + elseif (! $error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays + { + $fk_parent_line = 0; - dol_syslog("There is " . count($this->lines) . " lines that are array lines"); + dol_syslog("There is ".count($this->lines)." lines that are array lines"); - foreach ($this->lines as $i => $val) { - $line = $this->lines[$i]; + foreach ($this->lines as $i => $val) + { + $line = $this->lines[$i]; - // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array - //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. - if (!is_object($line)) - $line = (object) $line; + // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array + //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. + if (! is_object($line)) $line = (object) $line; - if ($result >= 0) { - // Reset fk_parent_line for no child products and special product - if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { - $fk_parent_line = 0; - } + if ($result >= 0) + { + // Reset fk_parent_line for no child products and special product + if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { + $fk_parent_line = 0; + } - // Complete vat rate with code - $vatrate = $line->tva_tx; - if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) - $vatrate .= ' (' . $line->vat_src_code . ')'; + // Complete vat rate with code + $vatrate = $line->tva_tx; + if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; - $result = $this->addline( - $line->desc, $line->subprice, $line->qty, $vatrate, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, $line->date_start, $line->date_end, $line->fk_code_ventilation, $line->info_bits, $line->fk_remise_except, 'HT', 0, $line->product_type, $line->rang, $line->special_code, $this->element, $line->id, $fk_parent_line, $line->fk_fournprice, $line->pa_ht, $line->label, $line->array_options, $line->situation_percent, $line->fk_prev_id, $line->fk_unit, $line->pu_ht_devise - ); - if ($result < 0) { - $this->error = $this->db->lasterror(); - dol_print_error($this->db); - $this->db->rollback(); - return -1; - } + $result = $this->addline( + $line->desc, + $line->subprice, + $line->qty, + $vatrate, + $line->localtax1_tx, + $line->localtax2_tx, + $line->fk_product, + $line->remise_percent, + $line->date_start, + $line->date_end, + $line->fk_code_ventilation, + $line->info_bits, + $line->fk_remise_except, + 'HT', + 0, + $line->product_type, + $line->rang, + $line->special_code, + $this->element, + $line->id, + $fk_parent_line, + $line->fk_fournprice, + $line->pa_ht, + $line->label, + $line->array_options, + $line->situation_percent, + $line->fk_prev_id, + $line->fk_unit, + $line->pu_ht_devise + ); + if ($result < 0) + { + $this->error=$this->db->lasterror(); + dol_print_error($this->db); + $this->db->rollback(); + return -1; + } - // Defined the new fk_parent_line - if ($result > 0 && $line->product_type == 9) { - $fk_parent_line = $result; - } - } - } - } + // Defined the new fk_parent_line + if ($result > 0 && $line->product_type == 9) { + $fk_parent_line = $result; + } + } + } + } - /* - * Insert lines of predefined invoices - */ - if (!$error && $this->fac_rec > 0) { - foreach ($_facrec->lines as $i => $val) { - if ($_facrec->lines[$i]->fk_product) { - $prod = new Product($this->db); - $res = $prod->fetch($_facrec->lines[$i]->fk_product); - } + /* + * Insert lines of predefined invoices + */ + if (! $error && $this->fac_rec > 0) + { + foreach ($_facrec->lines as $i => $val) + { + if ($_facrec->lines[$i]->fk_product) + { + $prod = new Product($this->db); + $res=$prod->fetch($_facrec->lines[$i]->fk_product); + } - // For line from template invoice, we use data from template invoice - /* - $tva_tx = get_default_tva($mysoc,$soc,$prod->id); - $tva_npr = get_default_npr($mysoc,$soc,$prod->id); - if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx=get_localtax($tva_tx,1,$soc,$mysoc,$tva_npr); - $localtax2_tx=get_localtax($tva_tx,2,$soc,$mysoc,$tva_npr); - */ - $tva_tx = $_facrec->lines[$i]->tva_tx . ($_facrec->lines[$i]->vat_src_code ? '(' . $_facrec->lines[$i]->vat_src_code . ')' : ''); - $tva_npr = $_facrec->lines[$i]->info_bits; - if (empty($tva_tx)) - $tva_npr = 0; - $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; - $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; + // For line from template invoice, we use data from template invoice + /* + $tva_tx = get_default_tva($mysoc,$soc,$prod->id); + $tva_npr = get_default_npr($mysoc,$soc,$prod->id); + if (empty($tva_tx)) $tva_npr=0; + $localtax1_tx=get_localtax($tva_tx,1,$soc,$mysoc,$tva_npr); + $localtax2_tx=get_localtax($tva_tx,2,$soc,$mysoc,$tva_npr); + */ + $tva_tx = $_facrec->lines[$i]->tva_tx.($_facrec->lines[$i]->vat_src_code ? '('.$_facrec->lines[$i]->vat_src_code.')' : ''); + $tva_npr = $_facrec->lines[$i]->info_bits; + if (empty($tva_tx)) $tva_npr=0; + $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; + $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; - $result_insert = $this->addline( - $_facrec->lines[$i]->desc, $_facrec->lines[$i]->subprice, $_facrec->lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $_facrec->lines[$i]->fk_product, $_facrec->lines[$i]->remise_percent, ($_facrec->lines[$i]->date_start_fill == 1 && $originaldatewhen) ? $originaldatewhen : '', ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) ? $previousdaynextdatewhen : '', 0, $tva_npr, '', 'HT', 0, $_facrec->lines[$i]->product_type, $_facrec->lines[$i]->rang, $_facrec->lines[$i]->special_code, '', 0, 0, null, 0, $_facrec->lines[$i]->label, empty($_facrec->lines[$i]->array_options) ? null : $_facrec->lines[$i]->array_options, $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit, $_facrec->lines[$i]->pu_ht_devise - ); + $result_insert = $this->addline( + $_facrec->lines[$i]->desc, + $_facrec->lines[$i]->subprice, + $_facrec->lines[$i]->qty, + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $_facrec->lines[$i]->fk_product, + $_facrec->lines[$i]->remise_percent, + ($_facrec->lines[$i]->date_start_fill == 1 && $originaldatewhen)?$originaldatewhen:'', + ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen)?$previousdaynextdatewhen:'', + 0, + $tva_npr, + '', + 'HT', + 0, + $_facrec->lines[$i]->product_type, + $_facrec->lines[$i]->rang, + $_facrec->lines[$i]->special_code, + '', + 0, + 0, + null, + 0, + $_facrec->lines[$i]->label, + empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, + $_facrec->lines[$i]->situation_percent, + '', + $_facrec->lines[$i]->fk_unit, + $_facrec->lines[$i]->pu_ht_devise + ); - if ($result_insert < 0) { - $error++; - $this->error = $this->db->error(); - break; - } - } - } + if ( $result_insert < 0) + { + $error++; + $this->error=$this->db->error(); + break; + } + } + } - if (!$error) { + if (! $error) + { - $result = $this->update_price(1); - if ($result > 0) { - $action = 'create'; + $result=$this->update_price(1); + if ($result > 0) + { + $action='create'; - // Actions on extra fields - if (!$error) { - $result = $this->insertExtraFields(); - if ($result < 0) - $error++; - } + // Actions on extra fields + if (! $error) + { + $result=$this->insertExtraFields(); + if ($result < 0) $error++; + } - if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('BILL_CREATE', $user); - if ($result < 0) - $error++; - // End call triggers - } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_CREATE',$user); + if ($result < 0) $error++; + // End call triggers + } - if (!$error) { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -4; - } - } else { - $this->error = $langs->trans('FailedToUpdatePrice'); - $this->db->rollback(); - return -3; - } - } else { - dol_syslog(get_class($this) . "::create error " . $this->error, LOG_ERR); - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -4; + } + } + else + { + $this->error=$langs->trans('FailedToUpdatePrice'); + $this->db->rollback(); + return -3; + } + } + else + { + dol_syslog(get_class($this)."::create error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } - /** - * Create a new invoice in database from current invoice - * - * @param User $user Object user that ask creation - * @param int $invertdetail Reverse sign of amounts for lines - * @return int <0 if KO, >0 if OK - */ - function createFromCurrent(User $user, $invertdetail = 0) { - global $conf; - // Charge facture source - $facture = new Facture($this->db); + /** + * Create a new invoice in database from current invoice + * + * @param User $user Object user that ask creation + * @param int $invertdetail Reverse sign of amounts for lines + * @return int <0 if KO, >0 if OK + */ + function createFromCurrent(User $user, $invertdetail=0) + { + global $conf; - // Retreive all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); + // Charge facture source + $facture=new Facture($this->db); - if (!empty($this->array_options)) { - $facture->array_options = $this->array_options; + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + + if(!empty($this->array_options)){ + $facture->array_options = $this->array_options; } - foreach ($this->lines as &$line) { - $line->fetch_optionals(); //fetch extrafields + foreach($this->lines as &$line){ + $line->fetch_optionals();//fetch extrafields } - $facture->fk_facture_source = $this->fk_facture_source; - $facture->type = $this->type; - $facture->socid = $this->socid; - $facture->date = $this->date; - $facture->date_pointoftax = $this->date_pointoftax; - $facture->note_public = $this->note_public; - $facture->note_private = $this->note_private; - $facture->ref_client = $this->ref_client; - $facture->modelpdf = $this->modelpdf; - $facture->fk_project = $this->fk_project; - $facture->cond_reglement_id = $this->cond_reglement_id; - $facture->mode_reglement_id = $this->mode_reglement_id; - $facture->remise_absolue = $this->remise_absolue; - $facture->remise_percent = $this->remise_percent; + $facture->fk_facture_source = $this->fk_facture_source; + $facture->type = $this->type; + $facture->socid = $this->socid; + $facture->date = $this->date; + $facture->date_pointoftax = $this->date_pointoftax; + $facture->note_public = $this->note_public; + $facture->note_private = $this->note_private; + $facture->ref_client = $this->ref_client; + $facture->modelpdf = $this->modelpdf; + $facture->fk_project = $this->fk_project; + $facture->cond_reglement_id = $this->cond_reglement_id; + $facture->mode_reglement_id = $this->mode_reglement_id; + $facture->remise_absolue = $this->remise_absolue; + $facture->remise_percent = $this->remise_percent; - $facture->origin = $this->origin; - $facture->origin_id = $this->origin_id; + $facture->origin = $this->origin; + $facture->origin_id = $this->origin_id; - $facture->lines = $this->lines; // Tableau des lignes de factures - $facture->products = $this->lines; // Tant que products encore utilise - $facture->situation_counter = $this->situation_counter; - $facture->situation_cycle_ref = $this->situation_cycle_ref; - $facture->situation_final = $this->situation_final; + $facture->lines = $this->lines; // Tableau des lignes de factures + $facture->products = $this->lines; // Tant que products encore utilise + $facture->situation_counter = $this->situation_counter; + $facture->situation_cycle_ref=$this->situation_cycle_ref; + $facture->situation_final = $this->situation_final; - // Loop on each line of new invoice - foreach ($facture->lines as $i => $tmpline) { - $facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid; - if ($invertdetail) { - $facture->lines[$i]->subprice = -$facture->lines[$i]->subprice; - $facture->lines[$i]->total_ht = -$facture->lines[$i]->total_ht; - $facture->lines[$i]->total_tva = -$facture->lines[$i]->total_tva; - $facture->lines[$i]->total_localtax1 = -$facture->lines[$i]->total_localtax1; - $facture->lines[$i]->total_localtax2 = -$facture->lines[$i]->total_localtax2; - $facture->lines[$i]->total_ttc = -$facture->lines[$i]->total_ttc; - } - } + // Loop on each line of new invoice + foreach($facture->lines as $i => $tmpline) + { + $facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid; + if ($invertdetail) + { + $facture->lines[$i]->subprice = -$facture->lines[$i]->subprice; + $facture->lines[$i]->total_ht = -$facture->lines[$i]->total_ht; + $facture->lines[$i]->total_tva = -$facture->lines[$i]->total_tva; + $facture->lines[$i]->total_localtax1 = -$facture->lines[$i]->total_localtax1; + $facture->lines[$i]->total_localtax2 = -$facture->lines[$i]->total_localtax2; + $facture->lines[$i]->total_ttc = -$facture->lines[$i]->total_ttc; + } + } - dol_syslog(get_class($this) . "::createFromCurrent invertdetail=" . $invertdetail . " socid=" . $this->socid . " nboflines=" . count($facture->lines)); + dol_syslog(get_class($this)."::createFromCurrent invertdetail=".$invertdetail." socid=".$this->socid." nboflines=".count($facture->lines)); - $facid = $facture->create($user); - if ($facid <= 0) { - $this->error = $facture->error; - $this->errors = $facture->errors; - } elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) { - $this->fetchObjectLinked('', '', $facture->id, 'facture'); + $facid = $facture->create($user); + if ($facid <= 0) + { + $this->error=$facture->error; + $this->errors=$facture->errors; + } + elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) + { + $this->fetchObjectLinked('', '', $facture->id, 'facture'); - foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) { - foreach ($Tfk_object as $fk_object) { - $facture->add_object_linked($typeObject, $fk_object); - } - } + foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) + { + foreach ($Tfk_object as $fk_object) + { + $facture->add_object_linked($typeObject, $fk_object); + } + } - $facture->add_object_linked('facture', $this->fk_facture_source); - } + $facture->add_object_linked('facture', $this->fk_facture_source); + } - return $facid; - } + return $facid; + } - /** - * Load an object from its id and create a new one in database - * - * @param int $socid Id of thirdparty - * @return int New id of clone - */ - function createFromClone($socid = 0) { - global $user, $hookmanager; - $error = 0; + /** + * Load an object from its id and create a new one in database + * + * @param int $socid Id of thirdparty + * @return int New id of clone + */ + function createFromClone($socid=0) + { + global $user,$hookmanager; - $this->context['createfromclone'] = 'createfromclone'; + $error=0; - $this->db->begin(); + $this->context['createfromclone'] = 'createfromclone'; - // get extrafields so they will be clone - foreach ($this->lines as $line) - $line->fetch_optionals($line->rowid); + $this->db->begin(); - // Load source object - $objFrom = clone $this; + // get extrafields so they will be clone + foreach($this->lines as $line) + $line->fetch_optionals($line->rowid); + + // Load source object + $objFrom = clone $this; - // Change socid if needed - if (!empty($socid) && $socid != $this->socid) { - $objsoc = new Societe($this->db); + // Change socid if needed + if (! empty($socid) && $socid != $this->socid) + { + $objsoc = new Societe($this->db); - if ($objsoc->fetch($socid) > 0) { - $this->socid = $objsoc->id; - $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $this->fk_project = ''; - $this->fk_delivery_address = ''; - } + if ($objsoc->fetch($socid)>0) + { + $this->socid = $objsoc->id; + $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $this->fk_project = ''; + $this->fk_delivery_address = ''; + } - // TODO Change product price if multi-prices - } + // TODO Change product price if multi-prices + } - $this->id = 0; - $this->statut = self::STATUS_DRAFT; + $this->id=0; + $this->statut= self::STATUS_DRAFT; - // Clear fields - $this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box - $this->user_author = $user->id; - $this->user_valid = ''; - $this->fk_facture_source = 0; - $this->date_creation = ''; - $this->date_validation = ''; - $this->ref_client = ''; - $this->close_code = ''; - $this->close_note = ''; - $this->products = $this->lines; // Tant que products encore utilise - // Loop on each line of new invoice - foreach ($this->lines as $i => $line) { - if (($this->lines[$i]->info_bits & 0x02) == 0x02) { // We do not clone line of discounts - unset($this->lines[$i]); - unset($this->products[$i]); // Tant que products encore utilise - } - } + // Clear fields + $this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box + $this->user_author = $user->id; + $this->user_valid = ''; + $this->fk_facture_source = 0; + $this->date_creation = ''; + $this->date_validation = ''; + $this->ref_client = ''; + $this->close_code = ''; + $this->close_note = ''; + $this->products = $this->lines; // Tant que products encore utilise - // Create clone - $result = $this->create($user); - if ($result < 0) - $error++; - else { - // copy internal contacts - if ($this->copy_linked_contact($objFrom, 'internal') < 0) - $error++; + // Loop on each line of new invoice + foreach($this->lines as $i => $line) + { + if (($this->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts + { + unset($this->lines[$i]); + unset($this->products[$i]); // Tant que products encore utilise + } + } - // copy external contacts if same company - elseif ($objFrom->socid == $this->socid) { - if ($this->copy_linked_contact($objFrom, 'external') < 0) - $error++; - } - } + // Create clone + $result=$this->create($user); + if ($result < 0) $error++; + else { + // copy internal contacts + if ($this->copy_linked_contact($objFrom, 'internal') < 0) + $error++; - if (!$error) { - // Hook of thirdparty module - if (is_object($hookmanager)) { - $parameters = array('objFrom' => $objFrom); - $action = ''; - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) - $error++; - } - } + // copy external contacts if same company + elseif ($objFrom->socid == $this->socid) + { + if ($this->copy_linked_contact($objFrom, 'external') < 0) + $error++; + } + } - unset($this->context['createfromclone']); + if (! $error) + { + // Hook of thirdparty module + if (is_object($hookmanager)) + { + $parameters=array('objFrom'=>$objFrom); + $action=''; + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; + } + } - // End - if (!$error) { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -1; - } - } + unset($this->context['createfromclone']); - /** - * Load an object from an order and create a new invoice into database - * - * @param Object $object Object source - * @param User $user Object user - * @return int <0 if KO, 0 if nothing done, 1 if OK - */ - function createFromOrder($object, User $user) { - global $hookmanager; + // End + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -1; + } + } - $error = 0; + /** + * Load an object from an order and create a new invoice into database + * + * @param Object $object Object source + * @param User $user Object user + * @return int <0 if KO, 0 if nothing done, 1 if OK + */ + function createFromOrder($object, User $user) + { + global $hookmanager; - // Closed order - $this->date = dol_now(); - $this->source = 0; + $error=0; - $num = count($object->lines); - for ($i = 0; $i < $num; $i++) { - $line = new FactureLigne($this->db); + // Closed order + $this->date = dol_now(); + $this->source = 0; - $line->libelle = $object->lines[$i]->libelle; - $line->label = $object->lines[$i]->label; - $line->desc = $object->lines[$i]->desc; - $line->subprice = $object->lines[$i]->subprice; - $line->total_ht = $object->lines[$i]->total_ht; - $line->total_tva = $object->lines[$i]->total_tva; - $line->total_localtax1 = $object->lines[$i]->total_localtax1; - $line->total_localtax2 = $object->lines[$i]->total_localtax2; - $line->total_ttc = $object->lines[$i]->total_ttc; - $line->vat_src_code = $object->lines[$i]->vat_src_code; - $line->tva_tx = $object->lines[$i]->tva_tx; - $line->localtax1_tx = $object->lines[$i]->localtax1_tx; - $line->localtax2_tx = $object->lines[$i]->localtax2_tx; - $line->qty = $object->lines[$i]->qty; - $line->fk_remise_except = $object->lines[$i]->fk_remise_except; - $line->remise_percent = $object->lines[$i]->remise_percent; - $line->fk_product = $object->lines[$i]->fk_product; - $line->info_bits = $object->lines[$i]->info_bits; - $line->product_type = $object->lines[$i]->product_type; - $line->rang = $object->lines[$i]->rang; - $line->special_code = $object->lines[$i]->special_code; - $line->fk_parent_line = $object->lines[$i]->fk_parent_line; - $line->fk_unit = $object->lines[$i]->fk_unit; - $line->date_start = $object->lines[$i]->date_start; - $line->date_end = $object->lines[$i]->date_end; + $num=count($object->lines); + for ($i = 0; $i < $num; $i++) + { + $line = new FactureLigne($this->db); - $line->fk_fournprice = $object->lines[$i]->fk_fournprice; - $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); - $line->pa_ht = $marginInfos[0]; + $line->libelle = $object->lines[$i]->libelle; + $line->label = $object->lines[$i]->label; + $line->desc = $object->lines[$i]->desc; + $line->subprice = $object->lines[$i]->subprice; + $line->total_ht = $object->lines[$i]->total_ht; + $line->total_tva = $object->lines[$i]->total_tva; + $line->total_localtax1 = $object->lines[$i]->total_localtax1; + $line->total_localtax2 = $object->lines[$i]->total_localtax2; + $line->total_ttc = $object->lines[$i]->total_ttc; + $line->vat_src_code = $object->lines[$i]->vat_src_code; + $line->tva_tx = $object->lines[$i]->tva_tx; + $line->localtax1_tx = $object->lines[$i]->localtax1_tx; + $line->localtax2_tx = $object->lines[$i]->localtax2_tx; + $line->qty = $object->lines[$i]->qty; + $line->fk_remise_except = $object->lines[$i]->fk_remise_except; + $line->remise_percent = $object->lines[$i]->remise_percent; + $line->fk_product = $object->lines[$i]->fk_product; + $line->info_bits = $object->lines[$i]->info_bits; + $line->product_type = $object->lines[$i]->product_type; + $line->rang = $object->lines[$i]->rang; + $line->special_code = $object->lines[$i]->special_code; + $line->fk_parent_line = $object->lines[$i]->fk_parent_line; + $line->fk_unit = $object->lines[$i]->fk_unit; + $line->date_start = $object->lines[$i]->date_start; + $line->date_end = $object->lines[$i]->date_end; + + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; + $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); + $line->pa_ht = $marginInfos[0]; // get extrafields from original line - $object->lines[$i]->fetch_optionals(); - foreach ($object->lines[$i]->array_options as $options_key => $value) - $line->array_options[$options_key] = $value; + $object->lines[$i]->fetch_optionals(); + foreach($object->lines[$i]->array_options as $options_key => $value) + $line->array_options[$options_key] = $value; - $this->lines[$i] = $line; - } + $this->lines[$i] = $line; + } - $this->socid = $object->socid; - $this->fk_project = $object->fk_project; - $this->cond_reglement_id = $object->cond_reglement_id; - $this->mode_reglement_id = $object->mode_reglement_id; - $this->availability_id = $object->availability_id; - $this->demand_reason_id = $object->demand_reason_id; - $this->date_livraison = $object->date_livraison; - $this->fk_delivery_address = $object->fk_delivery_address; - $this->contact_id = $object->contactid; - $this->ref_client = $object->ref_client; - $this->note_private = $object->note_private; - $this->note_public = $object->note_public; + $this->socid = $object->socid; + $this->fk_project = $object->fk_project; + $this->cond_reglement_id = $object->cond_reglement_id; + $this->mode_reglement_id = $object->mode_reglement_id; + $this->availability_id = $object->availability_id; + $this->demand_reason_id = $object->demand_reason_id; + $this->date_livraison = $object->date_livraison; + $this->fk_delivery_address = $object->fk_delivery_address; + $this->contact_id = $object->contactid; + $this->ref_client = $object->ref_client; + $this->note_private = $object->note_private; + $this->note_public = $object->note_public; - $this->origin = $object->element; - $this->origin_id = $object->id; + $this->origin = $object->element; + $this->origin_id = $object->id; // get extrafields from original line - $object->fetch_optionals($object->id); - foreach ($object->array_options as $options_key => $value) - $this->array_options[$options_key] = $value; + $object->fetch_optionals($object->id); + foreach($object->array_options as $options_key => $value) + $this->array_options[$options_key] = $value; - // Possibility to add external linked objects with hooks - $this->linked_objects[$this->origin] = $this->origin_id; - if (!empty($object->other_linked_objects) && is_array($object->other_linked_objects)) { - $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); - } + // Possibility to add external linked objects with hooks + $this->linked_objects[$this->origin] = $this->origin_id; + if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) + { + $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); + } - $ret = $this->create($user); + $ret = $this->create($user); - if ($ret > 0) { - // Actions hooked (by external module) - $hookmanager->initHooks(array('invoicedao')); + if ($ret > 0) + { + // Actions hooked (by external module) + $hookmanager->initHooks(array('invoicedao')); - $parameters = array('objFrom' => $object); - $action = ''; - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) - $error++; + $parameters=array('objFrom'=>$object); + $action=''; + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; - if (!$error) { - return 1; - } else - return -1; - } else - return -1; - } + if (! $error) + { + return 1; + } + else return -1; + } + else return -1; + } - /** - * Return link to download file from a direct external access - * - * @param int $withpicto Add download picto into link - * @return string HTML link to file - */ - function getDirectExternalLink($withpicto = 0) { - global $dolibarr_main_url_root; + /** + * Return link to download file from a direct external access + * + * @param int $withpicto Add download picto into link + * @return string HTML link to file + */ + function getDirectExternalLink($withpicto=0) + { + global $dolibarr_main_url_root; - // Define $urlwithroot - $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - // TODO Read into ecmfile table to get entry and hash exists (PS: If not found, add it) - include_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php'; - $ecmfile = new EcmFiles($this->db); - //$result = $ecmfile->get(); + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $hashp = 'todo'; - return '' . $this->ref . ''; - } + // TODO Read into ecmfile table to get entry and hash exists (PS: If not found, add it) + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($this->db); + //$result = $ecmfile->get(); - /** - * Return clicable link of object (with eventually picto) - * - * @param int $withpicto Add picto into link - * @param string $option Where point the link - * @param int $max Maxlength of ref - * @param int $short 1=Return just URL - * @param string $moretitle Add more text to title tooltip + $hashp='todo'; + return ''.$this->ref.''; + } + + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param string $option Where point the link + * @param int $max Maxlength of ref + * @param int $short 1=Return just URL + * @param string $moretitle Add more text to title tooltip * @param int $notooltip 1=Disable tooltip * @param int $addlinktonotes 1=Add link to notes * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1) { - global $langs, $conf, $user, $form; + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $moretitle='', $notooltip=0, $addlinktonotes=0, $save_lastsearch_value=-1) + { + global $langs, $conf, $user, $form; - if (!empty($conf->dol_no_mouse_hover)) - $notooltip = 1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $result = ''; + $result=''; - if ($option == 'withdraw') - $url = DOL_URL_ROOT . '/compta/facture/prelevement.php?facid=' . $this->id; - else - $url = DOL_URL_ROOT . '/compta/facture/card.php?facid=' . $this->id; + if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; + else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; if (!$user->rights->facture->lire) $option = 'nolink'; - if ($short) - return $url; + if ($option !== 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } - if ($option !== 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) - $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) - $url .= '&save_lastsearch_values=1'; - } - - $picto = 'bill'; - if ($this->type == self::TYPE_REPLACEMENT) - $picto .= 'r'; // Replacement invoice - if ($this->type == self::TYPE_CREDIT_NOTE) - $picto .= 'a'; // Credit note - if ($this->type == self::TYPE_DEPOSIT) - $picto .= 'd'; // Deposit invoice - $label = ''; + $picto='bill'; + if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice + if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note + if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice + $label=''; if ($user->rights->facture->lire) { $label = '' . $langs->trans("ShowInvoice") . ''; - if (!empty($this->ref)) - $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; - if (!empty($this->ref_client)) + if (! empty($this->ref)) + $label .= '
'.$langs->trans('Ref') . ': ' . $this->ref; + if (! empty($this->ref_client)) $label .= '
' . $langs->trans('RefCustomer') . ': ' . $this->ref_client; - if (!empty($this->total_ht)) - $label .= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_tva)) - $label .= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_localtax1)) - $label .= '
' . $langs->trans('LT1') . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_localtax2)) - $label .= '
' . $langs->trans('LT2') . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_ttc)) - $label .= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if ($this->type == self::TYPE_REPLACEMENT) - $label = $langs->transnoentitiesnoconv("ShowInvoiceReplace") . ': ' . $this->ref; - if ($this->type == self::TYPE_CREDIT_NOTE) - $label = $langs->transnoentitiesnoconv("ShowInvoiceAvoir") . ': ' . $this->ref; - if ($this->type == self::TYPE_DEPOSIT) - $label = $langs->transnoentitiesnoconv("ShowInvoiceDeposit") . ': ' . $this->ref; - if ($this->type == self::TYPE_SITUATION) - $label = $langs->transnoentitiesnoconv("ShowInvoiceSituation") . ': ' . $this->ref; - if ($moretitle) - $label .= ' - ' . $moretitle; + if (! empty($this->total_ht)) + $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + if (! empty($this->total_tva)) + $label.= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + if (! empty($this->total_localtax1)) + $label.= '
' . $langs->trans('LT1') . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); + if (! empty($this->total_localtax2)) + $label.= '
' . $langs->trans('LT2') . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); + if (! empty($this->total_ttc)) + $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; + if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; + if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; + if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; + if ($moretitle) $label.=' - '.$moretitle; } - $linkclose = ''; - if (empty($notooltip) && $user->rights->facture->lire) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label = $langs->trans("ShowInvoice"); - $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; - } - $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose=''; + if (empty($notooltip) && $user->rights->facture->lire) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowInvoice"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip"'; + } - $linkstart = ''; - $linkend = ''; + $linkstart=''; + $linkend=''; if ($option == 'nolink') { $linkstart = ''; $linkend = ''; } - $result .= $linkstart; - if ($withpicto) - $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="' . (($withpicto != 2) ? 'paddingright ' : '') . 'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) - $result .= ($max ? dol_trunc($this->ref, $max) : $this->ref); - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref,$max):$this->ref); + $result .= $linkend; - if ($addlinktonotes) { - $txttoshow = ($user->societe_id > 0 ? $this->note_public : $this->note_private); - if ($txttoshow) { - $notetoshow = $langs->trans("ViewPrivateNote") . ':
' . dol_string_nohtmltag($txttoshow, 1); - $result .= ' '; - $result .= '' . img_picto('', 'object_generic') . ''; - //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); - //$result.=''; - $result .= ''; - } - } + if ($addlinktonotes) + { + $txttoshow=($user->societe_id>0?$this->note_public:$this->note_private); + if ($txttoshow) + { + $notetoshow=$langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow,1); + $result.=' '; + $result.=''.img_picto('','object_generic').''; + //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); + //$result.=''; + $result.=''; + } + } - return $result; - } + return $result; + } - /** - * Get object and lines from database - * - * @param int $rowid Id of object to load - * @param string $ref Reference of invoice - * @param string $ref_ext External reference of invoice - * @param int $ref_int Internal reference of other object - * @param bool $fetch_situation Fetch the previous and next situation in $tab_previous_situation_invoice and $tab_next_situation_invoice - * @return int >0 if OK, <0 if KO, 0 if not found - */ - function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_situation = false) { - global $conf; + /** + * Get object and lines from database + * + * @param int $rowid Id of object to load + * @param string $ref Reference of invoice + * @param string $ref_ext External reference of invoice + * @param int $ref_int Internal reference of other object + * @param bool $fetch_situation Fetch the previous and next situation in $tab_previous_situation_invoice and $tab_next_situation_invoice + * @return int >0 if OK, <0 if KO, 0 if not found + */ + function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false) + { + global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) - return -1; + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT f.rowid,f.entity,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; - $sql .= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; - $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; - $sql .= ', f.datef as df, f.date_pointoftax'; - $sql .= ', f.date_lim_reglement as dlr'; - $sql .= ', f.datec as datec'; - $sql .= ', f.date_valid as datev'; - $sql .= ', f.tms as datem'; - $sql .= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc'; - $sql .= ', f.fk_facture_source'; - $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; - $sql .= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; - $sql .= ', f.fk_account'; - $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; - $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; - $sql .= ', f.fk_incoterms, f.location_incoterms'; - $sql .= ", i.libelle as libelle_incoterms"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as p ON f.fk_mode_reglement = p.id'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_incoterms as i ON f.fk_incoterms = i.rowid'; + $sql = 'SELECT f.rowid,f.entity,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; + $sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; + $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; + $sql.= ', f.datef as df, f.date_pointoftax'; + $sql.= ', f.date_lim_reglement as dlr'; + $sql.= ', f.datec as datec'; + $sql.= ', f.date_valid as datev'; + $sql.= ', f.tms as datem'; + $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc'; + $sql.= ', f.fk_facture_source'; + $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; + $sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; + $sql.= ', f.fk_account'; + $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; + $sql.= ', f.fk_incoterms, f.location_incoterms'; + $sql.= ", i.libelle as libelle_incoterms"; + $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; - if ($rowid) - $sql .= " WHERE f.rowid=" . $rowid; - else - $sql .= ' WHERE f.entity IN (' . getEntity('facture') . ')'; // Dont't use entity if you use rowid + if ($rowid) $sql.= " WHERE f.rowid=".$rowid; + else $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; // Dont't use entity if you use rowid - if ($ref) - $sql .= " AND f.facnumber='" . $this->db->escape($ref) . "'"; - if ($ref_ext) - $sql .= " AND f.ref_ext='" . $this->db->escape($ref_ext) . "'"; - if ($ref_int) - $sql .= " AND f.ref_int='" . $this->db->escape($ref_int) . "'"; + if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; - dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - $this->entity = $obj->entity; + $this->id = $obj->rowid; + $this->entity = $obj->entity; - $this->ref = $obj->facnumber; - $this->ref_client = $obj->ref_client; - $this->ref_ext = $obj->ref_ext; - $this->ref_int = $obj->ref_int; - $this->type = $obj->type; - $this->date = $this->db->jdate($obj->df); - $this->date_pointoftax = $this->db->jdate($obj->date_pointoftax); - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_validation = $this->db->jdate($obj->datev); - $this->datem = $this->db->jdate($obj->datem); - $this->remise_percent = $obj->remise_percent; - $this->remise_absolue = $obj->remise_absolue; - $this->total_ht = $obj->total; - $this->total_tva = $obj->tva; - $this->total_localtax1 = $obj->localtax1; - $this->total_localtax2 = $obj->localtax2; - $this->total_ttc = $obj->total_ttc; - $this->revenuestamp = $obj->revenuestamp; - $this->paye = $obj->paye; - $this->close_code = $obj->close_code; - $this->close_note = $obj->close_note; - $this->socid = $obj->fk_soc; - $this->statut = $obj->fk_statut; - $this->date_lim_reglement = $this->db->jdate($obj->dlr); - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->mode_reglement_code = $obj->mode_reglement_code; - $this->mode_reglement = $obj->mode_reglement_libelle; - $this->cond_reglement_id = $obj->fk_cond_reglement; - $this->cond_reglement_code = $obj->cond_reglement_code; - $this->cond_reglement = $obj->cond_reglement_libelle; - $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; - $this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null; - $this->fk_project = $obj->fk_projet; - $this->fk_facture_source = $obj->fk_facture_source; - $this->note = $obj->note_private; // deprecated - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->user_author = $obj->fk_user_author; - $this->user_valid = $obj->fk_user_valid; - $this->modelpdf = $obj->model_pdf; - $this->last_main_doc = $obj->last_main_doc; - $this->situation_cycle_ref = $obj->situation_cycle_ref; - $this->situation_counter = $obj->situation_counter; - $this->situation_final = $obj->situation_final; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->ref = $obj->facnumber; + $this->ref_client = $obj->ref_client; + $this->ref_ext = $obj->ref_ext; + $this->ref_int = $obj->ref_int; + $this->type = $obj->type; + $this->date = $this->db->jdate($obj->df); + $this->date_pointoftax = $this->db->jdate($obj->date_pointoftax); + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_validation = $this->db->jdate($obj->datev); + $this->datem = $this->db->jdate($obj->datem); + $this->remise_percent = $obj->remise_percent; + $this->remise_absolue = $obj->remise_absolue; + $this->total_ht = $obj->total; + $this->total_tva = $obj->tva; + $this->total_localtax1 = $obj->localtax1; + $this->total_localtax2 = $obj->localtax2; + $this->total_ttc = $obj->total_ttc; + $this->revenuestamp = $obj->revenuestamp; + $this->paye = $obj->paye; + $this->close_code = $obj->close_code; + $this->close_note = $obj->close_note; + $this->socid = $obj->fk_soc; + $this->statut = $obj->fk_statut; + $this->date_lim_reglement = $this->db->jdate($obj->dlr); + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement_libelle; + $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->cond_reglement_code = $obj->cond_reglement_code; + $this->cond_reglement = $obj->cond_reglement_libelle; + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + $this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null; + $this->fk_project = $obj->fk_projet; + $this->fk_facture_source = $obj->fk_facture_source; + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->user_author = $obj->fk_user_author; + $this->user_valid = $obj->fk_user_valid; + $this->modelpdf = $obj->model_pdf; + $this->last_main_doc = $obj->last_main_doc; + $this->situation_cycle_ref = $obj->situation_cycle_ref; + $this->situation_counter = $obj->situation_counter; + $this->situation_final = $obj->situation_final; + $this->extraparams = (array) json_decode($obj->extraparams, true); - //Incoterms - $this->fk_incoterms = $obj->fk_incoterms; - $this->location_incoterms = $obj->location_incoterms; - $this->libelle_incoterms = $obj->libelle_incoterms; + //Incoterms + $this->fk_incoterms = $obj->fk_incoterms; + $this->location_incoterms = $obj->location_incoterms; + $this->libelle_incoterms = $obj->libelle_incoterms; - // Multicurrency - $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; - $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) { - $this->fetchPreviousNextSituationInvoice(); - } + if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) + { + $this->fetchPreviousNextSituationInvoice(); + } - if ($this->statut == self::STATUS_DRAFT) - $this->brouillon = 1; + if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; - // Retreive all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); - /* - * Lines - */ + /* + * Lines + */ - $this->lines = array(); + $this->lines = array(); - $result = $this->fetch_lines(); - if ($result < 0) { - $this->error = $this->db->error(); - return -3; - } - return 1; - } else { - $this->error = 'Bill with id=' . $rowid . ' or ref=' . $ref . ' or ref_ext=' . $ref_ext . ' not found'; - dol_syslog(get_class($this) . "::fetch Error " . $this->error, LOG_ERR); - return 0; - } - } else { - $this->error = $this->db->error(); - return -1; - } - } + $result=$this->fetch_lines(); + if ($result < 0) + { + $this->error=$this->db->error(); + return -3; + } + return 1; + } + else + { + $this->error='Bill with id='.$rowid.' or ref='.$ref.' or ref_ext='.$ref_ext.' not found'; + dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); + return 0; + } + } + else + { + $this->error=$this->db->error(); + return -1; + } + } - /** - * Load all detailed lines into this->lines - * - * @return int 1 if OK, < 0 if KO - */ - function fetch_lines() { - $this->lines = array(); - $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql .= ' l.situation_percent, l.fk_prev_id,'; - $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; - $sql .= ' l.rang, l.special_code,'; - $sql .= ' l.date_start as date_start, l.date_end as date_end,'; - $sql .= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; - $sql .= ' l.fk_unit,'; - $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; - $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facturedet as l'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p ON l.fk_product = p.rowid'; - $sql .= ' WHERE l.fk_facture = ' . $this->id; - $sql .= ' ORDER BY l.rang, l.rowid'; + /** + * Load all detailed lines into this->lines + * + * @return int 1 if OK, < 0 if KO + */ + function fetch_lines() + { + $this->lines=array(); - dol_syslog(get_class($this) . '::fetch_lines', LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $this->db->fetch_object($result); - $line = new FactureLigne($this->db); + $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; + $sql.= ' l.situation_percent, l.fk_prev_id,'; + $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; + $sql.= ' l.rang, l.special_code,'; + $sql.= ' l.date_start as date_start, l.date_end as date_end,'; + $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; + $sql.= ' l.fk_unit,'; + $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; + $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql.= ' WHERE l.fk_facture = '.$this->id; + $sql.= ' ORDER BY l.rang, l.rowid'; - $line->id = $objp->rowid; - $line->rowid = $objp->rowid; // deprecated - $line->fk_facture = $objp->fk_facture; - $line->label = $objp->custom_label; // deprecated - $line->desc = $objp->description; // Description line - $line->description = $objp->description; // Description line - $line->product_type = $objp->product_type; // Type of line - $line->ref = $objp->product_ref; // Ref product - $line->product_ref = $objp->product_ref; // Ref product - $line->libelle = $objp->product_label; // TODO deprecated - $line->product_label = $objp->product_label; // Label product - $line->product_desc = $objp->product_desc; // Description product - $line->fk_product_type = $objp->fk_product_type; // Type of product - $line->qty = $objp->qty; - $line->subprice = $objp->subprice; + dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) + { + $objp = $this->db->fetch_object($result); + $line = new FactureLigne($this->db); - $line->vat_src_code = $objp->vat_src_code; - $line->tva_tx = $objp->tva_tx; - $line->localtax1_tx = $objp->localtax1_tx; - $line->localtax2_tx = $objp->localtax2_tx; - $line->localtax1_type = $objp->localtax1_type; - $line->localtax2_type = $objp->localtax2_type; - $line->remise_percent = $objp->remise_percent; - $line->fk_remise_except = $objp->fk_remise_except; - $line->fk_product = $objp->fk_product; - $line->date_start = $this->db->jdate($objp->date_start); - $line->date_end = $this->db->jdate($objp->date_end); - $line->date_start = $this->db->jdate($objp->date_start); - $line->date_end = $this->db->jdate($objp->date_end); - $line->info_bits = $objp->info_bits; - $line->total_ht = $objp->total_ht; - $line->total_tva = $objp->total_tva; - $line->total_localtax1 = $objp->total_localtax1; - $line->total_localtax2 = $objp->total_localtax2; - $line->total_ttc = $objp->total_ttc; - $line->code_ventilation = $objp->fk_code_ventilation; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; - $line->marge_tx = $marginInfos[1]; - $line->marque_tx = $marginInfos[2]; - $line->rang = $objp->rang; - $line->special_code = $objp->special_code; - $line->fk_parent_line = $objp->fk_parent_line; - $line->situation_percent = $objp->situation_percent; - $line->fk_prev_id = $objp->fk_prev_id; - $line->fk_unit = $objp->fk_unit; + $line->id = $objp->rowid; + $line->rowid = $objp->rowid; // deprecated + $line->fk_facture = $objp->fk_facture; + $line->label = $objp->custom_label; // deprecated + $line->desc = $objp->description; // Description line + $line->description = $objp->description; // Description line + $line->product_type = $objp->product_type; // Type of line + $line->ref = $objp->product_ref; // Ref product + $line->product_ref = $objp->product_ref; // Ref product + $line->libelle = $objp->product_label; // TODO deprecated + $line->product_label = $objp->product_label; // Label product + $line->product_desc = $objp->product_desc; // Description product + $line->fk_product_type = $objp->fk_product_type; // Type of product + $line->qty = $objp->qty; + $line->subprice = $objp->subprice; - // Accountancy - $line->fk_accounting_account = $objp->fk_code_ventilation; + $line->vat_src_code = $objp->vat_src_code; + $line->tva_tx = $objp->tva_tx; + $line->localtax1_tx = $objp->localtax1_tx; + $line->localtax2_tx = $objp->localtax2_tx; + $line->localtax1_type = $objp->localtax1_type; + $line->localtax2_type = $objp->localtax2_type; + $line->remise_percent = $objp->remise_percent; + $line->fk_remise_except = $objp->fk_remise_except; + $line->fk_product = $objp->fk_product; + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); + $line->info_bits = $objp->info_bits; + $line->total_ht = $objp->total_ht; + $line->total_tva = $objp->total_tva; + $line->total_localtax1 = $objp->total_localtax1; + $line->total_localtax2 = $objp->total_localtax2; + $line->total_ttc = $objp->total_ttc; + $line->code_ventilation = $objp->fk_code_ventilation; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; + $line->rang = $objp->rang; + $line->special_code = $objp->special_code; + $line->fk_parent_line = $objp->fk_parent_line; + $line->situation_percent= $objp->situation_percent; + $line->fk_prev_id = $objp->fk_prev_id; + $line->fk_unit = $objp->fk_unit; - // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; - $line->multicurrency_subprice = $objp->multicurrency_subprice; - $line->multicurrency_total_ht = $objp->multicurrency_total_ht; - $line->multicurrency_total_tva = $objp->multicurrency_total_tva; - $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + // Accountancy + $line->fk_accounting_account = $objp->fk_code_ventilation; - // TODO Fetch optional like done in fetch line of facture_rec ? + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $this->lines[$i] = $line; + // TODO Fetch optional like done in fetch line of facture_rec ? - $i++; - } - $this->db->free($result); - return 1; - } else { - $this->error = $this->db->error(); - return -3; - } - } + $this->lines[$i] = $line; - /** - * Fetch previous and next situations invoices - * - * @return void - */ - function fetchPreviousNextSituationInvoice() { - global $conf; + $i++; + } + $this->db->free($result); + return 1; + } + else + { + $this->error=$this->db->error(); + return -3; + } + } - $this->tab_previous_situation_invoice = array(); - $this->tab_next_situation_invoice = array(); + /** + * Fetch previous and next situations invoices + * + * @return void + */ + function fetchPreviousNextSituationInvoice() + { + global $conf; - $sql = 'SELECT rowid, situation_counter FROM ' . MAIN_DB_PREFIX . 'facture WHERE rowid <> ' . $this->id . ' AND entity = ' . $conf->entity . ' AND situation_cycle_ref = ' . (int) $this->situation_cycle_ref . ' ORDER BY situation_counter ASC'; + $this->tab_previous_situation_invoice = array(); + $this->tab_next_situation_invoice = array(); - dol_syslog(get_class($this) . '::fetchPreviousNextSituationInvoice ', LOG_DEBUG); - $result = $this->db->query($sql); - if ($result && $this->db->num_rows($result) > 0) { - while ($objp = $this->db->fetch_object($result)) { - $invoice = new Facture($this->db); - if ($invoice->fetch($objp->rowid) > 0) { - if ($objp->situation_counter < $this->situation_counter || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes - ) { - $this->tab_previous_situation_invoice[] = $invoice; - } else { - $this->tab_next_situation_invoice[] = $invoice; - } - } - } - } - } + $sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture WHERE rowid <> '.$this->id.' AND entity = '.$conf->entity.' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref.' ORDER BY situation_counter ASC'; - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - function update(User $user, $notrigger = 0) { - $error = 0; + dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result && $this->db->num_rows($result) > 0) + { + while ($objp = $this->db->fetch_object($result)) + { + $invoice = new Facture($this->db); + if ($invoice->fetch($objp->rowid) > 0) + { + if ($objp->situation_counter < $this->situation_counter + || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes + ) + { + $this->tab_previous_situation_invoice[] = $invoice; + } + else + { + $this->tab_next_situation_invoice[] = $invoice; + } + } + } + } - // Clean parameters - if (empty($this->type)) - $this->type = self::TYPE_STANDARD; - if (isset($this->facnumber)) - $this->facnumber = trim($this->ref); - if (isset($this->ref_client)) - $this->ref_client = trim($this->ref_client); - if (isset($this->increment)) - $this->increment = trim($this->increment); - if (isset($this->close_code)) - $this->close_code = trim($this->close_code); - if (isset($this->close_note)) - $this->close_note = trim($this->close_note); - if (isset($this->note) || isset($this->note_private)) - $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated - if (isset($this->note) || isset($this->note_private)) - $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); - if (isset($this->note_public)) - $this->note_public = trim($this->note_public); - if (isset($this->modelpdf)) - $this->modelpdf = trim($this->modelpdf); - if (isset($this->import_key)) - $this->import_key = trim($this->import_key); + } - // Check parameters - // Put here code to add control on parameters values - // Update request - $sql = "UPDATE " . MAIN_DB_PREFIX . "facture SET"; - $sql .= " facnumber=" . (isset($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : "null") . ","; - $sql .= " type=" . (isset($this->type) ? $this->db->escape($this->type) : "null") . ","; - $sql .= " ref_client=" . (isset($this->ref_client) ? "'" . $this->db->escape($this->ref_client) . "'" : "null") . ","; - $sql .= " increment=" . (isset($this->increment) ? "'" . $this->db->escape($this->increment) . "'" : "null") . ","; - $sql .= " fk_soc=" . (isset($this->socid) ? $this->db->escape($this->socid) : "null") . ","; - $sql .= " datec=" . (strval($this->date_creation) != '' ? "'" . $this->db->idate($this->date_creation) . "'" : 'null') . ","; - $sql .= " datef=" . (strval($this->date) != '' ? "'" . $this->db->idate($this->date) . "'" : 'null') . ","; - $sql .= " date_pointoftax=" . (strval($this->date_pointoftax) != '' ? "'" . $this->db->idate($this->date_pointoftax) . "'" : 'null') . ","; - $sql .= " date_valid=" . (strval($this->date_validation) != '' ? "'" . $this->db->idate($this->date_validation) . "'" : 'null') . ","; - $sql .= " paye=" . (isset($this->paye) ? $this->db->escape($this->paye) : "null") . ","; - $sql .= " remise_percent=" . (isset($this->remise_percent) ? $this->db->escape($this->remise_percent) : "null") . ","; - $sql .= " remise_absolue=" . (isset($this->remise_absolue) ? $this->db->escape($this->remise_absolue) : "null") . ","; - $sql .= " close_code=" . (isset($this->close_code) ? "'" . $this->db->escape($this->close_code) . "'" : "null") . ","; - $sql .= " close_note=" . (isset($this->close_note) ? "'" . $this->db->escape($this->close_note) . "'" : "null") . ","; - $sql .= " tva=" . (isset($this->total_tva) ? $this->total_tva : "null") . ","; - $sql .= " localtax1=" . (isset($this->total_localtax1) ? $this->total_localtax1 : "null") . ","; - $sql .= " localtax2=" . (isset($this->total_localtax2) ? $this->total_localtax2 : "null") . ","; - $sql .= " total=" . (isset($this->total_ht) ? $this->total_ht : "null") . ","; - $sql .= " total_ttc=" . (isset($this->total_ttc) ? $this->total_ttc : "null") . ","; - $sql .= " revenuestamp=" . ((isset($this->revenuestamp) && $this->revenuestamp != '') ? $this->db->escape($this->revenuestamp) : "null") . ","; - $sql .= " fk_statut=" . (isset($this->statut) ? $this->db->escape($this->statut) : "null") . ","; - $sql .= " fk_user_author=" . (isset($this->user_author) ? $this->db->escape($this->user_author) : "null") . ","; - $sql .= " fk_user_valid=" . (isset($this->fk_user_valid) ? $this->db->escape($this->fk_user_valid) : "null") . ","; - $sql .= " fk_facture_source=" . (isset($this->fk_facture_source) ? $this->db->escape($this->fk_facture_source) : "null") . ","; - $sql .= " fk_projet=" . (isset($this->fk_project) ? $this->db->escape($this->fk_project) : "null") . ","; - $sql .= " fk_cond_reglement=" . (isset($this->cond_reglement_id) ? $this->db->escape($this->cond_reglement_id) : "null") . ","; - $sql .= " fk_mode_reglement=" . (isset($this->mode_reglement_id) ? $this->db->escape($this->mode_reglement_id) : "null") . ","; - $sql .= " date_lim_reglement=" . (strval($this->date_lim_reglement) != '' ? "'" . $this->db->idate($this->date_lim_reglement) . "'" : 'null') . ","; - $sql .= " note_private=" . (isset($this->note_private) ? "'" . $this->db->escape($this->note_private) . "'" : "null") . ","; - $sql .= " note_public=" . (isset($this->note_public) ? "'" . $this->db->escape($this->note_public) . "'" : "null") . ","; - $sql .= " model_pdf=" . (isset($this->modelpdf) ? "'" . $this->db->escape($this->modelpdf) . "'" : "null") . ","; - $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ","; - $sql .= " situation_cycle_ref=" . (empty($this->situation_cycle_ref) ? "null" : $this->db->escape($this->situation_cycle_ref)) . ","; - $sql .= " situation_counter=" . (empty($this->situation_counter) ? "null" : $this->db->escape($this->situation_counter)) . ","; - $sql .= " situation_final=" . (empty($this->situation_counter) ? "0" : $this->db->escape($this->situation_counter)); - $sql .= " WHERE rowid=" . $this->id; + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update(User $user, $notrigger=0) + { + $error=0; - $this->db->begin(); + // Clean parameters + if (empty($this->type)) $this->type= self::TYPE_STANDARD; + if (isset($this->facnumber)) $this->facnumber=trim($this->ref); + if (isset($this->ref_client)) $this->ref_client=trim($this->ref_client); + if (isset($this->increment)) $this->increment=trim($this->increment); + if (isset($this->close_code)) $this->close_code=trim($this->close_code); + if (isset($this->close_note)) $this->close_note=trim($this->close_note); + if (isset($this->note) || isset($this->note_private)) $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); + if (isset($this->note_public)) $this->note_public=trim($this->note_public); + if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); + if (isset($this->import_key)) $this->import_key=trim($this->import_key); - dol_syslog(get_class($this) . "::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = "Error " . $this->db->lasterror(); - } + // Check parameters + // Put here code to add control on parameters values - if (!$error) { - if (!$notrigger) { - // Call trigger - $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) - $error++; - // End call triggers - } - } + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET"; + $sql.= " facnumber=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; + $sql.= " type=".(isset($this->type)?$this->db->escape($this->type):"null").","; + $sql.= " ref_client=".(isset($this->ref_client)?"'".$this->db->escape($this->ref_client)."'":"null").","; + $sql.= " increment=".(isset($this->increment)?"'".$this->db->escape($this->increment)."'":"null").","; + $sql.= " fk_soc=".(isset($this->socid)?$this->db->escape($this->socid):"null").","; + $sql.= " datec=".(strval($this->date_creation)!='' ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; + $sql.= " datef=".(strval($this->date)!='' ? "'".$this->db->idate($this->date)."'" : 'null').","; + $sql.= " date_pointoftax=".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; + $sql.= " date_valid=".(strval($this->date_validation)!='' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; + $sql.= " paye=".(isset($this->paye)?$this->db->escape($this->paye):"null").","; + $sql.= " remise_percent=".(isset($this->remise_percent)?$this->db->escape($this->remise_percent):"null").","; + $sql.= " remise_absolue=".(isset($this->remise_absolue)?$this->db->escape($this->remise_absolue):"null").","; + $sql.= " close_code=".(isset($this->close_code)?"'".$this->db->escape($this->close_code)."'":"null").","; + $sql.= " close_note=".(isset($this->close_note)?"'".$this->db->escape($this->close_note)."'":"null").","; + $sql.= " tva=".(isset($this->total_tva)?$this->total_tva:"null").","; + $sql.= " localtax1=".(isset($this->total_localtax1)?$this->total_localtax1:"null").","; + $sql.= " localtax2=".(isset($this->total_localtax2)?$this->total_localtax2:"null").","; + $sql.= " total=".(isset($this->total_ht)?$this->total_ht:"null").","; + $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").","; + $sql.= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '')?$this->db->escape($this->revenuestamp):"null").","; + $sql.= " fk_statut=".(isset($this->statut)?$this->db->escape($this->statut):"null").","; + $sql.= " fk_user_author=".(isset($this->user_author)?$this->db->escape($this->user_author):"null").","; + $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->db->escape($this->fk_user_valid):"null").","; + $sql.= " fk_facture_source=".(isset($this->fk_facture_source)?$this->db->escape($this->fk_facture_source):"null").","; + $sql.= " fk_projet=".(isset($this->fk_project)?$this->db->escape($this->fk_project):"null").","; + $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->db->escape($this->cond_reglement_id):"null").","; + $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->db->escape($this->mode_reglement_id):"null").","; + $sql.= " date_lim_reglement=".(strval($this->date_lim_reglement)!='' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; + $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; + $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; + $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; + $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; + $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; + $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; + $sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter)); + $sql.= " WHERE rowid=".$this->id; - // Commit or rollback - if ($error) { - foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } + $this->db->begin(); - /** - * Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount) - * - * @param int $idremise Id of absolute discount - * @return int >0 if OK, <0 if KO - */ - function insert_discount($idremise) { - global $langs; + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } - include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; - include_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + } - $this->db->begin(); + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } - $remise = new DiscountAbsolute($this->db); - $result = $remise->fetch($idremise); - if ($result > 0) { - if ($remise->fk_facture) { // Protection against multiple submission - $this->error = $langs->trans("ErrorDiscountAlreadyUsed"); - $this->db->rollback(); - return -5; - } + /** + * Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount) + * + * @param int $idremise Id of absolute discount + * @return int >0 if OK, <0 if KO + */ + function insert_discount($idremise) + { + global $langs; - $facligne = new FactureLigne($this->db); - $facligne->fk_facture = $this->id; - $facligne->fk_remise_except = $remise->id; - $facligne->desc = $remise->description; // Description ligne - $facligne->vat_src_code = $remise->vat_src_code; - $facligne->tva_tx = $remise->tva_tx; - $facligne->subprice = -$remise->amount_ht; - $facligne->fk_product = 0; // Id produit predefini - $facligne->qty = 1; - $facligne->remise_percent = 0; - $facligne->rang = -1; - $facligne->info_bits = 2; + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - // Get buy/cost price of invoice that is source of discount - if ($remise->fk_facture_source > 0) { - $srcinvoice = new Facture($this->db); - $srcinvoice->fetch($remise->fk_facture_source); - $totalcostpriceofinvoice = 0; - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; // TODO Move this into commonobject - $formmargin = new FormMargin($this->db); - $arraytmp = $formmargin->getMarginInfosArray($srcinvoice, false); - $facligne->pa_ht = $arraytmp['pa_total']; - } + $this->db->begin(); - $facligne->total_ht = -$remise->amount_ht; - $facligne->total_tva = -$remise->amount_tva; - $facligne->total_ttc = -$remise->amount_ttc; + $remise=new DiscountAbsolute($this->db); + $result=$remise->fetch($idremise); - $facligne->multicurrency_subprice = -$remise->multicurrency_subprice; - $facligne->multicurrency_total_ht = -$remise->multicurrency_total_ht; - $facligne->multicurrency_total_tva = -$remise->multicurrency_total_tva; - $facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc; + if ($result > 0) + { + if ($remise->fk_facture) // Protection against multiple submission + { + $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); + $this->db->rollback(); + return -5; + } - $lineid = $facligne->insert(); - if ($lineid > 0) { - $result = $this->update_price(1); - if ($result > 0) { - // Create link between discount and invoice line - $result = $remise->link_to_invoice($lineid, 0); - if ($result < 0) { - $this->error = $remise->error; - $this->db->rollback(); - return -4; - } + $facligne=new FactureLigne($this->db); + $facligne->fk_facture=$this->id; + $facligne->fk_remise_except=$remise->id; + $facligne->desc=$remise->description; // Description ligne + $facligne->vat_src_code=$remise->vat_src_code; + $facligne->tva_tx=$remise->tva_tx; + $facligne->subprice = -$remise->amount_ht; + $facligne->fk_product=0; // Id produit predefini + $facligne->qty=1; + $facligne->remise_percent=0; + $facligne->rang=-1; + $facligne->info_bits=2; - $this->db->commit(); - return 1; - } else { - $this->error = $facligne->error; - $this->db->rollback(); - return -1; - } - } else { - $this->error = $facligne->error; - $this->db->rollback(); - return -2; - } - } else { - $this->db->rollback(); - return -3; - } - } + // Get buy/cost price of invoice that is source of discount + if ($remise->fk_facture_source > 0) + { + $srcinvoice=new Facture($this->db); + $srcinvoice->fetch($remise->fk_facture_source); + $totalcostpriceofinvoice=0; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject + $formmargin=new FormMargin($this->db); + $arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false); + $facligne->pa_ht = $arraytmp['pa_total']; + } - /** - * Set customer ref - * - * @param string $ref_client Customer ref - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >0 if OK - */ - function set_ref_client($ref_client, $notrigger = 0) { - global $user; + $facligne->total_ht = -$remise->amount_ht; + $facligne->total_tva = -$remise->amount_tva; + $facligne->total_ttc = -$remise->amount_ttc; - $error = 0; + $facligne->multicurrency_subprice = -$remise->multicurrency_subprice; + $facligne->multicurrency_total_ht = -$remise->multicurrency_total_ht; + $facligne->multicurrency_total_tva = -$remise->multicurrency_total_tva; + $facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc; - $this->db->begin(); + $lineid=$facligne->insert(); + if ($lineid > 0) + { + $result=$this->update_price(1); + if ($result > 0) + { + // Create link between discount and invoice line + $result=$remise->link_to_invoice($lineid,0); + if ($result < 0) + { + $this->error=$remise->error; + $this->db->rollback(); + return -4; + } - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; - if (empty($ref_client)) - $sql .= ' SET ref_client = NULL'; - else - $sql .= ' SET ref_client = \'' . $this->db->escape($ref_client) . '\''; - $sql .= ' WHERE rowid = ' . $this->id; + $this->db->commit(); + return 1; + } + else + { + $this->error=$facligne->error; + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$facligne->error; + $this->db->rollback(); + return -2; + } + } + else + { + $this->db->rollback(); + return -3; + } + } - dol_syslog(__METHOD__ . ' this->id=' . $this->id . ', ref_client=' . $ref_client, LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->errors[] = $this->db->error(); - $error++; - } + /** + * Set customer ref + * + * @param string $ref_client Customer ref + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK + */ + function set_ref_client($ref_client, $notrigger=0) + { + global $user; - if (!$error) { - $this->ref_client = $ref_client; - } + $error=0; - if (!$notrigger && empty($error)) { + $this->db->begin(); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; + if (empty($ref_client)) + $sql .= ' SET ref_client = NULL'; + else + $sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\''; + $sql .= ' WHERE rowid = '.$this->id; + + dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); + $resql=$this->db->query($sql); + if (!$resql) + { + $this->errors[]=$this->db->error(); + $error++; + } + + if (! $error) + { + $this->ref_client = $ref_client; + } + + if (! $notrigger && empty($error)) + { + // Call trigger + $result=$this->call_trigger('BILL_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + + if (! $error) + { + + $this->ref_client = $ref_client; + + $this->db->commit(); + return 1; + } + else + { + foreach($this->errors as $errmsg) + { + dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + } + + /** + * Delete invoice + * + * @param User $user User making the deletion. + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $idwarehouse Id warehouse to use for stock change. + * @return int <0 if KO, 0=Refused, >0 if OK + */ + function delete($user, $notrigger=0, $idwarehouse=-1) + { + global $langs,$conf; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $rowid=$this->id; + + dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG); + + // Test to avoid invoice deletion (allowed if draft) + $result = $this->is_erasable(); + + if ($result <= 0) return 0; + + $error=0; + + $this->db->begin(); + + if (! $error && ! $notrigger) + { // Call trigger - $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) - $error++; + $result=$this->call_trigger('BILL_DELETE',$user); + if ($result < 0) $error++; // End call triggers - } + } - if (!$error) { + // Removed extrafields + if (! $error) { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error deleteExtraFields ".$this->error, LOG_ERR); + } + } - $this->ref_client = $ref_client; + if (! $error) + { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + } - $this->db->commit(); - return 1; - } else { - foreach ($this->errors as $errmsg) { - dol_syslog(__METHOD__ . ' Error: ' . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } - } + if (! $error) + { + // If invoice was converted into a discount not yet consumed, we remove discount + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql.= ' WHERE fk_facture_source = '.$rowid; + $sql.= ' AND fk_facture_line IS NULL'; + $resql=$this->db->query($sql); - /** - * Delete invoice - * - * @param User $user User making the deletion. - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @param int $idwarehouse Id warehouse to use for stock change. - * @return int <0 if KO, 0=Refused, >0 if OK - */ - function delete($user, $notrigger = 0, $idwarehouse = -1) { - global $langs, $conf; - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + // If invoice has consumned discounts + $this->fetch_lines(); + $list_rowid_det=array(); + foreach($this->lines as $key => $invoiceline) + { + $list_rowid_det[]=$invoiceline->rowid; + } - $rowid = $this->id; + // Consumned discounts are freed + if (count($list_rowid_det)) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql.= ' SET fk_facture = NULL, fk_facture_line = NULL'; + $sql.= ' WHERE fk_facture_line IN ('.join(',',$list_rowid_det).')'; - dol_syslog(get_class($this) . "::delete rowid=" . $rowid . ", ref=" . $this->ref . ", thirdparty=" . $this->thirdparty->name, LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + if (! $this->db->query($sql)) + { + $this->error=$this->db->error()." sql=".$sql; + $this->db->rollback(); + return -5; + } + } - // Test to avoid invoice deletion (allowed if draft) - $result = $this->is_erasable(); + // If we decrement stock on invoice validation, we increment + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse!=-1) + { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; + $langs->load("agenda"); - if ($result <= 0) - return 0; + $num=count($this->lines); + for ($i = 0; $i < $num; $i++) + { + if ($this->lines[$i]->fk_product > 0) + { + $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; + // We decrease stock for product + if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); + else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value + } + } + } - $error = 0; - $this->db->begin(); + // Delete invoice line + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid; - if (!$error && !$notrigger) { + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + + if ($this->db->query($sql) && $this->delete_linked_contact()) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + + $resql=$this->db->query($sql); + if ($resql) + { + // On efface le repertoire de pdf provisoire + $ref = dol_sanitizeFileName($this->ref); + if ($conf->facture->dir_output && !empty($this->ref)) + { + $dir = $conf->facture->dir_output . "/" . $ref; + $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; + if (file_exists($file)) // We must delete all files before deleting directory + { + $ret=dol_delete_preview($this); + + if (! dol_delete_file($file,0,0,0,$this)) // For triggers + { + $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); + $this->db->rollback(); + return 0; + } + } + if (file_exists($dir)) + { + if (! dol_delete_dir_recursive($dir)) // For remove dir and meta + { + $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); + $this->db->rollback(); + return 0; + } + } + } + + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror()." sql=".$sql; + $this->db->rollback(); + return -6; + } + } + else + { + $this->error=$this->db->lasterror()." sql=".$sql; + $this->db->rollback(); + return -4; + } + } + else + { + $this->db->rollback(); + return -2; + } + } + + /** + * Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1 + * ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 + * + * @param User $user Objet utilisateur qui modifie + * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple) + * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) + * @return int <0 if KO, >0 if OK + */ + function set_paid($user, $close_code='', $close_note='') + { + $error=0; + + if ($this->paye != 1) + { + $this->db->begin(); + + dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; + $sql.= ' fk_statut='.self::STATUS_CLOSED; + if (! $close_code) $sql.= ', paye=1'; + if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; + if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; + $sql.= ' WHERE rowid = '.$this->id; + + $resql = $this->db->query($sql); + if ($resql) + { + // Call trigger + $result=$this->call_trigger('BILL_PAYED',$user); + if ($result < 0) $error++; + // End call triggers + } + else + { + $error++; + $this->error=$this->db->lasterror(); + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + else + { + return 0; + } + } + + + /** + * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED + * Fonction utilisee quand un paiement prelevement est refuse, + * ou quand une facture annulee et reouverte. + * + * @param User $user Object user that change status + * @return int <0 if KO, >0 if OK + */ + function set_unpaid($user) + { + $error=0; + + $this->db->begin(); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; + $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null'; + $sql.= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { // Call trigger - $result = $this->call_trigger('BILL_DELETE', $user); - if ($result < 0) - $error++; + $result=$this->call_trigger('BILL_UNPAYED',$user); + if ($result < 0) $error++; // End call triggers - } + } + else + { + $error++; + $this->error=$this->db->error(); + dol_print_error($this->db); + } - // Removed extrafields - if (!$error) { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - dol_syslog(get_class($this) . "::delete error deleteExtraFields " . $this->error, LOG_ERR); - } - } - - if (!$error) { - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) - $error++; - } - - if (!$error) { - // If invoice was converted into a discount not yet consumed, we remove discount - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'societe_remise_except'; - $sql .= ' WHERE fk_facture_source = ' . $rowid; - $sql .= ' AND fk_facture_line IS NULL'; - $resql = $this->db->query($sql); - - // If invoice has consumned discounts - $this->fetch_lines(); - $list_rowid_det = array(); - foreach ($this->lines as $key => $invoiceline) { - $list_rowid_det[] = $invoiceline->rowid; - } - - // Consumned discounts are freed - if (count($list_rowid_det)) { - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except'; - $sql .= ' SET fk_facture = NULL, fk_facture_line = NULL'; - $sql .= ' WHERE fk_facture_line IN (' . join(',', $list_rowid_det) . ')'; - - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); - if (!$this->db->query($sql)) { - $this->error = $this->db->error() . " sql=" . $sql; - $this->db->rollback(); - return -5; - } - } - - // If we decrement stock on invoice validation, we increment - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) { - require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; - $langs->load("agenda"); - - $num = count($this->lines); - for ($i = 0; $i < $num; $i++) { - if ($this->lines[$i]->fk_product > 0) { - $mouvP = new MouvementStock($this->db); - $mouvP->origin = &$this; - // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) - $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); - else - $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value - } - } - } + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } - // Delete invoice line - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE fk_facture = ' . $rowid; + /** + * Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL + * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because + * of no payment even if merchandises were sent). + * + * @param User $user Object user making change + * @param string $close_code Code of closing invoice (CLOSECODE_REPLACED, CLOSECODE_...) + * @param string $close_note Comment + * @return int <0 if KO, >0 if OK + */ + function set_canceled($user, $close_code='', $close_note='') + { - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG); - if ($this->db->query($sql) && $this->delete_linked_contact()) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facture WHERE rowid = ' . $rowid; + $this->db->begin(); - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; + $sql.= ' fk_statut='.self::STATUS_ABANDONED; + if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; + if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; + $sql.= ' WHERE rowid = '.$this->id; - $resql = $this->db->query($sql); - if ($resql) { - // On efface le repertoire de pdf provisoire - $ref = dol_sanitizeFileName($this->ref); - if ($conf->facture->dir_output && !empty($this->ref)) { - $dir = $conf->facture->dir_output . "/" . $ref; - $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; - if (file_exists($file)) { // We must delete all files before deleting directory - $ret = dol_delete_preview($this); + $resql = $this->db->query($sql); + if ($resql) + { + // On desaffecte de la facture les remises liees + // car elles n'ont pas ete utilisees vu que la facture est abandonnee. + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql.= ' SET fk_facture = NULL'; + $sql.= ' WHERE fk_facture = '.$this->id; - if (!dol_delete_file($file, 0, 0, 0, $this)) { // For triggers - $this->error = $langs->trans("ErrorCanNotDeleteFile", $file); - $this->db->rollback(); - return 0; - } - } - if (file_exists($dir)) { - if (!dol_delete_dir_recursive($dir)) { // For remove dir and meta - $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); - $this->db->rollback(); - return 0; - } - } - } + $resql=$this->db->query($sql); + if ($resql) + { + // Call trigger + $result=$this->call_trigger('BILL_CANCEL',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror() . " sql=" . $sql; - $this->db->rollback(); - return -6; - } - } else { - $this->error = $this->db->lasterror() . " sql=" . $sql; - $this->db->rollback(); - return -4; - } - } else { - $this->db->rollback(); - return -2; - } - } + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error()." sql=".$sql; + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$this->db->error()." sql=".$sql; + $this->db->rollback(); + return -2; + } + } - /** - * Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1 - * ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 - * - * @param User $user Objet utilisateur qui modifie - * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple) - * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) - * @return int <0 if KO, >0 if OK - */ - function set_paid($user, $close_code = '', $close_note = '') { - $error = 0; - - if ($this->paye != 1) { - $this->db->begin(); - - dol_syslog(get_class($this) . "::set_paid rowid=" . $this->id, LOG_DEBUG); - - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET'; - $sql .= ' fk_statut=' . self::STATUS_CLOSED; - if (!$close_code) - $sql .= ', paye=1'; - if ($close_code) - $sql .= ", close_code='" . $this->db->escape($close_code) . "'"; - if ($close_note) - $sql .= ", close_note='" . $this->db->escape($close_note) . "'"; - $sql .= ' WHERE rowid = ' . $this->id; - - $resql = $this->db->query($sql); - if ($resql) { - // Call trigger - $result = $this->call_trigger('BILL_PAYED', $user); - if ($result < 0) - $error++; - // End call triggers - } - else { - $error++; - $this->error = $this->db->lasterror(); - } - - if (!$error) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } else { - return 0; - } - } - - /** - * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED - * Fonction utilisee quand un paiement prelevement est refuse, - * ou quand une facture annulee et reouverte. - * - * @param User $user Object user that change status - * @return int <0 if KO, >0 if OK - */ - function set_unpaid($user) { - $error = 0; - - $this->db->begin(); - - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; - $sql .= ' SET paye=0, fk_statut=' . self::STATUS_VALIDATED . ', close_code=null, close_note=null'; - $sql .= ' WHERE rowid = ' . $this->id; - - dol_syslog(get_class($this) . "::set_unpaid", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - // Call trigger - $result = $this->call_trigger('BILL_UNPAYED', $user); - if ($result < 0) - $error++; - // End call triggers - } - else { - $error++; - $this->error = $this->db->error(); - dol_print_error($this->db); - } - - if (!$error) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - /** - * Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL - * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because - * of no payment even if merchandises were sent). - * - * @param User $user Object user making change - * @param string $close_code Code of closing invoice (CLOSECODE_REPLACED, CLOSECODE_...) - * @param string $close_note Comment - * @return int <0 if KO, >0 if OK - */ - function set_canceled($user, $close_code = '', $close_note = '') { - - dol_syslog(get_class($this) . "::set_canceled rowid=" . $this->id, LOG_DEBUG); - - $this->db->begin(); - - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET'; - $sql .= ' fk_statut=' . self::STATUS_ABANDONED; - if ($close_code) - $sql .= ", close_code='" . $this->db->escape($close_code) . "'"; - if ($close_note) - $sql .= ", close_note='" . $this->db->escape($close_note) . "'"; - $sql .= ' WHERE rowid = ' . $this->id; - - $resql = $this->db->query($sql); - if ($resql) { - // On desaffecte de la facture les remises liees - // car elles n'ont pas ete utilisees vu que la facture est abandonnee. - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except'; - $sql .= ' SET fk_facture = NULL'; - $sql .= ' WHERE fk_facture = ' . $this->id; - - $resql = $this->db->query($sql); - if ($resql) { - // Call trigger - $result = $this->call_trigger('BILL_CANCEL', $user); - if ($result < 0) { - $this->db->rollback(); - return -1; - } - // End call triggers - - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error() . " sql=" . $sql; - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error() . " sql=" . $sql; - $this->db->rollback(); - return -2; - } - } - - /** - * Tag invoice as validated + call trigger BILL_VALIDATE - * Object must have lines loaded with fetch_lines - * - * @param User $user Object user that validate - * @param string $force_number Reference to force on invoice - * @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease) - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + /** + * Tag invoice as validated + call trigger BILL_VALIDATE + * Object must have lines loaded with fetch_lines + * + * @param User $user Object user that validate + * @param string $force_number Reference to force on invoice + * @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease) + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK - */ - function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) { - global $conf, $langs; - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + */ + function validate($user, $force_number='', $idwarehouse=0, $notrigger=0) + { + global $conf,$langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $now = dol_now(); + $now=dol_now(); - $error = 0; - dol_syslog(get_class($this) . '::validate user=' . $user->id . ', force_number=' . $force_number . ', idwarehouse=' . $idwarehouse); + $error=0; + dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse); - // Force to have object complete for checks - $this->fetch_thirdparty(); - $this->fetch_lines(); + // Force to have object complete for checks + $this->fetch_thirdparty(); + $this->fetch_lines(); - // Check parameters - if (!$this->brouillon) { - dol_syslog(get_class($this) . "::validate no draft status", LOG_WARNING); - return 0; - } - if (count($this->lines) <= 0) { - $langs->load("errors"); - $this->error = $langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); - return -1; - } - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) { - $this->error = 'Permission denied'; - dol_syslog(get_class($this) . "::validate " . $this->error . ' MAIN_USE_ADVANCED_PERMS=' . $conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); - return -1; - } + // Check parameters + if (! $this->brouillon) + { + dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); + return 0; + } + if (count($this->lines) <= 0) + { + $langs->load("errors"); + $this->error=$langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); + return -1; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) + { + $this->error='Permission denied'; + dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); + return -1; + } - $this->db->begin(); + $this->db->begin(); - // Check parameters - if ($this->type == self::TYPE_REPLACEMENT) { // si facture de remplacement - // Controle que facture source connue - if ($this->fk_facture_source <= 0) { - $this->error = $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceReplacement")); - $this->db->rollback(); - return -10; - } + // Check parameters + if ($this->type == self::TYPE_REPLACEMENT) // si facture de remplacement + { + // Controle que facture source connue + if ($this->fk_facture_source <= 0) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("InvoiceReplacement")); + $this->db->rollback(); + return -10; + } - // Charge la facture source a remplacer - $facreplaced = new Facture($this->db); - $result = $facreplaced->fetch($this->fk_facture_source); - if ($result <= 0) { - $this->error = $langs->trans("ErrorBadInvoice"); - $this->db->rollback(); - return -11; - } + // Charge la facture source a remplacer + $facreplaced=new Facture($this->db); + $result=$facreplaced->fetch($this->fk_facture_source); + if ($result <= 0) + { + $this->error=$langs->trans("ErrorBadInvoice"); + $this->db->rollback(); + return -11; + } - // Controle que facture source non deja remplacee par une autre - $idreplacement = $facreplaced->getIdReplacingInvoice('validated'); - if ($idreplacement && $idreplacement != $this->id) { - $facreplacement = new Facture($this->db); - $facreplacement->fetch($idreplacement); - $this->error = $langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref); - $this->db->rollback(); - return -12; - } + // Controle que facture source non deja remplacee par une autre + $idreplacement=$facreplaced->getIdReplacingInvoice('validated'); + if ($idreplacement && $idreplacement != $this->id) + { + $facreplacement=new Facture($this->db); + $facreplacement->fetch($idreplacement); + $this->error=$langs->trans("ErrorInvoiceAlreadyReplaced",$facreplaced->ref,$facreplacement->ref); + $this->db->rollback(); + return -12; + } - $result = $facreplaced->set_canceled($user, self::CLOSECODE_REPLACED, ''); - if ($result < 0) { - $this->error = $facreplaced->error; - $this->db->rollback(); - return -13; - } - } + $result=$facreplaced->set_canceled($user, self::CLOSECODE_REPLACED, ''); + if ($result < 0) + { + $this->error=$facreplaced->error; + $this->db->rollback(); + return -13; + } + } - // Define new ref - if ($force_number) { - $num = $force_number; - } else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life - if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date - $this->date = dol_now(); - $this->date_lim_reglement = $this->calculate_date_lim_reglement(); - } - $num = $this->getNextNumRef($this->thirdparty); - } else { - $num = $this->ref; - } - $this->newref = $num; + // Define new ref + if ($force_number) + { + $num = $force_number; + } + else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life + { + if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date + { + $this->date=dol_now(); + $this->date_lim_reglement=$this->calculate_date_lim_reglement(); + } + $num = $this->getNextNumRef($this->thirdparty); + } + else + { + $num = $this->ref; + } + $this->newref = $num; - if ($num) { - $this->update_price(1); + if ($num) + { + $this->update_price(1); - // Validate - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; - $sql .= " SET facnumber='" . $num . "', fk_statut = " . self::STATUS_VALIDATED . ", fk_user_valid = " . ($user->id > 0 ? $user->id : "null") . ", date_valid = '" . $this->db->idate($now) . "'"; - if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date - $sql .= ", datef='" . $this->db->idate($this->date) . "'"; - $sql .= ", date_lim_reglement='" . $this->db->idate($this->date_lim_reglement) . "'"; - } - $sql .= ' WHERE rowid = ' . $this->id; + // Validate + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; + $sql.= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; + if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date + { + $sql.= ", datef='".$this->db->idate($this->date)."'"; + $sql.= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; + } + $sql.= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this) . "::validate", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - dol_print_error($this->db); - $error++; - } + dol_syslog(get_class($this)."::validate", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + $error++; + } - // On verifie si la facture etait une provisoire - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) { - // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne - } + // On verifie si la facture etait une provisoire + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + { + // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne + } - if (!$error) { - // Define third party as a customer - $result = $this->thirdparty->set_as_client(); + if (! $error) + { + // Define third party as a customer + $result=$this->thirdparty->set_as_client(); - // Si active on decremente le produit principal et ses composants a la validation de facture - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) { - require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; - $langs->load("agenda"); + // Si active on decremente le produit principal et ses composants a la validation de facture + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) + { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; + $langs->load("agenda"); + + // Loop on each line + $cpt=count($this->lines); + for ($i = 0; $i < $cpt; $i++) + { + if ($this->lines[$i]->fk_product > 0) + { + $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; + // We decrease stock for product + if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num)); + else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); + if ($result < 0) { + $error++; + $this->error = $mouvP->error; + } + } + } + } + } + + // Trigger calls + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_VALIDATE',$user); + if ($result < 0) $error++; + // End call triggers + } + + if (! $error) + { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Rename of object directory ($this->ref = old ref, $num = new ref) + // to not lose the linked files + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->facture->dir_output.'/'.$oldref; + $dirdest = $conf->facture->dir_output.'/'.$newref; + if (file_exists($dirsource)) + { + dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles=dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + foreach($listoffiles as $fileentry) + { + $dirsource=$fileentry['name']; + $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource); + $dirsource=$fileentry['path'].'/'.$dirsource; + $dirdest=$fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + if (! $error && !$this->is_last_in_cycle()) + { + if (! $this->updatePriceNextInvoice($langs)) + { + $error++; + } + } + + // Set new ref and define current statut + if (! $error) + { + $this->ref = $num; + $this->facnumber=$num; + $this->statut= self::STATUS_VALIDATED; + $this->brouillon=0; + $this->date_validation=$now; + $i = 0; + + if (!empty($conf->global->INVOICE_USE_SITUATION)) + { + $final = true; + $nboflines = count($this->lines); + while (($i < $nboflines) && $final) { + $final = ($this->lines[$i]->situation_percent == 100); + $i++; + } + + if (empty($final)) $this->situation_final = 0; + else $this->situation_final = 1; + + $this->setFinal($user); - // Loop on each line - $cpt = count($this->lines); - for ($i = 0; $i < $cpt; $i++) { - if ($this->lines[$i]->fk_product > 0) { - $mouvP = new MouvementStock($this->db); - $mouvP->origin = &$this; - // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) - $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num)); - else - $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); - if ($result < 0) { - $error++; - $this->error = $mouvP->error; - } - } - } } - } + } + } + else + { + $error++; + } - // Trigger calls - if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('BILL_VALIDATE', $user); - if ($result < 0) - $error++; - // End call triggers - } + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } - if (!$error) { - $this->oldref = $this->ref; + /** + * Update price of next invoice + * + * @param Translate $langs Translate object + * @return bool false if KO, true if OK + */ + function updatePriceNextInvoice(&$langs) + { + foreach ($this->tab_next_situation_invoice as $next_invoice) + { + $is_last = $next_invoice->is_last_in_cycle(); - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // Rename of object directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->facture->dir_output . '/' . $oldref; - $dirdest = $conf->facture->dir_output . '/' . $newref; - if (file_exists($dirsource)) { - dol_syslog(get_class($this) . "::validate rename dir " . $dirsource . " into " . $dirdest); + if ($next_invoice->brouillon && $is_last != 1) + { + $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); + return false; + } - if (@rename($dirsource, $dirdest)) { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->facture->dir_output . '/' . $newref, 'files', 1, '^' . preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^' . preg_quote($oldref, '/') . '/', $newref, $dirsource); - $dirsource = $fileentry['path'] . '/' . $dirsource; - $dirdest = $fileentry['path'] . '/' . $dirdest; - @rename($dirsource, $dirdest); - } - } - } - } - } + $next_invoice->brouillon = 1; + foreach ($next_invoice->lines as $line) + { + $result = $next_invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, + $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, + $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, + $line->fk_unit); - if (!$error && !$this->is_last_in_cycle()) { - if (!$this->updatePriceNextInvoice($langs)) { - $error++; - } - } + if ($result < 0) + { + $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); + return false; + } + } - // Set new ref and define current statut - if (!$error) { - $this->ref = $num; - $this->facnumber = $num; - $this->statut = self::STATUS_VALIDATED; - $this->brouillon = 0; - $this->date_validation = $now; - $i = 0; + break; // Only the next invoice and not each next invoice + } - if (!empty($conf->global->INVOICE_USE_SITUATION)) { - $final = true; - $nboflines = count($this->lines); - while (($i < $nboflines) && $final) { - $final = ($this->lines[$i]->situation_percent == 100); - $i++; - } + return true; + } - if (empty($final)) - $this->situation_final = 0; - else - $this->situation_final = 1; + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $idwarehouse Id warehouse to use for stock change. + * @return int <0 if KO, >0 if OK + */ + function set_draft($user,$idwarehouse=-1) + { + global $conf,$langs; - $this->setFinal($user); - } - } - } - else { - $error++; - } + $error=0; - if (!$error) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } + if ($this->statut == self::STATUS_DRAFT) + { + dol_syslog(get_class($this)."::set_draft already draft status", LOG_WARNING); + return 0; + } - /** - * Update price of next invoice - * - * @param Translate $langs Translate object - * @return bool false if KO, true if OK - */ - function updatePriceNextInvoice(&$langs) { - foreach ($this->tab_next_situation_invoice as $next_invoice) { - $is_last = $next_invoice->is_last_in_cycle(); + $this->db->begin(); - if ($next_invoice->brouillon && $is_last != 1) { - $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); - return false; - } + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $sql.= " SET fk_statut = ".self::STATUS_DRAFT; + $sql.= " WHERE rowid = ".$this->id; - $next_invoice->brouillon = 1; - foreach ($next_invoice->lines as $line) { - $result = $next_invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + dol_syslog(get_class($this)."::set_draft", LOG_DEBUG); + $result=$this->db->query($sql); + if ($result) + { + // Si on decremente le produit principal et ses composants a la validation de facture, on réincrement + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; + $langs->load("agenda"); - if ($result < 0) { - $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); - return false; - } - } + $num=count($this->lines); + for ($i = 0; $i < $num; $i++) + { + if ($this->lines[$i]->fk_product > 0) + { + $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; + // We decrease stock for product + if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); + else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value + } + } + } - break; // Only the next invoice and not each next invoice - } + if ($error == 0) + { + $old_statut=$this->statut; + $this->brouillon = 1; + $this->statut = self::STATUS_DRAFT; + // Call trigger + $result=$this->call_trigger('BILL_UNVALIDATE',$user); + if ($result < 0) + { + $error++; + $this->statut=$old_statut; + $this->brouillon=0; + } + // End call triggers + } else { + $this->db->rollback(); + return -1; + } - return true; - } + if ($error == 0) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } - /** - * Set draft status - * - * @param User $user Object user that modify - * @param int $idwarehouse Id warehouse to use for stock change. - * @return int <0 if KO, >0 if OK - */ - function set_draft($user, $idwarehouse = -1) { - global $conf, $langs; - $error = 0; + /** + * Add an invoice line into database (linked to product/service or not). + * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel + * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini + * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) + * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) + * + * @param string $desc Description of line + * @param double $pu_ht Unit price without tax (> 0 even for credit note) + * @param double $qty Quantity + * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') + * @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) + * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) + * @param int $fk_product Id of predefined product/service + * @param double $remise_percent Percent of discount on line + * @param int $date_start Date start of service + * @param int $date_end Date end of service + * @param int $ventil Code of dispatching into accountancy + * @param int $info_bits Bits de type de lignes + * @param int $fk_remise_except Id discount used + * @param string $price_base_type 'HT' or 'TTC' + * @param double $pu_ttc Unit price with tax (> 0 even for credit note) + * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. + * @param int $rang Position of line + * @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 + * @param int $fk_fournprice Supplier price id (to calculate margin) or '' + * @param int $pa_ht Buying price of line (to calculate margin) or '' + * @param string $label Label of the line (deprecated, do not use) + * @param array $array_options extrafields array + * @param int $situation_percent Situation advance percentage + * @param int $fk_prev_id Previous situation line id reference + * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param double $pu_ht_devise Unit price in currency + * @return int <0 if KO, Id of line if OK + */ + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id=0, $fk_unit = null, $pu_ht_devise = 0) + { + // Deprecation warning + if ($label) { + dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + //var_dump(debug_backtrace(false));exit; + } - if ($this->statut == self::STATUS_DRAFT) { - dol_syslog(get_class($this) . "::set_draft already draft status", LOG_WARNING); - return 0; - } + global $mysoc, $conf, $langs; - $this->db->begin(); + dol_syslog(get_class($this)."::addline id=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG); + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - $sql = "UPDATE " . MAIN_DB_PREFIX . "facture"; - $sql .= " SET fk_statut = " . self::STATUS_DRAFT; - $sql .= " WHERE rowid = " . $this->id; + // Clean parameters + if (empty($remise_percent)) $remise_percent=0; + if (empty($qty)) $qty=0; + if (empty($info_bits)) $info_bits=0; + if (empty($rang)) $rang=0; + if (empty($ventil)) $ventil=0; + if (empty($txtva)) $txtva=0; + if (empty($txlocaltax1)) $txlocaltax1=0; + if (empty($txlocaltax2)) $txlocaltax2=0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; + if (empty($fk_prev_id)) $fk_prev_id = 'null'; + if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - dol_syslog(get_class($this) . "::set_draft", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - // Si on decremente le produit principal et ses composants a la validation de facture, on réincrement - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { - require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; - $langs->load("agenda"); + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); - $num = count($this->lines); - for ($i = 0; $i < $num; $i++) { - if ($this->lines[$i]->fk_product > 0) { - $mouvP = new MouvementStock($this->db); - $mouvP->origin = &$this; - // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) - $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); - else - $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value - } - } - } + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } - if ($error == 0) { - $old_statut = $this->statut; - $this->brouillon = 1; - $this->statut = self::STATUS_DRAFT; - // Call trigger - $result = $this->call_trigger('BILL_UNVALIDATE', $user); - if ($result < 0) { - $error++; - $this->statut = $old_statut; - $this->brouillon = 0; - } - // End call triggers - } else { - $this->db->rollback(); - return -1; - } + $remise_percent=price2num($remise_percent); + $qty=price2num($qty); + $pu_ht=price2num($pu_ht); + $pu_ht_devise=price2num($pu_ht_devise); + $pu_ttc=price2num($pu_ttc); + $pa_ht=price2num($pa_ht); + $txtva=price2num($txtva); + $txlocaltax1=price2num($txlocaltax1); + $txlocaltax2=price2num($txlocaltax2); - if ($error == 0) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + if ($price_base_type=='HT') + { + $pu=$pu_ht; + } + else + { + $pu=$pu_ttc; + } - /** - * Add an invoice line into database (linked to product/service or not). - * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel - * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini - * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) - * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) - * - * @param string $desc Description of line - * @param double $pu_ht Unit price without tax (> 0 even for credit note) - * @param double $qty Quantity - * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') - * @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) - * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) - * @param int $fk_product Id of predefined product/service - * @param double $remise_percent Percent of discount on line - * @param int $date_start Date start of service - * @param int $date_end Date end of service - * @param int $ventil Code of dispatching into accountancy - * @param int $info_bits Bits de type de lignes - * @param int $fk_remise_except Id discount used - * @param string $price_base_type 'HT' or 'TTC' - * @param double $pu_ttc Unit price with tax (> 0 even for credit note) - * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. - * @param int $rang Position of line - * @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 - * @param int $fk_fournprice Supplier price id (to calculate margin) or '' - * @param int $pa_ht Buying price of line (to calculate margin) or '' - * @param string $label Label of the line (deprecated, do not use) - * @param array $array_options extrafields array - * @param int $situation_percent Situation advance percentage - * @param int $fk_prev_id Previous situation line id reference - * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in currency - * @return int <0 if KO, Id of line if OK - */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0) { - // Deprecation warning - if ($label) { - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); - //var_dump(debug_backtrace(false));exit; - } + // Check parameters + if ($type < 0) return -1; - global $mysoc, $conf, $langs; + if (! empty($this->brouillon)) + { + $this->db->begin(); - dol_syslog(get_class($this) . "::addline id=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG); - include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; + $product_type=$type; + if (!empty($fk_product)) + { + $product=new Product($this->db); + $result=$product->fetch($fk_product); + $product_type=$product->type; - // Clean parameters - if (empty($remise_percent)) - $remise_percent = 0; - if (empty($qty)) - $qty = 0; - if (empty($info_bits)) - $info_bits = 0; - if (empty($rang)) - $rang = 0; - if (empty($ventil)) - $ventil = 0; - if (empty($txtva)) - $txtva = 0; - if (empty($txlocaltax1)) - $txlocaltax1 = 0; - if (empty($txlocaltax2)) - $txlocaltax2 = 0; - if (empty($fk_parent_line) || $fk_parent_line < 0) - $fk_parent_line = 0; - if (empty($fk_prev_id)) - $fk_prev_id = 'null'; - if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') - $situation_percent = 100; - - $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); - - // Clean vat code - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } - - $remise_percent = price2num($remise_percent); - $qty = price2num($qty); - $pu_ht = price2num($pu_ht); - $pu_ht_devise = price2num($pu_ht_devise); - $pu_ttc = price2num($pu_ttc); - $pa_ht = price2num($pa_ht); - $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); - - if ($price_base_type == 'HT') { - $pu = $pu_ht; - } else { - $pu = $pu_ttc; - } - - // Check parameters - if ($type < 0) - return -1; - - if (!empty($this->brouillon)) { - $this->db->begin(); - - $product_type = $type; - if (!empty($fk_product)) { - $product = new Product($this->db); - $result = $product->fetch($fk_product); - $product_type = $product->type; - - if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { + if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { $langs->load("errors"); - $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); - $this->db->rollback(); - return -3; - } - } + $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $this->db->rollback(); + return -3; + } + } - // Calcul du total TTC et de la TVA pour la ligne a partir de - // qty, pu, remise_percent et txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + // Calcul du total TTC et de la TVA pour la ligne a partir de + // qty, pu, remise_percent et txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); - $total_ht = $tabprice[0]; - $total_tva = $tabprice[1]; - $total_ttc = $tabprice[2]; - $total_localtax1 = $tabprice[9]; - $total_localtax2 = $tabprice[10]; - $pu_ht = $tabprice[3]; + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - $pu_ht_devise = $tabprice[19]; + $pu_ht_devise = $tabprice[19]; - // Rank to use - $rangtouse = $rang; - if ($rangtouse == -1) { - $rangmax = $this->line_max($fk_parent_line); - $rangtouse = $rangmax + 1; - } + // Rank to use + $rangtouse = $rang; + if ($rangtouse == -1) + { + $rangmax = $this->line_max($fk_parent_line); + $rangtouse = $rangmax + 1; + } - // Insert line - $this->line = new FactureLigne($this->db); + // Insert line + $this->line=new FactureLigne($this->db); - $this->line->context = $this->context; + $this->line->context = $this->context; - $this->line->fk_facture = $this->id; - $this->line->label = $label; // deprecated - $this->line->desc = $desc; + $this->line->fk_facture=$this->id; + $this->line->label=$label; // deprecated + $this->line->desc=$desc; - $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise - $this->line->vat_src_code = $vat_src_code; - $this->line->tva_tx = $txtva; - $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0); - $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0); - $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->vat_src_code=$vat_src_code; + $this->line->tva_tx=$txtva; + $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); + $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; - $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative - $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative - $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative + $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); // For credit note and if qty is negative, total is negative + $this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); // For credit note and if qty is negative, total is negative + $this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1); // For credit note and if qty is negative, total is negative + $this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2); // For credit note and if qty is negative, total is negative - $this->line->fk_product = $fk_product; - $this->line->product_type = $product_type; - $this->line->remise_percent = $remise_percent; - $this->line->date_start = $date_start; - $this->line->date_end = $date_end; - $this->line->ventil = $ventil; - $this->line->rang = $rangtouse; - $this->line->info_bits = $info_bits; - $this->line->fk_remise_except = $fk_remise_except; + $this->line->fk_product=$fk_product; + $this->line->product_type=$product_type; + $this->line->remise_percent=$remise_percent; + $this->line->date_start=$date_start; + $this->line->date_end=$date_end; + $this->line->ventil=$ventil; + $this->line->rang=$rangtouse; + $this->line->info_bits=$info_bits; + $this->line->fk_remise_except=$fk_remise_except; - $this->line->special_code = $special_code; - $this->line->fk_parent_line = $fk_parent_line; - $this->line->origin = $origin; - $this->line->origin_id = $origin_id; - $this->line->situation_percent = $situation_percent; - $this->line->fk_prev_id = $fk_prev_id; - $this->line->fk_unit = $fk_unit; + $this->line->special_code=$special_code; + $this->line->fk_parent_line=$fk_parent_line; + $this->line->origin=$origin; + $this->line->origin_id=$origin_id; + $this->line->situation_percent = $situation_percent; + $this->line->fk_prev_id = $fk_prev_id; + $this->line->fk_unit=$fk_unit; - // infos marge - $this->line->fk_fournprice = $fk_fournprice; - $this->line->pa_ht = $pa_ht; + // infos marge + $this->line->fk_fournprice = $fk_fournprice; + $this->line->pa_ht = $pa_ht; - // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + // Multicurrency + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->multicurrency_subprice = $pu_ht_devise; + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - if (is_array($array_options) && count($array_options) > 0) { - $this->line->array_options = $array_options; - } + if (is_array($array_options) && count($array_options)>0) { + $this->line->array_options=$array_options; + } - $result = $this->line->insert(); - if ($result > 0) { - // Reorder if child line - if (!empty($fk_parent_line)) - $this->line_order(true, 'DESC'); + $result=$this->line->insert(); + if ($result > 0) + { + // Reorder if child line + if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); - // Mise a jour informations denormalisees au niveau de la facture meme - $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. + // Mise a jour informations denormalisees au niveau de la facture meme + $result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. - if ($result > 0) { - $this->db->commit(); - return $this->line->id; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->line->error; - $this->db->rollback(); - return -2; - } - } else { - dol_syslog(get_class($this) . "::addline status of order must be Draft to allow use of ->addline()", LOG_ERR); - return -3; - } - } + if ($result > 0) + { + $this->db->commit(); + return $this->line->id; + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$this->line->error; + $this->db->rollback(); + return -2; + } + } + else + { + dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR); + return -3; + } + } - /** - * Update a detail line - * - * @param int $rowid Id of line to update - * @param string $desc Description of line - * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines) - * @param double $qty Quantity - * @param double $remise_percent Pourcentage de remise de la ligne - * @param int $date_start Date de debut de validite du service - * @param int $date_end Date de fin de validite du service - * @param double $txtva VAT Rate (Can be '8.5', '8.5 (ABC)') - * @param double $txlocaltax1 Local tax 1 rate - * @param double $txlocaltax2 Local tax 2 rate - * @param string $price_base_type HT or TTC - * @param int $info_bits Miscellaneous informations - * @param int $type Type of line (0=product, 1=service) - * @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 - * @param int $pa_ht Price (without tax) of product when it was bought - * @param string $label Label of the line (deprecated, do not use) - * @param int $special_code Special code (also used by externals modules!) + /** + * Update a detail line + * + * @param int $rowid Id of line to update + * @param string $desc Description of line + * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines) + * @param double $qty Quantity + * @param double $remise_percent Pourcentage de remise de la ligne + * @param int $date_start Date de debut de validite du service + * @param int $date_end Date de fin de validite du service + * @param double $txtva VAT Rate (Can be '8.5', '8.5 (ABC)') + * @param double $txlocaltax1 Local tax 1 rate + * @param double $txlocaltax2 Local tax 2 rate + * @param string $price_base_type HT or TTC + * @param int $info_bits Miscellaneous informations + * @param int $type Type of line (0=product, 1=service) + * @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 + * @param int $pa_ht Price (without tax) of product when it was bought + * @param string $label Label of the line (deprecated, do not use) + * @param int $special_code Special code (also used by externals modules!) * @param array $array_options extrafields array - * @param int $situation_percent Situation advance percentage - * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in currency - * @param int $notrigger disable line update trigger - * @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 = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { - global $conf, $user; - // Deprecation warning - if ($label) { - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); - } + * @param int $situation_percent Situation advance percentage + * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param double $pu_ht_devise Unit price in currency + * @param int $notrigger disable line update trigger + * @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= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0, $notrigger=0) + { + global $conf,$user; + // Deprecation warning + if ($label) { + dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + } - include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - global $mysoc, $langs; + global $mysoc,$langs; - dol_syslog(get_class($this) . "::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); + dol_syslog(get_class($this)."::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); - if ($this->brouillon) { - if (!$this->is_last_in_cycle() && empty($this->error)) { - if (!$this->checkProgressLine($rowid, $situation_percent)) { - if (!$this->error) - $this->error = $langs->trans('invoiceLineProgressError'); - return -3; - } - } + if ($this->brouillon) + { + if (!$this->is_last_in_cycle() && empty($this->error)) + { + if (!$this->checkProgressLine($rowid, $situation_percent)) + { + if (!$this->error) $this->error=$langs->trans('invoiceLineProgressError'); + return -3; + } + } - $this->db->begin(); + $this->db->begin(); - // 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; - if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') - $situation_percent = 100; + // 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; + if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - $remise_percent = price2num($remise_percent); - $qty = price2num($qty); - $pu = price2num($pu); - $pu_ht_devise = price2num($pu_ht_devise); - $pa_ht = price2num($pa_ht); - $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + $pu = price2num($pu); + $pu_ht_devise = price2num($pu_ht_devise); + $pa_ht = price2num($pa_ht); + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); - // Check parameters - if ($type < 0) - return -1; + // Check parameters + if ($type < 0) return -1; - // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); - // Clean vat code - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); - $total_ht = $tabprice[0]; - $total_tva = $tabprice[1]; - $total_ttc = $tabprice[2]; - $total_localtax1 = $tabprice[9]; - $total_localtax2 = $tabprice[10]; - $pu_ht = $tabprice[3]; - $pu_tva = $tabprice[4]; - $pu_ttc = $tabprice[5]; + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1=$tabprice[9]; + $total_localtax2=$tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - $pu_ht_devise = $tabprice[19]; + $pu_ht_devise = $tabprice[19]; - // Old properties: $price, $remise (deprecated) - $price = $pu; - $remise = 0; - if ($remise_percent > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = ($pu - $remise); - } - $price = price2num($price); + // Old properties: $price, $remise (deprecated) + $price = $pu; + $remise = 0; + if ($remise_percent > 0) + { + $remise = round(($pu * $remise_percent / 100),2); + $price = ($pu - $remise); + } + $price = price2num($price); - //Fetch current line from the database and then clone the object and set it in $oldline property - $line = new FactureLigne($this->db); - $line->fetch($rowid); + //Fetch current line from the database and then clone the object and set it in $oldline property + $line = new FactureLigne($this->db); + $line->fetch($rowid); - if (!empty($line->fk_product)) { - $product = new Product($this->db); - $result = $product->fetch($line->fk_product); - $product_type = $product->type; + if (!empty($line->fk_product)) + { + $product=new Product($this->db); + $result=$product->fetch($line->fk_product); + $product_type=$product->type; - if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { + if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { $langs->load("errors"); - $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); - $this->db->rollback(); - return -3; - } - } + $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $this->db->rollback(); + return -3; + } + } - $staticline = clone $line; + $staticline = clone $line; - $line->oldline = $staticline; - $this->line = $line; + $line->oldline = $staticline; + $this->line = $line; $this->line->context = $this->context; - // Reorder if fk_parent_line change - if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { - $rangmax = $this->line_max($fk_parent_line); - $this->line->rang = $rangmax + 1; - } + // Reorder if fk_parent_line change + if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) + { + $rangmax = $this->line_max($fk_parent_line); + $this->line->rang = $rangmax + 1; + } - $this->line->rowid = $rowid; - $this->line->label = $label; - $this->line->desc = $desc; - $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $this->line->rowid = $rowid; + $this->line->label = $label; + $this->line->desc = $desc; + $this->line->qty = ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative - $this->line->vat_src_code = $vat_src_code; - $this->line->tva_tx = $txtva; - $this->line->localtax1_tx = $txlocaltax1; - $this->line->localtax2_tx = $txlocaltax2; - $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->vat_src_code = $vat_src_code; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = $txlocaltax1; + $this->line->localtax2_tx = $txlocaltax2; + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; - $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->date_start = $date_start; - $this->line->date_end = $date_end; - $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); - $this->line->info_bits = $info_bits; - $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; - $this->line->situation_percent = $situation_percent; - $this->line->fk_unit = $fk_unit; + $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->date_start = $date_start; + $this->line->date_end = $date_end; + $this->line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); + $this->line->total_localtax1 = $total_localtax1; + $this->line->total_localtax2 = $total_localtax2; + $this->line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); + $this->line->info_bits = $info_bits; + $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; + $this->line->situation_percent = $situation_percent; + $this->line->fk_unit = $fk_unit; - $this->line->fk_fournprice = $fk_fournprice; - $this->line->pa_ht = $pa_ht; + $this->line->fk_fournprice = $fk_fournprice; + $this->line->pa_ht = $pa_ht; - // Multicurrency - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + // Multicurrency + $this->line->multicurrency_subprice = $pu_ht_devise; + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - if (is_array($array_options) && count($array_options) > 0) { - $this->line->array_options = $array_options; - } + if (is_array($array_options) && count($array_options)>0) { + $this->line->array_options=$array_options; + } - $result = $this->line->update($user, $notrigger); - if ($result > 0) { - // Reorder if child line - if (!empty($fk_parent_line)) - $this->line_order(true, 'DESC'); + $result=$this->line->update($user, $notrigger); + if ($result > 0) + { + // Reorder if child line + if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); - // Mise a jour info denormalisees au niveau facture - $this->update_price(1); - $this->db->commit(); - return $result; - } - else { - $this->error = $this->line->error; - $this->db->rollback(); - return -1; - } - } else { - $this->error = "Invoice statut makes operation forbidden"; - return -2; - } - } + // Mise a jour info denormalisees au niveau facture + $this->update_price(1); + $this->db->commit(); + return $result; + } + else + { + $this->error=$this->line->error; + $this->db->rollback(); + return -1; + } + } + else + { + $this->error="Invoice statut makes operation forbidden"; + return -2; + } + } - /** - * Check if the percent edited is lower of next invoice line - * - * @param int $idline id of line to check - * @param float $situation_percent progress percentage need to be test - * @return false if KO, true if OK - */ - function checkProgressLine($idline, $situation_percent) { - $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd - INNER JOIN ' . MAIN_DB_PREFIX . 'facture f ON (fd.fk_facture = f.rowid) - WHERE fd.fk_prev_id = ' . $idline . ' + /** + * Check if the percent edited is lower of next invoice line + * + * @param int $idline id of line to check + * @param float $situation_percent progress percentage need to be test + * @return false if KO, true if OK + */ + function checkProgressLine($idline, $situation_percent) + { + $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd + INNER JOIN '.MAIN_DB_PREFIX.'facture f ON (fd.fk_facture = f.rowid) + WHERE fd.fk_prev_id = '.$idline.' AND f.fk_statut <> 0'; - $result = $this->db->query($sql); - if (!$result) { - $this->error = $this->db->error(); - return false; - } + $result = $this->db->query($sql); + if (! $result) + { + $this->error=$this->db->error(); + return false; + } - $obj = $this->db->fetch_object($result); + $obj = $this->db->fetch_object($result); - if ($obj === null) - return true; - else - return $situation_percent < $obj->situation_percent; - } + if ($obj === null) return true; + else return $situation_percent < $obj->situation_percent; + } - /** - * Update invoice line with percentage - * - * @param FactureLigne $line Invoice line - * @param int $percent Percentage - * @return void - */ - function update_percent($line, $percent) { - global $mysoc, $user; + /** + * Update invoice line with percentage + * + * @param FactureLigne $line Invoice line + * @param int $percent Percentage + * @return void + */ + function update_percent($line, $percent) + { + global $mysoc,$user; - include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'); + include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'); - // Cap percentages to 100 - if ($percent > 100) - $percent = 100; - $line->situation_percent = $percent; - $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $percent); - $line->total_ht = $tabprice[0]; - $line->total_tva = $tabprice[1]; - $line->total_ttc = $tabprice[2]; - $line->total_localtax1 = $tabprice[9]; - $line->total_localtax2 = $tabprice[10]; - $line->multicurrency_total_ht = $tabprice[16]; - $line->multicurrency_total_tva = $tabprice[17]; - $line->multicurrency_total_ttc = $tabprice[18]; - $line->update($user); - $this->update_price(1); - $this->db->commit(); - } + // Cap percentages to 100 + if ($percent > 100) $percent = 100; + $line->situation_percent = $percent; + $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $percent); + $line->total_ht = $tabprice[0]; + $line->total_tva = $tabprice[1]; + $line->total_ttc = $tabprice[2]; + $line->total_localtax1 = $tabprice[9]; + $line->total_localtax2 = $tabprice[10]; + $line->multicurrency_total_ht = $tabprice[16]; + $line->multicurrency_total_tva = $tabprice[17]; + $line->multicurrency_total_ttc = $tabprice[18]; + $line->update($user); + $this->update_price(1); + $this->db->commit(); + } - /** - * Delete line in database - * - * @param int $rowid Id of line to delete - * @return int <0 if KO, >0 if OK - */ - function deleteline($rowid) { + /** + * Delete line in database + * + * @param int $rowid Id of line to delete + * @return int <0 if KO, >0 if OK + */ + function deleteline($rowid) + { global $user; - dol_syslog(get_class($this) . "::deleteline rowid=" . $rowid, LOG_DEBUG); + dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); - if (!$this->brouillon) { - $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; - return -1; - } + if (! $this->brouillon) + { + $this->error='ErrorDeleteLineNotAllowedByObjectStatus'; + return -1; + } - $this->db->begin(); + $this->db->begin(); - // Libere remise liee a ligne de facture - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except'; - $sql .= ' SET fk_facture_line = NULL'; - $sql .= ' WHERE fk_facture_line = ' . $rowid; + // Libere remise liee a ligne de facture + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql.= ' SET fk_facture_line = NULL'; + $sql.= ' WHERE fk_facture_line = '.$rowid; - dol_syslog(get_class($this) . "::deleteline", LOG_DEBUG); - $result = $this->db->query($sql); - if (!$result) { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } + dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); + $result = $this->db->query($sql); + if (! $result) + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } - $line = new FactureLigne($this->db); + $line=new FactureLigne($this->db); $line->context = $this->context; - // For triggers - $result = $line->fetch($rowid); - if (!($result > 0)) - dol_print_error($this->db, $line->error, $line->errors); + // For triggers + $result = $line->fetch($rowid); + if (! ($result > 0)) dol_print_error($this->db, $line->error, $line->errors); - if ($line->delete($user) > 0) { - $result = $this->update_price(1); + if ($line->delete($user) > 0) + { + $result=$this->update_price(1); - if ($result > 0) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } else { - $this->db->rollback(); - $this->error = $line->error; - return -1; - } - } + if ($result > 0) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + $this->error=$this->db->lasterror(); + return -1; + } + } + else + { + $this->db->rollback(); + $this->error=$line->error; + return -1; + } + } - /** - * Set percent discount - * - * @param User $user User that set discount - * @param double $remise Discount - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if ko, >0 if ok - */ - function set_remise($user, $remise, $notrigger = 0) { - // Clean parameters - if (empty($remise)) - $remise = 0; + /** + * Set percent discount + * + * @param User $user User that set discount + * @param double $remise Discount + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if ko, >0 if ok + */ + function set_remise($user, $remise, $notrigger=0) + { + // Clean parameters + if (empty($remise)) $remise=0; - if ($user->rights->facture->creer) { - $remise = price2num($remise); + if ($user->rights->facture->creer) + { + $remise=price2num($remise); - $error = 0; + $error=0; - $this->db->begin(); + $this->db->begin(); - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; - $sql .= ' SET remise_percent = ' . $remise; - $sql .= ' WHERE rowid = ' . $this->id; - $sql .= ' AND fk_statut = ' . self::STATUS_DRAFT; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; + $sql.= ' SET remise_percent = '.$remise; + $sql.= ' WHERE rowid = '.$this->id; + $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; - dol_syslog(__METHOD__, LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->errors[] = $this->db->error(); - $error++; - } + dol_syslog(__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if (!$resql) + { + $this->errors[]=$this->db->error(); + $error++; + } - if (!$notrigger && empty($error)) { - // Call trigger - $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) - $error++; - // End call triggers - } + if (! $notrigger && empty($error)) + { + // Call trigger + $result=$this->call_trigger('BILL_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } - if (!$error) { - $this->remise_percent = $remise; - $this->update_price(1); + if (! $error) + { + $this->remise_percent = $remise; + $this->update_price(1); - $this->db->commit(); - return 1; - } else { - foreach ($this->errors as $errmsg) { - dol_syslog(__METHOD__ . ' Error: ' . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } - } - } + $this->db->commit(); + return 1; + } + else + { + foreach($this->errors as $errmsg) + { + dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + } + } - /** - * Set absolute discount - * - * @param User $user User that set discount - * @param double $remise Discount - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >0 if OK - */ - function set_remise_absolue($user, $remise, $notrigger = 0) { - if (empty($remise)) - $remise = 0; - if ($user->rights->facture->creer) { - $error = 0; + /** + * Set absolute discount + * + * @param User $user User that set discount + * @param double $remise Discount + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK + */ + function set_remise_absolue($user, $remise, $notrigger=0) + { + if (empty($remise)) $remise=0; - $this->db->begin(); + if ($user->rights->facture->creer) + { + $error=0; - $remise = price2num($remise); + $this->db->begin(); - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture'; - $sql .= ' SET remise_absolue = ' . $remise; - $sql .= ' WHERE rowid = ' . $this->id; - $sql .= ' AND fk_statut = ' . self::STATUS_DRAFT; + $remise=price2num($remise); - dol_syslog(__METHOD__, LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->errors[] = $this->db->error(); - $error++; - } + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; + $sql.= ' SET remise_absolue = '.$remise; + $sql.= ' WHERE rowid = '.$this->id; + $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; - if (!$error) { - $this->oldcopy = clone $this; - $this->remise_absolue = $remise; - $this->update_price(1); - } + dol_syslog(__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if (!$resql) + { + $this->errors[]=$this->db->error(); + $error++; + } - if (!$notrigger && empty($error)) { - // Call trigger - $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) - $error++; - // End call triggers - } + if (! $error) + { + $this->oldcopy= clone $this; + $this->remise_absolue = $remise; + $this->update_price(1); + } - if (!$error) { - $this->db->commit(); - return 1; - } else { - foreach ($this->errors as $errmsg) { - dol_syslog(__METHOD__ . ' Error: ' . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } - } - } + if (! $notrigger && empty($error)) + { + // Call trigger + $result=$this->call_trigger('BILL_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } - /** - * Return next reference of customer invoice not already used (or last reference) - * according to numbering module defined into constant FACTURE_ADDON - * - * @param Societe $soc object company - * @param string $mode 'next' for next value or 'last' for last value - * @return string free ref or last ref - */ - function getNextNumRef($soc, $mode = 'next') { - global $conf, $langs; - $langs->load("bills"); + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + foreach($this->errors as $errmsg) + { + dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + } + } - // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->FACTURE_ADDON)) - $conf->global->FACTURE_ADDON = 'mod_facture_terre'; - else if ($conf->global->FACTURE_ADDON == 'terre') - $conf->global->FACTURE_ADDON = 'mod_facture_terre'; - else if ($conf->global->FACTURE_ADDON == 'mercure') - $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; + /** + * Return next reference of customer invoice not already used (or last reference) + * according to numbering module defined into constant FACTURE_ADDON + * + * @param Societe $soc object company + * @param string $mode 'next' for next value or 'last' for last value + * @return string free ref or last ref + */ + function getNextNumRef($soc,$mode='next') + { + global $conf, $langs; + $langs->load("bills"); - if (!empty($conf->global->FACTURE_ADDON)) { - dol_syslog("Call getNextNumRef with FACTURE_ADDON = " . $conf->global->FACTURE_ADDON . ", thirdparty=" . $soc->nom . ", type=" . $soc->typent_code, LOG_DEBUG); + // Clean parameters (if not defined or using deprecated value) + if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON='mod_facture_terre'; + else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre'; + else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure'; - $mybool = false; + if (! empty($conf->global->FACTURE_ADDON)) + { + dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG); - $file = $conf->global->FACTURE_ADDON . ".php"; - $classname = $conf->global->FACTURE_ADDON; + $mybool=false; - // Include file with class - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + $file = $conf->global->FACTURE_ADDON.".php"; + $classname = $conf->global->FACTURE_ADDON; - foreach ($dirmodels as $reldir) { + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - $dir = dol_buildpath($reldir . "core/modules/facture/"); + foreach ($dirmodels as $reldir) { - // Load file with numbering class (if found) - if (is_file($dir . $file) && is_readable($dir . $file)) { + $dir = dol_buildpath($reldir."core/modules/facture/"); + + // Load file with numbering class (if found) + if (is_file($dir.$file) && is_readable($dir.$file)) + { $mybool |= include_once $dir . $file; } - } + } - // For compatibility - if (!$mybool) { - $file = $conf->global->FACTURE_ADDON . "/" . $conf->global->FACTURE_ADDON . ".modules.php"; - $classname = "mod_facture_" . $conf->global->FACTURE_ADDON; - $classname = preg_replace('/\-.*$/', '', $classname); - // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) { - $dir = $dirroot . "/core/modules/facture/"; + // For compatibility + if (! $mybool) + { + $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; + $classname = "mod_facture_".$conf->global->FACTURE_ADDON; + $classname = preg_replace('/\-.*$/','',$classname); + // Include file with class + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot."/core/modules/facture/"; - // Load file with numbering class (if found) - if (is_file($dir . $file) && is_readable($dir . $file)) { + // Load file with numbering class (if found) + if (is_file($dir.$file) && is_readable($dir.$file)) { $mybool |= include_once $dir . $file; } - } - } + } + } - if (!$mybool) { - dol_print_error('', "Failed to include file " . $file); - return ''; - } + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } - $obj = new $classname(); - $numref = ""; - $numref = $obj->getNextValue($soc, $this, $mode); + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc,$this,$mode); - /** - * $numref can be empty in case we ask for the last value because if there is no invoice created with the - * set up mask. - */ - if ($mode != 'last' && !$numref) { - $this->error = $obj->error; - //dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); - return ""; - } + /** + * $numref can be empty in case we ask for the last value because if there is no invoice created with the + * set up mask. + */ + if ($mode != 'last' && !$numref) { + $this->error=$obj->error; + //dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); + return ""; + } - return $numref; - } else { - $langs->load("errors"); - print $langs->trans("Error") . " " . $langs->trans("ErrorModuleSetupNotComplete"); - return ""; - } - } + return $numref; + } + else + { + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + return ""; + } + } - /** - * Load miscellaneous information for tab "Info" - * - * @param int $id Id of object to load - * @return void - */ - function info($id) { - $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; - $sql .= ' fk_user_author, fk_user_valid'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture as c'; - $sql .= ' WHERE c.rowid = ' . $id; + /** + * Load miscellaneous information for tab "Info" + * + * @param int $id Id of object to load + * @return void + */ + function info($id) + { + $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; + $sql.= ' fk_user_author, fk_user_valid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c'; + $sql.= ' WHERE c.rowid = '.$id; - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if ($obj->fk_user_valid) { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); // Should be in log table - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } - - /** - * Return list of invoices (eventually filtered on a user) into an array - * - * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) - * @param int $draft 0=not draft, 1=draft - * @param User $excluser Objet user to exclude - * @param int $socid Id third pary - * @param int $limit For pagination - * @param int $offset For pagination - * @param string $sortfield Sort criteria - * @param string $sortorder Sort order - * @return int -1 if KO, array with result if OK - */ - function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') { - global $conf, $user; - - $ga = array(); - - $sql = "SELECT s.rowid, s.nom as name, s.client,"; - $sql .= " f.rowid as fid, f.facnumber as ref, f.datef as df"; - if (!$user->rights->societe->client->voir && !$socid) - $sql .= ", sc.fk_soc, sc.fk_user"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "facture as f"; - if (!$user->rights->societe->client->voir && !$socid) - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; - $sql .= " WHERE f.entity = " . $conf->entity; - $sql .= " AND f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) { //restriction - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; - } - if ($socid) - $sql .= " AND s.rowid = " . $socid; - if ($draft) - $sql .= " AND f.fk_statut = " . self::STATUS_DRAFT; - if (is_object($excluser)) - $sql .= " AND f.fk_user_author <> " . $excluser->id; - $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - - $result = $this->db->query($sql); - if ($result) { - $numc = $this->db->num_rows($result); - if ($numc) { - $i = 0; - while ($i < $numc) { - $obj = $this->db->fetch_object($result); - - if ($shortlist == 1) { - $ga[$obj->fid] = $obj->ref; - } else if ($shortlist == 2) { - $ga[$obj->fid] = $obj->ref . ' (' . $obj->name . ')'; - } else { - $ga[$i]['id'] = $obj->fid; - $ga[$i]['ref'] = $obj->ref; - $ga[$i]['name'] = $obj->name; - } - $i++; - } - } - return $ga; - } else { - dol_print_error($this->db); - return -1; - } - } - - /** - * Return list of invoices qualified to be replaced by another invoice. - * Invoices matching the following rules are returned: - * (Status validated or abandonned for a reason 'other') + not payed + no payment at all + not already replaced - * - * @param int $socid Id thirdparty - * @return array Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) - */ - function list_replacable_invoices($socid = 0) { - global $conf; - - $return = array(); - - $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut,"; - $sql .= " ff.rowid as rowidnext"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as ff ON f.rowid = ff.fk_facture_source"; - $sql .= " WHERE (f.fk_statut = " . self::STATUS_VALIDATED . " OR (f.fk_statut = " . self::STATUS_ABANDONED . " AND f.close_code = '" . self::CLOSECODE_ABANDONED . "'))"; - $sql .= " AND f.entity = " . $conf->entity; - $sql .= " AND f.paye = 0"; // Pas classee payee completement - $sql .= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait - $sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement - if ($socid > 0) - $sql .= " AND f.fk_soc = " . $socid; - $sql .= " ORDER BY f.facnumber"; - - dol_syslog(get_class($this) . "::list_replacable_invoices", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $return[$obj->rowid] = array('id' => $obj->rowid, - 'ref' => $obj->facnumber, - 'status' => $obj->fk_statut); - } - //print_r($return); - return $return; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Return list of invoices qualified to be corrected by a credit note. - * Invoices matching the following rules are returned: - * (validated + payment on process) or classified (payed completely or payed partiely) + not already replaced + not already a credit note - * - * @param int $socid Id thirdparty - * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) - */ - function list_qualified_avoir_invoices($socid = 0) { - global $conf; - - $return = array(); + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); // Should be in log table + } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } - $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=" . self::TYPE_REPLACEMENT . ")"; - $sql .= " WHERE f.entity = " . $conf->entity; - $sql .= " AND f.fk_statut in (" . self::STATUS_VALIDATED . "," . self::STATUS_CLOSED . ")"; - // $sql.= " WHERE f.fk_statut >= 1"; - // $sql.= " AND (f.paye = 1"; // Classee payee completement - // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement - $sql .= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement - $sql .= " AND f.type != " . self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir + /** + * Return list of invoices (eventually filtered on a user) into an array + * + * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) + * @param int $draft 0=not draft, 1=draft + * @param User $excluser Objet user to exclude + * @param int $socid Id third pary + * @param int $limit For pagination + * @param int $offset For pagination + * @param string $sortfield Sort criteria + * @param string $sortorder Sort order + * @return int -1 if KO, array with result if OK + */ + function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='f.datef,f.rowid', $sortorder='DESC') + { + global $conf,$user; - if ($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE) { - // Select the last situation invoice - $sqlSit = 'SELECT MAX(fs.rowid)'; - $sqlSit .= " FROM " . MAIN_DB_PREFIX . "facture as fs"; - $sqlSit .= " WHERE fs.entity = " . $conf->entity; - $sqlSit .= " AND fs.type = " . self::TYPE_SITUATION; - $sqlSit .= " AND fs.fk_statut in (" . self::STATUS_VALIDATED . "," . self::STATUS_CLOSED . ")"; - $sqlSit .= " GROUP BY fs.situation_cycle_ref"; - $sqlSit .= " ORDER BY fs.situation_counter"; - $sql .= " AND ( f.type != " . self::TYPE_SITUATION . " OR f.rowid IN (" . $sqlSit . ") )"; // Type non 5 si facture non avoir - } else { - $sql .= " AND f.type != " . self::TYPE_SITUATION; // Type non 5 si facture non avoir - } + $ga = array(); - if ($socid > 0) - $sql .= " AND f.fk_soc = " . $socid; - $sql .= " ORDER BY f.facnumber"; + $sql = "SELECT s.rowid, s.nom as name, s.client,"; + $sql.= " f.rowid as fid, f.facnumber as ref, f.datef as df"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " AND f.fk_soc = s.rowid"; + if (! $user->rights->societe->client->voir && ! $socid) //restriction + { + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + } + if ($socid) $sql.= " AND s.rowid = ".$socid; + if ($draft) $sql.= " AND f.fk_statut = ".self::STATUS_DRAFT; + if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id; + $sql.= $this->db->order($sortfield,$sortorder); + $sql.= $this->db->plimit($limit,$offset); - dol_syslog(get_class($this) . "::list_qualified_avoir_invoices", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $qualified = 0; - if ($obj->fk_statut == self::STATUS_VALIDATED) - $qualified = 1; - if ($obj->fk_statut == self::STATUS_CLOSED) - $qualified = 1; - if ($qualified) { - //$ref=$obj->facnumber; - $paymentornot = ($obj->fk_paiement ? 1 : 0); - $return[$obj->rowid] = array('ref' => $obj->facnumber, 'status' => $obj->fk_statut, 'type' => $obj->type, 'paye' => $obj->paye, 'paymentornot' => $paymentornot); - } - } + $result=$this->db->query($sql); + if ($result) + { + $numc = $this->db->num_rows($result); + if ($numc) + { + $i = 0; + while ($i < $numc) + { + $obj = $this->db->fetch_object($result); - return $return; - } else { - $this->error = $this->db->error(); - return -1; - } - } + if ($shortlist == 1) + { + $ga[$obj->fid] = $obj->ref; + } + else if ($shortlist == 2) + { + $ga[$obj->fid] = $obj->ref.' ('.$obj->name.')'; + } + else + { + $ga[$i]['id'] = $obj->fid; + $ga[$i]['ref'] = $obj->ref; + $ga[$i]['name'] = $obj->name; + } + $i++; + } + } + return $ga; + } + else + { + dol_print_error($this->db); + return -1; + } + } - /** - * Create a withdrawal request for a standing order. - * Use the remain to pay excluding all existing open direct debit requests. - * - * @param User $fuser User asking the direct debit transfer - * @param float $amount Amount we request direct debit for - * @return int <0 if KO, >0 if OK - */ - function demande_prelevement($fuser, $amount = 0) { - $error = 0; + /** + * Return list of invoices qualified to be replaced by another invoice. + * Invoices matching the following rules are returned: + * (Status validated or abandonned for a reason 'other') + not payed + no payment at all + not already replaced + * + * @param int $socid Id thirdparty + * @return array Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) + */ + function list_replacable_invoices($socid=0) + { + global $conf; - dol_syslog(get_class($this) . "::demande_prelevement", LOG_DEBUG); + $return = array(); - if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; - $bac = new CompanyBankAccount($this->db); - $bac->fetch(0, $this->socid); + $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut,"; + $sql.= " ff.rowid as rowidnext"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; + $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; + $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.paye = 0"; // Pas classee payee completement + $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait + $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement + if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; + $sql.= " ORDER BY f.facnumber"; - $sql = 'SELECT count(*)'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'prelevement_facture_demande'; - $sql .= ' WHERE fk_facture = ' . $this->id; - $sql .= ' AND traite = 0'; + dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $return[$obj->rowid]=array( 'id' => $obj->rowid, + 'ref' => $obj->facnumber, + 'status' => $obj->fk_statut); + } + //print_r($return); + return $return; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } - dol_syslog(get_class($this) . "::demande_prelevement", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $row = $this->db->fetch_row($resql); - if ($row[0] == 0) { - $now = dol_now(); - $totalpaye = $this->getSommePaiement(); + /** + * Return list of invoices qualified to be corrected by a credit note. + * Invoices matching the following rules are returned: + * (validated + payment on process) or classified (payed completely or payed partiely) + not already replaced + not already a credit note + * + * @param int $socid Id thirdparty + * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) + */ + function list_qualified_avoir_invoices($socid=0) + { + global $conf; + + $return = array(); + + + $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; + $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + // $sql.= " WHERE f.fk_statut >= 1"; + // $sql.= " AND (f.paye = 1"; // Classee payee completement + // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement + $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement + $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir + + if($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE){ + // Select the last situation invoice + $sqlSit = 'SELECT MAX(fs.rowid)'; + $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; + $sqlSit.= " WHERE fs.entity = ".$conf->entity; + $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; + $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sqlSit.= " GROUP BY fs.situation_cycle_ref"; + $sqlSit.= " ORDER BY fs.situation_counter"; + $sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir + } + else + { + $sql.= " AND f.type != ".self::TYPE_SITUATION ; // Type non 5 si facture non avoir + } + + if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; + $sql.= " ORDER BY f.facnumber"; + + dol_syslog(get_class($this)."::list_qualified_avoir_invoices", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $qualified=0; + if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1; + if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1; + if ($qualified) + { + //$ref=$obj->facnumber; + $paymentornot=($obj->fk_paiement?1:0); + $return[$obj->rowid]=array('ref'=>$obj->facnumber,'status'=>$obj->fk_statut,'type'=>$obj->type,'paye'=>$obj->paye,'paymentornot'=>$paymentornot); + } + } + + return $return; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + + /** + * Create a withdrawal request for a standing order. + * Use the remain to pay excluding all existing open direct debit requests. + * + * @param User $fuser User asking the direct debit transfer + * @param float $amount Amount we request direct debit for + * @return int <0 if KO, >0 if OK + */ + function demande_prelevement($fuser, $amount=0) + { + + $error=0; + + dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); + + if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) + { + require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + $bac = new CompanyBankAccount($this->db); + $bac->fetch(0,$this->socid); + + $sql = 'SELECT count(*)'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; + $sql.= ' WHERE fk_facture = '.$this->id; + $sql.= ' AND traite = 0'; + + dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + if ($row[0] == 0) + { + $now=dol_now(); + + $totalpaye = $this->getSommePaiement(); $totalcreditnotes = $this->getSumCreditNotesUsed(); $totaldeposits = $this->getSumDepositsUsed(); //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; + // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - if (empty($amount)) - $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT'); - if (is_numeric($amount) && $amount != 0) { - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'prelevement_facture_demande'; - $sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)'; - $sql .= ' VALUES (' . $this->id; - $sql .= ",'" . price2num($amount) . "'"; - $sql .= ",'" . $this->db->idate($now) . "'"; - $sql .= "," . $fuser->id; - $sql .= ",'" . $bac->code_banque . "'"; - $sql .= ",'" . $bac->code_guichet . "'"; - $sql .= ",'" . $bac->number . "'"; - $sql .= ",'" . $bac->cle_rib . "')"; + if (is_numeric($amount) && $amount != 0) + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande'; + $sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)'; + $sql .= ' VALUES ('.$this->id; + $sql .= ",'".price2num($amount)."'"; + $sql .= ",'".$this->db->idate($now)."'"; + $sql .= ",".$fuser->id; + $sql .= ",'".$bac->code_banque."'"; + $sql .= ",'".$bac->code_guichet."'"; + $sql .= ",'".$bac->number."'"; + $sql .= ",'".$bac->cle_rib."')"; - dol_syslog(get_class($this) . "::demande_prelevement", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this) . '::demandeprelevement Erreur'); - $error++; - } - } else { - $this->error = 'WithdrawRequestErrorNilAmount'; - dol_syslog(get_class($this) . '::demandeprelevement WithdrawRequestErrorNilAmount'); - $error++; - } + dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this).'::demandeprelevement Erreur'); + $error++; + } + } + else + { + $this->error='WithdrawRequestErrorNilAmount'; + dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount'); + $error++; + } - if (!$error) { - // Force payment mode of invoice to withdraw - $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); - if ($payment_mode_id > 0) { - $result = $this->setPaymentMethods($payment_mode_id); - } - } + if (! $error) + { + // Force payment mode of invoice to withdraw + $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); + if ($payment_mode_id > 0) + { + $result=$this->setPaymentMethods($payment_mode_id); + } + } - if ($error) - return -1; + if ($error) return -1; return 1; } - else { - $this->error = "A request already exists"; - dol_syslog(get_class($this) . '::demandeprelevement Impossible de creer une demande, demande deja en cours'); + else + { + $this->error="A request already exists"; + dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); return 0; } - } else { - $this->error = $this->db->error(); - dol_syslog(get_class($this) . '::demandeprelevement Erreur -2'); + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this).'::demandeprelevement Erreur -2'); return -2; } - } else { - $this->error = "Status of invoice does not allow this"; - dol_syslog(get_class($this) . "::demandeprelevement " . $this->error . " $this->statut, $this->paye, $this->mode_reglement_id"); + } + else + { + $this->error="Status of invoice does not allow this"; + dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id"); return -3; } } - /** - * Supprime une demande de prelevement - * - * @param User $fuser User making delete - * @param int $did id de la demande a supprimer - * @return int <0 if OK, >0 if KO - */ - function demande_prelevement_delete($fuser, $did) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'prelevement_facture_demande'; - $sql .= ' WHERE rowid = ' . $did; - $sql .= ' AND traite = 0'; - if ($this->db->query($sql)) { - return 0; - } else { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this) . '::demande_prelevement_delete Error ' . $this->error); - return -1; - } - } + /** + * Supprime une demande de prelevement + * + * @param User $fuser User making delete + * @param int $did id de la demande a supprimer + * @return int <0 if OK, >0 if KO + */ + function demande_prelevement_delete($fuser, $did) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; + $sql .= ' WHERE rowid = '.$did; + $sql .= ' AND traite = 0'; + if ( $this->db->query($sql) ) + { + return 0; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error); + return -1; + } + } - /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Object user - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK - */ - function load_board($user) { - global $conf, $langs; - $clause = " WHERE"; + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Object user + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + */ + function load_board($user) + { + global $conf, $langs; - $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; - $sql .= " WHERE sc.fk_user = " . $user->id; - $clause = " AND"; - } - $sql .= $clause . " f.paye=0"; - $sql .= " AND f.entity = " . $conf->entity; - $sql .= " AND f.fk_statut = " . self::STATUS_VALIDATED; - if ($user->societe_id) - $sql .= " AND f.fk_soc = " . $user->societe_id; + $clause = " WHERE"; - $resql = $this->db->query($sql); - if ($resql) { - $langs->load("bills"); - $now = dol_now(); + $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = " AND"; + } + $sql.= $clause." f.paye=0"; + $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED; + if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id; - $response = new WorkboardResponse(); - $response->warning_delay = $conf->facture->client->warning_delay / 60 / 60 / 24; - $response->label = $langs->trans("CustomerBillsUnpaid"); - $response->url = DOL_URL_ROOT . '/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills'; - $response->img = img_object('', "bill"); + $resql=$this->db->query($sql); + if ($resql) + { + $langs->load("bills"); + $now=dol_now(); - $generic_facture = new Facture($this->db); + $response = new WorkboardResponse(); + $response->warning_delay=$conf->facture->client->warning_delay/60/60/24; + $response->label=$langs->trans("CustomerBillsUnpaid"); + $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills'; + $response->img=img_object('',"bill"); - while ($obj = $this->db->fetch_object($resql)) { - $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin); - $generic_facture->statut = $obj->fk_statut; + $generic_facture = new Facture($this->db); - $response->nbtodo++; + while ($obj=$this->db->fetch_object($resql)) + { + $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin); + $generic_facture->statut = $obj->fk_statut; - if ($generic_facture->hasDelay()) { - $response->nbtodolate++; - } - } + $response->nbtodo++; - return $response; - } else { - dol_print_error($this->db); - $this->error = $this->db->error(); - return -1; - } - } + if ($generic_facture->hasDelay()) { + $response->nbtodolate++; + } + } - /* gestion des contacts d'une facture */ + return $response; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } - /** - * Retourne id des contacts clients de facturation - * - * @return array Liste des id contacts facturation - */ - function getIdBillingContact() { - return $this->getIdContact('external', 'BILLING'); - } - /** - * Retourne id des contacts clients de livraison - * - * @return array Liste des id contacts livraison - */ - function getIdShippingContact() { - return $this->getIdContact('external', 'SHIPPING'); - } + /* gestion des contacts d'une facture */ - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines - * @return void - */ - function initAsSpecimen($option = '') { - global $langs; + /** + * Retourne id des contacts clients de facturation + * + * @return array Liste des id contacts facturation + */ + function getIdBillingContact() + { + return $this->getIdContact('external','BILLING'); + } - $now = dol_now(); - $arraynow = dol_getdate($now); - $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); + /** + * Retourne id des contacts clients de livraison + * + * @return array Liste des id contacts livraison + */ + function getIdShippingContact() + { + return $this->getIdContact('external','SHIPPING'); + } + + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines + * @return void + */ + function initAsSpecimen($option='') + { + global $langs; + + $now=dol_now(); + $arraynow=dol_getdate($now); + $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); // Load array of products prodids - $num_prods = 0; - $prodids = array(); - $sql = "SELECT rowid"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product"; - $sql .= " WHERE entity IN (" . getEntity('product') . ")"; - $resql = $this->db->query($sql); - if ($resql) { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } - //Avoid php warning Warning: mt_rand(): max(0) is smaller than min(1) when no product exists - if (empty($num_prods)) { - $num_prods = 1; - } + $num_prods = 0; + $prodids = array(); + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product"; + $sql.= " WHERE entity IN (".getEntity('product').")"; + $resql = $this->db->query($sql); + if ($resql) + { + $num_prods = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_prods) + { + $i++; + $row = $this->db->fetch_row($resql); + $prodids[$i] = $row[0]; + } + } + //Avoid php warning Warning: mt_rand(): max(0) is smaller than min(1) when no product exists + if (empty($num_prods)) { + $num_prods=1; + } - // Initialize parameters - $this->id = 0; - $this->entity = 1; - $this->ref = 'SPECIMEN'; - $this->specimen = 1; - $this->socid = 1; - $this->date = $nownotime; - $this->date_lim_reglement = $nownotime + 3600 * 24 * 30; - $this->cond_reglement_id = 1; - $this->cond_reglement_code = 'RECEP'; - $this->date_lim_reglement = $this->calculate_date_lim_reglement(); - $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR - $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR - $this->note_public = 'This is a comment (public)'; - $this->note_private = 'This is a comment (private)'; - $this->note = 'This is a comment (private)'; - $this->fk_incoterms = 0; - $this->location_incoterms = ''; + // Initialize parameters + $this->id=0; + $this->entity = 1; + $this->ref = 'SPECIMEN'; + $this->specimen=1; + $this->socid = 1; + $this->date = $nownotime; + $this->date_lim_reglement = $nownotime + 3600 * 24 *30; + $this->cond_reglement_id = 1; + $this->cond_reglement_code = 'RECEP'; + $this->date_lim_reglement=$this->calculate_date_lim_reglement(); + $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR + $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR + $this->note_public='This is a comment (public)'; + $this->note_private='This is a comment (private)'; + $this->note='This is a comment (private)'; + $this->fk_incoterms=0; + $this->location_incoterms=''; - if (empty($option) || $option != 'nolines') { - // Lines - $nbp = 5; - $xnbp = 0; - while ($xnbp < $nbp) { - $line = new FactureLigne($this->db); - $line->desc = $langs->trans("Description") . " " . $xnbp; - $line->qty = 1; - $line->subprice = 100; - $line->tva_tx = 19.6; - $line->localtax1_tx = 0; - $line->localtax2_tx = 0; - $line->remise_percent = 0; - if ($xnbp == 1) { // Qty is negative (product line) - $prodid = mt_rand(1, $num_prods); - $line->fk_product = $prodids[$prodid]; - $line->qty = -1; - $line->total_ht = -100; - $line->total_ttc = -119.6; - $line->total_tva = -19.6; - $line->multicurrency_total_ht = -200; - $line->multicurrency_total_ttc = -239.2; - $line->multicurrency_total_tva = -39.2; - } else if ($xnbp == 2) { // UP is negative (free line) - $line->subprice = -100; - $line->total_ht = -100; - $line->total_ttc = -119.6; - $line->total_tva = -19.6; - $line->remise_percent = 0; - $line->multicurrency_total_ht = -200; - $line->multicurrency_total_ttc = -239.2; - $line->multicurrency_total_tva = -39.2; - } else if ($xnbp == 3) { // Discount is 50% (product line) - $prodid = mt_rand(1, $num_prods); - $line->fk_product = $prodids[$prodid]; - $line->total_ht = 50; - $line->total_ttc = 59.8; - $line->total_tva = 9.8; - $line->multicurrency_total_ht = 100; - $line->multicurrency_total_ttc = 119.6; - $line->multicurrency_total_tva = 19.6; - $line->remise_percent = 50; - } else { // (product line) - $prodid = mt_rand(1, $num_prods); - $line->fk_product = $prodids[$prodid]; - $line->total_ht = 100; - $line->total_ttc = 119.6; - $line->total_tva = 19.6; - $line->multicurrency_total_ht = 200; - $line->multicurrency_total_ttc = 239.2; - $line->multicurrency_total_tva = 39.2; - $line->remise_percent = 0; - } + if (empty($option) || $option != 'nolines') + { + // Lines + $nbp = 5; + $xnbp = 0; + while ($xnbp < $nbp) + { + $line=new FactureLigne($this->db); + $line->desc=$langs->trans("Description")." ".$xnbp; + $line->qty=1; + $line->subprice=100; + $line->tva_tx=19.6; + $line->localtax1_tx=0; + $line->localtax2_tx=0; + $line->remise_percent=0; + if ($xnbp == 1) // Qty is negative (product line) + { + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; + $line->qty=-1; + $line->total_ht=-100; + $line->total_ttc=-119.6; + $line->total_tva=-19.6; + $line->multicurrency_total_ht=-200; + $line->multicurrency_total_ttc=-239.2; + $line->multicurrency_total_tva=-39.2; + } + else if ($xnbp == 2) // UP is negative (free line) + { + $line->subprice=-100; + $line->total_ht=-100; + $line->total_ttc=-119.6; + $line->total_tva=-19.6; + $line->remise_percent=0; + $line->multicurrency_total_ht=-200; + $line->multicurrency_total_ttc=-239.2; + $line->multicurrency_total_tva=-39.2; + } + else if ($xnbp == 3) // Discount is 50% (product line) + { + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; + $line->total_ht=50; + $line->total_ttc=59.8; + $line->total_tva=9.8; + $line->multicurrency_total_ht=100; + $line->multicurrency_total_ttc=119.6; + $line->multicurrency_total_tva=19.6; + $line->remise_percent=50; + } + else // (product line) + { + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; + $line->total_ht=100; + $line->total_ttc=119.6; + $line->total_tva=19.6; + $line->multicurrency_total_ht=200; + $line->multicurrency_total_ttc=239.2; + $line->multicurrency_total_tva=39.2; + $line->remise_percent=0; + } - $this->lines[$xnbp] = $line; + $this->lines[$xnbp]=$line; - $this->total_ht += $line->total_ht; - $this->total_tva += $line->total_tva; - $this->total_ttc += $line->total_ttc; + $this->total_ht += $line->total_ht; + $this->total_tva += $line->total_tva; + $this->total_ttc += $line->total_ttc; - $this->multicurrency_total_ht += $line->multicurrency_total_ht; - $this->multicurrency_total_tva += $line->multicurrency_total_tva; - $this->multicurrency_total_ttc += $line->multicurrency_total_ttc; + $this->multicurrency_total_ht += $line->multicurrency_total_ht; + $this->multicurrency_total_tva += $line->multicurrency_total_tva; + $this->multicurrency_total_ttc += $line->multicurrency_total_ttc; - $xnbp++; - } - $this->revenuestamp = 0; + $xnbp++; + } + $this->revenuestamp = 0; - // Add a line "offered" - $line = new FactureLigne($this->db); - $line->desc = $langs->trans("Description") . " (offered line)"; - $line->qty = 1; - $line->subprice = 100; - $line->tva_tx = 19.6; - $line->localtax1_tx = 0; - $line->localtax2_tx = 0; - $line->remise_percent = 100; - $line->total_ht = 0; - $line->total_ttc = 0; // 90 * 1.196 - $line->total_tva = 0; - $line->multicurrency_total_ht = 0; - $line->multicurrency_total_ttc = 0; - $line->multicurrency_total_tva = 0; - $prodid = mt_rand(1, $num_prods); - $line->fk_product = $prodids[$prodid]; + // Add a line "offered" + $line=new FactureLigne($this->db); + $line->desc=$langs->trans("Description")." (offered line)"; + $line->qty=1; + $line->subprice=100; + $line->tva_tx=19.6; + $line->localtax1_tx=0; + $line->localtax2_tx=0; + $line->remise_percent=100; + $line->total_ht=0; + $line->total_ttc=0; // 90 * 1.196 + $line->total_tva=0; + $line->multicurrency_total_ht=0; + $line->multicurrency_total_ttc=0; + $line->multicurrency_total_tva=0; + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; - $this->lines[$xnbp] = $line; - $xnbp++; - } - } + $this->lines[$xnbp]=$line; + $xnbp++; + } + } - /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @return int <0 if KO, >0 if OK - */ - function load_state_board() { - global $conf, $user; + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @return int <0 if KO, >0 if OK + */ + function load_state_board() + { + global $conf, $user; - $this->nb = array(); + $this->nb=array(); - $clause = "WHERE"; + $clause = "WHERE"; - $sql = "SELECT count(f.rowid) as nb"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql .= " WHERE sc.fk_user = " . $user->id; - $clause = "AND"; - } - $sql .= " " . $clause . " f.entity = " . $conf->entity; + $sql = "SELECT count(f.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = "AND"; + } + $sql.= " ".$clause." f.entity = ".$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $this->nb["invoices"] = $obj->nb; - } + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["invoices"]=$obj->nb; + } $this->db->free($resql); - return 1; - } else { - dol_print_error($this->db); - $this->error = $this->db->error(); - return -1; - } - } + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } - /** - * Create an array of invoice lines - * - * @return int >0 if OK, <0 if KO - */ - function getLinesArray() { - return $this->fetch_lines(); - } + /** + * Create an array of invoice lines + * + * @return int >0 if OK, <0 if KO + */ + function getLinesArray() + { + return $this->fetch_lines(); + } - /** - * Create a document onto disk according to template module. - * - * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example. - * @param Translate $outputlangs objet lang a utiliser pour traduction - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information - * @return int <0 if KO, >0 if OK - */ - public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf, $langs; + /** + * Create a document onto disk according to template module. + * + * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example. + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int <0 if KO, >0 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) + { + global $conf,$langs; - $langs->load("bills"); + $langs->load("bills"); - if (!dol_strlen($modele)) { + if (! dol_strlen($modele)) { - $modele = 'crabe'; + $modele = 'crabe'; - if ($this->modelpdf) { - $modele = $this->modelpdf; - } elseif (!empty($conf->global->FACTURE_ADDON_PDF)) { - $modele = $conf->global->FACTURE_ADDON_PDF; - } - } + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->FACTURE_ADDON_PDF)) { + $modele = $conf->global->FACTURE_ADDON_PDF; + } + } - $modelpath = "core/modules/facture/doc/"; + $modelpath = "core/modules/facture/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - } + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } - /** - * Gets the smallest reference available for a new cycle - * - * @return int >= 1 if OK, -1 if error - */ - function newCycle() { - $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql .= " WHERE f.entity in (" . getEntity('facture', 0) . ")"; - $resql = $this->db->query($sql); - if ($resql) { - if ($resql->num_rows > 0) { - $res = $this->db->fetch_array($resql); - $ref = $res['max(situation_cycle_ref)']; - $ref++; - } else { - $ref = 1; - } - $this->db->free($resql); - return $ref; - } else { - $this->error = $this->db->lasterror(); - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); - return -1; - } - } + /** + * Gets the smallest reference available for a new cycle + * + * @return int >= 1 if OK, -1 if error + */ + function newCycle() + { + $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; + $sql.= " WHERE f.entity in (".getEntity('facture', 0).")"; + $resql = $this->db->query($sql); + if ($resql) { + if ($resql->num_rows > 0) + { + $res = $this->db->fetch_array($resql); + $ref = $res['max(situation_cycle_ref)']; + $ref++; + } else { + $ref = 1; + } + $this->db->free($resql); + return $ref; + } else { + $this->error = $this->db->lasterror(); + dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + return -1; + } + } - /** - * Checks if the invoice is the first of a cycle - * - * @return boolean - */ - function is_first() { - return ($this->situation_counter == 1); - } + /** + * Checks if the invoice is the first of a cycle + * + * @return boolean + */ + function is_first() + { + return ($this->situation_counter == 1); + } - /** - * Returns an array containing the previous situations as Facture objects - * - * @return mixed -1 if error, array of previous situations - */ - function get_prev_sits() { - global $conf; + /** + * Returns an array containing the previous situations as Facture objects + * + * @return mixed -1 if error, array of previous situations + */ + function get_prev_sits() + { + global $conf; - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; - $sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref; - $sql .= ' and situation_counter < ' . $this->situation_counter; - $sql .= ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); - $resql = $this->db->query($sql); - $res = array(); - if ($resql && $resql->num_rows > 0) { - while ($row = $this->db->fetch_object($resql)) { - $id = $row->rowid; - $situation = new Facture($this->db); - $situation->fetch($id); - $res[] = $situation; - } - } else { - $this->error = $this->db->error(); - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); - return -1; - } + $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; + $sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref; + $sql .= ' and situation_counter < ' . $this->situation_counter; + $sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity); + $resql = $this->db->query($sql); + $res = array(); + if ($resql && $resql->num_rows > 0) { + while ($row = $this->db->fetch_object($resql)) { + $id = $row->rowid; + $situation = new Facture($this->db); + $situation->fetch($id); + $res[] = $situation; + } + } else { + $this->error = $this->db->error(); + dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + return -1; + } - return $res; - } + return $res; + } - /** - * Sets the invoice as a final situation - * - * @param User $user Object user - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >0 if OK - */ - function setFinal(User $user, $notrigger = 0) { - $error = 0; + /** + * Sets the invoice as a final situation + * + * @param User $user Object user + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK + */ + function setFinal(User $user, $notrigger=0) + { + $error=0; - $this->db->begin(); + $this->db->begin(); - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; - dol_syslog(__METHOD__, LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->errors[] = $this->db->error(); - $error++; - } + dol_syslog(__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if (!$resql) + { + $this->errors[]=$this->db->error(); + $error++; + } - if (!$notrigger && empty($error)) { - // Call trigger - $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) - $error++; - // End call triggers - } + if (! $notrigger && empty($error)) + { + // Call trigger + $result=$this->call_trigger('BILL_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } - if (!$error) { - $this->db->commit(); - return 1; - } else { - foreach ($this->errors as $errmsg) { - dol_syslog(__METHOD__ . ' Error: ' . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } - } + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + foreach($this->errors as $errmsg) + { + dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + } - /** - * Checks if the invoice is the last in its cycle - * - * @return bool Last of the cycle status - * - */ - function is_last_in_cycle() { - global $conf; + /** + * Checks if the invoice is the last in its cycle + * + * @return bool Last of the cycle status + * + */ + function is_last_in_cycle() + { + global $conf; - if (!empty($this->situation_cycle_ref)) { - // No point in testing anything if we're not inside a cycle - $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref . ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); - $resql = $this->db->query($sql); + if (!empty($this->situation_cycle_ref)) { + // No point in testing anything if we're not inside a cycle + $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref . ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); + $resql = $this->db->query($sql); - if ($resql && $resql->num_rows > 0) { - $res = $this->db->fetch_array($resql); - $last = $res['max(situation_counter)']; - return ($last == $this->situation_counter); - } else { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); - return false; - } - } else { - return true; - } - } + if ($resql && $resql->num_rows > 0) { + $res = $this->db->fetch_array($resql); + $last = $res['max(situation_counter)']; + return ($last == $this->situation_counter); + } else { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + return false; + } + } else { + return true; + } + } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) { - $tables = array( - 'facture' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'facture' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + } - /** - * Is the customer invoice delayed? - * - * @return bool - */ - public function hasDelay() { - global $conf; + /** + * Is the customer invoice delayed? + * + * @return bool + */ + public function hasDelay() + { + global $conf; - $now = dol_now(); + $now = dol_now(); - // Paid invoices have status STATUS_CLOSED - if ($this->statut != Facture::STATUS_VALIDATED) - return false; - - return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); - } + // Paid invoices have status STATUS_CLOSED + if ($this->statut != Facture::STATUS_VALIDATED) return false; + return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); + } } /** - * Class to manage invoice lines. + * Class to manage invoice lines. * Saved into database table llx_facturedet */ -class FactureLigne extends CommonInvoiceLine +class FactureLigne extends CommonInvoiceLine { + public $element='facturedet'; + public $table_element='facturedet'; - public $element = 'facturedet'; - public $table_element = 'facturedet'; - var $oldline; - //! From llx_facturedet - //! Id facture - var $fk_facture; - //! Id parent line - var $fk_parent_line; + var $oldline; - /** - * @deprecated - */ - var $label; - //! Description ligne - var $desc; - var $localtax1_type; // Local tax 1 type - var $localtax2_type; // Local tax 2 type - var $fk_remise_except; // Link to line into llx_remise_except - var $rang = 0; - var $fk_fournprice; - var $pa_ht; - var $marge_tx; - var $marque_tx; - var $special_code; // Liste d'options non cumulabels: - // 1: frais de port - // 2: ecotaxe - // 3: ?? - var $origin; - var $origin_id; - var $fk_code_ventilation = 0; - var $date_start; - var $date_end; - // Ne plus utiliser - //var $price; // P.U. HT apres remise % de ligne (exemple 80) - //var $remise; // Montant calcule de la remise % sur PU HT (exemple 20) - // From llx_product - /** - * @deprecated - * @see product_ref - */ - var $ref; // Product ref (deprecated) - var $product_ref; // Product ref - /** - * @deprecated - * @see product_label - */ - var $libelle; // Product label (deprecated) - var $product_label; // Product label - var $product_desc; // Description produit - var $skip_update_total; // Skip update price total for special lines + //! From llx_facturedet + //! Id facture + var $fk_facture; + //! Id parent line + var $fk_parent_line; + /** + * @deprecated + */ + var $label; + //! Description ligne + var $desc; - /** - * @var int Situation advance percentage - */ - public $situation_percent; + var $localtax1_type; // Local tax 1 type + var $localtax2_type; // Local tax 2 type + var $fk_remise_except; // Link to line into llx_remise_except + var $rang = 0; - /** - * @var int Previous situation line id reference - */ - public $fk_prev_id; - // Multicurrency - var $fk_multicurrency; - var $multicurrency_code; - var $multicurrency_subprice; - var $multicurrency_total_ht; - var $multicurrency_total_tva; - var $multicurrency_total_ttc; + var $fk_fournprice; + var $pa_ht; + var $marge_tx; + var $marque_tx; - /** - * Load invoice line from database - * - * @param int $rowid id of invoice line to get - * @return int <0 if KO, >0 if OK - */ - function fetch($rowid) { - $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; - $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; - $sql .= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; - $sql .= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; - $sql .= ' fd.fk_code_ventilation,'; - $sql .= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; - $sql .= ' fd.situation_percent, fd.fk_prev_id,'; - $sql .= ' fd.multicurrency_subprice,'; - $sql .= ' fd.multicurrency_total_ht,'; - $sql .= ' fd.multicurrency_total_tva,'; - $sql .= ' fd.multicurrency_total_ttc,'; - $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facturedet as fd'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p ON fd.fk_product = p.rowid'; - $sql .= ' WHERE fd.rowid = ' . $rowid; + var $special_code; // Liste d'options non cumulabels: + // 1: frais de port + // 2: ecotaxe + // 3: ?? - $result = $this->db->query($sql); - if ($result) { - $objp = $this->db->fetch_object($result); + var $origin; + var $origin_id; - $this->rowid = $objp->rowid; - $this->fk_facture = $objp->fk_facture; - $this->fk_parent_line = $objp->fk_parent_line; - $this->label = $objp->custom_label; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->subprice = $objp->subprice; - $this->vat_src_code = $objp->vat_src_code; - $this->tva_tx = $objp->tva_tx; - $this->localtax1_tx = $objp->localtax1_tx; - $this->localtax2_tx = $objp->localtax2_tx; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->product_type = $objp->product_type; - $this->date_start = $this->db->jdate($objp->date_start); - $this->date_end = $this->db->jdate($objp->date_end); - $this->info_bits = $objp->info_bits; - $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; - $this->special_code = $objp->special_code; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_localtax1 = $objp->total_localtax1; - $this->total_localtax2 = $objp->total_localtax2; - $this->total_ttc = $objp->total_ttc; - $this->fk_code_ventilation = $objp->fk_code_ventilation; - $this->rang = $objp->rang; - $this->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); - $this->pa_ht = $marginInfos[0]; - $this->marge_tx = $marginInfos[1]; - $this->marque_tx = $marginInfos[2]; + var $fk_code_ventilation = 0; - $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_libelle; // deprecated - $this->product_label = $objp->product_libelle; - $this->product_desc = $objp->product_desc; - $this->fk_unit = $objp->fk_unit; - $this->fk_user_modif = $objp->fk_user_modif; - $this->fk_user_author = $objp->fk_user_author; + var $date_start; + var $date_end; - $this->situation_percent = $objp->situation_percent; - $this->fk_prev_id = $objp->fk_prev_id; + // Ne plus utiliser + //var $price; // P.U. HT apres remise % de ligne (exemple 80) + //var $remise; // Montant calcule de la remise % sur PU HT (exemple 20) - $this->multicurrency_subprice = $objp->multicurrency_subprice; - $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva = $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + // From llx_product + /** + * @deprecated + * @see product_ref + */ + var $ref; // Product ref (deprecated) + var $product_ref; // Product ref + /** + * @deprecated + * @see product_label + */ + var $libelle; // Product label (deprecated) + var $product_label; // Product label + var $product_desc; // Description produit - $this->db->free($result); + var $skip_update_total; // Skip update price total for special lines - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + /** + * @var int Situation advance percentage + */ + public $situation_percent; - /** - * Insert line into database - * - * @param int $notrigger 1 no triggers - * @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another - * @return int <0 if KO, >0 if OK - */ - function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) { - global $langs, $user, $conf; + /** + * @var int Previous situation line id reference + */ + public $fk_prev_id; - $error = 0; + // Multicurrency + var $fk_multicurrency; + var $multicurrency_code; + var $multicurrency_subprice; + var $multicurrency_total_ht; + var $multicurrency_total_tva; + var $multicurrency_total_ttc; + + /** + * Load invoice line from database + * + * @param int $rowid id of invoice line to get + * @return int <0 if KO, >0 if OK + */ + function fetch($rowid) + { + $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; + $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; + $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; + $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; + $sql.= ' fd.fk_code_ventilation,'; + $sql.= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; + $sql.= ' fd.situation_percent, fd.fk_prev_id,'; + $sql.= ' fd.multicurrency_subprice,'; + $sql.= ' fd.multicurrency_total_ht,'; + $sql.= ' fd.multicurrency_total_tva,'; + $sql.= ' fd.multicurrency_total_ttc,'; + $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; + $sql.= ' WHERE fd.rowid = '.$rowid; + + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); + + $this->rowid = $objp->rowid; + $this->fk_facture = $objp->fk_facture; + $this->fk_parent_line = $objp->fk_parent_line; + $this->label = $objp->custom_label; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; + $this->tva_tx = $objp->tva_tx; + $this->localtax1_tx = $objp->localtax1_tx; + $this->localtax2_tx = $objp->localtax2_tx; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->product_type = $objp->product_type; + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); + $this->info_bits = $objp->info_bits; + $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; + $this->special_code = $objp->special_code; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_localtax1 = $objp->total_localtax1; + $this->total_localtax2 = $objp->total_localtax2; + $this->total_ttc = $objp->total_ttc; + $this->fk_code_ventilation = $objp->fk_code_ventilation; + $this->rang = $objp->rang; + $this->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); + $this->pa_ht = $marginInfos[0]; + $this->marge_tx = $marginInfos[1]; + $this->marque_tx = $marginInfos[2]; + + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_libelle; // deprecated + $this->product_label = $objp->product_libelle; + $this->product_desc = $objp->product_desc; + $this->fk_unit = $objp->fk_unit; + $this->fk_user_modif = $objp->fk_user_modif; + $this->fk_user_author = $objp->fk_user_author; + + $this->situation_percent = $objp->situation_percent; + $this->fk_prev_id = $objp->fk_prev_id; + + $this->multicurrency_subprice = $objp->multicurrency_subprice; + $this->multicurrency_total_ht = $objp->multicurrency_total_ht; + $this->multicurrency_total_tva= $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc= $objp->multicurrency_total_ttc; + + $this->db->free($result); + + return 1; + } + else + { + $this->error = $this->db->lasterror(); + return -1; + } + } + + /** + * Insert line into database + * + * @param int $notrigger 1 no triggers + * @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another + * @return int <0 if KO, >0 if OK + */ + function insert($notrigger=0, $noerrorifdiscountalreadylinked=0) + { + global $langs,$user,$conf; + + $error=0; $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. - dol_syslog(get_class($this) . "::insert rang=" . $this->rang, LOG_DEBUG); + dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG); - // Clean parameters - $this->desc = trim($this->desc); - if (empty($this->tva_tx)) - $this->tva_tx = 0; - if (empty($this->localtax1_tx)) - $this->localtax1_tx = 0; - if (empty($this->localtax2_tx)) - $this->localtax2_tx = 0; - if (empty($this->localtax1_type)) - $this->localtax1_type = 0; - if (empty($this->localtax2_type)) - $this->localtax2_type = 0; - if (empty($this->total_localtax1)) - $this->total_localtax1 = 0; - if (empty($this->total_localtax2)) - $this->total_localtax2 = 0; - if (empty($this->rang)) - $this->rang = 0; - if (empty($this->remise_percent)) - $this->remise_percent = 0; - if (empty($this->info_bits)) - $this->info_bits = 0; - if (empty($this->subprice)) - $this->subprice = 0; - if (empty($this->special_code)) - $this->special_code = 0; - if (empty($this->fk_parent_line)) - $this->fk_parent_line = 0; - if (empty($this->fk_prev_id)) - $this->fk_prev_id = 0; - if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') - $this->situation_percent = 100; + // Clean parameters + $this->desc=trim($this->desc); + if (empty($this->tva_tx)) $this->tva_tx=0; + if (empty($this->localtax1_tx)) $this->localtax1_tx=0; + if (empty($this->localtax2_tx)) $this->localtax2_tx=0; + if (empty($this->localtax1_type)) $this->localtax1_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->rang)) $this->rang=0; + if (empty($this->remise_percent)) $this->remise_percent=0; + if (empty($this->info_bits)) $this->info_bits=0; + if (empty($this->subprice)) $this->subprice=0; + if (empty($this->special_code)) $this->special_code=0; + if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + if (empty($this->fk_prev_id)) $this->fk_prev_id = 0; + if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; - if (empty($this->pa_ht)) - $this->pa_ht = 0; - if (empty($this->multicurrency_subprice)) - $this->multicurrency_subprice = 0; - if (empty($this->multicurrency_total_ht)) - $this->multicurrency_total_ht = 0; - if (empty($this->multicurrency_total_tva)) - $this->multicurrency_total_tva = 0; - if (empty($this->multicurrency_total_ttc)) - $this->multicurrency_total_ttc = 0; + if (empty($this->pa_ht)) $this->pa_ht=0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0 && $pa_ht_isemptystring) { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { - return $result; - } else { - $this->pa_ht = $result; - } - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0 && $pa_ht_isemptystring) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } - // Check parameters - if ($this->product_type < 0) { - $this->error = 'ErrorProductTypeMustBe0orMore'; - return -1; - } - if (!empty($this->fk_product)) { - // Check product exists - $result = Product::isExistingObject('product', $this->fk_product); - if ($result <= 0) { - $this->error = 'ErrorProductIdDoesNotExists'; - return -1; - } - } + // Check parameters + if ($this->product_type < 0) + { + $this->error='ErrorProductTypeMustBe0orMore'; + return -1; + } + if (! empty($this->fk_product)) + { + // Check product exists + $result=Product::isExistingObject('product', $this->fk_product); + if ($result <= 0) + { + $this->error='ErrorProductIdDoesNotExists'; + return -1; + } + } - $this->db->begin(); + $this->db->begin(); - // Insertion dans base de la ligne - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'facturedet'; - $sql .= ' (fk_facture, fk_parent_line, label, description, qty,'; - $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql .= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; - $sql .= ' date_start, date_end, fk_code_ventilation, '; - $sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; - $sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; - $sql .= ' situation_percent, fk_prev_id,'; - $sql .= ' fk_unit, fk_user_author, fk_user_modif,'; - $sql .= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql .= ')'; - $sql .= " VALUES (" . $this->fk_facture . ","; - $sql .= " " . ($this->fk_parent_line > 0 ? $this->fk_parent_line : "null") . ","; - $sql .= " " . (!empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : "null") . ","; - $sql .= " '" . $this->db->escape($this->desc) . "',"; - $sql .= " " . price2num($this->qty) . ","; - $sql .= " " . (empty($this->vat_src_code) ? "''" : "'" . $this->db->escape($this->vat_src_code) . "'") . ","; - $sql .= " " . price2num($this->tva_tx) . ","; - $sql .= " " . price2num($this->localtax1_tx) . ","; - $sql .= " " . price2num($this->localtax2_tx) . ","; - $sql .= " '" . $this->db->escape($this->localtax1_type) . "',"; - $sql .= " '" . $this->db->escape($this->localtax2_type) . "',"; - $sql .= ' ' . (!empty($this->fk_product) ? $this->fk_product : "null") . ','; - $sql .= " " . $this->product_type . ","; - $sql .= " " . price2num($this->remise_percent) . ","; - $sql .= " " . price2num($this->subprice) . ","; - $sql .= ' ' . (!empty($this->fk_remise_except) ? $this->fk_remise_except : "null") . ','; - $sql .= " " . (!empty($this->date_start) ? "'" . $this->db->idate($this->date_start) . "'" : "null") . ","; - $sql .= " " . (!empty($this->date_end) ? "'" . $this->db->idate($this->date_end) . "'" : "null") . ","; - $sql .= ' ' . $this->fk_code_ventilation . ','; - $sql .= ' ' . $this->rang . ','; - $sql .= ' ' . $this->special_code . ','; - $sql .= ' ' . (!empty($this->fk_fournprice) ? $this->fk_fournprice : "null") . ','; - $sql .= ' ' . price2num($this->pa_ht) . ','; - $sql .= " '" . $this->db->escape($this->info_bits) . "',"; - $sql .= " " . price2num($this->total_ht) . ","; - $sql .= " " . price2num($this->total_tva) . ","; - $sql .= " " . price2num($this->total_ttc) . ","; - $sql .= " " . price2num($this->total_localtax1) . ","; - $sql .= " " . price2num($this->total_localtax2); - $sql .= ", " . $this->situation_percent; - $sql .= ", " . (!empty($this->fk_prev_id) ? $this->fk_prev_id : "null"); - $sql .= ", " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql .= ", " . $user->id; - $sql .= ", " . $user->id; - $sql .= ", " . (int) $this->fk_multicurrency; - $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'"; - $sql .= ", " . price2num($this->multicurrency_subprice); - $sql .= ", " . price2num($this->multicurrency_total_ht); - $sql .= ", " . price2num($this->multicurrency_total_tva); - $sql .= ", " . price2num($this->multicurrency_total_ttc); - $sql .= ')'; + // Insertion dans base de la ligne + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; + $sql.= ' (fk_facture, fk_parent_line, label, description, qty,'; + $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; + $sql.= ' date_start, date_end, fk_code_ventilation, '; + $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; + $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; + $sql.= ' situation_percent, fk_prev_id,'; + $sql.= ' fk_unit, fk_user_author, fk_user_modif,'; + $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql.= ')'; + $sql.= " VALUES (".$this->fk_facture.","; + $sql.= " ".($this->fk_parent_line>0 ? $this->fk_parent_line:"null").","; + $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; + $sql.= " '".$this->db->escape($this->desc)."',"; + $sql.= " ".price2num($this->qty).","; + $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").","; + $sql.= " ".price2num($this->tva_tx).","; + $sql.= " ".price2num($this->localtax1_tx).","; + $sql.= " ".price2num($this->localtax2_tx).","; + $sql.= " '".$this->db->escape($this->localtax1_type)."',"; + $sql.= " '".$this->db->escape($this->localtax2_type)."',"; + $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").','; + $sql.= " ".$this->product_type.","; + $sql.= " ".price2num($this->remise_percent).","; + $sql.= " ".price2num($this->subprice).","; + $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").','; + $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").","; + $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").","; + $sql.= ' '.$this->fk_code_ventilation.','; + $sql.= ' '.$this->rang.','; + $sql.= ' '.$this->special_code.','; + $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").','; + $sql.= ' '.price2num($this->pa_ht).','; + $sql.= " '".$this->db->escape($this->info_bits)."',"; + $sql.= " ".price2num($this->total_ht).","; + $sql.= " ".price2num($this->total_tva).","; + $sql.= " ".price2num($this->total_ttc).","; + $sql.= " ".price2num($this->total_localtax1).","; + $sql.= " ".price2num($this->total_localtax2); + $sql.= ", " . $this->situation_percent; + $sql.= ", " . (!empty($this->fk_prev_id)?$this->fk_prev_id:"null"); + $sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql.= ", ".$user->id; + $sql.= ", ".$user->id; + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".price2num($this->multicurrency_subprice); + $sql.= ", ".price2num($this->multicurrency_total_ht); + $sql.= ", ".price2num($this->multicurrency_total_tva); + $sql.= ", ".price2num($this->multicurrency_total_ttc); + $sql.= ')'; - dol_syslog(get_class($this) . "::insert", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . 'facturedet'); - $this->rowid = $this->id; // For backward compatibility + dol_syslog(get_class($this)."::insert", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); + $this->rowid=$this->id; // For backward compatibility - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used - $result = $this->insertExtraFields(); - if ($result < 0) { - $error++; - } + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } - // Si fk_remise_except defini, on lie la remise a la facture - // ce qui la flague comme "consommee". - if ($this->fk_remise_except) { - $discount = new DiscountAbsolute($this->db); - $result = $discount->fetch($this->fk_remise_except); - if ($result >= 0) { - // Check if discount was found - if ($result > 0) { - // Check if discount not already affected to another invoice - if ($discount->fk_facture_line > 0) { - if (empty($noerrorifdiscountalreadylinked)) { - $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id); - dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } - } else { - $result = $discount->link_to_invoice($this->rowid, 0); - if ($result < 0) { - $this->error = $discount->error; - dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } - } - } else { - $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); - dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } - } else { - $this->error = $discount->error; - dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } - } + // Si fk_remise_except defini, on lie la remise a la facture + // ce qui la flague comme "consommee". + if ($this->fk_remise_except) + { + $discount=new DiscountAbsolute($this->db); + $result=$discount->fetch($this->fk_remise_except); + if ($result >= 0) + { + // Check if discount was found + if ($result > 0) + { + // Check if discount not already affected to another invoice + if ($discount->fk_facture_line > 0) + { + if (empty($noerrorifdiscountalreadylinked)) + { + $this->error=$langs->trans("ErrorDiscountAlreadyUsed",$discount->id); + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } + } + else + { + $result=$discount->link_to_invoice($this->rowid,0); + if ($result < 0) + { + $this->error=$discount->error; + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } + } + } + else + { + $this->error=$langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } + } + else + { + $this->error=$discount->error; + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } + } - if (!$notrigger) { + if (! $notrigger) + { // Call trigger - $result = $this->call_trigger('LINEBILL_INSERT', $user); - if ($result < 0) { - $this->db->rollback(); - return -2; - } + $result=$this->call_trigger('LINEBILL_INSERT',$user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } // End call triggers - } + } - $this->db->commit(); - return $this->id; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; - } - } + $this->db->commit(); + return $this->id; - /** - * Update line into database - * - * @param User $user User object - * @param int $notrigger Disable triggers - * @return int <0 if KO, >0 if OK - */ - function update($user = '', $notrigger = 0) { - global $user, $conf; + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } - $error = 0; + /** + * Update line into database + * + * @param User $user User object + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user='',$notrigger=0) + { + global $user,$conf; - $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. - // Clean parameters - $this->desc = trim($this->desc); - if (empty($this->tva_tx)) - $this->tva_tx = 0; - if (empty($this->localtax1_tx)) - $this->localtax1_tx = 0; - if (empty($this->localtax2_tx)) - $this->localtax2_tx = 0; - if (empty($this->localtax1_type)) - $this->localtax1_type = 0; - if (empty($this->localtax2_type)) - $this->localtax2_type = 0; - if (empty($this->total_localtax1)) - $this->total_localtax1 = 0; - if (empty($this->total_localtax2)) - $this->total_localtax2 = 0; - if (empty($this->remise_percent)) - $this->remise_percent = 0; - if (empty($this->info_bits)) - $this->info_bits = 0; - if (empty($this->special_code)) - $this->special_code = 0; - if (empty($this->product_type)) - $this->product_type = 0; - if (empty($this->fk_parent_line)) - $this->fk_parent_line = 0; - if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') - $this->situation_percent = 100; - if (empty($this->pa_ht)) - $this->pa_ht = 0; + $error=0; - if (empty($this->multicurrency_subprice)) - $this->multicurrency_subprice = 0; - if (empty($this->multicurrency_total_ht)) - $this->multicurrency_total_ht = 0; - if (empty($this->multicurrency_total_tva)) - $this->multicurrency_total_tva = 0; - if (empty($this->multicurrency_total_ttc)) - $this->multicurrency_total_ttc = 0; + $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. - // Check parameters - if ($this->product_type < 0) - return -1; + // Clean parameters + $this->desc=trim($this->desc); + if (empty($this->tva_tx)) $this->tva_tx=0; + if (empty($this->localtax1_tx)) $this->localtax1_tx=0; + if (empty($this->localtax2_tx)) $this->localtax2_tx=0; + if (empty($this->localtax1_type)) $this->localtax1_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->remise_percent)) $this->remise_percent=0; + if (empty($this->info_bits)) $this->info_bits=0; + if (empty($this->special_code)) $this->special_code=0; + if (empty($this->product_type)) $this->product_type=0; + if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; + if (empty($this->pa_ht)) $this->pa_ht=0; - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0 && $pa_ht_isemptystring) { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { - return $result; - } else { - $this->pa_ht = $result; - } - } + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; - $this->db->begin(); + // Check parameters + if ($this->product_type < 0) return -1; + + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0 && $pa_ht_isemptystring) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } + + $this->db->begin(); // Mise a jour ligne en base - $sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet SET"; - $sql .= " description='" . $this->db->escape($this->desc) . "'"; - $sql .= ", label=" . (!empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : "null"); - $sql .= ", subprice=" . price2num($this->subprice) . ""; - $sql .= ", remise_percent=" . price2num($this->remise_percent) . ""; - if ($this->fk_remise_except) - $sql .= ", fk_remise_except=" . $this->fk_remise_except; - else - $sql .= ", fk_remise_except=null"; - $sql .= ", vat_src_code = '" . (empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code)) . "'"; - $sql .= ", tva_tx=" . price2num($this->tva_tx) . ""; - $sql .= ", localtax1_tx=" . price2num($this->localtax1_tx) . ""; - $sql .= ", localtax2_tx=" . price2num($this->localtax2_tx) . ""; - $sql .= ", localtax1_type='" . $this->db->escape($this->localtax1_type) . "'"; - $sql .= ", localtax2_type='" . $this->db->escape($this->localtax2_type) . "'"; - $sql .= ", qty=" . price2num($this->qty); - $sql .= ", date_start=" . (!empty($this->date_start) ? "'" . $this->db->idate($this->date_start) . "'" : "null"); - $sql .= ", date_end=" . (!empty($this->date_end) ? "'" . $this->db->idate($this->date_end) . "'" : "null"); - $sql .= ", product_type=" . $this->product_type; - $sql .= ", info_bits='" . $this->db->escape($this->info_bits) . "'"; - $sql .= ", special_code='" . $this->db->escape($this->special_code) . "'"; - if (empty($this->skip_update_total)) { - $sql .= ", total_ht=" . price2num($this->total_ht); - $sql .= ", total_tva=" . price2num($this->total_tva); - $sql .= ", total_ttc=" . price2num($this->total_ttc); - $sql .= ", total_localtax1=" . price2num($this->total_localtax1); - $sql .= ", total_localtax2=" . price2num($this->total_localtax2); + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; + $sql.= " description='".$this->db->escape($this->desc)."'"; + $sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); + $sql.= ", subprice=".price2num($this->subprice).""; + $sql.= ", remise_percent=".price2num($this->remise_percent).""; + if ($this->fk_remise_except) $sql.= ", fk_remise_except=".$this->fk_remise_except; + else $sql.= ", fk_remise_except=null"; + $sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->db->escape($this->vat_src_code))."'"; + $sql.= ", tva_tx=".price2num($this->tva_tx).""; + $sql.= ", localtax1_tx=".price2num($this->localtax1_tx).""; + $sql.= ", localtax2_tx=".price2num($this->localtax2_tx).""; + $sql.= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql.= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql.= ", qty=".price2num($this->qty); + $sql.= ", date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null"); + $sql.= ", date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); + $sql.= ", product_type=".$this->product_type; + $sql.= ", info_bits='".$this->db->escape($this->info_bits)."'"; + $sql.= ", special_code='".$this->db->escape($this->special_code)."'"; + if (empty($this->skip_update_total)) + { + $sql.= ", total_ht=".price2num($this->total_ht); + $sql.= ", total_tva=".price2num($this->total_tva); + $sql.= ", total_ttc=".price2num($this->total_ttc); + $sql.= ", total_localtax1=".price2num($this->total_localtax1); + $sql.= ", total_localtax2=".price2num($this->total_localtax2); } - $sql .= ", fk_product_fournisseur_price=" . (!empty($this->fk_fournprice) ? "'" . $this->db->escape($this->fk_fournprice) . "'" : "null"); - $sql .= ", buy_price_ht='" . price2num($this->pa_ht) . "'"; - $sql .= ", fk_parent_line=" . ($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); - if (!empty($this->rang)) - $sql .= ", rang=" . $this->rang; - $sql .= ", situation_percent=" . $this->situation_percent; - $sql .= ", fk_unit=" . (!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql .= ", fk_user_modif =" . $user->id; + $sql.= ", fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); + $sql.= ", buy_price_ht='".price2num($this->pa_ht)."'"; + $sql.= ", fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); + if (! empty($this->rang)) $sql.= ", rang=".$this->rang; + $sql.= ", situation_percent=" . $this->situation_percent; + $sql.= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql.= ", fk_user_modif =".$user->id; - // Multicurrency - $sql .= ", multicurrency_subprice=" . price2num($this->multicurrency_subprice) . ""; - $sql .= ", multicurrency_total_ht=" . price2num($this->multicurrency_total_ht) . ""; - $sql .= ", multicurrency_total_tva=" . price2num($this->multicurrency_total_tva) . ""; - $sql .= ", multicurrency_total_ttc=" . price2num($this->multicurrency_total_ttc) . ""; + // Multicurrency + $sql.= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + $sql.= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; + $sql.= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; + $sql.= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql .= " WHERE rowid = " . $this->rowid; + $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog(get_class($this) . "::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used - $this->id = $this->rowid; - $result = $this->insertExtraFields(); - if ($result < 0) { - $error++; - } - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) { + if (! $error && ! $notrigger) + { // Call trigger - $result = $this->call_trigger('LINEBILL_UPDATE', $user); - if ($result < 0) { - $this->db->rollback(); - return -2; - } + $result=$this->call_trigger('LINEBILL_UPDATE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } // End call triggers - } - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -2; - } - } + } + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -2; + } + } - /** - * Delete line in database - * TODO Add param User $user and notrigger (see skeleton) + /** + * Delete line in database + * TODO Add param User $user and notrigger (see skeleton) * - * @return int <0 if KO, >0 if OK - */ - function delete() { - global $user; + * @return int <0 if KO, >0 if OK + */ + function delete() + { + global $user; - $this->db->begin(); + $this->db->begin(); - // Call trigger - $result = $this->call_trigger('LINEBILL_DELETE', $user); - if ($result < 0) { - $this->db->rollback(); - return -1; - } - // End call triggers + // Call trigger + $result=$this->call_trigger('LINEBILL_DELETE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet WHERE rowid = " . $this->rowid; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); - if ($this->db->query($sql)) { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error() . " sql=" . $sql; - $this->db->rollback(); - return -1; - } - } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + if ($this->db->query($sql) ) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error()." sql=".$sql; + $this->db->rollback(); + return -1; + } + } - /** - * Mise a jour en base des champs total_xxx de ligne de facture - * TODO What is goal of this method ? - * - * @return int <0 if KO, >0 if OK - */ - function update_total() { - $this->db->begin(); - dol_syslog(get_class($this) . "::update_total", LOG_DEBUG); + /** + * Mise a jour en base des champs total_xxx de ligne de facture + * TODO What is goal of this method ? + * + * @return int <0 if KO, >0 if OK + */ + function update_total() + { + $this->db->begin(); + dol_syslog(get_class($this)."::update_total", LOG_DEBUG); - // Clean parameters - if (empty($this->total_localtax1)) - $this->total_localtax1 = 0; - if (empty($this->total_localtax2)) - $this->total_localtax2 = 0; + // Clean parameters + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; - // Mise a jour ligne en base - $sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet SET"; - $sql .= " total_ht=" . price2num($this->total_ht) . ""; - $sql .= ",total_tva=" . price2num($this->total_tva) . ""; - $sql .= ",total_localtax1=" . price2num($this->total_localtax1) . ""; - $sql .= ",total_localtax2=" . price2num($this->total_localtax2) . ""; - $sql .= ",total_ttc=" . price2num($this->total_ttc) . ""; - $sql .= " WHERE rowid = " . $this->rowid; + // Mise a jour ligne en base + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; + $sql.= " total_ht=".price2num($this->total_ht).""; + $sql.= ",total_tva=".price2num($this->total_tva).""; + $sql.= ",total_localtax1=".price2num($this->total_localtax1).""; + $sql.= ",total_localtax2=".price2num($this->total_localtax2).""; + $sql.= ",total_ttc=".price2num($this->total_ttc).""; + $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog(get_class($this) . "::update_total", LOG_DEBUG); + dol_syslog(get_class($this)."::update_total", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -2; - } - } + $resql=$this->db->query($sql); + if ($resql) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -2; + } + } - /** - * Returns situation_percent of the previous line. - * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. - * - * @param int $invoiceid Invoice id - * @return int >= 0 - */ - function get_prev_progress($invoiceid) { - if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { - return 0; - } else { - // If invoice is a not a situation invoice, this->fk_prev_id is used for something else - $tmpinvoice = new Facture($this->db); + /** + * Returns situation_percent of the previous line. + * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. + * + * @param int $invoiceid Invoice id + * @return int >= 0 + */ + function get_prev_progress($invoiceid) + { + if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { + return 0; + } else { + // If invoice is a not a situation invoice, this->fk_prev_id is used for something else + $tmpinvoice=new Facture($this->db); $tmpinvoice->fetch($invoiceid); - if ($tmpinvoice->type != Facture::TYPE_SITUATION) - return 0; - - $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; - $resql = $this->db->query($sql); - if ($resql && $resql->num_rows > 0) { - $res = $this->db->fetch_array($resql); - return $res['situation_percent']; - } else { - $this->error = $this->db->error(); - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); - $this->db->rollback(); - return -1; - } - } - } + if ($tmpinvoice->type != Facture::TYPE_SITUATION) return 0; + $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; + $resql = $this->db->query($sql); + if ($resql && $resql->num_rows > 0) { + $res = $this->db->fetch_array($resql); + return $res['situation_percent']; + } else { + $this->error = $this->db->error(); + dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + } + } } From 303fb94acb6d286de340fa57480f14f8135d0082 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Jul 2018 13:04:37 +0200 Subject: [PATCH 121/228] Fix trans --- htdocs/langs/en_US/modulebuilder.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 460cdce63c2..30db5989587 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -96,6 +96,6 @@ DropTableIfEmpty=(Delete table if empty) TableDoesNotExists=The table %s does not exists TableDropped=Table %s deleted InitStructureFromExistingTable=Build the structure array string of an existing table -UseAboutPage=Disallow the about page -UseDocFolder=Disallow the documentation folder +UseAboutPage=Disable the about page +UseDocFolder=Disable the documentation folder UseSpecificReadme=Use a specific ReadMe \ No newline at end of file From 1e565486d88d908d6bd54b0390026e29df6e0525 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 6 Jul 2018 19:17:11 +0200 Subject: [PATCH 122/228] fix : typo and update code --- htdocs/product/document.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 34337218a62..83d59a26a90 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -288,11 +288,11 @@ if ($object->id) print '
'; } - $style = 'impair'; foreach ($filearray as $filetoadd) { if ($ext = pathinfo($filetoadd['name'], PATHINFO_EXTENSION) == 'pdf') { - if ($style == 'pair') { - $style = 'impair'; - } else { - $style = 'pair'; - } - $checked = ''; $filename = $filetoadd['name']; if ($conf->global->MAIN_MULTILANGS) { - if (array_key_exists($filetoadd['name'] . '_' . $delauft_lang, $filetomerge->lines)) + if (array_key_exists($filetoadd['name'] . '_' . $default_lang, $filetomerge->lines)) { - $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $delauft_lang); + $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $default_lang); $checked = ' checked '; } } @@ -331,7 +324,7 @@ if ($object->id) } } - print ''; } From 5944c161bc7224bf81cc07fe214063de4b502406 Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 7 Jul 2018 08:41:17 +0200 Subject: [PATCH 123/228] spelling and some grammar corrections for installation texts en_US --- htdocs/langs/en_US/admin.lang | 190 ++++++++++++++++---------------- htdocs/langs/en_US/help.lang | 20 ++-- htdocs/langs/en_US/install.lang | 132 +++++++++++----------- htdocs/langs/en_US/main.lang | 16 +-- 4 files changed, 179 insertions(+), 179 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 960bee03aef..404dc6c2c37 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -10,9 +10,9 @@ VersionDevelopment=Development VersionUnknown=Unknown VersionRecommanded=Recommended FileCheck=Files integrity checker -FileCheckDesc=This tool allows you to check the integrity of files and setup of your application, comparing each files with the official ones. Value of some setup constants may also be checked. You can use this tool to detect if some files were modified by a hacker for example. +FileCheckDesc=This tool allows you to check the integrity of files and the setup of your application, comparing each file with the official one. The value of some setup constants may also be checked. You can use this tool to detect if some files were modified by a hacker, for example. FileIntegrityIsStrictlyConformedWithReference=Files integrity is strictly conformed with the reference. -FileIntegrityIsOkButFilesWereAdded=Files integrity check has passed, however some new files were added. +FileIntegrityIsOkButFilesWereAdded=Files integrity check has passed, however some new files have been added. FileIntegritySomeFilesWereRemovedOrModified=Files integrity check has failed. Some files were modified, removed or added. GlobalChecksum=Global checksum MakeIntegrityAnalysisFrom=Make integrity analysis of application files from @@ -30,14 +30,14 @@ SessionSaveHandler=Handler to save sessions SessionSavePath=Storage session localization PurgeSessions=Purge of sessions ConfirmPurgeSessions=Do you really want to purge all sessions? This will disconnect every user (except yourself). -NoSessionListWithThisHandler=Save session handler configured in your PHP does not allow to list all running sessions. +NoSessionListWithThisHandler=Save session handler configured in your PHP does not allow listing all running sessions. LockNewSessions=Lock new connections -ConfirmLockNewSessions=Are you sure you want to restrict any new Dolibarr connection to yourself. Only user %s will be able to connect after that. +ConfirmLockNewSessions=Are you sure you want to restrict any new Dolibarr connection to yourself? Only user %s will be able to connect after that. UnlockNewSessions=Remove connection lock YourSession=Your session -Sessions=Users session +Sessions=Users sessions WebUserGroup=Web server user/group -NoSessionFound=Your PHP seems to not allow to list active sessions. Directory used to save sessions (%s) might be protected (For example, by OS permissions or by PHP directive open_basedir). +NoSessionFound=Your PHP seems to not allow listing of active sessions. The directory used to save sessions (%s) might be protected (For example, by OS permissions or by PHP directive open_basedir). DBStoringCharset=Database charset to store data DBSortingCharset=Database charset to sort data ClientCharset=Client charset @@ -68,8 +68,8 @@ ErrorCodeCantContainZero=Code can't contain value 0 DisableJavascript=Disable JavaScript and Ajax functions (Recommended for blind person or text browsers) UseSearchToSelectCompanyTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant COMPANY_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseSearchToSelectContactTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant CONTACT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. -DelaiedFullListToSelectCompany=Wait you press a key before loading content of thirdparties combo list (This may increase performance if you have a large number of thirdparties, but it is less convenient) -DelaiedFullListToSelectContact=Wait you press a key before loading content of contact combo list (This may increase performance if you have a large number of contact, but it is less convenient) +DelaiedFullListToSelectCompany=Wait you press a key before loading content of third-parties combo list (This may increase performance if you have a large number of third-parties, but it is less convenient) +DelaiedFullListToSelectContact=Wait you press a key before loading content of contact combo list (This may increase performance if you have a large number of contacts, but it is less convenient) NumberOfKeyToSearch=Nbr of characters to trigger search: %s NotAvailableWhenAjaxDisabled=Not available when Ajax disabled AllowToSelectProjectFromOtherCompany=On document of a third party, can choose a project linked to another third party @@ -80,7 +80,7 @@ PreviewNotAvailable=Preview not available ThemeCurrentlyActive=Theme currently active CurrentTimeZone=TimeZone PHP (server) MySQLTimeZone=TimeZone MySql (database) -TZHasNoEffect=Dates are stored and returned by database server as if they were kept as submited string. The timezone has effect only when using UNIX_TIMESTAMP function (that should not be used by Dolibarr, so database TZ should have no effect, even if changed after data was entered). +TZHasNoEffect=Dates are stored and returned by database server as if they were kept as submitted string. The timezone has effect only when using the UNIX_TIMESTAMP function (that should not be used by Dolibarr, so database TZ should have no effect, even if changed after data was entered). Space=Space Table=Table Fields=Fields @@ -118,7 +118,7 @@ Destination=Destination IdModule=Module ID IdPermissions=Permissions ID LanguageBrowserParameter=Parameter %s -LocalisationDolibarrParameters=Localisation parameters +LocalisationDolibarrParameters=Localization parameters ClientTZ=Client Time Zone (user) ClientHour=Client time (user) OSTZ=Server OS Time Zone @@ -126,8 +126,8 @@ PHPTZ=PHP server Time Zone DaylingSavingTime=Daylight saving time CurrentHour=PHP Time (server) CurrentSessionTimeOut=Current session timeout -YouCanEditPHPTZ=To set a different PHP timezone (not required), you can try to add a file .htaccess with a line like this "SetEnv TZ Europe/Paris" -HoursOnThisPageAreOnServerTZ=Warning, in contrary of other screens, hours on this page are not in your local timezone, but for the timezone of the server. +YouCanEditPHPTZ=To set a different PHP timezone (not required), you can try to add a .htaccess file with a line like this "SetEnv TZ Europe/Paris" +HoursOnThisPageAreOnServerTZ=Warning, in contrary of other screens, hours on this page are not in your local timezone, but of the timezone of the server. Box=Widget Boxes=Widgets MaxNbOfLinesForBoxes=Max number of lines for widgets @@ -195,10 +195,10 @@ BoxesDesc=Widgets are components showing some information that you can add to pe OnlyActiveElementsAreShown=Only elements from enabled modules are shown. ModulesDesc=Dolibarr modules define which application/feature is enabled in software. Some application/modules require permissions you must grant to users, after activating it. Click on button on/off to enable a module/application. ModulesMarketPlaceDesc=You can find more modules to download on external websites on the Internet... -ModulesDeployDesc=If permissions on your file system allows it, you can use this tool to deploy an external module. The module wil then be visible on the tab %s. +ModulesDeployDesc=If permissions on your file system allows it, you can use this tool to deploy an external module. The module will then be visible on the tab %s. ModulesMarketPlaces=Find external app/modules ModulesDevelopYourModule=Develop your own app/modules -ModulesDevelopDesc=You can develop or find a partner to develop for you, your personalised module +ModulesDevelopDesc=You can develop or find a partner to develop for you, your personalized module DOLISTOREdescriptionLong=Instead of switching on www.dolistore.com web site to find an external module, you can use this embedded tool that will make the seach on the external market place for you (may be slow, need an internet access)... NewModule=New FreeModule=Free @@ -246,8 +246,8 @@ ExternalResources=External resources SocialNetworks=Social Networks ForDocumentationSeeWiki=For user or developer documentation (Doc, FAQs...),
take a look at the Dolibarr Wiki:
%s ForAnswersSeeForum=For any other questions/help, you can use the Dolibarr forum:
%s -HelpCenterDesc1=This area can help you to get a Help support service on Dolibarr. -HelpCenterDesc2=Some part of this service are available in english only. +HelpCenterDesc1=Here are some resources for getting help and support with Dolibarr. +HelpCenterDesc2=Some of these resources are only available in english. CurrentMenuHandler=Current menu handler MeasuringUnit=Measuring unit LeftMargin=Left margin @@ -269,20 +269,20 @@ MAIN_MAIL_SMTP_SERVER=SMTP/SMTPS Host (By default in php.ini: %s) MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=SMTP/SMTPS Port (Not defined into PHP on Unix like systems) MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=SMTP/SMTPS Host (Not defined into PHP on Unix like systems) MAIN_MAIL_EMAIL_FROM=Sender email for automatic emails (By default in php.ini: %s) -MAIN_MAIL_ERRORS_TO=Eemail used for error returns emails (fields 'Errors-To' in emails sent) +MAIN_MAIL_ERRORS_TO=Email used for error returns emails (fields 'Errors-To' in emails sent) MAIN_MAIL_AUTOCOPY_TO= Send systematically a hidden carbon-copy of all sent emails to -MAIN_DISABLE_ALL_MAILS=Disable all emails sendings (for test purposes or demos) +MAIN_DISABLE_ALL_MAILS=Disable all email sending (for test purposes or demos) MAIN_MAIL_FORCE_SENDTO=Send all emails to (instead of real recipients, for test purposes) -MAIN_MAIL_ENABLED_USER_DEST_SELECT=Add employees users with email into allowed destinaries list +MAIN_MAIL_ENABLED_USER_DEST_SELECT=Add employees users with email into allowed recipient list MAIN_MAIL_SENDMODE=Method to use to send EMails MAIN_MAIL_SMTPS_ID=SMTP ID if authentication required MAIN_MAIL_SMTPS_PW=SMTP Password if authentication required MAIN_MAIL_EMAIL_TLS= Use TLS (SSL) encrypt MAIN_MAIL_EMAIL_STARTTLS= Use TLS (STARTTLS) encrypt -MAIN_DISABLE_ALL_SMS=Disable all SMS sendings (for test purposes or demos) +MAIN_DISABLE_ALL_SMS=Disable all SMS sending (for test purposes or demos) MAIN_SMS_SENDMODE=Method to use to send SMS -MAIN_MAIL_SMS_FROM=Default sender phone number for Sms sending -MAIN_MAIL_DEFAULT_FROMTYPE=Sender email by default for manual sendings (User email or Company email) +MAIN_MAIL_SMS_FROM=Default sender phone number for SMS sending +MAIN_MAIL_DEFAULT_FROMTYPE=Sender email by default for manual sending (User email or Company email) UserEmail=User email CompanyEmail=Company email FeatureNotAvailableOnLinux=Feature not available on Unix like systems. Test your sendmail program locally. @@ -317,7 +317,7 @@ SetupIsReadyForUse=Module deployment is finished. You must however enable and se NotExistsDirect=The alternative root directory is not defined to an existing directory.
InfDirAlt=Since version 3, it is possible to define an alternative root directory. This allows you to store, into a dedicated directory, plug-ins and custom templates.
Just create a directory at the root of Dolibarr (eg: custom).
InfDirExample=
Then declare it in the file conf.php
$dolibarr_main_url_root_alt='/custom'
$dolibarr_main_document_root_alt='/path/of/dolibarr/htdocs/custom'
If these lines are commented with "#", to enable them, just uncomment by removing the "#" character. -YouCanSubmitFile=For this step, you can submit the .zip file of module package here : +YouCanSubmitFile=For this step, you can submit the .zip file of module package here: CurrentVersion=Dolibarr current version CallUpdatePage=Go to the page that updates the database structure and data: %s. LastStableVersion=Latest stable version @@ -370,9 +370,9 @@ ResponseTimeout=Response timeout SmsTestMessage=Test message from __PHONEFROM__ to __PHONETO__ ModuleMustBeEnabledFirst=Module %s must be enabled first if you need this feature. SecurityToken=Key to secure URLs -NoSmsEngine=No SMS sender manager available. SMS sender manager are not installed with default distribution (because they depends on an external supplier) but you can find some on %s +NoSmsEngine=No SMS sender manager available. A SMS sender manager is not installed with the default distribution because they depend on an external supplier, but you can find some on %s PDF=PDF -PDFDesc=You can set each global options related to the PDF generation +PDFDesc=You can set each global option related to the PDF generation PDFAddressForging=Rules to forge address boxes HideAnyVATInformationOnPDF=Hide all information related to Sales tax / VAT on generated PDF PDFRulesForSalesTax=Rules for Sales Tax / VAT @@ -387,7 +387,7 @@ UrlGenerationParameters=Parameters to secure URLs SecurityTokenIsUnique=Use a unique securekey parameter for each URL EnterRefToBuildUrl=Enter reference for object %s GetSecuredUrl=Get calculated URL -ButtonHideUnauthorized=Hide buttons to non admin users for unauthorized actions instead of showing greyed disabled buttons +ButtonHideUnauthorized=Hide buttons to non-admin users for unauthorized actions instead of showing greyed disabled buttons OldVATRates=Old VAT rate NewVATRates=New VAT rate PriceBaseTypeToChange=Modify on prices with base reference value defined on @@ -432,7 +432,7 @@ DefaultLink=Default link SetAsDefault=Set as default ValueOverwrittenByUserSetup=Warning, this value may be overwritten by user specific setup (each user can set his own clicktodial url) ExternalModule=External module - Installed into directory %s -BarcodeInitForThirdparties=Mass barcode init for thirdparties +BarcodeInitForthird-parties=Mass barcode init for third-parties BarcodeInitForProductsOrServices=Mass barcode init or reset for products or services CurrentlyNWithoutBarCode=Currently, you have %s record on %s %s without barcode defined. InitEmptyBarCode=Init value for next %s empty records @@ -446,14 +446,14 @@ NoDetails=No more details in footer DisplayCompanyInfo=Display company address DisplayCompanyManagers=Display manager names DisplayCompanyInfoAndManagers=Display company address and manager names -EnableAndSetupModuleCron=If you want to have this recurring invoice beeing generated automatically, module *%s* must be enabled and correctly setup. Otherwise, generation of invoices must be done manually from this template with button *Create*. Note that even if you enabled automatic generation, you can still safely launch manual generation. Duplicates generation for same period are not possible. +EnableAndSetupModuleCron=If you want to have this recurring invoice generated automatically, module *%s* must be enabled and correctly setup. Otherwise, generation of invoices must be done manually from this template using the *Create* button. Note that even if you enabled automatic generation, you can still safely launch manual generation. Generation of duplicates for the same period is not possible. ModuleCompanyCodeCustomerAquarium=%s followed by third party customer code for a customer accounting code ModuleCompanyCodeSupplierAquarium=%s followed by third party supplier code for a supplier accounting code ModuleCompanyCodePanicum=Return an empty accounting code. ModuleCompanyCodeDigitaria=Accounting code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code. Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).
Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required. UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than... -WarningPHPMail=WARNING: It is often better to setup outgoing emails to use the email server of your provider instead of the default setup. Some email providers (like Yahoo) does not allow you to send an email from another server than their own server. Your current setup use the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not a server of them, so few of your sent Emails may not be accepted (be carefull also to your email provider sending quota).
If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account). +WarningPHPMail=WARNING: It is often better to setup outgoing emails to use the email server of your provider instead of the default setup. Some email providers (like Yahoo) do not allow you to send an email from another server than their own server. Your current setup uses the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not a server of them, so few of your sent Emails may not be accepted (be careful also to your email provider sending quota).
If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account). WarningPHPMail2=If your email SMTP provider need to restrict email client to some IP addresses (very rare), this is the IP address of the mail user agent (MUA) for your ERP CRM application: %s. ClickToShowDescription=Click to show description DependsOn=This module need the module(s) @@ -461,10 +461,10 @@ RequiredBy=This module is required by module(s) TheKeyIsTheNameOfHtmlField=This is the name of the HTML field. This need to have technical knowledges to read the content of the HTML page to get the key name of a field. PageUrlForDefaultValues=You must enter here the relative url of the page. If you include parameters in URL, the default values will be effective if all parameters are set to same value. Examples: PageUrlForDefaultValuesCreate=
For form to create a new thirdparty, it is %s,
If you want default value only if url has some parameter, you can use %s -PageUrlForDefaultValuesList=
For page that list thirdparties, it is %s,
If you want default value only if url has some parameter, you can use %s +PageUrlForDefaultValuesList=
For page that list third-parties, it is %s,
If you want default value only if url has some parameter, you can use %s EnableDefaultValues=Enable usage of personalized default values EnableOverwriteTranslation=Enable usage of overwrote translation -GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation. +GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code. To change this value, you must edit it from Home-Setup-translation. WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order and restore default behavior. Field=Field ProductDocumentTemplates=Document templates to generate product document @@ -511,13 +511,13 @@ Module52Desc=Stock management (products) Module53Name=Services Module53Desc=Service management Module54Name=Contracts/Subscriptions -Module54Desc=Management of contracts (services or reccuring subscriptions) +Module54Desc=Management of contracts (services or recurring subscriptions) Module55Name=Barcodes Module55Desc=Barcode management Module56Name=Telephony Module56Desc=Telephony integration Module57Name=Direct bank payment orders -Module57Desc=Management of Direct Debit payment orders. It includes generation of SEPA file for european countries. +Module57Desc=Management of Direct Debit payment orders. It includes generation of SEPA file for European countries. Module58Name=ClickToDial Module58Desc=Integration of a ClickToDial system (Asterisk, ...) Module59Name=Bookmark4u @@ -531,17 +531,17 @@ Module80Desc=Shipments and delivery order management Module85Name=Banks and cash Module85Desc=Management of bank or cash accounts Module100Name=External site -Module100Desc=This module include an external web site or page into Dolibarr menus and view it into a Dolibarr frame +Module100Desc=This module includes an external web site or page into Dolibarr menus and view it into a Dolibarr frame Module105Name=Mailman and SPIP Module105Desc=Mailman or SPIP interface for member module Module200Name=LDAP -Module200Desc=LDAP directory synchronisation +Module200Desc=LDAP directory synchronization Module210Name=PostNuke Module210Desc=PostNuke integration Module240Name=Data exports Module240Desc=Tool to export Dolibarr data (with assistants) Module250Name=Data imports -Module250Desc=Tool to import data in Dolibarr (with assistants) +Module250Desc=Tool to import data in Dolibarr (with assistants) Module310Name=Members Module310Desc=Foundation members management Module320Name=RSS Feed @@ -582,7 +582,7 @@ Module2200Desc=Enable the usage of math expressions for prices Module2300Name=Scheduled jobs Module2300Desc=Scheduled jobs management (alias cron or chrono table) Module2400Name=Events/Agenda -Module2400Desc=Follow done and upcoming events. Let application logs automatic events for tracking purposes or record manual events or rendez-vous. This is the main important module for a good Customer or Supplier Relationship Management. +Module2400Desc=Follow done and upcoming events. Let application log automatic events for tracking purposes or record manual events or rendezvous. This is the main important module for a good Customer or Supplier Relationship Management. Module2500Name=DMS / ECM Module2500Desc=Document Management System / Electronic Content Management. Automatic organization of your generated or stored documents. Share them when you need. Module2600Name=API/Web services (SOAP server) @@ -621,7 +621,7 @@ Module50200Desc=Module to offer an online payment page accepting payments using Module50400Name=Accounting (advanced) Module50400Desc=Accounting management (double entries, support general and auxiliary ledgers). Export the ledger in several other accounting software format. Module54000Name=PrintIPP -Module54000Desc=Direct print (without opening the documents) using Cups IPP interface (Printer must be visible from server, and CUPS must be installe on server). +Module54000Desc=Direct print (without opening the documents) using Cups IPP interface (Printer must be visible from server, and CUPS must be installed on server). Module55000Name=Poll, Survey or Vote Module55000Desc=Module to make online polls, surveys or votes (like Doodle, Studs, Rdvz, ...) Module59000Name=Margins @@ -651,9 +651,9 @@ Permission32=Create/modify products Permission34=Delete products Permission36=See/manage hidden products Permission38=Export products -Permission41=Read projects and tasks (shared project and projects i'm contact for). Can also enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) -Permission42=Create/modify projects (shared project and projects i'm contact for). Can also create tasks and assign users to project and tasks -Permission44=Delete projects (shared project and projects i'm contact for) +Permission41=Read projects and tasks (shared project and projects I'm contact for). Can also enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) +Permission42=Create/modify projects (shared project and projects I'm contact for). Can also create tasks and assign users to project and tasks +Permission44=Delete projects (shared project and projects I'm contact for) Permission45=Export projects Permission61=Read interventions Permission62=Create/modify interventions @@ -725,7 +725,7 @@ Permission187=Close supplier orders Permission188=Cancel supplier orders Permission192=Create lines Permission193=Cancel lines -Permission194=Read the bandwith lines +Permission194=Read the bandwidth lines Permission202=Create ADSL connections Permission203=Order connections orders Permission204=Order connections @@ -750,12 +750,12 @@ Permission244=See the contents of the hidden categories Permission251=Read other users and groups PermissionAdvanced251=Read other users Permission252=Read permissions of other users -Permission253=Create/modify other users, groups and permisssions +Permission253=Create/modify other users, groups and permissions PermissionAdvanced253=Create/modify internal/external users and permissions Permission254=Create/modify external users only Permission255=Modify other users password Permission256=Delete or disable other users -Permission262=Extend access to all third parties (not only third parties that user is a sale representative).
Not effective for external users (always limited to themselves for proposals, orders, invoices, contracts, etc).
Not effective for projects (only rules on project permissions, visibility and assignement matters). +Permission262=Extend access to all third parties (not only third parties that user is a sale representative).
Not effective for external users (always limited to themselves for proposals, orders, invoices, contracts, etc.).
Not effective for projects (only rules on project permissions, visibility and assignment matters). Permission271=Read CA Permission272=Read invoices Permission273=Issue invoices @@ -880,8 +880,8 @@ Permission63001=Read resources Permission63002=Create/modify resources Permission63003=Delete resources Permission63004=Link resources to agenda events -DictionaryCompanyType=Types of thirdparties -DictionaryCompanyJuridicalType=Legal forms of thirdparties +DictionaryCompanyType=Types of third-parties +DictionaryCompanyJuridicalType=Legal forms of third-parties DictionaryProspectLevel=Prospect potential level DictionaryCanton=State/Province DictionaryRegion=Regions @@ -921,8 +921,8 @@ BackToModuleList=Back to modules list BackToDictionaryList=Back to dictionaries list TypeOfRevenueStamp=Type of tax stamp VATManagement=VAT Management -VATIsUsedDesc=By default when creating prospects, invoices, orders etc the VAT rate follows the active standard rule:
If the seller is not subjected to VAT, then VAT defaults to 0. End of rule.
If the (selling country= buying country), then the VAT by default equals the VAT of the product in the selling country. End of rule.
If seller and buyer are both in the European Community and goods are transport products (car, ship, plane), the default VAT is 0 ( The VAT should be paid by the buyer to the customoffice of his country and not to the seller). End of rule.
If seller and buyer are both in the European Community and the buyer is not a company, then the VAT by defaults to the VAT of the product sold. End of rule.
If seller and buyer are both in the European Community and the buyer is a company, then the VAT is 0 by default . End of rule.
In any othe case the proposed default is VAT=0. End of rule. -VATIsNotUsedDesc=By default the proposed VAT is 0 which can be used for cases like associations, individuals ou small companies. +VATIsUsedDesc=By default when creating prospects, invoices, orders etc. the VAT rate follows the active standard rule:
If the seller is not subjected to VAT, then VAT defaults to 0. End of rule.
If the (selling country= buying country), then the VAT by default equals the VAT of the product in the selling country. End of rule.
If seller and buyer are both in the European Community and goods are transport products (car, ship, plane), the default VAT is 0 (the VAT should be paid by the buyer to the customs office of his country and not to the seller). End of rule.
If seller and buyer are both in the European Community and the buyer is not a company, then the VAT by defaults to the VAT of the product sold. End of rule.
If seller and buyer are both in the European Community and the buyer is a company, then the VAT is 0 by default . End of rule.
In any other case the proposed default is VAT=0. End of rule. +VATIsNotUsedDesc=By default the proposed VAT is 0 which can be used for cases like associations, individuals or small companies. VATIsUsedExampleFR=In France, it means companies or organizations having a real fiscal system (Simplified real or normal real). A system in which VAT is declared. VATIsNotUsedExampleFR=In France, it means associations that are non VAT declared or companies, organizations or liberal professions that have chosen the micro enterprise fiscal system (VAT in franchise) and paid a franchise VAT without any VAT declaration. This choice will display the reference "Non applicable VAT - art-293B of CGI" on invoices. ##### Local Taxes ##### @@ -940,15 +940,15 @@ LocalTax2Management=Third type of tax LocalTax2IsUsedExample= LocalTax2IsNotUsedExample= LocalTax1ManagementES= RE Management -LocalTax1IsUsedDescES= The RE rate by default when creating prospects, invoices, orders etc follow the active standard rule:
If te buyer is not subjected to RE, RE by default=0. End of rule.
If the buyer is subjected to RE then the RE by default. End of rule.
+LocalTax1IsUsedDescES= The RE rate by default when creating prospects, invoices, orders etc. follow the active standard rule:
If the buyer is not subjected to RE, RE by default=0. End of rule.
If the buyer is subjected to RE then the RE by default. End of rule.
LocalTax1IsNotUsedDescES= By default the proposed RE is 0. End of rule. LocalTax1IsUsedExampleES= In Spain they are professionals subject to some specific sections of the Spanish IAE. LocalTax1IsNotUsedExampleES= In Spain they are professional and societies and subject to certain sections of the Spanish IAE. LocalTax2ManagementES= IRPF Management -LocalTax2IsUsedDescES= The RE rate by default when creating prospects, invoices, orders etc follow the active standard rule:
If the seller is not subjected to IRPF, then IRPF by default=0. End of rule.
If the seller is subjected to IRPF then the IRPF by default. End of rule.
+LocalTax2IsUsedDescES= The RE rate by default when creating prospects, invoices, orders etc. follow the active standard rule:
If the seller is not subjected to IRPF, then IRPF by default=0. End of rule.
If the seller is subjected to IRPF then the IRPF by default. End of rule.
LocalTax2IsNotUsedDescES= By default the proposed IRPF is 0. End of rule. LocalTax2IsUsedExampleES= In Spain, freelancers and independent professionals who provide services and companies who have chosen the tax system of modules. -LocalTax2IsNotUsedExampleES= In Spain they are bussines not subject to tax system of modules. +LocalTax2IsNotUsedExampleES= In Spain they are businesses not subject to tax system of modules. CalcLocaltax=Reports on local taxes CalcLocaltax1=Sales - Purchases CalcLocaltax1Desc=Local Taxes reports are calculated with the difference between localtaxes sales and localtaxes purchases @@ -996,13 +996,13 @@ Skin=Skin theme DefaultSkin=Default skin theme MaxSizeList=Max length for list DefaultMaxSizeList=Default max length for lists -DefaultMaxSizeShortList=Default max length for short lists (ie in customer card) +DefaultMaxSizeShortList=Default max length for short lists (i.e. in customer card) MessageOfDay=Message of the day MessageLogin=Login page message LoginPage=Login page BackgroundImageLogin=Background image PermanentLeftSearchForm=Permanent search form on left menu -DefaultLanguage=Default language to use (language code) +DefaultLanguage=Default language to use (variant) EnableMultilangInterface=Enable multilingual interface EnableShowLogo=Show logo on left menu CompanyInfo=Company/organization information @@ -1033,7 +1033,7 @@ Delays_MAIN_DELAY_PROPALS_TO_BILL=Delay tolerance (in days) before alert on prop Delays_MAIN_DELAY_NOT_ACTIVATED_SERVICES=Tolerance delay (in days) before alert on services to activate Delays_MAIN_DELAY_RUNNING_SERVICES=Tolerance delay (in days) before alert on expired services Delays_MAIN_DELAY_SUPPLIER_BILLS_TO_PAY=Tolerance delay (in days) before alert on unpaid supplier invoices -Delays_MAIN_DELAY_CUSTOMER_BILLS_UNPAYED=Tolerence delay (in days) before alert on unpaid client invoices +Delays_MAIN_DELAY_CUSTOMER_BILLS_UNPAYED=Tolerance delay (in days) before alert on unpaid client invoices Delays_MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE=Tolerance delay (in days) before alert on pending bank reconciliation Delays_MAIN_DELAY_MEMBERS=Tolerance delay (in days) before alert on delayed membership fee Delays_MAIN_DELAY_CHEQUES_TO_DEPOSIT=Tolerance delay (in days) before alert for cheques deposit to do @@ -1069,7 +1069,7 @@ ToActivateModule=To activate modules, go on setup Area (Home->Setup->Modules). SessionTimeOut=Time out for session SessionExplanation=This number guarantee that session will never expire before this delay, if the session cleaner is done by Internal PHP session cleaner (and nothing else). Internal PHP session cleaner does not guaranty that session will expire just after this delay. It will expire, after this delay, and when the session cleaner is ran, so every %s/%s access, but only during access made by other sessions.
Note: on some servers with an external session cleaning mechanism (cron under debian, ubuntu ...), the sessions can be destroyed after a period defined by the default session.gc_maxlifetime, no matter what the value entered here. TriggersAvailable=Available triggers -TriggersDesc=Triggers are files that will modify the behaviour of Dolibarr workflow once copied into the directory htdocs/core/triggers. They realised new actions, activated on Dolibarr events (new company creation, invoice validation, ...). +TriggersDesc=Triggers are files that will modify the behavior of Dolibarr workflow once copied into the directory htdocs/core/triggers. They realize new actions, activated on Dolibarr events (new company creation, invoice validation, ...). TriggerDisabledByName=Triggers in this file are disabled by the -NORUN suffix in their name. TriggerDisabledAsModuleDisabled=Triggers in this file are disabled as module %s is disabled. TriggerAlwaysActive=Triggers in this file are always active, whatever are the activated Dolibarr modules. @@ -1079,7 +1079,7 @@ DictionaryDesc=Insert all reference data. You can add your values to the default ConstDesc=This page allows you to edit all other parameters not available in previous pages. These are mostly reserved parameters for developers or advanced troubleshooting. For a list of options check here. MiscellaneousDesc=All other security related parameters are defined here. LimitsSetup=Limits/Precision setup -LimitsDesc=You can define limits, precisions and optimisations used by Dolibarr here +LimitsDesc=You can define limits, precisions and optimizations used by Dolibarr here MAIN_MAX_DECIMALS_UNIT=Max decimals for unit prices MAIN_MAX_DECIMALS_TOT=Max decimals for total prices MAIN_MAX_DECIMALS_SHOWN=Max decimals for prices shown on screen (Add ... after this number if you want to see ... when number is truncated when shown on screen) @@ -1088,16 +1088,16 @@ UnitPriceOfProduct=Net unit price of a product TotalPriceAfterRounding=Total price (net/vat/incl tax) after rounding ParameterActiveForNextInputOnly=Parameter effective for next input only NoEventOrNoAuditSetup=No security event has been recorded yet. This can be normal if audit has not been enabled on "setup - security - audit" page. -NoEventFoundWithCriteria=No security event has been found for such search criterias. +NoEventFoundWithCriteria=No security event has been found for this search criteria. SeeLocalSendMailSetup=See your local sendmail setup BackupDesc=To make a complete backup of Dolibarr, you must: BackupDesc2=Save content of documents directory (%s) that contains all uploaded and generated files (So it includes all dump files generated at step 1). BackupDesc3=Save content of your database (%s) into a dump file. For this, you can use following assistant. BackupDescX=Archived directory should be stored in a secure place. BackupDescY=The generated dump file should be stored in a secure place. -BackupPHPWarning=Backup can't be guaranted with this method. Prefer previous one +BackupPHPWarning=Backup cannot be guaranteed with this method. Prefer previous one RestoreDesc=To restore a Dolibarr backup, you must: -RestoreDesc2=Restore archive file (zip file for example) of documents directory to extract tree of files in documents directory of a new Dolibarr installation or into this current documents directoy (%s). +RestoreDesc2=Restore archive file (zip file for example) of documents directory to extract tree of files in documents directory of a new Dolibarr installation or into this current documents directory (%s). RestoreDesc3=Restore the data, from a backup dump file, into the database of the new Dolibarr installation or into the database of this current installation (%s). Warning, once restore is finished, you must use a login/password, that existed when backup was made, to connect again. To restore a backup database into this current installation, you can follow this assistant. RestoreMySQL=MySQL import ForcedToByAModule= This rule is forced to %s by an activated module @@ -1118,7 +1118,7 @@ MeteoPercentageMod=Percentage mode MeteoPercentageModEnabled=Percentage mode enabled MeteoUseMod=Click to use %s TestLoginToAPI=Test login to API -ProxyDesc=Some features of Dolibarr need to have an Internet access to work. Define here parameters for this. If the Dolibarr server is behind a Proxy server, those parameters tells Dolibarr how to access Internet through it. +ProxyDesc=Some features of Dolibarr need to have internet access to work. Define here the parameters for this. If the Dolibarr server is behind a Proxy server, these parameters tell Dolibarr how to access the internet through it. ExternalAccess=External access MAIN_PROXY_USE=Use a proxy server (otherwise direct access to internet) MAIN_PROXY_HOST=Name/Address of proxy server @@ -1158,7 +1158,7 @@ CurrentTranslationString=Current translation string WarningAtLeastKeyOrTranslationRequired=A search criteria is required at least for key or translation string NewTranslationStringToShow=New translation string to show OriginalValueWas=The original translation is overwritten. Original value was:

%s -TransKeyWithoutOriginalValue=You forced a new translation for the translation key '%s' that does not exists in any language files +TransKeyWithoutOriginalValue=You forced a new translation for the translation key '%s' that does not exist in any language files TotalNumberOfActivatedModules=Activated application/modules: %s / %s YouMustEnableOneModule=You must at least enable 1 module ClassNotFoundIntoPathWarning=Class %s not found into PHP path @@ -1167,15 +1167,15 @@ OnlyFollowingModulesAreOpenedToExternalUsers=Note, only following modules are op SuhosinSessionEncrypt=Session storage encrypted by Suhosin ConditionIsCurrently=Condition is currently %s YouUseBestDriver=You use driver %s that is best driver available currently. -YouDoNotUseBestDriver=You use drive %s but driver %s is recommended. -NbOfProductIsLowerThanNoPb=You have only %s products/services into database. This does not required any particular optimization. +YouDoNotUseBestDriver=You use driver %s but driver %s is recommended. +NbOfProductIsLowerThanNoPb=You have only %s products/services in the database. This does not require any particular optimization. SearchOptim=Search optimization YouHaveXProductUseSearchOptim=You have %s product into database. You should add the constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 into Home-Setup-Other, you limit the search to the beginning of strings making possible for database to use index and you should get an immediate response. -BrowserIsOK=You are using the web browser %s. This browser is ok for security and performance. -BrowserIsKO=You are using the web browser %s. This browser is known to be a bad choice for security, performance and reliability. We recommand you to use Firefox, Chrome, Opera or Safari. +BrowserIsOK=You are using the %s web browser. This browser is ok for security and performance. +BrowserIsKO=You are using the %s web browser. This browser is known to be a bad choice for security, performance and reliability. We recommend using Firefox, Chrome, Opera or Safari. XDebugInstalled=XDebug is loaded. XCacheInstalled=XCache is loaded. -AddRefInList=Display customer/supplier ref into list (select list or combobox) and most of hyperlink. Third parties will appears with name "CC12345 - SC45678 - The big company coorp", instead of "The big company coorp". +AddRefInList=Display customer/supplier ref into list (select list or combobox) and most of hyperlink. Third parties will appear with name "CC12345 - SC45678 - The big company coorp", instead of "The big company corp". AskForPreferredShippingMethod=Ask for preferred Sending Method for Third Parties. FieldEdition=Edition of field %s FillThisOnlyIfRequired=Example: +2 (fill only if timezone offset problems are experienced) @@ -1343,11 +1343,11 @@ LDAPTestSynchroMemberType=Test member type synchronization LDAPTestSearch= Test a LDAP search LDAPSynchroOK=Synchronization test successful LDAPSynchroKO=Failed synchronization test -LDAPSynchroKOMayBePermissions=Failed synchronization test. Check that connexion to server is correctly configured and allows LDAP udpates +LDAPSynchroKOMayBePermissions=Failed synchronization test. Check that the connection to the server is correctly configured and allows LDAP updates LDAPTCPConnectOK=TCP connect to LDAP server successful (Server=%s, Port=%s) LDAPTCPConnectKO=TCP connect to LDAP server failed (Server=%s, Port=%s) -LDAPBindOK=Connect/Authentificate to LDAP server successful (Server=%s, Port=%s, Admin=%s, Password=%s) -LDAPBindKO=Connect/Authentificate to LDAP server failed (Server=%s, Port=%s, Admin=%s, Password=%s) +LDAPBindOK=Connect/Authenticate to LDAP server successful (Server=%s, Port=%s, Admin=%s, Password=%s) +LDAPBindKO=Connect/Authenticate to LDAP server failed (Server=%s, Port=%s, Admin=%s, Password=%s) LDAPSetupForVersion3=LDAP server configured for version 3 LDAPSetupForVersion2=LDAP server configured for version 2 LDAPDolibarrMapping=Dolibarr Mapping @@ -1409,26 +1409,26 @@ LDAPDescMembersTypes=This page allows you to define LDAP attributes name in LDAP LDAPDescValues=Example values are designed for OpenLDAP with following loaded schemas: core.schema, cosine.schema, inetorgperson.schema). If you use thoose values and OpenLDAP, modify your LDAP config file slapd.conf to have all thoose schemas loaded. ForANonAnonymousAccess=For an authenticated access (for a write access for example) PerfDolibarr=Performance setup/optimizing report -YouMayFindPerfAdviceHere=You will find on this page some checks or advices related to performance. +YouMayFindPerfAdviceHere=You will find on this page some checks or advice related to performance. NotInstalled=Not installed, so your server is not slow down by this. ApplicativeCache=Applicative cache MemcachedNotAvailable=No applicative cache found. You can enhance performance by installing a cache server Memcached and a module able to use this cache server.
More information here http://wiki.dolibarr.org/index.php/Module_MemCached_EN.
Note that a lot of web hosting provider does not provide such cache server. MemcachedModuleAvailableButNotSetup=Module memcached for applicative cache found but setup of module is not complete. MemcachedAvailableAndSetup=Module memcached dedicated to use memcached server is enabled. OPCodeCache=OPCode cache -NoOPCodeCacheFound=No OPCode cache found. May be you use another OPCode cache than XCache or eAccelerator (good), may be you don't have OPCode cache (very bad). +NoOPCodeCacheFound=No OPCode cache found. Maybe you are using an OPCode cache other than XCache or eAccelerator (good), or maybe you don't have OPCode cache (very bad). HTTPCacheStaticResources=HTTP cache for static resources (css, img, javascript) FilesOfTypeCached=Files of type %s are cached by HTTP server FilesOfTypeNotCached=Files of type %s are not cached by HTTP server FilesOfTypeCompressed=Files of type %s are compressed by HTTP server FilesOfTypeNotCompressed=Files of type %s are not compressed by HTTP server CacheByServer=Cache by server -CacheByServerDesc=For exemple using the Apache directive "ExpiresByType image/gif A2592000" +CacheByServerDesc=For example using the Apache directive "ExpiresByType image/gif A2592000" CacheByClient=Cache by browser CompressionOfResources=Compression of HTTP responses -CompressionOfResourcesDesc=For exemple using the Apache directive "AddOutputFilterByType DEFLATE" +CompressionOfResourcesDesc=For example using the Apache directive "AddOutputFilterByType DEFLATE" TestNotPossibleWithCurrentBrowsers=Such an automatic detection is not possible with current browsers -DefaultValuesDesc=You can define/force here the default value you want to get when your create a new record, and/or defaut filters or sort order when your list record. +DefaultValuesDesc=You can define/force here the default value you want to get when you create a new record, and/or default filters or sort order when your list record. DefaultCreateForm=Default values (on forms to create) DefaultSearchFilters=Default search filters DefaultSortOrder=Default sort orders @@ -1441,7 +1441,7 @@ NumberOfProductShowInSelect=Max number of products in combos select lists (0=no ViewProductDescInFormAbility=Visualization of product descriptions in the forms (otherwise as popup tooltip) MergePropalProductCard=Activate in product/service Attached Files tab an option to merge product PDF document to proposal PDF azur if product/service is in the proposal ViewProductDescInThirdpartyLanguageAbility=Visualization of products descriptions in the third party language -UseSearchToSelectProductTooltip=Also if you have a large number of product (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. +UseSearchToSelectProductTooltip=Also if you have a large number of products (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseSearchToSelectProduct=Wait you press a key before loading content of product combo list (This may increase performance if you have a large number of products, but it is less convenient) SetDefaultBarcodeTypeProducts=Default barcode type to use for products SetDefaultBarcodeTypeThirdParties=Default barcode type to use for third parties @@ -1503,7 +1503,7 @@ SendingsSetup=Sending module setup SendingsReceiptModel=Sending receipt model SendingsNumberingModules=Sendings numbering modules SendingsAbility=Support shipping sheets for customer deliveries -NoNeedForDeliveryReceipts=In most cases, shipping sheets are used both as sheets for customer deliveries (list of products to send) and sheets that is received and signed by customer. So product deliveries receipts is a duplicated feature and is rarely activated. +NoNeedForDeliveryReceipts=In most cases, shipping sheets are used both as sheets for customer deliveries (list of products to send) and sheets that are received and signed by customer. Hence the product deliveries receipt is a duplicated feature and is rarely activated. FreeLegalTextOnShippings=Free text on shipments ##### Deliveries ##### DeliveryOrderNumberingModules=Products deliveries receipt numbering module @@ -1515,18 +1515,18 @@ AdvancedEditor=Advanced editor ActivateFCKeditor=Activate advanced editor for: FCKeditorForCompany=WYSIWIG creation/edition of elements description and note (except products/services) FCKeditorForProduct=WYSIWIG creation/edition of products/services description and note -FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formating when building PDF files. +FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formatting when building PDF files. FCKeditorForMailing= WYSIWIG creation/edition for mass eMailings (Tools->eMailing) FCKeditorForUserSignature=WYSIWIG creation/edition of user signature FCKeditorForMail=WYSIWIG creation/edition for all mail (except Tools->eMailing) ##### OSCommerce 1 ##### -OSCommerceErrorConnectOkButWrongDatabase=Connection succeeded but database doesn't look to be an OSCommerce database (Key %s not found in table %s). -OSCommerceTestOk=Connection to server '%s' on database '%s' with user '%s' successfull. +OSCommerceErrorConnectOkButWrongDatabase=Connection succeeded but database does not appear to be an OSCommerce database (Key %s not found in table %s). +OSCommerceTestOk=Connection to server '%s' on database '%s' with user '%s' successful. OSCommerceTestKo1=Connection to server '%s' succeed but database '%s' could not be reached. OSCommerceTestKo2=Connection to server '%s' with user '%s' failed. ##### Stock ##### StockSetup=Stock module setup -IfYouUsePointOfSaleCheckModule=If you use a Point of Sale module (POS module provided by default or another external module), this setup may be ignored by your Point Of Sale module. Most point of sales modules are designed to create immediatly an invoice and decrease stock by default whatever are options here. So, if you need or not to have a stock decrease when registering a sell from your Point Of Sale, check also your POS module set up. +IfYouUsePointOfSaleCheckModule=If you use a Point of Sale module (POS module provided by default or another external module), this setup may be ignored by your Point Of Sale module. Most point of sales modules are designed to create an invoice immediately and decrease stock by default whatever are options here. So, if you need or not to have a stock decrease when registering a sale from your Point Of Sale, check also your POS module setup. ##### Menu ##### MenuDeleted=Menu deleted Menus=Menus @@ -1548,7 +1548,7 @@ DetailRight=Condition to display unauthorized grey menus DetailLangs=Lang file name for label code translation DetailUser=Intern / Extern / All Target=Target -DetailTarget=Target for links (_blank top open a new window) +DetailTarget=Target for links (_blank top opens a new window) DetailLevel=Level (-1:top menu, 0:header menu, >0 menu and sub menu) ModifMenu=Menu change DeleteMenu=Delete menu entry @@ -1563,7 +1563,7 @@ OptionVatDefaultDesc=VAT is due:
- on delivery for goods (we use invoice date OptionVatDebitOptionDesc=VAT is due:
- on delivery for goods (we use invoice date)
- on invoice (debit) for services OptionPaymentForProductAndServices=Cash basis for products and services OptionPaymentForProductAndServicesDesc=VAT is due:
- on payment for goods
- on payments for services -SummaryOfVatExigibilityUsedByDefault=Time of VAT exigibility by default according to chosen option: +SummaryOfVatExigibilityUsedByDefault=Time of VAT eligibility by default according to chosen option: OnDelivery=On delivery OnPayment=On payment OnInvoice=On invoice @@ -1586,7 +1586,7 @@ AGENDA_DEFAULT_FILTER_TYPE=Set automatically this type of event into search filt AGENDA_DEFAULT_FILTER_STATUS=Set automatically this status for events into search filter of agenda view AGENDA_DEFAULT_VIEW=Which tab do you want to open by default when selecting menu Agenda AGENDA_REMINDER_EMAIL=Enable event reminder by emails (remind option/delay can be defined on each event). Note: Module %s must be enabled and correctly setup to have reminder sent at the correct frequency. -AGENDA_REMINDER_BROWSER=Enable event reminder on users browser (when event date is reached, each user is able to refuse this from the browser confirmation question) +AGENDA_REMINDER_BROWSER=Enable event reminder on user's browser (when event date is reached, each user is able to refuse this from the browser confirmation question) AGENDA_REMINDER_BROWSER_SOUND=Enable sound notification AGENDA_SHOW_LINKED_OBJECT=Show linked object into agenda view ##### Clicktodial ##### @@ -1594,7 +1594,7 @@ ClickToDialSetup=Click To Dial module setup ClickToDialUrlDesc=Url called when a click on phone picto is done. In URL, you can use tags
__PHONETO__ that will be replaced with the phone number of person to call
__PHONEFROM__ that will be replaced with phone number of calling person (yours)
__LOGIN__ that will be replaced with clicktodial login (defined on user card)
__PASS__ that will be replaced with clicktodial password (defined on user card). ClickToDialDesc=This module allows to make phone numbers clickable. A click on this icon will call make your phone to call the phone number. This can be used to call a call center system from Dolibarr that can call the phone number on a SIP system for example. ClickToDialUseTelLink=Use just a link "tel:" on phone numbers -ClickToDialUseTelLinkDesc=Use this method if your users have a softphone or a software interface installed on same computer than the browser, and called when you click on a link in your browser that start with "tel:". If you need a full server solution (no need of local software installation), you must set this to "No" and fill next field. +ClickToDialUseTelLinkDesc=Use this method if your users have a softphone or a software interface installed on the same computer as the browser, and called when you click on a link in your browser that start with "tel:". If you need a full server solution (no need of local software installation), you must set this to "No" and fill next field. ##### Point Of Sales (CashDesk) ##### CashDesk=Point of sales CashDeskSetup=Point of sales module setup @@ -1606,10 +1606,10 @@ CashDeskDoNotDecreaseStock=Disable stock decrease when a sell is done from Point CashDeskIdWareHouse=Force and restrict warehouse to use for stock decrease StockDecreaseForPointOfSaleDisabled=Stock decrease from Point Of Sale disabled StockDecreaseForPointOfSaleDisabledbyBatch=Stock decrease in POS is not compatible with lot management -CashDeskYouDidNotDisableStockDecease=You did not disable stock decrease when making a sell from Point Of Sale. So a warehouse is required. +CashDeskYouDidNotDisableStockDecease=You did not disable stock decrease when making a sale from Point Of Sale. Hence a warehouse is required. ##### Bookmark ##### BookmarkSetup=Bookmark module setup -BookmarkDesc=This module allows you to manage bookmarks. You can also add shortcuts to any Dolibarr pages or externale web sites on your left menu. +BookmarkDesc=This module allows you to manage bookmarks. You can also add shortcuts to any Dolibarr pages or external web sites on your left menu. NbOfBoomarkToShow=Maximum number of bookmarks to show in left menu ##### WebServices ##### WebServicesSetup=Webservices module setup @@ -1637,7 +1637,7 @@ ChequeReceiptsNumberingModule=Cheque Receipts Numbering module MultiCompanySetup=Multi-company module setup ##### Suppliers ##### SuppliersSetup=Supplier module setup -SuppliersCommandModel=Complete template of prchase order (logo...) +SuppliersCommandModel=Complete template of purchase order (logo...) SuppliersInvoiceModel=Complete template of vendor invoice (logo...) SuppliersInvoiceNumberingModel=Supplier invoices numbering models IfSetToYesDontForgetPermission=If set to yes, don't forget to provide permissions to groups or users allowed for the second approval @@ -1654,7 +1654,7 @@ ProjectsSetup=Project module setup ProjectsModelModule=Project reports document model TasksNumberingModules=Tasks numbering module TaskModelModule=Tasks reports document model -UseSearchToSelectProject=Wait you press a key before loading content of project combo list (This may increase performance if you have a large number of project, but it is less convenient) +UseSearchToSelectProject=Wait until you press a key before loading content of project combo list (this may improve performance if you have a large number of projects, but it is less convenient) ##### ECM (GED) ##### ##### Fiscal Year ##### AccountingPeriods=Accounting periods @@ -1712,13 +1712,13 @@ BackgroundTableLineEvenColor=Background color for even table lines MinimumNoticePeriod=Minimum notice period (Your leave request must be done before this delay) NbAddedAutomatically=Number of days added to counters of users (automatically) each month EnterAnyCode=This field contains a reference to identify line. Enter any value of your choice, but without special characters. -UnicodeCurrency=Enter here between braces, list of byte number that represent the currency symbol. For exemple: for $, enter [36] - for brazil real R$ [82,36] - for €, enter [8364] +UnicodeCurrency=Enter here between braces, list of byte number that represent the currency symbol. For example: for $, enter [36] - for brazil real R$ [82,36] - for €, enter [8364] ColorFormat=The RGB color is in HEX format, eg: FF0000 PositionIntoComboList=Position of line into combo lists SellTaxRate=Sale tax rate RecuperableOnly=Yes for VAT "Not Perceived but Recoverable" dedicated for some state in France. Keep value to "No" in all other cases. UrlTrackingDesc=If the provider or transport service offer a page or web site to check status of your shipping, you can enter it here. You can use the key {TRACKID} into URL parameters so the system will replace it with value of tracking number user entered into shipment card. -OpportunityPercent=When you create an opportunity, you will defined an estimated amount of project/lead. According to status of opportunity, this amount may be multiplicated by this rate to evaluate global amount all your opportunities may generate. Value is percent (between 0 and 100). +OpportunityPercent=When you create an opportunity, you will define an estimated amount of project/lead. According to status of opportunity, this amount may be multiplied by this rate to evaluate global amount all your opportunities may generate. Value is percent (between 0 and 100). TemplateForElement=This template record is dedicated to which element TypeOfTemplate=Type of template TemplateIsVisibleByOwnerOnly=Template is visible by owner only @@ -1748,7 +1748,7 @@ TitleExampleForMajorRelease=Example of message you can use to announce this majo TitleExampleForMaintenanceRelease=Example of message you can use to announce this maintenance release (feel free to use it on your web sites) ExampleOfNewsMessageForMajorRelease=Dolibarr ERP & CRM %s is available. Version %s is a major release with a lot of new features for both users and developers. You can download it from the download area of https://www.dolibarr.org portal (subdirectory Stable versions). You can read ChangeLog for complete list of changes. ExampleOfNewsMessageForMaintenanceRelease=Dolibarr ERP & CRM %s is available. Version %s is a maintenance version, so it contains only fixes of bugs. We recommend everybody using an older version to upgrade to this one. As any maintenance release, no new features, nor data structure change is present into this version. You can download it from the download area of https://www.dolibarr.org portal (subdirectory Stable versions). You can read ChangeLog for complete list of changes. -MultiPriceRuleDesc=When option "Several level of prices per product/service" is on, you can define different prices (one per price level) for each product. To save you time, you can enter here rule to have price for each level autocalculated according to price of first level, so you will have to enter only price for first level on each product. This page is here to save you time and can be usefull only if your prices for each leve are relative to first level. You can ignore this page in most cases. +MultiPriceRuleDesc=When option "Several level of prices per product/service" is on, you can define different prices (one per price level) for each product. To save you time, you can enter here rule to have price for each level autocalculated according to price of first level, so you will have to enter only price for first level on each product. This page is here to save you time and can be useful only if your prices for each level are relative to first level. You can ignore this page in most cases. ModelModulesProduct=Templates for product documents ToGenerateCodeDefineAutomaticRuleFirst=To be able to generate automatically codes, you must first define a manager to auto define barcode number. SeeSubstitutionVars=See * note for list of possible substitution variables @@ -1773,8 +1773,8 @@ AddSubstitutions=Add keys substitutions DetectionNotPossible=Detection not possible UrlToGetKeyToUseAPIs=Url to get token to use API (once token has been received it is saved on database user table and must be provided on each API call) ListOfAvailableAPIs=List of available APIs -activateModuleDependNotSatisfied=Module "%s" depends on module "%s" that is missing, so module "%1$s" may not work correclty. Please install module "%2$s" or disable module "%1$s" if you want to be safe from any surprise -CommandIsNotInsideAllowedCommands=The command you try to run is not inside list of allowed commands defined into parameter $dolibarr_main_restrict_os_commands into conf.php file. +activateModuleDependNotSatisfied=Module "%s" depends on module "%s", that is missing, so module "%1$s" may not work correctly. Please install module "%2$s" or disable module "%1$s" if you want to be safe from any surprise +CommandIsNotInsideAllowedCommands=The command you try to run is not in the list of allowed commands defined into parameter $dolibarr_main_restrict_os_commands in the conf.php file. LandingPage=Landing page SamePriceAlsoForSharedCompanies=If you use a multicompany module, with the choice "Single price", price will be also the same for all companies if products are shared between environments ModuleEnabledAdminMustCheckRights=Module has been activated. Permissions for activated module(s) were given to admin users only. You may need to grant permissions to other users or groups manually if necessary. @@ -1783,13 +1783,13 @@ TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta i BaseCurrency=Reference currency of the company (go into setup of company to change this) WarningNoteModuleInvoiceForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016). WarningNoteModulePOSForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016) because module Non Reversible Logs is automatically activated. -WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the publisher of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. +WarningInstallationMayBecomeNotCompliantWithLaw=You are trying to install module %s that is an external module. Activating an external module means you trust the publisher of that module and that you are sure that this module does not impact adversely the behavior of your application, and is compliant with laws of your country (%s). If the module introduces an illegal feature, you become responsible for the use of a illegal software. MAIN_PDF_MARGIN_LEFT=Left margin on PDF MAIN_PDF_MARGIN_RIGHT=Right margin on PDF MAIN_PDF_MARGIN_TOP=Top margin on PDF MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF SetToYesIfGroupIsComputationOfOtherGroups=Set this to yes if this group is a computation of other groups -EnterCalculationRuleIfPreviousFieldIsYes=Enter calculcation rule if previous field was set to Yes (For example 'CODEGRP1+CODEGRP2') +EnterCalculationRuleIfPreviousFieldIsYes=Enter calculation rule if previous field was set to Yes (For example 'CODEGRP1+CODEGRP2') SeveralLangugeVariatFound=Several language variants found COMPANY_AQUARIUM_REMOVE_SPECIAL=Remove special characters COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX) diff --git a/htdocs/langs/en_US/help.lang b/htdocs/langs/en_US/help.lang index 2ddbc51ce3a..d5a19d6d119 100644 --- a/htdocs/langs/en_US/help.lang +++ b/htdocs/langs/en_US/help.lang @@ -5,9 +5,9 @@ RemoteControlSupport=Online real time / remote support OtherSupport=Other support ToSeeListOfAvailableRessources=To contact/see available resources: HelpCenter=Help center -DolibarrHelpCenter=Dolibarr help and support center -ToGoBackToDolibarr=Otherwise, click here to use Dolibarr -TypeOfSupport=Source of support +DolibarrHelpCenter=Dolibarr Help and Support Center +ToGoBackToDolibarr=Otherwise, click here to continue to use Dolibarr. +TypeOfSupport=Type of support TypeSupportCommunauty=Community (free) TypeSupportCommercial=Commercial TypeOfHelp=Type @@ -15,12 +15,12 @@ NeedHelpCenter=Need help or support? Efficiency=Efficiency TypeHelpOnly=Help only TypeHelpDev=Help+Development -TypeHelpDevForm=Help+Development+Formation -ToGetHelpGoOnSparkAngels1=Some companies can provide a fast (sometime immediate) and more efficient online support by taking control of your computer. Such helpers can be found on %s web site: -ToGetHelpGoOnSparkAngels3=You can also go to the list of all available coaches for Dolibarr, for this click on button -ToGetHelpGoOnSparkAngels2=Sometimes, there is no company available at the moment you make your search, so think to change the filter to look for "all availability". You will be able to send more requests. -BackToHelpCenter=Otherwise, click here to go back to help center home page. -LinkToGoldMember=You can call one of the coach preselected by Dolibarr for your language (%s) by clicking his Widget (status and maximum price are automatically updated): +TypeHelpDevForm=Help+Development+Training +ToGetHelpGoOnSparkAngels1=Some companies can provide a fast (sometime immediate) and more efficient online support by remote control of your computer. Such help can be found on %s web site: +ToGetHelpGoOnSparkAngels3=You can also go to the list of all available trainers for Dolibarr, for this click on button +ToGetHelpGoOnSparkAngels2=Sometimes, there is no company available when you make your search, so change the filter to look for "all availability". You will be able to send more requests. +BackToHelpCenter=Otherwise, go back to Help center home page. +LinkToGoldMember=You can call one of the trainers preselected by Dolibarr for your language (%s) by clicking their Widget (status and maximum price are automatically updated): PossibleLanguages=Supported languages -SubscribeToFoundation=Help Dolibarr project, subscribe to the foundation +SubscribeToFoundation=Help the Dolibarr project, subscribe to the foundation SeeOfficalSupport=For official Dolibarr support in your language:
%s diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 00d4be864ff..629ac022331 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -2,37 +2,37 @@ InstallEasy=Just follow the instructions step by step. MiscellaneousChecks=Prerequisites check ConfFileExists=Configuration file %s exists. -ConfFileDoesNotExistsAndCouldNotBeCreated=Configuration file %s does not exist and could not be created ! +ConfFileDoesNotExistsAndCouldNotBeCreated=Configuration file %s does not exist and could not be created! ConfFileCouldBeCreated=Configuration file %s could be created. -ConfFileIsNotWritable=Configuration file %s is not writable. Check permissions. For first install, your web server must be granted to be able to write into this file during configuration process ("chmod 666" for example on a Unix like OS). +ConfFileIsNotWritable=Configuration file %s is not writable. Check permissions. For first install, your web server must be able to write into this file during configuration process ("chmod 666" for example on a Unix like OS). ConfFileIsWritable=Configuration file %s is writable. ConfFileMustBeAFileNotADir=Configuration file %s must be a file, not a directory. -ConfFileReload=Reload all information from configuration file. +ConfFileReload=Reloading parameters from configuration file. PHPSupportSessions=This PHP supports sessions. PHPSupportPOSTGETOk=This PHP supports variables POST and GET. -PHPSupportPOSTGETKo=It's possible your PHP setup does not support variables POST and/or GET. Check your parameter variables_order in php.ini. -PHPSupportGD=This PHP support GD graphical functions. -PHPSupportCurl=This PHP support Curl. -PHPSupportUTF8=This PHP support UTF8 functions. +PHPSupportPOSTGETKo=It's possible your PHP setup does not support variables POST and/or GET. Check the parameter variables_order in php.ini. +PHPSupportGD=This PHP supports GD graphical functions. +PHPSupportCurl=This PHP supports Curl. +PHPSupportUTF8=This PHP supports UTF8 functions. PHPMemoryOK=Your PHP max session memory is set to %s. This should be enough. -PHPMemoryTooLow=Your PHP max session memory is set to %s bytes. This should be too low. Change your php.ini to set memory_limit parameter to at least %s bytes. -Recheck=Click here for a more significative test -ErrorPHPDoesNotSupportSessions=Your PHP installation does not support sessions. This feature is required to make Dolibarr working. Check your PHP setup. -ErrorPHPDoesNotSupportGD=Your PHP installation does not support graphical function GD. No graph will be available. +PHPMemoryTooLow=Your PHP max session memory is set to %s bytes. This is too low. Change your php.ini to set memory_limit parameter to at least %s bytes. +Recheck=Click here for a more detailed test +ErrorPHPDoesNotSupportSessions=Your PHP installation does not support sessions. This feature is required to allow Dolibarr to work. Check your PHP setup and permissions of the sessions directory. +ErrorPHPDoesNotSupportGD=Your PHP installation does not support GD graphical functions. No graphs will be available. ErrorPHPDoesNotSupportCurl=Your PHP installation does not support Curl. -ErrorPHPDoesNotSupportUTF8=Your PHP installation does not support UTF8 functions. Dolibarr can't work correctly. Solve this before installing Dolibarr. +ErrorPHPDoesNotSupportUTF8=Your PHP installation does not support UTF8 functions. Dolibarr cannot work correctly. Resolve this before installing Dolibarr. ErrorDirDoesNotExists=Directory %s does not exist. -ErrorGoBackAndCorrectParameters=Go backward and correct wrong parameters. +ErrorGoBackAndCorrectParameters=Go back and check/correct the parameters. ErrorWrongValueForParameter=You may have typed a wrong value for parameter '%s'. ErrorFailedToCreateDatabase=Failed to create database '%s'. ErrorFailedToConnectToDatabase=Failed to connect to database '%s'. ErrorDatabaseVersionTooLow=Database version (%s) too old. Version %s or higher is required. ErrorPHPVersionTooLow=PHP version too old. Version %s is required. -ErrorConnectedButDatabaseNotFound=Connection to server successfull but database '%s' not found. +ErrorConnectedButDatabaseNotFound=Connection to server successful but database '%s' not found. ErrorDatabaseAlreadyExists=Database '%s' already exists. -IfDatabaseNotExistsGoBackAndUncheckCreate=If database does not exists, go back and check option "Create database". +IfDatabaseNotExistsGoBackAndUncheckCreate=If the database does not exist, go back and check option "Create database". IfDatabaseExistsGoBackAndCheckCreate=If database already exists, go back and uncheck "Create database" option. -WarningBrowserTooOld=Too old version of browser. Upgrading your browser to a recent version of Firefox, Chrome or Opera is highly recommanded. +WarningBrowserTooOld=Version of browser is too old. Upgrading your browser to a recent version of Firefox, Chrome or Opera is highly recommended. PHPVersion=PHP Version License=Using license ConfigurationFile=Configuration file @@ -45,22 +45,22 @@ DolibarrDatabase=Dolibarr Database DatabaseType=Database type DriverType=Driver type Server=Server -ServerAddressDescription=Name or ip address for database server, usually 'localhost' when database server is hosted on same server than web server +ServerAddressDescription=Name or ip address for the database server. Usually 'localhost' when the database server is hosted on the same server as the web server. ServerPortDescription=Database server port. Keep empty if unknown. DatabaseServer=Database server DatabaseName=Database name -DatabasePrefix=Database prefix table -AdminLogin=Login for Dolibarr database owner. -PasswordAgain=Retype password a second time +DatabasePrefix=Database table prefix +AdminLogin=User account for the Dolibarr database owner. +PasswordAgain=Retype password confirmation AdminPassword=Password for Dolibarr database owner. CreateDatabase=Create database -CreateUser=Create owner or grant him permission on database +CreateUser=Create user account or grant user account permission on the Dolibarr database DatabaseSuperUserAccess=Database server - Superuser access -CheckToCreateDatabase=Check box if database does not exist and must be created.
In this case, you must fill the login/password for superuser account at the bottom of this page. -CheckToCreateUser=Check box if database owner does not exist and must be created, or if it exists but database does not exists and permissions must be granted.
In this case, you must choose its login and password and also fill the login/password for the superuser account at the bottom of this page. If this box is unchecked, owner database and its passwords must exists. -DatabaseRootLoginDescription=Login of the user allowed to create new databases or new users, mandatory if your database or its owner does not already exists. -KeepEmptyIfNoPassword=Leave empty if user has no password (avoid this) -SaveConfigurationFile=Save values +CheckToCreateDatabase=Check the box if the database does not exist yet and so must be created.
In this case, you must fill in the user name and password for the superuser account at the bottom of this page. +CheckToCreateUser=Check the box if:
the database user account does not yet exist and so must be created, or
if the user account exists but the database does not exist and permissions must be granted.
In this case, you must enter the user account and password and also the superuser account name and password at the bottom of this page. If this box is unchecked, database owner and password must already exist. +DatabaseRootLoginDescription=Superuser account name (to create new databases or new users), mandatory if the database or its owner does not already exist. +KeepEmptyIfNoPassword=Leave empty if superuser has no password (NOT recommended) +SaveConfigurationFile=Saving parameters to ServerConnection=Server connection DatabaseCreation=Database creation CreateDatabaseObjects=Database objects creation @@ -71,9 +71,9 @@ CreateOtherKeysForTable=Create foreign keys and indexes for table %s OtherKeysCreation=Foreign keys and indexes creation FunctionsCreation=Functions creation AdminAccountCreation=Administrator login creation -PleaseTypePassword=Please type a password, empty passwords are not allowed ! -PleaseTypeALogin=Please type a login ! -PasswordsMismatch=Passwords differs, please try again ! +PleaseTypePassword=Please type a password, empty passwords are not allowed! +PleaseTypeALogin=Please type a login! +PasswordsMismatch=Passwords differs, please try again! SetupEnd=End of setup SystemIsInstalled=This installation is complete. SystemIsUpgraded=Dolibarr has been upgraded successfully. @@ -81,65 +81,65 @@ YouNeedToPersonalizeSetup=You need to configure Dolibarr to suit your needs (app AdminLoginCreatedSuccessfuly=Dolibarr administrator login '%s' created successfully. GoToDolibarr=Go to Dolibarr GoToSetupArea=Go to Dolibarr (setup area) -MigrationNotFinished=Version of your database is not completely up to date, so you'll have to run the upgrade process again. +MigrationNotFinished=The database version is not completely up to date: run the upgrade process again. GoToUpgradePage=Go to upgrade page again WithNoSlashAtTheEnd=Without the slash "/" at the end -DirectoryRecommendation=It is recommanded to use a directory outside of your directory of your web pages. +DirectoryRecommendation=It is recommended to use a directory outside of the web pages. LoginAlreadyExists=Already exists DolibarrAdminLogin=Dolibarr admin login -AdminLoginAlreadyExists=Dolibarr administrator account '%s' already exists. Go back, if you want to create another one. +AdminLoginAlreadyExists=Dolibarr administrator account '%s' already exists. Go back if you want to create another one. FailedToCreateAdminLogin=Failed to create Dolibarr administrator account. -WarningRemoveInstallDir=Warning, for security reasons, once the install or upgrade is complete, to avoid using install tools again, you should add a file called install.lock into Dolibarr document directory, in order to avoid malicious use of it. -FunctionNotAvailableInThisPHP=Not available on this PHP +WarningRemoveInstallDir=Warning, for security reasons, once the install or upgrade is complete, you should add a file called install.lock into the Dolibarr document directory in order to prevent the accidental/malicious use of the install tools again. +FunctionNotAvailableInThisPHP=Not available in this PHP ChoosedMigrateScript=Choose migration script DataMigration=Database migration (data) DatabaseMigration=Database migration (structure + some data) ProcessMigrateScript=Script processing ChooseYourSetupMode=Choose your setup mode and click "Start"... FreshInstall=Fresh install -FreshInstallDesc=Use this mode if this is your first install. If not, this mode can repair a incomplete previous install, but if you want to upgrade your version, choose "Upgrade" mode. +FreshInstallDesc=Use this mode if this is your first install. If not, this mode can repair a incomplete previous install. If you want to upgrade your version, choose "Upgrade" mode. Upgrade=Upgrade UpgradeDesc=Use this mode if you have replaced old Dolibarr files with files from a newer version. This will upgrade your database and data. Start=Start InstallNotAllowed=Setup not allowed by conf.php permissions YouMustCreateWithPermission=You must create file %s and set write permissions on it for the web server during install process. -CorrectProblemAndReloadPage=Please fix the problem and press F5 to reload page. +CorrectProblemAndReloadPage=Please fix the problem and press F5 to reload the page. AlreadyDone=Already migrated DatabaseVersion=Database version ServerVersion=Database server version YouMustCreateItAndAllowServerToWrite=You must create this directory and allow for the web server to write into it. DBSortingCollation=Character sorting order -YouAskDatabaseCreationSoDolibarrNeedToConnect=You ask to create database %s, but for this, Dolibarr need to connect to server %s with super user %s permissions. -YouAskLoginCreationSoDolibarrNeedToConnect=You ask to create database login %s, but for this, Dolibarr need to connect to server %s with super user %s permissions. -BecauseConnectionFailedParametersMayBeWrong=As connection failed, host or super user parameters must be wrong. +YouAskDatabaseCreationSoDolibarrNeedToConnect=You selected create database %s, but for this, Dolibarr needs to connect to server %s with super user %s permissions. +YouAskLoginCreationSoDolibarrNeedToConnect=You selected create database user %s, but for this, Dolibarr needs to connect to server %s with super user %s permissions. +BecauseConnectionFailedParametersMayBeWrong=The database connection failed: the host or super user parameters must be wrong. OrphelinsPaymentsDetectedByMethod=Orphans payment detected by method %s RemoveItManuallyAndPressF5ToContinue=Remove it manually and press F5 to continue. FieldRenamed=Field renamed -IfLoginDoesNotExistsCheckCreateUser=If login does not exists yet, you must check option "Create user" -ErrorConnection=Server "%s", database name "%s", login "%s", or database password may be wrong or PHP client version may be too old compared to database version. +IfLoginDoesNotExistsCheckCreateUser=If the user does not exist yet, you must check option "Create user" +ErrorConnection=Server "%s", database name "%s", login "%s", or database password may be wrong or the PHP client version may be too old compared to the database version. InstallChoiceRecommanded=Recommended choice to install version %s from your current version %s InstallChoiceSuggested=Install choice suggested by installer. -MigrateIsDoneStepByStep=The targeted version (%s) has a gap of several versions, so install wizard will come back to suggest next migration once this one will be finished. -CheckThatDatabasenameIsCorrect=Check that database name "%s" is correct. +MigrateIsDoneStepByStep=The targeted version (%s) has a gap of several versions. The install wizard will come back to suggest a further migration once this one is complete. +CheckThatDatabasenameIsCorrect=Check that the database name "%s" is correct. IfAlreadyExistsCheckOption=If this name is correct and that database does not exist yet, you must check option "Create database". OpenBaseDir=PHP openbasedir parameter -YouAskToCreateDatabaseSoRootRequired=You checked the box "Create database". For this, you need to provide login/password of superuser (bottom of form). -YouAskToCreateDatabaseUserSoRootRequired=You checked the box "Create database owner". For this, you need to provide login/password of superuser (bottom of form). -NextStepMightLastALongTime=Current step may last several minutes. Please wait until the next screen is shown completely before continuing. +YouAskToCreateDatabaseSoRootRequired=You checked the box "Create database". For this, you need to provide the login/password of superuser (bottom of form). +YouAskToCreateDatabaseUserSoRootRequired=You checked the box "Create database owner". For this, you need to provide the login/password of superuser (bottom of form). +NextStepMightLastALongTime=The current step may take several minutes. Please wait until the next screen is shown completely before continuing. MigrationCustomerOrderShipping=Migrate shipping for customer orders storage MigrationShippingDelivery=Upgrade storage of shipping MigrationShippingDelivery2=Upgrade storage of shipping 2 MigrationFinished=Migration finished -LastStepDesc=Last step: Define here login and password you plan to use to connect to software. Do not loose this as it is the account to administer all others. +LastStepDesc=Last step: Define here the login and password you wish to use to connect to Dolibarr. Do not lose this as it is the master account to administer all other/additional user accounts. ActivateModule=Activate module %s ShowEditTechnicalParameters=Click here to show/edit advanced parameters (expert mode) -WarningUpgrade=Warning:\nDid your run a database backup first?\nThis is highly recommanded: for example, due to some bugs into databases systems (for example mysql version 5.5.40/41/42/43), some data or tables may be lost during this process, so it is highly recommanded to have a complete dump of your database before starting migration.\n\nClick OK to start migration process... -ErrorDatabaseVersionForbiddenForMigration=Your database version is %s. It has a critical bug making data loss if you make structure change on your database, like it is required by the migration process. For his reason, migration will not be allowed until you upgrade your database to a higher fixed version (list of known bugged version: %s) -KeepDefaultValuesWamp=You use the Dolibarr setup wizard from DoliWamp, so values proposed here are already optimized. Change them only if you know what you do. -KeepDefaultValuesDeb=You use the Dolibarr setup wizard from a Linux package (Ubuntu, Debian, Fedora...), so values proposed here are already optimized. Only the password of the database owner to create must be completed. Change other parameters only if you know what you do. -KeepDefaultValuesMamp=You use the Dolibarr setup wizard from DoliMamp, so values proposed here are already optimized. Change them only if you know what you do. -KeepDefaultValuesProxmox=You use the Dolibarr setup wizard from a Proxmox virtual appliance, so values proposed here are already optimized. Change them only if you know what you do. -UpgradeExternalModule=Run dedicated upgrade process of external modules +WarningUpgrade=Warning:\nDid you run a database backup first?\nThis is highly recommended. Loss of data (due to for example bugs in mysql version 5.5.40/41/42/43) may be possible during this process, so it is essential to take a complete dump of your database before starting any migration.\n\nClick OK to start migration process... +ErrorDatabaseVersionForbiddenForMigration=Your database version is %s. It has a critical bug, making data loss possible if you make structural changes in your database, such as is required by the migration process. For his reason, migration will not be allowed until you upgrade your database to a layer (patched) version (list of known buggy versions: %s) +KeepDefaultValuesWamp=You used the Dolibarr setup wizard from DoliWamp, so values proposed here are already optimized. Change them only if you know what you are doing. +KeepDefaultValuesDeb=You used the Dolibarr setup wizard from a Linux package (Ubuntu, Debian, Fedora...), so the values proposed here are already optimized. Only the password of the database owner to create must be entered. Change other parameters only if you know what you are doing. +KeepDefaultValuesMamp=You used the Dolibarr setup wizard from DoliMamp, so the values proposed here are already optimized. Change them only if you know what you are doing. +KeepDefaultValuesProxmox=You used the Dolibarr setup wizard from a Proxmox virtual appliance, so the values proposed here are already optimized. Change them only if you know what you are doing. +UpgradeExternalModule=Run dedicated upgrade process of external module SetAtLeastOneOptionAsUrlParameter=Set at least one option as a parameter in URL. For example: '...repair.php?standard=confirmed' NothingToDelete=Nothing to clean/delete NothingToDo=Nothing to do @@ -151,7 +151,7 @@ MigrationSupplierOrder=Data migration for vendor's orders MigrationProposal=Data migration for commercial proposals MigrationInvoice=Data migration for customer's invoices MigrationContract=Data migration for contracts -MigrationSuccessfullUpdate=Upgrade successfull +MigrationSuccessfullUpdate=Upgrade successful MigrationUpdateFailed=Failed upgrade process MigrationRelationshipTables=Data migration for relationship tables (%s) MigrationPaymentsUpdate=Payment data correction @@ -163,9 +163,9 @@ MigrationContractsUpdate=Contract data correction MigrationContractsNumberToUpdate=%s contract(s) to update MigrationContractsLineCreation=Create contract line for contract ref %s MigrationContractsNothingToUpdate=No more things to do -MigrationContractsFieldDontExist=Field fk_facture does not exists anymore. Nothing to do. +MigrationContractsFieldDontExist=Field fk_facture does not exist anymore. Nothing to do. MigrationContractsEmptyDatesUpdate=Contract empty date correction -MigrationContractsEmptyDatesUpdateSuccess=Contract emtpy date correction done successfully +MigrationContractsEmptyDatesUpdateSuccess=Contract empty date correction done successfully MigrationContractsEmptyDatesNothingToUpdate=No contract empty date to correct MigrationContractsEmptyCreationDatesNothingToUpdate=No contract creation date to correct MigrationContractsInvalidDatesUpdate=Bad value date contract correction @@ -187,24 +187,24 @@ MigrationDeliveryDetail=Delivery update MigrationStockDetail=Update stock value of products MigrationMenusDetail=Update dynamic menus tables MigrationDeliveryAddress=Update delivery address in shipments -MigrationProjectTaskActors=Data migration for llx_projet_task_actors table +MigrationProjectTaskActors=Data migration for table llx_projet_task_actors MigrationProjectUserResp=Data migration field fk_user_resp of llx_projet to llx_element_contact MigrationProjectTaskTime=Update time spent in seconds MigrationActioncommElement=Update data on actions MigrationPaymentMode=Data migration for payment mode MigrationCategorieAssociation=Migration of categories -MigrationEvents=Migration of events to add event owner into assignement table -MigrationEventsContact=Migration of events to add event contact into assignement table +MigrationEvents=Migration of events to add event owner into assignment table +MigrationEventsContact=Migration of events to add event contact into assignment table MigrationRemiseEntity=Update entity field value of llx_societe_remise MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_except MigrationUserRightsEntity=Update entity field value of llx_user_rights MigrationUserGroupRightsEntity=Update entity field value of llx_usergroup_rights MigrationReloadModule=Reload module %s MigrationResetBlockedLog=Reset module BlockedLog for v7 algorithm -ShowNotAvailableOptions=Show not available options -HideNotAvailableOptions=Hide not available options -ErrorFoundDuringMigration=Error were reported during migration process so next step is not available. To ignore errors, you can click here, but application or some features may not work correctly until fixed. -YouTryInstallDisabledByDirLock=The application try to sefl upgrade, but install/upgrade pages have been disabled for security reason (directory renamed with .lock suffix).
-YouTryInstallDisabledByFileLock=The application try to sefl upgrade, but install/upgrade pages pages have been disabled for security reason (by lock file install.lock into dolibarr documents directory).
+ShowNotAvailableOptions=Show unavailable options +HideNotAvailableOptions=Hide unavailable options +ErrorFoundDuringMigration=Error(s) were reported during the migration process so next step is not available. To ignore errors, you can click here, but the application or some features may not work correctly until the errors are resolved. +YouTryInstallDisabledByDirLock=The application tried to self-upgrade, but the install/upgrade pages have been disabled for security (directory renamed with .lock suffix).
+YouTryInstallDisabledByFileLock=The application tried to self-upgrade, but the install/upgrade pages have been disabled for security (by the existence of a lock file install.lock in the dolibarr documents directory).
ClickHereToGoToApp=Click here to go to your application -ClickOnLinkOrRemoveManualy=Click on following link and if you always reach this page, you must remove the file install.lock into documents directory manually \ No newline at end of file +ClickOnLinkOrRemoveManualy=Click on the following link. If you always see this same page, you must remove/rename the file install.lock in the documents directory. \ No newline at end of file diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c9320a9ebb1..da140b602f2 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -468,7 +468,7 @@ and=and or=or Other=Other Others=Others -OtherInformations=Other informations +OtherInformations=Other information Quantity=Quantity Qty=Qty ChangedBy=Changed by @@ -716,7 +716,7 @@ Merge=Merge DocumentModelStandardPDF=Standard PDF template PrintContentArea=Show page to print main content area MenuManager=Menu manager -WarningYouAreInMaintenanceMode=Warning, you are in a maintenance mode, so only login %s is allowed to use application at the moment. +WarningYouAreInMaintenanceMode=Warning, you are in a maintenance mode, so only login %s is allowed to use the application at the moment. CoreErrorTitle=System error CoreErrorMessage=Sorry, an error occurred. Contact your system administrator to check the logs or disable $dolibarr_main_prod=1 to get more information. CreditCard=Credit card @@ -724,7 +724,7 @@ ValidatePayment=Validate payment CreditOrDebitCard=Credit or debit card FieldsWithAreMandatory=Fields with %s are mandatory FieldsWithIsForPublic=Fields with %s are shown on public list of members. If you don't want this, check off the "public" box. -AccordingToGeoIPDatabase=(according to GeoIP convertion) +AccordingToGeoIPDatabase=(according to GeoIP conversion) Line=Line NotSupported=Not supported RequiredField=Required field @@ -818,12 +818,12 @@ Sincerely=Sincerely DeleteLine=Delete line ConfirmDeleteLine=Are you sure you want to delete this line? NoPDFAvailableForDocGenAmongChecked=No PDF were available for the document generation among checked record -TooManyRecordForMassAction=Too many record selected for mass action. The action is restricted to a list of %s record. +TooManyRecordForMassAction=Too many records selected for mass action. The action is restricted to a list of %s records. NoRecordSelected=No record selected MassFilesArea=Area for files built by mass actions ShowTempMassFilesArea=Show area of files built by mass actions ConfirmMassDeletion=Bulk delete confirmation -ConfirmMassDeletionQuestion=Are you sure you want to delete the %s selected record ? +ConfirmMassDeletionQuestion=Are you sure you want to delete the %s selected record? RelatedObjects=Related Objects ClassifyBilled=Classify billed ClassifyUnbilled=Classify unbilled @@ -841,7 +841,7 @@ Calendar=Calendar GroupBy=Group by... ViewFlatList=View flat list RemoveString=Remove string '%s' -SomeTranslationAreUncomplete=Some languages may be partially translated or may contains errors. If you detect some, you can fix language files registering to https://transifex.com/projects/p/dolibarr/. +SomeTranslationAreUncomplete=Some of the languages offered may be only partially translated or may contain errors. Please help to correct your language by registering at https://transifex.com/projects/p/dolibarr/ to add your improvements. DirectDownloadLink=Direct download link (public/external) DirectDownloadInternalLink=Direct download link (need to be logged and need permissions) Download=Download @@ -861,11 +861,11 @@ HR=HR HRAndBank=HR and Bank AutomaticallyCalculated=Automatically calculated TitleSetToDraft=Go back to draft -ConfirmSetToDraft=Are you sure you want to go back to Draft status ? +ConfirmSetToDraft=Are you sure you want to go back to Draft status? ImportId=Import id Events=Events EMailTemplates=Emails templates -FileNotShared=File not shared to exernal public +FileNotShared=File not shared to external public Project=Project Projects=Projects Rights=Permissions From 1e1ed485f5ee2be4749e434457f8e7c0054432ae Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 7 Jul 2018 10:47:56 +0200 Subject: [PATCH 124/228] Docs : update comments --- .../doc/pdf_standard.modules.php | 87 +++++++++++++++---- 1 file changed, 71 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index f9567a32a5c..bda0170397d 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -38,23 +38,78 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php'; */ class pdf_standard extends ModelePDFSuppliersPayments { - var $db; - var $name; - var $description; - var $type; + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; - var $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; - - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; - - var $emetteur; // Objet societe qui emet + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.4 = array(5, 4) + */ + public $phpmin = array(5, 4); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe + */ + public $emetteur; /** From fe5bfe3aaf0e94f7e44e94d7627a5088b1f68878 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 7 Jul 2018 10:51:09 +0200 Subject: [PATCH 125/228] Docs : update comments --- .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index bca4ae8425f..5f971cab2d1 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -60,9 +60,9 @@ class pdf_aurore extends ModelePDFSupplierProposal /** * @var array() Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.3 = array(5, 3) + * e.g.: PHP ≥ 5.4 = array(5, 4) */ - public $phpmin = array(5, 2); + public $phpmin = array(5, 4); /** * Dolibarr version of the loaded document From 4b1e9e3fafd477fa380cd008d8ac93b6281186e5 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 7 Jul 2018 11:03:22 +0200 Subject: [PATCH 126/228] Docs : translation --- htdocs/holiday/class/holiday.class.php | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 03b2491ab59..c8b64790061 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -346,12 +346,12 @@ class Holiday extends CommonObject $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau $sql.= " AND cp.fk_user IN (".$user_id.")"; - // Filtre de séléction + // Selection filter if(!empty($filter)) { $sql.= $filter; } - // Ordre d'affichage du résultat + // Order of display of the result if(!empty($order)) { $sql.= $order; } @@ -359,19 +359,19 @@ class Holiday extends CommonObject dol_syslog(get_class($this)."::fetchByUser", LOG_DEBUG); $resql=$this->db->query($sql); - // Si pas d'erreur SQL + // If no SQL error if ($resql) { $i = 0; $tab_result = $this->holiday; $num = $this->db->num_rows($resql); - // Si pas d'enregistrement + // If no registration if(!$num) { return 2; } - // Liste les enregistrements et les ajoutent au tableau + // List the records and add them to the table while($i < $num) { $obj = $this->db->fetch_object($resql); @@ -412,13 +412,13 @@ class Holiday extends CommonObject $i++; } - // Retourne 1 avec le tableau rempli + // Returns 1 with the filled array $this->holiday = $tab_result; return 1; } else { - // Erreur SQL + // SQL Error $this->error="Error ".$this->db->lasterror(); return -1; } @@ -471,12 +471,12 @@ class Holiday extends CommonObject $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau - // Filtrage de séléction + // Selection filtering if(!empty($filter)) { $sql.= $filter; } - // Ordre d'affichage + // order of display if(!empty($order)) { $sql.= $order; } @@ -484,19 +484,19 @@ class Holiday extends CommonObject dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); $resql=$this->db->query($sql); - // Si pas d'erreur SQL + // If no SQL error if ($resql) { $i = 0; $tab_result = $this->holiday; $num = $this->db->num_rows($resql); - // Si pas d'enregistrement + // If no registration if(!$num) { return 2; } - // On liste les résultats et on les ajoutent dans le tableau + // List the records and add them to the table while($i < $num) { $obj = $this->db->fetch_object($resql); @@ -536,13 +536,13 @@ class Holiday extends CommonObject $i++; } - // Retourne 1 et ajoute le tableau à la variable + // Returns 1 and adds the array to the variable $this->holiday = $tab_result; return 1; } else { - // Erreur SQL + // SQL Error $this->error="Error ".$this->db->lasterror(); return -1; } From 47e80123d5cbd4b7180ae40be393e72f77aad76c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 7 Jul 2018 11:36:46 +0200 Subject: [PATCH 127/228] Docs : update code --- htdocs/core/modules/modApi.class.php | 2 +- htdocs/core/modules/modAsset.class.php | 2 +- .../modulebuilder/template/core/modules/modMyModule.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index c8dc7ae84ba..71374e136e5 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -82,7 +82,7 @@ class modApi extends DolibarrModules $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->phpmin = array(5,3); // Minimum version of PHP required by module + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("other"); // Constants diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index 9b82a6015c4..d6a50ab9b07 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -96,7 +96,7 @@ class modAsset extends DolibarrModules $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->langfiles = array("assets"); - $this->phpmin = array(5,3); // Minimum version of PHP required by module + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(7,0); // Minimum version of Dolibarr required by module $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 675271a2947..8169cd9961f 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -116,7 +116,7 @@ class modMyModule extends DolibarrModules $this->requiredby = array(); // List of module class names to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->langfiles = array("mymodule@mymodule"); - $this->phpmin = array(5,3); // Minimum version of PHP required by module + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) From 65e42522d352145e23821dd8d2208da2336f74f9 Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 7 Jul 2018 23:50:41 +0200 Subject: [PATCH 128/228] minor html and css corrections (as shown by browser validation and phpstorm inspections) --- htdocs/install/check.php | 70 +++++++++++---------- htdocs/install/default.css | 11 ++-- htdocs/install/fileconf.php | 121 ++++++++++++++++++------------------ htdocs/install/inc.php | 2 +- htdocs/install/index.php | 2 +- htdocs/install/repair.php | 8 +-- htdocs/install/step1.php | 44 ++++++------- htdocs/install/step2.php | 23 ++++--- htdocs/install/step4.php | 19 +++--- htdocs/install/step5.php | 22 +++---- htdocs/install/upgrade.php | 2 +- 11 files changed, 159 insertions(+), 165 deletions(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 09f38fdf452..a5913f9304f 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -40,7 +40,7 @@ $langs->setDefaultLang($setuplang); $langs->load("install"); -// Now we load forced value from install.forced.php file. +// Now we load forced/pre-set values from install.forced.php file. $useforcedwizard=false; $forcedfile="./install.forced.php"; if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; @@ -49,14 +49,14 @@ if (@file_exists($forcedfile)) { include_once $forcedfile; } -dolibarr_install_syslog("--- check: Dolibarr install/upgrade process started"); +dolibarr_install_syslog("- check: Dolibarr install/upgrade process started"); /* * View */ -pHeader('',''); // No next step for navigation buttons. Next step is defined by clik on links. +pHeader('',''); // No next step for navigation buttons. Next step is defined by click on links. //print "
\n"; @@ -233,13 +233,13 @@ else else dolibarr_install_syslog("check: failed to create a new file " . $conffile . " into current dir " . getcwd() . ". Please check permissions.", LOG_ERR); } - // First install, we can't upgrade + // First install: no upgrade necessary/required $allowupgrade=false; } -// File is missng and can't be created +// File is missing and cannot be created if (! file_exists($conffile)) { print 'Error '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated",$conffiletoshow); @@ -258,7 +258,7 @@ else $allowinstall=0; } - // File exists but can't be modified + // File exists but cannot be modified elseif (!is_writable($conffile)) { if ($confexists) @@ -294,7 +294,7 @@ else } print "
\n"; - // Requirements ok, we display the next step button + // Requirements met/all ok: display the next step button if ($checksok) { $ok=0; @@ -307,7 +307,7 @@ else { if (! file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) { - print 'A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file.
'."\n"; + print 'A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file.
'."\n"; dol_syslog("A '" . $conffiletoshow . "' file exists with a dolibarr_main_document_root to " . $dolibarr_main_document_root . " that seems wrong. Try to fix or remove the '" . $conffiletoshow . "' file.", LOG_WARNING); } else @@ -326,7 +326,7 @@ else else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } - // $conf is already instancied inside inc.php + // $conf already created in inc.php $conf->db->type = $dolibarr_main_db_type; $conf->db->host = $dolibarr_main_db_host; $conf->db->port = $dolibarr_main_db_port; @@ -342,7 +342,7 @@ else } } - // If a database access is available, we set more variable + // If database access is available, we set more variables if ($ok) { if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0; @@ -364,8 +364,8 @@ else // Show title if (! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ! empty($conf->global->MAIN_VERSION_LAST_INSTALL)) { - print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE).'
'; - print $langs->trans("VersionProgram").': '.DOL_VERSION.''; + print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE).'
'; + print $langs->trans("VersionProgram").': '.DOL_VERSION.''; //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired")); print '
'; print '
'; @@ -375,7 +375,7 @@ else print $langs->trans("InstallEasy")." "; print $langs->trans("ChooseYourSetupMode"); - print '

'; + print '
'; $foundrecommandedchoice=0; @@ -383,9 +383,9 @@ else $notavailable_choices = array(); // Show first install line - $choice = '
'; - $choice .= ''; - $choice .= ''; - $choice .= ''; - $choice .= ''; + $choice .= ''; - $choice .= '
'.$langs->trans("Module").' '; + print ''.$langs->trans("All").""; + print '/'; + print ''.$langs->trans("None").""; + print ' '.$langs->trans("Permissions").'
'; - $delauft_lang = empty($lang_id) ? $langs->getDefaultLang() : $lang_id; + $default_lang = empty($lang_id) ? $langs->getDefaultLang() : $lang_id; $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); - print Form::selectarray('lang_id', $langs_available, $delauft_lang, 0, 0, 0, '', 0, 0, 0, 'ASC'); + print Form::selectarray('lang_id', $langs_available, $default_lang, 0, 0, 0, '', 0, 0, 0, 'ASC'); if ($conf->global->MAIN_MULTILANGS) { print ''; @@ -301,25 +301,18 @@ if ($object->id) print '
'; + print '
'; print '' . $filename . ''; print '
'.$langs->trans("FreshInstall").''; + $choice = "\n".'
'.$langs->trans("FreshInstall").''; $choice .= ''; + $choice .= ''; $choice .= $langs->trans("FreshInstallDesc"); if (empty($dolibarr_main_db_host)) // This means install process was not run { @@ -397,7 +397,7 @@ else } $choice .= ''; + $choice .= ''; if ($allowinstall) { $choice .= ''.$langs->trans("Start").''; @@ -465,7 +465,7 @@ else if ($ok) { - if (count($dolibarrlastupgradeversionarray) >= 2) // If a database access is available and last upgrade version is known + if (count($dolibarrlastupgradeversionarray) >= 2) // If database access is available and last upgrade version is known { // Now we check if this is the first qualified choice if ($allowupgrade && empty($foundrecommandedchoice) && @@ -477,22 +477,23 @@ else } } else { - // We can not recommand a choice. + // We cannot recommend a choice. // A version of install may be known, but we need last upgrade. } } - $choice .= '
'.$langs->trans("Upgrade").'
'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'
'; + $choice .= "\n".''; + $choice .= ''.$langs->trans("Upgrade").'
'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'
'; $choice .= $langs->trans("UpgradeDesc"); if ($recommended_choice) { $choice .= '
'; //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE); - $choice .= '
'.$langs->trans("InstallChoiceSuggested").'
'; - if ($count < count($migarray)) // There is other choices after + $choice .= '
'; + $choice .= '
'.$langs->trans("InstallChoiceSuggested").'
'; + if ($count < count($migarray)) // There are other choices after { print $langs->trans("MigrateIsDoneStepByStep",DOL_VERSION); } @@ -500,7 +501,7 @@ else } $choice .= '
'; + $choice .= ''; if ($allowupgrade) { $disabled=false; @@ -512,8 +513,14 @@ else { $foundrecommandedchoice = 2; } - if ($disabled) $choice .= ''.$langs->trans("NotAvailable").''; - else $choice .= ''.$langs->trans("Start").''; + if ($disabled) + { + $choice .= ''.$langs->trans("NotAvailable").''; + } + else + { + $choice .= ''.$langs->trans("Start").''; + } } else { @@ -537,28 +544,28 @@ else } // Array of install choices + print"\n"; print ''; foreach ($available_choices as $choice) { print $choice; } - print '
'; + print '
'."\n"; if (count($notavailable_choices)) { - print '
'; print ''; print ''; } @@ -590,6 +597,5 @@ $(".runupgrade").click(function() { '; -dolibarr_install_syslog("--- check: end"); +dolibarr_install_syslog("- check: end"); pFooter(1); // Never display next button - diff --git a/htdocs/install/default.css b/htdocs/install/default.css index e23a36ddd21..6ea6d451e92 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -199,7 +199,7 @@ input:-webkit-autofill { -webkit-box-shadow: 0 0 0 50px #FBFFEA inset; } -table.listofchoices, tr.listofchoices, td.listofchoices { +table.listofchoices, table.listofchoices tr, table.listofchoices td { border-collapse: collapse; padding: 4px; color: #000000; @@ -207,9 +207,6 @@ table.listofchoices, tr.listofchoices, td.listofchoices { line-height: 18px; } -tr.listofchoices { - height: 42px; -} .listofchoicesdesc { color: #999 !important; } @@ -230,7 +227,7 @@ tr.listofchoices { div.ok { color: #114466; } -font.ok { +span.ok { color: #114466; } @@ -238,7 +235,7 @@ font.ok { div.warning { color: #777711; } -font.warning { +span.warning { color: #777711; } @@ -249,7 +246,7 @@ div.error { padding: 0.2em 0.2em 0.2em 0; margin: 0.5em 0 0.5em 0; } -font.error { +span.error { color: #550000; font-weight: bold; } diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index b0affb2218a..cee5d181d45 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -24,7 +24,7 @@ /** * \file htdocs/install/fileconf.php * \ingroup install - * \brief Ask all informations required to build Dolibarr htdocs/conf/conf.php file (will be wrote on disk on next page step1) + * \brief Ask all information required to build Dolibarr htdocs/conf/conf.php file (will be written to disk on next page step1) */ include_once 'inc.php'; @@ -39,7 +39,7 @@ $langs->setDefaultLang($setuplang); $langs->load("install"); $langs->load("errors"); -dolibarr_install_syslog("--- fileconf: entering fileconf.php page"); +dolibarr_install_syslog("- fileconf: entering fileconf.php page"); // You can force preselected values of the config step of Dolibarr by adding a file // install.forced.php into directory htdocs/install (This is the case with some wizard @@ -56,7 +56,7 @@ if (! isset($force_install_databaselogin)) $force_install_databaselogin=''; if (! isset($force_install_databasepass)) $force_install_databasepass=''; if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin=''; if (! isset($force_install_databaserootpass)) $force_install_databaserootpass=''; -// Now we load forced value from install.forced.php file. +// Now we load forced values from install.forced.php file. $useforcedwizard=false; $forcedfile="./install.forced.php"; if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; // Must be after inc.php @@ -71,7 +71,7 @@ if (@file_exists($forcedfile)) { * View */ -session_start(); // To be able to keep info into session (used for not loosing pass during navigation. pass must not transit throug parmaeters) +session_start(); // To be able to keep info into session (used for not losing pass during navigation. pass must not transit through parmaeters) pHeader($langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY)?'':$force_dolibarr_js_JQUERY.'/'), 'main-inside-bis'); @@ -80,7 +80,7 @@ if (! is_writable($conffile)) { print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING); - dolibarr_install_syslog("--- fileconf: end"); + dolibarr_install_syslog("- fileconf: end"); pFooter(1,$setuplang,'jscheckparam'); exit; } @@ -117,20 +117,18 @@ if (! empty($force_install_message)) - '; - print $langs->trans("WebPagesDirectory"); - print ""; - + + - + @@ -149,19 +147,19 @@ if (! empty($force_install_message)) - trans("DocumentsDirectory"); ?> - + - + @@ -186,12 +184,13 @@ if (! empty($force_install_message)) } ?> - trans("URLRoot"); ?> + - + - trans("ForceHttps"); ?> - - + + @@ -239,11 +239,11 @@ if (! empty($force_install_message)) - trans("DatabaseName"); ?> - - - + + - trans("DriverType"); ?> - + - trans("DatabaseServer"); ?> - - + + - trans("Port"); ?> - + + - trans("DatabasePrefix"); ?> - - - + + - trans("CreateDatabase"); ?> - - + + - trans("Login"); ?> - - - + + - trans("Password"); ?> - - - + + - trans("CreateUser"); ?> - - + + @@ -473,8 +471,8 @@ if (! empty($force_install_message)) - trans("Login"); ?> - + + - trans("Password"); ?> - - + + close(); Not database connexion yet -dolibarr_install_syslog("--- fileconf: end"); +dolibarr_install_syslog("- fileconf: end"); pFooter($err,$setuplang,'jscheckparam'); diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 0a2a6866f26..88dbc76f9a6 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -149,7 +149,7 @@ if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now '' define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...) -if (empty($conf->file->character_set_client)) $conf->file->character_set_client="UTF-8"; +if (empty($conf->file->character_set_client)) $conf->file->character_set_client="utf-8"; if (empty($conf->db->character_set)) $conf->db->character_set='utf8'; if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation='utf8_unicode_ci'; if (empty($conf->db->dolibarr_main_db_encryption)) $conf->db->dolibarr_main_db_encryption=0; diff --git a/htdocs/install/index.php b/htdocs/install/index.php index 82dcd87b030..46e60be52ec 100644 --- a/htdocs/install/index.php +++ b/htdocs/install/index.php @@ -55,7 +55,7 @@ print '

'; print ''; print ''; -print ''; print ''; diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 97f9a71bb87..0c3edfaebd3 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -549,11 +549,11 @@ if ($ok && GETPOST('clean_menus','alpha')) dol_print_error($db); } else - print ' - Cleaned'; + print ' - Cleaned'; } else { - print ' - Canceled (test mode)'; + print ' - Canceled (test mode)'; } } else @@ -982,11 +982,11 @@ if ($ok && GETPOST('force_disable_of_modules_not_found','alpha')) dol_print_error($db); } else - print ' - Cleaned'; + print ' - Cleaned'; } else { - print ' - Canceled (test mode)'; + print ' - Canceled (test mode)'; } } else diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 6f1143d6f10..f6f1571b4ec 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -46,7 +46,7 @@ $main_dir = GETPOST('main_dir')?GETPOST('main_dir'):(empty($argv[3])?'':$argv[3] $main_data_dir = GETPOST('main_data_dir') ? GETPOST('main_data_dir') : (empty($argv[4])? ($main_dir . '/documents') :$argv[4]); // Dolibarr root URL $main_url = GETPOST('main_url')?GETPOST('main_url'):(empty($argv[5])?'':$argv[5]); -// Database login informations +// Database login information $userroot=GETPOST('db_user_root','alpha')?GETPOST('db_user_root','alpha'):(empty($argv[6])?'':$argv[6]); $passroot=GETPOST('db_pass_root','none')?GETPOST('db_pass_root','none'):(empty($argv[7])?'':$argv[7]); // Database server @@ -68,18 +68,18 @@ $main_alt_dir_name = ((GETPOST("main_alt_dir_name",'alpha') && GETPOST("main_alt session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters) -// Save a flag to tell to restore input value if we do back +// Save a flag to tell to restore input value if we go back $_SESSION['dol_save_pass']=$db_pass; //$_SESSION['dol_save_passroot']=$passroot; -// Now we load forced value from install.forced.php file. +// Now we load forced values from install.forced.php file. $useforcedwizard=false; $forcedfile="./install.forced.php"; if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; - // If forced install is enabled, let's replace post values. These are empty because form fields are disabled. + // If forced install is enabled, replace the post values. These are empty because form fields are disabled. if ($force_install_noedit) { $main_dir = detect_dolibarr_main_document_root(); if (!empty($force_install_main_data_root)) { @@ -204,7 +204,7 @@ if (! $error) { $result=@include_once $main_dir."/core/db/".$db_type.'.class.php'; if ($result) { - // If we ask database or user creation we need to connect as root, so we need root login + // If we require database or user creation we need to connect as root, so we need root login credentials if (!empty($db_create_database) && !$userroot) { print '
'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$db_name).'
'; print '
'; @@ -397,7 +397,7 @@ if (! $error && $db->connected && $action == "set") print ""; print ''; $error++; @@ -420,7 +420,7 @@ if (! $error && $db->connected && $action == "set") } } - // Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre telecharges en passant outre l'authentification + // Documents are stored above the web pages root to prevent being downloaded without authentification $dir=array(); $dir[] = $main_data_dir."/mycompany"; $dir[] = $main_data_dir."/medias"; @@ -431,7 +431,7 @@ if (! $error && $db->connected && $action == "set") $dir[] = $main_data_dir."/produit"; $dir[] = $main_data_dir."/doctemplates"; - // Boucle sur chaque repertoire de dir[] pour les creer s'ils nexistent pas + // Loop on each directory of dir [] to create them if they do not exist $num=count($dir); for ($i = 0; $i < $num; $i++) { @@ -469,7 +469,7 @@ if (! $error && $db->connected && $action == "set") print ""; print ''; } @@ -519,7 +519,7 @@ if (! $error && $db->connected && $action == "set") // Save old conf file on disk if (file_exists("$conffile")) { - // We must ignore errors as an existing old file may already exists and not be replacable or + // We must ignore errors as an existing old file may already exist and not be replaceable or // the installer (like for ubuntu) may not have permission to create another file than conf.php. // Also no other process must be able to read file or we expose the new file, so content with password. @dol_copy($conffile, $conffile.'.old', '0400'); @@ -539,7 +539,7 @@ if (! $error && $db->connected && $action == "set") print ''; print ''; - // Si creation utilisateur admin demandee, on le cree + // Create database user if requested if (isset($db_create_user) && ($db_create_user == "1" || $db_create_user == "on")) { dolibarr_install_syslog("step1: create database user: " . $dolibarr_main_db_user); @@ -558,7 +558,7 @@ if (! $error && $db->connected && $action == "set") $databasefortest='master'; } - // Creation handler de base, verification du support et connexion + // Check database connection $db=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,$databasefortest,$conf->db->port); @@ -629,7 +629,7 @@ if (! $error && $db->connected && $action == "set") print ''; print ''; - // Affiche aide diagnostique + // warning message due to connection failure print ''; print ''; - // Affiche aide diagnostique + // warning message print '"; - // si acces serveur ok et acces base ok, tout est ok, on ne va pas plus loin, on a meme pas utilise le compte root. + // server access ok, basic access ok if ($db->database_selected) { dolibarr_install_syslog("step1: connection to database " . $conf->db->name . " by user " . $conf->db->user . " ok"); @@ -747,7 +747,7 @@ if (! $error && $db->connected && $action == "set") print 'Error'; print ""; - // Affiche aide diagnostique + // warning message print '"; - // Affiche aide diagnostique + // warning message print '\n"; + print '\n"; } } } From 78ba8bc3b59fed3ebcc9ea149a7f92bb8150a256 Mon Sep 17 00:00:00 2001 From: tarrsalah Date: Sun, 8 Jul 2018 14:07:06 +0100 Subject: [PATCH 129/228] FIX side nav height. --- htdocs/theme/eldy/style.css.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 9df170b3124..da7e6f6d50e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1109,6 +1109,7 @@ td.showDragHandle { border-right: 1px solid #d0d0d0; box-shadow: 3px 0 6px -2px #eee; background: rgb(); + height: 100vh; } div.blockvmenulogo { From 41f21f3867a8e16e9fa6492b7eaf3d883a8fb42e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jul 2018 20:06:24 +0200 Subject: [PATCH 130/228] Translation --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 2 +- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 2 +- htdocs/core/tpl/admin_extrafields_view.tpl.php | 2 +- htdocs/langs/en_US/admin.lang | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 6a59722e4d8..81b49719e98 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -144,7 +144,7 @@ $langs->load("modulebuilder");
'.$langs->trans("DefaultLanguage").' : '; +print ''.$langs->trans("DefaultLanguage").' : '; print $formadmin->select_language('auto','selectlang',1,0,0,1); print '
".$langs->trans("ErrorDirDoesNotExists",$main_data_dir); print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite"); print ''; - print ''.$langs->trans("Error").''; + print ''.$langs->trans("Error").''; print "

'.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').'
".$langs->trans("ErrorDirDoesNotExists",$main_data_dir); print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite"); print ''; - print ''.$langs->trans("Error").''; + print ''.$langs->trans("Error").''; print "

'.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').'
Ok
Error

'; print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot); print '
'; @@ -640,10 +640,10 @@ if (! $error && $db->connected && $action == "set") $error++; } } - } // Fin si "creation utilisateur" + } // end of user account creation - // If database creation is asked, we create it + // If database creation was asked, we create it if (!$error && (isset($db_create_database) && ($db_create_database == "1" || $db_create_database == "on"))) { dolibarr_install_syslog("step1: create database: " . $dolibarr_main_db_name . " " . $dolibarr_main_db_character_set . " " . $dolibarr_main_db_collation . " " . $dolibarr_main_db_user); $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); @@ -672,7 +672,7 @@ if (! $error && $db->connected && $action == "set") } else { - // Affiche aide diagnostique + // warning message print '

'; print $langs->trans("ErrorFailedToCreateDatabase",$dolibarr_main_db_name).'
'; print $newdb->lasterror().'
'; @@ -693,7 +693,7 @@ if (! $error && $db->connected && $action == "set") print '
Error

'; print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot); print '
'; @@ -703,7 +703,7 @@ if (! $error && $db->connected && $action == "set") $error++; } - } // Fin si "creation database" + } // end of create database // We test access with dolibarr database user (not admin) @@ -724,7 +724,7 @@ if (! $error && $db->connected && $action == "set") print 'Ok'; print "

'; print $langs->trans('CheckThatDatabasenameIsCorrect',$dolibarr_main_db_name).'
'; print $langs->trans('IfAlreadyExistsCheckOption').'
'; @@ -767,7 +767,7 @@ if (! $error && $db->connected && $action == "set") print 'Error'; print "

'; print $langs->trans("ErrorConnection",$conf->db->host,$conf->db->name,$conf->db->user); print $langs->trans('IfLoginDoesNotExistsCheckCreateUser').'
'; @@ -1023,7 +1023,7 @@ function write_conf_file($conffile) if (file_exists("$conffile")) { - include $conffile; // On force rechargement. Ne pas mettre include_once ! + include $conffile; // force config reload, do not put include_once conf($dolibarr_main_document_root); print "
"; diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 30b3ff7d64f..b9adb5dac21 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -58,7 +58,7 @@ if ($dolibarr_main_db_type == "sqlite3") $choix=5; //if (empty($choix)) dol_print_error('','Database type '.$dolibarr_main_db_type.' not supported into step2.php page'); -// Now we load forced value from install.forced.php file. +// Now we load forced values from install.forced.php file. $useforcedwizard=false; $forcedfile="./install.forced.php"; if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; @@ -67,7 +67,7 @@ if (@file_exists($forcedfile)) { include_once $forcedfile; } -dolibarr_install_syslog("--- step2: entering step2.php page"); +dolibarr_install_syslog("- step2: entering step2.php page"); /* @@ -88,7 +88,7 @@ if ($action == "set") { print '

Database '.$langs->trans("Database").'

'; - print ''; + print '
'; $error=0; $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); @@ -237,7 +237,7 @@ if ($action == "set") print ""; - print ''; + print ''; $error++; } } @@ -246,7 +246,7 @@ if ($action == "set") { print ""; - print ''; + print ''; $error++; dolibarr_install_syslog("step2: failed to open file " . $dir . $file, LOG_ERR); } @@ -384,7 +384,7 @@ if ($action == "set") print ""; - print ''; + print ''; $error++; } } @@ -395,7 +395,7 @@ if ($action == "set") { print ""; - print '"; + print '"; $error++; dolibarr_install_syslog("step2: failed to open file " . $dir . $file, LOG_ERR); } @@ -417,7 +417,7 @@ if ($action == "set") ***************************************************************************************/ if ($ok && $createfunctions) { - // For this file, we use directory according to database type + // For this file, we use a directory according to database type if ($choix==1) $dir = "mysql/functions/"; elseif ($choix==2) $dir = "pgsql/functions/"; elseif ($choix==3) $dir = "mssql/functions/"; @@ -473,7 +473,7 @@ if ($action == "set") print ""; - print ''; + print ''; $error++; } } @@ -594,7 +594,7 @@ if ($action == "set") { $ok = 0; $okallfile = 0; - print ''.$langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()."
"; + print ''.$langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()."
"; } } } @@ -627,7 +627,7 @@ $ret=0; if (!$ok && isset($argv[1])) $ret=1; dolibarr_install_syslog("Exit ".$ret); -dolibarr_install_syslog("--- step2: end"); +dolibarr_install_syslog("- step2: end"); pFooter($ok?0:1,$setuplang); @@ -635,4 +635,3 @@ if (isset($db) && is_object($db)) $db->close(); // Return code if ran from command line if ($ret) exit($ret); - diff --git a/htdocs/install/step4.php b/htdocs/install/step4.php index 92bcb3dc1a7..64d6993cc94 100644 --- a/htdocs/install/step4.php +++ b/htdocs/install/step4.php @@ -47,7 +47,7 @@ if (@file_exists($forcedfile)) { include_once $forcedfile; } -dolibarr_install_syslog("--- step4: entering step4.php page"); +dolibarr_install_syslog("- step4: entering step4.php page"); $error=0; $ok = 0; @@ -74,18 +74,18 @@ print '


'; -print '

".$langs->trans("CreateTableAndPrimaryKey",$name); print "
\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer.'
Executed query : '.$db->lastquery; print "\n
'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'
'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'
".$langs->trans("CreateTableAndPrimaryKey",$name); print "'.$langs->trans("Error").' Failed to open file '.$dir.$file.'
'.$langs->trans("Error").' Failed to open file '.$dir.$file.'
".$langs->trans("CreateOtherKeysForTable",$name); print "
\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror(); print "\n
'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'
'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'
".$langs->trans("CreateOtherKeysForTable",$name); print "'.$langs->trans("Error")." Failed to open file ".$dir.$file."
'.$langs->trans("Error")." Failed to open file ".$dir.$file."
".$langs->trans("FunctionsCreation"); print "
\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer; print "\n
'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'
'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'
'; +print '
'; $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); if ($db->ok) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'.$langs->trans("Login").' :'; - print '
'.$langs->trans("Password").' :'; - print '
'.$langs->trans("PasswordAgain").' :'; - print '
'; + print '
'; + print '
'; + print '
'; if (isset($_GET["error"]) && $_GET["error"] == 1) @@ -113,12 +113,11 @@ if ($db->ok) } - $ret=0; if ($error && isset($argv[1])) $ret=1; dolibarr_install_syslog("Exit ".$ret); -dolibarr_install_syslog("--- step4: end"); +dolibarr_install_syslog("- step4: end"); pFooter($error,$setuplang); diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 79fead3c51d..845c3aa8a02 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -23,7 +23,7 @@ /** * \file htdocs/install/step5.php * \ingroup install - * \brief Last page of upgrade or install process + * \brief Last page of upgrade / install process */ include_once 'inc.php'; @@ -67,7 +67,7 @@ if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.fo if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; - // If forced install is enabled, let's replace post values. These are empty because form fields are disabled. + // If forced install is enabled, replace post values. These are empty because form fields are disabled. if ($force_install_noedit == 2) { if (!empty($force_install_dolibarrlogin)) { $login = $force_install_dolibarrlogin; @@ -75,16 +75,15 @@ if (@file_exists($forcedfile)) { } } -dolibarr_install_syslog("--- step5: entering step5.php page"); +dolibarr_install_syslog("- step5: entering step5.php page"); $error=0; - /* * Actions */ -// If install, check pass and pass_verif used to create admin account +// If install, check password and password_verification used to create admin account if ($action == "set") { if ($pass <> $pass_verif) { header("Location: step4.php?error=1&selectlang=$setuplang" . (isset($login) ? '&login=' . $login : '')); @@ -394,8 +393,8 @@ if ($action == "set" && $success) else { // If here MAIN_VERSION_LAST_UPGRADE is not empty - print $langs->trans("VersionLastUpgrade").': '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'
'; - print $langs->trans("VersionProgram").': '.DOL_VERSION.'
'; + print $langs->trans("VersionLastUpgrade").': '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'
'; + print $langs->trans("VersionProgram").': '.DOL_VERSION.'
'; print $langs->trans("MigrationNotFinished").'
'; print "
"; @@ -442,8 +441,8 @@ elseif (empty($action) || preg_match('/upgrade/i',$action)) else { // If here MAIN_VERSION_LAST_UPGRADE is not empty - print $langs->trans("VersionLastUpgrade").': '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'
'; - print $langs->trans("VersionProgram").': '.DOL_VERSION.''; + print $langs->trans("VersionLastUpgrade").': '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'
'; + print $langs->trans("VersionProgram").': '.DOL_VERSION.''; print "
"; @@ -457,17 +456,14 @@ else dol_print_error('','step5.php: unknown choice of action'); } - - // Clear cache files clearstatcache(); - $ret=0; if ($error && isset($argv[1])) $ret=1; dolibarr_install_syslog("Exit ".$ret); -dolibarr_install_syslog("--- step5: Dolibarr setup finished"); +dolibarr_install_syslog("- step5: Dolibarr setup finished"); pFooter(1,$setuplang); diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index c2ee6e93ad4..3136c813bea 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -297,7 +297,7 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 { if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE') { - print '
'.$sql.' : '.$db->lasterror()."
'.$sql.' : '.$db->lasterror()."
- + diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 3c3cc1858c5..1d40a851576 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -176,7 +176,7 @@ elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($t } ?> - + diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 1b0a5303bec..f6d5cebcc9e 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -51,7 +51,7 @@ print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 960bee03aef..a7cb30d970d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -958,6 +958,7 @@ CalcLocaltax3=Sales CalcLocaltax3Desc=Local Taxes reports are the total of localtaxes sales LabelUsedByDefault=Label used by default if no translation can be found for code LabelOnDocuments=Label on documents +LabelOrTranslationKey=Label or translation key NbOfDays=Nb of days AtEndOfMonth=At end of month CurrentNext=Current/Next From 291f149a9b4b291d254b2c1f38de38d10053e66d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jul 2018 20:26:48 +0200 Subject: [PATCH 131/228] NEW Can set a tooltip help text on extrafields --- htdocs/core/actions_extrafields.inc.php | 4 ++-- htdocs/core/tpl/admin_extrafields_add.tpl.php | 9 ++++++--- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 8 ++++++-- htdocs/core/tpl/admin_extrafields_view.tpl.php | 4 ++-- htdocs/langs/en_US/admin.lang | 2 ++ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 6b6d40acd9c..599b847b49e 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -178,7 +178,7 @@ if ($action == 'add') (GETPOST('alwayseditable', 'alpha')?1:0), (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), $visibility, - 0, + GETPOST('help','alpha'), GETPOST('computed_value','alpha'), (GETPOST('entitycurrentorall', 'alpha')?0:''), GETPOST('langfile', 'alpha') @@ -344,7 +344,7 @@ if ($action == 'update') (GETPOST('alwayseditable', 'alpha')?1:0), (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), $visibility, - 0, + GETPOST('help','alpha'), GETPOST('default_value','alpha'), GETPOST('computed_value','alpha'), (GETPOST('entitycurrentorall', 'alpha')?0:''), diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 81b49719e98..e80685154fc 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -186,12 +186,15 @@ $langs->load("modulebuilder"); -multicompany->enabled) { ?> - - + + +multicompany->enabled) { ?> + + +
trans("Label"); ?>
trans("LabelOrTranslationKey"); ?>
trans("AttributeCode"); ?> (trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)
trans("Label"); ?>
trans("LabelOrTranslationKey"); ?>
trans("AttributeCode"); ?>
'.$langs->trans("Position"); print ''; print ''.$langs->trans("Label").''.$langs->trans("LabelOrTranslationKey").''.$langs->trans("TranslationString").''.$langs->trans("AttributeCode").''.$langs->trans("Type").'
trans("Required"); ?>>
trans("AlwaysEditable"); ?>>
trans("AllEntities"); ?>>
textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?>
textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?>
trans("AllEntities"); ?>>
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 1d40a851576..cb5ef26bc57 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -156,6 +156,7 @@ $param=$extrafields->attributes[$elementtype]['param'][$attrname]; $perms=$extrafields->attributes[$elementtype]['perms'][$attrname]; $langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname]; $list=$extrafields->attributes[$elementtype]['list'][$attrname]; +$help=$extrafields->attributes[$elementtype]['help'][$attrname]; $entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname]; if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) @@ -248,12 +249,15 @@ else trans("Required"); ?>> trans("AlwaysEditable"); ?>> +textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> + + +textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?> multicompany->enabled) { ?> + trans("AllEntities"); ?>> -textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> - diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index f6d5cebcc9e..a03c06f2d1d 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -56,8 +56,8 @@ print ''.$langs->trans("TranslationString").''; print ''.$langs->trans("AttributeCode").''; print ''.$langs->trans("Type").''; print ''.$langs->trans("Size").''; -print ''.$langs->trans("Unique").''; print ''.$langs->trans("ComputedFormula").''; +print ''.$langs->trans("Unique").''; print ''.$langs->trans("Required").''; print ''.$langs->trans("AlwaysEditable").''; print ''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''; @@ -83,8 +83,8 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel print "".$key."\n"; print "".$type2label[$extrafields->attributes[$elementtype]['type'][$key]]."\n"; print ''.$extrafields->attributes[$elementtype]['size'][$key]."\n"; - print ''.yn($extrafields->attributes[$elementtype]['unique'][$key])."\n"; print ''.dol_trunc($extrafields->attributes[$elementtype]['computed'][$key], 20)."\n"; + print ''.yn($extrafields->attributes[$elementtype]['unique'][$key])."\n"; print ''.yn($extrafields->attributes[$elementtype]['required'][$key])."\n"; print ''.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."\n"; print ''.$extrafields->attributes[$elementtype]['list'][$key]."\n"; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a7cb30d970d..adaa93103db 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1796,6 +1796,8 @@ COMPANY_AQUARIUM_REMOVE_SPECIAL=Remove special characters COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX) GDPRContact=GDPR contact GDPRContactDesc=If you store data about European companies/citizen, you can store here the contact who is responsible for the General Data Protection Regulation +HelpOnTooltip=Help text to show on tooltip +HelpOnTooltipDesc=Put here a text or a translation key for a text to show on a tooltip when this field appears into a form ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). From 12d4880e7b99f5ef47280e5b25a326a51c1780a2 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 9 Jul 2018 10:08:27 +0200 Subject: [PATCH 132/228] Docs : update and complete --- htdocs/core/modules/modAccounting.class.php | 2 +- htdocs/core/modules/modAdherent.class.php | 10 +++++----- htdocs/core/modules/modAgenda.class.php | 11 ++++++----- htdocs/core/modules/modApi.class.php | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 42cd67b9dab..ba56042ec61 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -66,7 +66,7 @@ class modAccounting extends DolibarrModules $this->depends = array("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array("modComptabilite"); // List of modules are in conflict with this module - $this->phpmin = array(5, 3); // Minimum version of PHP required by module + $this->phpmin = array(5, 4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3, 9); // Minimum version of Dolibarr required by module $this->langfiles = array("accountancy","compta"); diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 5fde53c9653..74f61fd288f 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -62,17 +62,17 @@ class modAdherent extends DolibarrModules $this->dirs = array("/adherent/temp"); // Config pages - //------------- $this->config_page_url = array("adherent.php@adherents"); // Dependencies - //------------ - $this->depends = array(); - $this->requiredby = array('modMailmanSpip'); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with $this->langfiles = array("members","companies"); + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Constants - //----------- $this->const = array(); $r=0; diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 5078f81ad05..d5620d6805b 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -65,14 +65,15 @@ class modAgenda extends DolibarrModules $this->dirs = array("/agenda/temp"); // Config pages - //------------- $this->config_page_url = array("agenda_other.php"); - // Dependancies - //------------- - $this->depends = array(); - $this->requiredby = array(); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->langfiles = array("companies"); + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Module parts $this->module_parts = array(); diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index c8dc7ae84ba..71374e136e5 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -82,7 +82,7 @@ class modApi extends DolibarrModules $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->phpmin = array(5,3); // Minimum version of PHP required by module + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("other"); // Constants From d3d1b6d513f598200610cf663cd875483fe08f48 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jul 2018 13:02:01 +0200 Subject: [PATCH 133/228] NEW Can enable a module, even external module, from command line --- htdocs/core/class/extrafields.class.php | 12 ++--- htdocs/core/db/mysqli.class.php | 26 ++++++---- htdocs/install/upgrade.php | 13 +++-- htdocs/install/upgrade2.php | 67 +++++++++++++++++++------ 4 files changed, 83 insertions(+), 35 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 174e01bf74c..db0af174810 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -256,10 +256,10 @@ class ExtraFields if ($type == 'varchar' && empty($lengthdb)) $lengthdb='255'; } $field_desc = array( - 'type'=>$typedb, - 'value'=>$lengthdb, - 'null'=>($required?'NOT NULL':'NULL'), - 'default' => $default_value + 'type'=>$typedb, + 'value'=>$lengthdb, + 'null'=>($required?'NOT NULL':'NULL'), + 'default' => $default_value ); $result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); @@ -376,8 +376,8 @@ class ExtraFields $sql.= " '".$this->db->escape($list)."',"; $sql.= " ".($default?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; - $sql .= " " . $user->id . ","; - $sql .= " " . $user->id . ","; + $sql .= " " . (is_object($user) ? $user->id : 0). ","; + $sql .= " " . (is_object($user) ? $user->id : 0). ","; $sql .= "'" . $this->db->idate(dol_now()) . "',"; $sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1").","; $sql.= " ".($help?"'".$this->db->escape($help)."'":"null"); diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 15d95e39194..23c19542ae6 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -765,28 +765,36 @@ class DoliDBMysqli extends DoliDB // ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); $sql= "ALTER TABLE ".$table." ADD ".$field_name." "; $sql.= $field_desc['type']; - if(preg_match("/^[^\s]/i",$field_desc['value'])) + if (preg_match("/^[^\s]/i",$field_desc['value'])) + { if (! in_array($field_desc['type'],array('date','datetime'))) { $sql.= "(".$field_desc['value'].")"; } - if(preg_match("/^[^\s]/i",$field_desc['attribute'])) - $sql.= " ".$field_desc['attribute']; - if(preg_match("/^[^\s]/i",$field_desc['null'])) - $sql.= " ".$field_desc['null']; - if(preg_match("/^[^\s]/i",$field_desc['default'])) + } + if (isset($field_desc['attribute']) && preg_match("/^[^\s]/i",$field_desc['attribute'])) + { + $sql.= " ".$field_desc['attribute']; + } + if (isset($field_desc['null']) && preg_match("/^[^\s]/i",$field_desc['null'])) + { + $sql.= " ".$field_desc['null']; + } + if (isset($field_desc['default']) && preg_match("/^[^\s]/i",$field_desc['default'])) { if(preg_match("/null/i",$field_desc['default'])) $sql.= " default ".$field_desc['default']; else $sql.= " default '".$field_desc['default']."'"; } - if(preg_match("/^[^\s]/i",$field_desc['extra'])) - $sql.= " ".$field_desc['extra']; + if (isset($field_desc['extra']) && preg_match("/^[^\s]/i",$field_desc['extra'])) + { + $sql.= " ".$field_desc['extra']; + } $sql.= " ".$field_position; dol_syslog(get_class($this)."::DDLAddField ".$sql,LOG_DEBUG); - if($this->query($sql)) { + if ($this->query($sql)) { return 1; } return -1; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index c2ee6e93ad4..f6e1b535706 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2015-2016 Raphaël Doursenaud * @@ -21,10 +21,13 @@ * * cd htdocs/install * php upgrade.php 3.4.0 3.5.0 [dirmodule|ignoredbversion] - * php upgrade2.php 3.4.0 3.5.0 + * php upgrade2.php 3.4.0 3.5.0 [MODULE_NAME1_TO_ENABLE,MODULE_NAME2_TO_ENABLE] * - * Option 'dirmodule' allows to provide a path for an external module, so we migrate from command line a script from a module. - * Option 'ignoredbversion' allows to run migration even if database is a bugged database version. + * And for final step: + * php step5.php 3.4.0 3.5.0 + * + * Option 'dirmodule' allows to provide a path for an external module, so we migrate from command line using a script from a module. + * Option 'ignoredbversion' allows to run migration even if database version does not match start version of migration * Return code is 0 if OK, >0 if error */ @@ -84,7 +87,7 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial if (! $versionfrom && ! $versionto) { print 'Error: Parameter versionfrom or versionto missing.'."\n"; - print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install) instead of page install/upgrade.php'."\n"; + print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 628f4dfc734..5174ebb6806 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2012 Laurent Destailleur + * Copyright (C) 2005-2018 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015-2016 Raphaël Doursenaud @@ -18,13 +18,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Upgrade scripts can be ran from command line with syntax: + * Upgrade2 scripts can be ran from command line with syntax: * * cd htdocs/install - * php upgrade.php 3.4.0 3.5.0 - * php upgrade2.php 3.4.0 3.5.0 [MODULE_NAME1_TO_ENABLE,MODULE_NAME2_TO_ENABLE] + * php upgrade.php 3.4.0 3.5.0 [dirmodule|ignoredbversion] + * php upgrade2.php 3.4.0 3.5.0 [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE] + * + * And for final step: + * php step5.php 3.4.0 3.5.0 * * Return code is 0 if OK, >0 if error + * + * Note: To just enable a module from command line, use this syntax: + * php upgrade2.php 0.0.0 0.0.0 [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE] */ /** @@ -77,7 +83,7 @@ if ($dolibarr_main_db_type == 'pgsql') $choix=2; if ($dolibarr_main_db_type == 'mssql') $choix=3; -dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page ".$versionfrom." ".$versionto); +dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page ".$versionfrom." ".$versionto." ".$enablemodules); if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); @@ -89,14 +95,14 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto || preg_match('/version/', $versionto))) { print 'Error: Parameter versionfrom or versionto missing or having a bad format.'."\n"; - print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install) instead of page install/upgrade.php'."\n"; + print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path=dirname(__FILE__).'/'; if (substr($sapi_type, 0, 3) == 'cli') { - print 'Syntax from command line: '.$script_file." x.y.z a.b.c\n"; + print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n"; } exit; } @@ -438,6 +444,13 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 migrate_rename_directories($db,$langs,$conf,'/contracts','/contract'); } + // Scripts for 9.0 + $afterversionarray=explode('.','8.0.9'); + $beforeversionarray=explode('.','9.0.9'); + if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) + { + //migrate_rename_directories($db,$langs,$conf,'/contracts','/contract'); + } } // Code executed only if migration is LAST ONE. Must always be done. @@ -541,12 +554,12 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 dolCopyDir($srcroot, $destroot, 0, 0); - // Actions for all versions (no database change, delete files and directories) + // Actions for all versions (no database change but delete some files and directories) migrate_delete_old_files($db, $langs, $conf); migrate_delete_old_dir($db, $langs, $conf); - // Actions for all versions (no database change, create directories) + // Actions for all versions (no database change but create some directories) dol_mkdir(DOL_DATA_ROOT.'/bank'); - // Actions for all versions (no database change, rename directories) + // Actions for all versions (no database change but rename some directories) migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits'); print '

'.$langs->trans("MigrationFinished").'
'; @@ -4536,11 +4549,11 @@ function migrate_delete_old_dir($db,$langs,$conf) * @param int $force 1=Reload module even if not already loaded * @return void */ -function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) +function migrate_reload_modules($db, $langs, $conf, $listofmodule=array(), $force=0) { if (count($listofmodule) == 0) return; - dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force); + dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule))); foreach($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' { @@ -4723,8 +4736,15 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg); if (! empty($reg[1])) { - $moduletoreloadshort = ucfirst(strtolower($reg[1])); - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort); + if (strtoupper($moduletoreload) == $moduletoreload) // If key is un uppercase + { + $moduletoreloadshort = ucfirst(strtolower($reg[1])); + } + else // If key is a mix of up and low case + { + $moduletoreloadshort = $reg[1]; + } + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort." with mode ".$reloadmode); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'; if ($res) { $classname = 'mod'.$moduletoreloadshort; @@ -4732,10 +4752,27 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) //$mod->remove('noboxes'); $mod->init($reloadmode); } + else + { + dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + + $res=@dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + if ($res) { + $classname = 'mod'.$moduletoreloadshort; + $mod=new $classname($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + else + { + dolibarr_install_syslog('Failed to include '.strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + } + } } else { - print "Error, can't find module name"; + dolibarr_install_syslog("Error, can't find module with name ".$moduletoreload, LOG_WARNING); + print "Error, can't find module with name ".$moduletoreload; } } From 2c4d7c4835e975fda9917047374415bfb3165156 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 9 Jul 2018 14:06:59 +0200 Subject: [PATCH 134/228] Docs : update and complete --- htdocs/core/modules/modAsset.class.php | 2 +- htdocs/core/modules/modCashDesk.class.php | 3 +- .../core/modules/modExpenseReport.class.php | 5 ++-- htdocs/core/modules/modGeoIPMaxmind.class.php | 8 +++-- htdocs/core/modules/modGravatar.class.php | 8 +++-- htdocs/core/modules/modHRM.class.php | 29 ++++++------------- htdocs/core/modules/modHoliday.class.php | 8 +++-- 7 files changed, 30 insertions(+), 33 deletions(-) diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index 9b82a6015c4..d6a50ab9b07 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -96,7 +96,7 @@ class modAsset extends DolibarrModules $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->langfiles = array("assets"); - $this->phpmin = array(5,3); // Minimum version of PHP required by module + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(7,0); // Minimum version of Dolibarr required by module $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index 4be7a937d1a..2b33e09c1ac 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -64,9 +64,10 @@ class modCashDesk extends DolibarrModules $this->config_page_url = array("cashdesk.php@cashdesk"); // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(4,1); // Minimum version of PHP required by module + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module $this->langfiles = array("cashdesk"); $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index 2dd46c9b788..78f517b6768 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -61,10 +61,11 @@ class modExpenseReport extends DolibarrModules $this->config_page_url = array('expensereport.php'); // Dependencies - $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled // $this->conflictwith = array("modDeplacement"); // Deactivate for access on old information $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(4,3); // Minimum version of PHP required by module + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,7); // Minimum version of Dolibarr required by module $this->langfiles = array("companies","trips"); diff --git a/htdocs/core/modules/modGeoIPMaxmind.class.php b/htdocs/core/modules/modGeoIPMaxmind.class.php index 88bc8b7e8b9..81eddf86076 100644 --- a/htdocs/core/modules/modGeoIPMaxmind.class.php +++ b/htdocs/core/modules/modGeoIPMaxmind.class.php @@ -65,9 +65,11 @@ class modGeoIPMaxmind extends DolibarrModules $this->config_page_url = array("geoipmaxmind.php"); // Dependencies - $this->depends = array(); - $this->requiredby = array(); - $this->phpmin = array(4,2,0); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); $this->phpmax = array(); $this->need_dolibarr_version = array(2,7,-1); // Minimum version of Dolibarr required by module $this->need_javascript_ajax = 1; diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index b6b9d4c9a59..44b4f8a6e80 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -71,9 +71,11 @@ class modGravatar extends DolibarrModules $this->config_page_url = array(); // Dependencies - $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(4, 3); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5, 4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(2, 7); // Minimum version of Dolibarr required by module $this->langfiles = array(); diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index a209fdccf2e..6b9f81a5a1f 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -66,27 +66,16 @@ class modHRM extends DolibarrModules $this->config_page_url = array('admin_hrm.php@hrm'); // Dependencies - $this->depends = array(); - $this->requiredby = array(/*" - modSalaries, - modExpenseReport, - modHoliday - "*/); - $this->conflictwith = array(); - $this->phpmin = array ( - 5, - 3 - ); // Minimum version of PHP required by module - $this->need_dolibarr_version = array ( - 3, - 9 - ); // Minimum version of Dolibarr required by module - $this->langfiles = array ( - "hrm" - ); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(/*"modSalaries, modExpenseReport, modHoliday"*/); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array (3,9); // Minimum version of Dolibarr required by module + $this->langfiles = array ("hrm"); - // Dictionnaries - $this->dictionnaries=array(); + // Dictionaries + $this->dictionaries=array(); // Constantes $this->const = array (); diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index ffaba49e36e..88ebd6d94e2 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -81,9 +81,11 @@ class modHoliday extends DolibarrModules // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); // Dependencies - $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(4,3); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("holiday"); From 4858f6a07e0823eae0aa341be88a6159b8b874f6 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 9 Jul 2018 14:34:54 +0200 Subject: [PATCH 135/228] Fix : typo --- ChangeLog | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ceb1d847ddb..402bb45423b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ English Dolibarr ChangeLog For Users: NEW: Experimental module: Ticket NEW: Experimental module: WebDAV -NEW: Accept anonmymous events (no user assigned) +NEW: Accept anonymous events (no user assigned) NEW: Accountancy - Add import on general ledger NEW: Accountancy - Show journal name on journal page and hide button draft export (Add an option in admin) NEW: Can create event from record card of a company and member @@ -19,7 +19,7 @@ NEW: Add a tab to specify accountant/auditor of the company NEW: Add Date delivery and Availability on Propals List NEW: Add date in goods reception supplier order table NEW: Add delivery_time_days of suppliers in export profile -NEW: Add Docments'tab to expedition module +NEW: Add Documents'tab to expedition module NEW: Use dol_print_phone in thirdparty list page to format phone NEW: Add entry for the GDPR contact NEW: Add extrafield type "html" @@ -101,7 +101,7 @@ NEW: Filter export model is now by user NEW: Finish implementation of option PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES NEW: generalize use of button to create new element from list NEW: hidden conf AGENDA_NB_WEEKS_IN_VIEW_PER_USER to set nb weeks to show into per user view -NEW: hidden conf to assign category to thirparty that are not customer nor prospect nor supplier +NEW: hidden conf to assign category to thirparty that are neither customer nor prospect or supplier NEW: hidden conf to set nb weeks to show into user view NEW: hidden option MAIN_DISABLE_FREE_LINES NEW: improve way of adding users/sales representative to thirdparty From 699df860d87ad859b3492906422b0fc92396c39e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jul 2018 15:39:59 +0200 Subject: [PATCH 136/228] Code comment --- htdocs/core/class/html.form.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 88377edfad9..0bc53a3066d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1073,10 +1073,10 @@ class Form $out=''; $num=0; $outarray=array(); - + if ($selected === '') $selected = array(); else if (!is_array($selected)) $selected = array($selected); - + // Clean $filter that may contains sql conditions so sql code if (function_exists('test_sql_and_script_inject')) $filter = test_sql_and_script_inject($filter, 3); @@ -1335,7 +1335,7 @@ class Form $langs->load('companies'); if (empty($htmlid)) $htmlid = $htmlname; - + if ($selected === '') $selected = array(); else if (!is_array($selected)) $selected = array($selected); $out=''; @@ -1484,13 +1484,13 @@ class Form function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity='0', $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0, $outputmode=0, $multiple=false) { global $conf,$user,$langs; - + // If no preselected user defined, we take current user if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id; if ($selected === '') $selected = array(); else if (!is_array($selected)) $selected = array($selected); - + $excludeUsers=null; $includeUsers=null; @@ -1568,7 +1568,7 @@ class Form if ($show_every) $out.= ''."\n"; $userstatic=new User($this->db); - + while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -6754,7 +6754,7 @@ class Form if (is_array($include)) $includeGroups = implode("','",$include); if (!is_array($selected)) $selected = array($selected); - + $out=''; // On recherche les groupes From 2ef78bee0b1e8cd16a75cd9cb9801391a00f2c8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jul 2018 16:16:07 +0200 Subject: [PATCH 137/228] Revert "FIX side nav height." This reverts commit 78ba8bc3b59fed3ebcc9ea149a7f92bb8150a256. --- htdocs/theme/eldy/style.css.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index db3ecd946a3..49a980298ae 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1182,7 +1182,6 @@ td.showDragHandle { border-right: 1px solid #d0d0d0; box-shadow: 3px 0 6px -2px #eee; background: rgb(); - height: 100vh; } div.blockvmenulogo { From b4b3e33e3e224ba92d15fda1c35876794226ae67 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 9 Jul 2018 17:22:34 +0200 Subject: [PATCH 138/228] Docs : update and complete comments --- htdocs/core/modules/modImport.class.php | 8 +++++--- htdocs/core/modules/modIncoterm.class.php | 8 +++++--- htdocs/core/modules/modLabel.class.php | 9 ++++++--- htdocs/core/modules/modLdap.class.php | 9 ++++++--- htdocs/core/modules/modLoan.class.php | 8 +++++--- htdocs/core/modules/modMailing.class.php | 7 +++++-- htdocs/core/modules/modMailmanSpip.class.php | 7 +++++-- htdocs/core/modules/modMargin.class.php | 8 +++++--- 8 files changed, 42 insertions(+), 22 deletions(-) diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index 01d66644dc7..ffaac0bf29e 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -60,9 +60,11 @@ class modImport extends DolibarrModules $this->config_page_url = array(); // Dependencies - $this->depends = array(); - $this->requiredby = array(); - $this->phpmin = array(4,3,0); // Need auto_detect_line_endings php option to solve MAC pbs. + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs. $this->phpmax = array(); $this->need_dolibarr_version = array(2,7,-1); // Minimum version of Dolibarr required by module $this->need_javascript_ajax = 1; diff --git a/htdocs/core/modules/modIncoterm.class.php b/htdocs/core/modules/modIncoterm.class.php index 7d4d1251f31..95949eeb05a 100644 --- a/htdocs/core/modules/modIncoterm.class.php +++ b/htdocs/core/modules/modIncoterm.class.php @@ -65,9 +65,11 @@ class modIncoterm extends DolibarrModules $this->config_page_url = array(); // Dependencies - $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(5,0); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("incoterm"); diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index 2d91fd121bb..563dddca3cc 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -56,9 +56,12 @@ class modLabel extends DolibarrModules // Data directories to create when module is enabled $this->dirs = array("/label/temp"); - // Dependancies - $this->depends = array(); - $this->requiredby = array(); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Config pages // $this->config_page_url = array("label.php"); diff --git a/htdocs/core/modules/modLdap.class.php b/htdocs/core/modules/modLdap.class.php index 0f183bd6c76..90577ae3ccf 100644 --- a/htdocs/core/modules/modLdap.class.php +++ b/htdocs/core/modules/modLdap.class.php @@ -60,9 +60,12 @@ class modLdap extends DolibarrModules // Config pages $this->config_page_url = array("ldap.php"); - // Dependancies - $this->depends = array(); - $this->requiredby = array(); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Constants $this->const = array( diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 51779f6ffc5..70386a1647a 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -63,9 +63,11 @@ class modLoan extends DolibarrModules $this->config_page_url = array('loan.php'); // Dependencies - $this->depends = array(); - $this->requiredby = array(); - $this->conflictwith = array(); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("loan"); // Constants diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 46b31a08696..062b9113e76 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -57,8 +57,11 @@ class modMailing extends DolibarrModules $this->dirs = array("/mailing/temp"); // Dependencies - $this->depends = array(); - $this->requiredby = array(); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("mails"); // Config pages diff --git a/htdocs/core/modules/modMailmanSpip.class.php b/htdocs/core/modules/modMailmanSpip.class.php index 9a019db7fea..8403147fd74 100644 --- a/htdocs/core/modules/modMailmanSpip.class.php +++ b/htdocs/core/modules/modMailmanSpip.class.php @@ -58,8 +58,11 @@ class modMailmanSpip extends DolibarrModules $this->dirs = array(); // Dependencies - $this->depends = array('modAdherent'); - $this->requiredby = array(); + $this->hidden = false; // A condition to hide module + $this->depends = array('modAdherent'); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Config pages $this->config_page_url = array('mailman.php'); diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index 53fba120656..4eb9ec7fb65 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -68,9 +68,11 @@ class modMargin extends DolibarrModules $this->config_page_url = array("margin.php@margin"); // Dependencies - $this->depends = array("modPropale", "modProduct"); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(5,1); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array("modPropale", "modProduct"); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,2); // Minimum version of Dolibarr required by module $this->langfiles = array("margins"); From e45e74a3bd125cf4960c1c65b77c0cf97a126199 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 9 Jul 2018 17:38:28 +0200 Subject: [PATCH 139/228] spelling and some grammar corrections to en_US --- htdocs/langs/en_US/accountancy.lang | 18 +-- htdocs/langs/en_US/admin.lang | 166 +++++++++++++------------- htdocs/langs/en_US/banks.lang | 2 +- htdocs/langs/en_US/bills.lang | 22 ++-- htdocs/langs/en_US/blockedlog.lang | 18 +-- htdocs/langs/en_US/boxes.lang | 2 +- htdocs/langs/en_US/cashdesk.lang | 2 +- htdocs/langs/en_US/commercial.lang | 4 +- htdocs/langs/en_US/companies.lang | 32 ++--- htdocs/langs/en_US/compta.lang | 6 +- htdocs/langs/en_US/contracts.lang | 2 +- htdocs/langs/en_US/cron.lang | 12 +- htdocs/langs/en_US/dict.lang | 10 +- htdocs/langs/en_US/errors.lang | 24 ++-- htdocs/langs/en_US/exports.lang | 58 ++++----- htdocs/langs/en_US/holiday.lang | 6 +- htdocs/langs/en_US/hrm.lang | 2 +- htdocs/langs/en_US/mails.lang | 18 +-- htdocs/langs/en_US/main.lang | 4 +- htdocs/langs/en_US/margins.lang | 2 +- htdocs/langs/en_US/members.lang | 2 +- htdocs/langs/en_US/modulebuilder.lang | 20 ++-- htdocs/langs/en_US/multicurrency.lang | 12 +- htdocs/langs/en_US/opensurvey.lang | 2 +- htdocs/langs/en_US/orders.lang | 4 +- htdocs/langs/en_US/other.lang | 10 +- htdocs/langs/en_US/paybox.lang | 4 +- htdocs/langs/en_US/paypal.lang | 16 +-- htdocs/langs/en_US/printing.lang | 6 +- htdocs/langs/en_US/products.lang | 16 +-- htdocs/langs/en_US/propal.lang | 2 +- htdocs/langs/en_US/salaries.lang | 4 +- htdocs/langs/en_US/sms.lang | 36 +++--- htdocs/langs/en_US/stocks.lang | 28 ++--- htdocs/langs/en_US/website.lang | 6 +- htdocs/langs/en_US/withdrawals.lang | 2 +- htdocs/langs/en_US/workflow.lang | 22 ++-- 37 files changed, 302 insertions(+), 300 deletions(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 266b2fae483..bd2afe049e5 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -36,7 +36,7 @@ AlreadyInGeneralLedger=Already journalized in ledgers NotYetInGeneralLedger=Not yet journalized in ledgers GroupIsEmptyCheckSetup=Group is empty, check setup of the personalized accounting group DetailByAccount=Show detail by account -AccountWithNonZeroValues=Accounts with non zero values +AccountWithNonZeroValues=Accounts with non-zero values ListOfAccounts=List of accounts MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup @@ -58,7 +58,7 @@ AccountancyAreaDescVat=STEP %s: Define accounting accounts for each VAT Rates. F AccountancyAreaDescDefault=STEP %s: Define default accounting accounts. For this, use the menu entry %s. AccountancyAreaDescExpenseReport=STEP %s: Define default accounting accounts for each type of expense report. For this, use the menu entry %s. AccountancyAreaDescSal=STEP %s: Define default accounting accounts for payment of salaries. For this, use the menu entry %s. -AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for special expences (miscellaneous taxes). For this, use the menu entry %s. +AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for special expenses (miscellaneous taxes). For this, use the menu entry %s. AccountancyAreaDescDonation=STEP %s: Define default accounting accounts for donation. For this, use the menu entry %s. AccountancyAreaDescMisc=STEP %s: Define mandatory default account and default accounting accounts for miscellaneous transactions. For this, use the menu entry %s. AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. For this, use the menu entry %s. @@ -198,13 +198,13 @@ PaymentsNotLinkedToProduct=Payment not linked to any product / service Pcgtype=Group of account Pcgsubtype=Subgroup of account -PcgtypeDesc=Group and subgroup of account are used as predefined 'filter' and 'grouping' criterias for some accounting reports. For example, 'INCOME' or 'EXPENSE' are used as groups for accounting accounts of products to build the expense/income report. +PcgtypeDesc=Group and subgroup of account are used as predefined 'filter' and 'grouping' criteria for some accounting reports. For example, 'INCOME' or 'EXPENSE' are used as groups for accounting accounts of products to build the expense/income report. TotalVente=Total turnover before tax TotalMarge=Total sales margin DescVentilCustomer=Consult here the list of customer invoice lines bound (or not) to a product accounting account -DescVentilMore=In most cases, if you use predefined products or services and you set the account number on the product/service card, the application will be able to make all the binding between your invoice lines and the accounting account of your chart of accounts, just in one click with the button "%s". If account was not set on product/service cards or if you still has some lines not bound to any account, you will have to make a manual binding from the menu "%s". +DescVentilMore=In most cases, if you use predefined products or services and you set the account number on the product/service card, the application will be able to make all the binding between your invoice lines and the accounting account of your chart of accounts, just in one click with the button "%s". If account was not set on product/service cards or if you still have some lines not bound to any account, you will have to make a manual binding from the menu "%s". DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their product accounting account DescVentilTodoCustomer=Bind invoice lines not already bound with a product accounting account ChangeAccount=Change the product/service accounting account for selected lines with the following accounting account: @@ -213,7 +213,7 @@ DescVentilSupplier=Consult here the list of vendor invoice lines bound or not ye DescVentilDoneSupplier=Consult here the list of the lines of invoices vendors and their accounting account DescVentilTodoExpenseReport=Bind expense report lines not already bound with a fee accounting account DescVentilExpenseReport=Consult here the list of expense report lines bound (or not) to a fee accounting account -DescVentilExpenseReportMore=If you setup accounting account on type of expense report lines, the application will be able to make all the binding between your expense report lines and the accounting account of your chart of accounts, just in one click with the button "%s". If account was not set on fees dictionary or if you still has some lines not bound to any account, you will have to make a manual binding from the menu "%s". +DescVentilExpenseReportMore=If you setup accounting account on type of expense report lines, the application will be able to make all the binding between your expense report lines and the accounting account of your chart of accounts, just in one click with the button "%s". If account was not set on fees dictionary or if you still have some lines not bound to any account, you will have to make a manual binding from the menu "%s". DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account ValidateHistory=Bind Automatically @@ -232,7 +232,7 @@ NotYetAccounted=Not yet accounted in ledger ## Admin ApplyMassCategories=Apply mass categories -AddAccountFromBookKeepingWithNoCategories=Available acccount not yet in a personalized group +AddAccountFromBookKeepingWithNoCategories=Available account not yet in a personalized group CategoryDeleted=Category for the accounting account has been removed AccountingJournals=Accounting journals AccountingJournal=Accounting journal @@ -292,15 +292,15 @@ ErrorNoAccountingCategoryForThisCountry=No accounting account group available fo ErrorInvoiceContainsLinesNotYetBounded=You try to journalize some lines of the invoice %s, but some other lines are not yet bounded to accounting account. Journalization of all invoice lines for this invoice are refused. ErrorInvoiceContainsLinesNotYetBoundedShort=Some lines on invoice are not bound to accounting account. ExportNotSupported=The export format setuped is not supported into this page -BookeppingLineAlreayExists=Lines already existing into bookeeping +BookeppingLineAlreayExists=Lines already existing into bookkeeping NoJournalDefined=No journal defined Binded=Lines bound ToBind=Lines to bind -UseMenuToSetBindindManualy=Autodection not possible, use menu %s to make the binding manually +UseMenuToSetBindindManualy=Autodetection not possible, use menu %s to make the binding manually ## Import ImportAccountingEntries=Accounting entries -WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. If your journalization is up to date, the bookkeeping view is more accurate. +WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manually in the Ledger. If your journalization is up to date, the bookkeeping view is more accurate. ExpenseReportJournal=Expense Report Journal InventoryJournal=Inventory Journal diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 404dc6c2c37..7ec3012eeeb 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -50,7 +50,7 @@ ExternalUser=External user InternalUsers=Internal users ExternalUsers=External users GUISetup=Display -SetupArea=Setup area +SetupArea=Setup UploadNewTemplate=Upload new template(s) FormToTestFileUploadForm=Form to test file upload (according to setup) IfModuleEnabled=Note: yes is effective only if module %s is enabled @@ -68,8 +68,8 @@ ErrorCodeCantContainZero=Code can't contain value 0 DisableJavascript=Disable JavaScript and Ajax functions (Recommended for blind person or text browsers) UseSearchToSelectCompanyTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant COMPANY_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseSearchToSelectContactTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant CONTACT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. -DelaiedFullListToSelectCompany=Wait you press a key before loading content of third-parties combo list (This may increase performance if you have a large number of third-parties, but it is less convenient) -DelaiedFullListToSelectContact=Wait you press a key before loading content of contact combo list (This may increase performance if you have a large number of contacts, but it is less convenient) +DelaiedFullListToSelectCompany=Wait until you press a key before loading content of third-parties combo list (This may increase performance if you have a large number of third-parties, but it is less convenient) +DelaiedFullListToSelectContact=Wait until you press a key before loading content of contact combo list (This may increase performance if you have a large number of contacts, but it is less convenient) NumberOfKeyToSearch=Nbr of characters to trigger search: %s NotAvailableWhenAjaxDisabled=Not available when Ajax disabled AllowToSelectProjectFromOtherCompany=On document of a third party, can choose a project linked to another third party @@ -111,7 +111,7 @@ NotConfigured=Module/Application not configured Active=Active SetupShort=Setup OtherOptions=Other options -OtherSetup=Other setup +OtherSetup=Other Setup CurrentValueSeparatorDecimal=Decimal separator CurrentValueSeparatorThousand=Thousand separator Destination=Destination @@ -191,14 +191,14 @@ IgnoreDuplicateRecords=Ignore errors of duplicate record (INSERT IGNORE) AutoDetectLang=Autodetect (browser language) FeatureDisabledInDemo=Feature disabled in demo FeatureAvailableOnlyOnStable=Feature only available on official stable versions -BoxesDesc=Widgets are components showing some information that you can add to personalize some pages. You can choose between showing the widget or not by selecting target page and clicking 'Activate', or by clicking the dustbin to disable it. +BoxesDesc=Widgets are components showing some information that you can add to personalize some pages. You can choose between showing the widget or not by selecting target page and clicking 'Activate', or by clicking the trashcan to disable it. OnlyActiveElementsAreShown=Only elements from enabled modules are shown. -ModulesDesc=Dolibarr modules define which application/feature is enabled in software. Some application/modules require permissions you must grant to users, after activating it. Click on button on/off to enable a module/application. +ModulesDesc=The modules/applications determine which features are available in the software. Some modules require permissions to be granted to users after activating the module. Click the on/off button to enable/disable a module/application. ModulesMarketPlaceDesc=You can find more modules to download on external websites on the Internet... -ModulesDeployDesc=If permissions on your file system allows it, you can use this tool to deploy an external module. The module will then be visible on the tab %s. +ModulesDeployDesc=If permissions on your file system allow it, you can use this tool to deploy an external module. The module will then be visible on the tab %s. ModulesMarketPlaces=Find external app/modules ModulesDevelopYourModule=Develop your own app/modules -ModulesDevelopDesc=You can develop or find a partner to develop for you, your personalized module +ModulesDevelopDesc=You may also develop your own module or find a partner to develop one for you. DOLISTOREdescriptionLong=Instead of switching on www.dolistore.com web site to find an external module, you can use this embedded tool that will make the seach on the external market place for you (may be slow, need an internet access)... NewModule=New FreeModule=Free @@ -211,8 +211,8 @@ Nouveauté=Novelty AchatTelechargement=Buy / Download GoModuleSetupArea=To deploy/install a new module, go onto the Module setup area at %s. DoliStoreDesc=DoliStore, the official market place for Dolibarr ERP/CRM external modules -DoliPartnersDesc=List of companies providing custom developed modules or features (Note: anyone experienced in PHP programming can provide custom development for an open source project) -WebSiteDesc=Reference websites to find more modules... +DoliPartnersDesc=List of companies providing custom-developed modules or features.
Note: since Dolibarr is an open source application, anyone experienced in PHP programming may develop a module. +WebSiteDesc=External websites for more add-on (non-core) modules... DevelopYourModuleDesc=Some solutions to develop your own module... URL=Link BoxesAvailable=Widgets available @@ -229,7 +229,7 @@ DoNotStoreClearPassword=Do no store clear passwords in database but store only e MainDbPasswordFileConfEncrypted=Database password encrypted in conf.php (Activated recommended) InstrucToEncodePass=To have password encoded into the conf.php file, replace the line
$dolibarr_main_db_pass="...";
by
$dolibarr_main_db_pass="crypted:%s"; InstrucToClearPass=To have password decoded (clear) into the conf.php file, replace the line
$dolibarr_main_db_pass="crypted:...";
by
$dolibarr_main_db_pass="%s"; -ProtectAndEncryptPdfFiles=Protection of generated pdf files (Activated NOT recommended, breaks mass pdf generation) +ProtectAndEncryptPdfFiles=Protection of generated PDF files NOT recommended, breaks mass PDF generation) ProtectAndEncryptPdfFilesDesc=Protection of a PDF document keeps it available to read and print with any PDF browser. However, editing and copying is not possible anymore. Note that using this feature makes building of a global merged PDFs not working. Feature=Feature DolibarrLicense=License @@ -262,27 +262,27 @@ NoticePeriod=Notice period NewByMonth=New by month Emails=Emails EMailsSetup=Emails setup -EMailsDesc=This page allows you to overwrite your PHP parameters for emails sending. In most cases on Unix/Linux OS, your PHP setup is correct and these parameters are useless. +EMailsDesc=This page allows you to override your default PHP parameters for email sending. In most cases on Unix/Linux OS, the PHP setup is correct and these parameters are unnecessary. EmailSenderProfiles=Emails sender profiles -MAIN_MAIL_SMTP_PORT=SMTP/SMTPS Port (By default in php.ini: %s) -MAIN_MAIL_SMTP_SERVER=SMTP/SMTPS Host (By default in php.ini: %s) -MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=SMTP/SMTPS Port (Not defined into PHP on Unix like systems) -MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=SMTP/SMTPS Host (Not defined into PHP on Unix like systems) -MAIN_MAIL_EMAIL_FROM=Sender email for automatic emails (By default in php.ini: %s) +MAIN_MAIL_SMTP_PORT=SMTP/SMTPS Port (default value in php.ini: %s) +MAIN_MAIL_SMTP_SERVER=SMTP/SMTPS Host (default value in php.ini: %s) +MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=SMTP/SMTPS Port (Not defined into PHP on Unix-like systems) +MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=SMTP/SMTPS Host (Not defined into PHP on Unix-like systems) +MAIN_MAIL_EMAIL_FROM=Sender email for automatic emails (default value in php.ini: %s) MAIN_MAIL_ERRORS_TO=Email used for error returns emails (fields 'Errors-To' in emails sent) -MAIN_MAIL_AUTOCOPY_TO= Send systematically a hidden carbon-copy of all sent emails to +MAIN_MAIL_AUTOCOPY_TO= Copy (Bcc) all sent emails to MAIN_DISABLE_ALL_MAILS=Disable all email sending (for test purposes or demos) MAIN_MAIL_FORCE_SENDTO=Send all emails to (instead of real recipients, for test purposes) -MAIN_MAIL_ENABLED_USER_DEST_SELECT=Add employees users with email into allowed recipient list -MAIN_MAIL_SENDMODE=Method to use to send EMails -MAIN_MAIL_SMTPS_ID=SMTP ID if authentication required -MAIN_MAIL_SMTPS_PW=SMTP Password if authentication required -MAIN_MAIL_EMAIL_TLS= Use TLS (SSL) encrypt -MAIN_MAIL_EMAIL_STARTTLS= Use TLS (STARTTLS) encrypt +MAIN_MAIL_ENABLED_USER_DEST_SELECT=Add employee users with email into allowed recipient list +MAIN_MAIL_SENDMODE=Email sending method +MAIN_MAIL_SMTPS_ID=SMTP ID (if sending server requires authentication) +MAIN_MAIL_SMTPS_PW=SMTP Password (if sending server requires authentication) +MAIN_MAIL_EMAIL_TLS= Use TLS (SSL) encryption +MAIN_MAIL_EMAIL_STARTTLS= Use TLS (STARTTLS) encryption MAIN_DISABLE_ALL_SMS=Disable all SMS sending (for test purposes or demos) MAIN_SMS_SENDMODE=Method to use to send SMS MAIN_MAIL_SMS_FROM=Default sender phone number for SMS sending -MAIN_MAIL_DEFAULT_FROMTYPE=Sender email by default for manual sending (User email or Company email) +MAIN_MAIL_DEFAULT_FROMTYPE=Default sender email for manual sending (User email or Company email) UserEmail=User email CompanyEmail=Company email FeatureNotAvailableOnLinux=Feature not available on Unix like systems. Test your sendmail program locally. @@ -311,13 +311,13 @@ ThisIsAlternativeProcessToFollow=This is an alternative setup to process manuall StepNb=Step %s FindPackageFromWebSite=Find a package that provides feature you want (for example on official web site %s). DownloadPackageFromWebSite=Download package (for example from official web site %s). -UnpackPackageInDolibarrRoot=Unpack the packaged files into server directory dedicated to Dolibarr: %s -UnpackPackageInModulesRoot=To deploy/install an external module, unpack the packaged files into the server directory dedicated to modules: %s +UnpackPackageInDolibarrRoot=Unpack/unzip the packaged files into the server directory dedicated to Dolibarr: %s +UnpackPackageInModulesRoot=To deploy/install an external module, unpack/unzip the packaged files into the server directory dedicated to external modules:
%s SetupIsReadyForUse=Module deployment is finished. You must however enable and setup the module in your application by going on the page to setup modules: %s. NotExistsDirect=The alternative root directory is not defined to an existing directory.
InfDirAlt=Since version 3, it is possible to define an alternative root directory. This allows you to store, into a dedicated directory, plug-ins and custom templates.
Just create a directory at the root of Dolibarr (eg: custom).
InfDirExample=
Then declare it in the file conf.php
$dolibarr_main_url_root_alt='/custom'
$dolibarr_main_document_root_alt='/path/of/dolibarr/htdocs/custom'
If these lines are commented with "#", to enable them, just uncomment by removing the "#" character. -YouCanSubmitFile=For this step, you can submit the .zip file of module package here: +YouCanSubmitFile=Alternatively, you may upload the module .zip file package: CurrentVersion=Dolibarr current version CallUpdatePage=Go to the page that updates the database structure and data: %s. LastStableVersion=Latest stable version @@ -352,7 +352,7 @@ ConfirmPurge=Are you sure you want to execute this purge?
This will delete de MinLength=Minimum length LanguageFilesCachedIntoShmopSharedMemory=Files .lang loaded in shared memory LanguageFile=Language file -ExamplesWithCurrentSetup=Examples with current running setup +ExamplesWithCurrentSetup=Examples with current configuration ListOfDirectories=List of OpenDocument templates directories ListOfDirectoriesForModelGenODT=List of directories containing templates files with OpenDocument format.

Put here full path of directories.
Add a carriage return between eah directory.
To add a directory of the GED module, add here DOL_DATA_ROOT/ecm/yourdirectoryname.

Files in those directories must end with .odt or .ods. NumberOfModelFilesFound=Number of ODT/ODS templates files found in those directories @@ -480,7 +480,7 @@ DAV_ALLOW_PUBLIC_DIRTooltip=The WebDav public directory is a WebDAV directory ev # Modules Module0Name=Users & groups Module0Desc=Users / Employees and Groups management -Module1Name=Third parties +Module1Name=Third Parties Module1Desc=Companies and contact management (customers, prospects...) Module2Name=Commercial Module2Desc=Commercial management @@ -530,8 +530,8 @@ Module80Name=Shipments Module80Desc=Shipments and delivery order management Module85Name=Banks and cash Module85Desc=Management of bank or cash accounts -Module100Name=External site -Module100Desc=This module includes an external web site or page into Dolibarr menus and view it into a Dolibarr frame +Module100Name=External Site +Module100Desc=Add external website link into Dolibarr menus to view it in a Dolibarr frame Module105Name=Mailman and SPIP Module105Desc=Mailman or SPIP interface for member module Module200Name=LDAP @@ -541,7 +541,7 @@ Module210Desc=PostNuke integration Module240Name=Data exports Module240Desc=Tool to export Dolibarr data (with assistants) Module250Name=Data imports -Module250Desc=Tool to import data in Dolibarr (with assistants) +Module250Desc=Tool to import data into Dolibarr (with assistants) Module310Name=Members Module310Desc=Foundation members management Module320Name=RSS Feed @@ -555,18 +555,18 @@ Module410Desc=Webcalendar integration Module500Name=Taxes and Special expenses Module500Desc=Management of other expenses (sale taxes, social or fiscal taxes, dividends, ...) Module510Name=Payment of employee wages -Module510Desc=Record and follow payment of your employee wages +Module510Desc=Record and track employee payments Module520Name=Loan Module520Desc=Management of loans Module600Name=Notifications on business events -Module600Desc=Send EMail notifications (triggered by some business events) to users (setup defined on each user), to third-party contacts (setup defined on each third party) or to fixed emails -Module600Long=Note that this module is dedicated to send real time emails when a dedicated business event occurs. If you are looking for a feature to send reminders by email of your agenda events, go into setup of module Agenda. +Module600Desc=Send email notifications triggered by a business event, for users (setup defined on each user), third-party contacts (setup defined on each third party) or to defined emails +Module600Long=Note that this module sends emails in real-time when a specific business event occurs. If you are looking for a feature to send email reminders of agenda events, go into the setup of module Agenda. Module610Name=Product Variants -Module610Desc=Allows creation of products variant based on attributes (color, size, ...) +Module610Desc=Creation of product variants (color, size etc.) Module700Name=Donations Module700Desc=Donation management Module770Name=Expense reports -Module770Desc=Management and claim expense reports (transportation, meal, ...) +Module770Desc=Manage and claim expense reports (transportation, meal, ...) Module1120Name=Vendor commercial proposal Module1120Desc=Request vendor commercial proposal and prices Module1200Name=Mantis @@ -576,13 +576,13 @@ Module1520Desc=Mass mail document generation Module1780Name=Tags/Categories Module1780Desc=Create tags/category (products, customers, vendors, contacts or members) Module2000Name=WYSIWYG editor -Module2000Desc=Allow to edit some text area using an advanced editor (Based on CKEditor) +Module2000Desc=Allow text fields to be edited using CKEditor Module2200Name=Dynamic Prices Module2200Desc=Enable the usage of math expressions for prices Module2300Name=Scheduled jobs Module2300Desc=Scheduled jobs management (alias cron or chrono table) Module2400Name=Events/Agenda -Module2400Desc=Follow done and upcoming events. Let application log automatic events for tracking purposes or record manual events or rendezvous. This is the main important module for a good Customer or Supplier Relationship Management. +Module2400Desc=Track events. Let Dolibarr log automatic events for tracking purposes or record manual events or meetings. This is the main important module for a good Customer or Supplier Relationship Management. Module2500Name=DMS / ECM Module2500Desc=Document Management System / Electronic Content Management. Automatic organization of your generated or stored documents. Share them when you need. Module2600Name=API/Web services (SOAP server) @@ -590,7 +590,7 @@ Module2600Desc=Enable the Dolibarr SOAP server providing API services Module2610Name=API/Web services (REST server) Module2610Desc=Enable the Dolibarr REST server providing API services Module2660Name=Call WebServices (SOAP client) -Module2660Desc=Enable the Dolibarr web services client (Can be used to push data/requests to external servers. Supplier orders supported only for the moment) +Module2660Desc=Enable the Dolibarr web services client (Can be used to push data/requests to external servers. Supplier orders supported only for the moment) Module2700Name=Gravatar Module2700Desc=Use online Gravatar service (www.gravatar.com) to show photo of users/members (found with their emails). Need an internet access Module2800Desc=FTP Client @@ -599,7 +599,7 @@ Module2900Desc=GeoIP Maxmind conversions capabilities Module3100Name=Skype Module3100Desc=Add a Skype button into users / third parties / contacts / members cards Module3200Name=Unalterable Archives -Module3200Desc=Activate log of some business events into an unalterable log. Events are archived in real-time. The log is a table of chained events that can be read only and exported. This module may be mandatory for some countries. +Module3200Desc=Enable an unalterable log of business events. Events are archived in real-time. The log is a read-only table of chained events that can be exported. This module may be mandatory for some countries. Module4000Name=HRM Module4000Desc=Human resources management (management of department, employee contracts and feelings) Module5000Name=Multi-company @@ -609,27 +609,29 @@ Module6000Desc=Workflow management (automatic creation of object and/or automati Module10000Name=Websites Module10000Desc=Create public websites with a WYSIWG editor. Just setup your web server (Apache, Nginx, ...) to point to the dedicated Dolibarr directory to have it online on the Internet with your own domain name. Module20000Name=Leave Requests management -Module20000Desc=Declare and follow employees leaves requests +Module20000Desc=Declare and track employees leave requests Module39000Name=Products lots Module39000Desc=Lot or serial number, eat-by and sell-by date management on products +Module40000Name=Multicurrency +Module40000Desc=Use alternative currencies in prices and documents Module50000Name=PayBox -Module50000Desc=Module to offer an online payment page accepting payments with Credit/Debit card via PayBox. This can be used to allow your customers to make free payments or for a payment on a particular Dolibarr object (invoice, order, ...) +Module50000Desc=Offer customers a PayBox online payment page (credit/debit cards). This can be used to allow your customers to make free payments or for a payment on a particular Dolibarr object (invoice, order, ...) Module50100Name=Point of sales Module50100Desc=Point of sales module (POS). Module50200Name=Paypal -Module50200Desc=Module to offer an online payment page accepting payments using PayPal (credit card or PayPal credit). This can be used to allow your customers to make free payments or for a payment on a particular Dolibarr object (invoice, order, ...) +Module50200Desc=Offer customers a PayPal online payment page (PayPal account or credit/debit cards). This can be used to allow your customers to make free payments or for a payment on a particular Dolibarr object (invoice, order, ...) Module50400Name=Accounting (advanced) Module50400Desc=Accounting management (double entries, support general and auxiliary ledgers). Export the ledger in several other accounting software format. Module54000Name=PrintIPP Module54000Desc=Direct print (without opening the documents) using Cups IPP interface (Printer must be visible from server, and CUPS must be installed on server). Module55000Name=Poll, Survey or Vote -Module55000Desc=Module to make online polls, surveys or votes (like Doodle, Studs, Rdvz, ...) +Module55000Desc=Module to create online polls, surveys or votes (like Doodle, Studs, Rdvz, ...) Module59000Name=Margins Module59000Desc=Module to manage margins Module60000Name=Commissions Module60000Desc=Module to manage commissions -Module62000Name=Incoterm -Module62000Desc=Add features to manage Incoterm +Module62000Name=Incoterms +Module62000Desc=Add features to manage Incoterms Module63000Name=Resources Module63000Desc=Manage resources (printers, cars, room, ...) you can then share into events Permission11=Read customer invoices @@ -908,7 +910,7 @@ DictionarySource=Origin of proposals/orders DictionaryAccountancyCategory=Personalized groups for reports DictionaryAccountancysystem=Models for chart of accounts DictionaryAccountancyJournal=Accounting journals -DictionaryEMailTemplates=Emails templates +DictionaryEMailTemplates=Email Templates DictionaryUnits=Units DictionaryProspectStatus=Prospection status DictionaryHolidayTypes=Types of leaves @@ -921,7 +923,7 @@ BackToModuleList=Back to modules list BackToDictionaryList=Back to dictionaries list TypeOfRevenueStamp=Type of tax stamp VATManagement=VAT Management -VATIsUsedDesc=By default when creating prospects, invoices, orders etc. the VAT rate follows the active standard rule:
If the seller is not subjected to VAT, then VAT defaults to 0. End of rule.
If the (selling country= buying country), then the VAT by default equals the VAT of the product in the selling country. End of rule.
If seller and buyer are both in the European Community and goods are transport products (car, ship, plane), the default VAT is 0 (the VAT should be paid by the buyer to the customs office of his country and not to the seller). End of rule.
If seller and buyer are both in the European Community and the buyer is not a company, then the VAT by defaults to the VAT of the product sold. End of rule.
If seller and buyer are both in the European Community and the buyer is a company, then the VAT is 0 by default . End of rule.
In any other case the proposed default is VAT=0. End of rule. +VATIsUsedDesc=By default when creating prospects, invoices, orders etc. the VAT rate follows the active standard rule:
If the seller is not subject to VAT, then VAT defaults to 0. End of rule.

If the (seller's country = buyer's country), then the VAT by default equals the VAT of the product in the seller's country. End of rule.

If the seller and buyer are both in the European Community and goods are transport-related products (haulage, shipping, airline), the default VAT is 0. This rule is dependant on the seller's country - please consult with your accountant. The VAT should be paid by the buyer to their customs office in their country and not to the seller. End of rule.

If the seller and buyer are both in the European Community and the buyer is not a company (with a registered intra-Community VAT number) then the VAT by defaults to the VAT of the seller's country. End of rule.

If the seller and buyer are both in the European Community and the buyer is a company (with a registered intra-Community VAT number), then the VAT is 0 by default. End of rule.

In any other case the proposed default is VAT=0. End of rule.

VATIsNotUsedDesc=By default the proposed VAT is 0 which can be used for cases like associations, individuals or small companies. VATIsUsedExampleFR=In France, it means companies or organizations having a real fiscal system (Simplified real or normal real). A system in which VAT is declared. VATIsNotUsedExampleFR=In France, it means associations that are non VAT declared or companies, organizations or liberal professions that have chosen the micro enterprise fiscal system (VAT in franchise) and paid a franchise VAT without any VAT declaration. This choice will display the reference "Non applicable VAT - art-293B of CGI" on invoices. @@ -1005,8 +1007,8 @@ PermanentLeftSearchForm=Permanent search form on left menu DefaultLanguage=Default language to use (variant) EnableMultilangInterface=Enable multilingual interface EnableShowLogo=Show logo on left menu -CompanyInfo=Company/organization information -CompanyIds=Company/organization identities +CompanyInfo=Company/Organization +CompanyIds=Company/Organization identities CompanyName=Name CompanyAddress=Address CompanyZip=Zip @@ -1021,28 +1023,28 @@ OwnerOfBankAccount=Owner of bank account %s BankModuleNotActive=Bank accounts module not enabled ShowBugTrackLink=Show link "%s" Alerts=Alerts -DelaysOfToleranceBeforeWarning=Tolerance delays before warning -DelaysOfToleranceDesc=This screen allows you to define the tolerated delays before an alert is reported on screen with picto %s for each late element. -Delays_MAIN_DELAY_ACTIONS_TODO=Delay tolerance (in days) before alert on planned events (agenda events) not completed yet -Delays_MAIN_DELAY_PROJECT_TO_CLOSE=Delay tolerance (in days) before alert on project not closed in time -Delays_MAIN_DELAY_TASKS_TODO=Delay tolerance (in days) before alert on planned tasks (project tasks) not completed yet -Delays_MAIN_DELAY_ORDERS_TO_PROCESS=Delay tolerance (in days) before alert on orders not processed yet -Delays_MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS=Delay tolerance (in days) before alert on purchase orders not processed yet -Delays_MAIN_DELAY_PROPALS_TO_CLOSE=Delay tolerance (in days) before alert on proposals to close -Delays_MAIN_DELAY_PROPALS_TO_BILL=Delay tolerance (in days) before alert on proposals not billed -Delays_MAIN_DELAY_NOT_ACTIVATED_SERVICES=Tolerance delay (in days) before alert on services to activate -Delays_MAIN_DELAY_RUNNING_SERVICES=Tolerance delay (in days) before alert on expired services -Delays_MAIN_DELAY_SUPPLIER_BILLS_TO_PAY=Tolerance delay (in days) before alert on unpaid supplier invoices -Delays_MAIN_DELAY_CUSTOMER_BILLS_UNPAYED=Tolerance delay (in days) before alert on unpaid client invoices -Delays_MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE=Tolerance delay (in days) before alert on pending bank reconciliation -Delays_MAIN_DELAY_MEMBERS=Tolerance delay (in days) before alert on delayed membership fee -Delays_MAIN_DELAY_CHEQUES_TO_DEPOSIT=Tolerance delay (in days) before alert for cheques deposit to do -Delays_MAIN_DELAY_EXPENSEREPORTS=Tolerance delay (in days) before alert for expense reports to approve -SetupDescription1=The setup area is for initial setup parameters before starting to use Dolibarr. -SetupDescription2=The two mandatory setup steps are the following steps (the two first entries in the left setup menu): -SetupDescription3=Settings in menu %s -> %s. This step is required because it defines data used on Dolibarr screens to customize the default behavior of the software (for country-related features for example). -SetupDescription4=Settings in menu %s -> %s. This step is required because Dolibarr ERP/CRM is a collection of several modules/applications, all more or less independent. New features are added to menus for every module you activate. -SetupDescription5=Other menu entries manage optional parameters. +DelaysOfToleranceBeforeWarning=Delays before displaying an alert warning +DelaysOfToleranceDesc=This screen allows you to define the delay before an alert is reported onscreen with a %s icon for each late element. +Delays_MAIN_DELAY_ACTIONS_TODO=Delay (in days) before alert on planned events (agenda events) not completed yet +Delays_MAIN_DELAY_PROJECT_TO_CLOSE=Delay (in days) before alert on project not closed in time +Delays_MAIN_DELAY_TASKS_TODO=Delay (in days) before alert on planned tasks (project tasks) not completed yet +Delays_MAIN_DELAY_ORDERS_TO_PROCESS=Delay (in days) before alert on orders not processed yet +Delays_MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS=Delay (in days) before alert on purchase orders not processed yet +Delays_MAIN_DELAY_PROPALS_TO_CLOSE=Delay (in days) before alert on proposals to close +Delays_MAIN_DELAY_PROPALS_TO_BILL=Delay (in days) before alert on proposals not billed +Delays_MAIN_DELAY_NOT_ACTIVATED_SERVICES=Delay (in days) before alert on services to activate +Delays_MAIN_DELAY_RUNNING_SERVICES=Delay (in days) before alert on expired services +Delays_MAIN_DELAY_SUPPLIER_BILLS_TO_PAY=Delay (in days) before alert on unpaid supplier invoices +Delays_MAIN_DELAY_CUSTOMER_BILLS_UNPAYED=Delay (in days) before alert on unpaid client invoices +Delays_MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE=Delay (in days) before alert on pending bank reconciliation +Delays_MAIN_DELAY_MEMBERS=Delay (in days) before alert on delayed membership fee +Delays_MAIN_DELAY_CHEQUES_TO_DEPOSIT=Delay (in days) before alert for cheque deposit to do +Delays_MAIN_DELAY_EXPENSEREPORTS=Delay (in days) before alert for expense reports to approve +SetupDescription1=Before starting to use Dolibarr some initial parameters must be defined and modules enabled/configured. +SetupDescription2=The following two sections are compulsory (the two first entries in the Setup menu on the left): +SetupDescription3=%s -> %s
Basic parameters used to customize the default behavior of Dolibarr (e.g for country-related features). +SetupDescription4=%s -> %s
Dolibarr ERP/CRM is a collection of many modules/applications, all more or less independent. The modules relevant to your needs must be enabled and configured. New items/options are added to menus with the activation of a module. +SetupDescription5=Other Setup menu entries manage optional parameters. LogEvents=Security audit events Audit=Audit InfoDolibarr=About Dolibarr @@ -1060,8 +1062,8 @@ LogEventDesc=You can enable here the logging for Dolibarr security events. Admin AreaForAdminOnly=Setup parameters can be set by administrator users only. SystemInfoDesc=System information is miscellaneous technical information you get in read only mode and visible for administrators only. SystemAreaForAdminOnly=This area is available for administrator users only. None of the Dolibarr permissions can reduce this limit. -CompanyFundationDesc=Edit on this page all known information of the company or foundation you need to manage (For this, click on "%s" or "%s" button at bottom of page) -AccountantDesc=Edit on this page all known information about your accountant/bookkeeper +CompanyFundationDesc=Edit the information of the company/entity. Click on "%s" or "%s" button at the bottom of the page. +AccountantDesc=Edit the details of your accountant/bookkeeper AccountantFileNumber=File number DisplayDesc=You can choose each parameter related to the Dolibarr look and feel here AvailableModules=Available app/modules @@ -1108,10 +1110,10 @@ YouMustRunCommandFromCommandLineAfterLoginToUser=You must run this command from YourPHPDoesNotHaveSSLSupport=SSL functions not available in your PHP DownloadMoreSkins=More skins to download SimpleNumRefModelDesc=Returns the reference number with format %syymm-nnnn where yy is year, mm is month and nnnn is a sequence without hole and with no reset -ShowProfIdInAddress=Show professionnal id with addresses on documents -ShowVATIntaInAddress=Hide VAT Intra num with addresses on documents +ShowProfIdInAddress=Show professional id with addresses on documents +ShowVATIntaInAddress=Hide intra-Community VAT number with addresses on documents TranslationUncomplete=Partial translation -MAIN_DISABLE_METEO=Disable meteo view +MAIN_DISABLE_METEO=Disable meteorological view MeteoStdMod=Standard mode MeteoStdModEnabled=Standard mode enabled MeteoPercentageMod=Percentage mode @@ -1125,7 +1127,7 @@ MAIN_PROXY_HOST=Name/Address of proxy server MAIN_PROXY_PORT=Port of proxy server MAIN_PROXY_USER=Login to use the proxy server MAIN_PROXY_PASS=Password to use the proxy server -DefineHereComplementaryAttributes=Define here all attributes, not already available by default, and that you want to be supported for %s. +DefineHereComplementaryAttributes=Define here any attributes not already available by default, that you want to be supported for %s. ExtraFields=Complementary attributes ExtraFieldsLines=Complementary attributes (lines) ExtraFieldsLinesRec=Complementary attributes (templates invoices lines) @@ -1163,7 +1165,7 @@ TotalNumberOfActivatedModules=Activated application/modules: %s / %s Edit your entry, otherwise confirm and think about creating a credit note of the excess received for each overpaid invoices. +HelpPaymentHigherThanReminderToPay=Attention, the payment amount of one or more bills is higher than the rest to pay.
Edit your entry, otherwise confirm and think about creating a credit note of the excess received for each overpaid invoice. HelpPaymentHigherThanReminderToPaySupplier=Attention, the payment amount of one or more bills is higher than the rest to pay.
Edit your entry, otherwise confirm and think about creating a credit note of the excess paid for each overpaid invoice. ClassifyPaid=Classify 'Paid' ClassifyPaidPartially=Classify 'Paid partially' @@ -141,7 +141,7 @@ BillShortStatusNotRefunded=Not refunded BillShortStatusClosedUnpaid=Closed BillShortStatusClosedPaidPartially=Paid (partially) PaymentStatusToValidShort=To validate -ErrorVATIntraNotConfigured=Intracommunautary VAT number not yet defined +ErrorVATIntraNotConfigured=Intra-Community VAT number not yet defined ErrorNoPaiementModeConfigured=No default payment mode defined. Go to Invoice module setup to fix this. ErrorCreateBankAccount=Create a bank account, then go to Setup panel of Invoice module to define payment modes ErrorBillNotFound=Invoice %s does not exist @@ -150,7 +150,7 @@ ErrorDiscountAlreadyUsed=Error, discount already used ErrorInvoiceAvoirMustBeNegative=Error, correct invoice must have a negative amount ErrorInvoiceOfThisTypeMustBePositive=Error, this type of invoice must have a positive amount ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice that has been replaced by another invoice that is still in draft status -ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved=This part or another is already used so discount serie cant be removed. +ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved=This part or another is already used so discount series cannot be removed. BillFrom=From BillTo=To ActionsOnBill=Actions on invoice @@ -180,14 +180,14 @@ ConfirmCancelBill=Are you sure you want to cancel invoice %s? ConfirmCancelBillQuestion=Why do you want to classify this invoice 'abandoned'? ConfirmClassifyPaidPartially=Are you sure you want to change invoice %s to status paid? ConfirmClassifyPaidPartiallyQuestion=This invoice has not been paid completely. What are reasons for you to close this invoice? -ConfirmClassifyPaidPartiallyReasonAvoir=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I regularise the VAT with a credit note. +ConfirmClassifyPaidPartiallyReasonAvoir=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I regularize the VAT with a credit note. ConfirmClassifyPaidPartiallyReasonDiscount=Remaining unpaid (%s %s) is a discount granted because payment was made before term. ConfirmClassifyPaidPartiallyReasonDiscountNoVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I accept to lose the VAT on this discount. ConfirmClassifyPaidPartiallyReasonDiscountVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I recover the VAT on this discount without a credit note. ConfirmClassifyPaidPartiallyReasonBadCustomer=Bad customer ConfirmClassifyPaidPartiallyReasonProductReturned=Products partially returned ConfirmClassifyPaidPartiallyReasonOther=Amount abandoned for other reason -ConfirmClassifyPaidPartiallyReasonDiscountNoVatDesc=This choice is possible if your invoice have been provided with suitable comment. (Example «Only the tax corresponding to the price that have been actually paid gives rights to deduction») +ConfirmClassifyPaidPartiallyReasonDiscountNoVatDesc=This choice is possible if your invoice has been provided with suitable comment. (Example «Only the tax corresponding to the price that has been actually paid gives rights to deduction») ConfirmClassifyPaidPartiallyReasonDiscountVatDesc=In some countries, this choice might be possible only if your invoice contains correct note. ConfirmClassifyPaidPartiallyReasonAvoirDesc=Use this choice if all other does not suit ConfirmClassifyPaidPartiallyReasonBadCustomerDesc=A bad customer is a customer that refuse to pay his debt. @@ -304,7 +304,7 @@ SupplierDiscounts=Vendors discounts BillAddress=Bill address HelpEscompte=This discount is a discount granted to customer because its payment was made before term. HelpAbandonBadCustomer=This amount has been abandoned (customer said to be a bad customer) and is considered as an exceptional loose. -HelpAbandonOther=This amount has been abandoned since it was an error (wrong customer or invoice replaced by an other for example) +HelpAbandonOther=This amount has been abandoned since it was an error (wrong customer or invoice replaced by another for example) IdSocialContribution=Social/fiscal tax payment id PaymentId=Payment id PaymentRef=Payment ref. @@ -325,7 +325,7 @@ DescTaxAndDividendsArea=This area presents a summary of all payments made for sp NbOfPayments=Nb of payments SplitDiscount=Split discount in two ConfirmSplitDiscount=Are you sure you want to split this discount of %s %s into 2 lower discounts? -TypeAmountOfEachNewDiscount=Input amount for each of two parts : +TypeAmountOfEachNewDiscount=Input amount for each of two parts: TotalOfTwoDiscountMustEqualsOriginal=Total of two new discount must be equal to original discount amount. ConfirmRemoveDiscount=Are you sure you want to remove this discount? RelatedBill=Related invoice @@ -336,7 +336,7 @@ LatestRelatedBill=Latest related invoice WarningBillExist=Warning, one or more invoice already exist MergingPDFTool=Merging PDF tool AmountPaymentDistributedOnInvoice=Payment amount distributed on invoice -PaymentOnDifferentThirdBills=Allow payments on different thirdparties bills but same parent company +PaymentOnDifferentThirdBills=Allow payments on different third parties bills but same parent company PaymentNote=Payment note ListOfPreviousSituationInvoices=List of previous situation invoices ListOfNextSituationInvoices=List of next situation invoices @@ -415,11 +415,11 @@ PaymentTypeFAC=Factor PaymentTypeShortFAC=Factor BankDetails=Bank details BankCode=Bank code -DeskCode=Desk code +DeskCode=Office code BankAccountNumber=Account number -BankAccountNumberKey=Key +BankAccountNumberKey=Check digits Residence=Direct debit -IBANNumber=IBAN number +IBANNumber=IBAN complete account number IBAN=IBAN BIC=BIC/SWIFT BICNumber=BIC/SWIFT number diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 9f6a49a5146..d2acd9873cb 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -2,13 +2,13 @@ BlockedLog=Unalterable Logs Field=Field BlockedLogDesc=This module tracks some events into an unalterable log (that you can't modify once recorded) into a block chain, in real time. This module provides compatibility with requirements of laws of some countries (like France with the law Finance 2016 - Norme NF535). Fingerprints=Archived events and fingerprints -FingerprintsDesc=This is the tool to browse or extract the unalterable logs. Unalterable logs are generated and archived locally into a dedicated table, in real time when you record a business event. You can use this tool to export this archive and save it into an external support (some countries, like France, ask you do it every year). Note that, there is no feature to purge this log and every change tried to be done directly into this log (by a hacker for example) will be reported with a non valid fingerprint. If you really need to purge this table because you used your application for a demo/test purpose and want to clean your data to start your production, you can ask your reseller or integrator to reset your database (all your data will be removed). +FingerprintsDesc=This is the tool to browse or extract the unalterable logs. Unalterable logs are generated and archived locally into a dedicated table, in real time when you record a business event. You can use this tool to export this archive and save it into an external support (some countries, like France, ask that you do it every year). Note that, there is no feature to purge this log and every change tried to be done directly into this log (by a hacker for example) will be reported with a non-valid fingerprint. If you really need to purge this table because you used your application for a demo/test purpose and want to clean your data to start your production, you can ask your reseller or integrator to reset your database (all your data will be removed). CompanyInitialKey=Company initial key (hash of genesis block) BrowseBlockedLog=Unalterable logs ShowAllFingerPrintsMightBeTooLong=Show all archived logs (might be long) -ShowAllFingerPrintsErrorsMightBeTooLong=Show all non valid archive logs (might be long) +ShowAllFingerPrintsErrorsMightBeTooLong=Show all non-valid archive logs (might be long) DownloadBlockChain=Download fingerprints -KoCheckFingerprintValidity=Archived log is not valid. It means someone (a hacker ?) has modified some datas of this archived log after it was recorded, or has erased the previous archived record (check that line with previous # exists). +KoCheckFingerprintValidity=Archived log is not valid. It means someone (a hacker?) has modified some datas of this archived log after it was recorded, or has erased the previous archived record (check that line with previous # exists). OkCheckFingerprintValidity=Archived log is valid. It means all data on this line were not modified and record follow the previous one. OkCheckFingerprintValidityButChainIsKo=Archived log seems valid compared to previous one but the chain was corrupted previously. AddedByAuthority=Stored into remote authority @@ -23,7 +23,7 @@ logPAYMENT_CUSTOMER_DELETE=Customer payment logical deletion logDONATION_PAYMENT_CREATE=Donation payment created logDONATION_PAYMENT_DELETE=Donation payment logical deletion logBILL_PAYED=Customer invoice payed -logBILL_UNPAYED=Customer invoice set unpayed +logBILL_UNPAYED=Customer invoice set unpaid logBILL_VALIDATE=Customer invoice validated logBILL_SENTBYMAIL=Customer invoice send by mail logBILL_DELETE=Customer invoice logically deleted @@ -32,9 +32,9 @@ logMODULE_SET=Module BlockedLog was enabled logDON_VALIDATE=Donation validated logDON_MODIFY=Donation modified logDON_DELETE=Donation logical deletion -logMEMBER_SUBSCRIPTION_CREATE=Member subcription created -logMEMBER_SUBSCRIPTION_MODIFY=Member subcription modified -logMEMBER_SUBSCRIPTION_DELETE=Member subcription logical deletion +logMEMBER_SUBSCRIPTION_CREATE=Member subscription created +logMEMBER_SUBSCRIPTION_MODIFY=Member subscription modified +logMEMBER_SUBSCRIPTION_DELETE=Member subscription logical deletion BlockedLogBillDownload=Customer invoice download BlockedLogBillPreview=Customer invoice preview BlockedlogInfoDialog=Log Details @@ -46,8 +46,8 @@ logDOC_DOWNLOAD=Download of a validated document in order to print or send DataOfArchivedEvent=Full datas of archived event ImpossibleToReloadObject=Original object (type %s, id %s) not linked (see 'Full datas' column to get unalterable saved data) BlockedLogAreRequiredByYourCountryLegislation=Unalterable Logs module may be required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of legal software as they can not be validated by a tax audit. -BlockedLogActivatedBecauseRequiredByYourCountryLegislation=Unalterable Logs module was activated because of the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of legal software as they can not be validated by a tax audit. +BlockedLogActivatedBecauseRequiredByYourCountryLegislation=Unalterable Logs module was activated because of the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of legal software as they cannot be validated by a tax audit. BlockedLogDisableNotAllowedForCountry=List of countries where usage of this module is mandatory (just to prevent to disable the module by error, if your country is in this list, disable of module is not possible without editing this list first. Note also that enabling/disabling this module will keep a track into the unalterable log). -OnlyNonValid=Non valid +OnlyNonValid=Non-valid TooManyRecordToScanRestrictFilters=Too many record to scan/analyze. Please restrict list with more restrictive filters. RestrictYearToExport=Restrict year to export \ No newline at end of file diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index f5e1ee8f366..8b3b309dc19 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -45,7 +45,7 @@ BoxTitleLastModifiedExpenses=Latest %s modified expense reports BoxGlobalActivity=Global activity (invoices, proposals, orders) BoxGoodCustomers=Good customers BoxTitleGoodCustomers=%s Good customers -FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Latest successfull refresh date: %s +FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Latest successful refresh date: %s LastRefreshDate=Latest refresh date NoRecordedBookmarks=No bookmarks defined. ClickToAdd=Click here to add. diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 1f51f375e89..e5cf5beaf88 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -30,5 +30,5 @@ ShowCompany=Show company ShowStock=Show warehouse DeleteArticle=Click to remove this article FilterRefOrLabelOrBC=Search (Ref/Label) -UserNeedPermissionToEditStockToUsePos=You ask to decrease stock on invoice creation, so user that use POS need to have permission to edit stock. +UserNeedPermissionToEditStockToUsePos=You ask to decrease stock on invoice creation, so user that uses POS needs to have permission to edit stock. DolibarrReceiptPrinter=Dolibarr Receipt Printer diff --git a/htdocs/langs/en_US/commercial.lang b/htdocs/langs/en_US/commercial.lang index 9f2e16857de..97b8c68fd9b 100644 --- a/htdocs/langs/en_US/commercial.lang +++ b/htdocs/langs/en_US/commercial.lang @@ -72,8 +72,8 @@ StatusProsp=Prospect status DraftPropals=Draft commercial proposals NoLimit=No limit ToOfferALinkForOnlineSignature=Link for online signature -WelcomeOnOnlineSignaturePage=Welcome on the page to accept commerical proposals from %s +WelcomeOnOnlineSignaturePage=Welcome on the page to accept commercial proposals from %s ThisScreenAllowsYouToSignDocFrom=This screen allow you to accept and sign, or refuse, a quote/commercial proposal ThisIsInformationOnDocumentToSign=This is information on document to accept or refuse -SignatureProposalRef=Signature of quote/commerical proposal %s +SignatureProposalRef=Signature of quote/commercial proposal %s FeatureOnlineSignDisabled=Feature for online signing disabled or document generated before the feature was enabled \ No newline at end of file diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index b3e1e7b6c86..87412f5f350 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -27,11 +27,11 @@ CompanyName=Company name AliasNames=Alias name (commercial, trademark, ...) AliasNameShort=Alias name Companies=Companies -CountryIsInEEC=Country is inside European Economic Community +CountryIsInEEC=Country is inside the European Economic Community ThirdPartyName=Third party name ThirdPartyEmail=Third party email ThirdParty=Third party -ThirdParties=Third parties +ThirdParties=Third Parties ThirdPartyProspects=Prospects ThirdPartyProspectsStats=Prospects ThirdPartyCustomers=Customers @@ -40,7 +40,7 @@ ThirdPartyCustomersWithIdProf12=Customers with %s or %s ThirdPartySuppliers=Vendors ThirdPartyType=Third party type Individual=Private individual -ToCreateContactWithSameName=Will create automatically a contact/address with same information than third party under the third party. In most cases, even if your third party is a physical people, creating a third party alone is enough. +ToCreateContactWithSameName=Will create automatically a contact/address with same information as the third party under the third party. In most cases, even if your third party is a physical person, creating a third party alone is enough. ParentCompany=Parent company Subsidiaries=Subsidiaries ReportByMonth=Report by month @@ -77,10 +77,10 @@ Web=Web Poste= Position DefaultLang=Language by default VATIsUsed=Sales tax is used -VATIsUsedWhenSelling=This define if this third party includes a sale tax or not when it makes an invoice to its own customers +VATIsUsedWhenSelling=This defines if this third party includes a sale tax or not when it makes an invoice to its own customers VATIsNotUsed=Sales tax is not used CopyAddressFromSoc=Fill address with third party address -ThirdpartyNotCustomerNotSupplierSoNoRef=Third party neither customer nor vendor, no available refering objects +ThirdpartyNotCustomerNotSupplierSoNoRef=Third party neither customer nor vendor, no available referring objects ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts=Third party neither customer nor supplier, discounts are not available PaymentBankAccount=Payment bank account OverAllProposals=Proposals @@ -258,7 +258,7 @@ ProfId1DZ=RC ProfId2DZ=Art. ProfId3DZ=NIF ProfId4DZ=NIS -VATIntra=Sales tax ID +VATIntra=Sales Tax/VAT ID VATIntraShort=Tax ID VATIntraSyntaxIsValid=Syntax is valid VATReturn=VAT return @@ -311,12 +311,12 @@ CustomerCodeDesc=Customer code, unique for all customers SupplierCodeDesc=Vendor code, unique for all vendors RequiredIfCustomer=Required if third party is a customer or prospect RequiredIfSupplier=Required if third party is a vendor -ValidityControledByModule=Validity controled by module +ValidityControledByModule=Validity controlled by module ThisIsModuleRules=This is rules for this module ProspectToContact=Prospect to contact CompanyDeleted=Company "%s" deleted from database. ListOfContacts=List of contacts/addresses -ListOfContactsAddresses=List of contacts/adresses +ListOfContactsAddresses=List of contacts/addresses ListOfThirdParties=List of third parties ShowCompany=Show third party ShowContact=Show contact @@ -340,13 +340,13 @@ CapitalOf=Capital of %s EditCompany=Edit company ThisUserIsNot=This user is not a prospect, customer nor vendor VATIntraCheck=Check -VATIntraCheckDesc=The link %s allows to ask the european VAT checker service. An external internet access from server is required for this service to work. +VATIntraCheckDesc=The link %s uses the European VAT checker service (VIES). An external internet access from server is required for this service to work. VATIntraCheckURL=http://ec.europa.eu/taxation_customs/vies/vieshome.do -VATIntraCheckableOnEUSite=Check Intracomunnautary VAT on European commision site -VATIntraManualCheck=You can also check manually from european web site %s +VATIntraCheckableOnEUSite=Check intra-Community VAT on the European Commission website +VATIntraManualCheck=You can also check manually on the European Commission website %s ErrorVATCheckMS_UNAVAILABLE=Check not possible. Check service is not provided by the member state (%s). NorProspectNorCustomer=Nor prospect, nor customer -JuridicalStatus=Legal form +JuridicalStatus=Legal Entity Type Staff=Staff ProspectLevelShort=Potential ProspectLevel=Prospect potential @@ -402,9 +402,9 @@ DeleteFile=Delete file ConfirmDeleteFile=Are you sure you want to delete this file? AllocateCommercial=Assigned to sales representative Organization=Organization -FiscalYearInformation=Information on the fiscal year +FiscalYearInformation=Fiscal Year FiscalMonthStart=Starting month of the fiscal year -YouMustAssignUserMailFirst=You must create email for this user first to be able to add emails notifications for him. +YouMustAssignUserMailFirst=You must create an email for this user prior to being able to add an email notification. YouMustCreateContactFirst=To be able to add email notifications, you must first define contacts with valid emails for the third party ListSuppliersShort=List of vendors ListProspectsShort=List of prospects @@ -420,12 +420,12 @@ CurrentOutstandingBill=Current outstanding bill OutstandingBill=Max. for outstanding bill OutstandingBillReached=Max. for outstanding bill reached OrderMinAmount=Minimum amount for order -MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for vendor code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0. +MonkeyNumRefModelDesc=Return a number with the format %syymm-nnnn for the customer code and %syymm-nnnn for the vendor code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0. LeopardNumRefModelDesc=The code is free. This code can be modified at any time. ManagingDirectors=Manager(s) name (CEO, director, president...) MergeOriginThirdparty=Duplicate third party (third party you want to delete) MergeThirdparties=Merge third parties -ConfirmMergeThirdparties=Are you sure you want to merge this third party into the current one? All linked objects (invoices, orders, ...) will be moved to current third party, then the thirdparty will be deleted. +ConfirmMergeThirdparties=Are you sure you want to merge this third party into the current one? All linked objects (invoices, orders, ...) will be moved to current third party, then the third party will be deleted. ThirdpartiesMergeSuccess=Third parties have been merged SaleRepresentativeLogin=Login of sales representative SaleRepresentativeFirstname=First name of sales representative diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 1b1748f90a1..81c8aadf7c8 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -229,9 +229,9 @@ ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for VAT on sales (used ACCOUNTING_VAT_BUY_ACCOUNT=Accounting account by default for VAT on purchases (used if not defined on VAT dictionary setup) ACCOUNTING_VAT_PAY_ACCOUNT=Accounting account by default for paying VAT ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account used for customer third parties -ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated customer accouting account on third party is not defined. +ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated customer accounting account on third party is not defined. ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for vendor third parties -ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined. +ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated supplier accounting account on third party is not defined. CloneTax=Clone a social/fiscal tax ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment CloneTaxForNextMonth=Clone it for next month @@ -248,7 +248,7 @@ ErrorBankAccountNotFound=Error: Bank account not found FiscalPeriod=Accounting period ListSocialContributionAssociatedProject=List of social contributions associated with the project DeleteFromCat=Remove from accounting group -AccountingAffectation=Accounting assignement +AccountingAffectation=Accounting assignment LastDayTaxIsRelatedTo=Last day of period the tax is related to VATDue=Sale tax claimed ClaimedForThisPeriod=Claimed for the period diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index 3768cfb9ff1..017e02d855e 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -67,7 +67,7 @@ CloseService=Close service BoardRunningServices=Expired running services ServiceStatus=Status of service DraftContracts=Drafts contracts -CloseRefusedBecauseOneServiceActive=Contract can't be closed as ther is at least one open service on it +CloseRefusedBecauseOneServiceActive=Contract can't be closed as there is at least one open service on it ActivateAllContracts=Activate all contract lines CloseAllContracts=Close all contract lines DeleteContractLine=Delete a contract line diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 243d089a2b1..43fe8aecc36 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -12,7 +12,7 @@ OrToLaunchASpecificJob=Or to check and launch a specific job KeyForCronAccess=Security key for URL to launch cron jobs FileToLaunchCronJobs=Command line to check and launch qualified cron jobs CronExplainHowToRunUnix=On Unix environment you should use the following crontab entry to run the command line each 5 minutes -CronExplainHowToRunWin=On Microsoft(tm) Windows environement you can use Scheduled task tools to run the command line each 5 minutes +CronExplainHowToRunWin=On Microsoft(tm) Windows environment you can use Scheduled Task tools to run the command line each 5 minutes CronMethodDoesNotExists=Class %s does not contains any method %s CronJobDefDesc=Cron job profiles are defined into the module descriptor file. When module is activated, they are loaded and available so you can administer the jobs from the admin tools menu %s. CronJobProfiles=List of predefined cron job profiles @@ -61,11 +61,11 @@ CronStatusInactiveBtn=Disable CronTaskInactive=This job is disabled CronId=Id CronClassFile=Filename with class -CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module).
For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for module is
product -CronClassFileHelp=The relative path and file name to load (path is relative to web server root directory).
For exemple to call the fetch method of Dolibarr Product object htdocs/product/class/product.class.php, the value for class file name is
product/class/product.class.php -CronObjectHelp=The object name to load.
For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for class file name is
Product -CronMethodHelp=The object method to launch.
For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for method is
fetch -CronArgsHelp=The method arguments.
For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for paramters can be
0, ProductRef +CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module).
For example to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for module is
product +CronClassFileHelp=The relative path and file name to load (path is relative to web server root directory).
For example to call the fetch method of Dolibarr Product object htdocs/product/class/product.class.php, the value for class file name is
product/class/product.class.php +CronObjectHelp=The object name to load.
For example to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for class file name is
Product +CronMethodHelp=The object method to launch.
For example to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for method is
fetch +CronArgsHelp=The method arguments.
For example to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for paramters can be
0, ProductRef CronCommandHelp=The system command line to execute. CronCreateJob=Create new Scheduled Job CronFrom=From diff --git a/htdocs/langs/en_US/dict.lang b/htdocs/langs/en_US/dict.lang index 81f62469896..9a8ee71106b 100644 --- a/htdocs/langs/en_US/dict.lang +++ b/htdocs/langs/en_US/dict.lang @@ -116,7 +116,7 @@ CountryHM=Heard Island and McDonald CountryVA=Holy See (Vatican City State) CountryHN=Honduras CountryHK=Hong Kong -CountryIS=Icelande +CountryIS=Iceland CountryIN=India CountryID=Indonesia CountryIR=Iran @@ -131,7 +131,7 @@ CountryKI=Kiribati CountryKP=North Korea CountryKR=South Korea CountryKW=Kuwait -CountryKG=Kyrghyztan +CountryKG=Kyrgyzstan CountryLA=Lao CountryLV=Latvia CountryLB=Lebanon @@ -160,7 +160,7 @@ CountryMD=Moldova CountryMN=Mongolia CountryMS=Monserrat CountryMZ=Mozambique -CountryMM=Birmania (Myanmar) +CountryMM=Myanmar (Burma) CountryNA=Namibia CountryNR=Nauru CountryNP=Nepal @@ -223,7 +223,7 @@ CountryTO=Tonga CountryTT=Trinidad and Tobago CountryTR=Turkey CountryTM=Turkmenistan -CountryTC=Turks and Cailos Islands +CountryTC=Turks and Caicos Islands CountryTV=Tuvalu CountryUG=Uganda CountryUA=Ukraine @@ -277,7 +277,7 @@ CurrencySingMGA=Ariary CurrencyMUR=Mauritius rupees CurrencySingMUR=Mauritius rupee CurrencyNOK=Norwegian krones -CurrencySingNOK=Norwegian krone +CurrencySingNOK=Norwegian kronas CurrencyTND=Tunisian dinars CurrencySingTND=Tunisian dinar CurrencyUSD=US Dollars diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 646414c2fc5..37d9980c806 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -42,7 +42,7 @@ ErrorBadDateFormat=Value '%s' has wrong date format ErrorWrongDate=Date is not correct! ErrorFailedToWriteInDir=Failed to write in directory %s ErrorFoundBadEmailInFile=Found incorrect email syntax for %s lines in file (example line %s with email=%s) -ErrorUserCannotBeDelete=User cannot be deleted. May be it is associated to Dolibarr entities. +ErrorUserCannotBeDelete=User cannot be deleted. Maybe it is associated to Dolibarr entities. ErrorFieldsRequired=Some required fields were not filled. ErrorSubjectIsRequired=The email topic is required ErrorFailedToCreateDir=Failed to create a directory. Check that Web server user has permissions to write into Dolibarr documents directory. If parameter safe_mode is enabled on this PHP, check that Dolibarr php files owns to web server user (or group). @@ -71,15 +71,15 @@ ErrorNoAccountancyModuleLoaded=No accountancy module activated ErrorExportDuplicateProfil=This profile name already exists for this export set. ErrorLDAPSetupNotComplete=Dolibarr-LDAP matching is not complete. ErrorLDAPMakeManualTest=A .ldif file has been generated in directory %s. Try to load it manually from command line to have more information on errors. -ErrorCantSaveADoneUserWithZeroPercentage=Can't save an action with "statut not started" if field "done by" is also filled. +ErrorCantSaveADoneUserWithZeroPercentage=Can't save an action with "status not started" if field "done by" is also filled. ErrorRefAlreadyExists=Ref used for creation already exists. ErrorPleaseTypeBankTransactionReportName=Please enter the bank statement name where the entry has to be reported (Format YYYYMM or YYYYMMDD) -ErrorRecordHasChildren=Failed to delete record since it has some childs. +ErrorRecordHasChildren=Failed to delete record since it has some child records. ErrorRecordHasAtLeastOneChildOfType=Object has at least one child of type %s -ErrorRecordIsUsedCantDelete=Can't delete record. It is already used or included into other object. +ErrorRecordIsUsedCantDelete=Can't delete record. It is already used or included into another object. ErrorModuleRequireJavascript=Javascript must not be disabled to have this feature working. To enable/disable Javascript, go to menu Home->Setup->Display. ErrorPasswordsMustMatch=Both typed passwords must match each other -ErrorContactEMail=A technical error occured. Please, contact administrator to following email %s en provide the error code %s in your message, or even better by adding a screen copy of this page. +ErrorContactEMail=A technical error occured. Please, contact administrator to following email %s and provide the error code %s in your message, or add a screen copy of this page. ErrorWrongValueForField=Wrong value for field number %s (value '%s' does not match regex rule %s) ErrorFieldValueNotIn=Wrong value for field number %s (value '%s' is not a value available into field %s of table %s) ErrorFieldRefNotIn=Wrong value for field number %s (value '%s' is not a %s existing ref) @@ -95,7 +95,7 @@ ErrorBadMaskBadRazMonth=Error, bad reset value ErrorMaxNumberReachForThisMask=Max number reach for this mask ErrorCounterMustHaveMoreThan3Digits=Counter must have more than 3 digits ErrorSelectAtLeastOne=Error. Select at least one entry. -ErrorDeleteNotPossibleLineIsConsolidated=Delete not possible because record is linked to a bank transation that is conciliated +ErrorDeleteNotPossibleLineIsConsolidated=Delete not possible because record is linked to a bank transaction that is conciliated ErrorProdIdAlreadyExist=%s is assigned to another third ErrorFailedToSendPassword=Failed to send password ErrorFailedToLoadRSSFile=Fails to get RSS feed. Try to add constant MAIN_SIMPLEXMLLOAD_DEBUG if error messages does not provide enough information. @@ -147,7 +147,7 @@ ErrorPriceExpression5=Unexpected '%s' ErrorPriceExpression6=Wrong number of arguments (%s given, %s expected) ErrorPriceExpression8=Unexpected operator '%s' ErrorPriceExpression9=An unexpected error occured -ErrorPriceExpression10=Iperator '%s' lacks operand +ErrorPriceExpression10=Operator '%s' lacks operand ErrorPriceExpression11=Expecting '%s' ErrorPriceExpression14=Division by zero ErrorPriceExpression17=Undefined variable '%s' @@ -174,7 +174,7 @@ ErrorMandatoryParametersNotProvided=Mandatory parameter(s) not provided ErrorOppStatusRequiredIfAmount=You set an estimated amount for this opportunity/lead. So you must also enter its status ErrorFailedToLoadModuleDescriptorForXXX=Failed to load module descriptor class for %s ErrorBadDefinitionOfMenuArrayInModuleDescriptor=Bad Definition Of Menu Array In Module Descriptor (bad value for key fk_menu) -ErrorSavingChanges=An error has ocurred when saving the changes +ErrorSavingChanges=An error has occurred when saving the changes ErrorWarehouseRequiredIntoShipmentLine=Warehouse is required on the line to ship ErrorFileMustHaveFormat=File must have format %s ErrorSupplierCountryIsNotDefined=Country for this vendor is not defined. Correct this first. @@ -201,7 +201,7 @@ ErrorTooManyErrorsProcessStopped=Too many errors. Process was stopped. ErrorMassValidationNotAllowedWhenStockIncreaseOnAction=Mass validation is not possible when option to increase/decrease stock is set on this action (you must validate one by one so you can define the warehouse to increase/decrease) ErrorObjectMustHaveStatusDraftToBeValidated=Object %s must have status 'Draft' to be validated. ErrorObjectMustHaveLinesToBeValidated=Object %s must have lines to be validated. -ErrorOnlyInvoiceValidatedCanBeSentInMassAction=Only validated invoices can be sent using the "Send by email" mass action. +ErrorOnlyInvoiceValidatedCanBeSentInMassAction=Only validated invoices can be sent using the "Send by email" mass action. ErrorChooseBetweenFreeEntryOrPredefinedProduct=You must choose if article is a predefined product or not ErrorDiscountLargerThanRemainToPaySplitItBefore=The discount you try to apply is larger than remain to pay. Split the discount in 2 smaller discounts before. ErrorFileNotFoundWithSharedLink=File was not found. May be the share key was modified or file was removed recently. @@ -217,9 +217,9 @@ WarningBookmarkAlreadyExists=A bookmark with this title or this target (URL) alr WarningPassIsEmpty=Warning, database password is empty. This is a security hole. You should add a password to your database and change your conf.php file to reflect this. WarningConfFileMustBeReadOnly=Warning, your config file (htdocs/conf/conf.php) can be overwritten by the web server. This is a serious security hole. Modify permissions on file to be in read only mode for operating system user used by Web server. If you use Windows and FAT format for your disk, you must know that this file system does not allow to add permissions on file, so can't be completely safe. WarningsOnXLines=Warnings on %s source record(s) -WarningNoDocumentModelActivated=No model, for document generation, has been activated. A model will be choosed by default until you check your module setup. +WarningNoDocumentModelActivated=No model, for document generation, has been activated. A model will be chosen by default until you check your module setup. WarningLockFileDoesNotExists=Warning, once setup is finished, you must disable install/migrate tools by adding a file install.lock into directory %s. Missing this file is a security hole. -WarningUntilDirRemoved=All security warnings (visible by admin users only) will remain active as long as the vulnerability is present (or that constant MAIN_REMOVE_INSTALL_WARNING is added in Setup->Other setup). +WarningUntilDirRemoved=All security warnings (visible by admin users only) will remain active as long as the vulnerability is present (or that constant MAIN_REMOVE_INSTALL_WARNING is added in Setup->Other Setup). WarningCloseAlways=Warning, closing is done even if amount differs between source and target elements. Enable this feature with caution. WarningUsingThisBoxSlowDown=Warning, using this box slow down seriously all pages showing the box. WarningClickToDialUserSetupNotComplete=Setup of ClickToDial information for your user are not complete (see tab ClickToDial onto your user card). @@ -229,5 +229,5 @@ WarningTooManyDataPleaseUseMoreFilters=Too many data (more than %s lines). Pleas WarningSomeLinesWithNullHourlyRate=Some times were recorded by some users while their hourly rate was not defined. A value of 0 %s per hour was used but this may result in wrong valuation of time spent. WarningYourLoginWasModifiedPleaseLogin=Your login was modified. For security purpose you will have to login with your new login before next action. WarningAnEntryAlreadyExistForTransKey=An entry already exists for the translation key for this language -WarningNumberOfRecipientIsRestrictedInMassAction=Warning, number of different recipient is limited to %s when using the bulk actions on lists +WarningNumberOfRecipientIsRestrictedInMassAction=Warning, number of different recipient is limited to %s when using the mass actions on lists WarningDateOfLineMustBeInExpenseReportRange=Warning, the date of line is not in the range of the expense report \ No newline at end of file diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 4a1152e6581..0642b64dd7f 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -7,33 +7,33 @@ ExportableDatas=Exportable dataset ImportableDatas=Importable dataset SelectExportDataSet=Choose dataset you want to export... SelectImportDataSet=Choose dataset you want to import... -SelectExportFields=Choose fields you want to export, or select a predefined export profile -SelectImportFields=Choose source file fields you want to import and their target field in database by moving them up and down with anchor %s, or select a predefined import profile: +SelectExportFields=Choose the fields you want to export, or select a predefined export profile +SelectImportFields=Choose the source file fields you want to import and their target field in database by moving them up and down with anchor %s, or select a predefined import profile: NotImportedFields=Fields of source file not imported -SaveExportModel=Save this export profile if you plan to reuse it later... -SaveImportModel=Save this import profile if you plan to reuse it later... +SaveExportModel=Save this export profile (for reuse) ... +SaveImportModel=Save this import profile (for reuse) ... ExportModelName=Export profile name -ExportModelSaved=Export profile saved under name %s. +ExportModelSaved=Export profile saved as %s. ExportableFields=Exportable fields ExportedFields=Exported fields ImportModelName=Import profile name -ImportModelSaved=Import profile saved under name %s. +ImportModelSaved=Import profile saved as %s. DatasetToExport=Dataset to export DatasetToImport=Import file into dataset ChooseFieldsOrdersAndTitle=Choose fields order... FieldsTitle=Fields title FieldTitle=Field title -NowClickToGenerateToBuildExportFile=Now, select file format in combo box and click on "Generate" to build export file... +NowClickToGenerateToBuildExportFile=Now, select the file format in the combo box and click on "Generate" to build the export file... AvailableFormats=Available formats LibraryShort=Library Step=Step FormatedImport=Import assistant -FormatedImportDesc1=This area allows to import personalized data, using an assistant to help you in process without technical knowledge. -FormatedImportDesc2=First step is to choose a king of data you want to load, then file to load, then to choose which fields you want to load. +FormatedImportDesc1=This area allows the import of personalized data using an assistant, to help you in the process without technical knowledge. +FormatedImportDesc2=First step is to choose the kind of data you want to import, then the format of the source file, then the fields you want to import. FormatedExport=Export assistant -FormatedExportDesc1=This area allows to export personalized data, using an assistant to help you in process without technical knowledge. -FormatedExportDesc2=First step is to choose a predefined dataset, then to choose which fields you want in your result files, and which order. -FormatedExportDesc3=When data to export are selected, you can define output file format you want to export your data to. +FormatedExportDesc1=These tools allow the export of personalized data using an assistant, to help you in the process without requiring technical knowledge. +FormatedExportDesc2=First step is to choose a predefined dataset, then which fields you want to export, and in which order. +FormatedExportDesc3=When data to export are selected, you can choose the format of the output file. Sheet=Sheet NoImportableData=No importable data (no module with definitions to allow data imports) FileSuccessfullyBuilt=File generated @@ -50,10 +50,10 @@ LineTotalVAT=Amount of VAT for line TypeOfLineServiceOrProduct=Type of line (0=product, 1=service) FileWithDataToImport=File with data to import FileToImport=Source file to import -FileMustHaveOneOfFollowingFormat=File to import must have one of following format +FileMustHaveOneOfFollowingFormat=File to import must have one of following formats DownloadEmptyExample=Download example of empty source file -ChooseFormatOfFileToImport=Choose file format to use as import file format by clicking on picto %s to select it... -ChooseFileToImport=Upload file then click on picto %s to select file as source import file... +ChooseFormatOfFileToImport=Choose the file format to use as import file format by clicking on the %s icon to select it... +ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... SourceFileFormat=Source file format FieldsInSourceFile=Fields in source file FieldsInTargetDatabase=Target fields in Dolibarr database (bold=mandatory) @@ -68,7 +68,7 @@ FieldsTarget=Targeted fields FieldTarget=Targeted field FieldSource=Source field NbOfSourceLines=Number of lines in source file -NowClickToTestTheImport=Check import parameters you have defined. If they are correct, click on button "%s" to launch a simulation of import process (no data will be changed in your database, it's only a simulation for the moment)... +NowClickToTestTheImport=Check the import parameters you have defined. If they are correct, click on button "%s" to launch a simulation of the import process (no data will be changed in your database, it's only a simulation)... RunSimulateImportFile=Launch the import simulation FieldNeedSource=This field requires data from the source file SomeMandatoryFieldHaveNoSource=Some mandatory fields have no source from data file @@ -77,36 +77,36 @@ InformationOnTargetTables=Information on target fields SelectAtLeastOneField=Switch at least one source field in the column of fields to export SelectFormat=Choose this import file format RunImportFile=Launch import file -NowClickToRunTheImport=Check result of import simulation. If everything is ok, launch the definitive import. +NowClickToRunTheImport=Check result of import simulation. If everything is ok, launch the real import process. DataLoadedWithId=All data will be loaded with the following import id: %s -ErrorMissingMandatoryValue=Mandatory data is empty in source file for field %s. -TooMuchErrors=There is still %s other source lines with errors but output has been limited. -TooMuchWarnings=There is still %s other source lines with warnings but output has been limited. +ErrorMissingMandatoryValue=Mandatory data is empty in the source file for field %s. +TooMuchErrors=There are still %s other source lines with errors but output has been limited. +TooMuchWarnings=There are still %s other source lines with warnings but output has been limited. EmptyLine=Empty line (will be discarded) -CorrectErrorBeforeRunningImport=You must first correct all errors before running definitive import. +CorrectErrorBeforeRunningImport=You must correct all errors before running the definitive import. FileWasImported=File was imported with number %s. -YouCanUseImportIdToFindRecord=You can find all imported record in your database by filtering on field import_key='%s'. +YouCanUseImportIdToFindRecord=You can find all the imported records in your database by filtering on field import_key='%s'. NbOfLinesOK=Number of lines with no errors and no warnings: %s. NbOfLinesImported=Number of lines successfully imported: %s. DataComeFromNoWhere=Value to insert comes from nowhere in source file. DataComeFromFileFieldNb=Value to insert comes from field number %s in source file. -DataComeFromIdFoundFromRef=Value that comes from field number %s of source file will be used to find id of parent object to use (So the objet %s that has the ref. from source file must exists into Dolibarr). -DataComeFromIdFoundFromCodeId=Code that comes from field number %s of source file will be used to find id of parent object to use (So the code from source file must exists into dictionary %s). Note that if you know id, you can also use it into source file instead of code. Import should work in both cases. +DataComeFromIdFoundFromRef=Value that comes from field number %s of source file will be used to find the id of the parent object to use (so the object %s that has the ref. from source file must exist in the database). +DataComeFromIdFoundFromCodeId=Code that comes from field number %s of source file will be used to find the id of the parent object to use (so the code from source file must exist in the dictionary %s). Note that if you know the id, you can also use it in the source file instead of the code. Import should work in both cases. DataIsInsertedInto=Data coming from source file will be inserted into the following field: -DataIDSourceIsInsertedInto=The id of parent object found using the data in source file, will be inserted into the following field: +DataIDSourceIsInsertedInto=The id of parent object was found using the data in the source file, will be inserted into the following field: DataCodeIDSourceIsInsertedInto=The id of parent line found from code, will be inserted into following field: SourceRequired=Data value is mandatory SourceExample=Example of possible data value ExampleAnyRefFoundIntoElement=Any ref found for element %s ExampleAnyCodeOrIdFoundIntoDictionary=Any code (or id) found into dictionary %s -CSVFormatDesc=Comma Separated Value file format (.csv).
This is a text file format where fields are separated by separator [ %s ]. If separator is found inside a field content, field is rounded by round character [ %s ]. Escape character to escape round character is [ %s ]. -Excel95FormatDesc=Excel file format (.xls)
This is native Excel 95 format (BIFF5). -Excel2007FormatDesc=Excel file format (.xlsx)
This is native Excel 2007 format (SpreadsheetML). +CSVFormatDesc=Comma Separated Value file format (.csv).
This is a text file format where fields are separated by a separator [ %s ]. If separator is found inside a field content, field is rounded by round character [ %s ]. Escape character to escape round character is [ %s ]. +Excel95FormatDesc=Excel file format (.xls)
This is the native Excel 95 format (BIFF5). +Excel2007FormatDesc=Excel file format (.xlsx)
This is the native Excel 2007 format (SpreadsheetML). TsvFormatDesc=Tab Separated Value file format (.tsv)
This is a text file format where fields are separated by a tabulator [tab]. ExportFieldAutomaticallyAdded=Field %s was automatically added. It will avoid you to have similar lines to be treated as duplicate record (with this field added, all lines will own their own id and will differ). CsvOptions=Csv Options Separator=Separator -Enclosure=Enclosure +Enclosure=Delimiter SpecialCode=Special code ExportStringFilter=%% allows replacing one or more characters in the text ExportDateFilter=YYYY, YYYYMM, YYYYMMDD : filters by one year/month/day
YYYY+YYYY, YYYYMM+YYYYMM, YYYYMMDD+YYYYMMDD : filters over a range of years/months/days
> YYYY, > YYYYMM, > YYYYMMDD : filters on all following years/months/days
< YYYY, < YYYYMM, < YYYYMMDD : filters on all previous years/months/days diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index eca2bbdfe46..5c9c9e04200 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -19,8 +19,8 @@ ListeCP=List of leaves LeaveId=Leave ID ReviewedByCP=Will be approved by UserForApprovalID=User for approval ID -UserForApprovalFirstname=Firstname of approval user -UserForApprovalLastname=Lastname of approval user +UserForApprovalFirstname=First name of approval user +UserForApprovalLastname=Last name of approval user UserForApprovalLogin=Login of approval user DescCP=Description SendRequestCP=Create leave request @@ -112,7 +112,7 @@ NoticePeriod=Notice period HolidaysToValidate=Validate leave requests HolidaysToValidateBody=Below is a leave request to validate HolidaysToValidateDelay=This leave request will take place within a period of less than %s days. -HolidaysToValidateAlertSolde=The user who made this leave reques do not have enough available days. +HolidaysToValidateAlertSolde=The user who made this leave request does have enough available days. HolidaysValidated=Validated leave requests HolidaysValidatedBody=Your leave request for %s to %s has been validated. HolidaysRefused=Request denied diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index 3889c73dbbb..12bb1592cbc 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -5,7 +5,7 @@ Establishments=Establishments Establishment=Establishment NewEstablishment=New establishment DeleteEstablishment=Delete establishment -ConfirmDeleteEstablishment=Are-you sure to delete this establishment? +ConfirmDeleteEstablishment=Are you sure you wish to delete this establishment? OpenEtablishment=Open establishment CloseEtablishment=Close establishment # Dictionary diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index bab16304d83..21dc5ec4db5 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -33,7 +33,7 @@ ValidMailing=Valid emailing MailingStatusDraft=Draft MailingStatusValidated=Validated MailingStatusSent=Sent -MailingStatusSentPartialy=Sent partialy +MailingStatusSentPartialy=Sent partially MailingStatusSentCompletely=Sent completely MailingStatusError=Error MailingStatusNotSent=Not sent @@ -45,8 +45,8 @@ MailingStatusReadAndUnsubscribe=Read and unsubscribe ErrorMailRecipientIsEmpty=Email recipient is empty WarningNoEMailsAdded=No new Email to add to recipient's list. ConfirmValidMailing=Are you sure you want to validate this emailing? -ConfirmResetMailing=Warning, by reinitializing emailing %s, you allow to make a mass sending of this email another time. Are you sure you this is what you want to do? -ConfirmDeleteMailing=Are you sure you want to delete this emailling? +ConfirmResetMailing=Warning, by reinitializing emailing %s, you will allow resending this email in a mass mailing. Are you sure you this is what you want to do? +ConfirmDeleteMailing=Are you sure you want to delete this emailing? NbOfUniqueEMails=Nb of unique emails NbOfEMails=Nb of EMails TotalNbOfDistinctRecipients=Number of distinct recipients @@ -66,12 +66,12 @@ DateLastSend=Date of latest sending DateSending=Date sending SentTo=Sent to %s MailingStatusRead=Read -YourMailUnsubcribeOK=The email %s is correctly unsubcribe from mailing list -ActivateCheckReadKey=Key used to encrypt URL used for "Read Receipt" and "Unsubcribe" feature +YourMailUnsubcribeOK=The email %s is correctly unsubscribe from mailing list +ActivateCheckReadKey=Key used to encrypt URL used for "Read Receipt" and "Unsubscribe" feature EMailSentToNRecipients=EMail sent to %s recipients. EMailSentForNElements=EMail sent for %s elements. XTargetsAdded=%s recipients added into target list -OnlyPDFattachmentSupported=If the PDF documents were already generated for the objects to send, they will be attached to email. If not, no email will be sent (also, note that only pdf documents are supported as attachment in mass sending in this version). +OnlyPDFattachmentSupported=If the PDF documents were already generated for the objects to send, they will be attached to email. If not, no email will be sent (also, note that only pdf documents are supported as attachments in mass sending in this version). AllRecipientSelected=The recipients of the %s record selected (if their email is known). GroupEmails=Group emails OneEmailPerRecipient=One email per recipient (by default, one email per record selected) @@ -139,7 +139,7 @@ UseFormatFileEmailToTarget=Imported file must have format email;name;fir UseFormatInputEmailToTarget=Enter a string with format email;name;firstname;other MailAdvTargetRecipients=Recipients (advanced selection) AdvTgtTitle=Fill input fields to preselect the third parties or contacts/addresses to target -AdvTgtSearchTextHelp=Use %% as magic caracters. For exemple to find all item like jean, joe, jim, you can input j%%, you can also use ; as separator for value, and use ! for except this value. For exemple jean;joe;jim%%;!jimo;!jima% will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima +AdvTgtSearchTextHelp=Use %% as wildcards. For example to find all item like jean, joe, jim, you can input j%%, you can also use ; as separator for value, and use ! for except this value. For example jean;joe;jim%%;!jimo;!jima% will target all jean, joe, start with jim but not jimo and not everything that starts with jima AdvTgtSearchIntHelp=Use interval to select int or float value AdvTgtMinVal=Minimum value AdvTgtMaxVal=Maximum value @@ -153,7 +153,7 @@ AddAll=Add all RemoveAll=Remove all ItemsCount=Item(s) AdvTgtNameTemplate=Filter name -AdvTgtAddContact=Add emails according to criterias +AdvTgtAddContact=Add emails according to criteria AdvTgtLoadFilter=Load filter AdvTgtDeleteFilter=Delete filter AdvTgtSaveFilter=Save filter @@ -166,4 +166,4 @@ InGoingEmailSetup=Incoming email setup OutGoingEmailSetupForEmailing=Outgoing email setup (for mass emailing) DefaultOutgoingEmailSetup=Default outgoing email setup Information=Information -ContactsWithThirdpartyFilter=Contacts avec filtre client +ContactsWithThirdpartyFilter=Contacts with third party filter diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index da140b602f2..51514b98160 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -822,7 +822,7 @@ TooManyRecordForMassAction=Too many records selected for mass action. The action NoRecordSelected=No record selected MassFilesArea=Area for files built by mass actions ShowTempMassFilesArea=Show area of files built by mass actions -ConfirmMassDeletion=Bulk delete confirmation +ConfirmMassDeletion=Mass delete confirmation ConfirmMassDeletionQuestion=Are you sure you want to delete the %s selected record? RelatedObjects=Related Objects ClassifyBilled=Classify billed @@ -945,6 +945,6 @@ LocalAndRemote=Local and Remote KeyboardShortcut=Keyboard shortcut AssignedTo=Assigned to Deletedraft=Delete draft -ConfirmMassDraftDeletion=Draft Bulk delete confirmation +ConfirmMassDraftDeletion=Draft mass delete confirmation FileSharedViaALink=File shared via a link diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index b9d52dcfdc6..167e316703c 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -41,4 +41,4 @@ rateMustBeNumeric=Rate must be a numeric value markRateShouldBeLesserThan100=Mark rate should be lower than 100 ShowMarginInfos=Show margin infos CheckMargins=Margins detail -MarginPerSaleRepresentativeWarning=The report of margin per user use the link between third parties and sale representatives to calculate the margin of each sale representative. Because some thirdparties may not have any ddiated sale representative and some thirdparties may be linked to several, some amounts may not be included into this report (if there is no sale representative) and some may appear on different lines (for each sale representative). +MarginPerSaleRepresentativeWarning=The report of margin per user use the link between third parties and sale representatives to calculate the margin of each sale representative. Because some thirdparties may not have any dedicated sale representative and some third parties may be linked to several, some amounts may not be included into this report (if there is no sale representative) and some may appear on different lines (for each sale representative). diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 98e42b45e96..9eac3a0c542 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -88,7 +88,7 @@ ConfirmDeleteSubscription=Are you sure you want to delete this subscription? Filehtpasswd=htpasswd file ValidateMember=Validate a member ConfirmValidateMember=Are you sure you want to validate this member? -FollowingLinksArePublic=The following links are open pages not protected by any Dolibarr permission. They are not formated pages, provided as example to show how to list members database. +FollowingLinksArePublic=The following links are open pages not protected by any Dolibarr permission. They are not formatted pages, provided as example to show how to list members database. PublicMemberList=Public member list BlankSubscriptionForm=Public self-subscription form BlankSubscriptionFormDesc=Dolibarr can provide you a public URL/website to allow external visitors to ask to subscribe to the foundation. If an online payment module is enabled, a payment form may also be automatically provided. diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 460cdce63c2..bd506bd84a5 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - loan -ModuleBuilderDesc=This tools must be used by experienced users or developers. It gives you utilities to build or edit your own module (Documentation for alternative manual development is here). +ModuleBuilderDesc=This tool must be used by only by experienced users or developers. It gives you utilities to build or edit your own module.
Documentation for alternative manual development is here. EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...). The CRUD class file, but also API file, pages to list/add/edit/delete object and SQL files will be generated. ModuleBuilderDesc2=Path where modules are generated/edited (first alternative directory defined into %s): %s @@ -13,7 +13,7 @@ ModuleInitialized=Module initialized FilesForObjectInitialized=Files for new object '%s' initialized FilesForObjectUpdated=Files for object '%s' updated (.sql files and .class.php file) ModuleBuilderDescdescription=Enter here all general information that describe your module. -ModuleBuilderDescspecifications=You can enter here a long text to describe the specifications of your module that is not already structured into other tabs. So you have within easy reach all the rules to develop. Also this text content will be included into the generated documentation (see last tab). You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown) +ModuleBuilderDescspecifications=You can enter here a detailed description of the specifications of your module that is not already structured into other tabs. So you have within easy reach all the rules to develop. Also this text content will be included into the generated documentation (see last tab). You can use Markdown format, but it is recommended to use Asciidoc format (comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown). ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A CRUD DAO class, SQL files, page to list record of objects, to create/edit/view a record and an API will be generated. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module. @@ -21,12 +21,12 @@ ModuleBuilderDesctriggers=This is the view of triggers provided by your module. ModuleBuilderDeschooks=This tab is dedicated to hooks. ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets. ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module and a "ready to distribute" documentation file. Just click on button to build the package or documentation file. -EnterNameOfModuleToDeleteDesc=You can delete your module. WARNING: All files of module but also structured data and documentation will be definitly lost ! -EnterNameOfObjectToDeleteDesc=You can delete an object. WARNING: All files related to object will be definitly lost ! +EnterNameOfModuleToDeleteDesc=You can delete your module. WARNING: ALL files of module AND structured data and documentation will be deleted! +EnterNameOfObjectToDeleteDesc=You can delete an object. WARNING: All files related to object will be deleted! DangerZone=Danger zone BuildPackage=Build package/documentation BuildDocumentation=Build documentation -ModuleIsNotActive=This module was not activated yet. Go into %s to make it live or click here: +ModuleIsNotActive=This module is not activated yet. Go to %s to make it live or click here: ModuleIsLive=This module has been activated. Any change on it may break a current active feature. DescriptionLong=Long description EditorName=Name of editor @@ -47,7 +47,7 @@ RegenerateClassAndSql=Erase and regenerate class and sql files RegenerateMissingFiles=Generate missing files SpecificationFile=File with business rules LanguageFile=File for language -ConfirmDeleteProperty=Are you sure you want to delete the property %s ? This will change code in PHP class but also remove column from table definition of object. +ConfirmDeleteProperty=Are you sure you want to delete the property %s? This will change code in PHP class but also remove column from table definition of object. NotNull=Not NULL NotNullDesc=1=Set database to NOT NULL. -1=Allow null values and force value to NULL if empty ('' or 0). SearchAll=Used for 'search all' @@ -66,7 +66,7 @@ PageForLib=File for PHP libraries SqlFileExtraFields=Sql file for complementary attributes SqlFileKey=Sql file for keys AnObjectAlreadyExistWithThisNameAndDiffCase=An object already exists with this name and a different case -UseAsciiDocFormat=You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown) +UseAsciiDocFormat=You can use Markdown format, but it is recommended to use Asciidoc format (omparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown) IsAMeasure=Is a measure DirScanned=Directory scanned NoTrigger=No trigger @@ -77,8 +77,8 @@ ListOfPermissionsDefined=List of defined permissions SeeExamples=See examples here EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) VisibleDesc=Is the field visible ? (Examples: 0=Never visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only. Using a negative value means field is not shown by default on list but can be selected for viewing) -IsAMeasureDesc=Can the value of field be cumulated to get a total into list ? (Examples: 1 or 0) -SearchAllDesc=Is the field used to make a search from the quick search tool ? (Examples: 1 or 0) +IsAMeasureDesc=Can the value of field be cumulated to get a total into list? (Examples: 1 or 0) +SearchAllDesc=Is the field used to make a search from the quick search tool? (Examples: 1 or 0) SpecDefDesc=Enter here all documentation you want to provide with your module that is not already defined by other tabs. You can use .md or better, the rich .asciidoc syntax. LanguageDefDesc=Enter in this files, all the key and the translation for each language file. MenusDefDesc=Define here the menus provided by your module (once defined, they are visible into the menu editor %s) @@ -88,7 +88,7 @@ TriggerDefDesc=Define in the trigger file the code you want to execute for each SeeIDsInUse=See IDs in use in your installation SeeReservedIDsRangeHere=See range of reserved IDs ToolkitForDevelopers=Toolkit for Dolibarr developers -TryToUseTheModuleBuilder=If you have knowledge in SQL and PHP, you can try to use the native module builder wizard. Just enable the module and use the wizard by clicking the on the top right menu. Warning: This is a developer feature, bad use may breaks your application. +TryToUseTheModuleBuilder=If you have knowledge of SQL and PHP, you may use the native module builder wizard.
Enable the module (Setup->Other Setup->MAIN_FEATURES_LEVEL = 2) and use the wizard by clicking the on the top right menu.
Warning: This is an advanced developer feature, do not experiment on your production site! SeeTopRightMenu=See on the top right menu AddLanguageFile=Add language file YouCanUseTranslationKey=You can use here a key that is the translation key found into language file (see tab "Languages") diff --git a/htdocs/langs/en_US/multicurrency.lang b/htdocs/langs/en_US/multicurrency.lang index 0da2ee58b60..048e6721310 100644 --- a/htdocs/langs/en_US/multicurrency.lang +++ b/htdocs/langs/en_US/multicurrency.lang @@ -3,18 +3,18 @@ MultiCurrency=Multi currency ErrorAddRateFail=Error in added rate ErrorAddCurrencyFail=Error in added currency ErrorDeleteCurrencyFail=Error delete fail -multicurrency_syncronize_error=Synchronisation error: %s -MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE=Use date of document to find currency rate, instead of using latest known rate -multicurrency_useOriginTx=When an object is created from another, keep the original rate of source object (otherwise use the latest known rate) +multicurrency_syncronize_error=Synchronization error: %s +MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE=Use the date of the document to find the currency rate, instead of using the latest known rate +multicurrency_useOriginTx=When an object is created from another, keep the original rate from the source object (otherwise use the latest known rate) CurrencyLayerAccount=CurrencyLayer API -CurrencyLayerAccount_help_to_synchronize=You sould create an account on their website to use this functionnality
Get your API key
If you use a free account you can't change the currency source (USD by default)
But if your main currency isn't USD you can use the alternate currency source to force you main currency

You are limited at 1000 synchronizations per month +CurrencyLayerAccount_help_to_synchronize=You must create an account on their website to use this functionality.
Get your API key.
If you use a free account you can't change the currency source (USD by default).
If your main currency is not USD you can use the alternate currency source to force your main currency.

You are limited to 1000 synchronizations per month. multicurrency_appId=API key multicurrency_appCurrencySource=Currency source multicurrency_alternateCurrencySource=Alternate currency source CurrenciesUsed=Currencies used -CurrenciesUsed_help_to_add=Add the differents currencies and rates you need to use on you proposals, orders, etc. +CurrenciesUsed_help_to_add=Add the different currencies and rates you need to use on your proposals, orders etc. rate=rate MulticurrencyReceived=Received, original currency -MulticurrencyRemainderToTake=Remaining amout, original currency +MulticurrencyRemainderToTake=Remaining amount, original currency MulticurrencyPaymentAmount=Payment amount, original currency AmountToOthercurrency=Amount To (in currency of receiving account) \ No newline at end of file diff --git a/htdocs/langs/en_US/opensurvey.lang b/htdocs/langs/en_US/opensurvey.lang index 41f91cf8bef..0dff05cbfc0 100644 --- a/htdocs/langs/en_US/opensurvey.lang +++ b/htdocs/langs/en_US/opensurvey.lang @@ -11,7 +11,7 @@ PollTitle=Poll title ToReceiveEMailForEachVote=Receive an email for each vote TypeDate=Type date TypeClassic=Type standard -OpenSurveyStep2=Select your dates amoung the free days (grey). The selected days are green. You can unselect a day previously selected by clicking again on it +OpenSurveyStep2=Select your dates among the free days (grey). The selected days are green. You can unselect a day previously selected by clicking again on it RemoveAllDays=Remove all days CopyHoursOfFirstDay=Copy hours of first day RemoveAllHours=Remove all hours diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 06191d9f7b7..ac4ff87b8e1 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -88,7 +88,7 @@ NumberOfOrdersByMonth=Number of orders by month AmountOfOrdersByMonthHT=Amount of orders by month (net of tax) ListOfOrders=List of orders CloseOrder=Close order -ConfirmCloseOrder=Are you sure you want to set this order to deliverd? Once an order is delivered, it can be set to billed. +ConfirmCloseOrder=Are you sure you want to set this order to delivered? Once an order is delivered, it can be set to billed. ConfirmDeleteOrder=Are you sure you want to delete this order? ConfirmValidateOrder=Are you sure you want to validate this order under name %s? ConfirmUnvalidateOrder=Are you sure you want to restore order %s to draft status? @@ -116,7 +116,7 @@ DispatchSupplierOrder=Receiving supplier order %s FirstApprovalAlreadyDone=First approval already done SecondApprovalAlreadyDone=Second approval already done SupplierOrderReceivedInDolibarr=Purchase Order %s received %s -SupplierOrderSubmitedInDolibarr=Purchase Order %s submited +SupplierOrderSubmitedInDolibarr=Purchase Order %s submitted SupplierOrderClassifiedBilled=Purchase Order %s set billed OtherOrders=Other orders ##### Types de contacts ##### diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 8ef8cc30090..c5535cd8eb0 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -23,7 +23,7 @@ MessageForm=Message on online payment form MessageOK=Message on validated payment return page MessageKO=Message on canceled payment return page ContentOfDirectoryIsNotEmpty=Content of this directory is not empty. -DeleteAlsoContentRecursively=Check to delete all content recursiveley +DeleteAlsoContentRecursively=Check to delete all content recursively YearOfInvoice=Year of invoice date PreviousYearOfInvoice=Previous year of invoice date @@ -41,8 +41,8 @@ Notify_ORDER_SUPPLIER_VALIDATE=Supplier order recorded Notify_ORDER_SUPPLIER_APPROVE=Supplier order approved Notify_ORDER_SUPPLIER_REFUSE=Supplier order refused Notify_PROPAL_VALIDATE=Customer proposal validated -Notify_PROPAL_CLOSE_SIGNED=Customer propal closed signed -Notify_PROPAL_CLOSE_REFUSED=Customer propal closed refused +Notify_PROPAL_CLOSE_SIGNED=Customer proposal closed signed +Notify_PROPAL_CLOSE_REFUSED=Customer proposal closed refused Notify_PROPAL_SENTBYMAIL=Commercial proposal sent by mail Notify_WITHDRAW_TRANSMIT=Transmission withdrawal Notify_WITHDRAW_CREDIT=Credit withdrawal @@ -185,7 +185,7 @@ NumberOfUnitsCustomerInvoices=Number of units on customer invoices NumberOfUnitsSupplierProposals=Number of units on supplier proposals NumberOfUnitsSupplierOrders=Number of units on supplier orders NumberOfUnitsSupplierInvoices=Number of units on supplier invoices -EMailTextInterventionAddedContact=A newintervention %s has been assigned to you. +EMailTextInterventionAddedContact=A new intervention %s has been assigned to you. EMailTextInterventionValidated=The intervention %s has been validated. EMailTextInvoiceValidated=The invoice %s has been validated. EMailTextProposalValidated=The proposal %s has been validated. @@ -204,7 +204,7 @@ NewLength=New width NewHeight=New height NewSizeAfterCropping=New size after cropping DefineNewAreaToPick=Define new area on image to pick (left click on image then drag until you reach the opposite corner) -CurrentInformationOnImage=This tool was designed to help you to resize or crop an image. This is informations on current edited image +CurrentInformationOnImage=This tool was designed to help you to resize or crop an image. This is the information on the current edited image ImageEditor=Image editor YouReceiveMailBecauseOfNotification=You receive this message because your email has been added to list of targets to be informed of particular events into %s software of %s. YouReceiveMailBecauseOfNotification2=This event is the following: diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang index 522243ab899..c7e7bd38bdc 100644 --- a/htdocs/langs/en_US/paybox.lang +++ b/htdocs/langs/en_US/paybox.lang @@ -21,9 +21,9 @@ ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (required only for free payment) to add your own payment comment tag. -SetupPayBoxToHavePaymentCreatedAutomatically=Setup your PayBox with url %s to have payment created automatically when validated by paybox. +SetupPayBoxToHavePaymentCreatedAutomatically=Setup your Paybox with url %s to have payment created automatically when validated by Paybox. YourPaymentHasBeenRecorded=This page confirms that your payment has been recorded. Thank you. -YourPaymentHasNotBeenRecorded=You payment has NOT been recorded and transaction has been canceled. Thank you. +YourPaymentHasNotBeenRecorded=Your payment has NOT been recorded and the transaction has been canceled. Thank you. AccountParameter=Account parameters UsageParameter=Usage parameters InformationToFindParameters=Help to find your %s account information diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index 547b188b4a5..bc5e828e903 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -1,19 +1,19 @@ # Dolibarr language file - Source file is en_US - paypal PaypalSetup=PayPal module setup -PaypalDesc=This module offer pages to allow payment on PayPal by customers. This can be used for a free payment or for a payment on a particular Dolibarr object (invoice, order, ...) -PaypalOrCBDoPayment=Pay with Paypal (Credit Card or Paypal) -PaypalDoPayment=Pay with Paypal +PaypalDesc=This module allows payment on PayPal by customers. This can be used for a free payment or for a payment on a particular Dolibarr object (invoice, order, ...) +PaypalOrCBDoPayment=Pay with PayPal (Credit Card or PayPal) +PaypalDoPayment=Pay with PayPal PAYPAL_API_SANDBOX=Mode test/sandbox PAYPAL_API_USER=API username PAYPAL_API_PASSWORD=API password PAYPAL_API_SIGNATURE=API signature PAYPAL_SSLVERSION=Curl SSL Version -PAYPAL_API_INTEGRAL_OR_PAYPALONLY=Offer payment "integral" (Credit card+Paypal) or "Paypal" only +PAYPAL_API_INTEGRAL_OR_PAYPALONLY=Offer payment "integral" (Credit card+PayPal) or "PayPal" only PaypalModeIntegral=Integral PaypalModeOnlyPaypal=PayPal only -ONLINE_PAYMENT_CSS_URL=Optionnal URL of CSS style sheet on online payment page +ONLINE_PAYMENT_CSS_URL=Optional URL of CSS stylesheet on online payment page ThisIsTransactionId=This is id of transaction: %s -PAYPAL_ADD_PAYMENT_URL=Add the url of Paypal payment when you send a document by mail +PAYPAL_ADD_PAYMENT_URL=Add the url of PayPal payment when you send a document by mail YouAreCurrentlyInSandboxMode=You are currently in the %s "sandbox" mode NewOnlinePaymentReceived=New online payment received NewOnlinePaymentFailed=New online payment tried but failed @@ -28,7 +28,7 @@ ShortErrorMessage=Short Error Message ErrorCode=Error Code ErrorSeverityCode=Error Severity Code OnlinePaymentSystem=Online payment system -PaypalLiveEnabled=Paypal live enabled (otherwise test/sandbox mode) -PaypalImportPayment=Import Paypal payments +PaypalLiveEnabled=PayPal live enabled (otherwise test/sandbox mode) +PaypalImportPayment=Import PayPal payments PostActionAfterPayment=Post actions after payments ARollbackWasPerformedOnPostActions=A rollback was performed on all Post actions. You must complete post actions manually if they are necessary. \ No newline at end of file diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index e8349453247..d2399823e37 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -2,7 +2,7 @@ Module64000Name=Direct Printing Module64000Desc=Enable Direct Printing System PrintingSetup=Setup of Direct Printing System -PrintingDesc=This module adds a Print button to send documents directly to a printer (without opening document into an application) with various module. +PrintingDesc=This module adds a Print button to various modules to allow documents to be printed directly to a printer without needing to open the document in another application. MenuDirectPrinting=Direct Printing jobs DirectPrint=Direct print PrintingDriverDesc=Configuration variables for printing driver. @@ -19,7 +19,7 @@ UserConf=Setup per user PRINTGCP_INFO=Google OAuth API setup PRINTGCP_AUTHLINK=Authentication PRINTGCP_TOKEN_ACCESS=Google Cloud Print OAuth Token -PrintGCPDesc=This driver allow to send documents directly to a printer with Google Cloud Print. +PrintGCPDesc=This driver allows sending documents directly to a printer using Google Cloud Print. GCP_Name=Name GCP_displayName=Display Name GCP_Id=Printer Id @@ -27,7 +27,7 @@ GCP_OwnerName=Owner Name GCP_State=Printer State GCP_connectionStatus=Online State GCP_Type=Printer Type -PrintIPPDesc=This driver allow to send documents directly to a printer. It requires a Linux system with CUPS installed. +PrintIPPDesc=This driver allows sending of documents directly to a printer. It requires a Linux system with CUPS installed. PRINTIPP_HOST=Print server PRINTIPP_PORT=Port PRINTIPP_USER=Login diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 21c2e1dc62c..e5da8738d96 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -17,12 +17,12 @@ Reference=Reference NewProduct=New product NewService=New service ProductVatMassChange=Mass VAT change -ProductVatMassChangeDesc=This page can be used to modify a VAT rate defined on products or services from a value to another. Warning, this change is done on all database. +ProductVatMassChangeDesc=This page can be used to modify a VAT rate defined on products or services from one value to another. Warning, this change is global/done on all database. MassBarcodeInit=Mass barcode init MassBarcodeInitDesc=This page can be used to initialize a barcode on objects that does not have barcode defined. Check before that setup of module barcode is complete. ProductAccountancyBuyCode=Accounting code (purchase) ProductAccountancySellCode=Accounting code (sale) -ProductAccountancySellIntraCode=Accounting code (sale intra-community) +ProductAccountancySellIntraCode=Accounting code (sale intra-Community) ProductAccountancySellExportCode=Accounting code (sale export) ProductOrService=Product or Service ProductsAndServices=Products and Services @@ -97,7 +97,7 @@ NoteNotVisibleOnBill=Note (not visible on invoices, proposals...) ServiceLimitedDuration=If product is a service with limited duration: MultiPricesAbility=Several segment of prices per product/service (each customer is in one segment) MultiPricesNumPrices=Number of prices -AssociatedProductsAbility=Activate the feature to manage virtual products +AssociatedProductsAbility=Activate virtual products (kits) AssociatedProducts=Virtual product AssociatedProductsNumber=Number of products composing this virtual product ParentProductsNumber=Number of parent packaging product @@ -134,7 +134,7 @@ PredefinedServicesToSell=Predefined services to sell PredefinedProductsAndServicesToSell=Predefined products/services to sell PredefinedProductsToPurchase=Predefined product to purchase PredefinedServicesToPurchase=Predefined services to purchase -PredefinedProductsAndServicesToPurchase=Predefined products/services to puchase +PredefinedProductsAndServicesToPurchase=Predefined products/services to purchase NotPredefinedProducts=Not predefined products/services GenerateThumb=Generate thumb ServiceNb=Service #%s @@ -145,7 +145,7 @@ Finished=Manufactured product RowMaterial=Raw Material CloneProduct=Clone product or service ConfirmCloneProduct=Are you sure you want to clone product or service %s? -CloneContentProduct=Clone all main informations of product/service +CloneContentProduct=Clone all main information of product/service ClonePricesProduct=Clone prices CloneCompositionProduct=Clone packaged product/service CloneCombinationsProduct=Clone product variants @@ -202,7 +202,7 @@ PriceByQuantity=Different prices by quantity DisablePriceByQty=Disable prices by quantity PriceByQuantityRange=Quantity range MultipriceRules=Price segment rules -UseMultipriceRules=Use price segment rules (defined into product module setup) to autocalculate prices of all other segment according to first segment +UseMultipriceRules=Use price segment rules (defined into product module setup) to auto calculate prices of all other segments according to first segment PercentVariationOver=%% variation over %s PercentDiscountOver=%% discount over %s KeepEmptyForAutoCalculation=Keep empty to have this calculated automatically from weight or volume of products @@ -233,7 +233,7 @@ BarCodeDataForThirdparty=Barcode information of third party %s : ResetBarcodeForAllRecords=Define barcode value for all record (this will also reset barcode value already defined with new values) PriceByCustomer=Different prices for each customer PriceCatalogue=A single sell price per product/service -PricingRule=Rules for sell prices +PricingRule=Rules for selling prices AddCustomerPrice=Add price by customer ForceUpdateChildPriceSoc=Set same price on customer subsidiaries PriceByCustomerLog=Log of previous customer prices @@ -254,7 +254,7 @@ ComposedProduct=Sub-product MinSupplierPrice=Minimum buying price MinCustomerPrice=Minimum selling price DynamicPriceConfiguration=Dynamic price configuration -DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able to use and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value. +DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able to use and if the variable need an automatic update, the external URL to use to ask Dolibarr to update the value automatically. AddVariable=Add Variable AddUpdater=Add Updater GlobalVariables=Global variables diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 5a7169ac925..2d2f1bb2ff0 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -53,7 +53,7 @@ ErrorPropalNotFound=Propal %s not found AddToDraftProposals=Add to draft proposal NoDraftProposals=No draft proposals CopyPropalFrom=Create commercial proposal by copying existing proposal -CreateEmptyPropal=Create empty commercial proposals vierge or from list of products/services +CreateEmptyPropal=Create empty commercial proposal or from list of products/services DefaultProposalDurationValidity=Default commercial proposal validity duration (in days) UseCustomerContactAsPropalRecipientIfExist=Use customer contact address if defined instead of third party address as proposal recipient address ClonePropal=Clone commercial proposal diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 432ab894040..1efb877673d 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -1,6 +1,6 @@ # Dolibarr language file - Source file is en_US - salaries SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties -SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated user accouting account on user is not defined. +SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated user accounting account on user is not defined. SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for wage payments Salary=Salary Salaries=Salaries @@ -15,4 +15,4 @@ THMDescription=This value may be used to calculate cost of time consumed on a pr TJMDescription=This value is currently as information only and is not used for any calculation LastSalaries=Latest %s salary payments AllSalaries=All salary payments -SalariesStatistics=Statistiques salaires \ No newline at end of file +SalariesStatistics=Salary statistics \ No newline at end of file diff --git a/htdocs/langs/en_US/sms.lang b/htdocs/langs/en_US/sms.lang index 05b521aae36..15200341490 100644 --- a/htdocs/langs/en_US/sms.lang +++ b/htdocs/langs/en_US/sms.lang @@ -1,9 +1,9 @@ # Dolibarr language file - Source file is en_US - sms Sms=Sms -SmsSetup=Sms setup -SmsDesc=This page allows you to define globals options on SMS features +SmsSetup=SMS setup +SmsDesc=This page allows you to define global options on SMS features SmsCard=SMS Card -AllSms=All SMS campains +AllSms=All SMS campaigns SmsTargets=Targets SmsRecipients=Targets SmsRecipient=Target @@ -13,20 +13,20 @@ SmsTo=Target SmsTopic=Topic of SMS SmsText=Message SmsMessage=SMS Message -ShowSms=Show Sms -ListOfSms=List SMS campains -NewSms=New SMS campain -EditSms=Edit Sms +ShowSms=Show SMS +ListOfSms=List SMS campaigns +NewSms=New SMS campaign +EditSms=Edit SMS ResetSms=New sending -DeleteSms=Delete Sms campain -DeleteASms=Remove a Sms campain -PreviewSms=Previuw Sms -PrepareSms=Prepare Sms -CreateSms=Create Sms -SmsResult=Result of Sms sending -TestSms=Test Sms -ValidSms=Validate Sms -ApproveSms=Approve Sms +DeleteSms=Delete SMS campaign +DeleteASms=Remove a SMS campaign +PreviewSms=Previuw SMS +PrepareSms=Prepare SMS +CreateSms=Create SMS +SmsResult=Result of SMS sending +TestSms=Test SMS +ValidSms=Validate SMS +ApproveSms=Approve SMS SmsStatusDraft=Draft SmsStatusValidated=Validated SmsStatusApproved=Approved @@ -35,10 +35,10 @@ SmsStatusSentPartialy=Sent partially SmsStatusSentCompletely=Sent completely SmsStatusError=Error SmsStatusNotSent=Not sent -SmsSuccessfulySent=Sms correctly sent (from %s to %s) +SmsSuccessfulySent=SMS correctly sent (from %s to %s) ErrorSmsRecipientIsEmpty=Number of target is empty WarningNoSmsAdded=No new phone number to add to target list -ConfirmValidSms=Do you confirm validation of this campain? +ConfirmValidSms=Do you confirm validation of this campaign? NbOfUniqueSms=Nb dof unique phone numbers NbOfSms=Nbre of phon numbers ThisIsATestMessage=This is a test message diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 0d22a3b3c75..951178b8183 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -55,20 +55,20 @@ PMPValueShort=WAP EnhancedValueOfWarehouses=Warehouses value UserWarehouseAutoCreate=Create a user warehouse automatically when creating a user AllowAddLimitStockByWarehouse=Allow to add limit and desired stock per couple (product, warehouse) instead of per product -IndependantSubProductStock=Product stock and subproduct stock are independant +IndependantSubProductStock=Product stock and subproduct stock are independent QtyDispatched=Quantity dispatched QtyDispatchedShort=Qty dispatched QtyToDispatchShort=Qty to dispatch OrderDispatch=Item receipts -RuleForStockManagementDecrease=Rule for automatic stock management decrease (manual decrease is always possible, even if an automatic decrease rule is activated) -RuleForStockManagementIncrease=Rule for automatic stock management increase (manual increase is always possible, even if an automatic increase rule is activated) -DeStockOnBill=Decrease real stocks on customers invoices/credit notes validation -DeStockOnValidateOrder=Decrease real stocks on customers orders validation +RuleForStockManagementDecrease=Choose Rule for automatic stock decrease (manual decrease is always possible, even if an automatic decrease rule is activated) +RuleForStockManagementIncrease=Choose Rule for automatic stock increase (manual increase is always possible, even if an automatic increase rule is activated) +DeStockOnBill=Decrease real stocks on validation of customer invoice/credit note +DeStockOnValidateOrder=Decrease real stocks on validation of customer order DeStockOnShipment=Decrease real stocks on shipping validation DeStockOnShipmentOnClosing=Decrease real stocks on shipping classification closed -ReStockOnBill=Increase real stocks on suppliers invoices/credit notes validation -ReStockOnValidateOrder=Increase real stocks on purchase orders approbation -ReStockOnDispatchOrder=Increase real stocks on manual dispatching into warehouses, after supplier order receipt of goods +ReStockOnBill=Increase real stocks on validation of supplier invoice/credit note +ReStockOnValidateOrder=Increase real stocks on purchase order approval +ReStockOnDispatchOrder=Increase real stocks on manual dispatching into warehouse, after supplier order receipt of goods OrderStatusNotReadyToDispatch=Order has not yet or no more a status that allows dispatching of products in stock warehouses. StockDiffPhysicTeoric=Explanation for difference between physical and virtual stock NoPredefinedProductToDispatch=No predefined products for this object. So no dispatching in stock is required. @@ -130,9 +130,9 @@ RecordMovement=Record transfer ReceivingForSameOrder=Receipts for this order StockMovementRecorded=Stock movements recorded RuleForStockAvailability=Rules on stock requirements -StockMustBeEnoughForInvoice=Stock level must be enough to add product/service to invoice (check is done on current real stock when adding a line into invoice whatever is rule for automatic stock change) -StockMustBeEnoughForOrder=Stock level must be enough to add product/service to order (check is done on current real stock when adding a line into order whatever is rule for automatic stock change) -StockMustBeEnoughForShipment= Stock level must be enough to add product/service to shipment (check is done on current real stock when adding a line into shipment whatever is rule for automatic stock change) +StockMustBeEnoughForInvoice=Stock level must be enough to add product/service to invoice (check is done on current real stock when adding a line into invoice whatever the rule for automatic stock change) +StockMustBeEnoughForOrder=Stock level must be enough to add product/service to order (check is done on current real stock when adding a line into order whatever the rule for automatic stock change) +StockMustBeEnoughForShipment= Stock level must be enough to add product/service to shipment (check is done on current real stock when adding a line into shipment whatever the rule for automatic stock change) MovementLabel=Label of movement DateMovement=Date of movement InventoryCode=Movement or inventory code @@ -172,7 +172,7 @@ inventoryDraft=Running inventorySelectWarehouse=Warehouse choice inventoryConfirmCreate=Create inventoryOfWarehouse=Inventory for warehouse : %s -inventoryErrorQtyAdd=Error : one quantity is leaser than zero +inventoryErrorQtyAdd=Error : one quantity is less than zero inventoryMvtStock=By inventory inventoryWarningProductAlreadyExists=This product is already into list SelectCategory=Category filter @@ -195,12 +195,12 @@ AddInventoryProduct=Add product to inventory AddProduct=Add ApplyPMP=Apply PMP FlushInventory=Flush inventory -ConfirmFlushInventory=Do you confirm this action ? +ConfirmFlushInventory=Do you confirm this action? InventoryFlushed=Inventory flushed ExitEditMode=Exit edition inventoryDeleteLine=Delete line RegulateStock=Regulate Stock ListInventory=List -StockSupportServices=Stock management support services +StockSupportServices=Stock management supports Services StockSupportServicesDesc=By default, you can stock only product with type "product". If on, and if module service is on, you can also stock a product with type "service" ReceiveProducts=Receive items \ No newline at end of file diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 21935b5dae0..6286f19b8dc 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -1,8 +1,8 @@ # Dolibarr language file - Source file is en_US - website Shortname=Code -WebsiteSetupDesc=Create here as much entry as number of different websites you need. Then go into menu Websites to edit them. +WebsiteSetupDesc=Create here the websites you wish to use. Then go into menu Websites to edit them. DeleteWebsite=Delete website -ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. +ConfirmDeleteWebsite=Are you sure you want to delete this web site? All its pages and content will also be removed. WEBSITE_TYPE_CONTAINER=Type of page/container WEBSITE_PAGE_EXAMPLE=Web page to use as example WEBSITE_PAGENAME=Page name/alias @@ -74,7 +74,7 @@ AnotherContainer=Another container WEBSITE_USE_WEBSITE_ACCOUNTS=Enable the web site account table WEBSITE_USE_WEBSITE_ACCOUNTSTooltip=Enable the table to store web site accounts (login/pass) for each website / thirdparty YouMustDefineTheHomePage=You must first define the default Home page -OnlyEditionOfSourceForGrabbedContentFuture=Note: only edition of HTML source will be possible when a page content is initiliazed by grabbing it from an external page (WYSIWYG editor will not be available) +OnlyEditionOfSourceForGrabbedContentFuture=Note: only edition of HTML source will be possible when a page content is initialized by grabbing it from an external page (WYSIWYG editor will not be available) OnlyEditionOfSourceForGrabbedContent=Only edition of HTML source is possible when content was grabbed from an external site GrabImagesInto=Grab also images found into css and page. ImagesShouldBeSavedInto=Images should be saved into directory diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 5a25a9e96e2..aadc12802a0 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -26,7 +26,7 @@ LastWithdrawalReceipt=Latest %s direct debit receipts MakeWithdrawRequest=Make a direct debit payment request WithdrawRequestsDone=%s direct debit payment requests recorded ThirdPartyBankCode=Third party bank code -NoInvoiceCouldBeWithdrawed=No invoice withdrawed with success. Check that invoices are on companies with a valid default BAN and that BAN has a RUM with mode %s. +NoInvoiceCouldBeWithdrawed=No invoice debited successfully. Check that invoices are on companies with a valid IBAN and that IBAN has a UMR (Unique Mandate Reference) with mode %s. ClassCredited=Classify credited ClassCreditedConfirm=Are you sure you want to classify this withdrawal receipt as credited on your bank account? TransData=Transmission date diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index ed19a531c07..3dab69667c4 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -1,20 +1,20 @@ # Dolibarr language file - Source file is en_US - workflow WorkflowSetup=Workflow module setup -WorkflowDesc=This module is designed to modify the behaviour of automatic actions into application. By default, workflow is open (you can do things in the order you want). You can activate the automatic actions you are interested in. +WorkflowDesc=This module provides some automatic actions. By default, the workflow is open (you can do things in the order you want) but here you can activate some automatic actions. ThereIsNoWorkflowToModify=There is no workflow modifications available with the activated modules. # Autocreate -descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a customer order after a commercial proposal is signed (new order will have same amount than proposal) -descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed (new invoice will have same amount than proposal) +descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a customer order after a commercial proposal is signed (the new order will have same amount as the proposal) +descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed (the new invoice will have same amount as the proposal) descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Automatically create a customer invoice after a contract is validated -descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice after a customer order is closed (new invoice will have same amount than order) +descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice after a customer order is closed (the new invoice will have same amount as the order) # Autoclassify customer proposal or order -descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal(s) to billed when customer order is set to billed (and if amount of the order is same than total amount of signed linked proposals) -descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal(s) to billed when customer invoice is validated (and if amount of the invoice is same than total amount of signed linked proposals) -descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is validated (and if amount of the invoice is same than total amount of linked orders) -descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid (and if amount of the invoice is same than total amount of linked orders) -descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify linked source customer order to shipped when a shipment is validated (and if quantity shipped by all shipments is the same as in the order to update) +descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal as billed when customer order is set to billed (and if the amount of the order is the same as the total amount of the signed linked proposal) +descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal as billed when customer invoice is validated (and if the amount of the invoice is the same as the total amount of the signed linked proposal) +descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source customer order as billed when customer invoice is validated (and if the amount of the invoice is the same as the total amount of the linked order) +descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order as billed when customer invoice is set to paid (and if the amount of the invoice is the same as the total amount of the linked order) +descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify linked source customer order as shipped when a shipment is validated (and if the quantity shipped by all shipments is the same as in the order to update) # Autoclassify supplier order -descWORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL=Classify linked source vendor proposal(s) to billed when vendor invoice is validated (and if amount of the invoice is same than total amount of linked proposals) -descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER=Classify linked source purchase order(s) to billed when vendor invoice is validated (and if amount of the invoice is same than total amount of linked orders) +descWORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL=Classify linked source vendor proposal as billed when vendor invoice is validated (and if the amount of the invoice is the same as the total amount of the linked proposal) +descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER=Classify linked source purchase order as billed when vendor invoice is validated (and if the amount of the invoice is the same as the total amount of the linked order) AutomaticCreation=Automatic creation AutomaticClassification=Automatic classification \ No newline at end of file From df1bead49bcaece84f9da2a669c671cc327b4cff Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 9 Jul 2018 19:04:50 +0200 Subject: [PATCH 140/228] Docs : update and complete comments --- htdocs/core/modules/modModuleBuilder.class.php | 2 +- htdocs/core/modules/modMultiCurrency.class.php | 2 +- htdocs/core/modules/modNotification.class.php | 7 +++++-- htdocs/core/modules/modOauth.class.php | 8 +++++--- htdocs/core/modules/modOpenSurvey.class.php | 8 +++++--- htdocs/core/modules/modPaybox.class.php | 8 +++++--- htdocs/core/modules/modPaypal.class.php | 8 +++++--- htdocs/core/modules/modPrelevement.class.php | 9 ++++++--- 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 875820c9b6b..60afb99afc5 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -62,7 +62,7 @@ class modModuleBuilder extends DolibarrModules //------------- $this->config_page_url = array('setup@modulebuilder'); - // Dependancies + // Dependencies //------------- $this->hidden = false; // A condition to disable module $this->depends = array(); // List of modules id that must be enabled if this module is enabled diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 2d443c2e7bb..b19c018b0d9 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -88,7 +88,7 @@ class modMultiCurrency extends DolibarrModules $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->phpmin = array(5, 0); // Minimum version of PHP required by module + $this->phpmin = array(5, 4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module $this->langfiles = array("multicurrency"); diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index cc016d294b5..9dbd77fae86 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -55,8 +55,11 @@ class modNotification extends DolibarrModules $this->dirs = array(); // Dependencies - $this->depends = array(); - $this->requiredby = array(); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("mails"); // Config pages diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index 3177e41e787..3f2ecc0ac72 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -67,9 +67,11 @@ class modOauth extends DolibarrModules $this->config_page_url = array("oauth.php"); // Dependencies - $this->depends = array(); - $this->requiredby = array(); - $this->phpmin = array(5,1); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module $this->conflictwith = array(); $this->langfiles = array("oauth"); diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index fcee9f585aa..23c1b2680b8 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -72,9 +72,11 @@ class modOpenSurvey extends DolibarrModules //$this->dirs[1] = DOL_DATA_ROOT.'/mymodule/temp; // Dependencies - $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(4,1); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,4,0); // Minimum version of Dolibarr required by module // Constants diff --git a/htdocs/core/modules/modPaybox.class.php b/htdocs/core/modules/modPaybox.class.php index 727e6723ce2..ba7851aad4a 100644 --- a/htdocs/core/modules/modPaybox.class.php +++ b/htdocs/core/modules/modPaybox.class.php @@ -69,9 +69,11 @@ class modPayBox extends DolibarrModules $this->config_page_url = array("paybox.php@paybox"); // Dependencies - $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(4,1); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(2,6); // Minimum version of Dolibarr required by module $this->langfiles = array("paybox"); diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index e713685691c..a11fa41b7a6 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -70,9 +70,11 @@ class modPaypal extends DolibarrModules $this->config_page_url = array("paypal.php@paypal"); // Dependencies - $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array('modPaypalPlus'); // List of modules id to disable if this one is disabled - $this->phpmin = array(5,2); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array('modPaypalPlus'); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("paypal"); diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index 4d91c937d99..cc74273d29c 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -63,9 +63,12 @@ class modPrelevement extends DolibarrModules // Data directories to create when module is enabled $this->dirs = array("/prelevement/temp","/prelevement/receipts"); - // Dependancies - $this->depends = array("modFacture","modBanque"); - $this->requiredby = array(); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array("modFacture","modBanque"); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Config pages $this->config_page_url = array("prelevement.php"); From b92190ac697f682fb0000eb68820586d365eb1b3 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 10 Jul 2018 09:32:55 +0200 Subject: [PATCH 141/228] Docs : Update and complete --- htdocs/core/modules/modPrinting.class.php | 8 +++++--- htdocs/core/modules/modProduct.class.php | 7 +++++-- htdocs/core/modules/modProductBatch.class.php | 8 +++++--- htdocs/core/modules/modProjet.class.php | 10 ++++++---- htdocs/core/modules/modPropale.class.php | 9 ++++++--- htdocs/core/modules/modReceiptPrinter.class.php | 8 +++++--- htdocs/core/modules/modResource.class.php | 2 +- htdocs/core/modules/modSalaries.class.php | 8 +++++--- htdocs/core/modules/modService.class.php | 9 ++++++--- htdocs/core/modules/modSkype.class.php | 17 ++++++----------- 10 files changed, 50 insertions(+), 36 deletions(-) diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index 1aa36bdacce..17d2f398e2b 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -66,9 +66,11 @@ class modPrinting extends DolibarrModules $this->config_page_url = array("printing.php@printing"); // Dependencies - $this->depends = array(); - $this->requiredby = array(); - $this->phpmin = array(5,1); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module $this->conflictwith = array(); $this->langfiles = array("printing"); diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 6ad67ac089c..ab62edc00f6 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -65,8 +65,11 @@ class modProduct extends DolibarrModules $this->dirs = array("/product/temp"); // Dependencies - $this->depends = array(); - $this->requiredby = array("modStock","modBarcode","modProductBatch"); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array("modStock","modBarcode","modProductBatch"); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Config pages $this->config_page_url = array("product.php@product"); diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index 91e8ddbae3c..ac968233772 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -68,9 +68,11 @@ class modProductBatch extends DolibarrModules $this->config_page_url = array("product_lot_extrafields.php@product"); // Dependencies - $this->depends = array("modProduct","modStock","modExpedition","modFournisseur"); // List of modules id that must be enabled if this module is enabled. modExpedition is required to manage batch exit (by manual stock decrease on shipment), modSupplier to manage batch entry (after supplier order). - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(5,0); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array("modProduct","modStock","modExpedition","modFournisseur"); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("productbatch"); diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index d38fc743de1..3e440d3330a 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -64,10 +64,12 @@ class modProjet extends DolibarrModules // Data directories to create when module is enabled $this->dirs = array("/projet/temp"); - // Dependancies - $this->depends = array(); - $this->requiredby = array(); - $this->conflictwith = array(); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array('projects'); // Constants diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index c0701d3bfe2..5b3b2fdd4d8 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -63,9 +63,12 @@ class modPropale extends DolibarrModules // Data directories to create when module is enabled $this->dirs = array("/propale/temp"); - // Dependancies - $this->depends = array("modSociete"); - $this->requiredby = array(); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array("modSociete"); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->config_page_url = array("propal.php"); $this->langfiles = array("propal","bills","companies","deliveries","products"); diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 19df7ca0726..77f264f0d52 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -67,9 +67,11 @@ class modReceiptPrinter extends DolibarrModules $this->config_page_url = array("receiptprinter.php"); // Dependencies - $this->depends = array(); - $this->requiredby = array(); - $this->phpmin = array(5,1); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,9,-2); // Minimum version of Dolibarr required by module $this->conflictwith = array(); $this->langfiles = array("receiptprinter"); diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 15b414947ef..b088a301c6b 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -95,7 +95,7 @@ class modResource extends DolibarrModules // List of modules id to disable if this one is disabled $this->requiredby = array('modPlace'); // Minimum version of PHP required by module - $this->phpmin = array(5, 3); + $this->phpmin = array(5, 4); $this->langfiles = array("resource"); // langfiles@resource // Constants diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index e3d418d182e..9e319c8bf41 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -70,9 +70,11 @@ class modSalaries extends DolibarrModules $this->config_page_url = array(); // Dependencies - $this->depends = array(); - $this->requiredby = array(); - $this->conflictwith = array(); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("salaries","bills"); // Constants diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index df09d27ca51..6db325f8f55 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -62,9 +62,12 @@ class modService extends DolibarrModules // Data directories to create when module is enabled $this->dirs = array("/product/temp"); - // Dependancies - $this->depends = array(); - $this->requiredby = array(); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Config pages $this->config_page_url = array("product.php@product"); diff --git a/htdocs/core/modules/modSkype.class.php b/htdocs/core/modules/modSkype.class.php index d84520318a3..4a8b3013fe0 100644 --- a/htdocs/core/modules/modSkype.class.php +++ b/htdocs/core/modules/modSkype.class.php @@ -59,31 +59,26 @@ class modSkype extends DolibarrModules $this->dirs = array(); // Config pages - //------------- $this->config_page_url = array(); - // Dependancies - //------------- - $this->hidden = ! empty($conf->global->MODULE_SKYPE_DISABLED); // A condition to disable module - $this->depends = array('modSociete'); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + // Dependencies + $this->hidden = ! empty($conf->global->MODULE_SKYPE_DISABLED); // A condition to hide module + $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array(); // Constants - //----------- // New pages on tabs - // ----------------- $this->tabs = array(); // Boxes - //------ $this->boxes = array(); // Main menu entries - //------------------ $this->menu = array(); } } From 243bc49a9028df7805ac4e56c09a4979fc113173 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 10 Jul 2018 09:38:05 +0200 Subject: [PATCH 142/228] Docs : Typo --- htdocs/core/modules/modSkype.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modSkype.class.php b/htdocs/core/modules/modSkype.class.php index 4a8b3013fe0..84a55ac365f 100644 --- a/htdocs/core/modules/modSkype.class.php +++ b/htdocs/core/modules/modSkype.class.php @@ -25,7 +25,7 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; /** - * Class to describe a Cron module + * Class to describe a Skype module */ class modSkype extends DolibarrModules { From 0d10722a7fc48efce5e1bcec6ce5e83fe4ab63ef Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 10 Jul 2018 14:57:23 +0200 Subject: [PATCH 143/228] Docs : Update and complete --- htdocs/core/modules/modSociete.class.php | 7 +++++-- htdocs/core/modules/modStock.class.php | 7 +++++-- htdocs/core/modules/modStripe.class.php | 3 ++- .../core/modules/modSupplierProposal.class.php | 16 +++++++++++----- htdocs/core/modules/modSyslog.class.php | 7 +++++-- htdocs/core/modules/modTax.class.php | 8 +++++--- 6 files changed, 33 insertions(+), 15 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 9d9c0268e2d..5b40ea235a6 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -66,8 +66,11 @@ class modSociete extends DolibarrModules $this->dirs = array("/societe/temp"); // Dependencies - $this->depends = array(); - $this->requiredby = array("modExpedition","modFacture","modFournisseur","modFicheinter","modPropale","modContrat","modCommande"); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array("modExpedition","modFacture","modFournisseur","modFicheinter","modPropale","modContrat","modCommande"); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("companies",'bills'); // Constants diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index ff767dd3658..9622e087699 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -65,8 +65,11 @@ class modStock extends DolibarrModules $this->config_page_url = array("stock.php"); // Dependencies - $this->depends = array("modProduct"); - $this->requiredby = array("modProductBatch"); + $this->hidden = false; // A condition to hide module + $this->depends = array("modProduct"); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array("modProductBatch"); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("stocks"); // Constants diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index e5b481f4daa..1f6f1e92f05 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -65,10 +65,11 @@ class modStripe extends DolibarrModules // Data directories to create when module is enabled. $this->dirs = array(); - // Config pages. Put here list of php page names stored in admmin directory used to setup module. + // Config pages. Put here list of php page names stored in admin directory used to setup module. $this->config_page_url = array("stripe.php@stripe"); // Dependencies + $this->hidden = false; // A condition to hide module $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(5,4); // Minimum version of PHP required by module diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index fa7553fd6df..bb3cda6a837 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -57,13 +57,19 @@ class modSupplierProposal extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto='supplier_proposal'; - + + // Data directories to create when module is enabled. $this->dirs = array(); + + // Config pages. Put here list of php page names stored in admin directory used to setup module. + $this->config_page_url = array("supplier_proposal.php"); - // Dependancies - $this->depends = array('modFournisseur'); - $this->requiredby = array(); - $this->config_page_url = array("supplier_proposal.php"); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array('modFournisseur'); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("supplier_proposal"); // Constants diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php index fca192f5ec0..0274eeb2e63 100644 --- a/htdocs/core/modules/modSyslog.class.php +++ b/htdocs/core/modules/modSyslog.class.php @@ -67,8 +67,11 @@ class modSyslog extends DolibarrModules $this->config_page_url = array("syslog.php"); // Dependencies - $this->depends = array(); - $this->requiredby = array(); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module // Constants $this->const = array(); diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index f3fa7d4e9db..e3b49bba016 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -67,9 +67,11 @@ class modTax extends DolibarrModules $this->config_page_url = array("taxes.php"); // Dependencies - $this->depends = array(); - $this->requiredby = array(); - $this->conflictwith = array(); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("compta","bills"); // Constants From 2f2ca16e2b4d0eb1d0e74e5cc080d3797ab768b0 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 10 Jul 2018 16:44:14 +0200 Subject: [PATCH 144/228] Add DELETE Trigger action into admin event agenda log --- htdocs/install/mysql/data/llx_c_action_trigger.sql | 11 +++++++++++ htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 35077eb5bc5..435d98a7a88 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -36,25 +36,30 @@ delete from llx_c_action_trigger; -- actions enabled by default (constant created for that) when we enable module agenda insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('COMPANY_CREATE','Third party created','Executed when a third party is created','societe',1); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('COMPANY_DELETE','Third party deleted','Executed when you delete third party','societe',1); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_VALIDATE','Customer proposal validated','Executed when a commercial proposal is validated','propal',2); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal',3); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_CLOSE_SIGNED','Customer proposal closed signed','Executed when a customer proposal is closed signed','propal',2); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_CLOSE_REFUSED','Customer proposal closed refused','Executed when a customer proposal is closed refused','propal',2); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_CLASSIFY_BILLED','Customer proposal set billed','Executed when a customer proposal is set to billed','propal',2); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_DELETE','Customer proposal deleted','Executed when a customer proposal is deleted','propal',2); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_VALIDATE','Customer order validate','Executed when a customer order is validated','commande',4); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_CLOSE','Customer order classify delivered','Executed when a customer order is set delivered','commande',5); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_CLASSIFY_BILLED','Customer order classify billed','Executed when a customer order is set to billed','commande',5); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_CANCEL','Customer order canceled','Executed when a customer order is canceled','commande',5); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SENTBYMAIL','Customer order sent by mail','Executed when a customer order is sent by mail ','commande',5); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_DELETE','Customer order deleted','Executed when a customer order is deleted','commande',5); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_VALIDATE','Customer invoice validated','Executed when a customer invoice is approved','facture',6); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_PAYED','Customer invoice payed','Executed when a customer invoice is payed','facture',7); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_CANCEL','Customer invoice canceled','Executed when a customer invoice is conceled','facture',8); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SENTBYMAIL','Customer invoice sent by mail','Executed when a customer invoice is sent by mail','facture',9); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_UNVALIDATE','Customer invoice unvalidated','Executed when a customer invoice status set back to draft','facture',9); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_DELETE','Customer invoice deleted','Executed when a customer invoice is deleted','facture',9); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_VALIDATE','Price request validated','Executed when a commercial proposal is validated','proposal_supplier',10); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_SENTBYMAIL','Price request sent by mail','Executed when a commercial proposal is sent by mail','proposal_supplier',10); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_CLOSE_SIGNED','Price request closed signed','Executed when a customer proposal is closed signed','proposal_supplier',10); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_CLOSE_REFUSED','Price request closed refused','Executed when a customer proposal is closed refused','proposal_supplier',10); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_DELETE','Price request deleted','Executed when a customer proposal delete','proposal_supplier',10); --insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_CREATE','Supplier order created','Executed when a supplier order is created','order_supplier',11); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_VALIDATE','Supplier order validated','Executed when a supplier order is validated','order_supplier',12); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_APPROVE','Supplier order request approved','Executed when a supplier order is approved','order_supplier',13); @@ -63,15 +68,19 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_REFUSE','Supplier order request refused','Executed when a supplier order is refused','order_supplier',13); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_SENTBYMAIL','Supplier order sent by mail','Executed when a supplier order is sent by mail','order_supplier',14); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_CLASSIFY_BILLED','Supplier order set billed','Executed when a supplier order is set as billed','order_supplier',14); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_DELETE','Supplier order deleted','Executed when a supplier order is deleted','order_supplier',14); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_VALIDATE','Supplier invoice validated','Executed when a supplier invoice is validated','invoice_supplier',15); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_UNVALIDATE','Supplier invoice unvalidated','Executed when a supplier invoice status is set back to draft','invoice_supplier',15); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_PAYED','Supplier invoice payed','Executed when a supplier invoice is payed','invoice_supplier',16); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_SENTBYMAIL','Supplier invoice sent by mail','Executed when a supplier invoice is sent by mail','invoice_supplier',17); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_CANCELED','Supplier invoice cancelled','Executed when a supplier invoice is cancelled','invoice_supplier',17); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_DELETE','Supplier invoice deleted','Executed when a supplier invoice is deleted','invoice_supplier',17); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat',18); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_SENTBYMAIL','Contract sent by mail','Executed when a contract is sent by mail','contrat',18); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_DELETE','Contract deleted','Executed when a contract is deleted','contrat',18); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping',20); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping',21); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_DELETE','Shipping sent is deleted','Executed when a shipping is deleted','shipping',21); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_VALIDATE','Member validated','Executed when a member is validated','member',22); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SENTBYMAIL','Mails sent from member card','Executed when you send email from member card','member',23); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION_CREATE','Member subscribtion recorded','Executed when a member subscribtion is deleted','member',24); @@ -84,12 +93,14 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_CLASSIFY_UNBILLED','Intervention set unbilled','Executed when a intervention is set to unbilled (when option FICHINTER_CLASSIFY_BILLED is set)','ficheinter',33); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_REOPEN','Intervention opened','Executed when a intervention is re-opened','ficheinter',34); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',35); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_DELETE','Intervention is deleted','Executed when a intervention is deleted','ficheinter',35); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',40); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',42); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expensereport',204); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_DELETE','Expense report deleted','Executed when an expense report is deleted','expensereport',204); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_VALIDATE','Project validation','Executed when a project is validated','project',141); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_DELETE','Project deleted','Executed when a project is deleted','project',143); -- actions not enabled by default (no constant created for that) when we enable module agenda diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 3f5c57e1ad0..87ada98390b 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -37,3 +37,15 @@ ALTER TABLE llx_user ADD COLUMN dateemploymentend date after dateemployment; ALTER TABLE llx_c_field_list ADD COLUMN visible tinyint DEFAULT 1 NOT NULL AFTER search; + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('COMPANY_DELETE','Third party deleted','Executed when you delete third party','societe',1); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_DELETE','Customer proposal deleted','Executed when a customer proposal is deleted','propal',2); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_DELETE','Customer order deleted','Executed when a customer order is deleted','commande',5); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_DELETE','Customer invoice deleted','Executed when a customer invoice is deleted','facture',9); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_DELETE','Price request deleted','Executed when a customer proposal delete','proposal_supplier',10); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_DELETE','Supplier order deleted','Executed when a supplier order is deleted','order_supplier',14); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_DELETE','Supplier invoice deleted','Executed when a supplier invoice is deleted','invoice_supplier',17); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_DELETE','Contract deleted','Executed when a contract is deleted','contrat',18); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_DELETE','Intervention is deleted','Executed when a intervention is deleted','ficheinter',35); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_DELETE','Expense report deleted','Executed when an expense report is deleted','expensereport',204); + From 72adc485f090d67aec1c0a6f6fd5821433c2a220 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 10 Jul 2018 22:32:55 +0200 Subject: [PATCH 145/228] Docs : Update and complete --- htdocs/core/modules/modTax.class.php | 3 --- htdocs/core/modules/modTicket.class.php | 13 ++++++------- htdocs/core/modules/modUser.class.php | 13 ++++++------- htdocs/core/modules/modVariants.class.php | 10 ++++------ htdocs/core/modules/modWebServices.class.php | 16 ++++++---------- .../core/modules/modWebServicesClient.class.php | 15 ++++++--------- htdocs/core/modules/modWebsite.class.php | 8 ++------ htdocs/core/modules/modWorkflow.class.php | 8 +++++--- 8 files changed, 35 insertions(+), 51 deletions(-) diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index e3b49bba016..91ed84366de 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -119,13 +119,10 @@ class modTax extends DolibarrModules // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports - //-------- $r=0; $r++; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 01c10a631ca..bc871d9c0e0 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -95,12 +95,11 @@ class modTicket extends DolibarrModules $this->config_page_url = array("ticket.php"); // Dependencies - // List of modules id that must be enabled if this module is enabled - $this->depends = array(); - // List of modules id to disable if this one is disabled - $this->requiredby = array(); - // Minimum version of PHP required by module - $this->phpmin = array(5, 3); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("ticket"); // Constants // List of particular constants to add when module is enabled @@ -115,7 +114,7 @@ class modTicket extends DolibarrModules 'project:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?projectid=__ID__', ); - // Dictionnaries + // Dictionaries if (! isset($conf->ticket->enabled)) { $conf->ticket=new stdClass(); $conf->ticket->enabled=0; diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 1c4a08411ad..19e146a6e8c 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -63,9 +63,12 @@ class modUser extends DolibarrModules // Config pages $this->config_page_url = array("user.php"); - // Dependancies - $this->depends = array(); - $this->requiredby = array(); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("main","users","companies","members",'salaries'); $this->always_enabled = true; // Can't be disabled @@ -205,13 +208,10 @@ class modUser extends DolibarrModules // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports - //-------- $r=0; $r++; @@ -244,7 +244,6 @@ class modUser extends DolibarrModules $this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user').')'; // Imports - //-------- $r=0; // Import list of users attributes diff --git a/htdocs/core/modules/modVariants.class.php b/htdocs/core/modules/modVariants.class.php index c56f5c0e49a..19c50d8843e 100644 --- a/htdocs/core/modules/modVariants.class.php +++ b/htdocs/core/modules/modVariants.class.php @@ -79,12 +79,10 @@ class modVariants extends DolibarrModules // Dependencies $this->hidden = false; // A condition to hide module - $this->depends = array( - 'modProduct' - ); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->phpmin = array(5,0); // Minimum version of PHP required by module + $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("products"); diff --git a/htdocs/core/modules/modWebServices.class.php b/htdocs/core/modules/modWebServices.class.php index 8963f81813f..a3e9510563f 100644 --- a/htdocs/core/modules/modWebServices.class.php +++ b/htdocs/core/modules/modWebServices.class.php @@ -55,30 +55,26 @@ class modWebServices extends DolibarrModules $this->dirs = array(); // Config pages - //------------- $this->config_page_url = array("index.php@webservices"); - // Dependancies - //------------- - $this->depends = array(); - $this->requiredby = array(); - //$this->phpmax = array(7,1); // Maximum version of PHP required by module + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("other"); // Constants - //----------- $this->const = array(); // New pages on tabs - // ----------------- $this->tabs = array(); // Boxes - //------ $this->boxes = array(); // Permissions - //------------ $this->rights = array(); $this->rights_class = 'webservices'; $r=0; diff --git a/htdocs/core/modules/modWebServicesClient.class.php b/htdocs/core/modules/modWebServicesClient.class.php index 9b6535143b3..35c4da5b037 100644 --- a/htdocs/core/modules/modWebServicesClient.class.php +++ b/htdocs/core/modules/modWebServicesClient.class.php @@ -55,29 +55,26 @@ class modWebServicesClient extends DolibarrModules $this->dirs = array(); // Config pages - //------------- //$this->config_page_url = array(); - // Dependancies - //------------- - $this->depends = array(); - $this->requiredby = array(); + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("other"); // Constants - //----------- $this->const = array(); // New pages on tabs - // ----------------- $this->tabs = array(); // Boxes - //------ $this->boxes = array(); // Permissions - //------------ $this->rights = array(); $this->rights_class = 'syncsupplierwebservices'; $r=0; diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index fb6e91283db..f684985917a 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -61,27 +61,23 @@ class modWebsite extends DolibarrModules $this->dirs = array("/website/temp"); // Config pages - //------------- $this->config_page_url = array('website.php'); - // Dependancies - //------------- + // Dependencies $this->hidden = ! empty($conf->global->MODULE_WEBSITE_DISABLED); // A condition to disable module $this->depends = array('modFckeditor'); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->langfiles = array("website"); // Constants - //----------- $this->const = array(); // New pages on tabs - // ----------------- //$this->tabs[] = array(); // To add a new tab identified by code tabname1 // Boxes - //------ $this->boxes = array(); // Permissions diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index e721513073a..882e8aebf53 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -68,9 +68,11 @@ class modWorkflow extends DolibarrModules $this->config_page_url = array('workflow.php'); // Dependencies - $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(5,2); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(2,8); // Minimum version of Dolibarr required by module $this->langfiles = array("@workflow"); From 4c65f4d498ee1b250c9e713856557fc16d6a1baf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Jul 2018 09:38:40 +0200 Subject: [PATCH 146/228] Log --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1cce0c38772..4a65754e975 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5154,7 +5154,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $buyer_country_code = $thirdparty_buyer->country_code; $buyer_in_cee = isInEEC($thirdparty_buyer); - dol_syslog("get_default_tva: seller use vat=".$seller_use_vat.", seller country=".$seller_country_code.", seller in cee=".$seller_in_cee.", buyer country=".$buyer_country_code.", buyer in cee=".$buyer_in_cee.", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)?$conf->global->SERVICES_ARE_ECOMMERCE_200238EC:'')); + dol_syslog("get_default_tva: seller use vat=".$seller_use_vat.", seller country=".$seller_country_code.", seller in cee=".$seller_in_cee.", buyer vat number=".$thirdparty_buyer->tva_intra." buyer country=".$buyer_country_code.", buyer in cee=".$buyer_in_cee.", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)?$conf->global->SERVICES_ARE_ECOMMERCE_200238EC:'')); // If services are eServices according to EU Council Directive 2002/38/EC (http://ec.europa.eu/taxation_customs/taxation/vat/traders/e-commerce/article_1610_en.htm) // we use the buyer VAT. From 076bf0a3a709ee29d74ec423980eadd2a4ffd710 Mon Sep 17 00:00:00 2001 From: ias-ceo Date: Thu, 12 Jul 2018 05:09:36 +0300 Subject: [PATCH 147/228] fix sql error --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1cce0c38772..e5def24be2d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7576,7 +7576,7 @@ function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield=' { $dictvalues[$tablename] = array(); $sql = 'SELECT * FROM '.$tablename.' WHERE 1'; - if ($checkentity) $sql.= ' entity IN (0,'.getEntity('').')'; + if ($checkentity) $sql.= ' and entity IN (0,'.getEntity('').')'; $resql = $db->query($sql); if ($resql) From 740f35966ce8f81b47d3e73996d5eb396bad8eff Mon Sep 17 00:00:00 2001 From: ias-ceo Date: Thu, 12 Jul 2018 05:15:09 +0300 Subject: [PATCH 148/228] installation default port number if missing --- htdocs/filefunc.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index ce83e3a3460..18c5dd4962a 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -130,8 +130,8 @@ $dolibarr_main_url_root_alt=(empty($dolibarr_main_url_root_alt)?'':trim($dolibar $dolibarr_main_document_root=trim($dolibarr_main_document_root); $dolibarr_main_document_root_alt=(empty($dolibarr_main_document_root_alt)?'':trim($dolibarr_main_document_root_alt)); -if (empty($dolibarr_main_db_port)) $dolibarr_main_db_port=0; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' -if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysqli'; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' +if (empty($dolibarr_main_db_port)) $dolibarr_main_db_port=3306; // For compatibility with old configs, if not defined, we take 'mysql' type +if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysqli'; // For compatibility with old configs, if not defined, we take 'mysql' type // Mysql driver support has been removed in favor of mysqli if ($dolibarr_main_db_type == 'mysql') $dolibarr_main_db_type = 'mysqli'; From 6945680e03af6e75809eeef3877b91e473bfbf6d Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 12 Jul 2018 10:11:42 +0200 Subject: [PATCH 149/228] update code and typo --- htdocs/core/modules/DolibarrModules.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 562f9eed374..d222e54703a 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -337,7 +337,7 @@ class DolibarrModules // Can not be abstract, because we need to insta /** * @var array() Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.3 = array(5, 3) + * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin; @@ -464,7 +464,7 @@ class DolibarrModules // Can not be abstract, because we need to insta } /** - * Disable function. Deletes the module constant and boxes from the database. + * Disable function. Deletes the module constants and boxes from the database. * * @param string[] $array_sql SQL requests to be executed when module is disabled * @param string $options Options when disabling module: @@ -553,7 +553,7 @@ class DolibarrModules // Can not be abstract, because we need to insta } else { - // If module name translation using it's unique id does not exists, we try to use its name to find translation + // If module name translation using it's unique id does not exist, we try to use its name to find translation if (is_array($this->langfiles)) { foreach($this->langfiles as $val) @@ -613,9 +613,9 @@ class DolibarrModules // Can not be abstract, because we need to insta /** * Gives the long description of a module. First check README-la_LA.md then README.md - * If not markdown files found, it return translated value of the key ->descriptionlong. + * If no markdown files found, it returns translated value of the key ->descriptionlong. * - * @return string Long description of a module from README.md of from property. + * @return string Long description of a module from README.md of from property. */ function getDescLong() { From 52dee71b392e4bb1349dfa6d138333d6fa7bb403 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Jul 2018 18:05:33 +0200 Subject: [PATCH 150/228] Responsive --- htdocs/product/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 47135d22a15..385187b316e 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -764,7 +764,7 @@ if ($resql) // Sell price if (! empty($arrayfields['p.sellprice']['checked'])) { - print ''; + print ''; if ($obj->tosell) { if ($obj->price_base_type == 'TTC') print price($obj->price_ttc).' '.$langs->trans("TTC"); @@ -777,7 +777,7 @@ if ($resql) // Better buy price if (! empty($arrayfields['p.minbuyprice']['checked'])) { - print ''; + print ''; if ($obj->tobuy && $obj->minsellprice != '') { //print price($obj->minsellprice).' '.$langs->trans("HT"); From 1fa13fc7478bae4c5945f13a15b73a1fed22f87e Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 12 Jul 2018 18:27:09 +0200 Subject: [PATCH 151/228] fix list of event unformize code --- htdocs/core/lib/company.lib.php | 50 ++---------------------------- htdocs/core/lib/functions2.lib.php | 6 +++- 2 files changed, 8 insertions(+), 48 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index ea91c4796d2..4118bf0746c 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1478,10 +1478,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); @@ -1490,12 +1487,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $userstatic=new User($db); $contactstatic = new Contact($db); - // TODO mutualize/uniformize - $propalstatic=new Propal($db); - $orderstatic=new Commande($db); - $supplierorderstatic=new CommandeFournisseur($db); - $facturestatic=new Facture($db); - $out.='
'; if ($objcon && get_class($objcon) == 'Contact' && $filterobj && get_class($filterobj) == 'Societe') { @@ -1656,45 +1647,10 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= //$out.=''.dol_trunc($histo[$key]['note'], 40).''; // Objet lie - // TODO mutualize/uniformize $out.=''; - //var_dump($histo[$key]['elementtype']); - if (isset($histo[$key]['elementtype'])) + if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) { - if ($histo[$key]['elementtype'] == 'propal' && ! empty($conf->propal->enabled)) - { - //$propalstatic->ref=$langs->trans("ProposalShort"); - //$propalstatic->id=$histo[$key]['fk_element']; - if ($propalstatic->fetch($histo[$key]['fk_element'])>0) { - $propalstatic->type=$histo[$key]['ftype']; - $out.=$propalstatic->getNomUrl(1); - } else { - //$out.= ''.$langs->trans("ProposalDeleted").''; - } - } - elseif (($histo[$key]['elementtype'] == 'order' || $histo[$key]['elementtype'] == 'commande') && ! empty($conf->commande->enabled)) - { - //$orderstatic->ref=$langs->trans("Order"); - //$orderstatic->id=$histo[$key]['fk_element']; - if ($orderstatic->fetch($histo[$key]['fk_element'])>0) { - $orderstatic->type=$histo[$key]['ftype']; - $out.=$orderstatic->getNomUrl(1); - } else { - //$out.= ''.$langs->trans("OrderDeleted").''; - } - } - elseif (($histo[$key]['elementtype'] == 'invoice' || $histo[$key]['elementtype'] == 'facture') && ! empty($conf->facture->enabled)) - { - //$facturestatic->ref=$langs->trans("Invoice"); - //$facturestatic->id=$histo[$key]['fk_element']; - if ($facturestatic->fetch($histo[$key]['fk_element'])>0) { - $facturestatic->type=$histo[$key]['ftype']; - $out.=$facturestatic->getNomUrl(1,'compta'); - } else { - //$out.= ''.$langs->trans("InvoiceDeleted").''; - } - } - else $out.=' '; + $out.=dolGetElementUrl($histo[$key]['fk_element'],$histo[$key]['elementtype'],1); } else $out.=' '; $out.=''; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index c95deeef81f..5fd565fb191 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1865,7 +1865,11 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') { $object = new $classname($db); $res=$object->fetch($objectid); - if ($res > 0) $ret=$object->getNomUrl($withpicto,$option); + if ($res > 0) { + $ret=$object->getNomUrl($withpicto,$option); + } elseif($res==0) { + $ret=$langs->trans('Deleted'); + } unset($object); } else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); From e1dabe3924d4b2d31e19f351616b8e25641cdf13 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Jul 2018 16:07:19 +0200 Subject: [PATCH 152/228] NEW add agenda documents in API REST --- htdocs/api/class/api_documents.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 07f124741fe..66c293f2cb0 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -356,6 +356,22 @@ class Documents extends DolibarrApi $upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); } + else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') + { + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + + if (!DolibarrApiAccess::$user->rights->agenda->myactions->read && !DolibarrApiAccess::$user->rights->agenda->allactions->read) { + throw new RestException(401); + } + + $object = new ActionComm($this->db); + $result=$object->fetch($id, $ref); + if ( ! $result ) { + throw new RestException(404, 'Event not found'); + } + + $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); + } else { throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); From 988b6a49d26d5926aed7a8cef048686a9501a345 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Jul 2018 18:40:54 +0200 Subject: [PATCH 153/228] Fix warning php 7.3 --- dev/dolibarr_changes.txt | 17 +++++++++++++++++ htdocs/includes/tecnickcom/tcpdf/tcpdf.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index cdbc2e2bb40..6303eaafaae 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -48,6 +48,23 @@ into // initialize subsetchars $subsetchars = array_fill(0, 256, true); +* Replace the continue into switch with a break: + +case 're': { + // justify block + if (!TCPDF_STATIC::empty_string($this->lispacer)) { + $this->lispacer = ''; + continue; + } + +into +case 're': { + // justify block + if (!TCPDF_STATIC::empty_string($this->lispacer)) { + $this->lispacer = ''; + break; + } + * Optionnaly, removed all fonts except dejavusans* (used by greek, arab, persan, romanian, turkish), freemono* (russian), diff --git a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php index ef411a17dee..3cdfff4f227 100644 --- a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php +++ b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php @@ -17783,7 +17783,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: // justify block if (!TCPDF_STATIC::empty_string($this->lispacer)) { $this->lispacer = ''; - continue; + break; } preg_match('/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s](re)([\s]*)/x', $pmid, $xmatches); if (!isset($xmatches[1])) { From 9ae7e55fea11ed2e9abb1cbe4a9916fb21943738 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 13 Jul 2018 19:54:37 +0200 Subject: [PATCH 154/228] fix: breaking link --- htdocs/core/class/notify.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 698eca5fd21..f9c7fe6467c 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -573,13 +573,13 @@ class Notify $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$link); break; case 'PROPAL_VALIDATE': - $link='/comm/propal/card.php?id='.$object->id; + $link='' . $newref . ''; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$link); break; case 'PROPAL_CLOSE_SIGNED': - $link='/comm/propal/card.php?id='.$object->id; + $link='' . $newref . ''; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$link); From a45ac4519ac3f999c9f80cd677341c3bea2f1b70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Jul 2018 18:03:31 +0200 Subject: [PATCH 155/228] Fix translation --- htdocs/langs/en_US/ticket.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 6cc31a25bfd..d6038255c92 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -138,7 +138,7 @@ TicketStatByStatus=Tickets by status # # Ticket card # -Ticket=Incident ticket +Ticket=Ticket TicketCard=Ticket card CreateTicket=Create ticket EditTicket=Edit ticket From 20e360e918f378d0e1e95a3ffa1cb96f6490c06c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Jul 2018 18:22:26 +0200 Subject: [PATCH 156/228] Start to introduce array fields for products --- htdocs/product/class/product.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c271346d4bc..e81326e6742 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -300,6 +300,23 @@ class Product extends CommonObject public $price_autogen = 0; + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'note' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), + 'fk_user_author'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), + //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), + ); + /** * Regular product */ From 0ca9f6f52234f0e1db482bc5201b8406d0823a7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Jul 2018 20:00:43 +0200 Subject: [PATCH 157/228] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e5def24be2d..a3e1ac50e18 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7576,7 +7576,7 @@ function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield=' { $dictvalues[$tablename] = array(); $sql = 'SELECT * FROM '.$tablename.' WHERE 1'; - if ($checkentity) $sql.= ' and entity IN (0,'.getEntity('').')'; + if ($checkentity) $sql.= ' AND entity IN (0,'.getEntity('').')'; $resql = $db->query($sql); if ($resql) From a5442033ac1795fd3e69fdf80f844ae6b41fbc93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Jul 2018 20:09:51 +0200 Subject: [PATCH 158/228] Code comment --- htdocs/core/lib/functions2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index e7eb9eb259d..0ba249e03ef 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1760,7 +1760,7 @@ function getSoapParams() /** - * List urls of element + * Return link url to an object * * @param int $objectid Id of record * @param string $objecttype Type of object ('invoice', 'order', 'expedition_bon', ...) From bd9149e03bf84061f93a529f76faf84549fd390b Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 16 Jul 2018 07:28:22 +0200 Subject: [PATCH 159/228] more minor grammar corrections --- htdocs/langs/en_US/admin.lang | 36 +++++++-------- htdocs/langs/en_US/banks.lang | 2 +- htdocs/langs/en_US/bills.lang | 10 ++--- htdocs/langs/en_US/boxes.lang | 44 +++++++++--------- htdocs/langs/en_US/categories.lang | 2 +- htdocs/langs/en_US/companies.lang | 64 +++++++++++++-------------- htdocs/langs/en_US/compta.lang | 2 +- htdocs/langs/en_US/cron.lang | 2 +- htdocs/langs/en_US/ecm.lang | 2 +- htdocs/langs/en_US/exports.lang | 40 ++++++++--------- htdocs/langs/en_US/interventions.lang | 4 +- htdocs/langs/en_US/mails.lang | 10 ++--- htdocs/langs/en_US/main.lang | 12 ++--- htdocs/langs/en_US/opensurvey.lang | 2 +- htdocs/langs/en_US/orders.lang | 2 +- htdocs/langs/en_US/other.lang | 6 +-- htdocs/langs/en_US/products.lang | 6 +-- htdocs/langs/en_US/projects.lang | 8 ++-- htdocs/langs/en_US/sms.lang | 8 ++-- htdocs/langs/en_US/suppliers.lang | 4 +- htdocs/langs/en_US/users.lang | 6 +-- htdocs/langs/en_US/withdrawals.lang | 4 +- 22 files changed, 138 insertions(+), 138 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1b1d07f6cde..fc609ebec68 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -68,8 +68,8 @@ ErrorCodeCantContainZero=Code can't contain value 0 DisableJavascript=Disable JavaScript and Ajax functions (Recommended for blind person or text browsers) UseSearchToSelectCompanyTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant COMPANY_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseSearchToSelectContactTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant CONTACT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. -DelaiedFullListToSelectCompany=Wait until you press a key before loading content of third-parties combo list (This may increase performance if you have a large number of third-parties, but it is less convenient) -DelaiedFullListToSelectContact=Wait until you press a key before loading content of contact combo list (This may increase performance if you have a large number of contacts, but it is less convenient) +DelaiedFullListToSelectCompany=Wait until a key is pressed before loading content of Third Parties combo list.
This may increase performance if you have a large number of third parties, but it is less convenient. +DelaiedFullListToSelectContact=Wait until a key is pressed before loading content of Contact combo list.
This may increase performance if you have a large number of contacts, but it is less convenient) NumberOfKeyToSearch=Nbr of characters to trigger search: %s NotAvailableWhenAjaxDisabled=Not available when Ajax disabled AllowToSelectProjectFromOtherCompany=On document of a third party, can choose a project linked to another third party @@ -355,7 +355,7 @@ LanguageFile=Language file ExamplesWithCurrentSetup=Examples with current configuration ListOfDirectories=List of OpenDocument templates directories ListOfDirectoriesForModelGenODT=List of directories containing templates files with OpenDocument format.

Put here full path of directories.
Add a carriage return between eah directory.
To add a directory of the GED module, add here DOL_DATA_ROOT/ecm/yourdirectoryname.

Files in those directories must end with .odt or .ods. -NumberOfModelFilesFound=Number of ODT/ODS templates files found in those directories +NumberOfModelFilesFound=Number of ODT/ODS template files found in these directories ExampleOfDirectoriesForModelGen=Examples of syntax:
c:\mydir
/home/mydir
DOL_DATA_ROOT/ecm/ecmdir FollowingSubstitutionKeysCanBeUsed=
To know how to create your odt document templates, before storing them in those directories, read wiki documentation: FullListOnOnlineDocumentation=http://wiki.dolibarr.org/index.php/Create_an_ODT_document_template @@ -447,8 +447,8 @@ DisplayCompanyInfo=Display company address DisplayCompanyManagers=Display manager names DisplayCompanyInfoAndManagers=Display company address and manager names EnableAndSetupModuleCron=If you want to have this recurring invoice generated automatically, module *%s* must be enabled and correctly setup. Otherwise, generation of invoices must be done manually from this template using the *Create* button. Note that even if you enabled automatic generation, you can still safely launch manual generation. Generation of duplicates for the same period is not possible. -ModuleCompanyCodeCustomerAquarium=%s followed by third party customer code for a customer accounting code -ModuleCompanyCodeSupplierAquarium=%s followed by third party supplier code for a supplier accounting code +ModuleCompanyCodeCustomerAquarium=%s followed by customer code for a customer accounting code +ModuleCompanyCodeSupplierAquarium=%s followed by supplier code for a supplier accounting code ModuleCompanyCodePanicum=Return an empty accounting code. ModuleCompanyCodeDigitaria=Accounting code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code. Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).
Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required. @@ -478,7 +478,7 @@ DAVSetup=Setup of module DAV DAV_ALLOW_PUBLIC_DIR=Enable the public directory (WebDav directory with no login required) DAV_ALLOW_PUBLIC_DIRTooltip=The WebDav public directory is a WebDAV directory everybody can access to (in read and write mode), with no need to have/use an existing login/password account. # Modules -Module0Name=Users & groups +Module0Name=Users & Groups Module0Desc=Users / Employees and Groups management Module1Name=Third Parties Module1Desc=Companies and contact management (customers, prospects...) @@ -528,7 +528,7 @@ Module75Name=Expense and trip notes Module75Desc=Expense and trip notes management Module80Name=Shipments Module80Desc=Shipments and delivery order management -Module85Name=Banks and cash +Module85Name=Banks and Cash Module85Desc=Management of bank or cash accounts Module100Name=External Site Module100Desc=Add external website link into Dolibarr menus to view it in a Dolibarr frame @@ -920,7 +920,7 @@ DictionaryExpenseTaxRange=Expense report - Range by transportation category SetupSaved=Setup saved SetupNotSaved=Setup not saved BackToModuleList=Back to modules list -BackToDictionaryList=Back to dictionaries list +BackToDictionaryList=Back to list of Dictionaries TypeOfRevenueStamp=Type of tax stamp VATManagement=VAT Management VATIsUsedDesc=By default when creating prospects, invoices, orders etc. the VAT rate follows the active standard rule:
If the seller is not subject to VAT, then VAT defaults to 0. End of rule.

If the (seller's country = buyer's country), then the VAT by default equals the VAT of the product in the seller's country. End of rule.

If the seller and buyer are both in the European Community and goods are transport-related products (haulage, shipping, airline), the default VAT is 0. This rule is dependant on the seller's country - please consult with your accountant. The VAT should be paid by the buyer to their customs office in their country and not to the seller. End of rule.

If the seller and buyer are both in the European Community and the buyer is not a company (with a registered intra-Community VAT number) then the VAT by defaults to the VAT of the seller's country. End of rule.

If the seller and buyer are both in the European Community and the buyer is a company (with a registered intra-Community VAT number), then the VAT is 0 by default. End of rule.

In any other case the proposed default is VAT=0. End of rule.

@@ -961,7 +961,7 @@ CalcLocaltax3Desc=Local Taxes reports are the total of localtaxes sales LabelUsedByDefault=Label used by default if no translation can be found for code LabelOnDocuments=Label on documents LabelOrTranslationKey=Label or translation key -NbOfDays=Nb of days +NbOfDays=No. of days AtEndOfMonth=At end of month CurrentNext=Current/Next Offset=Offset @@ -987,7 +987,7 @@ DatabaseUser=Database user DatabasePassword=Database password Tables=Tables TableName=Table name -NbOfRecord=Nb of records +NbOfRecord=No. of records Host=Server DriverType=Driver type SummarySystem=System information summary @@ -1178,8 +1178,8 @@ BrowserIsOK=You are using the %s web browser. This browser is ok for security an BrowserIsKO=You are using the %s web browser. This browser is known to be a bad choice for security, performance and reliability. We recommend using Firefox, Chrome, Opera or Safari. XDebugInstalled=XDebug is loaded. XCacheInstalled=XCache is loaded. -AddRefInList=Display customer/supplier ref into list (select list or combobox) and most of hyperlink. Third parties will appear with name "CC12345 - SC45678 - The big company coorp", instead of "The big company corp". -AskForPreferredShippingMethod=Ask for preferred Sending Method for Third Parties. +AddRefInList=Display Customer/Supplier ref. info list (select list or combobox) and most of hyperlink.
Third Parties will appear with a name format of "CC12345 - SC45678 - The Big Company corp." instead of "The Big Company corp". +AskForPreferredShippingMethod=Ask for preferred sending method for Third Parties. FieldEdition=Edition of field %s FillThisOnlyIfRequired=Example: +2 (fill only if timezone offset problems are experienced) GetBarCode=Get barcode @@ -1198,17 +1198,17 @@ UserMailRequired=EMail required to create a new user HRMSetup=HRM module setup ##### Company setup ##### CompanySetup=Companies module setup -CompanyCodeChecker=Module for third parties code generation and checking (customer or vendor) -AccountCodeManager=Module for accounting code generation (customer or vendor) +CompanyCodeChecker=Options for automatic generation of customer/supplier codes +AccountCodeManager=Options for automatic generation of customer/supplier accounting codes NotificationsDesc=EMails notifications feature allows you to silently send automatic mail, for some Dolibarr events. Targets of notifications can be defined: NotificationsDescUser=* per users, one user at time. NotificationsDescContact=* per third parties contacts (customers or vendors), one contact at time. NotificationsDescGlobal=* or by setting global target emails in module setup page. -ModelModules=Documents templates -DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT or .ODS files for OpenOffice, KOffice, TextEdit,...) +ModelModules=Document Templates +DocumentModelOdt=Generate documents from OpenDocument templates (.ODT / .ODS files from LibreOffice, OpenOffice, KOffice, TextEdit,...) WatermarkOnDraft=Watermark on draft document JSOnPaimentBill=Activate feature to autofill payment lines on payment form -CompanyIdProfChecker=Rules on Professional Ids +CompanyIdProfChecker=Rules for Professional IDs MustBeUnique=Must be unique? MustBeMandatory=Mandatory to create third parties? MustBeInvoiceMandatory=Mandatory to validate invoices? @@ -1657,7 +1657,7 @@ ProjectsSetup=Project module setup ProjectsModelModule=Project reports document model TasksNumberingModules=Tasks numbering module TaskModelModule=Tasks reports document model -UseSearchToSelectProject=Wait until you press a key before loading content of project combo list (this may improve performance if you have a large number of projects, but it is less convenient) +UseSearchToSelectProject=Wait until a key is pressed before loading content of Project combo list.
This may improve performance if you have a large number of projects, but it is less convenient. ##### ECM (GED) ##### ##### Fiscal Year ##### AccountingPeriods=Accounting periods diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index ac5ba91bbec..9d1ebc47427 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -116,7 +116,7 @@ ConfirmDeleteCheckReceipt=Are you sure you want to delete this check receipt? BankChecks=Bank checks BankChecksToReceipt=Checks awaiting deposit ShowCheckReceipt=Show check deposit receipt -NumberOfCheques=Nb of check +NumberOfCheques=No. of check DeleteTransaction=Delete entry ConfirmDeleteTransaction=Are you sure you want to delete this entry? ThisWillAlsoDeleteBankRecord=This will also delete generated bank entry diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 0768f8c9999..54194358748 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -200,8 +200,8 @@ ConfirmSupplierPayment=Do you confirm this payment input for %s %s? ConfirmValidatePayment=Are you sure you want to validate this payment? No change can be made once payment is validated. ValidateBill=Validate invoice UnvalidateBill=Unvalidate invoice -NumberOfBills=Nb of invoices -NumberOfBillsByMonth=Nb of invoices by month +NumberOfBills=No. of invoices +NumberOfBillsByMonth=No. of invoices per month AmountOfBills=Amount of invoices AmountOfBillsByMonthHT=Amount of invoices by month (net of tax) ShowSocialContribution=Show social/fiscal tax @@ -260,9 +260,9 @@ Repeatables=Templates ChangeIntoRepeatableInvoice=Convert into template invoice CreateRepeatableInvoice=Create template invoice CreateFromRepeatableInvoice=Create from template invoice -CustomersInvoicesAndInvoiceLines=Customer invoices and invoice's lines +CustomersInvoicesAndInvoiceLines=Customer invoices and invoice details CustomersInvoicesAndPayments=Customer invoices and payments -ExportDataset_invoice_1=Customer invoices list and invoice's lines +ExportDataset_invoice_1=Customer invoices and invoice details ExportDataset_invoice_2=Customer invoices and payments ProformaBill=Proforma Bill: Reduction=Reduction @@ -322,7 +322,7 @@ CloneInvoice=Clone invoice ConfirmCloneInvoice=Are you sure you want to clone this invoice %s? DisabledBecauseReplacedInvoice=Action disabled because invoice has been replaced DescTaxAndDividendsArea=This area presents a summary of all payments made for special expenses. Only record with payment during the fixed year are included here. -NbOfPayments=Nb of payments +NbOfPayments=No. of payments SplitDiscount=Split discount in two ConfirmSplitDiscount=Are you sure you want to split this discount of %s %s into 2 lower discounts? TypeAmountOfEachNewDiscount=Input amount for each of two parts: diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 8b3b309dc19..bbb79f99bb0 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - boxes -BoxLoginInformation=Login information +BoxLoginInformation=Login Information BoxLastRssInfos=Rss information BoxLastProducts=Latest %s products/services BoxProductsAlertStock=Stock alerts for products @@ -20,22 +20,22 @@ BoxLastMembers=Latest members BoxFicheInter=Latest interventions BoxCurrentAccounts=Open accounts balance BoxTitleLastRssInfos=Latest %s news from %s -BoxTitleLastProducts=Latest %s modified products/services -BoxTitleProductsAlertStock=Products in stock alert +BoxTitleLastProducts=Products/Services: last %s modified +BoxTitleProductsAlertStock=Products: stock alert BoxTitleLastSuppliers=Latest %s recorded suppliers -BoxTitleLastModifiedSuppliers=Latest %s modified suppliers -BoxTitleLastModifiedCustomers=Latest %s modified customers +BoxTitleLastModifiedSuppliers=Suppliers: last %s modified +BoxTitleLastModifiedCustomers=Customers: last %s modified BoxTitleLastCustomersOrProspects=Latest %s customers or prospects BoxTitleLastCustomerBills=Latest %s customer invoices BoxTitleLastSupplierBills=Latest %s supplier invoices -BoxTitleLastModifiedProspects=Latest %s modified prospects +BoxTitleLastModifiedProspects=Prospects: last %s modified BoxTitleLastModifiedMembers=Latest %s members BoxTitleLastFicheInter=Latest %s modified interventions -BoxTitleOldestUnpaidCustomerBills=Oldest %s unpaid customer invoices -BoxTitleOldestUnpaidSupplierBills=Oldest %s unpaid supplier invoices -BoxTitleCurrentAccounts=Open accounts balances -BoxTitleLastModifiedContacts=Latest %s modified contacts/addresses -BoxMyLastBookmarks=My latest %s bookmarks +BoxTitleOldestUnpaidCustomerBills=Customer Invoices: oldest %s unpaid +BoxTitleOldestUnpaidSupplierBills=Supplier Invoices: oldest %s unpaid +BoxTitleCurrentAccounts=Open Accounts: balances +BoxTitleLastModifiedContacts=Contacts/Addresses: last %s modified +BoxMyLastBookmarks=Bookmarks: last %s BoxOldestExpiredServices=Oldest active expired services BoxLastExpiredServices=Latest %s oldest contacts with active expired services BoxTitleLastActionsToDo=Latest %s actions to do @@ -65,18 +65,18 @@ NoRecordedContracts=No recorded contracts NoRecordedInterventions=No recorded interventions BoxLatestSupplierOrders=Latest supplier orders NoSupplierOrder=No recorded supplier order -BoxCustomersInvoicesPerMonth=Customer invoices per month -BoxSuppliersInvoicesPerMonth=Supplier invoices per month -BoxCustomersOrdersPerMonth=Customer orders per month -BoxSuppliersOrdersPerMonth=Supplier orders per month +BoxCustomersInvoicesPerMonth=Customer Invoices per month +BoxSuppliersInvoicesPerMonth=Supplier Invoices per month +BoxCustomersOrdersPerMonth=Customer Orders per month +BoxSuppliersOrdersPerMonth=Supplier Orders per month BoxProposalsPerMonth=Proposals per month -NoTooLowStockProducts=No product under the low stock limit -BoxProductDistribution=Products/Services distribution -BoxProductDistributionFor=Distribution of %s for %s -BoxTitleLastModifiedSupplierBills=Latest %s modified supplier bills -BoxTitleLatestModifiedSupplierOrders=Latest %s modified supplier orders -BoxTitleLastModifiedCustomerBills=Latest %s modified customer bills -BoxTitleLastModifiedCustomerOrders=Latest %s modified customer orders +NoTooLowStockProducts=No products are under the low stock limit +BoxProductDistribution=Products/Services Distribution +BoxProductDistributionFor=Distribution of %s by %s +BoxTitleLastModifiedSupplierBills=Supplier Invoices: last %s modified +BoxTitleLatestModifiedSupplierOrders=Supplier Orders: last %s modified +BoxTitleLastModifiedCustomerBills=Customer Invoices: last %s modified +BoxTitleLastModifiedCustomerOrders=Customer Orders: last %s modified BoxTitleLastModifiedPropals=Latest %s modified proposals ForCustomersInvoices=Customers invoices ForCustomersOrders=Customers orders diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index c0c8d4c0cef..47b5ea92d12 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -54,7 +54,7 @@ MembersCategoryShort=Members tag/category SuppliersCategoriesShort=Suppliers tags/categories CustomersCategoriesShort=Customers tags/categories ProspectsCategoriesShort=Prospects tags/categories -CustomersProspectsCategoriesShort=Custo./Prosp. categories +CustomersProspectsCategoriesShort=Cust./Prosp. categories ProductsCategoriesShort=Products tags/categories MembersCategoriesShort=Members tags/categories ContactCategoriesShort=Contacts tags/categories diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 87412f5f350..8a720bd422b 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -5,13 +5,13 @@ SelectThirdParty=Select a third party ConfirmDeleteCompany=Are you sure you want to delete this company and all inherited information? DeleteContact=Delete a contact/address ConfirmDeleteContact=Are you sure you want to delete this contact and all inherited information? -MenuNewThirdParty=New third party -MenuNewCustomer=New customer -MenuNewProspect=New prospect -MenuNewSupplier=New vendor +MenuNewThirdParty=new Third Party +MenuNewCustomer=new Customer +MenuNewProspect=new Prospect +MenuNewSupplier=new Vendor MenuNewPrivateIndividual=New private individual NewCompany=New company (prospect, customer, vendor) -NewThirdParty=New third party (prospect, customer, vendor) +NewThirdParty=New Third Party (prospect, customer, vendor) CreateDolibarrThirdPartySupplier=Create a third party (vendor) CreateThirdPartyOnly=Create third party CreateThirdPartyAndContact=Create a third party + a child contact @@ -25,12 +25,12 @@ ThirdPartyContact=Third party contact/address Company=Company CompanyName=Company name AliasNames=Alias name (commercial, trademark, ...) -AliasNameShort=Alias name +AliasNameShort=Alias Name Companies=Companies CountryIsInEEC=Country is inside the European Economic Community -ThirdPartyName=Third party name +ThirdPartyName=Third Party Name ThirdPartyEmail=Third party email -ThirdParty=Third party +ThirdParty=Third Party ThirdParties=Third Parties ThirdPartyProspects=Prospects ThirdPartyProspectsStats=Prospects @@ -38,7 +38,7 @@ ThirdPartyCustomers=Customers ThirdPartyCustomersStats=Customers ThirdPartyCustomersWithIdProf12=Customers with %s or %s ThirdPartySuppliers=Vendors -ThirdPartyType=Third party type +ThirdPartyType=Third Party Type Individual=Private individual ToCreateContactWithSameName=Will create automatically a contact/address with same information as the third party under the third party. In most cases, even if your third party is a physical person, creating a third party alone is enough. ParentCompany=Parent company @@ -75,8 +75,8 @@ Zip=Zip Code Town=City Web=Web Poste= Position -DefaultLang=Language by default -VATIsUsed=Sales tax is used +DefaultLang=Language default +VATIsUsed=Sales tax used VATIsUsedWhenSelling=This defines if this third party includes a sale tax or not when it makes an invoice to its own customers VATIsNotUsed=Sales tax is not used CopyAddressFromSoc=Fill address with third party address @@ -303,12 +303,12 @@ AddThirdParty=Create third party DeleteACompany=Delete a company PersonalInformations=Personal data AccountancyCode=Accounting account -CustomerCode=Customer code -SupplierCode=Vendor code -CustomerCodeShort=Customer code -SupplierCodeShort=Vendor code -CustomerCodeDesc=Customer code, unique for all customers -SupplierCodeDesc=Vendor code, unique for all vendors +CustomerCode=Customer Code +SupplierCode=Vendor Code +CustomerCodeShort=Customer Code +SupplierCodeShort=Vendor Code +CustomerCodeDesc=Customer Code, unique for all customers +SupplierCodeDesc=Vendor Code, unique for all vendors RequiredIfCustomer=Required if third party is a customer or prospect RequiredIfSupplier=Required if third party is a vendor ValidityControledByModule=Validity controlled by module @@ -317,8 +317,8 @@ ProspectToContact=Prospect to contact CompanyDeleted=Company "%s" deleted from database. ListOfContacts=List of contacts/addresses ListOfContactsAddresses=List of contacts/addresses -ListOfThirdParties=List of third parties -ShowCompany=Show third party +ListOfThirdParties=List of Third Parties +ShowCompany=Show Third Party ShowContact=Show contact ContactsAllShort=All (No filter) ContactType=Contact type @@ -333,7 +333,7 @@ NoContactForAnyProposal=This contact is not a contact for any commercial proposa NoContactForAnyContract=This contact is not a contact for any contract NoContactForAnyInvoice=This contact is not a contact for any invoice NewContact=New contact -NewContactAddress=New contact/address +NewContactAddress=new Contact/Address MyContacts=My contacts Capital=Capital CapitalOf=Capital of %s @@ -387,12 +387,12 @@ ExportCardToFormat=Export card to format ContactNotLinkedToCompany=Contact not linked to any third party DolibarrLogin=Dolibarr login NoDolibarrAccess=No Dolibarr access -ExportDataset_company_1=Third parties (Companies / foundations / physical people) and properties -ExportDataset_company_2=Contacts and properties -ImportDataset_company_1=Third parties (Companies / foundations / physical people) and properties -ImportDataset_company_2=Contacts/Addresses (of third parties or not) and attributes -ImportDataset_company_3=Bank accounts of third parties -ImportDataset_company_4=Third parties/Sales representatives (Assign sales representatives users to companies) +ExportDataset_company_1=Third Parties (companies/foundations/physical people) and their properties +ExportDataset_company_2=Contacts and their properties +ImportDataset_company_1=Third Parties (companies/foundations/physical people) and their properties +ImportDataset_company_2=Contacts/Addresses and attributes +ImportDataset_company_3=Bank accounts of Third Parties +ImportDataset_company_4=Third Parties - sales representatives (assign sales representatives/users to companies) PriceLevel=Price level DeliveryAddress=Delivery address AddAddress=Add address @@ -406,12 +406,12 @@ FiscalYearInformation=Fiscal Year FiscalMonthStart=Starting month of the fiscal year YouMustAssignUserMailFirst=You must create an email for this user prior to being able to add an email notification. YouMustCreateContactFirst=To be able to add email notifications, you must first define contacts with valid emails for the third party -ListSuppliersShort=List of vendors -ListProspectsShort=List of prospects -ListCustomersShort=List of customers -ThirdPartiesArea=Third parties and contact area -LastModifiedThirdParties=Latest %s modified third parties -UniqueThirdParties=Total of unique third parties +ListSuppliersShort=List of Vendors +ListProspectsShort=List of Prospects +ListCustomersShort=List of Customers +ThirdPartiesArea=Third Parties/Contacts +LastModifiedThirdParties=Last %s modified Third Parties +UniqueThirdParties=Total of Third Parties InActivity=Open ActivityCeased=Closed ThirdPartyIsClosed=Third party is closed diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 81c8aadf7c8..0f1219e565e 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -132,7 +132,7 @@ NewCheckDeposit=New check deposit NewCheckDepositOn=Create receipt for deposit on account: %s NoWaitingChecks=No checks awaiting deposit. DateChequeReceived=Check reception date -NbOfCheques=Nb of checks +NbOfCheques=No. of checks PaySocialContribution=Pay a social/fiscal tax ConfirmPaySocialContribution=Are you sure you want to classify this social or fiscal tax as paid? DeleteSocialContribution=Delete a social or fiscal tax payment diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 43fe8aecc36..92d43edc7c1 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -42,7 +42,7 @@ CronModule=Module CronNoJobs=No jobs registered CronPriority=Priority CronLabel=Label -CronNbRun=Nb. launch +CronNbRun=No. launches CronMaxRun=Max number launch CronEach=Every JobFinished=Job launched and finished diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index 38f9425c4d1..1c89de928ca 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - ecm -ECMNbOfDocs=Nb of documents in directory +ECMNbOfDocs=No. of documents in directory ECMSection=Directory ECMSectionManual=Manual directory ECMSectionAuto=Automatic directory diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 0642b64dd7f..1249849ef0b 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -1,8 +1,8 @@ # Dolibarr language file - Source file is en_US - exports -ExportsArea=Exports area -ImportArea=Import area -NewExport=New export -NewImport=New import +ExportsArea=Exports +ImportArea=Import +NewExport=New Export +NewImport=New Import ExportableDatas=Exportable dataset ImportableDatas=Importable dataset SelectExportDataSet=Choose dataset you want to export... @@ -10,7 +10,7 @@ SelectImportDataSet=Choose dataset you want to import... SelectExportFields=Choose the fields you want to export, or select a predefined export profile SelectImportFields=Choose the source file fields you want to import and their target field in database by moving them up and down with anchor %s, or select a predefined import profile: NotImportedFields=Fields of source file not imported -SaveExportModel=Save this export profile (for reuse) ... +SaveExportModel=Save your selections as an export profile/template (for reuse). SaveImportModel=Save this import profile (for reuse) ... ExportModelName=Export profile name ExportModelSaved=Export profile saved as %s. @@ -24,13 +24,13 @@ ChooseFieldsOrdersAndTitle=Choose fields order... FieldsTitle=Fields title FieldTitle=Field title NowClickToGenerateToBuildExportFile=Now, select the file format in the combo box and click on "Generate" to build the export file... -AvailableFormats=Available formats +AvailableFormats=Available Formats LibraryShort=Library Step=Step -FormatedImport=Import assistant -FormatedImportDesc1=This area allows the import of personalized data using an assistant, to help you in the process without technical knowledge. +FormatedImport=Import Assistant +FormatedImportDesc1=This module allows you to update existing data or add new objects into the database from a file without technical knowledge, using an assistant. FormatedImportDesc2=First step is to choose the kind of data you want to import, then the format of the source file, then the fields you want to import. -FormatedExport=Export assistant +FormatedExport=Export Assistant FormatedExportDesc1=These tools allow the export of personalized data using an assistant, to help you in the process without requiring technical knowledge. FormatedExportDesc2=First step is to choose a predefined dataset, then which fields you want to export, and in which order. FormatedExportDesc3=When data to export are selected, you can choose the format of the output file. @@ -51,7 +51,7 @@ TypeOfLineServiceOrProduct=Type of line (0=product, 1=service) FileWithDataToImport=File with data to import FileToImport=Source file to import FileMustHaveOneOfFollowingFormat=File to import must have one of following formats -DownloadEmptyExample=Download example of empty source file +DownloadEmptyExample=Download template file with field content information (* are mandatory fields) ChooseFormatOfFileToImport=Choose the file format to use as import file format by clicking on the %s icon to select it... ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... SourceFileFormat=Source file format @@ -68,17 +68,17 @@ FieldsTarget=Targeted fields FieldTarget=Targeted field FieldSource=Source field NbOfSourceLines=Number of lines in source file -NowClickToTestTheImport=Check the import parameters you have defined. If they are correct, click on button "%s" to launch a simulation of the import process (no data will be changed in your database, it's only a simulation)... -RunSimulateImportFile=Launch the import simulation +NowClickToTestTheImport=Check the CSV format (field and string delimiters) of your file matches the options shown and that you have omitted the header line, or these will be flagged as errors in the following simulation.
Click on the "%s" button to run a check of the file structure/contents and simulate the import process.
No data will be changed in your database. +RunSimulateImportFile=Run Import Simulation FieldNeedSource=This field requires data from the source file SomeMandatoryFieldHaveNoSource=Some mandatory fields have no source from data file InformationOnSourceFile=Information on source file InformationOnTargetTables=Information on target fields SelectAtLeastOneField=Switch at least one source field in the column of fields to export SelectFormat=Choose this import file format -RunImportFile=Launch import file -NowClickToRunTheImport=Check result of import simulation. If everything is ok, launch the real import process. -DataLoadedWithId=All data will be loaded with the following import id: %s +RunImportFile=Import Data +NowClickToRunTheImport=Check the results of the import simulation. Correct any errors and re-test.
When the simulation reports no errors you may proceed to import the data into the database. +DataLoadedWithId=All data will be loaded with the following import id: %s to enable a search on this set of data in case of discovering problems in the future. ErrorMissingMandatoryValue=Mandatory data is empty in the source file for field %s. TooMuchErrors=There are still %s other source lines with errors but output has been limited. TooMuchWarnings=There are still %s other source lines with warnings but output has been limited. @@ -104,16 +104,16 @@ Excel95FormatDesc=Excel file format (.xls)
This is the native Excel 95 Excel2007FormatDesc=Excel file format (.xlsx)
This is the native Excel 2007 format (SpreadsheetML). TsvFormatDesc=Tab Separated Value file format (.tsv)
This is a text file format where fields are separated by a tabulator [tab]. ExportFieldAutomaticallyAdded=Field %s was automatically added. It will avoid you to have similar lines to be treated as duplicate record (with this field added, all lines will own their own id and will differ). -CsvOptions=Csv Options -Separator=Separator -Enclosure=Delimiter +CsvOptions=CSV format options +Separator=Field Separator +Enclosure=String Delimiter SpecialCode=Special code ExportStringFilter=%% allows replacing one or more characters in the text ExportDateFilter=YYYY, YYYYMM, YYYYMMDD : filters by one year/month/day
YYYY+YYYY, YYYYMM+YYYYMM, YYYYMMDD+YYYYMMDD : filters over a range of years/months/days
> YYYY, > YYYYMM, > YYYYMMDD : filters on all following years/months/days
< YYYY, < YYYYMM, < YYYYMMDD : filters on all previous years/months/days ExportNumericFilter=NNNNN filters by one value
NNNNN+NNNNN filters over a range of values
< NNNNN filters by lower values
> NNNNN filters by higher values ImportFromLine=Import starting from line number EndAtLineNb=End at line number -ImportFromToLine=Import line numbers (from - to) +ImportFromToLine=Limit range (from - to) eg. to omit header line SetThisValueTo2ToExcludeFirstLine=For example, set this value to 3 to exclude the 2 first lines KeepEmptyToGoToEndOfFile=Keep this field empty to go up to the end of file SelectPrimaryColumnsForUpdateAttempt=Select column(s) to use as primary key for update attempt @@ -127,7 +127,7 @@ FilteredFields=Filtered fields FilteredFieldsValues=Value for filter FormatControlRule=Format control rule ## imports updates -KeysToUseForUpdates=Key to use for updating data +KeysToUseForUpdates=Key (column) to use for updating existing data NbInsert=Number of inserted lines: %s NbUpdate=Number of updated lines: %s MultipleRecordFoundWithTheseFilters=Multiple records have been found with these filters: %s \ No newline at end of file diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 4c93eff9d0d..604d51c41b9 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -50,8 +50,8 @@ UseServicesDurationOnFichinter=Use services duration for interventions generated UseDurationOnFichinter=Hides the duration field for intervention records UseDateWithoutHourOnFichinter=Hides hours and minutes off the date field for intervention records InterventionStatistics=Statistics of interventions -NbOfinterventions=Nb of intervention cards -NumberOfInterventionsByMonth=Nb of intervention cards by month (date of validation) +NbOfinterventions=No. of intervention cards +NumberOfInterventionsByMonth=No. of intervention cards by month (date of validation) AmountOfInteventionNotIncludedByDefault=Amount of intervention is not included by default into profit (in most cases, timesheets are used to count time spent). Add option PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT to 1 into home-setup-other to include them. ##### Exports ##### InterId=Intervention id diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 21dc5ec4db5..8f9c49d8bff 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -47,8 +47,8 @@ WarningNoEMailsAdded=No new Email to add to recipient's list. ConfirmValidMailing=Are you sure you want to validate this emailing? ConfirmResetMailing=Warning, by reinitializing emailing %s, you will allow resending this email in a mass mailing. Are you sure you this is what you want to do? ConfirmDeleteMailing=Are you sure you want to delete this emailing? -NbOfUniqueEMails=Nb of unique emails -NbOfEMails=Nb of EMails +NbOfUniqueEMails=No. of unique emails +NbOfEMails=No. of EMails TotalNbOfDistinctRecipients=Number of distinct recipients NoTargetYet=No recipients defined yet (Go on tab 'Recipients') NoRecipientEmail=No recipient email for %s @@ -77,9 +77,9 @@ GroupEmails=Group emails OneEmailPerRecipient=One email per recipient (by default, one email per record selected) WarningIfYouCheckOneRecipientPerEmail=Warning, if you check this box, it means only one email will be sent for several different record selected, so, if your message contains substitution variables that refers to data of a record, it becomes not possible to replace them. ResultOfMailSending=Result of mass EMail sending -NbSelected=Nb selected -NbIgnored=Nb ignored -NbSent=Nb sent +NbSelected=No. selected +NbIgnored=No. ignored +NbSent=No. sent SentXXXmessages=%s message(s) sent. ConfirmUnvalidateEmailing=Are you sure you want to change email %s to draft status? MailingModuleDescContactsWithThirdpartyFilter=Contact with customer filters diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 51514b98160..5059e7cb2cd 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -81,7 +81,7 @@ FileUploaded=The file was successfully uploaded FileTransferComplete=File(s) was uploaded successfully FilesDeleted=File(s) successfully deleted FileWasNotUploaded=A file is selected for attachment but was not yet uploaded. Click on "Attach file" for this. -NbOfEntries=Nb of entries +NbOfEntries=No. of entries GoToWikiHelpPage=Read online help (Internet access needed) GoToHelpPage=Read help RecordSaved=Record saved @@ -94,7 +94,7 @@ Undefined=Undefined PasswordForgotten=Password forgotten? NoAccount=No account? SeeAbove=See above -HomeArea=Home area +HomeArea=Home LastConnexion=Latest connection PreviousConnexion=Previous connection PreviousValue=Previous value @@ -453,8 +453,8 @@ Generate=Generate Duration=Duration TotalDuration=Total duration Summary=Summary -DolibarrStateBoard=Database statistics -DolibarrWorkBoard=Open items dashboard +DolibarrStateBoard=Database Statistics +DolibarrWorkBoard=Pending Items NoOpenedElementToProcess=No opened element to process Available=Available NotYetAvailable=Not yet available @@ -772,14 +772,14 @@ ByDay=By day BySalesRepresentative=By sales representative LinkedToSpecificUsers=Linked to a particular user contact NoResults=No results -AdminTools=Admin tools +AdminTools=Admin Tools SystemTools=System tools ModulesSystemTools=Modules tools Test=Test Element=Element NoPhotoYet=No pictures available yet Dashboard=Dashboard -MyDashboard=My dashboard +MyDashboard=My Dashboard Deductible=Deductible from=from toward=toward diff --git a/htdocs/langs/en_US/opensurvey.lang b/htdocs/langs/en_US/opensurvey.lang index 0dff05cbfc0..356f1ff6efe 100644 --- a/htdocs/langs/en_US/opensurvey.lang +++ b/htdocs/langs/en_US/opensurvey.lang @@ -35,7 +35,7 @@ TitleChoice=Choice label ExportSpreadsheet=Export result spreadsheet ExpireDate=Limit date NbOfSurveys=Number of polls -NbOfVoters=Nb of voters +NbOfVoters=No. of voters SurveyResults=Results PollAdminDesc=You are allowed to change all vote lines of this poll with button "Edit". You can, as well, remove a column or a line with %s. You can also add a new column with %s. 5MoreChoices=5 more choices diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index ac4ff87b8e1..e5518951222 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -19,7 +19,7 @@ SuppliersOrdersRunning=Current purchase orders CustomerOrder=Customer Order CustomersOrders=Customer Orders CustomersOrdersRunning=Current customer orders -CustomersOrdersAndOrdersLines=Customer orders and order lines +CustomersOrdersAndOrdersLines=Customer orders and order details OrdersDeliveredToBill=Customer orders delivered to bill OrdersToBill=Customer orders delivered OrdersInProcess=Customer orders in process diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index c5535cd8eb0..3556862bfec 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -3,7 +3,7 @@ SecurityCode=Security code NumberingShort=N° Tools=Tools TMenuTools=Tools -ToolsDesc=All miscellaneous tools not included in other menu entries are collected here.

All the tools can be reached in the left menu. +ToolsDesc=All tools not included in other menu entries are grouped here.
All the tools can be accessed via the left menu. Birthday=Birthday BirthdayDate=Birthday date DateToBirth=Date of birth @@ -77,7 +77,7 @@ TotalSizeOfAttachedFiles=Total size of attached files/documents MaxSize=Maximum size AttachANewFile=Attach a new file/document LinkedObject=Linked object -NbOfActiveNotifications=Number of notifications (nb of recipient emails) +NbOfActiveNotifications=Number of notifications (no. of recipient emails) PredefinedMailTest=__(Hello)__\nThis is a test mail sent to __EMAIL__.\nThe two lines are separated by a carriage return.\n\n__USER_SIGNATURE__ PredefinedMailTestHtml=__(Hello)__\nThis is a test mail (the word test must be in bold).
The two lines are separated by a carriage return.

__USER_SIGNATURE__ PredefinedMailContentSendInvoice=__(Hello)__\n\nYou will find here the invoice __REF__\n\n__ONLINE_PAYMENT_TEXT_AND_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ @@ -172,7 +172,7 @@ EnableGDLibraryDesc=Install or enable GD library on your PHP installation to use ProfIdShortDesc=Prof Id %s is an information depending on third party country.
For example, for country %s, it's code %s. DolibarrDemo=Dolibarr ERP/CRM demo StatsByNumberOfUnits=Statistics for sum of qty of products/services -StatsByNumberOfEntities=Statistics in number of referring entities (nb of invoice, or order...) +StatsByNumberOfEntities=Statistics in number of referring entities (no. of invoice, or order...) NumberOfProposals=Number of proposals NumberOfCustomerOrders=Number of customer orders NumberOfCustomerInvoices=Number of customer invoices diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index e5da8738d96..ec890377d70 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -98,7 +98,7 @@ ServiceLimitedDuration=If product is a service with limited duration: MultiPricesAbility=Several segment of prices per product/service (each customer is in one segment) MultiPricesNumPrices=Number of prices AssociatedProductsAbility=Activate virtual products (kits) -AssociatedProducts=Virtual product +AssociatedProducts=Virtual products AssociatedProductsNumber=Number of products composing this virtual product ParentProductsNumber=Number of parent packaging product ParentProducts=Parent products @@ -325,8 +325,8 @@ DoNotRemovePreviousCombinations=Do not remove previous variants UsePercentageVariations=Use percentage variations PercentageVariation=Percentage variation ErrorDeletingGeneratedProducts=There was an error while trying to delete existing product variants -NbOfDifferentValues=Nb of different values -NbProducts=Nb. of products +NbOfDifferentValues=No. of different values +NbProducts=No. of products ParentProduct=Parent product HideChildProducts=Hide variant products ConfirmCloneProductCombinations=Would you like to copy all the product variants to the other parent product with the given reference? diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 6dfb11e2284..058fdee0637 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -39,8 +39,8 @@ ShowProject=Show project ShowTask=Show task SetProject=Set project NoProject=No project defined or owned -NbOfProjects=Nb of projects -NbOfTasks=Nb of tasks +NbOfProjects=No. of projects +NbOfTasks=No. of tasks TimeSpent=Time spent TimeSpentByYou=Time spent by you TimeSpentByUser=Time spent by user @@ -191,8 +191,8 @@ AssignTask=Assign ProjectOverview=Overview ManageTasks=Use projects to follow tasks and time ManageOpportunitiesStatus=Use projects to follow leads/opportinuties -ProjectNbProjectByMonth=Nb of created projects by month -ProjectNbTaskByMonth=Nb of created tasks by month +ProjectNbProjectByMonth=No. of created projects by month +ProjectNbTaskByMonth=No. of created tasks by month ProjectOppAmountOfProjectsByMonth=Amount of opportunities by month ProjectWeightedOppAmountOfProjectsByMonth=Weighted amount of opportunities by month ProjectOpenedProjectByOppStatus=Open project/lead by opportunity status diff --git a/htdocs/langs/en_US/sms.lang b/htdocs/langs/en_US/sms.lang index 15200341490..bf92a7b63cf 100644 --- a/htdocs/langs/en_US/sms.lang +++ b/htdocs/langs/en_US/sms.lang @@ -39,12 +39,12 @@ SmsSuccessfulySent=SMS correctly sent (from %s to %s) ErrorSmsRecipientIsEmpty=Number of target is empty WarningNoSmsAdded=No new phone number to add to target list ConfirmValidSms=Do you confirm validation of this campaign? -NbOfUniqueSms=Nb dof unique phone numbers -NbOfSms=Nbre of phon numbers +NbOfUniqueSms=No. of unique phone numbers +NbOfSms=No. of phone numbers ThisIsATestMessage=This is a test message SendSms=Send SMS -SmsInfoCharRemain=Nb of remaining characters -SmsInfoNumero= (format international ie : +33899701761) +SmsInfoCharRemain=No. of remaining characters +SmsInfoNumero= (international format ie : +33899701761) DelayBeforeSending=Delay before sending (minutes) SmsNoPossibleSenderFound=No sender available. Check setup of your SMS provider. SmsNoPossibleRecipientFound=No target available. Check setup of your SMS provider. diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index d0cf540d3eb..ac5102323d9 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -21,9 +21,9 @@ SupplierPayment=Vendor payment SuppliersArea=Vendor area RefSupplierShort=Ref. vendor Availability=Availability -ExportDataset_fournisseur_1=Vendor invoices list and invoice lines +ExportDataset_fournisseur_1=Vendor invoices and invoice details ExportDataset_fournisseur_2=Vendor invoices and payments -ExportDataset_fournisseur_3=Purchase orders and order lines +ExportDataset_fournisseur_3=Purchase orders and order details ApproveThisOrder=Approve this order ConfirmApproveThisOrder=Are you sure you want to approve order %s? DenyingThisOrder=Deny this order diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 9f840556f75..69477da6ad3 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -66,7 +66,7 @@ CreateDolibarrThirdParty=Create a third party LoginAccountDisableInDolibarr=Account disabled in Dolibarr. UsePersonalValue=Use personal value InternalUser=Internal user -ExportDataset_user_1=Dolibarr's users and properties +ExportDataset_user_1=Users and their properties DomainUser=Domain user %s Reactivate=Reactivate CreateInternalUserDesc=This form allows you to create an user internal to your company/organization. To create an external user (customer, supplier, ...), use the button 'Create Dolibarr user' from third party's contact card. @@ -92,8 +92,8 @@ LoginToCreate=Login to create NameToCreate=Name of third party to create YourRole=Your roles YourQuotaOfUsersIsReached=Your quota of active users is reached ! -NbOfUsers=Nb of users -NbOfPermissions=Nb of permissions +NbOfUsers=No. of users +NbOfPermissions=No. of permissions DontDowngradeSuperAdmin=Only a superadmin can downgrade a superadmin HierarchicalResponsible=Supervisor HierarchicView=Hierarchical view diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index aadc12802a0..6162bfe6aa1 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -12,8 +12,8 @@ WithdrawalsLines=Direct debit order lines RequestStandingOrderToTreat=Request for direct debit payment order to process RequestStandingOrderTreated=Request for direct debit payment order processed NotPossibleForThisStatusOfWithdrawReceiptORLine=Not yet possible. Withdraw status must be set to 'credited' before declaring reject on specific lines. -NbOfInvoiceToWithdraw=Nb. of qualified invoice with waiting direct debit order -NbOfInvoiceToWithdrawWithInfo=Nb. of customer invoice with direct debit payment orders having defined bank account information +NbOfInvoiceToWithdraw=No. of qualified invoice with waiting direct debit order +NbOfInvoiceToWithdrawWithInfo=No. of customer invoice with direct debit payment orders having defined bank account information InvoiceWaitingWithdraw=Invoice waiting for direct debit AmountToWithdraw=Amount to withdraw WithdrawsRefused=Direct debit refused From 6bf4ef5ef4f1919ef96a0d203fb29caf3b0f4c7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jul 2018 10:09:13 +0200 Subject: [PATCH 160/228] Fix double " Fix double " --- htdocs/core/modules/cheque/doc/pdf_blochet.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 097cd336c94..c159a7af925 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -388,4 +388,3 @@ class BordereauChequeBlochet extends ModeleChequeReceipts return pdf_pagefoot($pdf,$outputlangs,$newfreetext,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } - From e3d9e609d52ec54fa37b2fc82a55d3b0cefa47f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jul 2018 11:20:42 +0200 Subject: [PATCH 161/228] Fix var not defined --- htdocs/core/class/extrafields.class.php | 2 +- htdocs/core/lib/holiday.lib.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index db0af174810..cd3e6c90fb5 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -630,7 +630,7 @@ class ExtraFields private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$help='',$default='',$computed='',$entity='',$langfile='',$enabled='1') { global $conf, $user; - dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled); + dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled); // Clean parameters if ($elementtype == 'thirdparty') $elementtype='societe'; diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index b0653968c5f..b4b19d4df40 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -84,9 +84,9 @@ function holiday_admin_prepare_head() // 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); to remove a tab - complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin'); + complete_head_from_modules($conf,$langs,null,$head,$h,'holiday_admin'); - complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin','remove'); + complete_head_from_modules($conf,$langs,null,$head,$h,'holiday_admin','remove'); return $head; } From c477ca82669dcfcc208be02b4600c58b18be7f0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jul 2018 11:25:21 +0200 Subject: [PATCH 162/228] Fix scrutinizer --- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/lib/payments.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index ffe22b580e7..4ce4bfee824 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -934,7 +934,7 @@ class FormMail extends Form $url=getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); $paymenturl=$url; - $validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod); + $validpaymentmethod = getValidOnlinePaymentMethods(''); } if (count($validpaymentmethod) > 0 && $paymenturl) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index d56a7e2311c..1819d8e80c5 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -90,7 +90,7 @@ function payment_supplier_prepare_head(Paiement $object) { /** * Return array of valid payment mode * - * @param string $paymentmethod Filter on this payment method + * @param string $paymentmethod Filter on this payment method (''=none, 'paypal', ...) * @return array Array of valid payment method */ function getValidOnlinePaymentMethods($paymentmethod='') From e5f2fbf8dbbd0c392b88d0a91fe4dea8b2703ba7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jul 2018 15:21:29 +0200 Subject: [PATCH 163/228] Fix trans --- htdocs/core/lib/ticket.lib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 7fac65ab42b..6ae66803c39 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -105,6 +105,11 @@ function ticket_prepare_head($object) // History $head[$h][0] = DOL_URL_ROOT.'/ticket/history.php?track_id=' . $object->track_id; $head[$h][1] = $langs->trans('Events'); + if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + { + $head[$h][1].= '/'; + $head[$h][1].= $langs->trans("Agenda"); + } $head[$h][2] = 'tabTicketLogs'; $h++; From 9d3a0442c0ef9c4e1d913d0cf98a1dcff7dd5e20 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 16 Jul 2018 17:10:33 +0200 Subject: [PATCH 164/228] dolibarr-develop, php 7.2.7 On third party, add bank account. After spanish account has been added, on summary screen ..../htdocs/societe/paymentmodes.php a correct account number causes the error: Warning: A non-numeric value encountered in .......\public_html\dolibarr-develop\htdocs\core\lib\bank.lib.php on line 359 This is `$sum += $values[$i] * substr($InumCta, $i, 1);` Since substr returns a string it cannot be summed (I assume). I changed it to `$sum += $values[$i] * (int)substr($InumCta, $i, 1)` --- htdocs/core/lib/bank.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 5e1e300520c..e361d8fa9f6 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -356,7 +356,7 @@ function checkES($IentOfi, $InumCta) $sum = 0; for ($i = 0; $i < 11; $i++) { - $sum += $values[$i] * substr($InumCta, $i, 1); + $sum += $values[$i] * (int)substr($InumCta, $i, 1);//int to cast result of substr to a number } $key = 11 - $sum % 11; From 508133b33687c72a045ac681f109bb42d8a1b299 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Jul 2018 13:04:54 +0200 Subject: [PATCH 165/228] Clean code --- htdocs/core/class/commonobject.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 771f9fc4456..5e528f6a1d0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5122,7 +5122,7 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $form=new Form($this->db); } - + $val=$this->fields[$key]; $out=''; @@ -5137,20 +5137,20 @@ abstract class CommonObject $param['options']=array($reg[1].':'.$reg[2]=>'N'); $type ='link'; }else if(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){ - + $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N'); $type ='sellist'; }else if(preg_match('/varchar\((\d+)\)/', $val['type'],$reg)){ - + $param['options']=array(); $type ='varchar'; $size=$reg[1]; }else if(preg_match('/varchar/', $val['type'])){ - + $param['options']=array(); $type ='varchar'; }else if(is_array($this->fields[$key]['arrayofkeyval'])){ - + $param['options']=$this->fields[$key]['arrayofkeyval']; $type ='select'; }else { @@ -5164,7 +5164,7 @@ abstract class CommonObject $computed=$this->fields[$key]['computed']; $unique=$this->fields[$key]['unique']; $required=$this->fields[$key]['required']; - + $langfile=$this->fields[$key]['langfile']; $list=$this->fields[$key]['list']; $hidden=abs($this->fields[$key]['visible'])!=1?1:0; @@ -5707,7 +5707,7 @@ abstract class CommonObject */ return $out; } - + /** * Return HTML string to show a field into a page * Code very similar with showOutputField of extra fields From d4a5491753fa771ffa46340432333493882769bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Jul 2018 13:48:08 +0200 Subject: [PATCH 166/228] Fix duplicate tab "contact" on thirdparty --- htdocs/core/lib/company.lib.php | 58 ++++++++++++++++--------------- htdocs/core/lib/functions.lib.php | 1 + 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2b7bc860746..36a96cf56b8 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -50,26 +50,38 @@ function societe_prepare_head(Societe $object) $head[$h][2] = 'card'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); - $nbContact = 0; // TODO - - $sql = "SELECT COUNT(p.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; - $sql .= " WHERE p.fk_soc = ".$object->id; - $resql = $db->query($sql); - if ($resql) + if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) + { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $obj = $db->fetch_object($resql); - if ($obj) $nbContact = $obj->nb; - } + //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $nbContact = 0; // TODO - $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; - $head[$h][2] = 'contact'; - $h++; + $sql = "SELECT COUNT(p.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; + $sql .= " WHERE p.fk_soc = ".$object->id; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $nbContact = $obj->nb; + } + + $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; + } + } + else + { + $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id; + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][1] = $langs->trans("ContactsAddresses"); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; } if ($object->client==1 || $object->client==2 || $object->client==3) @@ -100,16 +112,6 @@ function societe_prepare_head(Societe $object) $h++; } - if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) - { - $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id; - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); - $head[$h][1] = $langs->trans("ContactsAddresses"); - if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; - $head[$h][2] = 'contact'; - $h++; - } - if (! empty($conf->projet->enabled) && (!empty($user->rights->projet->lire) )) { $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0ad00fd3a36..7e5f6791a7f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6969,6 +6969,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= foreach($head as $key => $val) { $condition = (! empty($values[3]) ? verifCond($values[3]) : 1); + //var_dump($key.' - '.$tabname.' - '.$head[$key][2].' - '.$condition); if ($head[$key][2]==$tabname && $condition) { unset($head[$key]); From 26507ee7126ba44b133d880896870e6da240f0af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Jul 2018 14:02:08 +0200 Subject: [PATCH 167/228] Code comment --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7e5f6791a7f..08ece769bff 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6969,7 +6969,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= foreach($head as $key => $val) { $condition = (! empty($values[3]) ? verifCond($values[3]) : 1); - //var_dump($key.' - '.$tabname.' - '.$head[$key][2].' - '.$condition); + //var_dump($key.' - '.$tabname.' - '.$head[$key][2].' - '.$values[3].' - '.$condition); if ($head[$key][2]==$tabname && $condition) { unset($head[$key]); From 1a58a40f772b17ed2c1b558a12196fa52e91eff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Jul 2018 16:48:34 +0200 Subject: [PATCH 168/228] remove commented log --- htdocs/public/stripe/ipn.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index c5d2cd85e5c..748f1439687 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -222,7 +222,6 @@ elseif ($event->type == 'charge.failed') { $subject = 'Your payment has been received: '.$event->data->object->id.''; $headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - //mail('ptibogxiv@msn.com', $subject, 'test', $headers); } elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated==true)) { @@ -321,7 +320,6 @@ elseif (($event->type == 'source.chargeable') && ($event->data->object->type == $body = ""; $subject = 'Facture '.$invoice->ref; $headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - //mail('ptibogxiv@msn.com', $subject, $body, $headers); TODO convert in dolibarr standard } elseif ($event->type == 'customer.deleted') { $db->begin(); From 7dc552a54ee3493a38bcf71fa4ec118f56f14803 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Jul 2018 18:10:42 +0200 Subject: [PATCH 169/228] Fix alignement --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 61818d4deb9..626d30ccd60 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -107,7 +107,7 @@ if ($nolinesbefore) { if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { ?> - trans('SupplierRef'); ?> + trans('SupplierRef'); ?> trans('VAT'); ?> trans('PriceUHT'); ?> From 34c2facff1a2cb65f9d9391c52d1167bda362296 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Jul 2018 18:16:30 +0200 Subject: [PATCH 170/228] Fix missing link on bank account --- htdocs/compta/bank/class/account.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 117621d9197..79b72a5a54c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1308,10 +1308,12 @@ class Account extends CommonObject $label .= '
' . $langs->trans('BankAccount') . ': ' . $this->label; $label .= '
' . $langs->trans('AccountNumber') . ': ' . $this->number; $label .= '
' . $langs->trans("AccountCurrency") . ': ' . $this->currency_code; - - if (!$user->rights->accounting->read || !empty($user->socid)) - $option = 'nolink'; - + + if (empty($user->rights->banque->lire) || !empty($user->socid)) + { + $option = 'nolink'; + } + if (! empty($conf->accounting->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -1346,7 +1348,7 @@ class Account extends CommonObject $linkstart = ''; $linkend = ''; } - + $result .= $linkstart; if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); From 74704acbcb618d98c5f11f8feb3fa99b67341041 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 18 Jul 2018 16:13:13 +0200 Subject: [PATCH 171/228] clean and update code --- htdocs/imports/import.php | 5 ++--- htdocs/livraison/card.php | 6 +++--- htdocs/product/admin/product.php | 4 +--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 10747ed0212..73c3d071110 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -905,12 +905,11 @@ if ($step == 4 && $datatoimport) $height=24; $i = 0; $mandatoryfieldshavesource=true; - $var=true; + print ''; foreach($fieldstarget as $code=>$label) { - $var = !$var; - print ''; + print ''; $i++; $entity=(! empty($objimport->array_import_entities[0][$code])?$objimport->array_import_entities[0][$code]:$objimport->array_import_icon[0]); diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 072c53aa3cb..b33b9b4fb7a 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2015 Claudio Aschieri * * 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 @@ -586,7 +586,7 @@ else print ''; /* - * Lignes produits + * Products lines */ $num_prod = count($object->lines); @@ -683,7 +683,7 @@ else $line->array_options = array_merge($line->array_options, $srcLine->array_options); } print ''; - print $line->showOptionals($extrafieldsline, $mode, array('style'=>$bc[$var], 'colspan'=>$colspan),$i); + print $line->showOptionals($extrafieldsline, $mode, array('style'=>'class="oddeven"', 'colspan'=>$colspan),$i); print ''; } diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 2e57e452928..cbf47bbcd21 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -658,7 +658,6 @@ if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) { // Add canvas feature $dir = DOL_DOCUMENT_ROOT . "/product/canvas/"; - $var = false; print ''; print ''."\n"; @@ -686,8 +685,7 @@ if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) if ($conf->$module->enabled) { - - print "'; print "\n"; - $var = false; - print ''; print ''; print ''; @@ -436,7 +434,6 @@ if ($id > 0 || ! empty($ref)) print "\n"; $companystatic = new Societe($db); - $var = true; foreach(array('internal','external') as $source) { @@ -446,9 +443,7 @@ if ($id > 0 || ! empty($ref)) $i = 0; while ($i < $num) { - $var = !$var; - - print ''; + print ''; // Source print '"; + print ''; print ''; @@ -1042,7 +1039,7 @@ class ActionsTicket print ''; } print ''; - print ""; + print ''; print ''; - $var = !$var; - print ""; + print ''; print ''; @@ -1221,7 +1217,7 @@ class ActionsTicket print ''; } print ''; - print ""; + print ''; print ''; @@ -1244,7 +1240,7 @@ class ActionsTicket */ public function viewTicketTimelineMessages($show_private, $show_user, Ticket $object) { - global $conf, $langs, $user, $bc; + global $conf, $langs, $user; // Load logs in cache $ret = $object->loadCacheMsgsTicket(); diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 76b25751806..1bf0dbbe785 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -244,7 +244,7 @@ if ($action == 'edit') print ''; - print ''; print ''; - print ''; print ''; print ''; - print ''; print ''; @@ -306,7 +306,7 @@ else print ''; - print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("ProductSpecial").'
"; + print '
'; print $object->description; From e362a0e9df743b64653917e4ef6899f1c9eed0ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Jul 2018 16:06:06 +0200 Subject: [PATCH 172/228] FIX website in inline edit mode --- htdocs/core/lib/website.lib.php | 13 +++++++++---- htdocs/website/index.php | 23 ++++++++++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 904f9f57411..4ca0812c9ee 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -56,6 +56,10 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); + // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart=" + $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); + $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); + return $content; } @@ -91,14 +95,15 @@ function dolWebsiteOutput($content) // Replace relative link /xxx.php with dolibarr URL: ...href="....php" $content=preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); // Replace relative link /xxx with dolibarr URL: ...href="....php" - $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(["\?]+)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); + $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); + $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\?)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart=" - $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep); - $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep); + $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); + $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); // Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart=" - $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep); + $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/ $content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 076554dcd76..e1460f497f1 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -157,7 +157,10 @@ $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; +$htmlheadercontentdefault.=''."\n"; /* @@ -2292,9 +2295,17 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out = ''."\n"; - $out.='
'."\n"; - // TODO Use contenteditable="true" / document.getElementById("myP").contentEditable="true" for part coming from CKEditor + // Include a html so we can benefit of the header of page. + // Note: We can't use iframe as it can be used to include another external html file + // Note: We can't use frame as it is deprecated. + $out.="\n\n"; + $out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1); + $out.="\n"; + $out.="\n"; + $out.='
'."\n"; + + // Note:
or
with contenteditable="true" inside this can be edited with inline ckeditor // REPLACEMENT OF LINKS When page called by website editor @@ -2319,7 +2330,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out.=''."\n"; // Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders, - // so editable will be available from container created from scratch + // so editable will be available only from container created from scratch //$out.='
grabbed_from ? ' contenteditable="true"' : '').'>'."\n"; $out.='
'."\n"; @@ -2329,6 +2340,12 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out.='
'; + /*if ($includepageintoaframeoradiv == 'iframe') + { + $out .= ""; + }*/ + $out .= "\n\n"; + $out.= "\n".''."\n\n"; // For jqueryscoped (does not work as expected) From 010c5af2457b5a9263cff9488da02aa771c06777 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 19 Jul 2018 16:48:20 +0200 Subject: [PATCH 173/228] Clean and update code --- htdocs/projet/tasks/contact.php | 7 +------ htdocs/ticket/class/actions_ticket.class.php | 20 ++++++++------------ htdocs/user/param_ihm.php | 12 ++++++------ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 1ca25090876..4d78aad4764 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -352,8 +352,6 @@ if ($id > 0 || ! empty($ref)) print '
 
'; diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 6dc946ebad3..f49325a5bc5 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -1001,7 +1001,7 @@ class ActionsTicket */ public function viewTicketLogs($show_user = true) { - global $conf, $langs, $bc; + global $conf, $langs; // Load logs in cache $ret = $this->dao->loadCacheLogsTicket(); @@ -1021,11 +1021,8 @@ class ActionsTicket print ''; } - $var = true; - foreach ($this->dao->cache_logs_ticket as $id => $arraylogs) { - $var = !$var; - print "
'; print dol_print_date($arraylogs['datec'], 'dayhour'); print '
'; print dol_nl2br($arraylogs['message']); @@ -1064,7 +1061,7 @@ class ActionsTicket */ public function viewTimelineTicketLogs($show_user = true, $object = true) { - global $conf, $langs, $bc; + global $conf, $langs; // Load logs in cache $ret = $object->loadCacheLogsTicket(); @@ -1171,7 +1168,7 @@ class ActionsTicket */ public function viewTicketMessages($show_private, $show_user = true) { - global $conf, $langs, $user, $bc; + global $conf, $langs, $user; global $object; // Load logs in cache @@ -1202,8 +1199,7 @@ class ActionsTicket || ($arraymsgs['private'] == "1" && $show_private) ) { //print '
'; print dol_print_date($arraymsgs['datec'], 'dayhour'); print '
'; print $arraymsgs['message']; print ''; print (empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE); print 'conf->MAIN_LANDING_PAGE)?" checked":""); + print 'conf->MAIN_LANDING_PAGE)?" checked":""); print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; @@ -259,7 +259,7 @@ if ($action == 'edit') print $s?$s.' ':''; print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT)); print 'conf->MAIN_LANG_DEFAULT)?" checked":""); + print 'conf->MAIN_LANG_DEFAULT)?" checked":""); print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; @@ -269,7 +269,7 @@ if ($action == 'edit') // Taille max des listes print '
'.$langs->trans("MaxSizeList").''.$conf->global->MAIN_SIZE_LISTE_LIMIT.'conf->MAIN_SIZE_LISTE_LIMIT)?" checked":""); + print 'conf->MAIN_SIZE_LISTE_LIMIT)?" checked":""); print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").'
'; print (empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE); print 'conf->MAIN_LANDING_PAGE)?" checked":""); + print 'conf->MAIN_LANDING_PAGE)?" checked":""); print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; @@ -326,7 +326,7 @@ else print ($s?$s.' ':''); print (isset($conf->global->MAIN_LANG_DEFAULT) && $conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT)); print 'conf->MAIN_LANG_DEFAULT)?" checked":"").'> '.$langs->trans("UsePersonalValue").'conf->MAIN_LANG_DEFAULT)?" checked":"").'> '.$langs->trans("UsePersonalValue").''; $s=(isset($object->conf->MAIN_LANG_DEFAULT) ? picto_from_langcode($object->conf->MAIN_LANG_DEFAULT) : ''); print ($s?$s.' ':''); @@ -336,7 +336,7 @@ else print '
'.$langs->trans("MaxSizeList").''.(! empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?$conf->global->MAIN_SIZE_LISTE_LIMIT:' ').'conf->MAIN_SIZE_LISTE_LIMIT)?" checked":"").'> '.$langs->trans("UsePersonalValue").'conf->MAIN_SIZE_LISTE_LIMIT)?" checked":"").'> '.$langs->trans("UsePersonalValue").'' . (! empty($object->conf->MAIN_SIZE_LISTE_LIMIT)?$object->conf->MAIN_SIZE_LISTE_LIMIT:' ') . '

'; From 22d94a570a8a56983c58c2eb5e52d20aa63cf84d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 19 Jul 2018 18:59:24 +0200 Subject: [PATCH 174/228] Allow to enter a timespent with a numeric value --- htdocs/core/js/timesheet.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js index ae7d839919c..de8b24af96c 100644 --- a/htdocs/core/js/timesheet.js +++ b/htdocs/core/js/timesheet.js @@ -45,11 +45,16 @@ function regexEvent(objet,evt,type) case 'hours': var regex= /^[0-9]{1,2}:[0-9]{2}$/; var regex2=/^[0-9]{1,2}$/; + var regex3= /^[0-9]{1}([.,]{1}[0-9]{1,2})?$/; if(!regex.test(objet.value)) { if(regex2.test(objet.value)) objet.value=objet.value+':00'; - else + else if(regex3.test(objet.value)) { + var tmp=parseFloat(objet.value.replace(',','.')); + var rnd=Math.trunc(tmp); + objet.value=rnd+':'+ Math.round(60*(tmp-rnd)); + } else objet.value=''; } /* alert(jQuery("#"+id).val()); */ From 8247bb683c7edf0bf0d7e38af3659a831946b4a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Jul 2018 21:35:21 +0200 Subject: [PATCH 175/228] Debug website module --- htdocs/core/lib/website.lib.php | 24 ++++++++++++++++++---- htdocs/langs/en_US/website.lang | 1 + htdocs/website/index.php | 36 +++++++++++++++++++++++++++------ 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 4ca0812c9ee..610cbb3cc55 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -31,6 +31,7 @@ * @param string $content Content to replace * @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections. * @return boolean True if OK + * @see dolWebsiteOutput for function used to replace content in a web server context */ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) { @@ -48,10 +49,16 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) // Replace relative link /xxx.php with dolibarr URL $content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); + // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/ $content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); + $content = preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); + // ]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); // ]*src=")(?!(http|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); + $content = preg_replace('/(]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); + // ]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep); // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); @@ -70,7 +77,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) * * @param string $content Content string * @return void - * @see dolWebsiteSaveContent + * @see dolWebsiteReplacementOfLinks for function used to replace content in the backoffice editor context */ function dolWebsiteOutput($content) { @@ -98,15 +105,24 @@ function dolWebsiteOutput($content) $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\?)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); - // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart=" + // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: href="/document.php?modulepart=" => href="/dolibarr/document.php?modulepart=" $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); - // Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart=" + // Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: href="/viewimage.php?modulepart=" => href="/dolibarr/viewimage.php?modulepart=" $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); + $content=preg_replace('/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/ $content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); + $content=preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); + + // ]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); + // ]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); + // ]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep); // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 6286f19b8dc..e18f397d393 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -22,6 +22,7 @@ EditCss=Edit Style/CSS or HTML header EditMenu=Edit menu EditMedias=Edit medias EditPageMeta=Edit Meta +EditInline=Edit inline AddWebsite=Add website Webpage=Web page/container AddPage=Add page/container diff --git a/htdocs/website/index.php b/htdocs/website/index.php index e1460f497f1..94346b8a04f 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1651,16 +1651,29 @@ if (count($object->records) > 0) print '   '; print ''; + + print ''; + if ($websitepage->grabbed_from) { - print ''; + //print ''; + print ''.dol_escape_htmltag($langs->trans("EditInLine")).''; } else { - print ''; + //print ''; + if (empty($conf->global->WEBSITE_EDITINLINE)) + { + print ''.dol_escape_htmltag($langs->trans("EditInLine")).''; + } + else + { + print ''.dol_escape_htmltag($langs->trans("EditInLine")).''; + } } - print ''; + print '   '; + if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; else print ''; print ''; @@ -2305,8 +2318,6 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out.='
'."\n"; - // Note:
or
with contenteditable="true" inside this can be edited with inline ckeditor - // REPLACEMENT OF LINKS When page called by website editor $out.=''."\n"; + // Note:
or
with contenteditable="true" inside this can be edited with inline ckeditor + // Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders, // so editable will be available only from container created from scratch //$out.='
grabbed_from ? ' contenteditable="true"' : '').'>'."\n"; $out.='
'."\n"; - $out.=dolWebsiteReplacementOfLinks($object, $objectpage->content)."\n"; + // TODO Add the contenteditable="true" when mode Edit Inline is on + $newcontent = $objectpage->content; + if (empty($conf->global->WEBSITE_EDITINLINE_ON)) + { + $newcontent = preg_replace('/(div|section) contenteditable="true"/', '\1', $newcontent); + } + else + { + + } + + $out.=dolWebsiteReplacementOfLinks($object, $newcontent)."\n"; $out.='
'; From f419964c761e372307dac8e70a3ee0c0d95f8522 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Jul 2018 15:01:50 +0200 Subject: [PATCH 176/228] Fix Debug website module --- htdocs/langs/en_US/website.lang | 2 +- htdocs/public/website/index.php | 3 ++- htdocs/theme/eldy/style.css.php | 5 +++++ htdocs/theme/md/style.css.php | 6 ++++++ htdocs/website/index.php | 30 +++++++++++++++++++++--------- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index e18f397d393..48867fedb6f 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -22,7 +22,7 @@ EditCss=Edit Style/CSS or HTML header EditMenu=Edit menu EditMedias=Edit medias EditPageMeta=Edit Meta -EditInline=Edit inline +EditInLine=Edit inline AddWebsite=Add website Webpage=Web page/container AddPage=Add page/container diff --git a/htdocs/public/website/index.php b/htdocs/public/website/index.php index b61c02e9d63..436e352819a 100644 --- a/htdocs/public/website/index.php +++ b/htdocs/public/website/index.php @@ -131,7 +131,8 @@ if (empty($pageid)) header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); $langs->load("website"); - print $langs->trans("PreviewOfSiteNotYetAvailable"); + + if (! GETPOSTISSET('pageref')) print $langs->trans("PreviewOfSiteNotYetAvailable", $websitekey); include DOL_DOCUMENT_ROOT.'/public/error-404.php'; exit; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 21ca0e5e586..fb19b5d8c4e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2931,6 +2931,11 @@ div.pagination li.paginationafterarrows { .nohover:hover { background: unset; } +.nohoverborder:hover { + border: unset; + box-shadow: unset; + -webkit-box-shadow: unset; +} .oddeven, .evenodd, .impair, .nohover .impair:hover, tr.impair td.nohover { font-family: ; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a7c102d16eb..cec44aa00af 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2892,6 +2892,12 @@ ul.noborder li:nth-child(odd):not(.liste_titre) { /* Set the color for hover lines */ + +.nohoverborder:hover { + border: unset; + box-shadow: unset; + -webkit-box-shadow: unset; +} .oddeven:hover, .evenodd:hover, .impair:hover, .pair:hover { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 94346b8a04f..1ba90605deb 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -172,6 +172,19 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' +if ($action == 'seteditinline') +{ + dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1); + header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website','alphanohtml').'&pageid='.GETPOST('pageid','int')); + exit; +} +if ($action == 'unseteditinline') +{ + dolibarr_del_const($db, 'WEBSITE_EDITINLINE'); + header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website','alphanohtml').'&pageid='.GETPOST('pageid','int')); + exit; +} + // Add directory /* if ($action == 'adddir' && $permtouploadfile) @@ -197,12 +210,12 @@ if ($action == 'adddir' && $permtouploadfile) */ -if (GETPOST('refreshsite')) // If we change the site, we reset the pageid and cancel addsite action. +if (GETPOST('refreshsite','alpha')) // If we change the site, we reset the pageid and cancel addsite action. { $pageid=0; if ($action == 'addsite') $action = 'preview'; } -if (GETPOST('refreshpage') && ! in_array($action, array('updatecss'))) $action='preview'; +if (GETPOST('refreshpage','alpha') && ! in_array($action, array('updatecss'))) $action='preview'; // Add site @@ -1657,18 +1670,18 @@ if (count($object->records) > 0) if ($websitepage->grabbed_from) { //print ''; - print ''.dol_escape_htmltag($langs->trans("EditInLine")).''; + print ''.$langs->trans("EditInLine").img_picto($langs->trans("Disabled"),'switch_off').''; } else { //print ''; if (empty($conf->global->WEBSITE_EDITINLINE)) { - print ''.dol_escape_htmltag($langs->trans("EditInLine")).''; + print ''.$langs->trans("EditInLine").img_picto($langs->trans("Disabled"),'switch_off').''; } else { - print ''.dol_escape_htmltag($langs->trans("EditInLine")).''; + print ''.$langs->trans("EditInLine").img_picto($langs->trans("Disabled"),'switch_on').''; } } @@ -2296,7 +2309,6 @@ if ($action == 'editcontent') print "
\n\n"; - if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { if ($pageid > 0) @@ -2349,9 +2361,9 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa // TODO Add the contenteditable="true" when mode Edit Inline is on $newcontent = $objectpage->content; - if (empty($conf->global->WEBSITE_EDITINLINE_ON)) + if (empty($conf->global->WEBSITE_EDITINLINE)) { - $newcontent = preg_replace('/(div|section) contenteditable="true"/', '\1', $newcontent); + $newcontent = preg_replace('/(div|section)(\s[^\>]*)contenteditable="true"/', '\1\2', $newcontent); } else { @@ -2400,7 +2412,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa } else { - print '

'.$langs->trans("PreviewOfSiteNotYetAvailable", $website).'


'; + print '

'.$langs->trans("PreviewOfSiteNotYetAvailable", $object->ref).'


'; print '
'; } } From 84bfe2965b90ff6c78bd7cebd28582469ae0c112 Mon Sep 17 00:00:00 2001 From: ias-ceo Date: Fri, 20 Jul 2018 16:16:27 +0300 Subject: [PATCH 177/228] if time spent minutes zero --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 3844d8eeb50..f3271535bcd 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -160,7 +160,7 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) $object->timespent_note = $_POST["timespent_note"]; $object->progress = GETPOST('progress', 'int'); $object->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds - $object->timespent_duration+= $_POST["timespent_durationmin"]*60; // We store duration in seconds + $object->timespent_duration+= ($_POST["timespent_durationmin"]?$_POST["timespent_durationmin"]:0)*60; // We store duration in seconds if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timehour"),GETPOST("timemin"),0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear")); From b697307bac125959cf8dbd3409018c70c6fe0db4 Mon Sep 17 00:00:00 2001 From: fappels Date: Sun, 22 Jul 2018 10:41:39 +0200 Subject: [PATCH 178/228] Fix chromephp firephp Syslog infinite loop. When chromephp/firephp not found ->trans causes infinite loop. Can happen when files moved to other server or location. --- htdocs/core/modules/syslog/mod_syslog_chromephp.php | 5 +++-- htdocs/core/modules/syslog/mod_syslog_firephp.php | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/syslog/mod_syslog_chromephp.php b/htdocs/core/modules/syslog/mod_syslog_chromephp.php index a9b9ccd5836..7523588ac15 100644 --- a/htdocs/core/modules/syslog/mod_syslog_chromephp.php +++ b/htdocs/core/modules/syslog/mod_syslog_chromephp.php @@ -121,13 +121,14 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface if (! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.php') && ! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.class.php')) { + $conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP = 1; // avoid infinite loop if (is_object($langs)) // $langs may not be defined yet. { - $errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php or ChromePhp.php'); + $errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php or ChromePhp.php'); } else { - $errors[] = "ErrorFailedToOpenFile ChromePhp.class.php or ChromePhp.php"; + $errors[] = "ErrorFailedToOpenFile ChromePhp.class.php or ChromePhp.php"; } } diff --git a/htdocs/core/modules/syslog/mod_syslog_firephp.php b/htdocs/core/modules/syslog/mod_syslog_firephp.php index 69bc98230af..f502022c4f6 100644 --- a/htdocs/core/modules/syslog/mod_syslog_firephp.php +++ b/htdocs/core/modules/syslog/mod_syslog_firephp.php @@ -122,7 +122,15 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface if (!file_exists($conf->global->SYSLOG_FIREPHP_INCLUDEPATH . self::$firephp_class_path)) { - $errors[] = $langs->trans("ErrorFailedToOpenFile", self::$firephp_class_path); + $conf->global->MAIN_SYSLOG_DISABLE_FIREPHP = 1; // avoid infinite loop + if (is_object($langs)) // $langs may not be defined yet. + { + $errors[] = $langs->trans("ErrorFailedToOpenFile", self::$firephp_class_path); + } + else + { + $errors[] = "ErrorFailedToOpenFile " . self::$firephp_class_path; + } } return $errors; From e9fccec0557f6fff5a457d10805e07a48277b2d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Jul 2018 16:56:11 +0200 Subject: [PATCH 179/228] Fix website deletion --- htdocs/admin/website.php | 12 +++++++++--- htdocs/website/index.php | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 80144f93c1f..80ca0b29c0a 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -322,10 +322,16 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($website->id > 0) { - $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'"; - $result = $db->query($sql); + $sql = "DELETE from ".MAIN_DB_PREFIX."website_account WHERE fk_website ='".$rowid."'"; + $result = $db->query($sql); - $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'"; + $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'"; + $result = $db->query($sql); + + $sql = "DELETE from ".MAIN_DB_PREFIX."website_extrafields WHERE fk_object ='".$rowid."'"; + $result = $db->query($sql); + + $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'"; $result = $db->query($sql); if (! $result) { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 1ba90605deb..6563386f4c9 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1670,18 +1670,18 @@ if (count($object->records) > 0) if ($websitepage->grabbed_from) { //print ''; - print ''.$langs->trans("EditInLine").img_picto($langs->trans("Disabled"),'switch_off').''; + print ''.img_picto($langs->trans("EditInLineOff"),'switch_off').''; } else { //print ''; if (empty($conf->global->WEBSITE_EDITINLINE)) { - print ''.$langs->trans("EditInLine").img_picto($langs->trans("Disabled"),'switch_off').''; + print ''.img_picto($langs->trans("EditInLineOff"),'switch_off').''; } else { - print ''.$langs->trans("EditInLine").img_picto($langs->trans("Disabled"),'switch_on').''; + print ''.img_picto($langs->trans("EditInLineOn"),'switch_on').''; } } From 45c7a47d7ff3b4d9788b2bc580fa8be73813888a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Jul 2018 17:18:35 +0200 Subject: [PATCH 180/228] Module website --- htdocs/website/index.php | 95 +++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 44 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 6563386f4c9..cd9a26dfa8c 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -45,7 +45,7 @@ if (! ((GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHI } $error=0; -$website=GETPOST('website', 'alpha'); +$websitekey=GETPOST('website', 'alpha'); $page=GETPOST('page', 'alpha'); $pageid=GETPOST('pageid', 'int'); $pageref=GETPOST('pageref', 'aZ09'); @@ -92,18 +92,19 @@ $objectpage=new WebsitePage($db); $object->fetchAll(); // Init $object->records // If website not defined, we take first found -if (empty($website)) +if (empty($websitekey)) { foreach($object->records as $key => $valwebsite) { - $website=$valwebsite->ref; + $websitekey=$valwebsite->ref; break; } } -if ($website) +if ($websitekey) { - $res = $object->fetch(0, $website); + $res = $object->fetch(0, $websitekey); } +$website = $object; if ($pageid < 0) $pageid = 0; if (($pageid > 0 || $pageref) && $action != 'addcontainer') @@ -128,7 +129,7 @@ if (($pageid > 0 || $pageref) && $action != 'addcontainer') } global $dolibarr_main_data_root; -$pathofwebsite=$dolibarr_main_data_root.'/website/'.$website; +$pathofwebsite=$dolibarr_main_data_root.'/website/'.$websitekey; $filehtmlheader=$pathofwebsite.'/htmlheader.html'; $filecss=$pathofwebsite.'/styles.css.php'; $filejs=$pathofwebsite.'/javascript.js.php'; @@ -167,7 +168,7 @@ $htmlheadercontentdefault.='-->'."\n"; * Actions */ -$backtopage=$_SERVER["PHP_SELF"].'?file_manager=1&website='.$website.'&pageid='.$pageid; // used after a confirm_deletefile into actions_linkedfiles.inc.php +$backtopage=$_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid; // used after a confirm_deletefile into actions_linkedfiles.inc.php include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' @@ -636,13 +637,13 @@ if ($action == 'addcontainer') if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); - //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); + //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); //exit; } else { setEventMessages('Failed to write file '.$filetpl, null, 'errors'); - //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); + //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); //exit; } } @@ -717,7 +718,8 @@ if ($action == 'delete') $db->begin(); - $res = $object->fetch(0, $website); + $res = $object->fetch(0, $websitekey); + $website = $object; $res = $objectpage->fetch($pageid, $object->fk_website); @@ -734,9 +736,9 @@ if ($action == 'delete') if (! $error) { $db->commit(); - setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs'); + setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $websitekey), null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website); + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey); exit; } else @@ -755,7 +757,8 @@ if ($action == 'updatecss') } else { - $res = $object->fetch(0, $website); + $res = $object->fetch(0, $websitekey); + $website = $object; // Html header file $htmlheadercontent =''; @@ -922,7 +925,8 @@ if ($action == 'updatecss') if ($action == 'setashome') { $db->begin(); - $object->fetch(0, $website); + $object->fetch(0, $websitekey); + $website = $object; $object->fk_default_home = $pageid; $res = $object->update($user); @@ -956,7 +960,8 @@ if ($action == 'updatemeta') { $db->begin(); - $object->fetch(0, $website); + $object->fetch(0, $websitekey); + $website = $object; $objectpage->fk_website = $object->id; @@ -1074,13 +1079,13 @@ if ($action == 'updatemeta') if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); - //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); + //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); //exit; } else { setEventMessages('Failed to write file '.$filetpl, null, 'errors'); - //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); + //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); //exit; } @@ -1092,7 +1097,8 @@ if ($action == 'updatemeta') if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'confirm_createfromclone' || $action == 'confirm_createpagefromclone') || ($action == 'preview' && (GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview')))) { - $object->fetch(0, $website); + $object->fetch(0, $websitekey); + $website = $object; if ($action == 'confirm_createfromclone') { @@ -1244,13 +1250,13 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); exit; } else { setEventMessages('Failed to write file '.$filetpl, null, 'errors'); - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); exit; } } @@ -1261,7 +1267,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } else { - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); exit; } } @@ -1401,10 +1407,10 @@ if (count($object->records) > 0) $i=0; foreach($object->records as $key => $valwebsite) { - if (empty($website)) $website=$valwebsite->ref; + if (empty($websitekey)) $websitekey=$valwebsite->ref; $out.=''; @@ -1417,14 +1423,14 @@ if (count($object->records) > 0) print ''; - if ($website) + if ($websitekey) { $virtualurl=''; - $dataroot=DOL_DATA_ROOT.'/website/'.$website; + $dataroot=DOL_DATA_ROOT.'/website/'.$websitekey; if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; } - if ($website && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')) + if ($websitekey && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')) { $disabled=''; if (empty($user->rights->website->write)) $disabled=' disabled="disabled"'; @@ -1443,7 +1449,7 @@ if (count($object->records) > 0) print ' @@ -408,7 +408,7 @@ else if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'§ion='.urlencode($_REQUEST["section"]).'&file='.urlencode($_GET["file"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1); - + } // Confirmation de la suppression d'une ligne categorie @@ -486,7 +486,7 @@ else $newsection=$section; $newsectioniso=utf8_decode($section); //$newsection='/home'; - + // List content of directory ($newsection = '/', '/home', ...) if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) { @@ -551,7 +551,7 @@ else $is_directory=ftp_isdir($conn_id, $newremotefileiso); } - + print ''; // Name print ''; @@ -615,14 +615,14 @@ else print ""; - + if (! $ok) { print $mesg.'
'."\n"; setEventMessages($mesg, null, 'errors'); } - - + + // Actions /* if ($user->rights->ftp->write && ! empty($section)) @@ -654,7 +654,7 @@ else break; } $i++; - } + } if (! $foundsetup) { print $langs->trans("SetupOfFTPClientModuleNotComplete"); @@ -669,11 +669,11 @@ else print '
'; // Close FTP connection -if ($conn_id) +if ($conn_id) { if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) { - + } else if (! empty($conf->global->FTP_CONNECT_WITH_SSL)) { @@ -684,7 +684,7 @@ if ($conn_id) ftp_close($conn_id); } } - + llxFooter(); @@ -709,7 +709,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect $ok=1; $conn_id=null; - + if (! is_numeric($ftp_port)) { $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServer",$ftp_server,$ftp_port); @@ -719,17 +719,17 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect if ($ok) { $connecttimeout=(empty($conf->global->FTP_CONNECT_TIMEOUT)?40:$conf->global->FTP_CONNECT_TIMEOUT); - if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) + if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) { dol_syslog('Try to connect with ssh2_ftp'); $tmp_conn_id = ssh2_connect($ftp_server, $ftp_port); } - else if (! empty($conf->global->FTP_CONNECT_WITH_SSL)) + else if (! empty($conf->global->FTP_CONNECT_WITH_SSL)) { dol_syslog('Try to connect with ftp_ssl_connect'); $conn_id = ftp_ssl_connect($ftp_server, $ftp_port, $connecttimeout); } - else + else { dol_syslog('Try to connect with ftp_connect'); $conn_id = ftp_connect($ftp_server, $ftp_port, $connecttimeout); @@ -744,7 +744,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect { // Turn on passive mode transfers (must be after a successful login //if ($ftp_passive) ftp_pasv($conn_id, true); - + // Change the dir $newsectioniso=utf8_decode($section); //ftp_chdir($conn_id, $newsectioniso); @@ -756,25 +756,25 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect $error++; } } - else + else { $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); $ok=0; $error++; } - } + } else { if (ftp_login($conn_id, $ftp_user, $ftp_password)) { // Turn on passive mode transfers (must be after a successful login if ($ftp_passive) ftp_pasv($conn_id, true); - + // Change the dir $newsectioniso=utf8_decode($section); ftp_chdir($conn_id, $newsectioniso); } - else + else { $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); $ok=0; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 494c572eaad..1b6046d50f8 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -26,7 +26,7 @@ * \brief Form and file creation of paid holiday. */ -require('../main.inc.php'); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 55724549360..380f609ec6d 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -26,7 +26,7 @@ * \brief File that defines the balance of paid holiday of users. */ -require('../main.inc.php'); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 5df3fdb314b..86ca95580b1 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -23,7 +23,7 @@ * \brief List of holiday */ -require('../main.inc.php'); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 1e72122c2be..0faa2b56585 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -22,7 +22,7 @@ * \brief Monthly report of leave requests. */ -require('../main.inc.php'); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 198b9a8854c..c36ccd1f4d7 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -23,7 +23,7 @@ * \ingroup holiday */ -require('../main.inc.php'); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 996ddd58ed3..f52cb1afc61 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -20,7 +20,7 @@ * \ingroup HRM * \brief HRM Establishment module setup page */ -require('../../main.inc.php'); +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index a7a8b8a9352..ac47eec6292 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -20,7 +20,7 @@ * \ingroup HRM * \brief HRM module setup page */ -require('../../main.inc.php'); +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index db316098003..c95e886e792 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -19,7 +19,7 @@ * \file htdocs/hrm/establishment/card.php * \brief Page to show an establishment */ -require('../../main.inc.php'); +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php index 76eb236d1a1..6cd44861ad5 100644 --- a/htdocs/hrm/establishment/info.php +++ b/htdocs/hrm/establishment/info.php @@ -20,7 +20,7 @@ * \brief Page to show info of an establishment */ -require('../../main.inc.php'); +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 365d40cca96..b49dfd92998 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -24,7 +24,7 @@ * \brief Home page for HRM area. */ -require('../main.inc.php'); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index 240637282db..f7ae2608da5 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -181,7 +181,7 @@ class MailmanSpip if ($mydb) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $mdpass=dol_hash($object->pass); $htpass=crypt($object->pass,makesalt()); $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".dolGetFirstLastname($object->firstname,$object->lastname)."\",\"".$object->email."\",\"".$object->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")"; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 826f83356c4..797298c4653 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1732,7 +1732,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra // Define $bookmarks if (! empty($conf->bookmark->enabled) && $user->rights->bookmark->lire) { - include_once (DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'); + include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'; $langs->load("bookmarks"); $bookmarks=printBookmarksList($db, $langs); diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index eaa53aa8490..ced69451d9d 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -26,8 +26,8 @@ include '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); -require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; $langs->load("admin"); $langs->load("bills"); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 5350fd170f1..2eb20f48fea 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1640,7 +1640,7 @@ elseif (! empty($module)) } else { - $result = @include_once($dirread.'/'.$pathtoclass); + $result = @include_once $dirread.'/'.$pathtoclass; } if (class_exists($tabobj)) { diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index b72917daff0..e580c6c7457 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -25,15 +25,15 @@ // Load Dolibarr environment $res=0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; if (! $res) die("Include of main fails"); // Libraries diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index fd2c509233b..2cc6468729c 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -25,15 +25,15 @@ // Load Dolibarr environment $res=0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; if (! $res) die("Include of main fails"); global $langs, $user; diff --git a/htdocs/modulebuilder/template/css/mymodule.css.php b/htdocs/modulebuilder/template/css/mymodule.css.php index 5787fa4f64c..486d860e7f5 100644 --- a/htdocs/modulebuilder/template/css/mymodule.css.php +++ b/htdocs/modulebuilder/template/css/mymodule.css.php @@ -35,15 +35,15 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Load Dolibarr environment $res=0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/../main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; if (! $res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/modulebuilder/template/js/mymodule.js.php b/htdocs/modulebuilder/template/js/mymodule.js.php index 07f44756615..6a3447625a5 100644 --- a/htdocs/modulebuilder/template/js/mymodule.js.php +++ b/htdocs/modulebuilder/template/js/mymodule.js.php @@ -38,15 +38,15 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Load Dolibarr environment $res=0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/../main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; if (! $res) die("Include of main fails"); // Define js type diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 2a72464fb9d..f005fbf8354 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -29,7 +29,7 @@ if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; // Try main.inc.php using relative path if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 6516f7eeff9..4fe54aa63a4 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -563,7 +563,7 @@ if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nb $hidegeneratedfilelistifempty=1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 2574e4239fa..d240f07ef53 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -29,7 +29,7 @@ if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; // Try main.inc.php using relative path if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; diff --git a/htdocs/modulebuilder/template/scripts/myobject.php b/htdocs/modulebuilder/template/scripts/myobject.php index 0aad12e2e35..67bcdea1d74 100755 --- a/htdocs/modulebuilder/template/scripts/myobject.php +++ b/htdocs/modulebuilder/template/scripts/myobject.php @@ -47,12 +47,12 @@ $res=0; // Try master.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/master.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/master.inc.php"); -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/master.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/master.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/master.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/master.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/master.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/master.inc.php"; // Try master.inc.php using relative path -if (! $res && file_exists("../master.inc.php")) $res=@include("../master.inc.php"); -if (! $res && file_exists("../../master.inc.php")) $res=@include("../../master.inc.php"); -if (! $res && file_exists("../../../master.inc.php")) $res=@include("../../../master.inc.php"); +if (! $res && file_exists("../master.inc.php")) $res=@include "../master.inc.php"; +if (! $res && file_exists("../../master.inc.php")) $res=@include "../../master.inc.php"; +if (! $res && file_exists("../../../master.inc.php")) $res=@include "../../../master.inc.php"; if (! $res) die("Include of master fails"); // After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). // $user is created but empty. diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index fda06d67012..af75bf4783b 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -22,12 +22,12 @@ * \brief Page to edit survey */ -require_once('../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index a2b6096d77c..d80bac70b79 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -24,9 +24,9 @@ */ // Put here all includes required by your class file -require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); -//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); -//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); +require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; +//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; +//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; /** diff --git a/htdocs/opensurvey/exportcsv.php b/htdocs/opensurvey/exportcsv.php index 90fd56cd4d1..b36a5256059 100644 --- a/htdocs/opensurvey/exportcsv.php +++ b/htdocs/opensurvey/exportcsv.php @@ -23,10 +23,10 @@ */ -require_once('../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"); +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; $action=GETPOST('action','aZ09'); $numsondage = ''; diff --git a/htdocs/opensurvey/index.php b/htdocs/opensurvey/index.php index 663d4ad704a..3b800b748ff 100644 --- a/htdocs/opensurvey/index.php +++ b/htdocs/opensurvey/index.php @@ -21,9 +21,9 @@ * \brief Home page of opensurvey area */ -require_once('../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; // Security check if (!$user->rights->opensurvey->read) accessforbidden(); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 0471abcddb9..de8feaad8da 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -22,10 +22,10 @@ * \brief Page to list surveys */ -require_once('../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"); +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; // Security check if (!$user->rights->opensurvey->read) accessforbidden(); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index cd6e6ed3225..9672e310938 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -22,12 +22,11 @@ * \brief Page to preview votes of a survey */ -$res=0; -require_once('../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php index a415d6b4987..9acf9d441e2 100644 --- a/htdocs/opensurvey/wizard/choix_autre.php +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -22,10 +22,10 @@ * \brief Page to create a new survey (choice selection) */ -require_once('../../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check if (!$user->rights->opensurvey->write) accessforbidden(); diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index 7dd0168c77a..fb7312b891c 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -22,10 +22,10 @@ * \brief Page to create a new survey (date selection) */ -require_once('../../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check if (!$user->rights->opensurvey->write) accessforbidden(); diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 0dfc2505ce3..2e33d377ca2 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -23,11 +23,11 @@ * \brief Page to create a new survey */ -require_once('../../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check if (!$user->rights->opensurvey->write) accessforbidden(); diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 48afbcc9dbb..b52514a4195 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -22,7 +22,7 @@ * \brief Manage record and specific data for batch number management */ -require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); +require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; /** diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index 87fdd132878..92c6ffadca4 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -22,7 +22,7 @@ * \brief This file is an CRUD class file (Create/Read/Update/Delete) */ -require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); +require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 74422cc2601..a5592c87f5d 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -525,7 +525,7 @@ if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nb $hidegeneratedfilelistifempty=1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 92719093650..53818220081 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -23,7 +23,7 @@ * \brief Page activite perso du module projet */ -require ("../../main.inc.php"); +require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 2b8996373e4..0943d8dd428 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -24,7 +24,7 @@ * \brief List activities of tasks (per day entry) */ -require ("../../main.inc.php"); +require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index cf68f6ccc95..b22ed6ee71a 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -24,7 +24,7 @@ * \brief List activities of tasks (per week entry) */ -require ("../../main.inc.php"); +require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 45a417a6dd2..da418680376 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -23,7 +23,7 @@ * \brief Gantt diagramm of a project */ -require ("../main.inc.php"); +require "../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 5af0d6da9e5..bf2ddf33890 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -23,7 +23,7 @@ * \brief List all tasks of a project */ -require ("../main.inc.php"); +require "../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index ac527424721..6c4b7f56d3f 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -23,7 +23,7 @@ * \brief Page of a project task */ -require ("../../main.inc.php"); +require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 4d78aad4764..6ed9af89385 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -23,7 +23,7 @@ * \brief Actors of a task */ -require ("../../main.inc.php"); +require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 14703f6d3eb..7a97de16f52 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -24,7 +24,7 @@ * \brief List all task of a project */ -require ("../../main.inc.php"); +require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 9e6018ab5c5..2fd47827d6a 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -21,7 +21,7 @@ * \brief Page to show information on a task */ -require ("../../main.inc.php"); +require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 4809cfe1276..ace9ab21a29 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -23,7 +23,7 @@ * \brief Page of a project task */ -require ("../../main.inc.php"); +require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index b11bf4cc42f..3bee8fd6434 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -36,11 +36,7 @@ if (is_numeric($entity)) define("DOLENTITY", $entity); // librarie core // Dolibarr environment -$res = @include("../../main.inc.php"); // From htdocs directory -if (! $res) { - $res = @include("../../../main.inc.php"); // From "custom" directory -} -if (! $res) die("Include of master.inc.php fails"); +require '../../main.inc.php'; // librarie jobs dol_include_once("/cron/class/cronjob.class.php"); @@ -51,10 +47,6 @@ global $langs, $conf; $langs->load("admin"); $langs->load("cron"); - - - - /* * View */ diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 32cb5f2e1ba..a9bd8a0fb70 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -24,11 +24,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -require_once('../../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"); -require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Init vars diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 748f1439687..42a732fcb21 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -21,9 +21,7 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site. $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); -$res=0; -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); // to work if your module directory is into a subdir of root htdocs directory -if (! $res) die("Include of main fails"); +require '../../main.inc.php'; if (empty($conf->stripe->enabled)) accessforbidden('',0,0,1); require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -110,7 +108,7 @@ if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabl $key=1; } $ret=$mc->switchEntity($key); - if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); + if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; if (! $res) die("Include of main fails"); } diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 832f70f4ea1..e4a21ae9888 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -22,12 +22,7 @@ */ -// Change this following line to use the correct relative path (../, ../../, etc) -$res=0; -$res=@include("../main.inc.php"); // For root directory -if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory -if (! $res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 7c3999db7c9..515f08f6053 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -491,7 +491,7 @@ class Dolresource extends CommonObject $sql.= " t.fk_code_type_resource,"; $sql.= " t.tms,"; - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields=new ExtraFields($this->db); $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); if (is_array($extralabels) && count($extralabels)>0) { diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 19bed957f74..ed667fad8ab 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -21,8 +21,8 @@ * \ingroup core * \brief Class file to manage forms into resource module */ -require_once(DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php"); -require_once(DOL_DOCUMENT_ROOT ."/resource/class/dolresource.class.php"); +require_once DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php"; +require_once DOL_DOCUMENT_ROOT ."/resource/class/dolresource.class.php"; /** diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 389d0236759..b844fce0f6c 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -23,11 +23,7 @@ */ -$res=0; -$res=@include("../main.inc.php"); // For root directory -if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory -if (! $res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index f1e56d4a359..e15c0864574 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -21,7 +21,7 @@ * \brief Popup screen to validate VAT */ -require ("../../main.inc.php"); +require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once NUSOAP_PATH.'/nusoap.php'; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 551f168ded3..947c35a2d5c 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -25,7 +25,7 @@ * \brief Add a tab on thirpdarty view to list all products/services bought or sells by thirdparty */ -require("../main.inc.php"); +require "../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 3563283ba05..d00b3144185 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -535,7 +535,7 @@ if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nb $hidegeneratedfilelistifempty=1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 1113d1428f5..8ad547a47ee 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -30,8 +30,7 @@ */ // Load Dolibarr environment -$res=@include("../main.inc.php"); // For root directory -if (! $res) $res=@include("../../main.inc.php"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 3dc0ab39756..bf561c15f83 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -25,8 +25,8 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . "/core/class/commonobject.class.php"; require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php'; -//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); -//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); +//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; +//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; /** diff --git a/htdocs/ticket/class/ticketlogs.class.php b/htdocs/ticket/class/ticketlogs.class.php index ffa6a193415..b4a464f6a17 100644 --- a/htdocs/ticket/class/ticketlogs.class.php +++ b/htdocs/ticket/class/ticketlogs.class.php @@ -23,8 +23,8 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . "/core/class/commonobject.class.php"; -//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); -//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); +//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; +//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; /** diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index c99ac7e7e3a..b23b4c5d27e 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -701,7 +701,7 @@ if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nb $hidegeneratedfilelistifempty=1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 882e9111b5d..9c2f3437fa4 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -27,7 +27,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -if (! empty($conf->ldap->enabled)) require_once (DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); +if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; /** diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index e140550207d..8cbe54e0b29 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -22,7 +22,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -659,7 +659,7 @@ function createOrder($authentication,$order) { global $db,$conf,$langs; - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $now=dol_now(); diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 37df126c753..f6c98599d93 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -570,7 +570,7 @@ function createProductOrService($authentication,$product) // Update stock if stock count is provided and differs from database after creation or update if (isset($product['stock_real']) && $product['stock_real'] != '' && ! empty($conf->global->stock->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $savstockreal=$newobject->stock_reel; $newobject->load_stock('novirtual,nobatch'); // This overwrite ->stock_reel, surely 0 because we have just created product @@ -739,7 +739,7 @@ function updateProductOrService($authentication,$product) // Update stock if stock count is provided and differs from database after creation or update if (isset($product['stock_real']) && $product['stock_real'] != '' && ! empty($conf->global->stock->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $savstockreal=$newobject->stock_reel; $newobject->load_stock('novirtual,nobatch'); // This overwrite ->stock_reel diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 9a1ad910672..0bc4428deb2 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -22,24 +22,11 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); -if (! $res) die("Include of main fails"); - -include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); -include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); -include_once(DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'); -include_once(DOL_DOCUMENT_ROOT.'/website/lib/websiteaccount.lib.php'); +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/website/lib/websiteaccount.lib.php'; // Load translation files required by the page $langs->loadLangs(array("website","other")); diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index 2d557768d7d..53136bf67b2 100755 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -24,7 +24,7 @@ * \brief Page to detect empty accounting account */ -require_once($path."../../htdocs/master.inc.php"); +require_once $path."../../htdocs/master.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index 398ec1d7a19..1124749fcf4 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -33,7 +33,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -require_once($path."../../htdocs/master.inc.php"); +require_once $path."../../htdocs/master.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; diff --git a/scripts/company/export-contacts-xls-example.php b/scripts/company/export-contacts-xls-example.php index 5fd7806a26c..c4887cb5ee1 100755 --- a/scripts/company/export-contacts-xls-example.php +++ b/scripts/company/export-contacts-xls-example.php @@ -41,13 +41,13 @@ if (! isset($argv[1]) || ! $argv[1]) { $now=$argv[1]; -require_once($path."../../htdocs/master.inc.php"); -//require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php"); -//require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php"); +require_once $path."../../htdocs/master.inc.php"; +//require_once PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php"; +//require_once PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php"; -require_once(PHPEXCEL_PATH."/PHPExcel.php"); -//require_once(PHPEXCEL_PATH."/PHPExcel/Writer/Excel2007.php"); -require_once(PHPEXCEL_PATH."/PHPExcel/Writer/Excel5.php"); +require_once PHPEXCEL_PATH."/PHPExcel.php"; +//require_once PHPEXCEL_PATH."/PHPExcel/Writer/Excel2007.php"; +require_once PHPEXCEL_PATH."/PHPExcel/Writer/Excel5.php"; // Global variables $version=DOL_VERSION; diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index 900cdbc35ed..32260291aa7 100755 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -35,10 +35,10 @@ if (substr($sapi_type, 0, 3) == 'cgi') { } -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); -require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"; +require_once DOL_DOCUMENT_ROOT."/user/class/user.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; // Global variables $version=DOL_VERSION; diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index 0f5c91817db..4edf4fb261d 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -50,8 +50,8 @@ $mode=$argv[1]; $targettype=$argv[2]; -require($path."../../htdocs/master.inc.php"); -require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"); +require $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; $langs->load('main'); $langs->load('contracts'); diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index ad7ccebcba7..7b15d52dff2 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -48,8 +48,8 @@ if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm $mode=$argv[1]; -require($path."../../htdocs/master.inc.php"); -require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"); +require $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; $langs->load('main'); $langs->load('contracts'); diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index c690d7b63ef..88960766a68 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -41,9 +41,9 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -require_once ($path."../../htdocs/master.inc.php"); -require_once (DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php"); -require_once (DOL_DOCUMENT_ROOT.'/user/class/user.class.php'); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php"; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Check parameters if (! isset($argv[1]) || ! $argv[1]) { diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index ef9a35fc1ed..95b06f187e8 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -44,9 +44,9 @@ $id=$argv[1]; if (isset($argv[2]) || !empty($argv[2])) $login = $argv[2]; else $login = ''; -require_once ($path."../../htdocs/master.inc.php"); -require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"); -require_once (DOL_DOCUMENT_ROOT."/comm/mailing/class/mailing.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; +require_once DOL_DOCUMENT_ROOT."/comm/mailing/class/mailing.class.php"; // Global variables diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index 02e9db2e0ce..428f8932ea3 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -50,8 +50,8 @@ $mode=$argv[1]; $targettype=$argv[2]; -require($path."../../htdocs/master.inc.php"); -require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"); +require $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; $langs->load('main'); diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index e134d693d74..dd92a752dc3 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -48,8 +48,8 @@ if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm $mode=$argv[1]; -require($path."../../htdocs/master.inc.php"); -require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"); +require $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; $langs->load('main'); diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index 30782d3b913..2c71d9cf750 100755 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -34,12 +34,12 @@ if (substr($sapi_type, 0, 3) == 'cgi') { } // Include Dolibarr environment -require_once($path."../../htdocs/master.inc.php"); +require_once $path."../../htdocs/master.inc.php"; // After this $db is an opened handler to database. We close it at end of file. -require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); -require_once(DOL_DOCUMENT_ROOT."/core/modules/facture/modules_facture.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice2.lib.php'); +require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/modules/facture/modules_facture.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice2.lib.php'; // Load main language strings diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index a0c393d01c2..e3ca5f38e0a 100755 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -34,9 +34,9 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); -require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"; $langs->load("main"); diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index e7adb80e733..8cf0005800f 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -34,11 +34,11 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); -require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); -require_once(DOL_DOCUMENT_ROOT."/adherents/class/subscription.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"; +require_once DOL_DOCUMENT_ROOT."/adherents/class/subscription.class.php"; $langs->load("main"); $langs->load("errors"); diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php index 939a98c8728..dac7ccfd0bc 100755 --- a/scripts/members/sync_members_types_dolibarr2ldap.php +++ b/scripts/members/sync_members_types_dolibarr2ldap.php @@ -41,9 +41,9 @@ if (! isset($argv[1]) || ! $argv[1]) { } $now=$argv[1]; -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); -require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; // Global variables $version=DOL_VERSION; diff --git a/scripts/members/sync_members_types_ldap2dolibarr.php b/scripts/members/sync_members_types_ldap2dolibarr.php index 55d5606cd30..1363f989e15 100755 --- a/scripts/members/sync_members_types_ldap2dolibarr.php +++ b/scripts/members/sync_members_types_ldap2dolibarr.php @@ -36,10 +36,10 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); -require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; $langs->load("main"); $langs->load("errors"); diff --git a/scripts/modulebuilder/builddoc.php b/scripts/modulebuilder/builddoc.php index f2c0eef421f..c0b44a0bed8 100755 --- a/scripts/modulebuilder/builddoc.php +++ b/scripts/modulebuilder/builddoc.php @@ -45,7 +45,7 @@ if (! isset($argv[1]) || ! $argv[1]) { } $modulename=$argv[1]; -require_once ($path."../../htdocs/master.inc.php"); +require_once $path."../../htdocs/master.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; diff --git a/scripts/modulebuilder/initmodule.php b/scripts/modulebuilder/initmodule.php index 6c9801878d3..bee931dc8fa 100755 --- a/scripts/modulebuilder/initmodule.php +++ b/scripts/modulebuilder/initmodule.php @@ -41,7 +41,7 @@ if (! isset($argv[1]) || ! $argv[1]) { } $modulename=$argv[1]; -require_once ($path."../../htdocs/master.inc.php"); +require_once $path."../../htdocs/master.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; diff --git a/scripts/product/migrate_picture_path.php b/scripts/product/migrate_picture_path.php index d72c60f05e5..69322b2f350 100755 --- a/scripts/product/migrate_picture_path.php +++ b/scripts/product/migrate_picture_path.php @@ -37,9 +37,9 @@ if (substr($sapi_type, 0, 3) == 'cgi') { define('EVEN_IF_ONLY_LOGIN_ALLOWED',1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only". // Include and load Dolibarr environment variables -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; // After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). // $user is created but empty. diff --git a/scripts/product/regenerate_thumbs.php b/scripts/product/regenerate_thumbs.php index bc3e1f53a6b..a4d114746c2 100755 --- a/scripts/product/regenerate_thumbs.php +++ b/scripts/product/regenerate_thumbs.php @@ -37,10 +37,10 @@ if (substr($sapi_type, 0, 3) == 'cgi') { define('EVEN_IF_ONLY_LOGIN_ALLOWED',1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only". // Include and load Dolibarr environment variables -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"; // After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). // $user is created but empty. diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index e661a85beb5..ba304305696 100755 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -40,9 +40,9 @@ if (! isset($argv[1]) || ! $argv[1]) { } $now=$argv[1]; -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); -require_once(DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; // Global variables $version=DOL_VERSION; diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index cb745d9aff3..c78770c7a5c 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -35,11 +35,11 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); -require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php"); -require_once(DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +require_once DOL_DOCUMENT_ROOT."/user/class/user.class.php"; +require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; $langs->load("main"); $langs->load("errors"); diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index dd5e3d18de4..fa97c871a50 100755 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -40,9 +40,9 @@ if (! isset($argv[1]) || ! $argv[1]) { } $now=$argv[1]; -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); -require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +require_once DOL_DOCUMENT_ROOT."/user/class/user.class.php"; // Global variables $version=DOL_VERSION; diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 9a04f81c557..8c95bc0071f 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -34,10 +34,10 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); -require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +require_once DOL_DOCUMENT_ROOT."/user/class/user.class.php"; $langs->load("main"); $langs->load("errors"); diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php index d381c32676a..2f7ad26a1fe 100755 --- a/scripts/withdrawals/build_withdrawal_file.php +++ b/scripts/withdrawals/build_withdrawal_file.php @@ -34,11 +34,11 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bonprelevement.class.php"); -require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); -require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); -require_once(DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php"); +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/compta/prelevement/class/bonprelevement.class.php"; +require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; +require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; +require_once DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php"; // Global variables $version=DOL_VERSION; diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php index f8816f8b570..589a9116c78 100755 --- a/test/phpunit/ModulesTest.php +++ b/test/phpunit/ModulesTest.php @@ -136,7 +136,7 @@ class ModulesTest extends PHPUnit_Framework_TestCase 'Salaries','Service','Skype','Societe','Stock','Stripe','SupplierProposal','Syslog','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow'); foreach($modulelist as $modlabel) { - require_once(DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php'); + require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php'; $class='mod'.$modlabel; $mod=new $class($db); $result=$mod->remove(); diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index fe896894d86..6f7ca3610cd 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -28,7 +28,7 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; -require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP if (empty($user->id)) diff --git a/test/phpunit/WebservicesOrdersTest.php b/test/phpunit/WebservicesOrdersTest.php index e81ee2d3604..7fb2d101184 100644 --- a/test/phpunit/WebservicesOrdersTest.php +++ b/test/phpunit/WebservicesOrdersTest.php @@ -28,7 +28,7 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; -require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP if (empty($user->id)) { diff --git a/test/phpunit/WebservicesOtherTest.php b/test/phpunit/WebservicesOtherTest.php index e3725c8609c..45b01aa77d3 100644 --- a/test/phpunit/WebservicesOtherTest.php +++ b/test/phpunit/WebservicesOtherTest.php @@ -28,7 +28,7 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; -require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP if (empty($user->id)) { diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index e3500a68f5b..bcbb37b0419 100644 --- a/test/phpunit/WebservicesProductsTest.php +++ b/test/phpunit/WebservicesProductsTest.php @@ -30,7 +30,7 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; -require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP if (empty($user->id)) { diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index 90698407527..e1c2249b62a 100644 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -28,7 +28,7 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; -require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP if (empty($user->id)) { diff --git a/test/phpunit/WebservicesUserTest.php b/test/phpunit/WebservicesUserTest.php index 5098da22e6e..bfcdb400cc6 100644 --- a/test/phpunit/WebservicesUserTest.php +++ b/test/phpunit/WebservicesUserTest.php @@ -28,7 +28,7 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; -require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP if (empty($user->id)) { From 4eacad52f2ce32d3cb08c4b57ac7694be3b48bd5 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 27 Jul 2018 10:06:56 +0200 Subject: [PATCH 210/228] Clean and update code --- htdocs/public/ticket/list.php | 5 +++-- htdocs/public/ticket/view.php | 5 +++-- htdocs/resource/contact.php | 10 +++++----- htdocs/ticket/class/ticket.class.php | 11 +++++++---- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index d8290849f55..fe1dacbbbc7 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -121,8 +121,9 @@ if ($action == "view_ticketlist") { } } - if ($error) { - setEventMessage($object->errors, 'errors'); + if ($error || $errors) + { + setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 5383133c42e..38fcb3c4991 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -112,8 +112,9 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" | } } - if ($error) { - setEventMessage($object->errors, 'errors'); + if ($error || $errors) + { + setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } diff --git a/htdocs/resource/contact.php b/htdocs/resource/contact.php index 981a07d7e73..e350c746c12 100644 --- a/htdocs/resource/contact.php +++ b/htdocs/resource/contact.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007-2009 Laurent Destailleur * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2016 Gilles Poirier + * Copyright (C) 2016 Gilles Poirier * * This program is free software; you can redistribute it and/or modify @@ -47,7 +47,7 @@ $result = $object->fetch($id,$ref); /* - * Ajout d'un nouveau contact + * Add a new contact */ if ($action == 'addcontact' && $user->rights->resource->write) @@ -72,17 +72,17 @@ if ($action == 'addcontact' && $user->rights->resource->write) $mesg = $object->error; } - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, null, 'errors'); } } -// bascule du statut d'un contact +// Toggle the status of a contact else if ($action == 'swapstatut' && $user->rights->resource->write) { $result=$object->swapContactStatus(GETPOST('ligne','int')); } -// Efface un contact +// Erase a contact else if ($action == 'deletecontact' && $user->rights->resource->write) { $result = $object->delete_contact(GETPOST('lineid','int')); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 3dc0ab39756..bcec0158454 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1614,9 +1614,12 @@ class Ticket extends CommonObject } include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject, $info_sendto['email'], $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, 0); - if ($mailfile->error) { - setEventMessage($mailfile->error, 'errors'); - } else { + if ($mailfile->error || $mailfile->errors) + { + setEventMessages($mailfile->error, $mailfile->errors, 'errors'); + } + else + { $result = $mailfile->sendfile(); if ($result > 0) { $nb_sent++; @@ -1627,7 +1630,7 @@ class Ticket extends CommonObject } } - setEventMessage($langs->trans('TicketNotificationNumberEmailSent', $nb_sent)); + setEventMessages($langs->trans('TicketNotificationNumberEmailSent', $nb_sent), null, 'mesgs'); } return $nb_sent; From 541e919ae0745453590fe0bf75b97510398d8cb2 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 27 Jul 2018 14:49:33 +0200 Subject: [PATCH 211/228] Clean and update code --- htdocs/user/notify/card.php | 4 ++-- htdocs/variants/admin/admin.php | 8 ++++---- htdocs/variants/card.php | 16 ++++++++-------- htdocs/variants/combinations.php | 16 ++++++++-------- htdocs/variants/create.php | 4 ++-- htdocs/variants/create_val.php | 6 +++--- htdocs/variants/generator.php | 6 +++--- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 307b8ae5bc9..e8914298ac3 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2016 Abbes Bahfir * @@ -67,7 +67,7 @@ if ($action == 'add') if ($actionid <= 0) { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), null, 'errors'); $error++; } diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index dc039bf6d5f..57db7c49f20 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -31,15 +31,15 @@ if ($_POST) { $value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD'); if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) { - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } else { - setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); + setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); } if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } else { - setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); + setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); } } diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 547a82d0f63..3addef7ddf9 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -50,9 +50,9 @@ if ($_POST) { $object->label = $label; if ($object->update($user) < 1) { - setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); + setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); } else { - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2)); exit(); } @@ -77,9 +77,9 @@ if ($_POST) { if (! $error) { if ($objectval->update($user) > 0) { - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } else { - setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); + setEventMessage($langs->trans('CoreErrorMessage'), null, 'errors'); } } } @@ -99,11 +99,11 @@ if ($confirm == 'yes') { if ($res < 1 || ($object->delete() < 1)) { $db->rollback(); - setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); + setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2)); } else { $db->commit(); - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.dol_buildpath('/variants/list.php', 2)); } exit(); @@ -113,9 +113,9 @@ if ($confirm == 'yes') { if ($objectval->fetch($valueid) > 0) { if ($objectval->delete() < 1) { - setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); + setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); } else { - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2)); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index dbc413542c4..b741fef40bb 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -104,7 +104,7 @@ if ($_POST) { $features = $_SESSION['addvariant_'.$object->id]; if (!$features) { - setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); + setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { @@ -147,7 +147,7 @@ if ($_POST) { $result = $prodcomb->createProductCombination($object, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact); if ($result > 0) { - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); unset($_SESSION['addvariant_'.$object->id]); $db->commit(); @@ -214,7 +214,7 @@ if ($_POST) { } else { $db->commit(); - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } } @@ -230,7 +230,7 @@ if ($_POST) { $prodcomb->variation_weight = $weight_impact; if ($prodcomb->update($user) > 0) { - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); exit(); } else { @@ -250,13 +250,13 @@ if ($action === 'confirm_deletecombination') { if ($prodcomb->delete($user) > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0) { $db->commit(); - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2)); exit(); } $db->rollback(); - setEventMessage($langs->trans('ProductCombinationAlreadyUsed'), 'errors'); + setEventMessages($langs->trans('ProductCombinationAlreadyUsed'), null, 'errors'); $action = ''; } } elseif ($action === 'edit') { @@ -284,12 +284,12 @@ if ($action === 'confirm_deletecombination') { header('Location: '.dol_buildpath('/variants/combinations.php?id='.$prodstatic->id, 2)); exit(); } else { - setEventMessage($langs->trans('ErrorCopyProductCombinations'), 'errors'); + setEventMessages($langs->trans('ErrorCopyProductCombinations'), null, 'errors'); } } } else { - setEventMessage($langs->trans('ErrorDestinationProductNotFound'), 'errors'); + setEventMessages($langs->trans('ErrorDestinationProductNotFound'), null, 'errors'); } } diff --git a/htdocs/variants/create.php b/htdocs/variants/create.php index f1a34a835b6..c4d775f3d50 100644 --- a/htdocs/variants/create.php +++ b/htdocs/variants/create.php @@ -29,7 +29,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); if ($_POST) { if (empty($ref) || empty($label)) { - setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); + setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { $prodattr = new ProductAttribute($db); @@ -38,7 +38,7 @@ if ($_POST) { $resid = $prodattr->create($user); if ($resid > 0) { - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); if ($backtopage) { header('Location: '.$backtopage); diff --git a/htdocs/variants/create_val.php b/htdocs/variants/create_val.php index b290182a042..f0dd8e9cb74 100644 --- a/htdocs/variants/create_val.php +++ b/htdocs/variants/create_val.php @@ -58,7 +58,7 @@ if ($cancel) if ($action == 'add') { if (empty($ref) || empty($value)) { - setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); + setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { $objectval->fk_product_attribute = $object->id; @@ -66,11 +66,11 @@ if ($action == 'add') $objectval->value = $value; if ($objectval->create($user) > 0) { - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id); exit(); } else { - setEventMessage($langs->trans('ErrorCreatingProductAttributeValue'), 'errors'); + setEventMessages($langs->trans('ErrorCreatingProductAttributeValue'), null, 'errors'); } } } diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index 4daa2d8f45a..35cd9fc2a24 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -115,18 +115,18 @@ if ($_POST) { if ($res > 0) { $db->commit(); - setEventMessage($langs->trans('RecordSaved')); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); exit; } } else { - setEventMessage($langs->trans('ErrorDeletingGeneratedProducts'), 'errors'); + setEventMessages($langs->trans('ErrorDeletingGeneratedProducts'), null, 'errors'); } $db->rollback(); } else { - setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); + setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } } From 5a4524451c5be80119404724bc33591937e4e76f Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 28 Jul 2018 14:02:33 +0200 Subject: [PATCH 212/228] standardize --- htdocs/accountancy/admin/account.php | 1 + htdocs/accountancy/admin/accountmodel.php | 2 +- htdocs/accountancy/admin/card.php | 2 +- htdocs/accountancy/admin/categories.php | 2 +- htdocs/accountancy/admin/categories_list.php | 2 +- htdocs/accountancy/admin/defaultaccounts.php | 1 + htdocs/accountancy/admin/export.php | 1 + htdocs/accountancy/admin/fiscalyear.php | 2 +- htdocs/accountancy/admin/fiscalyear_card.php | 1 + htdocs/accountancy/admin/fiscalyear_info.php | 1 + htdocs/accountancy/admin/importaccounts.php | 1 + htdocs/accountancy/admin/index.php | 1 + htdocs/accountancy/admin/journals_list.php | 2 +- htdocs/accountancy/admin/productaccount.php | 1 + htdocs/accountancy/bookkeeping/balance.php | 3 ++- htdocs/accountancy/bookkeeping/balancebymonth.php | 1 + htdocs/accountancy/bookkeeping/card.php | 1 + htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/accountancy/bookkeeping/listbyaccount.php | 1 + 19 files changed, 20 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 493c9e62717..2587a58aef6 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -406,5 +406,6 @@ if ($resql) dol_print_error($db); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index f024f54c41c..2c7d92f3735 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -1004,7 +1004,7 @@ if ($id) print '
'; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 9643227da64..6a92a3f6080 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -397,6 +397,6 @@ else if ($id > 0 || $ref) { } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index aec34469559..735c5595ddc 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -184,6 +184,6 @@ if ($action == 'display' || $action == 'delete') { print ""; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 15a50e7b8e8..900205b7588 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -800,7 +800,7 @@ if ($id) print '
'; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index c33d4326836..8cd45c1cfda 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -190,5 +190,6 @@ print '
"; print ''; - llxFooter(); } +// End of page +llxFooter(); $db->close(); diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index 03265e434f6..3a0a1f73308 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -140,5 +140,6 @@ if ($resql) { } print "\n"; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 92c5713880c..e17cefd77bb 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -714,5 +714,6 @@ if ($action == 'create') dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b0a91f7ce36..ee44b52ab7d 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -748,6 +748,6 @@ print '
'; print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 80a4f0db5e8..55e9c8ab7ad 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -421,5 +421,6 @@ print ''; print ""; print ''; +// End of page llxFooter(); $db->close(); From f17275845d46e32414b4b0bdc05f1a3b153b0181 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 28 Jul 2018 14:29:28 +0200 Subject: [PATCH 213/228] standardize --- htdocs/accountancy/customer/card.php | 1 + htdocs/accountancy/customer/index.php | 2 +- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/customer/list.php | 6 ++++-- htdocs/accountancy/expensereport/card.php | 1 + htdocs/accountancy/expensereport/index.php | 1 + htdocs/accountancy/expensereport/lines.php | 2 +- htdocs/accountancy/expensereport/list.php | 6 ++++-- htdocs/accountancy/index.php | 1 + htdocs/accountancy/supplier/card.php | 1 + htdocs/accountancy/supplier/index.php | 2 +- htdocs/accountancy/supplier/lines.php | 3 +-- htdocs/accountancy/supplier/list.php | 6 ++++-- htdocs/adherents/admin/adherent.php | 3 +-- htdocs/adherents/admin/adherent_emails.php | 3 +-- htdocs/adherents/admin/adherent_extrafields.php | 2 +- htdocs/adherents/admin/adherent_type_extrafields.php | 2 +- htdocs/adherents/admin/website.php | 3 +-- htdocs/adherents/agenda.php | 4 +--- htdocs/adherents/card.php | 2 +- htdocs/adherents/cartes/carte.php | 2 +- htdocs/adherents/document.php | 2 +- htdocs/adherents/htpasswd.php | 3 +-- htdocs/adherents/index.php | 2 +- htdocs/adherents/ldap.php | 1 + htdocs/adherents/list.php | 2 +- htdocs/adherents/note.php | 2 +- htdocs/adherents/stats/byproperties.php | 3 +-- htdocs/adherents/stats/geo.php | 4 +--- htdocs/adherents/stats/index.php | 3 +-- htdocs/adherents/subscription.php | 3 +-- htdocs/adherents/subscription/card.php | 3 +-- htdocs/adherents/subscription/info.php | 1 + htdocs/adherents/subscription/list.php | 2 +- htdocs/adherents/type.php | 3 +-- htdocs/adherents/type_ldap.php | 1 + htdocs/admin/agenda_extrafields.php | 2 +- htdocs/admin/agenda_extsites.php | 3 +-- htdocs/admin/agenda_other.php | 2 +- htdocs/admin/agenda_reminder.php | 2 +- htdocs/admin/agenda_xcal.php | 2 +- htdocs/admin/menus/edit.php | 1 + htdocs/admin/menus/index.php | 2 +- htdocs/admin/menus/other.php | 2 +- htdocs/admin/system/about.php | 3 +-- htdocs/admin/system/browser.php | 3 +-- htdocs/admin/system/constall.php | 3 +-- htdocs/admin/system/database-tables.php | 1 + htdocs/admin/system/database.php | 2 +- htdocs/admin/system/dbtable.php | 2 +- htdocs/admin/system/dolibarr.php | 3 +-- htdocs/admin/system/filecheck.php | 5 +---- htdocs/admin/system/index.php | 7 +++---- htdocs/admin/system/modules.php | 1 + htdocs/admin/system/os.php | 2 +- htdocs/admin/system/perf.php | 3 +-- htdocs/admin/system/phpinfo.php | 3 +-- htdocs/admin/system/xcache.php | 2 +- htdocs/admin/tools/dolibarr_export.php | 2 +- htdocs/admin/tools/dolibarr_import.php | 2 +- htdocs/admin/tools/eaccelerator.php | 3 +-- htdocs/admin/tools/index.php | 2 +- htdocs/admin/tools/listevents.php | 2 +- htdocs/admin/tools/listsessions.php | 1 + htdocs/admin/tools/purge.php | 3 +-- htdocs/admin/tools/update.php | 3 +-- 66 files changed, 77 insertions(+), 87 deletions(-) diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 7e1387db951..677bc627c80 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -159,5 +159,6 @@ if (! empty($id)) { print "Error ID incorrect"; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 4191243e412..45387722719 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -415,6 +415,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. } } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index cc0ced6b067..83ddd1bd888 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -400,6 +400,6 @@ if ($result) { print $db->lasterror(); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 69396131b02..b5fec4a0e7c 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -201,8 +201,9 @@ llxHeader('', $langs->trans("Ventilation")); if (empty($chartaccountcode)) { print $langs->trans("ErrorChartOfAccountSystemNotSelected"); - llxFooter(); - $db->close(); + // End of page + llxFooter(); + $db->close(); exit; } @@ -524,5 +525,6 @@ jQuery(document).ready(function() { }); '; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index d9b2137157d..b245e2539a7 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -167,5 +167,6 @@ if (! empty($id)) { print "Error ID incorrect"; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 47a6f15e8c6..7f906e93879 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -345,5 +345,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print '
'; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 473bc379057..ae368a20de1 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -349,6 +349,6 @@ if ($result) { print $db->lasterror(); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index a20f88f1c30..8057c9809f2 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -180,8 +180,9 @@ llxHeader('', $langs->trans("ExpenseReportsVentilation")); if (empty($chartaccountcode)) { print $langs->trans("ErrorChartOfAccountSystemNotSelected"); - llxFooter(); - $db->close(); + // End of page + llxFooter(); + $db->close(); exit; } @@ -422,5 +423,6 @@ jQuery(document).ready(function() { }); '; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 2881de98132..53ba48ff9d9 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -163,5 +163,6 @@ else print $langs->trans("Module10Desc")."
\n"; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index f126d00f2e9..439b8625342 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -162,5 +162,6 @@ if (! empty($id)) { print "Error ID incorrect"; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 3a6af92e41b..3e6a6991f6c 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -342,6 +342,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print '
'; } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index ef54dec564d..326d249f86d 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -406,7 +406,6 @@ if ($result) { print $db->lasterror(); } - - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 57fdf0ace48..18c9fa11a3c 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -202,8 +202,9 @@ llxHeader('', $langs->trans("SuppliersVentilation")); if (empty($chartaccountcode)) { print $langs->trans("ErrorChartOfAccountSystemNotSelected"); - llxFooter(); - $db->close(); + // End of page + llxFooter(); + $db->close(); exit; } @@ -532,5 +533,6 @@ jQuery(document).ready(function() { }); '; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 4511ee0e8a7..2abc3b10841 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -265,7 +265,6 @@ form_constantes($constantes, 0, $helptext); dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php index 88514d83da3..76d40e57c17 100644 --- a/htdocs/adherents/admin/adherent_emails.php +++ b/htdocs/adherents/admin/adherent_emails.php @@ -160,7 +160,6 @@ form_constantes($constantes, 0, $helptext); dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/admin/adherent_extrafields.php b/htdocs/adherents/admin/adherent_extrafields.php index cfdea50538f..f47f92faa4c 100644 --- a/htdocs/adherents/admin/adherent_extrafields.php +++ b/htdocs/adherents/admin/adherent_extrafields.php @@ -113,6 +113,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/admin/adherent_type_extrafields.php b/htdocs/adherents/admin/adherent_type_extrafields.php index 2c849628ab9..e78c4ef29e5 100644 --- a/htdocs/adherents/admin/adherent_type_extrafields.php +++ b/htdocs/adherents/admin/adherent_type_extrafields.php @@ -116,6 +116,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index b35df5f0083..31d9c43afbb 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -250,7 +250,6 @@ if (! empty($conf->global->MEMBER_ENABLE_PUBLIC)) print ''.$urlwithroot.'/public/members/new.php'.$entity_qr.''; } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 2b663ecf2bc..8fb1851e021 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -175,8 +175,6 @@ if ($object->id > 0) } } - - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 990c8349e33..bc09ac2c250 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1896,6 +1896,6 @@ else } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index be3a13d8771..ff7e9c3be2e 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -310,6 +310,6 @@ print '
'; print '
'; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 8e12dec056e..4c91efc265c 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -170,6 +170,6 @@ else print $langs->trans("ErrorRecordNotFound"); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index 5814ed3bf70..adc3d32eea4 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -86,7 +86,6 @@ else dol_print_error($db); } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index c9e3d1936c6..030700bb0f6 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -435,6 +435,6 @@ print "
"; print '
'; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index ff0bad063bd..b6bffd3d1bd 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -221,5 +221,6 @@ else print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 3a1dd04443f..db017d71f61 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -827,6 +827,6 @@ print ''; if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit, 1); - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 1b887406df3..ae278b5dbb5 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -120,6 +120,6 @@ if ($id) } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index ded3dec120e..7ae29a7eeb9 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -143,7 +143,6 @@ print ''; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 1c6944c2a0a..9de537ed39a 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -309,8 +309,6 @@ if ($mode) dol_fiche_end(); - - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 083d81d6db6..902c2d35359 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -229,7 +229,6 @@ print '
'; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 3e4af5438c6..7e3dfe28b0e 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -1108,7 +1108,6 @@ else print $langs->trans("ErrorRecordNotFound"); } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index f905225a396..34b58c5b04d 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -417,7 +417,6 @@ if ($rowid && $action != 'edit') print '
'; } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/subscription/info.php b/htdocs/adherents/subscription/info.php index 05856c35f75..649a1e22996 100644 --- a/htdocs/adherents/subscription/info.php +++ b/htdocs/adherents/subscription/info.php @@ -76,5 +76,6 @@ print ''; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 21ba01088e4..91e5b2f8837 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -381,6 +381,6 @@ else dol_print_error($db); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 56363599c10..e9ad0b91498 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -787,7 +787,6 @@ if ($rowid > 0) } } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index 7edb42e6c76..5d60beb2a4d 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -187,5 +187,6 @@ else print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 69e834e22e2..887fba847e4 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -117,6 +117,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 906ecd8d092..236483f5ed4 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -238,7 +238,6 @@ print ''; print "\n"; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 2d20d285720..842c8d01470 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -399,6 +399,6 @@ print ''; print "
"; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index e78a8e089ed..269880236cb 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -247,6 +247,6 @@ print ''; print "
"; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 481a850790e..d76d95da47a 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -198,6 +198,6 @@ if (! empty($conf->use_javascript_ajax)) print ''; } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 191db98a402..2864fe79df0 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -514,5 +514,6 @@ elseif ($action == 'edit') print '
'; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index c3211fc2d75..2e6d8a91008 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -410,6 +410,6 @@ else print '
'; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/menus/other.php b/htdocs/admin/menus/other.php index 7789c3fb21c..0446c59af1d 100644 --- a/htdocs/admin/menus/other.php +++ b/htdocs/admin/menus/other.php @@ -105,6 +105,6 @@ print ''; print ''; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index 61780d51386..e9ea61ac944 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -214,7 +214,6 @@ if ($showpromotemessage) } } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/system/browser.php b/htdocs/admin/system/browser.php index 4f2a53de88d..c5aeff70b88 100644 --- a/htdocs/admin/system/browser.php +++ b/htdocs/admin/system/browser.php @@ -66,7 +66,6 @@ print ''; print ''; print '
'; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index 82e8481c2dd..9d4c4fc3cec 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -249,7 +249,6 @@ if ($resql) print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index 556961cb565..17d72edf20a 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -212,5 +212,6 @@ else } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 45ce3c087e6..d5a7bbcdbfd 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -126,6 +126,6 @@ else } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index cef493c95f8..392c083c382 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -138,6 +138,6 @@ else } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 4b02e7941d2..4dd4ef9dc9b 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -453,7 +453,6 @@ if ($resql) print ''; print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 9a9e2297cba..65a9354a19f 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -433,11 +433,8 @@ if (! $error && $xml) print $out; } - - - +// End of page llxFooter(); - $db->close(); exit($error); diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 3d473640618..7ffef739993 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -25,9 +25,8 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -$langs->load("admin"); -$langs->load("user"); -$langs->load("install"); +// Load translation files required by the page +$langs->loadLangs(array("admin", "user", "install")); if (! $user->admin) accessforbidden(); @@ -114,6 +113,6 @@ print '
'; //print "
\n"; print info_admin($langs->trans("SystemInfoDesc")).'
'; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 4a6967089e2..fda1946875a 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -159,5 +159,6 @@ foreach($rights_ids as $right_id) $old = $right_id; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/system/os.php b/htdocs/admin/system/os.php index 01d48f2444d..251025a4c9e 100644 --- a/htdocs/admin/system/os.php +++ b/htdocs/admin/system/os.php @@ -49,6 +49,6 @@ $osversion=version_os(); print "".$langs->trans("Version")."".$osversion."\n"; print ''; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 1e757b72f63..85ac2aea006 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -491,7 +491,6 @@ print ''.$langs->trans("DatabaseStatistics").': '; print '
'; */ - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index 8664a28b28a..aa502cde421 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -116,7 +116,6 @@ foreach($phparray as $key => $value) print '
'; } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/system/xcache.php b/htdocs/admin/system/xcache.php index 53eaeec085f..b582e61619b 100644 --- a/htdocs/admin/system/xcache.php +++ b/htdocs/admin/system/xcache.php @@ -76,6 +76,6 @@ if ($action == 'clear') } */ +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 1c985e23090..c9ef19dae98 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -522,6 +522,6 @@ print $langs->trans("BackupDescX").'

'; close(); diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index f390c192159..aca900c1cbc 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -212,6 +212,6 @@ else if (in_array($type, array('pgsql'))) close(); diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index d3253c02514..9999734a8f8 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -335,7 +335,6 @@ if (function_exists('eaccelerator_get')) { print "

"; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/tools/index.php b/htdocs/admin/tools/index.php index 98a490550ca..c5a05ef2136 100644 --- a/htdocs/admin/tools/index.php +++ b/htdocs/admin/tools/index.php @@ -56,6 +56,6 @@ print '

'; //print '
'; print '
'; // For a reason I don't know, the div class="center does not works, we must keep the
- +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 48d3ef57fd5..db5157789e1 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -339,6 +339,6 @@ else dol_print_error($db); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index 70b0987732b..13b99d92f6d 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -208,5 +208,6 @@ print ''; print '
'; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index f415ed1692c..097fc507240 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -119,7 +119,6 @@ if (preg_match('/^confirm/i',$choice)) print $form->formconfirm($_SERVER["PHP_SELF"].'?choice=allfiles', $langs->trans('Purge'), $langs->trans('ConfirmPurge').img_warning().' ', 'purge', $formquestion, 'no', 2); } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index d0802d6b473..41923aa068d 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -142,7 +142,6 @@ print '
'; print $langs->trans("GoModuleSetupArea", DOL_URL_ROOT.'/admin/modules.php?mode=deploy', $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules")); - +// End of page llxFooter(); - $db->close(); From 9cc40fcb215fe22c1997002dc5e07b5ca70364ab Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 28 Jul 2018 17:26:56 +0200 Subject: [PATCH 214/228] standardize --- htdocs/admin/agenda.php | 2 +- htdocs/admin/bank.php | 2 +- htdocs/admin/bank_extrafields.php | 2 +- htdocs/admin/barcode.php | 1 + htdocs/admin/boxes.php | 3 +-- htdocs/admin/chequereceipts.php | 2 +- htdocs/admin/clicktodial.php | 2 +- htdocs/admin/commande.php | 3 +-- htdocs/admin/company.php | 3 +-- htdocs/admin/compta.php | 1 + htdocs/admin/confexped.php | 1 + htdocs/admin/const.php | 3 +-- htdocs/admin/contract.php | 3 +-- htdocs/admin/dav.php | 2 +- htdocs/admin/defaultvalues.php | 3 +-- htdocs/admin/delais.php | 1 + htdocs/admin/dict.php | 2 +- htdocs/admin/ecm.php | 1 + htdocs/admin/events.php | 2 +- htdocs/admin/expedition.php | 1 + htdocs/admin/expedition_extrafields.php | 2 +- htdocs/admin/expeditiondet_extrafields.php | 2 +- htdocs/admin/expensereport.php | 3 +-- htdocs/admin/expensereport_extrafields.php | 2 +- htdocs/admin/expensereport_ik.php | 3 ++- htdocs/admin/expensereport_rules.php | 3 ++- htdocs/admin/export.php | 14 +++++--------- 27 files changed, 33 insertions(+), 36 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 6fedfa6d2cb..7f41927b478 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -202,6 +202,6 @@ print "\n"; print "
"; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index a4e9e4bb210..1e9acde2665 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -432,6 +432,6 @@ print "\n"; print ''; dol_fiche_end(); +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 99b8d09f277..3b95c158f27 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -114,6 +114,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index a7a863c4725..4e0c683a73f 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -405,5 +405,6 @@ if ($conf->produit->enabled) print "
"; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 04fd76e96fc..9f3453f7587 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -488,7 +488,6 @@ print '
'."\n"; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index df628ecc87f..82b0ed3848c 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -280,6 +280,6 @@ dol_fiche_end(); print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index c2cfaf9f72a..34a641137dc 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -140,6 +140,6 @@ if (! empty($conf->global->CLICKTODIAL_URL)) } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index cee12e4b08e..64df9194197 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -679,7 +679,6 @@ print "\n"; print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 949038b4413..4a006c56268 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -1153,7 +1153,6 @@ else print '
'; } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index 8e17541bfef..214c30dc544 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -164,5 +164,6 @@ print "\n"; print '

'; print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php index e4691a42e78..9e6745e6c29 100644 --- a/htdocs/admin/confexped.php +++ b/htdocs/admin/confexped.php @@ -147,5 +147,6 @@ print ''; print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 9dd68c16326..be5f785f9e4 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -314,7 +314,6 @@ if ($conf->use_javascript_ajax) print "\n"; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 74f7acb04f3..60be9e062ba 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -509,7 +509,6 @@ print ''; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index ea4bbf97af0..e882a56e2b8 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -143,6 +143,6 @@ $message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'Web $message.='
'; print $message; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 84271cff38f..984ddfbefd7 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -412,7 +412,6 @@ dol_fiche_end(); print "\n"; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index ae3c43c5b24..14dfb9922f6 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -415,5 +415,6 @@ if($action == 'edit') { } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 32995bce38f..0c25f3a5bd8 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1735,7 +1735,7 @@ else print '
'; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index dc2f3e489f7..3126f432938 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -109,5 +109,6 @@ print ''; print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index 1d1ec548853..606d3a5f201 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -114,6 +114,6 @@ print ""; print "\n"; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index eb18f904229..c851010635e 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -507,5 +507,6 @@ print '
$(function() { }); '; dol_fiche_end(); -llxFooter(); +// End of page +llxFooter(); $db->close(); diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php index b6f12a723ff..292c3604799 100644 --- a/htdocs/admin/export.php +++ b/htdocs/admin/export.php @@ -6,7 +6,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * 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 @@ -32,9 +32,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('admin', 'exports')); - -$langs->load('other'); +$langs->loadLangs(array('admin', 'exports', 'other')); if (! $user->admin) accessforbidden(); @@ -73,7 +71,7 @@ dol_fiche_head( // Setup page goes here $form=new Form($db); -$var=false; + print ''; print ''; print ''."\n"; @@ -82,8 +80,7 @@ print ''."\n"; // Example with a yes / no select -$var=!$var; -print ''; +print ''; print ''; print ''; print ''; - print '
'.$langs->trans("ExportModel").'
'.$langs->trans("set_EXPORTS_SHARE_MODELS").' '; @@ -94,9 +91,8 @@ echo ajax_constantonoff('EXPORTS_SHARE_MODELS'); print ''; print '
'; +// End of page llxFooter(); - $db->close(); From 36ea20b7d48d21a8df1475ed39536ffe70c4c39c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 28 Jul 2018 18:03:14 +0200 Subject: [PATCH 215/228] standardize --- htdocs/admin/external_rss.php | 2 +- htdocs/admin/facture.php | 3 +-- htdocs/admin/fckeditor.php | 2 +- htdocs/admin/fichinter.php | 7 ++----- htdocs/admin/geoipmaxmind.php | 2 +- htdocs/admin/holiday.php | 1 + htdocs/admin/ihm.php | 2 +- htdocs/admin/index.php | 3 +-- htdocs/admin/ldap.php | 1 + htdocs/admin/ldap_contacts.php | 1 + htdocs/admin/ldap_groups.php | 1 + htdocs/admin/ldap_members.php | 3 +-- htdocs/admin/ldap_members_types.php | 1 + htdocs/admin/ldap_users.php | 1 + htdocs/admin/limits.php | 3 +-- htdocs/admin/livraison.php | 1 + htdocs/admin/livraison_extrafields.php | 2 +- htdocs/admin/livraisondet_extrafields.php | 2 +- htdocs/admin/loan.php | 1 + htdocs/admin/mailing.php | 2 +- htdocs/admin/mailman.php | 3 +-- htdocs/admin/mails.php | 3 +-- htdocs/admin/mails_emailing.php | 3 +-- htdocs/admin/mails_templates.php | 1 + htdocs/admin/menus.php | 3 +-- htdocs/admin/modulehelp.php | 3 +-- htdocs/admin/modules.php | 4 +--- htdocs/admin/multicurrency.php | 2 +- htdocs/admin/notification.php | 3 +-- htdocs/admin/oauth.php | 2 +- htdocs/admin/oauthlogintokens.php | 2 +- htdocs/admin/order_extrafields.php | 2 +- htdocs/admin/orderdet_extrafields.php | 2 +- htdocs/admin/payment.php | 3 +-- htdocs/admin/pdf.php | 3 +-- htdocs/admin/perms.php | 3 ++- htdocs/admin/prelevement.php | 1 + htdocs/admin/propal.php | 3 +-- htdocs/admin/proxy.php | 1 + htdocs/admin/receiptprinter.php | 2 +- htdocs/admin/resource.php | 2 +- htdocs/admin/resource_extrafields.php | 2 +- htdocs/admin/salaries.php | 3 ++- htdocs/admin/security.php | 3 +-- htdocs/admin/security_file.php | 2 +- htdocs/admin/security_other.php | 2 +- htdocs/admin/sms.php | 3 +-- htdocs/admin/spip.php | 2 +- htdocs/admin/stock.php | 3 +-- 49 files changed, 52 insertions(+), 60 deletions(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index e8683dfc4ee..e0f3f72f927 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -325,6 +325,6 @@ else dol_print_error($db); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index f00d125a4d5..6c28081e6fc 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -782,7 +782,6 @@ print ''; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 19d4a4cc772..bed1d4d9bcb 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -234,6 +234,6 @@ else */ } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index a216f2d4ab7..c714c0c6c1b 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2011-2017 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * 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 @@ -560,7 +560,6 @@ print "\n"; print ''; //Use draft Watermark - print "
"; print ''; print ""; @@ -635,12 +634,10 @@ print ''; print ''; print '
'; - - - print ''; print '
'; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php index 9c944324527..9f154591f0f 100644 --- a/htdocs/admin/geoipmaxmind.php +++ b/htdocs/admin/geoipmaxmind.php @@ -153,6 +153,6 @@ if ($geoip) $geoip->close(); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index b199505d214..e2d1cfca145 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -517,5 +517,6 @@ print ''; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 62f17d5cb1d..355f5ae44fd 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -578,6 +578,6 @@ else // Show print '
'; } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 6542cec1174..2f64793c28b 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -114,7 +114,6 @@ if (empty($reshook)) print '
'; } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 6776cfb1480..052b2f38988 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -340,5 +340,6 @@ if (function_exists("ldap_connect")) } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 3188bf6e58a..dd85a998383 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -318,6 +318,7 @@ if (function_exists("ldap_connect")) } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 4ae6ce9ad97..2650fe4fe6e 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -251,5 +251,6 @@ if (function_exists("ldap_connect")) } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index 616eb99a8da..240901ec04d 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -442,7 +442,6 @@ if (function_exists("ldap_connect")) } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index e45857f2f38..e845fd37adc 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -241,5 +241,6 @@ if (function_exists("ldap_connect")) } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index 8b11069fc61..513aa63f035 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -470,5 +470,6 @@ if (function_exists("ldap_connect")) } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index e9389b0271d..d24891f80f6 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -306,7 +306,6 @@ else */ } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 88ce717f005..91fb9f964e4 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -478,6 +478,7 @@ print ''; print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/livraison_extrafields.php b/htdocs/admin/livraison_extrafields.php index c9fed1c6554..55fe6f10362 100644 --- a/htdocs/admin/livraison_extrafields.php +++ b/htdocs/admin/livraison_extrafields.php @@ -119,6 +119,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/livraisondet_extrafields.php b/htdocs/admin/livraisondet_extrafields.php index 921e9cfee41..e70b4f2d09b 100644 --- a/htdocs/admin/livraisondet_extrafields.php +++ b/htdocs/admin/livraisondet_extrafields.php @@ -120,6 +120,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index 3349ac0056a..419f6efbee9 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -122,5 +122,6 @@ print "\n"; print '
'; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 32fbdd4aeb6..d5b866d9d20 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -152,6 +152,6 @@ print '
\n"; print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index 87a89f5d99b..9490a291729 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -205,5 +205,6 @@ print '
'; print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 4465017bdc6..abe2fbea655 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -447,7 +447,7 @@ $object->barcode = '3700123862396'; //$printer->sendToPrinter($object, 1, 16); //setEventMessages($printer->error, $printer->errors, 'errors'); +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index e8f8bdba204..566e57e587b 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -137,6 +137,6 @@ print ''; dol_fiche_end(); - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index 722e5d88a9c..b8ea860ac25 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -116,6 +116,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php index 6c5281173c3..c5ec770e393 100644 --- a/htdocs/admin/salaries.php +++ b/htdocs/admin/salaries.php @@ -127,5 +127,6 @@ print '
'; - // Form to test upload print '
'; $formfile=new FormFile($db); @@ -188,5 +187,6 @@ $formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestF $filearray=dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1); $formfile->list_of_documents($filearray, null, 'admin_temp', ''); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 6503ab10f77..0e3da947fa8 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -206,6 +206,6 @@ print '
'; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index db1cb20b5e3..3dbc785d1d7 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -331,7 +331,6 @@ else } } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index b9892fdf2a9..d179c66d58d 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -163,6 +163,6 @@ else dol_fiche_end(); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index e1098ef262d..b83f87af162 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -566,7 +566,6 @@ if ($conf->global->PRODUIT_SOUSPRODUITS) } */ - +// End of page llxFooter(); - $db->close(); From 892174cbf8823b774f68e1a1b2adb4c9cfe8512c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 29 Jul 2018 10:29:12 +0200 Subject: [PATCH 216/228] standardize --- htdocs/admin/supplier_invoice.php | 3 +-- htdocs/admin/supplier_order.php | 3 +-- htdocs/admin/supplier_payment.php | 3 +-- htdocs/admin/supplier_proposal.php | 1 + htdocs/admin/supplierinvoice_extrafields.php | 2 +- htdocs/admin/supplierinvoicedet_extrafields.php | 2 +- htdocs/admin/supplierorder_extrafields.php | 2 +- htdocs/admin/supplierorderdet_extrafields.php | 2 +- htdocs/admin/syslog.php | 2 +- htdocs/admin/taxes.php | 2 +- htdocs/admin/ticket.php | 2 +- htdocs/admin/ticket_extrafields.php | 2 +- htdocs/admin/translation.php | 2 +- htdocs/admin/triggers.php | 2 +- htdocs/admin/user.php | 1 + htdocs/admin/usergroup.php | 1 + htdocs/admin/website.php | 4 +--- htdocs/admin/website_options.php | 3 +-- htdocs/admin/workflow.php | 3 +-- 19 files changed, 19 insertions(+), 23 deletions(-) diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 75a917dd185..367d1fe0d36 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -516,7 +516,6 @@ print "\n"; print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 695d25a963c..72050867dfa 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -589,7 +589,6 @@ print "\n"; print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index c1f3a7cb25d..55fb311ccda 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -430,7 +430,6 @@ print ''; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 99069447e81..eeb148e9d99 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -582,6 +582,7 @@ print "\n"; print "\n ".$langs->trans("PathDirectory")."\n ".$conf->supplier_proposal->dir_output."\n\n"; print "\n
"; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 16da8bf7a5c..65ce01a4faf 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -123,6 +123,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index 4ca9fd516d7..cdf128871fd 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -119,6 +119,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index 58c0408510d..640b6375c57 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -117,6 +117,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 7dfaa02545e..65fe0537ba7 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -118,6 +118,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 45dc91a8b95..e163fc83de5 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -302,6 +302,6 @@ if(! empty($conf->loghandlers['mod_syslog_file']) && ! empty($conf->cron->enable print ''; print "\n"; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index 7c4bf64909f..304f9b79bd0 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -273,6 +273,6 @@ if (! empty($conf->accounting->enabled)) print '

'.$langs->trans("AccountingAccountForSalesTaxAreDefinedInto", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup")).''; } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 95af411b813..38f0a8eb497 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -641,6 +641,6 @@ print ''; print '
'; print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index 0687a33c52b..07ace9fea0c 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -109,6 +109,6 @@ if ($action == 'edit' && !empty($attrname)) { include DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index cc21a8ff717..4c215e9ae52 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -584,6 +584,6 @@ if (! empty($langcode)) dol_set_focus('#transvalue'); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/triggers.php b/htdocs/admin/triggers.php index 1a1893e2eb0..cd2f33b4cb0 100644 --- a/htdocs/admin/triggers.php +++ b/htdocs/admin/triggers.php @@ -84,6 +84,6 @@ foreach ($triggers as $trigger) print ''; print '
'; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index f888c8410bb..2cf8fc5b6f3 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -337,5 +337,6 @@ print "
"; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index 28f1ad6af2f..c1b55dcec6a 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -282,5 +282,6 @@ print "
"; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 80ca0b29c0a..fcdeee79249 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -646,9 +646,7 @@ if ($id) dol_fiche_end(); -//print '
'; - - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php index c688da0e550..9d724b86390 100644 --- a/htdocs/admin/website_options.php +++ b/htdocs/admin/website_options.php @@ -143,9 +143,8 @@ else dol_fiche_end(); -//print '
'; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index b5bdec73f3e..24a39ce827a 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -187,7 +187,6 @@ if ($nbqualified == 0) } print ''; - +// End of page llxFooter(); - $db->close(); From 69feb3af141829d82c08291e54965186de8dfbb9 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 29 Jul 2018 11:33:52 +0200 Subject: [PATCH 217/228] standardize --- htdocs/asset/admin/assets_extrafields.php | 2 +- htdocs/asset/admin/assets_type_extrafields.php | 2 +- htdocs/asset/admin/setup.php | 3 +-- htdocs/asset/document.php | 2 +- htdocs/asset/info.php | 1 + htdocs/asset/note.php | 2 +- htdocs/asset/type.php | 3 +-- htdocs/asterisk/wrapper.php | 1 + htdocs/barcode/codeinit.php | 2 +- htdocs/barcode/printsheet.php | 2 +- htdocs/blockedlog/admin/blockedlog.php | 1 + htdocs/blockedlog/admin/blockedlog_list.php | 3 ++- 12 files changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php index 1cdf78df4bf..109b0f1e94f 100644 --- a/htdocs/asset/admin/assets_extrafields.php +++ b/htdocs/asset/admin/assets_extrafields.php @@ -109,6 +109,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php index d828bffa4de..e8f1d71370b 100644 --- a/htdocs/asset/admin/assets_type_extrafields.php +++ b/htdocs/asset/admin/assets_type_extrafields.php @@ -107,6 +107,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index c240f350590..1168fd3ada3 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -107,9 +107,8 @@ else print '
'; } - -// Page end dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index 66baaae196c..6427befd03e 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -148,6 +148,6 @@ else accessforbidden('',0,0); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php index 71460f31a2c..e8820ee5cfa 100644 --- a/htdocs/asset/info.php +++ b/htdocs/asset/info.php @@ -79,5 +79,6 @@ print ''; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index cf0166df96f..775b3e8747e 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -144,6 +144,6 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index f4409ee5417..001912f7de3 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -851,7 +851,6 @@ if ($rowid > 0) } } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index 8cd5ff979a0..66ff541d499 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -190,5 +190,6 @@ else { print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx'; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 26386052480..7086af7f17e 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -319,6 +319,6 @@ if ($conf->product->enabled || $conf->product->service) print ''; print '
'; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 7dfec76b39e..6dd578993ca 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -441,6 +441,6 @@ print '
'; print '
'; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index 326fea79c5d..8c2835d856c 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -178,5 +178,6 @@ if (GETPOST('withtab','alpha')) print '

'; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 8f5d47bf704..6bb1876b926 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -587,5 +587,6 @@ if (GETPOST('withtab','alpha')) print '

'; +// End of page llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file From de70bf983ec424a089879d18df7df18d9628da34 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 29 Jul 2018 13:40:35 +0200 Subject: [PATCH 218/228] standardize --- htdocs/bookmarks/admin/bookmark.php | 1 + htdocs/bookmarks/card.php | 3 +-- htdocs/bookmarks/list.php | 2 +- htdocs/cashdesk/admin/cashdesk.php | 1 + htdocs/categories/admin/categorie.php | 1 + htdocs/categories/admin/categorie_extrafields.php | 2 +- htdocs/categories/card.php | 3 +-- htdocs/categories/edit.php | 3 +-- htdocs/categories/index.php | 2 +- htdocs/categories/photos.php | 2 +- htdocs/categories/traduction.php | 1 + htdocs/categories/viewcat.php | 2 +- htdocs/collab/index.php | 5 +---- htdocs/comm/action/card.php | 3 +-- htdocs/comm/action/document.php | 3 +-- htdocs/comm/action/index.php | 2 +- htdocs/comm/action/info.php | 1 + htdocs/comm/action/list.php | 3 +-- htdocs/comm/action/pertype.php | 4 +--- htdocs/comm/action/peruser.php | 4 +--- htdocs/comm/action/rapport/index.php | 1 + htdocs/comm/admin/propal_extrafields.php | 2 +- htdocs/comm/admin/propaldet_extrafields.php | 2 +- 23 files changed, 23 insertions(+), 30 deletions(-) diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php index 25fa032902f..ed20f619b25 100644 --- a/htdocs/bookmarks/admin/bookmark.php +++ b/htdocs/bookmarks/admin/bookmark.php @@ -81,5 +81,6 @@ print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index d450e476506..b82c2b11b6c 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -336,7 +336,6 @@ if ($id > 0 && ! preg_match('/^add/i',$action)) } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index ac5a89c66f3..10ce877c7e0 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -209,7 +209,7 @@ else dol_print_error($db); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index f4af16b3739..62867d855cb 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -185,5 +185,6 @@ print '
\n"; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index 92e23a2199a..03adfdbb41e 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -122,5 +122,6 @@ print ''; print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 3fbd29a640b..abea3f41eeb 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -111,6 +111,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index db56902347b..ce3324505eb 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -288,7 +288,6 @@ if ($user->rights->categorie->creer) } } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index b420847f6fd..cdfac54fb9d 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -192,7 +192,6 @@ print '
'; - - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index e57e51caf62..e634da4fe80 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -202,6 +202,6 @@ print ""; print '
'; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 472a8eb9b95..095c0c611c5 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -273,6 +273,6 @@ else print $langs->trans("ErrorUnknown"); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 7d71b43a81b..dbcfca198d2 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -334,5 +334,6 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print '
'; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 24e70e7d587..ba3580cea87 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -697,6 +697,6 @@ if ($type == Categorie::TYPE_PROJECT) } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php index 2c056cd0e07..d7d5e9a8bbd 100644 --- a/htdocs/collab/index.php +++ b/htdocs/collab/index.php @@ -456,9 +456,6 @@ if ($action == 'editcontent') print "
\n\n"; - - - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 1d6a0286b68..dae5fb70617 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1611,7 +1611,6 @@ if ($id > 0) } } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 43e5b89f115..7fc12129cc5 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -268,7 +268,6 @@ else print $langs->trans("ErrorUnknown"); } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index c361d275882..178e4bfb6d7 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1250,8 +1250,8 @@ else // View by day print "\n".''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 9a043a13690..2582e9b6b32 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -114,5 +114,6 @@ print ''; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 2c11a1de977..319499d65fd 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -672,7 +672,6 @@ else dol_print_error($db); } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 2fdfa180319..9350de8f85c 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -730,10 +730,8 @@ jQuery(document).ready(function() { }); '; - - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 0cf056ef3a9..58690dc512b 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -865,10 +865,8 @@ jQuery(document).ready(function() { }); '; - - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 7e4108b470b..ff1c7746afa 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -209,5 +209,6 @@ else dol_print_error($db); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index 6a6aa12862a..becfabc949c 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -111,6 +111,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index 0816a4c035c..7172c0e5b7c 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -118,6 +118,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); From d1f100b0c965e6d408c2f39cf72d3169611e0c3d Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 29 Jul 2018 17:17:29 +0200 Subject: [PATCH 219/228] standardize --- htdocs/comm/card.php | 1 - htdocs/comm/contact.php | 2 +- htdocs/comm/index.php | 2 +- htdocs/comm/mailing/advtargetemailing.php | 1 + htdocs/comm/mailing/card.php | 1 + htdocs/comm/mailing/cibles.php | 3 +-- htdocs/comm/mailing/index.php | 3 +-- htdocs/comm/mailing/info.php | 1 + htdocs/comm/mailing/list.php | 2 +- htdocs/comm/multiprix.php | 1 + htdocs/comm/propal/contact.php | 2 +- htdocs/comm/propal/document.php | 1 + htdocs/comm/propal/index.php | 3 +-- htdocs/comm/propal/info.php | 1 + htdocs/comm/propal/note.php | 2 +- htdocs/comm/propal/stats/index.php | 3 +-- htdocs/comm/prospect/index.php | 2 +- htdocs/comm/prospect/recap-prospect.php | 1 + htdocs/comm/recap-client.php | 1 + htdocs/comm/remise.php | 6 ++++-- htdocs/comm/remx.php | 1 + 21 files changed, 23 insertions(+), 17 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 83db0e0f1d2..d7d5a3f4f5a 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1346,5 +1346,4 @@ else // End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index aa8dae43140..b6d9f0922aa 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -176,6 +176,6 @@ else dol_print_error($db); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index e90a821b5e3..92757dcac36 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -884,6 +884,6 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index b63ffac6efd..4d10120aaeb 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -471,5 +471,6 @@ if ($object->fetch($id) >= 0) { } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 97746ad9d82..469db6f2a54 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1358,5 +1358,6 @@ else } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 08ed54d2fc3..6caa262500e 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -649,7 +649,6 @@ if ($object->fetch($id) >= 0) } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 17693a1a73c..9cd1e8546d0 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -210,7 +210,6 @@ if ($langs->file_exists("html/spam.html",0)) { print '
'; } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index b4f2eaeb6f3..3c1e6e2cffa 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -75,5 +75,6 @@ if ($object->fetch($id) >= 0) dol_fiche_end(); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 87a390d4006..5087698b9ab 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -224,6 +224,6 @@ else dol_print_error($db); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 1e8c5c82cf4..e9ddee12b22 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -177,5 +177,6 @@ if ($_socid > 0) } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 5e21f493c64..4e017ff13d9 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -212,6 +212,6 @@ if ($object->id > 0) } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 1c8d494214d..2f16cd54864 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -179,5 +179,6 @@ else print $langs->trans("ErrorUnknown"); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 0dbe2fb855e..b47a4506412 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -530,7 +530,6 @@ if (! empty($conf->propal->enabled)) //print ''; print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index 317c9902d52..7879612b099 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -127,5 +127,6 @@ print ''; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 607cff245d9..a346f8df18f 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -144,6 +144,6 @@ if ($id > 0 || ! empty($ref)) } } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index ac6b42c45d8..00db6264377 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -344,7 +344,6 @@ print '
'; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 2273012696f..6d7e93af4be 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -275,6 +275,6 @@ if ($resql) //print ''; print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php index 50127d719c8..93cfada8860 100644 --- a/htdocs/comm/prospect/recap-prospect.php +++ b/htdocs/comm/prospect/recap-prospect.php @@ -89,5 +89,6 @@ else dol_print_error($db); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index 6cd41c6c658..86c1bad0521 100644 --- a/htdocs/comm/recap-client.php +++ b/htdocs/comm/recap-client.php @@ -89,5 +89,6 @@ else dol_print_error($db); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 6f3287b8831..f045e570c6e 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -129,8 +129,9 @@ if ($socid > 0) print ''; - llxFooter(); - $db->close(); + // End of page + llxFooter(); + $db->close(); exit; } @@ -324,5 +325,6 @@ if ($socid > 0) } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 3eec109e6b3..78e4643d5e3 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -998,5 +998,6 @@ if ($socid > 0) } } +// End of page llxFooter(); $db->close(); From fb565b15c531b276b393d3918b2c697fa4bdc949 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 29 Jul 2018 19:16:28 +0200 Subject: [PATCH 220/228] standardize --- htdocs/commande/card.php | 1 + htdocs/commande/contact.php | 1 + htdocs/commande/customer.php | 2 +- htdocs/commande/document.php | 2 +- htdocs/commande/index.php | 2 +- htdocs/commande/info.php | 1 + htdocs/commande/list.php | 1 + htdocs/commande/note.php | 1 + htdocs/commande/orderstoinvoice.php | 1 + htdocs/commande/stats/index.php | 3 +-- htdocs/compta/bank/annuel.php | 1 + htdocs/compta/bank/bankentries_list.php | 2 +- htdocs/compta/bank/bilan.php | 1 + htdocs/compta/bank/budget.php | 1 + htdocs/compta/bank/card.php | 1 + htdocs/compta/bank/categ.php | 2 ++ htdocs/compta/bank/document.php | 3 +-- htdocs/compta/bank/graph.php | 3 +-- htdocs/compta/bank/info.php | 1 + htdocs/compta/bank/ligne.php | 2 +- htdocs/compta/bank/list.php | 3 +-- htdocs/compta/bank/releve.php | 3 +-- htdocs/compta/bank/transfer.php | 1 + htdocs/compta/bank/treso.php | 1 + htdocs/compta/bank/various_payment/card.php | 4 +--- htdocs/compta/bank/various_payment/document.php | 2 +- htdocs/compta/bank/various_payment/index.php | 1 + htdocs/compta/bank/various_payment/info.php | 2 +- 28 files changed, 29 insertions(+), 20 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0c3e4328505..10005f3004a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2678,5 +2678,6 @@ if ($action == 'create' && $user->rights->commande->creer) } } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 7669239134a..bd00116e026 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -214,5 +214,6 @@ if ($id > 0 || ! empty($ref)) } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 9263ceb3f45..42def36ee28 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -190,7 +190,7 @@ else dol_print_error($db); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index ffebbaa260a..e7d0514a022 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -189,6 +189,6 @@ else } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 5cfb87c7a25..4c596620c6c 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -479,6 +479,6 @@ if (! empty($conf->commande->enabled)) print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 4bac4a3a447..6c0b5f42ec6 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -128,5 +128,6 @@ print ''; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 2b86ad2f18a..98c2333793f 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1160,5 +1160,6 @@ else dol_print_error($db); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 6cff3bfb3bc..bf02c9b993c 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -142,5 +142,6 @@ if ($id > 0 || ! empty($ref)) } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 03d379270b1..37768ade393 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -739,5 +739,6 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 8f259808357..49e7d5cfb60 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -369,7 +369,6 @@ print '
'; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index a786cf5ca28..1b2a5155a7e 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -494,5 +494,6 @@ else print "\n
\n"; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 8ddc3de0014..72c00f2f3a3 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1529,6 +1529,6 @@ if ($_POST["action"] == "search" && ! $num) print '
'.$langs->trans("NoRecordFound").'
'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/bank/bilan.php b/htdocs/compta/bank/bilan.php index 5e5194d55c8..10798bd0145 100644 --- a/htdocs/compta/bank/bilan.php +++ b/htdocs/compta/bank/bilan.php @@ -92,5 +92,6 @@ print "".$langs->trans("BankBalance").""; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index 280cd9bdbc0..963ad63f98f 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -96,5 +96,6 @@ else } print ""; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index db497733863..1e5c253d801 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -1034,5 +1034,6 @@ else } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index be029fcb2f5..41c9ac987f5 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -144,4 +144,6 @@ if ($action != 'edit') print ''; +// End of page llxFooter(); +$db->close(); diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 33e74dc3691..9ff2c25c9b9 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -147,7 +147,6 @@ else { exit; } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index b829002a990..f5e09e11e31 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -864,7 +864,6 @@ if ($mode == 'showalltime') print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/bank/info.php b/htdocs/compta/bank/info.php index ab43b9374aa..86a67c38973 100644 --- a/htdocs/compta/bank/info.php +++ b/htdocs/compta/bank/info.php @@ -71,5 +71,6 @@ print ''; print ''; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 10e549dd094..147ff16a8a1 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -688,6 +688,6 @@ if ($result) } else dol_print_error($db); +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index e52e285742c..3a8a640cad9 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -604,7 +604,6 @@ print ""; print ""; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 1d9d5526700..e8192859090 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -813,7 +813,6 @@ else } } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 765001e75a5..547aa4d4407 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -265,5 +265,6 @@ print '
"; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 0fb8880ce87..2389d1fec77 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -330,5 +330,6 @@ else print $langs->trans("ErrorBankAccountNotFound"); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 1b4d7579892..9c30dfe3cd8 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -499,8 +499,6 @@ if ($id) print "
"; } - - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index cf596860a4b..e11a608c7d0 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -154,6 +154,6 @@ else print $langs->trans("ErrorUnknown"); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 6535e0c0082..6e4060bbeb1 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -344,5 +344,6 @@ else } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index bb66871d6c0..c39a6379000 100644 --- a/htdocs/compta/bank/various_payment/info.php +++ b/htdocs/compta/bank/various_payment/info.php @@ -58,6 +58,6 @@ print ''; print ''; +// End of page llxFooter(); - $db->close(); From d67384802859f6b6f15bf8bf2977f9cfa403002b Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 30 Jul 2018 17:28:44 +0200 Subject: [PATCH 221/228] standardize --- htdocs/compta/charges/index.php | 3 +-- htdocs/compta/deplacement/card.php | 3 +-- htdocs/compta/deplacement/document.php | 2 +- htdocs/compta/deplacement/index.php | 3 +-- htdocs/compta/deplacement/info.php | 1 + htdocs/compta/deplacement/list.php | 2 +- htdocs/compta/deplacement/stats/index.php | 3 +-- htdocs/compta/facture/admin/facture_cust_extrafields.php | 2 +- htdocs/compta/facture/admin/facture_rec_cust_extrafields.php | 2 +- htdocs/compta/facture/admin/facturedet_cust_extrafields.php | 2 +- .../compta/facture/admin/facturedet_rec_cust_extrafields.php | 2 +- htdocs/compta/facture/card.php | 1 + htdocs/compta/facture/contact.php | 2 +- htdocs/compta/facture/document.php | 2 +- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/compta/facture/info.php | 1 + htdocs/compta/facture/invoicetemplate_list.php | 2 +- htdocs/compta/facture/list.php | 1 + htdocs/compta/facture/note.php | 3 +-- htdocs/compta/facture/prelevement.php | 2 +- htdocs/compta/facture/stats/index.php | 3 +-- 21 files changed, 21 insertions(+), 23 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 6d369b696b9..50e5285cb14 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -568,7 +568,6 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 05d509e268d..1e8fa358929 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -577,7 +577,6 @@ else if ($id) } } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 59d92140c86..c2b3595b476 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -129,6 +129,6 @@ else print $langs->trans("ErrorUnknown"); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index a390023e280..98c939965a3 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -204,7 +204,6 @@ else dol_print_error($db); print ''; - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/deplacement/info.php b/htdocs/compta/deplacement/info.php index 6a62484323f..f63b1765efb 100644 --- a/htdocs/compta/deplacement/info.php +++ b/htdocs/compta/deplacement/info.php @@ -59,5 +59,6 @@ if ($id) print ''; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index bdbdad0a712..20d300d9da4 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -212,6 +212,6 @@ else dol_print_error($db); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index cf652948a6e..193e2c7e9a9 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -312,7 +312,6 @@ print '
'; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index 4e44774e0c4..1fe26e82a54 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -114,6 +114,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 54d3da8e18a..23c0d79a33c 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -115,6 +115,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index c2490da4f42..0947f788719 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -113,6 +113,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 28c70ea9024..46d9ed28335 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -113,6 +113,6 @@ if ($action == 'edit' && ! empty($attrname)) require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0688d8488ed..5389b567b2e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4886,5 +4886,6 @@ else if ($id > 0 || ! empty($ref)) include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index af872a174ca..ab96700fc53 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -215,6 +215,6 @@ if ($id > 0 || ! empty($ref)) } } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 828c77f1178..045762de74c 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -191,6 +191,6 @@ else print $langs->trans("ErrorUnknown"); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 6719e7091c8..20e09e07eb4 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1734,6 +1734,6 @@ else } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 8964b85203b..ff597ee7071 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -122,5 +122,6 @@ print ''; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 13db00a02c2..0cfb0347a2d 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -709,6 +709,6 @@ else dol_print_error($db); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 75dce3c01a3..7d989e4b63e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1245,5 +1245,6 @@ else dol_print_error($db); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 58fc26030b7..c46d3ed690e 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -142,7 +142,6 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index ecde973bd3b..d7766268989 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -696,6 +696,6 @@ if ($object->id > 0) print ''; } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 0416e04f7b0..04603076b07 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -347,7 +347,6 @@ print '
'; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); From b0e2e69ed0d67569d5aa325ddeff842b2ae5e33a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 31 Jul 2018 07:45:03 +0200 Subject: [PATCH 222/228] New : Add project on salaries --- htdocs/compta/salaries/card.php | 79 ++++++++++++++++--- .../salaries/class/paymentsalary.class.php | 66 +++++++++------- htdocs/core/modules/modSalaries.class.php | 14 ++-- .../install/mysql/migration/8.0.0-9.0.0.sql | 40 ++++++++++ .../mysql/tables/llx_payment_salary.sql | 3 +- htdocs/langs/en_US/projects.lang | 1 + htdocs/langs/en_US/salaries.lang | 1 + htdocs/projet/element.php | 42 ++++++++-- 8 files changed, 191 insertions(+), 55 deletions(-) create mode 100644 htdocs/install/mysql/migration/8.0.0-9.0.0.sql diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 45fee127642..30b4164e81b 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2011-2018 Alexandre Spangaro * Copyright (C) 2014 Laurent Destailleur * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Charlie BENKE @@ -29,12 +29,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; +if (! empty($conf->projet->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +} // Load translation files required by the page $langs->loadLangs(array("compta","banks","bills","users","salaries","hrm")); +if (! empty($conf->projet->enabled)) $langs->load("projects"); $id=GETPOST("id",'int'); $action=GETPOST('action','aZ09'); +$cancel= GETPOST('cancel', 'aZ09'); +$projectid = (GETPOST('projectid','int') ? GETPOST('projectid', 'int') : GETPOST('fk_project','int')); // Security check $socid = GETPOST("socid","int"); @@ -52,20 +60,27 @@ $hookmanager->initHooks(array('salarycard','globalcard')); * Actions */ -if ($_POST["cancel"] == $langs->trans("Cancel")) +if ($cancel) { header("Location: index.php"); exit; } -if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) +// Link to a project +if ($action == 'classin' && $user->rights->banque->modifier) +{ + $object->fetch($id); + $object->setProject(GETPOST('projectid')); +} + +if ($action == 'add' && empty($cancel)) { $error=0; - $datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]); - $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); + $datep=dol_mktime(12,0,0, GETPOST("datepmonth",'int'), GETPOST("datepday",'int'), GETPOST("datepyear",'int')); + $datev=dol_mktime(12,0,0, GETPOST("datevmonth",'int'), GETPOST("datevday",'int'), GETPOST("datevyear",'int')); + $datesp=dol_mktime(12,0,0, GETPOST("datespmonth",'int'), GETPOST("datespday",'int'), GETPOST("datespyear",'int')); + $dateep=dol_mktime(12,0,0, GETPOST("dateepmonth",'int'), GETPOST("dateepday",'int'), GETPOST("dateepyear",'int')); if (empty($datev)) $datev=$datep; $type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1); @@ -82,6 +97,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $object->type_payment=($type_payment > 0 ? $type_payment : 0); $object->num_payment=GETPOST("num_payment"); $object->fk_user_author=$user->id; + $object->fk_project= GETPOST('fk_project','int'); // Set user current salary as ref salaray for the payment $fuser=new User($db); @@ -187,6 +203,7 @@ if ($action == 'delete') llxHeader("",$langs->trans("SalaryPayment")); $form = new Form($db); +if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db); if ($id) { @@ -278,6 +295,18 @@ if ($action == 'create') print ''; print ''; + // Project + if (! empty($conf->projet->enabled)) + { + $formproject=new FormProjets($db); + + print ''.$langs->trans("Project").''; + + $numproject=$formproject->select_projects(-1, $projectid,'fk_project',0,0,1,1); + + print ''; + } + // Bank if (! empty($conf->banque->enabled)) { @@ -335,14 +364,46 @@ if ($id) dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'payment'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref='
'; + // Employee $userstatic=new User($db); $userstatic->fetch($object->fk_user); - $morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1); + + // Project + if (! empty($conf->projet->enabled)) + { + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->salaries->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } $morehtmlref.='
'; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 3a3f34b85b4..2e656907aa7 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2014 Juanjo Menent +/* Copyright (C) 2011-2018 Alexandre Spangaro + * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +17,9 @@ */ /** - * \file htdocs/compta/salaries/class/paymentsalary.class.php - * \ingroup salaries - * \brief Class for salaries module payment + * \file htdocs/compta/salaries/class/paymentsalary.class.php + * \ingroup salaries + * \brief Class for salaries module payment */ // Put here all includes required by your class file @@ -40,6 +40,7 @@ class PaymentSalary extends CommonObject public $datep; public $datev; public $amount; + public $fk_project; public $type_payment; public $num_payment; public $label; @@ -102,6 +103,7 @@ class PaymentSalary extends CommonObject $sql.= " datep='".$this->db->idate($this->datep)."',"; $sql.= " datev='".$this->db->idate($this->datev)."',"; $sql.= " amount=".price2num($this->amount).","; + $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; $sql.= " fk_typepayment=".$this->fk_typepayment."',"; $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; $sql.= " label='".$this->db->escape($this->label)."',"; @@ -161,6 +163,7 @@ class PaymentSalary extends CommonObject $sql.= " s.datep,"; $sql.= " s.datev,"; $sql.= " s.amount,"; + $sql.= " s.fk_projet as fk_project,"; $sql.= " s.fk_typepayment,"; $sql.= " s.num_payment,"; $sql.= " s.label,"; @@ -186,25 +189,26 @@ class PaymentSalary extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->tms = $this->db->jdate($obj->tms); - $this->fk_user = $obj->fk_user; - $this->datep = $this->db->jdate($obj->datep); - $this->datev = $this->db->jdate($obj->datev); - $this->amount = $obj->amount; - $this->type_payement = $obj->fk_typepayment; - $this->num_payment = $obj->num_payment; - $this->label = $obj->label; - $this->datesp = $this->db->jdate($obj->datesp); - $this->dateep = $this->db->jdate($obj->dateep); - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_modif = $obj->fk_user_modif; - $this->fk_account = $obj->fk_account; - $this->fk_type = $obj->fk_type; - $this->rappro = $obj->rappro; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); + $this->fk_user = $obj->fk_user; + $this->datep = $this->db->jdate($obj->datep); + $this->datev = $this->db->jdate($obj->datev); + $this->amount = $obj->amount; + $this->fk_project = $obj->fk_project; + $this->type_payement = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->label = $obj->label; + $this->datesp = $this->db->jdate($obj->datesp); + $this->dateep = $this->db->jdate($obj->dateep); + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_modif = $obj->fk_user_modif; + $this->fk_account = $obj->fk_account; + $this->fk_type = $obj->fk_type; + $this->rappro = $obj->rappro; } $this->db->free($resql); @@ -276,12 +280,12 @@ class PaymentSalary extends CommonObject $this->fk_user_modif=''; } - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ function create($user) { global $conf,$langs; @@ -331,6 +335,7 @@ class PaymentSalary extends CommonObject $sql.= ", datep"; $sql.= ", datev"; $sql.= ", amount"; + $sql.= ", fk_projet"; $sql.= ", salary"; $sql.= ", fk_typepayment"; $sql.= ", num_payment"; @@ -348,6 +353,7 @@ class PaymentSalary extends CommonObject $sql.= ", '".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datev)."'"; $sql.= ", ".$this->amount; + $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0); $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); $sql.= ", ".$this->db->escape($this->type_payment); $sql.= ", '".$this->db->escape($this->num_payment)."'"; diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index e3d418d182e..eba3f1210eb 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2014 Alexandre Spangaro * * 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 @@ -23,11 +23,11 @@ */ /** - * \defgroup salaries Module salaries - * \brief Module to include salaries management - * \file htdocs/core/modules/modSalaries.class.php - * \ingroup salaries - * \brief File to activate module salaries + * \defgroup salaries Module salaries + * \brief Module to include salaries management + * \file htdocs/core/modules/modSalaries.class.php + * \ingroup salaries + * \brief File to activate module salaries */ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; @@ -182,7 +182,7 @@ class modSalaries extends DolibarrModules * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ function init($options='') diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql new file mode 100644 index 00000000000..3208d78d694 --- /dev/null +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -0,0 +1,40 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 9.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. + + +-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); +-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); + + + +-- Forgot in 8.0.0 + + +-- For 9.0.0 +ALTER TABLE llx_payment_salary ADD COLUMN fk_projet integer DEFAULT NULL after amount; diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index e3bcd0a9c4a..4fcbc233f33 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -26,11 +26,12 @@ create table llx_payment_salary datev date, -- value date (this field should not be here, only into bank tables) salary double(24,8), -- salary of user when payment was done amount double(24,8) NOT NULL DEFAULT 0, + fk_projet integer DEFAULT NULL, fk_typepayment integer NOT NULL, num_payment varchar(50), -- ref label varchar(255), datesp date, -- date start period - dateep date, -- date end period + dateep date, -- date end period entity integer DEFAULT 1 NOT NULL, -- multi company id note text, fk_bank integer, diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 6dfb11e2284..563748b04c9 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -91,6 +91,7 @@ ListFichinterAssociatedProject=List of interventions associated with the project ListExpenseReportsAssociatedProject=List of expense reports associated with the project ListDonationsAssociatedProject=List of donations associated with the project ListVariousPaymentsAssociatedProject=List of miscellaneous payments associated with the project +ListSalariesAssociatedProject=List of salaries associated with the project ListActionsAssociatedProject=List of events associated with the project ListTaskTimeUserProject=List of time consumed on tasks of project ListTaskTimeForTask=List of time consumed on task diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 432ab894040..ba3a4dfeb70 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -5,6 +5,7 @@ SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for wage paymen Salary=Salary Salaries=Salaries NewSalaryPayment=New salary payment +AddSalaryPayment=Add salary payment SalaryPayment=Salary payment SalariesPayments=Salaries payments ShowSalaryPayment=Show salary payment diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 5070c0a58d4..842527f4bbd 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2012-2016 Juanjo Menent - * Copyright (C) 2015-2017 Alexandre Spangaro + * Copyright (C) 2015-2018 Alexandre Spangaro * Copyright (C) 2015 Marcos García * Copyright (C) 2016 Josep Lluís Amador * @@ -43,7 +43,7 @@ if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (! empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +if (! empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -52,17 +52,19 @@ if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; if (! empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; +if (! empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'suppliers', 'compta')); -if (! empty($conf->facture->enabled)) $langs->load("bills"); -if (! empty($conf->commande->enabled)) $langs->load("orders"); -if (! empty($conf->propal->enabled)) $langs->load("propal"); +if (! empty($conf->facture->enabled)) $langs->load("bills"); +if (! empty($conf->commande->enabled)) $langs->load("orders"); +if (! empty($conf->propal->enabled)) $langs->load("propal"); if (! empty($conf->ficheinter->enabled)) $langs->load("interventions"); if (! empty($conf->deplacement->enabled)) $langs->load("trips"); if (! empty($conf->expensereport->enabled)) $langs->load("trips"); if (! empty($conf->don->enabled)) $langs->load("donations"); if (! empty($conf->loan->enabled)) $langs->load("loan"); +if (! empty($conf->salaries->enabled)) $langs->load("salaries"); $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); @@ -438,6 +440,19 @@ $listofreferent=array( 'datefieldname'=>'datem', 'disableamount'=>0, 'test'=>($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))), +'salaries'=>array( + 'name'=>"Salaries", + 'title'=>"ListSalariesAssociatedProject", + 'class'=>'PaymentSalary', + 'table'=>'payment_salary', + 'datefieldname'=>'datev', + 'margin'=>'minus', + 'disableamount'=>0, + 'urlnew'=>DOL_URL_ROOT.'/compta/salaries/card.php?action=create&projectid='.$id, + 'lang'=>'salaries', + 'buttonnew'=>'AddSalariesPayment', + 'testnew'=>$user->rights->salaries->write, + 'test'=>$conf->salaries->enabled && $user->rights->salaries->read), 'variouspayment'=>array( 'name'=>"VariousPayments", 'title'=>"ListVariousPaymentsAssociatedProject", @@ -768,7 +783,7 @@ foreach ($listofreferent as $key => $value) print ''; if (in_array($tablename, array('projet_task')) && $key == 'project_task') print ''; // if $key == 'project_task', we don't want details per user elseif (in_array($tablename, array('payment_various'))) print ''; // if $key == 'payment_various', we don't have any thirdparty - elseif (in_array($tablename, array('expensereport_det','don','projet_task','stock_mouvement'))) print $langs->trans("User"); + elseif (in_array($tablename, array('expensereport_det','don','projet_task','stock_mouvement','payment_salary'))) print $langs->trans("User"); else print $langs->trans("ThirdParty"); print ''; // Amount HT @@ -864,6 +879,10 @@ foreach ($listofreferent as $key => $value) { print $expensereport->getNomUrl(1); } + if ($tablename == 'payment_salary') + { + print ''; + } else { // Show ref with link @@ -901,6 +920,7 @@ foreach ($listofreferent as $key => $value) $date=''; $total_time_by_line = null; if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines elseif ($tablename == 'stock_mouvement') $date = $element->datem; + elseif ($tablename == 'payment_salary') $date = $element->datev; elseif ($tablename == 'payment_various') $date = $element->datev; elseif ($tablename == 'chargesociales') $date = $element->date_ech; elseif (! empty($element->status) || ! empty($element->statut) || ! empty($element->fk_status)) @@ -946,6 +966,12 @@ foreach ($listofreferent as $key => $value) $tmpuser->fetch($expensereport->fk_user_author); print $tmpuser->getNomUrl(1,'',48); } + else if ($tablename == 'payment_salary') + { + $tmpuser=new User($db); + $tmpuser->fetch($salaries->fk_user); + print $tmpuser->getNomUrl(1,'',48); + } else if ($tablename == 'don' || $tablename == 'stock_mouvement') { if ($element->fk_user_author > 0) @@ -967,7 +993,7 @@ foreach ($listofreferent as $key => $value) { $total_ht_by_line=null; $othermessage=''; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various') $total_ht_by_line=$element->amount; + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line=$element->amount; else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); elseif (in_array($tablename, array('projet_task'))) @@ -1008,7 +1034,7 @@ foreach ($listofreferent as $key => $value) if (empty($value['disableamount'])) { $total_ttc_by_line=null; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various') $total_ttc_by_line=$element->amount; + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line=$element->amount; else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); elseif ($tablename == 'projet_task') From 37a4a0c4888fd6cef0be2c88e4845faeb1c4193e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 31 Jul 2018 10:02:36 +0200 Subject: [PATCH 223/228] fix for travis --- htdocs/core/class/html.formprojet.class.php | 1 + htdocs/projet/class/project.class.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 25e2cb13d81..2e3bdafc319 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -456,6 +456,7 @@ class FormProjets * @param string $socid If of thirdparty to use as filter or 'id1,id2,...' * @param string $morecss More CSS * @param int $limitonstatus Add filters to limit length of list to opened status (for example to avoid ERR_RESPONSE_HEADERS_TOO_BIG on project/element.php page). TODO To implement + * @param string $projectkey Equivalent key to fk_projet for actual table_element * @return int|string The HTML select list of element or '' if nothing or -1 if KO */ function select_element($table_element, $socid=0, $morecss='', $limitonstatus=-2,$projectkey="fk_projet") diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 1078733c19e..c8c36a697fb 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -516,9 +516,10 @@ class Project extends CommonObject * @param string $datefieldname name of date field for filter * @param int $dates Start date * @param int $datee End date + * @param string $projectkey Equivalent key to fk_projet for actual type * @return mixed Array list of object ids linked to project, < 0 or string if error */ - function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='', $project_field='fk_projet') + function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='', $projectkey='fk_projet') { $elements = array(); @@ -548,7 +549,7 @@ class Project extends CommonObject } else { - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE ".$project_field." IN (". $ids .")"; + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE ".$projectkey." IN (". $ids .")"; } if ($dates > 0) From ee61a8854082bf8ab8b8109372636d9178a35cb2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 1 Aug 2018 07:46:17 +0200 Subject: [PATCH 224/228] Small fix --- htdocs/compta/salaries/class/paymentsalary.class.php | 6 ++---- htdocs/projet/element.php | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 2e656907aa7..31c616ac00d 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -508,13 +508,11 @@ class PaymentSalary extends CommonObject global $langs; $result=''; - $label=$langs->trans("ShowSalaryPayment").': '.$this->ref; + $label=$langs->trans("ShowSalaryPayment").': '.$this->ref; - $linkstart = ''; + $linkstart = ''; $linkend=''; - $picto='payment'; - $result .= $linkstart; if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.= $this->ref; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 842527f4bbd..7a263ba3995 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -879,13 +879,9 @@ foreach ($listofreferent as $key => $value) { print $expensereport->getNomUrl(1); } - if ($tablename == 'payment_salary') - { - print ''; - } else { - // Show ref with link + // Show ref with link if ($element instanceof Task) { print $element->getNomUrl(1,'withproject','time'); @@ -969,7 +965,7 @@ foreach ($listofreferent as $key => $value) else if ($tablename == 'payment_salary') { $tmpuser=new User($db); - $tmpuser->fetch($salaries->fk_user); + $tmpuser->fetch($element->fk_user); print $tmpuser->getNomUrl(1,'',48); } else if ($tablename == 'don' || $tablename == 'stock_mouvement') From d50a95c89b49e8491bf744a3331df46f0bf3296f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 1 Aug 2018 11:40:12 +0200 Subject: [PATCH 225/228] update to straipe cf https://stripe.com/docs/building-plugins#setappinfo --- htdocs/stripe/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index c61de994874..2e7447a6e5f 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -54,4 +54,4 @@ else } \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); -\Stripe\Stripe::setAppInfo("Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version +\Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version From 40b19b8e1d3ee0ccaa9cc8a7fe36459678be017f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 1 Aug 2018 11:50:43 +0200 Subject: [PATCH 226/228] update to Stripe Requirements and Best Practices cf https://stripe.com/docs/partners/requirements --- htdocs/stripe/config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 2e7447a6e5f..7aa22678d7a 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -55,3 +55,4 @@ else \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); \Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version +\Stripe\Stripe::setApiVersion("2018-07-27"); // force version API From ccabd2b859058a6838126915afb233bd71403bf9 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 2 Aug 2018 14:03:50 +0200 Subject: [PATCH 227/228] Uniformize --- htdocs/expedition/card.php | 3 +-- htdocs/expedition/contact.php | 2 +- htdocs/expedition/document.php | 3 +-- htdocs/expedition/index.php | 2 +- htdocs/expedition/list.php | 1 + htdocs/expedition/note.php | 3 +-- htdocs/expedition/shipment.php | 3 +-- htdocs/expedition/stats/index.php | 2 +- htdocs/expedition/stats/month.php | 2 +- htdocs/expensereport/card.php | 5 +++-- htdocs/expensereport/document.php | 2 +- htdocs/expensereport/export_csv.php | 2 +- htdocs/expensereport/index.php | 2 +- htdocs/expensereport/info.php | 2 +- htdocs/expensereport/list.php | 3 +-- htdocs/expensereport/note.php | 2 +- htdocs/expensereport/payment/card.php | 2 +- htdocs/expensereport/payment/info.php | 1 + htdocs/expensereport/payment/payment.php | 1 + htdocs/expensereport/stats/index.php | 3 +-- htdocs/exports/index.php | 3 +-- 21 files changed, 23 insertions(+), 26 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 93b3f3a5f4d..d56134b7726 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2594,7 +2594,6 @@ else if ($id || $ref) include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 3f557059600..acc2b5e1142 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -268,6 +268,6 @@ if ($id > 0 || ! empty($ref)) } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php index 4f9616df5ed..5d76a5f4918 100644 --- a/htdocs/expedition/document.php +++ b/htdocs/expedition/document.php @@ -185,7 +185,6 @@ else{ exit; } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 042d107b58e..8dde7bf0125 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -291,6 +291,6 @@ else dol_print_error($db); print ''; - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 14f9eb41f44..327a9394b77 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -632,5 +632,6 @@ else dol_print_error($db); } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index fafaf10fe1f..f276b2d0cb4 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -152,7 +152,6 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index cb058e44598..0d3111d9f12 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -926,7 +926,6 @@ if ($id > 0 || ! empty($ref)) } } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index 651be627b78..a167a447d7d 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -358,6 +358,6 @@ print ''; print '
'; print ''.$langs->trans("StatsOnShipmentsOnlyValidated").''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expedition/stats/month.php b/htdocs/expedition/stats/month.php index b7d217217c2..27b01cc6f55 100644 --- a/htdocs/expedition/stats/month.php +++ b/htdocs/expedition/stats/month.php @@ -71,6 +71,6 @@ print $px->show(); print ''; print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 141260d36f3..75285bf35cf 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1450,8 +1450,9 @@ else print $langs->trans('NotUserRightToView'); print ''; - llxFooter(); - $db->close(); + // End of page + llxFooter(); + $db->close(); exit; } diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index f0d61d0f80d..0ac498ca775 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -139,6 +139,6 @@ else print $langs->trans("ErrorUnknown"); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expensereport/export_csv.php b/htdocs/expensereport/export_csv.php index 4bc461b4d13..8ea72191b1d 100644 --- a/htdocs/expensereport/export_csv.php +++ b/htdocs/expensereport/export_csv.php @@ -195,6 +195,6 @@ if (isset($_POST['action'])) print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 0d988e4850d..758dd89afe2 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -231,6 +231,6 @@ else dol_print_error($db); print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expensereport/info.php b/htdocs/expensereport/info.php index 6babfcd647c..67f70f3a984 100644 --- a/htdocs/expensereport/info.php +++ b/htdocs/expensereport/info.php @@ -79,6 +79,6 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index d3e5bc6fabd..d328cd21de2 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -861,7 +861,6 @@ else dol_print_error($db); } - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expensereport/note.php b/htdocs/expensereport/note.php index baa0c174fc1..deb38abe8d6 100644 --- a/htdocs/expensereport/note.php +++ b/htdocs/expensereport/note.php @@ -97,6 +97,6 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 2876d512c52..2c053d5cc35 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -310,6 +310,6 @@ if ($action == '') print ''; +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/expensereport/payment/info.php b/htdocs/expensereport/payment/info.php index 97098ef2340..6c7f8dd99c6 100644 --- a/htdocs/expensereport/payment/info.php +++ b/htdocs/expensereport/payment/info.php @@ -77,5 +77,6 @@ print ''; dol_fiche_end(); +// End of page llxFooter(); $db->close(); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 23959c06e67..dc78b933055 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -336,5 +336,6 @@ if ($action == 'create' || empty($action)) print "\n"; } +// End of page llxFooter(); $db->close(); diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index b4f0327cd39..b97129a5779 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -305,7 +305,6 @@ print '
'; dol_fiche_end(); - +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/exports/index.php b/htdocs/exports/index.php index bccf25f1be8..81027882b6b 100644 --- a/htdocs/exports/index.php +++ b/htdocs/exports/index.php @@ -145,7 +145,6 @@ print ''; //print ''; - +// End of page llxFooter(); - $db->close(); From 0e3473701a0d5a0294c542a179277300fb656c13 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Aug 2018 18:38:33 +0200 Subject: [PATCH 228/228] Update bank.lib.php --- htdocs/core/lib/bank.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index e361d8fa9f6..28584b60e32 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -356,9 +356,9 @@ function checkES($IentOfi, $InumCta) $sum = 0; for ($i = 0; $i < 11; $i++) { - $sum += $values[$i] * (int)substr($InumCta, $i, 1);//int to cast result of substr to a number + $sum += $values[$i] * (int) substr($InumCta, $i, 1);//int to cast result of substr to a number } - + $key = 11 - $sum % 11; if ($key == 10)