From a158f5ab9db752a8d821e4e2bcee7b83083f299d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 12:01:51 +0200 Subject: [PATCH 001/111] Doc --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index e82fdf33d8a..b566652226b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 5.0.6 compared to 5.0.5 ***** +FIX: Removed a bad symbolic link into custom directory. +FIX: Renaming a resouce ref rename also the directory of attached files. ***** ChangeLog for 5.0.5 compared to 5.0.4 ***** FIX: #7075 : bad path for document From d66fac5662b85539469bf9fc3edac6f5ee9f9426 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 12:12:50 +0200 Subject: [PATCH 002/111] Prepare 5.0.7 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index f3f60885697..422a26d1866 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','5.0.6'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','5.0.7'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 52986c5c07d1a97188910bd05abc31d31e157f51 Mon Sep 17 00:00:00 2001 From: Jacques83300 Date: Mon, 4 Sep 2017 15:59:50 +0200 Subject: [PATCH 003/111] Add some missing attributes in Adherent:makeSubstitution (type, phone numbers) for use in substitution of tags --- htdocs/adherents/class/adherent.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ba6728586f1..9e6110bb35e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -198,6 +198,9 @@ class Adherent extends CommonObject $infos.= $langs->transnoentities("Town").": ".$this->town."\n"; $infos.= $langs->transnoentities("Country").": ".$this->country."\n"; $infos.= $langs->transnoentities("EMail").": ".$this->email."\n"; + $infos.= $langs->transnoentities("PhonePro").": ".$this->phone."\n"; + $infos.= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n"; + $infos.= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n"; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { $infos.= $langs->transnoentities("Login").": ".$this->login."\n"; @@ -225,6 +228,10 @@ class Adherent extends CommonObject '%PHOTO%'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo, '%LOGIN%'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login, '%PASSWORD%'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass, + '%TYPE%'=>$msgishtml?dol_htmlentitiesbr($this->type):$this->type, + '%PHONE_PRO%'=>$msgishtml?dol_htmlentitiesbr($this->phone):$this->phone, + '%PHONE_PERSO%'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):$this->phone_perso, + '%PHONE_MOBILE%'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):$this->phone_mobile, // For backward compatibility '%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos, '%SOCIETE%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe, From e599e47e844bf2640c9f30da3402ac6172ff38bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Sep 2017 13:06:34 +0200 Subject: [PATCH 004/111] Missing translation --- htdocs/supplier_proposal/list.php | 55 ++++++++++++++++--------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 7a841a13b19..f72cc3cd837 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -43,6 +43,7 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load('companies'); +$langs->load('propal'); $langs->load('supplier_proposal'); $langs->load('compta'); $langs->load('bills'); @@ -322,11 +323,11 @@ if ($result) { $title = $langs->trans('ListOfProposals'); } - + $num = $db->num_rows($result); $arrayofselected=is_array($toselect)?$toselect:array(); - + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; @@ -358,7 +359,7 @@ if ($result) if ($user->rights->supplier_proposal->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + // Lignes des champs de filtre print '
'; if ($optioncss != '') print ''; @@ -367,13 +368,13 @@ if ($result) print ''; print ''; print ''; - + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); if ($massaction == 'presend') { $langs->load("mails"); - + if (! GETPOST('cancel')) { $objecttmp=new SupplierProposal($db); @@ -392,17 +393,17 @@ if ($result) } } } - + print ''; - + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - + dol_fiche_head(null, '', ''); - + $topicmail="SendProposalRef"; $modelmail="propal_send"; - + // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -455,25 +456,25 @@ if ($result) $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; - + // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id']=join(',',$arrayofselected); //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - + print $formmail->get_form(); - + dol_fiche_end(); } - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + $i = 0; $moreforfilter=''; @@ -499,20 +500,20 @@ if ($result) $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 (! empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print ''; - + // Fields title print ''; print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'sp.ref','',$param,'',$sortfield,$sortorder); @@ -541,7 +542,7 @@ if ($result) $syearvalid = $yearvalid; $formother->select_year($syearvalid,'yearvalid',1, 20, 5); print ''; - + // Date print '\n"; - + // Date delivery print '
'; //print $langs->trans('Month').': '; @@ -632,7 +633,7 @@ if ($result) print ''; print dol_print_date($db->jdate($obj->date_valid), 'day'); print "'; print dol_print_date($db->jdate($obj->dp), 'day'); @@ -686,16 +687,16 @@ if ($result) } $db->free($resql); - + $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - + print '
'."\n"; print '
'."\n"; print '
'."\n"; - + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { /* @@ -703,18 +704,18 @@ if ($result) */ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - + $filedir=$diroutputmassaction; $genallowed=$user->rights->propal->lire; $delallowed=$user->rights->propal->lire; - + print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'',''); } else { print '
'.$langs->trans("ShowTempMassFilesArea").''; } - + } else { From 8906c95eea14c5ec4fa0b7205d311a40ed5fcda2 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 7 Sep 2017 16:23:51 +0200 Subject: [PATCH 005/111] NEW comments system on task --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/core/lib/functions2.lib.php | 22 + htdocs/core/lib/project.lib.php | 13 +- .../install/mysql/migration/6.0.0-7.0.0.sql | 11 + .../mysql/tables/llx_projet_task_comment.sql | 28 ++ htdocs/langs/en_US/projects.lang | 5 + htdocs/langs/fr_FR/projects.lang | 5 + htdocs/projet/admin/project.php | 9 + htdocs/projet/class/task.class.php | 331 ++++++++++++++- htdocs/projet/tasks/comment.php | 394 ++++++++++++++++++ htdocs/theme/eldy/style.css.php | 33 ++ 11 files changed, 850 insertions(+), 3 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_projet_task_comment.sql create mode 100644 htdocs/projet/tasks/comment.php diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f007cbdbf81..4dea3053d23 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -938,7 +938,7 @@ class Propal extends CommonObject $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; $sql.= ")"; - + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 40dcb1fe77d..9d3e6ee1b63 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2240,3 +2240,25 @@ function getModuleDirForApiClass($module) return $moduledirforclass; } + +/* + * Return 2 hexa code randomly + * + * @param $min int Between 0 and 255 + * @param $max int Between 0 and 255 + * @return String + */ +function random_color_part($min=0,$max=255) { + return str_pad( dechex( mt_rand( $min, $max) ), 2, '0', STR_PAD_LEFT); +} + +/* + * Return hexadecimal color randomly + * + * @param $min int Between 0 and 255 + * @param $max int Between 0 and 255 + * @return String + */ +function random_color($min=0, $max=255) { + return random_color_part($min, $max) . random_color_part($min, $max) . random_color_part($min, $max); +} \ No newline at end of file diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 035b7eac57b..189c37dbe32 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -175,6 +175,17 @@ function task_prepare_head($object) // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'task'); + + // Manage discussion + if (empty($conf->global->MAIN_ALLOW_COMMENT_ON_TASK)) + { + $nbComments= $object->getNbComments(); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + $head[$h][1] = $langs->trans("TaskCommentLinks"); + if ($nbComments > 0) $head[$h][1].= ' '.$nbComments.''; + $head[$h][2] = 'task_comment'; + $h++; + } if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { @@ -187,7 +198,7 @@ function task_prepare_head($object) $head[$h][2] = 'task_notes'; $h++; } - + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); $filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 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 be89142cecb..b0e585aeacd 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 @@ -224,6 +224,17 @@ UPDATE llx_accounting_account SET pcg_type = 'INCOME' where pcg_type = 'VENTAS_ UPDATE llx_accounting_account SET pcg_type = 'EXPENSE' where pcg_type = 'COMPRAS_GASTOS'; +CREATE TABLE llx_projet_task_comment ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime DEFAULT NULL, + tms timestamp, + description text NOT NULL, + fk_user integer DEFAULT NULL, + fk_task integer DEFAULT NULL, + entity integer DEFAULT 1, + import_key varchar(125) DEFAULT NULL +); + -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8; diff --git a/htdocs/install/mysql/tables/llx_projet_task_comment.sql b/htdocs/install/mysql/tables/llx_projet_task_comment.sql new file mode 100644 index 00000000000..42fe572958a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_projet_task_comment.sql @@ -0,0 +1,28 @@ +-- =========================================================================== +-- Copyright (C) 2005 Rodolphe Quiedeville +-- +-- 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_projet_task_comment ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime DEFAULT NULL, + tms timestamp, + description text NOT NULL, + fk_user integer DEFAULT NULL, + fk_task integer DEFAULT NULL, + entity integer DEFAULT 1, + import_key varchar(125) DEFAULT NULL +); diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 92282fd29f0..57406704bf4 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -208,3 +208,8 @@ OppStatusPENDING=Pending OppStatusWON=Won OppStatusLOST=Lost Budget=Budget +# Comments trans +AllowCommentOnTask=Allow user comments on tasks +TaskCommentLinks=Comments +TaskNbComments=Number of comments +TaskComment=Task's comments space diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 746fbd59c38..ece3272c743 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -207,3 +207,8 @@ OppStatusPENDING=En attente OppStatusWON=Gagné OppStatusLOST=Perdu Budget=Budget +#Comments trans +AllowCommentOnTask=Autoriser les commentaires entre utilisateurs sur les tâches +TaskCommentLinks=Commentaires +TaskNbComments=Nombre de commentaires +TaskComment=Tâches espace commentaires diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 744e52e0f2f..0c0da27457e 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -918,6 +918,15 @@ print ''; print ' '; print ''; +print ''; +print ''.$langs->trans("AllowCommentOnTask").''; + +print ''; +echo ajax_constantonoff('PROJECT_ALLOW_COMMENT_ON_TASK'); +print ''; +print ' '; +print ''; + print ''; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 17d1b5fcf45..258805f9970 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -35,7 +35,7 @@ class Task extends CommonObject public $table_element='projet_task'; //!< Name of table without prefix where object is stored public $fk_element='fk_task'; public $picto = 'task'; - protected $childtables=array('projet_task_time'); // To test if we can delete object + protected $childtables=array('projet_task_time','projet_task_comment'); // To test if we can delete object var $fk_task_parent; var $label; @@ -69,6 +69,8 @@ class Task extends CommonObject var $timespent_withhour; // 1 = we entered also start hours for timesheet line var $timespent_fk_user; var $timespent_note; + + var $comments = array(); public $oldcopy; @@ -1777,4 +1779,331 @@ class Task extends CommonObject return ($datetouse > 0 && ($datetouse < ($now - $conf->projet->task->warning_delay))); } + + /** + * Return nb comments already posted + * + * @return int + */ + public function getNbComments() + { + return count($this->comments); + } + + /** + * Load comments linked with current task + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchComments() + { + $sql = "SELECT"; + $sql.= " c.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_comment as c"; + $sql.= " WHERE c.fk_task = ".$this->id; + $sql.= " ORDER BY c.tms DESC"; + + dol_syslog(get_class($this)."::fetchComments", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num_rows = $this->db->num_rows($resql); + if ($num_rows > 0) + { + while($obj = $this->db->fetch_object($resql)) + { + $comment = new TaskComment($this->db); + $comment->fetch($obj->rowid); + $this->comments[] = $comment; + } + return $num_rows; + }else{ + return 0; + } + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } } + +/** + * Class to manage tasks + */ +class TaskComment extends CommonObject +{ + public $element='project_task_comment'; //!< Id that identify managed objects + public $table_element='projet_task_comment'; //!< Name of table without prefix where object is stored + public $fk_element='fk_task'; + public $picto = 'task'; + + var $fk_task; + + var $description; + + var $tms; + + var $datec; + + var $fk_user; + + var $entity; + + var $import_key; + + public $oldcopy; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + + + /** + * Create into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + function create($user, $notrigger=0) + { + global $conf, $langs; + + $error=0; + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_comment ("; + $sql.= "description"; + $sql.= ", datec"; + $sql.= ", fk_task"; + $sql.= ", fk_user"; + $sql.= ", entity"; + $sql.= ", import_key"; + $sql.= ") VALUES ("; + $sql.= "'".$this->db->escape($this->description)."'"; + $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); + $sql.= ", '".(isset($this->fk_task)?$this->fk_task:"null")."'"; + $sql.= ", '".(isset($this->fk_user)?$this->fk_user:"null")."'"; + $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); + $sql.= ", ".(!empty($this->import_key)?"'".$this->import_key."'":"null"); + $sql.= ")"; + + var_dump($this->db); + echo $sql; + + $this->db->begin(); + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from database + * + * @param int $id Id object + * @param int $ref ref object + * @return int <0 if KO, 0 if not found, >0 if OK + */ + function fetch($id) + { + global $langs; + + $sql = "SELECT"; + $sql.= " c.rowid,"; + $sql.= " c.description,"; + $sql.= " c.datec,"; + $sql.= " c.tms,"; + $sql.= " c.fk_task,"; + $sql.= " c.fk_user,"; + $sql.= " c.entity,"; + $sql.= " c.import_key"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_comment as c"; + $sql.= " WHERE c.rowid = ".$id; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num_rows = $this->db->num_rows($resql); + + if ($num_rows) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->description = $obj->description; + $this->datec = $this->db->jdate($obj->datec); + $this->tms = $obj->tms; + $this->fk_user = $obj->fk_user; + $this->fk_task = $obj->fk_task; + $this->entity = $obj->entity; + $this->import_key = $obj->import_key; + } + + $this->db->free($resql); + + if ($num_rows) return 1; + else return 0; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <=0 if KO, >0 if OK + */ + function update($user=null, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->fk_task)) $this->fk_project=trim($this->fk_task); + if (isset($this->fk_user)) $this->fk_project=trim($this->fk_user); + if (isset($this->description)) $this->description=trim($this->description); + + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; + $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; + $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; + $sql.= " fk_task=".(isset($this->fk_task)?$this->fk_task:"null").","; + $sql.= " fk_user=".(isset($this->fk_user)?$this->fk_user:"null").","; + $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; + $sql.= " import_key=".(!empty($this->import_key)?"'".$this->import_key."'":"null"); + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete task from database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $error=0; + + $this->db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_comment"; + $sql.= " WHERE rowid=".$this->id; + + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + }else{ + $this->db->commit(); + return 1; + } + } +} \ No newline at end of file diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php new file mode 100644 index 00000000000..0446cc71ea6 --- /dev/null +++ b/htdocs/projet/tasks/comment.php @@ -0,0 +1,394 @@ + + * Copyright (C) 2006-2017 Laurent Destailleur + * Copyright (C) 2010-2012 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/projet/tasks/task.php + * \ingroup project + * \brief Page of a project task + */ + +require ("../../main.inc.php"); +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + +$langs->load("projects"); +$langs->load("companies"); + +$id=GETPOST('id','int'); +$idcomment=GETPOST('idcomment','int'); +$ref=GETPOST("ref",'alpha',1); // task ref +$taskref=GETPOST("taskref",'alpha'); // task ref +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$withproject=GETPOST('withproject','int'); +$project_ref=GETPOST('project_ref','alpha'); +$planned_workload=((GETPOST('planned_workloadhour','int')!='' || GETPOST('planned_workloadmin','int')!='') ? (GETPOST('planned_workloadhour','int')>0?GETPOST('planned_workloadhour','int')*3600:0) + (GETPOST('planned_workloadmin','int')>0?GETPOST('planned_workloadmin','int')*60:0) : ''); + +// Security check +$socid=0; +//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +if (! $user->rights->projet->lire) accessforbidden(); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('projecttaskcard','globalcard')); + +$task = new Task($db); +$object = new TaskComment($db); +$extrafields = new ExtraFields($db); +$projectstatic = new Project($db); +$userstatic = new User($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($task->table_element); + + +/* + * Actions + */ + +if ($action == 'addcomment') +{ + if (!empty($_POST['comment_description'])) + { + $object->description = GETPOST('comment_description'); + $object->datec = time(); + $object->fk_task = $id; + $object->fk_user = $user->id; + $object->entity = $conf->entity; + if ($object->create($user) > 0) + { + header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':'')); + exit; + } + else + { + setEventMessages($task->error,$task->errors,'errors'); + $action=''; + } + } +} +if ($action == 'deletecomment') +{ + if ($object->fetch($idcomment) >= 0) + { + if ($object->delete($user) > 0) + { + header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':'')); + exit; + } + else + { + setEventMessages($task->error,$task->errors,'errors'); + $action=''; + } + } +} + +// Retreive First Task ID of Project if withprojet is on to allow project prev next to work +if (! empty($project_ref) && ! empty($withproject)) +{ + if ($projectstatic->fetch('',$project_ref) > 0) + { + $tasksarray=$task->getTasksArray(0, 0, $projectstatic->id, $socid, 0); + if (count($tasksarray) > 0) + { + $id=$tasksarray[0]->id; + } + else + { + header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode)?'':'&mode='.$mode)); + } + } +} + +/* + * View +*/ + + +llxHeader('', $langs->trans("TaskComment")); + +$form = new Form($db); +$formother = new FormOther($db); +$formfile = new FormFile($db); + +if ($id > 0 || ! empty($ref)) +{ + if ($task->fetch($id,$ref) > 0) + { + $res=$task->fetch_optionals($task->id,$extralabels); + $res = $task->fetchComments(); + + $result=$projectstatic->fetch($task->fk_project); + if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + + $task->project = clone $projectstatic; + + $userWrite = $projectstatic->restrictedProjectArea($user,'write'); + + if (! empty($withproject)) + { + // Tabs for project + $tab='tasks'; + $head=project_prepare_head($projectstatic); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); + + $param=($mode=='mine'?'&mode=mine':''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref='
'; + // Title + $morehtmlref.=$projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) + { + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref.='
'; + + // Define a complementary filter for search of next/prev ref. + if (! $user->rights->projet->all->lire) + { + $tasksListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); + $projectstatic->next_prev_filter=" rowid in (".(count($tasksListId)?join(',',array_keys($tasksListId)):'0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + print '
'; + + print ''; + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans("Visibility").''; + if ($projectstatic->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + print dol_print_date($projectstatic->date_start,'day'); + $end=dol_print_date($projectstatic->date_end,'day'); + if ($end) print ' - '.$end; + print '
'.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); + print '
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + // Description + print ''; + + // Categories + if($conf->categorie->enabled) { + print '"; + } + + print '
'.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
'.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id,'project',1); + print "
'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); + + print '
'; + } + + $head=task_prepare_head($task); + + /* + * Fiche tache en mode visu + */ + $param=($withproject?'&withproject=1':''); + $linkback=$withproject?''.$langs->trans("BackToList").'':''; + + dol_fiche_head($head, 'task_comment', $langs->trans("Task"), -1, 'projecttask'); + + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject,$langs->trans("DeleteATask"),$langs->trans("ConfirmDeleteATask"),"confirm_delete"); + } + + if (! GETPOST('withproject') || empty($projectstatic->id)) + { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); + $task->next_prev_filter=" fk_projet in (".$projectsListId.")"; + } + else $task->next_prev_filter=" fk_projet = ".$projectstatic->id; + + $morehtmlref=''; + + // Project + if (empty($withproject)) + { + $morehtmlref.='
'; + $morehtmlref.=$langs->trans("Project").': '; + $morehtmlref.=$projectstatic->getNomUrl(1); + $morehtmlref.='
'; + + // Third party + $morehtmlref.=$langs->trans("ThirdParty").': '; + if (!empty($projectstatic->thirdparty)) { + $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + } + $morehtmlref.='
'; + } + + dol_banner_tab($task, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); + + print '
'; + + print '
'; + print ''; + + // Nb comments + print ''; + + // Other attributes + $cols = 3; + $parameyers=array('socid'=>$socid); + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans("TaskNbComments").''; + print $task->getNbComments(); + print '
'; + + print '
'; + + dol_fiche_end(); + + + print '
'; + print '
'; + + // Add comment + + print '
'; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + print ''; + + // Description + print ''; + + print ''; + print '
'.$langs->trans("Comments").'
'; + + $desc = ($_POST['comment_description']?$_POST['comment_description']:''); + + $doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '100%'); + print $doleditor->Create(1); + + print ''; + print ''; + print '
'; + + // List of comments + if(!empty($task->comments)) { + // Default color for current user + $TColors = array($user->id => 'efefef'); + $first = true; + foreach($task->comments as $comment) { + $fk_user = $comment->fk_user; + $userstatic->fetch($fk_user); + if(empty($TColors[$fk_user])) { + $TColors[$fk_user] = random_color(180,240); + } + print '
'; + if($comment->fk_user == $user->id) { + print '
 
'; + } + + print '
'; + print '
'; + print $comment->description; + print '
'; + print '
'; + print $langs->trans('User').' : '.$userstatic->getNomUrl().'
'; + print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec'); + if($first && $fk_user == $user->id) { + print '
'.$langs->trans('Delete').''; + } + print '
'; + print '
'; + + if($comment->fk_user != $user->id) { + print '
 
'; + } + + $first = false; + } + } + + print '
'; + print '
'; + + } +} + + +llxFooter(); +$db->close(); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 1b0d04469c3..ccec30b0a34 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -826,6 +826,16 @@ div.fiche>form>div.div-table-responsive { .titlefieldmiddle { width: 50%; } .imgmaxwidth180 { max-width: 180px; } +.width20p { width:20%; } +.width25p { width:25%; } +.width40p { width:40%; } +.width50p { width:50%; } +.width60p { width:60%; } +.width75p { width:75%; } +.width80p { width:80%; } +.width100p { width:100%; } + + /* Force values for small screen 1400 */ @media only screen and (max-width: 1400px) { @@ -3799,6 +3809,29 @@ pre#editfilecontentaceeditorid { } +/* ============================================================================== */ +/* Comments */ +/* ============================================================================== */ + +#comment div { + box-sizing:border-box; +} + +#comment .comment { + border-radius:7px; + padding:7px 10px; + margin-bottom:10px; +} +#comment .comment-info { + font-size:0.8em; + color:#555; + margin-top:5px; +} +#comment textarea { + width: 100%; +} + + /* ============================================================================== */ /* JSGantt */ From 680fab313c40ec971d2929b013ac87b45480024d Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 7 Sep 2017 16:47:52 +0200 Subject: [PATCH 006/111] NEW preload comments in task --- htdocs/projet/class/task.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 258805f9970..cf94307a32a 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -259,8 +259,12 @@ class Task extends CommonObject $this->db->free($resql); - if ($num_rows) return 1; - else return 0; + if ($num_rows) { + $this->fetchComments(); + return 1; + }else { + return 0; + } } else { From 7648d300b5a01c3105cf0be912f2b8faff64bc55 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 7 Sep 2017 17:13:48 +0200 Subject: [PATCH 007/111] FIX: Bad link to unpayed suppliers invoices --- htdocs/fourn/class/fournisseur.facture.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index f4cf4762a91..7af1480d7cd 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2016 Juanjo Menent + * Copyright (C) 2010-2017 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García @@ -1788,7 +1788,7 @@ class FactureFournisseur extends CommonInvoice $response = new WorkboardResponse(); $response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24; $response->label=$langs->trans("SupplierBillsToPay"); - $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=fac.fk_statut:1,paye:0&mainmenu=accountancy&leftmenu=suppliers_bills'; + $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=suppliers_bills'; $response->img=img_object($langs->trans("Bills"),"bill"); $facturestatic = new FactureFournisseur($this->db); From 7f5950c9582fd74c62ff4503c473c17a5cef0ae9 Mon Sep 17 00:00:00 2001 From: arnaud Date: Fri, 8 Sep 2017 09:14:34 +0200 Subject: [PATCH 008/111] FIX multiple comments not reset on fetch --- htdocs/projet/class/task.class.php | 1 + htdocs/projet/tasks/comment.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index cf94307a32a..3789759c2e9 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1801,6 +1801,7 @@ class Task extends CommonObject */ public function fetchComments() { + $this->comments = array(); $sql = "SELECT"; $sql.= " c.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_comment as c"; diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 0446cc71ea6..3f0cbe0bf47 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -141,7 +141,6 @@ if ($id > 0 || ! empty($ref)) if ($task->fetch($id,$ref) > 0) { $res=$task->fetch_optionals($task->id,$extralabels); - $res = $task->fetchComments(); $result=$projectstatic->fetch($task->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); @@ -369,7 +368,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print $langs->trans('User').' : '.$userstatic->getNomUrl().'
'; print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec'); - if($first && $fk_user == $user->id) { + if(($first && $fk_user == $user->id) || $user->admin == 1) { print '
'.$langs->trans('Delete').''; } print '
'; From fdd758abb4db8b0125c5044c8eb8d53f780d08a9 Mon Sep 17 00:00:00 2001 From: arnaud Date: Fri, 8 Sep 2017 09:17:22 +0200 Subject: [PATCH 009/111] FIX empty test on conf fortask comment was bad --- htdocs/core/lib/project.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 189c37dbe32..0395f9f17ff 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -177,7 +177,7 @@ function task_prepare_head($object) complete_head_from_modules($conf,$langs,$object,$head,$h,'task'); // Manage discussion - if (empty($conf->global->MAIN_ALLOW_COMMENT_ON_TASK)) + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { $nbComments= $object->getNbComments(); $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); From da2f97134596b7f9955f053e8ae4d27dac631a14 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 8 Sep 2017 10:33:00 +0200 Subject: [PATCH 010/111] fix upload images on category --- htdocs/categories/class/categorie.class.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ecf95c5096d..94113799be9 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1525,11 +1525,13 @@ class Categorie extends CommonObject * Deplace fichier uploade sous le nom $files dans le repertoire sdir * * @param string $sdir Repertoire destination finale - * @param string $file Nom du fichier uploade + * @param string $files Nom du fichier uploade * @return void */ function add_photo($sdir, $file) { + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $dir = $sdir .'/'. get_exdir($this->id,2,0,0,$this,'category') . $this->id ."/"; @@ -1542,15 +1544,18 @@ class Categorie extends CommonObject if (file_exists($dir)) { - $originImage = $dir . $file['name']; + for ($i=0;$i<=count($file['name']);$i++) { - // Cree fichier en taille origine - dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0); + $originImage = $dir . $file['name'][$i]; - if (file_exists($originImage)) - { - // Create thumbs - $this->addThumbs($originImage); + // Cree fichier en taille origine + dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0); + + if (file_exists($originImage)) + { + // Create thumbs + $this->addThumbs($originImage); + } } } } From 20ed279489cd87f2dd386d8bbb5421e3317e9d75 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 8 Sep 2017 10:34:38 +0200 Subject: [PATCH 011/111] better fix --- htdocs/categories/class/categorie.class.php | 26 ++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 94113799be9..23cced4f0e5 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1542,18 +1542,28 @@ class Categorie extends CommonObject dol_mkdir($dir); } - if (file_exists($dir)) - { - for ($i=0;$i<=count($file['name']);$i++) { + if (file_exists($dir)) { + if (is_array($file['name']) && count($file['name']) > 0) { + for($i = 0; $i <= count($file['name']); $i ++) { - $originImage = $dir . $file['name'][$i]; + $originImage = $dir . $file['name'][$i]; + + // Cree fichier en taille origine + dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0); + + if (file_exists($originImage)) { + // Create thumbs + $this->addThumbs($originImage); + } + } + } else { + $originImage = $dir . $file['name']; // Cree fichier en taille origine - dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0); + dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0); - if (file_exists($originImage)) - { - // Create thumbs + if (file_exists($originImage)) { + // Create thumbs $this->addThumbs($originImage); } } From 34f08ce082dd5f0c2aff5173ed549d5cd2312856 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 8 Sep 2017 10:36:11 +0200 Subject: [PATCH 012/111] fix travis --- htdocs/categories/class/categorie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 23cced4f0e5..1e494c4a1ff 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1525,7 +1525,7 @@ class Categorie extends CommonObject * Deplace fichier uploade sous le nom $files dans le repertoire sdir * * @param string $sdir Repertoire destination finale - * @param string $files Nom du fichier uploade + * @param string $file Nom du fichier uploade * @return void */ function add_photo($sdir, $file) From 1a389b6faf891d4b3ffc51ad87e0b7d1ffcebb11 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 8 Sep 2017 10:36:45 +0200 Subject: [PATCH 013/111] fix upload photo for categ --- htdocs/categories/class/categorie.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 1e494c4a1ff..05d9049ff03 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1530,8 +1530,6 @@ class Categorie extends CommonObject */ function add_photo($sdir, $file) { - - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $dir = $sdir .'/'. get_exdir($this->id,2,0,0,$this,'category') . $this->id ."/"; From d4c20a919d5f1f4843382efb8706cd51c4a4ddb0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Sep 2017 12:52:56 +0200 Subject: [PATCH 014/111] Fix: avoid warning --- .../user/doc/doc_generic_user_odt.modules.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index b7079dde30e..1a9074fbedf 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -313,7 +313,7 @@ class doc_generic_user_odt extends ModelePDFUser { $socobject=$object->client; } - + // Open and load template require_once ODTPHP_PATH.'odf.php'; try { @@ -332,7 +332,7 @@ class doc_generic_user_odt extends ModelePDFUser $this->error=$e->getMessage(); return -1; } - + // Make substitutions into odt $array_user=$this->get_substitutionarray_user($object,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); @@ -366,7 +366,7 @@ class doc_generic_user_odt extends ModelePDFUser { } } - + // Replace labels translated $tmparray=$outputlangs->get_translations_for_substitutions(); foreach($tmparray as $key=>$value) @@ -420,12 +420,12 @@ class doc_generic_user_odt extends ModelePDFUser return -1; } - function get_substitutionarray_object($object,$outputlangs) { + function get_substitutionarray_object($object,$outputlangs,$array_key='object') { foreach($object as $key => $value) { - if(!is_array($value) && !is_object($value)) { - $array_other['object_'.$key] = $value; + if (!is_array($value) && !is_object($value)) { + $array_other['object_'.$key] = $value; } - } + } return $array_other; } From a6a142753a259c681dec77f6971888787c2f2114 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Sep 2017 15:24:27 +0200 Subject: [PATCH 015/111] Fix bad label when account not set --- htdocs/accountancy/customer/index.php | 41 ++++++++++++--- htdocs/accountancy/expensereport/index.php | 60 +++++++++++++++------- htdocs/accountancy/supplier/index.php | 42 +++++++++++---- htdocs/langs/en_US/accountancy.lang | 1 + 4 files changed, 109 insertions(+), 35 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index f1bea3bd4a1..c07f15a6ef4 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -213,8 +213,8 @@ for($i = 1; $i <= 12; $i ++) { } print '' . $langs->trans("Total") . ''; -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -240,8 +240,20 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print '' . length_accountg($row[0]) . ''; - print '' . $row[1] . ''; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print ''; for($i = 2; $i <= 12; $i ++) { print '' . price($row[$i]) . ''; } @@ -269,8 +281,8 @@ for($i = 1; $i <= 12; $i ++) { } print '' . $langs->trans("Total") . ''; -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -296,7 +308,20 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print '' . length_accountg($row[0]) . ''; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print ''; print '' . $row[1] . ''; for($i = 2; $i <= 12; $i ++) { print '' . price($row[$i]) . ''; @@ -363,7 +388,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. } print "\n"; - + if (! empty($conf->margin->enabled)) { print "
\n"; print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index b17aeedb4bd..19a0a6b5187 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -94,7 +94,7 @@ if ($action == 'validatehistory') { } dol_syslog('htdocs/accountancy/expensereport/index.php'); - + $resql1 = $db->query($sql1); if (! $resql1) { $error ++; @@ -139,7 +139,7 @@ if ($action == 'validatehistory') { $sql1.= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; $sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")"; $sql1.=")"; - + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); @@ -194,8 +194,8 @@ for($i = 1; $i <= 12; $i ++) { } print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -217,9 +217,21 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; - for($i = 2; $i <= 12; $i ++) { + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { print ''; } print ''; @@ -247,8 +259,8 @@ for($i = 1; $i <= 12; $i ++) { } print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -270,9 +282,21 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; - for($i = 2; $i <= 12; $i ++) { + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { print ''; } print ''; @@ -292,9 +316,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. { print '
'; print '
'; - + print_fiche_titre($langs->trans("OtherInfo"), '', ''); - + print "
\n"; print '
' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . price($row[13]) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . price($row[13]) . '
'; print ''; @@ -302,7 +326,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print ''; } print ''; - + $sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; @@ -314,12 +338,12 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy - + dol_syslog('htdocs/accountancy/expensereport/index.php'); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - + while ( $row = $db->fetch_row($resql)) { print ''; for($i = 1; $i <= 12; $i ++) { @@ -328,7 +352,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print ''; print ''; } - + $db->free($resql); } else { print $db->lasterror(); // Show last sql error diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index f862feb5ba3..3dac6a23567 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -190,8 +190,8 @@ for($i = 1; $i <= 12; $i ++) { } print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -213,8 +213,20 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; + print ''; + print ''; for($i = 2; $i <= 12; $i ++) { print ''; } @@ -244,8 +256,8 @@ for($i = 1; $i <= 12; $i ++) { } print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -267,9 +279,21 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; - for($i = 2; $i <= 12; $i ++) { + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { print ''; } print ''; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index e200f0ca7c0..757dbde1c0b 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -273,5 +273,6 @@ BookeppingLineAlreayExists=Lines already existing into bookeeping NoJournalDefined=No journal defined Binded=Lines bound ToBind=Lines to bind +UseMenuToSetBindindManualy=Autodection not possible, use menu %s to make the binding manually WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. It will be replaced by a more complete report in a next version. From 8b20c5edab762bf71208a281f76fa07645422e4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Sep 2017 15:44:11 +0200 Subject: [PATCH 016/111] FIX Remove warning when using log into syslog --- htdocs/accountancy/journal/bankjournal.php | 11 ++++++++--- htdocs/core/modules/syslog/mod_syslog_syslog.php | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 505e2a9f534..35f612802c2 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -172,13 +172,16 @@ if ($result) { { $obj = $db->fetch_object($result); + $lineisapurchase = ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)'); + $lineisasell = ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)'); + // Set accountancy code (for bank and thirdparty) $compta_bank = $obj->account_number; $compta_soc = 'NotDefined'; - if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') + if ($lineisapurchase) $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier); - if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') + if ($lineisasell) $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer); $tabcompany[$obj->rowid] = array ( @@ -604,6 +607,8 @@ if (! $error && $action == 'writebookkeeping') { } } + + // Export if ($action == 'exportcsv') { // ISO and not UTF8 ! $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; @@ -936,7 +941,7 @@ $db->close(); * Return source for doc_ref of a bank transaction * * @param string $val Array of val - * @param string $typerecord Type of record + * @param string $typerecord Type of record ('payment', 'payment_supplier', 'payment_expensereport', 'payment_vat', ...) * @return string|unknown */ function getSourceDocRef($val, $typerecord) diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php index e0283ac9a9f..1f2f499fbac 100644 --- a/htdocs/core/modules/syslog/mod_syslog_syslog.php +++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php @@ -49,7 +49,7 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface public function isActive() { global $conf; - + // This function does not exists on some ISP (Ex: Free in France) if (!function_exists('openlog')) return 0; @@ -81,15 +81,15 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface */ public function checkConfiguration() { - global $langs; + global $conf, $langs; $errors = array(); - $facility = SYSLOG_FACILITY; + $facility = constant($conf->global->SYSLOG_FACILITY); if ($facility) { // Only LOG_USER supported on Windows - if (! empty($_SERVER["WINDIR"])) $facility='LOG_USER'; + if (! empty($_SERVER["WINDIR"])) $facility=constant('LOG_USER'); dol_syslog("admin/syslog: facility ".$facility); } From c498ce3c41d8847f279169fc15202ba0bb8c830d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Sep 2017 17:50:39 +0200 Subject: [PATCH 017/111] FIX journalization for bank journal should not rely on a label. --- htdocs/accountancy/journal/bankjournal.php | 82 +++++++++++++++++----- htdocs/langs/en_US/accountancy.lang | 3 +- 2 files changed, 67 insertions(+), 18 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 35f612802c2..640c4b03353 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -104,12 +104,15 @@ $idpays = $mysoc->country_id; $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; -$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop,"; -$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop"; +$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop_company,"; +$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop_user,"; +$sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; $sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal; @@ -147,6 +150,7 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); + //print $sql; // Variables $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word @@ -172,16 +176,31 @@ if ($result) { { $obj = $db->fetch_object($result); - $lineisapurchase = ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)'); - $lineisasell = ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)'); + $lineisapurchase = -1; + $lineisasale = -1; + // Old method to detect if it's a sale or purchase + if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase=1; + if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale=1; + // Try a more reliable method to detect if record is a supplier payment or a customer payment + if ($lineisapurchase < 0) + { + if ($obj->typeop_payment_supplier == 'payment_supplier') $lineisapurchase = 1; + } + if ($lineisasale < 0) + { + if ($obj->typeop_payment == 'payment') $lineisasale = 1; + } + //var_dump($obj->type_payment); var_dump($obj->type_payment_supplier); + //var_dump($lineisapurchase); //var_dump($lineisasale); - // Set accountancy code (for bank and thirdparty) + // Set accountancy code for bank $compta_bank = $obj->account_number; + // Set accountancy code for thirdparty $compta_soc = 'NotDefined'; - if ($lineisapurchase) + if ($lineisapurchase > 0) $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier); - if ($lineisasell) + if ($lineisasale > 0) $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer); $tabcompany[$obj->rowid] = array ( @@ -190,6 +209,7 @@ if ($result) { 'code_compta' => $compta_soc, ); + // Set accountancy code for user $compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); $tabuser[$obj->rowid] = array ( @@ -205,6 +225,7 @@ if ($result) { $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ... $tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; + $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref; $tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account; if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) { $tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]); @@ -217,7 +238,7 @@ if ($result) { //var_dump($tabpay); // By default - $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or old record with no links in bank_url. + $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url. $tabtype[$obj->rowid] = 'unknown'; // get_url may return -1 which is not traversable @@ -742,6 +763,22 @@ if (empty($action) || $action == 'view') { journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); + + // Test that setup is complete + $sql='SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE fk_accountancy_journal IS NULL'; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if ($obj->nb > 0) + { + print img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); + print ' : '.$langs->trans("AccountancyAreaDescBank", 9, ''.$langs->transnoentitiesnoconv("MenuBankCash").''); + } + } + else dol_print_error($db); + + // Button to write into Ledger if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' || empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1' @@ -802,8 +839,10 @@ if (empty($action) || $action == 'view') { // Bank foreach ( $tabbq[$key] as $k => $mt ) { + //var_dump($tabpay[$key]); + print ''; print ''; - print ""; + print ""; print ""; print ""; // Ledger account @@ -824,11 +863,14 @@ if (empty($action) || $action == 'view') { } else print $accounttoshow;*/ print ""; - if ($val['soclib'] == '') { - print ""; - } else { - print ""; + print ""; print ""; print ""; print ""; @@ -839,14 +881,15 @@ if (empty($action) || $action == 'view') { if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { if ($k != 'type') { + print ''; print ''; - print ""; + print ""; print ""; print ""; // Ledger account print "'; - print ""; + print ""; print ""; print ""; // Ledger account diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 757dbde1c0b..0ef6afd193a 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -54,7 +54,7 @@ AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for speci 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. -AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. +AccountancyAreaDescBank=STEP %s: Define accounting accounts and journal code for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s. AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in Ledger in one click. Complete missing bindings. For this, use the menu entry %s. @@ -63,6 +63,7 @@ AccountancyAreaDescAnalyze=STEP %s: Add or edit existing transactions and genera AccountancyAreaDescClosePeriod=STEP %s: Close period so we can't make modification in a future. +TheJournalCodeIsNotDefinedOnSomeBankAccount=A mandatory step in setup was not complete (accountancy code journal not defined for all bank accounts) MenuAccountancy=Accountancy Selectchartofaccounts=Select active chart of accounts ChangeAndLoad=Change and load From 310e912a9d5ccb11f1777ca67aa1b190f3926b9c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Sep 2017 19:57:59 +0200 Subject: [PATCH 018/111] Fix: missing parameters for filter and sort --- htdocs/societe/list.php | 162 ++++++++++++++++++++-------------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7d7fa8baabb..c7506f31e08 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -208,63 +208,63 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Did we click on purge search criteria ? - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers - { - $search_nom=''; - $search_alias=''; - $search_categ_cus=0; - $search_categ_sup=0; - $search_sale=''; - $search_barcode=""; - $search_customer_code=''; - $search_supplier_code=''; - $search_account_customer_code=''; - $search_account_supplier_code=''; - $search_town=""; - $search_zip=""; - $search_state=""; - $search_country=''; - $search_email=''; - $search_phone=''; - $search_url=''; - $search_idprof1=''; - $search_idprof2=''; - $search_idprof3=''; - $search_idprof4=''; - $search_idprof5=''; - $search_idprof6=''; - $search_type=''; - $search_type_thirdparty=''; - $search_status=-1; - $search_stcomm=''; - $search_level_from=''; - $search_level_to=''; - $toselect=''; - $search_array_options=array(); - } + // Did we click on purge search criteria ? + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + $search_nom=''; + $search_alias=''; + $search_categ_cus=0; + $search_categ_sup=0; + $search_sale=''; + $search_barcode=""; + $search_customer_code=''; + $search_supplier_code=''; + $search_account_customer_code=''; + $search_account_supplier_code=''; + $search_town=""; + $search_zip=""; + $search_state=""; + $search_country=''; + $search_email=''; + $search_phone=''; + $search_url=''; + $search_idprof1=''; + $search_idprof2=''; + $search_idprof3=''; + $search_idprof4=''; + $search_idprof5=''; + $search_idprof6=''; + $search_type=''; + $search_type_thirdparty=''; + $search_status=-1; + $search_stcomm=''; + $search_level_from=''; + $search_level_to=''; + $toselect=''; + $search_array_options=array(); + } - // Mass actions - $objectclass='Societe'; - $objectlabel='ThirdParty'; - $permtoread = $user->rights->societe->lire; - $permtodelete = $user->rights->societe->supprimer; - $uploaddir = $conf->societe->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Mass actions + $objectclass='Societe'; + $objectlabel='ThirdParty'; + $permtoread = $user->rights->societe->lire; + $permtodelete = $user->rights->societe->supprimer; + $uploaddir = $conf->societe->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - if ($action == 'setstcomm') - { - $object = new Client($db); - $result=$object->fetch(GETPOST('stcommsocid')); - $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); - $result=$object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); + if ($action == 'setstcomm') + { + $object = new Client($db); + $result=$object->fetch(GETPOST('stcommsocid')); + $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); + $result=$object->update($object->id, $user); + if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); - $action=''; - } + $action=''; + } } if ($search_status=='') $search_status=1; // always display active thirdparty first @@ -906,30 +906,30 @@ print ''; print "\n"; print ''; -if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); -if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder); -if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); -if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); -if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); -if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.url","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer -if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); -if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.url","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer +if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -945,12 +945,12 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$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['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; From c1c75208eccbe6177aaa5ac7716c9b367bc2eceb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 09:46:21 +0200 Subject: [PATCH 019/111] Fix: missing parameters for filter and sort (contact list) --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 50bb85ace6e..7508381e6cd 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -642,7 +642,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$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("DateCreationShort",$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); From e555233dc12c1a206ae41754df78f2086cbba110 Mon Sep 17 00:00:00 2001 From: Kjeld Borch Egevang Date: Sat, 9 Sep 2017 11:29:30 +0200 Subject: [PATCH 020/111] Remove processing by htmlentities() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When translated texts contain international characters they are unintentionally changed by htmlentities(). You can see the problem at the admin/index.php page (language set to French): Les paramètres dans le menu Configuration -> Société/Organisation sont requis car les données définies sont utilisées dans l'affichage Dolibarr et pour personnaliser le comportement par défaut du logiciel (pour les fonctionnalités liées à un pays par exemple). --- htdocs/core/class/translate.class.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 169aec16307..180b4db0ba6 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -620,15 +620,6 @@ class Translate if ($maxsize) $str=dol_trunc($str,$maxsize); - // We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities - $str=str_replace(array('<','>','"',),array('__lt__','__gt__','__quot__'),$str); - - // Crypt string into HTML - $str=htmlentities($str,ENT_QUOTES,$this->charset_output); - - // Restore HTML tags - $str=str_replace(array('__lt__','__gt__','__quot__'),array('<','>','"',),$str); - return $str; } else // Translation is not available From 7404a6cf980468b5b749bf1edcc303234f1f4177 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 12:15:59 +0200 Subject: [PATCH 021/111] Fix: avoid htmlentities --- htdocs/admin/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 9ac33f1cc3d..65b38970a6e 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -70,13 +70,13 @@ if (! empty($conf->global->MAIN_MOTD_SETUPPAGE)) print $langs->trans("SetupDescription1").' '; print $langs->trans("AreaForAdminOnly").' '; -print $langs->trans("SetupDescription2", $langs->trans("MenuCompanySetup"), $langs->trans("Modules"))."

"; +print $langs->trans("SetupDescription2", $langs->transnoentities("MenuCompanySetup"), $langs->transnoentities("Modules"))."

"; print '
'; // Show info setup company if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; -print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->trans("Setup"), $langs->trans("MenuCompanySetup")); +print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); if (! empty($setupcompanynotcomplete)) { $langs->load("errors"); @@ -88,7 +88,7 @@ print '
'; print '
'; // Show info setup module -print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->trans("Setup"), $langs->trans("Modules")); +print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled { $langs->load("errors"); From a8fdf0b5eafe3628689d6a3e886491da437466a0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 16:49:26 +0200 Subject: [PATCH 022/111] Fix: missing salaries upgrade reload module --- htdocs/install/upgrade2.php | 478 ++++++++++++++++++------------------ 1 file changed, 245 insertions(+), 233 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 2c032ffa7c0..7bf283f828d 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -375,39 +375,40 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 } } - // Code executed only if migrate is LAST ONE. Must always be done. - if (versioncompare($versiontoarray,$versionranarray) >= 0 || versioncompare($versiontoarray,$versionranarray) <= -3) - { - // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) - $listofmodule=array( - 'MAIN_MODULE_AGENDA'=>'newboxdefonly', - 'MAIN_MODULE_BARCODE'=>'newboxdefonly', - 'MAIN_MODULE_CRON'=>'newboxdefonly', - 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', - 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', - 'MAIN_MODULE_DON'=>'newboxdefonly', - 'MAIN_MODULE_ECM'=>'newboxdefonly', - 'MAIN_MODULE_FACTURE'=>'newboxdefonly', - 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', - 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', - 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', - 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', - 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', - 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', - 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', - 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', - 'MAIN_MODULE_BARCODE'=>'newboxdefonly', - 'MAIN_MODULE_CRON'=>'newboxdefonly', - 'MAIN_MODULE_PRINTING'=>'newboxdefonly', + // Code executed only if migrate is LAST ONE. Must always be done. + if (versioncompare($versiontoarray,$versionranarray) >= 0 || versioncompare($versiontoarray,$versionranarray) <= -3) + { + // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) + $listofmodule=array( + 'MAIN_MODULE_AGENDA'=>'newboxdefonly', + 'MAIN_MODULE_BARCODE'=>'newboxdefonly', + 'MAIN_MODULE_CRON'=>'newboxdefonly', + 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', + 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', + 'MAIN_MODULE_DON'=>'newboxdefonly', + 'MAIN_MODULE_ECM'=>'newboxdefonly', + 'MAIN_MODULE_FACTURE'=>'newboxdefonly', + 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', + 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', + 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', + 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', + 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', + 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', + 'MAIN_MODULE_SERVICE'=>'newboxdefonly', + 'MAIN_MODULE_USER'=>'newboxdefonly', + 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', + 'MAIN_MODULE_BARCODE'=>'newboxdefonly', + 'MAIN_MODULE_CRON'=>'newboxdefonly', + 'MAIN_MODULE_PRINTING'=>'newboxdefonly', + 'MAIN_MODULE_SALARIES'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) - ); - migrate_reload_modules($db,$langs,$conf,$listofmodule); + 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) + ); + migrate_reload_modules($db,$langs,$conf,$listofmodule); - // Reload menus (this must be always and only into last targeted version) - migrate_reload_menu($db,$langs,$conf,$versionto); - } + // Reload menus (this must be always and only into last targeted version) + migrate_reload_menu($db,$langs,$conf,$versionto); + } // Can force activation of some module during migration with paramater 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' if (! $error && $enablemodules) @@ -4112,216 +4113,227 @@ function migrate_delete_old_dir($db,$langs,$conf) */ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) { - dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force); + dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force); - // If no info is provided, we reload all modules with mode newboxdefonly. - if (count($listofmodule) == 0) - { - $listofmodule=array( - 'MAIN_MODULE_AGENDA'=>'newboxdefonly', - 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', - 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', - 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', - 'MAIN_MODULE_FACTURE'=>'newboxdefonly', - 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', - 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', - 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', - 'MAIN_MODULE_DON'=>'newboxdefonly', - 'MAIN_MODULE_ECM'=>'newboxdefonly', - 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', - 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly' - ); - } + // If no info is provided, we reload all modules with mode newboxdefonly. + if (count($listofmodule) == 0) + { + $listofmodule=array( + 'MAIN_MODULE_AGENDA'=>'newboxdefonly', + 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', + 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', + 'MAIN_MODULE_SERVICE'=>'newboxdefonly', + 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', + 'MAIN_MODULE_FACTURE'=>'newboxdefonly', + 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', + 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', + 'MAIN_MODULE_USER'=>'newboxdefonly', + 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', + 'MAIN_MODULE_DON'=>'newboxdefonly', + 'MAIN_MODULE_ECM'=>'newboxdefonly', + 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', + 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', + 'MAIN_MODULE_SALARIES'=>'newboxdefonly' + ); + } - foreach($listofmodule as $moduletoreload => $reloadmode) - { - if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled + foreach($listofmodule as $moduletoreload => $reloadmode) + { + if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled - $mod=null; + $mod=null; - if ($moduletoreload == 'MAIN_MODULE_AGENDA') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; - if ($res) { - $mod=new modAgenda($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_API') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; - if ($res) { - $mod=new modApi($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_BARCODE') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; - if ($res) { - $mod=new modBarcode($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_CRON') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; - if ($res) { - $mod=new modCron($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_SOCIETE') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; - if ($res) { - $mod=new modSociete($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; - if ($res) { - $mod=new modProduct($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; - if ($res) { - $mod=new modService($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; - if ($res) { - $mod=new modCommande($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; - if ($res) { - $mod=new modFacture($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; - if ($res) { - $mod=new modFournisseur($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; - if ($res) { - $mod=new modHoliday($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; - if ($res) { - $mod=new modDeplacement($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; - if ($res) { - $mod=new modDon($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; - if ($res) { - $mod=new modECM($db); - $mod->remove('noboxes'); // We need to remove because a permission id has been removed - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; - if ($res) { - $mod=new modPaybox($db); - $mod->remove('noboxes'); // We need to remove because id of module has changed - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; - if ($res) { - $mod=new modOpenSurvey($db); - $mod->remove('noboxes'); // We need to remove because menu entries has changed - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_USER') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate User module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modUser.class.php'; - if ($res) { - $mod=new modUser($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } + if ($moduletoreload == 'MAIN_MODULE_AGENDA') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; + if ($res) { + $mod=new modAgenda($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_API') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; + if ($res) { + $mod=new modApi($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_BARCODE') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; + if ($res) { + $mod=new modBarcode($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_CRON') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; + if ($res) { + $mod=new modCron($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_SOCIETE') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; + if ($res) { + $mod=new modSociete($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; + if ($res) { + $mod=new modProduct($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; + if ($res) { + $mod=new modService($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; + if ($res) { + $mod=new modCommande($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; + if ($res) { + $mod=new modFacture($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; + if ($res) { + $mod=new modFournisseur($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; + if ($res) { + $mod=new modHoliday($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; + if ($res) { + $mod=new modDeplacement($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; + if ($res) { + $mod=new modDon($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; + if ($res) { + $mod=new modECM($db); + $mod->remove('noboxes'); // We need to remove because a permission id has been removed + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; + if ($res) { + $mod=new modPaybox($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; + if ($res) { + $mod=new modOpenSurvey($db); + $mod->remove('noboxes'); // We need to remove because menu entries has changed + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_SALARIES') // Permission has changed into 6.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Salaries module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSalaries.class.php'; + if ($res) { + $mod=new modSalaries($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_USER') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate User module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modUser.class.php'; + if ($res) { + $mod=new modUser($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } if (! empty($mod) && is_object($mod)) { - print '
'; + print ''; } - } + } } From 67e9b65a2e1fc6ed3c9e6c4c6a37b862384c4423 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 17:07:08 +0200 Subject: [PATCH 023/111] Fix: use $array_key value instead --- htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 1a9074fbedf..11ae5729b3b 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -421,9 +421,10 @@ class doc_generic_user_odt extends ModelePDFUser } function get_substitutionarray_object($object,$outputlangs,$array_key='object') { + $array_other=array(); foreach($object as $key => $value) { if (!is_array($value) && !is_object($value)) { - $array_other['object_'.$key] = $value; + $array_other[$array_key.'_'.$key] = $value; } } return $array_other; From 762b4eb8768a0b09d69c06529566954f7efbc1c0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 17:48:04 +0200 Subject: [PATCH 024/111] Fix: some problems with medias in multicompany --- htdocs/core/class/conf.class.php | 15 ++++++++++----- htdocs/core/lib/files.lib.php | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 77c24ff4109..da44eeeb6f6 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -83,11 +83,12 @@ class Conf $this->file = new stdClass(); $this->db = new stdClass(); $this->global = new stdClass(); - $this->mycompany = new stdClass(); - $this->admin = new stdClass(); + $this->mycompany = new stdClass(); + $this->admin = new stdClass(); $this->user = new stdClass(); $this->syslog = new stdClass(); $this->browser = new stdClass(); + $this->medias = new stdClass(); $this->multicompany = new stdClass(); //! Charset for HTML output and for storing data in memory @@ -96,7 +97,7 @@ class Conf // First level object // TODO Remove this part. $this->expedition_bon = new stdClass(); - $this->livraison_bon = new stdClass(); + $this->livraison_bon = new stdClass(); $this->fournisseur = new stdClass(); $this->product = new stdClass(); $this->service = new stdClass(); @@ -106,12 +107,12 @@ class Conf $this->propal = new stdClass(); $this->facture = new stdClass(); $this->contrat = new stdClass(); - $this->usergroup = new stdClass(); + $this->usergroup = new stdClass(); $this->adherent = new stdClass(); $this->bank = new stdClass(); $this->notification = new stdClass(); $this->mailing = new stdClass(); - $this->expensereport = new stdClass(); + $this->expensereport = new stdClass(); } @@ -322,6 +323,10 @@ class Conf $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; + // For medias storage + $this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); + $this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp"); + // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. // Sous module bons d'expedition diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index e3419be0d14..9ff9ec0df63 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1875,7 +1875,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) { $accessallowed=1; - $original_file=$dolibarr_main_data_root.'/medias/'.$original_file; + $original_file=$conf->medias->multidir_output[$entity].'/'.$original_file; } // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log elseif ($modulepart == 'logs' && !empty($dolibarr_main_data_root)) From 698a047573824d6acaac3f253fee6549d4e15201 Mon Sep 17 00:00:00 2001 From: reeperbahnause Date: Sat, 9 Sep 2017 20:00:09 +0200 Subject: [PATCH 025/111] fix #7361 missing generateDocument function fix #7361 Function generateDocument was missing for Class Fichinter --- htdocs/fichinter/class/fichinter.class.php | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index eaf10c357e4..9b71efe7811 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -579,6 +579,38 @@ class Fichinter extends CommonObject return $amount; } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force model to use ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) + { + global $conf,$langs; + + $langs->load("interventions"); + + if (! dol_strlen($modele)) { + + $modele = 'azur'; + + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->PROPALE_ADDON_PDF)) { + $modele = $conf->global->PROPALE_ADDON_PDF; + } + } + + $modelpath = "core/modules/fichinter/doc/"; + + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + } /** * Returns the label status From 8dbf4bfaeeebb9e292816ab3413e93e7c778abb8 Mon Sep 17 00:00:00 2001 From: Gitdyr Date: Sat, 9 Sep 2017 21:19:02 +0200 Subject: [PATCH 026/111] Danish accounting accounts. --- htdocs/install/mysql/data/llx_accounting.sql | 98 +++++++++++++++++++ .../mysql/data/llx_accounting_category.sql | 4 +- 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_accounting.sql b/htdocs/install/mysql/data/llx_accounting.sql index 43e72640450..bf973656661 100644 --- a/htdocs/install/mysql/data/llx_accounting.sql +++ b/htdocs/install/mysql/data/llx_accounting.sql @@ -2209,3 +2209,101 @@ INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (4782, 'PCG08-PYME','INCOME', 'XXXXXX', '7991', '4780', 'Revisión del deterioro de créditos a corto plazo empresas asociadas', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (4783, 'PCG08-PYME','INCOME', 'XXXXXX', '7992', '4780', 'Revisión del deterioro de créditos a corto plazo otras partes vinculadas', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (4784, 'PCG08-PYME','INCOME', 'XXXXXX', '7993', '4780', 'Revisión del deterioro de créditos a corto plazo otras empresas', 1); + +-- +-- Description of the accounts in DK-STD +-- + +INSERT INTO llx_accounting_system (rowid, pcg_version, label, active) VALUES (5,'DK-STD', 'Standardkontoplan fra SKAT', 1); + +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUE +(5082, 'DK-STD', 'Indtægter', 'XXXXXX', '1000', '0', 'Salg af varer/ydelser m. moms', 1), +(5083, 'DK-STD', 'Indtægter', '', '1010', '', 'Salg af varer EU', 1), +(5084, 'DK-STD', 'Indtægter', '', '1020', '', 'Salg af ydelser EU', 1), +(5085, 'DK-STD', 'Indtægter', '', '1030', '', 'Ej momspligtigt salg', 1), +(5086, 'DK-STD', 'Indtægter', '', '1040', '', 'Regulering igangværende arbejder', 1), +(5087, 'DK-STD', 'Omkostninger', '', '1100', '', 'Varekøb med moms', 1), +(5088, 'DK-STD', 'Omkostninger', '', '1110', '', 'Køb af varer EU', 1), +(5089, 'DK-STD', 'Omkostninger', '', '1120', '', 'Køb af ydelser EU', 1), +(5090, 'DK-STD', 'Omkostninger', '', '1130', '', 'Varelagerregulering', 1), +(5091, 'DK-STD', 'Omkostninger', '', '1140', '', 'Eget vareforbrug', 1), +(5092, 'DK-STD', 'Omkostninger', '', '1300', '', 'Repræsentation', 1), +(5093, 'DK-STD', 'Omkostninger', '', '1310', '', 'Annoncer/reklame', 1), +(5094, 'DK-STD', 'Omkostninger', '', '1320', '', 'Rejseudgifter', 1), +(5095, 'DK-STD', 'Omkostninger', '', '1330', '', 'Aviser og blade', 1), +(5096, 'DK-STD', 'Omkostninger', '', '1400', '', 'Brændstof', 1), +(5097, 'DK-STD', 'Omkostninger', '', '1410', '', 'Bilforsikring', 1), +(5098, 'DK-STD', 'Omkostninger', '', '1420', '', 'Vedligeholdelse', 1), +(5099, 'DK-STD', 'Omkostninger', '', '1430', '', 'Grøn ejerafgift mv.', 1), +(5100, 'DK-STD', 'Omkostninger', '', '1440', '', 'Leje og leasing', 1), +(5101, 'DK-STD', 'Omkostninger', '', '1450', '', 'Bilvask og pleje af bil', 1), +(5102, 'DK-STD', 'Omkostninger', '', '1460', '', 'Parkeringsudgifter', 1), +(5103, 'DK-STD', 'Omkostninger', '', '1470', '', 'Biludgifter efter statens takster', 1), +(5104, 'DK-STD', 'Omkostninger', '', '1480', '', 'Fri bil', 1), +(5105, 'DK-STD', 'Omkostninger', '', '1490', '', 'Privat andel af biludgifter', 1), +(5106, 'DK-STD', 'Omkostninger', '', '1600', '', 'Husleje uden forbrug', 1), +(5107, 'DK-STD', 'Omkostninger', '', '1610', '', 'Forbrugsudgifter (el, vand, gas og varme mv)', 1), +(5108, 'DK-STD', 'Omkostninger', '', '1620', '', 'Ejendomsskatter og forsikringer', 1), +(5109, 'DK-STD', 'Omkostninger', '', '1630', '', 'Vedligeholdelse af lokaler', 1), +(5110, 'DK-STD', 'Omkostninger', '', '1700', '', 'Kontorartikler og tryksager', 1), +(5111, 'DK-STD', 'Omkostninger', '', '1705', '', 'Telefon og internet', 1), +(5112, 'DK-STD', 'Omkostninger', '', '1710', '', 'Fri telefon privat andel', 1), +(5113, 'DK-STD', 'Omkostninger', '', '1715', '', 'Anskaffelse af småaktiver', 1), +(5114, 'DK-STD', 'Omkostninger', '', '1720', '', 'Arbejdstøj', 1), +(5115, 'DK-STD', 'Omkostninger', '', '1725', '', 'Rådgiverudgifter', 1), +(5116, 'DK-STD', 'Omkostninger', '', '1730', '', 'Porto og gebyrer', 1), +(5117, 'DK-STD', 'Omkostninger', '', '1735', '', 'Forsikringer', 1), +(5118, 'DK-STD', 'Omkostninger', '', '1740', '', 'Bøger og faglitteratur', 1), +(5119, 'DK-STD', 'Omkostninger', '', '1745', '', 'Konstaterede tab på debitorer', 1), +(5120, 'DK-STD', 'Omkostninger', '', '1750', '', 'Kassedifferencer', 1), +(5121, 'DK-STD', 'Afskrivninger', '', '2000', '', 'Afskrivning driftsmidler og inventar', 1), +(5122, 'DK-STD', 'Afskrivninger', '', '2010', '', 'Afskrivning blandede driftsmidler', 1), +(5123, 'DK-STD', 'Afskrivninger', '', '2020', '', 'Afskrivninger privat andel', 1), +(5124, 'DK-STD', 'Afskrivninger', '', '2030', '', 'Gevinst og tab ved salg af aktiver', 1), +(5125, 'DK-STD', 'Finansielle poster', '', '2400', '', 'Renteindtægter bank', 1), +(5126, 'DK-STD', 'Finansielle poster', '', '2410', '', 'Renteindtægter kunder', 1), +(5127, 'DK-STD', 'Finansielle poster', '', '2500', '', 'Renteudgifter bank og realkreditinstitut', 1), +(5128, 'DK-STD', 'Finansielle poster', '', '2510', '', 'Renteudgifter leverandører', 1), +(5129, 'DK-STD', 'Finansielle poster', '', '2520', '', 'Fradragsberettigede låneomkostninger', 1), +(5130, 'DK-STD', 'Finansielle poster', '', '2530', '', 'Fradragsberettigede renteudgifter til det offentlige', 1), +(5131, 'DK-STD', 'Balance', '', '3000', '', 'Afskrivningsgrundlag primo', 1), +(5132, 'DK-STD', 'Balance', '', '3010', '', 'Årets køb', 1), +(5133, 'DK-STD', 'Balance', '', '3015', '', 'Årets forbedringer', 1), +(5134, 'DK-STD', 'Balance', '', '3020', '', 'Årest salg', 1), +(5135, 'DK-STD', 'Balance', '', '3030', '', 'Årets afskrivning', 1), +(5136, 'DK-STD', 'Balance', '', '3040', '', 'Gevinst og tab', 1), +(5137, 'DK-STD', 'Balance', '', '3100', '', 'Afskrivningsgrundlag primo', 1), +(5138, 'DK-STD', 'Balance', '', '3110', '', 'Årets køb', 1), +(5139, 'DK-STD', 'Balance', '', '3115', '', 'Årets forbedringer', 1), +(5140, 'DK-STD', 'Balance', '', '3120', '', 'Årets salg', 1), +(5141, 'DK-STD', 'Balance', '', '3130', '', 'Årets afskrivning', 1), +(5142, 'DK-STD', 'Balance', '', '3140', '', 'Gevinst og tab', 1), +(5143, 'DK-STD', 'Balance', '', '3900', '', 'Huslejedepositum', 1), +(5144, 'DK-STD', 'Balance', '', '4000', '', 'Kasse', 1), +(5145, 'DK-STD', 'Balance', '', '4010', '', 'Bank', 1), +(5146, 'DK-STD', 'Balance', '', '4020', '', 'Forudbetalte omkostninger', 1), +(5147, 'DK-STD', 'Balance', '', '4030', '', 'Debitorer', 1), +(5148, 'DK-STD', 'Balance', '', '4040', '', 'Varelager', 1), +(5149, 'DK-STD', 'Balance', '', '4050', '', 'Igangværende arbejder', 1), +(5150, 'DK-STD', 'Balance', '', '5000', '', 'Egenkapital primo', 1), +(5151, 'DK-STD', 'Balance', '', '5010', '', 'Årets resultat', 1), +(5152, 'DK-STD', 'Balance', '', '5020', '', 'Privat hævet', 1), +(5153, 'DK-STD', 'Balance', '', '5030', '', 'Fri bil', 1), +(5154, 'DK-STD', 'Balance', '', '5040', '', 'Statens takster', 1), +(5155, 'DK-STD', 'Balance', '', '5050', '', 'Fri telefon m.v.', 1), +(5156, 'DK-STD', 'Balance', '', '5060', '', 'Private andele', 1), +(5157, 'DK-STD', 'Balance', '', '5065', '', 'Private afskrivninger', 1), +(5158, 'DK-STD', 'Balance', '', '5070', '', 'Driftsudgifter u/fradrag', 1), +(5159, 'DK-STD', 'Balance', '', '5080', '', 'Privat udlæg', 1), +(5160, 'DK-STD', 'Balance', '', '5090', '', 'Indskud', 1), +(5161, 'DK-STD', 'Balance', '', '7000', '', 'Gæld bank og realkreditinstitut', 1), +(5162, 'DK-STD', 'Balance', '', '7010', '', 'Gæld til leverandører af varer og tjenesteydelser', 1), +(5163, 'DK-STD', 'Balance', '', '7020', '', 'Periodeafgrænsningsposter', 1), +(5164, 'DK-STD', 'Balance', '', '7030', '', 'Anden gæld', 1), +(5165, 'DK-STD', 'Balance', '', '8000', '', 'Salgsmoms', 1), +(5166, 'DK-STD', 'Balance', '', '8010', '', 'Købsmoms', 1), +(5167, 'DK-STD', 'Balance', '', '8020', '', 'Konto for afgift af varekøb i EU', 1), +(5168, 'DK-STD', 'Balance', '', '8030', '', 'Konto for afgift af købte ydelser i EU', 1), +(5169, 'DK-STD', 'Balance', '', '8040', '', 'El- afgift', 1), +(5170, 'DK-STD', 'Balance', '', '8050', '', 'Øvrige energiafgifter', 1), +(5171, 'DK-STD', 'Balance', '', '8060', '', 'Betalt moms', 1) diff --git a/htdocs/install/mysql/data/llx_accounting_category.sql b/htdocs/install/mysql/data/llx_accounting_category.sql index 538a4257aab..4954ed3f0fc 100644 --- a/htdocs/install/mysql/data/llx_accounting_category.sql +++ b/htdocs/install/mysql/data/llx_accounting_category.sql @@ -18,7 +18,7 @@ -- Group of accounting account for French result. This is a minimal default setup. -INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VENTES', 'Income of products/services', 'Exemple: 7xxxxx', 0, 0, '', '10', 1, 1); -INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'DEPENSES', 'Expenses of products/services', 'Exemple: 6xxxxx', 0, 0, '', '20', 1, 1); +INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VENTES', 'Income of products/services', 'Example: 7xxxxx', 0, 0, '', '10', 1, 1); +INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'DEPENSES', 'Expenses of products/services', 'Example: 6xxxxx', 0, 0, '', '20', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 3, 'PROFIT', 'Balance', '', 0, 1, 'VENTES+DEPENSES', '30', 1, 1); From 68a8ef6e2d528523a4758bc18c30d820ad64a1ee Mon Sep 17 00:00:00 2001 From: Gitdyr Date: Sat, 9 Sep 2017 22:21:55 +0200 Subject: [PATCH 027/111] Fixed. --- htdocs/install/mysql/data/llx_accounting.sql | 181 +++++++++---------- 1 file changed, 90 insertions(+), 91 deletions(-) diff --git a/htdocs/install/mysql/data/llx_accounting.sql b/htdocs/install/mysql/data/llx_accounting.sql index bf973656661..4d2ddce37bc 100644 --- a/htdocs/install/mysql/data/llx_accounting.sql +++ b/htdocs/install/mysql/data/llx_accounting.sql @@ -2216,94 +2216,93 @@ INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype INSERT INTO llx_accounting_system (rowid, pcg_version, label, active) VALUES (5,'DK-STD', 'Standardkontoplan fra SKAT', 1); -INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUE -(5082, 'DK-STD', 'Indtægter', 'XXXXXX', '1000', '0', 'Salg af varer/ydelser m. moms', 1), -(5083, 'DK-STD', 'Indtægter', '', '1010', '', 'Salg af varer EU', 1), -(5084, 'DK-STD', 'Indtægter', '', '1020', '', 'Salg af ydelser EU', 1), -(5085, 'DK-STD', 'Indtægter', '', '1030', '', 'Ej momspligtigt salg', 1), -(5086, 'DK-STD', 'Indtægter', '', '1040', '', 'Regulering igangværende arbejder', 1), -(5087, 'DK-STD', 'Omkostninger', '', '1100', '', 'Varekøb med moms', 1), -(5088, 'DK-STD', 'Omkostninger', '', '1110', '', 'Køb af varer EU', 1), -(5089, 'DK-STD', 'Omkostninger', '', '1120', '', 'Køb af ydelser EU', 1), -(5090, 'DK-STD', 'Omkostninger', '', '1130', '', 'Varelagerregulering', 1), -(5091, 'DK-STD', 'Omkostninger', '', '1140', '', 'Eget vareforbrug', 1), -(5092, 'DK-STD', 'Omkostninger', '', '1300', '', 'Repræsentation', 1), -(5093, 'DK-STD', 'Omkostninger', '', '1310', '', 'Annoncer/reklame', 1), -(5094, 'DK-STD', 'Omkostninger', '', '1320', '', 'Rejseudgifter', 1), -(5095, 'DK-STD', 'Omkostninger', '', '1330', '', 'Aviser og blade', 1), -(5096, 'DK-STD', 'Omkostninger', '', '1400', '', 'Brændstof', 1), -(5097, 'DK-STD', 'Omkostninger', '', '1410', '', 'Bilforsikring', 1), -(5098, 'DK-STD', 'Omkostninger', '', '1420', '', 'Vedligeholdelse', 1), -(5099, 'DK-STD', 'Omkostninger', '', '1430', '', 'Grøn ejerafgift mv.', 1), -(5100, 'DK-STD', 'Omkostninger', '', '1440', '', 'Leje og leasing', 1), -(5101, 'DK-STD', 'Omkostninger', '', '1450', '', 'Bilvask og pleje af bil', 1), -(5102, 'DK-STD', 'Omkostninger', '', '1460', '', 'Parkeringsudgifter', 1), -(5103, 'DK-STD', 'Omkostninger', '', '1470', '', 'Biludgifter efter statens takster', 1), -(5104, 'DK-STD', 'Omkostninger', '', '1480', '', 'Fri bil', 1), -(5105, 'DK-STD', 'Omkostninger', '', '1490', '', 'Privat andel af biludgifter', 1), -(5106, 'DK-STD', 'Omkostninger', '', '1600', '', 'Husleje uden forbrug', 1), -(5107, 'DK-STD', 'Omkostninger', '', '1610', '', 'Forbrugsudgifter (el, vand, gas og varme mv)', 1), -(5108, 'DK-STD', 'Omkostninger', '', '1620', '', 'Ejendomsskatter og forsikringer', 1), -(5109, 'DK-STD', 'Omkostninger', '', '1630', '', 'Vedligeholdelse af lokaler', 1), -(5110, 'DK-STD', 'Omkostninger', '', '1700', '', 'Kontorartikler og tryksager', 1), -(5111, 'DK-STD', 'Omkostninger', '', '1705', '', 'Telefon og internet', 1), -(5112, 'DK-STD', 'Omkostninger', '', '1710', '', 'Fri telefon privat andel', 1), -(5113, 'DK-STD', 'Omkostninger', '', '1715', '', 'Anskaffelse af småaktiver', 1), -(5114, 'DK-STD', 'Omkostninger', '', '1720', '', 'Arbejdstøj', 1), -(5115, 'DK-STD', 'Omkostninger', '', '1725', '', 'Rådgiverudgifter', 1), -(5116, 'DK-STD', 'Omkostninger', '', '1730', '', 'Porto og gebyrer', 1), -(5117, 'DK-STD', 'Omkostninger', '', '1735', '', 'Forsikringer', 1), -(5118, 'DK-STD', 'Omkostninger', '', '1740', '', 'Bøger og faglitteratur', 1), -(5119, 'DK-STD', 'Omkostninger', '', '1745', '', 'Konstaterede tab på debitorer', 1), -(5120, 'DK-STD', 'Omkostninger', '', '1750', '', 'Kassedifferencer', 1), -(5121, 'DK-STD', 'Afskrivninger', '', '2000', '', 'Afskrivning driftsmidler og inventar', 1), -(5122, 'DK-STD', 'Afskrivninger', '', '2010', '', 'Afskrivning blandede driftsmidler', 1), -(5123, 'DK-STD', 'Afskrivninger', '', '2020', '', 'Afskrivninger privat andel', 1), -(5124, 'DK-STD', 'Afskrivninger', '', '2030', '', 'Gevinst og tab ved salg af aktiver', 1), -(5125, 'DK-STD', 'Finansielle poster', '', '2400', '', 'Renteindtægter bank', 1), -(5126, 'DK-STD', 'Finansielle poster', '', '2410', '', 'Renteindtægter kunder', 1), -(5127, 'DK-STD', 'Finansielle poster', '', '2500', '', 'Renteudgifter bank og realkreditinstitut', 1), -(5128, 'DK-STD', 'Finansielle poster', '', '2510', '', 'Renteudgifter leverandører', 1), -(5129, 'DK-STD', 'Finansielle poster', '', '2520', '', 'Fradragsberettigede låneomkostninger', 1), -(5130, 'DK-STD', 'Finansielle poster', '', '2530', '', 'Fradragsberettigede renteudgifter til det offentlige', 1), -(5131, 'DK-STD', 'Balance', '', '3000', '', 'Afskrivningsgrundlag primo', 1), -(5132, 'DK-STD', 'Balance', '', '3010', '', 'Årets køb', 1), -(5133, 'DK-STD', 'Balance', '', '3015', '', 'Årets forbedringer', 1), -(5134, 'DK-STD', 'Balance', '', '3020', '', 'Årest salg', 1), -(5135, 'DK-STD', 'Balance', '', '3030', '', 'Årets afskrivning', 1), -(5136, 'DK-STD', 'Balance', '', '3040', '', 'Gevinst og tab', 1), -(5137, 'DK-STD', 'Balance', '', '3100', '', 'Afskrivningsgrundlag primo', 1), -(5138, 'DK-STD', 'Balance', '', '3110', '', 'Årets køb', 1), -(5139, 'DK-STD', 'Balance', '', '3115', '', 'Årets forbedringer', 1), -(5140, 'DK-STD', 'Balance', '', '3120', '', 'Årets salg', 1), -(5141, 'DK-STD', 'Balance', '', '3130', '', 'Årets afskrivning', 1), -(5142, 'DK-STD', 'Balance', '', '3140', '', 'Gevinst og tab', 1), -(5143, 'DK-STD', 'Balance', '', '3900', '', 'Huslejedepositum', 1), -(5144, 'DK-STD', 'Balance', '', '4000', '', 'Kasse', 1), -(5145, 'DK-STD', 'Balance', '', '4010', '', 'Bank', 1), -(5146, 'DK-STD', 'Balance', '', '4020', '', 'Forudbetalte omkostninger', 1), -(5147, 'DK-STD', 'Balance', '', '4030', '', 'Debitorer', 1), -(5148, 'DK-STD', 'Balance', '', '4040', '', 'Varelager', 1), -(5149, 'DK-STD', 'Balance', '', '4050', '', 'Igangværende arbejder', 1), -(5150, 'DK-STD', 'Balance', '', '5000', '', 'Egenkapital primo', 1), -(5151, 'DK-STD', 'Balance', '', '5010', '', 'Årets resultat', 1), -(5152, 'DK-STD', 'Balance', '', '5020', '', 'Privat hævet', 1), -(5153, 'DK-STD', 'Balance', '', '5030', '', 'Fri bil', 1), -(5154, 'DK-STD', 'Balance', '', '5040', '', 'Statens takster', 1), -(5155, 'DK-STD', 'Balance', '', '5050', '', 'Fri telefon m.v.', 1), -(5156, 'DK-STD', 'Balance', '', '5060', '', 'Private andele', 1), -(5157, 'DK-STD', 'Balance', '', '5065', '', 'Private afskrivninger', 1), -(5158, 'DK-STD', 'Balance', '', '5070', '', 'Driftsudgifter u/fradrag', 1), -(5159, 'DK-STD', 'Balance', '', '5080', '', 'Privat udlæg', 1), -(5160, 'DK-STD', 'Balance', '', '5090', '', 'Indskud', 1), -(5161, 'DK-STD', 'Balance', '', '7000', '', 'Gæld bank og realkreditinstitut', 1), -(5162, 'DK-STD', 'Balance', '', '7010', '', 'Gæld til leverandører af varer og tjenesteydelser', 1), -(5163, 'DK-STD', 'Balance', '', '7020', '', 'Periodeafgrænsningsposter', 1), -(5164, 'DK-STD', 'Balance', '', '7030', '', 'Anden gæld', 1), -(5165, 'DK-STD', 'Balance', '', '8000', '', 'Salgsmoms', 1), -(5166, 'DK-STD', 'Balance', '', '8010', '', 'Købsmoms', 1), -(5167, 'DK-STD', 'Balance', '', '8020', '', 'Konto for afgift af varekøb i EU', 1), -(5168, 'DK-STD', 'Balance', '', '8030', '', 'Konto for afgift af købte ydelser i EU', 1), -(5169, 'DK-STD', 'Balance', '', '8040', '', 'El- afgift', 1), -(5170, 'DK-STD', 'Balance', '', '8050', '', 'Øvrige energiafgifter', 1), -(5171, 'DK-STD', 'Balance', '', '8060', '', 'Betalt moms', 1) +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5082, 'DK-STD', 'Indtægter', '', '1000', '', 'Salg af varer/ydelser m. moms', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5083, 'DK-STD', 'Indtægter', '', '1010', '', 'Salg af varer EU', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5084, 'DK-STD', 'Indtægter', '', '1020', '', 'Salg af ydelser EU', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5085, 'DK-STD', 'Indtægter', '', '1030', '', 'Ej momspligtigt salg', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5086, 'DK-STD', 'Indtægter', '', '1040', '', 'Regulering igangværende arbejder', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5087, 'DK-STD', 'Omkostninger', '', '1100', '', 'Varekøb med moms', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5088, 'DK-STD', 'Omkostninger', '', '1110', '', 'Køb af varer EU', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5089, 'DK-STD', 'Omkostninger', '', '1120', '', 'Køb af ydelser EU', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5090, 'DK-STD', 'Omkostninger', '', '1130', '', 'Varelagerregulering', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5091, 'DK-STD', 'Omkostninger', '', '1140', '', 'Eget vareforbrug', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5092, 'DK-STD', 'Omkostninger', '', '1300', '', 'Repræsentation', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5093, 'DK-STD', 'Omkostninger', '', '1310', '', 'Annoncer/reklame', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5094, 'DK-STD', 'Omkostninger', '', '1320', '', 'Rejseudgifter', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5095, 'DK-STD', 'Omkostninger', '', '1330', '', 'Aviser og blade', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5096, 'DK-STD', 'Omkostninger', '', '1400', '', 'Brændstof', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5097, 'DK-STD', 'Omkostninger', '', '1410', '', 'Bilforsikring', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5098, 'DK-STD', 'Omkostninger', '', '1420', '', 'Vedligeholdelse', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5099, 'DK-STD', 'Omkostninger', '', '1430', '', 'Grøn ejerafgift mv.', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5100, 'DK-STD', 'Omkostninger', '', '1440', '', 'Leje og leasing', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5101, 'DK-STD', 'Omkostninger', '', '1450', '', 'Bilvask og pleje af bil', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5102, 'DK-STD', 'Omkostninger', '', '1460', '', 'Parkeringsudgifter', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5103, 'DK-STD', 'Omkostninger', '', '1470', '', 'Biludgifter efter statens takster', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5104, 'DK-STD', 'Omkostninger', '', '1480', '', 'Fri bil', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5105, 'DK-STD', 'Omkostninger', '', '1490', '', 'Privat andel af biludgifter', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5106, 'DK-STD', 'Omkostninger', '', '1600', '', 'Husleje uden forbrug', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5107, 'DK-STD', 'Omkostninger', '', '1610', '', 'Forbrugsudgifter (el, vand, gas og varme mv)', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5108, 'DK-STD', 'Omkostninger', '', '1620', '', 'Ejendomsskatter og forsikringer', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5109, 'DK-STD', 'Omkostninger', '', '1630', '', 'Vedligeholdelse af lokaler', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5110, 'DK-STD', 'Omkostninger', '', '1700', '', 'Kontorartikler og tryksager', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5111, 'DK-STD', 'Omkostninger', '', '1705', '', 'Telefon og internet', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5112, 'DK-STD', 'Omkostninger', '', '1710', '', 'Fri telefon privat andel', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5113, 'DK-STD', 'Omkostninger', '', '1715', '', 'Anskaffelse af småaktiver', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5114, 'DK-STD', 'Omkostninger', '', '1720', '', 'Arbejdstøj', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5115, 'DK-STD', 'Omkostninger', '', '1725', '', 'Rådgiverudgifter', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5116, 'DK-STD', 'Omkostninger', '', '1730', '', 'Porto og gebyrer', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5117, 'DK-STD', 'Omkostninger', '', '1735', '', 'Forsikringer', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5118, 'DK-STD', 'Omkostninger', '', '1740', '', 'Bøger og faglitteratur', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5119, 'DK-STD', 'Omkostninger', '', '1745', '', 'Konstaterede tab på debitorer', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5120, 'DK-STD', 'Omkostninger', '', '1750', '', 'Kassedifferencer', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5121, 'DK-STD', 'Afskrivninger', '', '2000', '', 'Afskrivning driftsmidler og inventar', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5122, 'DK-STD', 'Afskrivninger', '', '2010', '', 'Afskrivning blandede driftsmidler', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5123, 'DK-STD', 'Afskrivninger', '', '2020', '', 'Afskrivninger privat andel', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5124, 'DK-STD', 'Afskrivninger', '', '2030', '', 'Gevinst og tab ved salg af aktiver', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5125, 'DK-STD', 'Finansielle poster', '', '2400', '', 'Renteindtægter bank', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5126, 'DK-STD', 'Finansielle poster', '', '2410', '', 'Renteindtægter kunder', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5127, 'DK-STD', 'Finansielle poster', '', '2500', '', 'Renteudgifter bank og realkreditinstitut', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5128, 'DK-STD', 'Finansielle poster', '', '2510', '', 'Renteudgifter leverandører', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5129, 'DK-STD', 'Finansielle poster', '', '2520', '', 'Fradragsberettigede låneomkostninger', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5130, 'DK-STD', 'Finansielle poster', '', '2530', '', 'Fradragsberettigede renteudgifter til det offentlige', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5131, 'DK-STD', 'Balance', '', '3000', '', 'Afskrivningsgrundlag primo', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5132, 'DK-STD', 'Balance', '', '3010', '', 'Årets køb', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5133, 'DK-STD', 'Balance', '', '3015', '', 'Årets forbedringer', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5134, 'DK-STD', 'Balance', '', '3020', '', 'Årest salg', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5135, 'DK-STD', 'Balance', '', '3030', '', 'Årets afskrivning', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5136, 'DK-STD', 'Balance', '', '3040', '', 'Gevinst og tab', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5137, 'DK-STD', 'Balance', '', '3100', '', 'Afskrivningsgrundlag primo', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5138, 'DK-STD', 'Balance', '', '3110', '', 'Årets køb', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5139, 'DK-STD', 'Balance', '', '3115', '', 'Årets forbedringer', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5140, 'DK-STD', 'Balance', '', '3120', '', 'Årets salg', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5141, 'DK-STD', 'Balance', '', '3130', '', 'Årets afskrivning', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5142, 'DK-STD', 'Balance', '', '3140', '', 'Gevinst og tab', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5143, 'DK-STD', 'Balance', '', '3900', '', 'Huslejedepositum', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5144, 'DK-STD', 'Balance', '', '4000', '', 'Kasse', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5145, 'DK-STD', 'Balance', '', '4010', '', 'Bank', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5146, 'DK-STD', 'Balance', '', '4020', '', 'Forudbetalte omkostninger', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5147, 'DK-STD', 'Balance', '', '4030', '', 'Debitorer', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5148, 'DK-STD', 'Balance', '', '4040', '', 'Varelager', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5149, 'DK-STD', 'Balance', '', '4050', '', 'Igangværende arbejder', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5150, 'DK-STD', 'Balance', '', '5000', '', 'Egenkapital primo', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5151, 'DK-STD', 'Balance', '', '5010', '', 'Årets resultat', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5152, 'DK-STD', 'Balance', '', '5020', '', 'Privat hævet', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5153, 'DK-STD', 'Balance', '', '5030', '', 'Fri bil', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5154, 'DK-STD', 'Balance', '', '5040', '', 'Statens takster', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5155, 'DK-STD', 'Balance', '', '5050', '', 'Fri telefon m.v.', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5156, 'DK-STD', 'Balance', '', '5060', '', 'Private andele', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5157, 'DK-STD', 'Balance', '', '5065', '', 'Private afskrivninger', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5158, 'DK-STD', 'Balance', '', '5070', '', 'Driftsudgifter u/fradrag', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5159, 'DK-STD', 'Balance', '', '5080', '', 'Privat udlæg', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5160, 'DK-STD', 'Balance', '', '5090', '', 'Indskud', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5161, 'DK-STD', 'Balance', '', '7000', '', 'Gæld bank og realkreditinstitut', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5162, 'DK-STD', 'Balance', '', '7010', '', 'Gæld til leverandører af varer og tjenesteydelser', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5163, 'DK-STD', 'Balance', '', '7020', '', 'Periodeafgrænsningsposter', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5164, 'DK-STD', 'Balance', '', '7030', '', 'Anden gæld', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5165, 'DK-STD', 'Balance', '', '8000', '', 'Salgsmoms', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5166, 'DK-STD', 'Balance', '', '8010', '', 'Købsmoms', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5167, 'DK-STD', 'Balance', '', '8020', '', 'Konto for afgift af varekøb i EU', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5168, 'DK-STD', 'Balance', '', '8030', '', 'Konto for afgift af købte ydelser i EU', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5169, 'DK-STD', 'Balance', '', '8040', '', 'El- afgift', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5170, 'DK-STD', 'Balance', '', '8050', '', 'Øvrige energiafgifter', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (5171, 'DK-STD', 'Balance', '', '8060', '', 'Betalt moms', 1); From 7f8d791d39517085c2cb2ebef7213ef33752d376 Mon Sep 17 00:00:00 2001 From: Gitdyr Date: Sun, 10 Sep 2017 07:24:38 +0200 Subject: [PATCH 028/111] Revert "Remove processing by htmlentities()" This reverts commit e555233dc12c1a206ae41754df78f2086cbba110. --- htdocs/core/class/translate.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 180b4db0ba6..169aec16307 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -620,6 +620,15 @@ class Translate if ($maxsize) $str=dol_trunc($str,$maxsize); + // We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities + $str=str_replace(array('<','>','"',),array('__lt__','__gt__','__quot__'),$str); + + // Crypt string into HTML + $str=htmlentities($str,ENT_QUOTES,$this->charset_output); + + // Restore HTML tags + $str=str_replace(array('__lt__','__gt__','__quot__'),array('<','>','"',),$str); + return $str; } else // Translation is not available From c315ad78010c9289a19ee9b37d90554947fdf6ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Sep 2017 18:01:20 +0200 Subject: [PATCH 029/111] Fix missing tables into childtables --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2bd764c92ed..523ab31c8f9 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -43,7 +43,7 @@ class Societe extends CommonObject public $element='societe'; public $table_element = 'societe'; public $fk_element='fk_soc'; - protected $childtables=array("supplier_proposal","propal","commande","facture","contrat","facture_fourn","commande_fournisseur","projet","expedition"); // To test if we can delete object + protected $childtables=array("supplier_proposal","propal","commande","facture","facture_rec","contrat","fichinter","facture_fourn","commande_fournisseur","projet","expedition","prelevement_lignes"); // To test if we can delete object /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe From d13c4b7b84cfbe2a1e3f6b834ce16f978e5f8033 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 00:19:42 +0200 Subject: [PATCH 030/111] Better autosize of extrafields --- htdocs/core/class/extrafields.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index e2e036c3700..6a7659cd925 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -770,24 +770,24 @@ class ExtraFields if (empty($showsize)) { - if ($type == 'date') + if ($type == 'date') { //$showsize=10; $showsize = 'minwidth100imp'; } - elseif ($type == 'datetime') + elseif ($type == 'datetime') { //$showsize=19; $showsize = 'minwidth200imp'; } - elseif (in_array($type,array('int','double'))) + elseif (in_array($type,array('int','double','price'))) { //$showsize=10; - $showsize = 'minwidth100imp'; + $showsize = 'maxwidth75'; } elseif ($type == 'url') { - $showsize='minwidth400imp'; + $showsize='minwidth400'; } elseif ($type == 'boolean') { @@ -797,16 +797,16 @@ class ExtraFields { if (round($size) < 12) { - $showsize = 'minwidth100imp'; + $showsize = 'minwidth100'; } else if (round($size) <= 48) { - $showsize = 'minwidth200imp'; + $showsize = 'minwidth200'; } else { //$showsize=48; - $showsize = 'minwidth400imp'; + $showsize = 'minwidth400'; } } } From 26385fa10d66dd54e2c72a5f311546bad7b2c229 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 01:04:53 +0200 Subject: [PATCH 031/111] FIX Clean bad parameters when inserting line of template invoice Conflicts: htdocs/compta/facture/class/facture-rec.class.php --- .../facture/class/facture-rec.class.php | 172 +++++++++--------- 1 file changed, 89 insertions(+), 83 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 52fb375000c..cbeba2828e7 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** - * Classe de gestion des factures recurrentes/Modeles + * Class to manage invoice templates */ class FactureRec extends CommonInvoice { @@ -43,7 +43,7 @@ class FactureRec extends CommonInvoice public $table_element_line='facturedet_rec'; public $fk_element='fk_facture'; public $picto='bill'; - + var $entity; var $number; var $date; @@ -58,7 +58,10 @@ class FactureRec extends CommonInvoice var $date_when; var $nb_gen_done; var $nb_gen_max; - + + var $frequency; + var $unit_frequency; + var $rang; var $special_code; @@ -91,20 +94,20 @@ class FactureRec extends CommonInvoice // Clean parameters $this->titre=trim($this->titre); $this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice; - + // No frequency defined then no next date to execution - if (empty($this->frequency)) + if (empty($this->frequency)) { $this->frequency=0; $this->date_when=NULL; } - - + + $this->frequency=abs($this->frequency); $this->nb_gen_done=0; $this->nb_gen_max=empty($this->nb_gen_max)?0:$this->nb_gen_max; $this->auto_validate=empty($this->auto_validate)?0:$this->auto_validate; - + $this->db->begin(); // Charge facture modele @@ -197,7 +200,7 @@ class FactureRec extends CommonInvoice $error++; } } - + // Add object linked if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) { @@ -210,7 +213,7 @@ class FactureRec extends CommonInvoice $error++; } } - } + } if ($error) { @@ -268,7 +271,7 @@ class FactureRec extends CommonInvoice if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; */ - + $result = $this->db->query($sql); if ($result) { @@ -361,8 +364,8 @@ class FactureRec extends CommonInvoice { return $this->fetch_lines(); } - - + + /** * Recupere les lignes de factures predefinies dans this->lines * @@ -386,7 +389,7 @@ class FactureRec extends CommonInvoice $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= ' WHERE l.fk_facture = '.$this->id; $sql.= ' ORDER BY l.rang'; - + dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); if ($result) @@ -431,7 +434,7 @@ class FactureRec extends CommonInvoice $line->special_code = $objp->special_code; $line->fk_unit = $objp->fk_unit; $line->fk_contract_line = $objp->fk_contract_line; - + // Ne plus utiliser $line->price = $objp->price; $line->remise = $objp->remise; @@ -463,12 +466,12 @@ class FactureRec extends CommonInvoice function delete($user, $notrigger=0, $idwarehouse=-1) { $rowid=$this->id; - + dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); - + $error=0; $this->db->begin(); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; dol_syslog($sql); if ($this->db->query($sql)) @@ -481,7 +484,7 @@ class FactureRec extends CommonInvoice $res = $this->deleteObjectLinked(); if ($res < 0) $error=-3; } - else + else { $this->error=$this->db->lasterror(); $error=-1; @@ -492,7 +495,7 @@ class FactureRec extends CommonInvoice $this->error=$this->db->lasterror(); $error=-2; } - + if (! $error) { $this->db->commit(); @@ -531,7 +534,7 @@ class FactureRec extends CommonInvoice function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; - + $facid=$this->id; dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); @@ -557,11 +560,14 @@ class FactureRec extends CommonInvoice if (empty($remise_percent)) $remise_percent=0; $qty=price2num($qty); if (! $info_bits) $info_bits=0; - $pu_ht=price2num($pu_ht); - $pu_ttc=price2num($pu_ttc); - $txtva=price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); + $pu_ht = price2num($pu_ht); + $pu_ttc = price2num($pu_ttc); + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); + if (empty($txtva)) $txtva=0; + if (empty($txlocaltax1)) $txlocaltax1=0; + if (empty($txlocaltax2)) $txlocaltax2=0; if ($price_base_type=='HT') { @@ -584,7 +590,7 @@ class FactureRec extends CommonInvoice $total_ttc = $tabprice[2]; $total_localtax1=$tabprice[9]; $total_localtax2=$tabprice[10]; - + $product_type=$type; if ($fk_product) { @@ -685,12 +691,12 @@ class FactureRec extends CommonInvoice function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; - + $facid=$this->id; - + dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - + // Check parameters if ($type < 0) return -1; @@ -715,7 +721,7 @@ class FactureRec extends CommonInvoice $txtva=price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - + if ($price_base_type=='HT') { $pu=$pu_ht; @@ -724,7 +730,7 @@ class FactureRec extends CommonInvoice { $pu=$pu_ttc; } - + // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker @@ -736,7 +742,7 @@ class FactureRec extends CommonInvoice $total_ttc = $tabprice[2]; $total_localtax1=$tabprice[9]; $total_localtax2=$tabprice[10]; - + $product_type=$type; if ($fk_product) { @@ -744,7 +750,7 @@ class FactureRec extends CommonInvoice $result=$product->fetch($fk_product); $product_type=$product->type; } - + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; $sql.= "fk_facture = '".$facid."'"; $sql.= ", label=".(! empty($label)?"'".$this->db->escape($label)."'":"null"); @@ -784,12 +790,12 @@ class FactureRec extends CommonInvoice return -1; } } - } - - + } + + /** - * Return the next date of - * + * Return the next date of + * * @return timestamp false if KO, timestamp if OK */ function getNextDate() @@ -797,27 +803,27 @@ class FactureRec extends CommonInvoice if (empty($this->date_when)) return false; return dol_time_plus_duree($this->date_when, $this->frequency, $this->unit_frequency); } - + /** * Create all recurrents invoices (for all entities if multicompany is used). * A result may also be provided into this->output. - * - * WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found. - * - * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) + * + * WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found. + * + * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ function createRecurringInvoices() { global $conf, $langs, $db, $user; - + $langs->load("bills"); - + $nb_create=0; - + $now = dol_now(); $tmparray=dol_getdate($now); $today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day - + dol_syslog("createRecurringInvoices"); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec'; $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency @@ -825,30 +831,30 @@ class FactureRec extends CommonInvoice $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; $sql.= $db->order('entity', 'ASC'); //print $sql;exit; - + $resql = $db->query($sql); if ($resql) { $i=0; $num = $db->num_rows($resql); - + if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; else $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); - + $saventity = $conf->entity; - + while ($i < $num) // Loop on each template invoice { $line = $db->fetch_object($resql); $db->begin(); - + $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); - + // Set entity context $conf->entity = $facturerec->entity; - + dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); $error=0; @@ -856,12 +862,12 @@ class FactureRec extends CommonInvoice $facture = new Facture($db); $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice - + $facture->type = self::TYPE_STANDARD; $facture->brouillon = 1; $facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; - + $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) { @@ -894,16 +900,16 @@ class FactureRec extends CommonInvoice $i++; } - + $conf->entity = $saventity; // Restore entity context } else dol_print_error($db); - + $this->output=trim($this->output); - + return $error?$error:0; } - + /** * Return clicable name (with picto eventually) * @@ -920,13 +926,13 @@ class FactureRec extends CommonInvoice $result=''; $label=$langs->trans("ShowInvoice").': '.$this->ref; - + $url = DOL_URL_ROOT.'/compta/facture/fiche-rec.php?facid='.$this->id; - + if ($short) return $url; - + $picto='bill'; - + $link = ''; $linkend=''; @@ -958,7 +964,7 @@ class FactureRec extends CommonInvoice // Load array of products prodids $num_prods = 0; $prodids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE entity IN (".getEntity('product').")"; @@ -1071,7 +1077,7 @@ class FactureRec extends CommonInvoice $this->lines[$xnbp]=$line; $xnbp++; } - + $this->usenewprice = 1; } @@ -1091,7 +1097,7 @@ class FactureRec extends CommonInvoice return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - + /** * Update frequency and unit * @@ -1115,12 +1121,12 @@ class FactureRec extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET frequency = '.($frequency?$this->db->escape($frequency):'null'); - if (!empty($unit)) + if (!empty($unit)) { $sql.= ', unit_frequency = \''.$this->db->escape($unit).'\''; } $sql.= ' WHERE rowid = '.$this->id; - + dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); if ($this->db->query($sql)) { @@ -1134,7 +1140,7 @@ class FactureRec extends CommonInvoice return -1; } } - + /** * Update the next date of execution * @@ -1167,7 +1173,7 @@ class FactureRec extends CommonInvoice return -1; } } - + /** * Update the maximum period * @@ -1181,9 +1187,9 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined",LOG_ERR); return -1; } - + if (empty($nb)) $nb=0; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET nb_gen_max = '.$nb; $sql.= ' WHERE rowid = '.$this->id; @@ -1200,7 +1206,7 @@ class FactureRec extends CommonInvoice return -1; } } - + /** * Update the auto validate invoice * @@ -1214,7 +1220,7 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined",LOG_ERR); return -1; } - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET auto_validate = '.$validate; $sql.= ' WHERE rowid = '.$this->id; @@ -1241,7 +1247,7 @@ class FactureRec extends CommonInvoice */ class FactureLigneRec extends CommonInvoiceLine { - + /** * Delete line in database * @@ -1250,11 +1256,11 @@ class FactureLigneRec extends CommonInvoiceLine function delete() { global $conf,$langs,$user; - + $error=0; - + $this->db->begin(); - + // Call trigger /*$result=$this->call_trigger('LINEBILLREC_DELETE',$user); if ($result < 0) @@ -1263,8 +1269,8 @@ class FactureLigneRec extends CommonInvoiceLine return -1; }*/ // End call triggers - - + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE rowid = ".($this->rowid > 0 ? $this->rowid : $this->id); dol_syslog(get_class($this)."::delete", LOG_DEBUG); if ($this->db->query($sql) ) @@ -1279,5 +1285,5 @@ class FactureLigneRec extends CommonInvoiceLine return -1; } } - + } From e9e6a8e5ad325c5ffc38685b8fe1953398441c95 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 03:29:36 +0200 Subject: [PATCH 032/111] Fix center of button --- htdocs/admin/dict.php | 2 +- htdocs/core/tpl/contacts.tpl.php | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 40068ec81e8..52e90b21956 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1119,7 +1119,7 @@ if ($id) } if ($id == 4) print ''; - print ''; // Relative and absolute discounts diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 41c5d67688c..443534eb1b3 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -64,7 +64,7 @@ class DiscountAbsolute * @param int $fk_facture_source fk_facture_source * @return int <0 if KO, =0 if not found, >0 if OK */ - function fetch($rowid,$fk_facture_source=0) + function fetch($rowid, $fk_facture_source=0) { global $conf; @@ -386,7 +386,7 @@ class DiscountAbsolute function getSumDepositsUsed($invoice, $multicurrency=0) { dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); - + if ($invoice->element == 'facture' || $invoice->element == 'invoice') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; @@ -407,7 +407,7 @@ class DiscountAbsolute dol_print_error($this->error); return -1; } - + $resql=$this->db->query($sql); if ($resql) { @@ -432,7 +432,7 @@ class DiscountAbsolute function getSumCreditNotesUsed($invoice, $multicurrency=0) { dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); - + if ($invoice->element == 'facture' || $invoice->element == 'invoice') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; @@ -453,7 +453,7 @@ class DiscountAbsolute dol_print_error($this->error); return -1; } - + $resql=$this->db->query($sql); if ($resql) { From f0f6df4c903122fa729638bba2df8358bdadb508 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 15:23:49 +0200 Subject: [PATCH 047/111] Fix tables declaration --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 8 ++++---- htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql | 2 +- htdocs/install/mysql/tables/llx_c_exp_tax_range.sql | 2 +- htdocs/install/mysql/tables/llx_expensereport_ik.sql | 2 +- htdocs/install/mysql/tables/llx_projet_task_comment.sql | 2 +- 5 files changed, 8 insertions(+), 8 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 d866369fedf..14b1e424469 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 @@ -98,14 +98,14 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik ( fk_range integer DEFAULT 0 NOT NULL, coef double DEFAULT 0 NOT NULL, offset double DEFAULT 0 NOT NULL -)ENGINE=innodb DEFAULT CHARSET=utf8; +)ENGINE=innodb; CREATE TABLE IF NOT EXISTS llx_c_exp_tax_cat ( rowid integer AUTO_INCREMENT PRIMARY KEY, label varchar(48) NOT NULL, entity integer DEFAULT 1 NOT NULL, active integer DEFAULT 1 NOT NULL -)ENGINE=innodb DEFAULT CHARSET=utf8; +)ENGINE=innodb; CREATE TABLE IF NOT EXISTS llx_c_exp_tax_range ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -113,7 +113,7 @@ CREATE TABLE IF NOT EXISTS llx_c_exp_tax_range ( range_ik double DEFAULT 0 NOT NULL, entity integer DEFAULT 1 NOT NULL, active integer DEFAULT 1 NOT NULL -)ENGINE=innodb DEFAULT CHARSET=utf8; +)ENGINE=innodb; INSERT INTO llx_c_type_fees (code, label, active, accountancy_code) VALUES ('EX_KME', 'ExpLabelKm', 1, '625100'), @@ -258,7 +258,7 @@ CREATE TABLE llx_projet_task_comment ( fk_task integer DEFAULT NULL, entity integer DEFAULT 1, import_key varchar(125) DEFAULT NULL -); +)ENGINE=innodb; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; diff --git a/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql b/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql index 9caea48ca21..e7227b2a2e9 100644 --- a/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql +++ b/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql @@ -23,4 +23,4 @@ CREATE TABLE IF NOT EXISTS llx_c_exp_tax_cat ( label varchar(48) NOT NULL, entity integer DEFAULT 1 NOT NULL, active integer DEFAULT 1 NOT NULL -)ENGINE=innodb DEFAULT CHARSET=utf8; \ No newline at end of file +)ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql b/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql index 4b60557851a..f108549eb45 100644 --- a/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql +++ b/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql @@ -24,4 +24,4 @@ CREATE TABLE IF NOT EXISTS llx_c_exp_tax_range ( range_ik double DEFAULT 0 NOT NULL, entity integer DEFAULT 1 NOT NULL, active integer DEFAULT 1 NOT NULL -)ENGINE=innodb DEFAULT CHARSET=utf8; +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_expensereport_ik.sql b/htdocs/install/mysql/tables/llx_expensereport_ik.sql index 13f1a8067d6..8debb56921c 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_ik.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_ik.sql @@ -26,4 +26,4 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik ( fk_range integer DEFAULT 0 NOT NULL, coef double DEFAULT 0 NOT NULL, offset double DEFAULT 0 NOT NULL -)ENGINE=innodb DEFAULT CHARSET=utf8; \ No newline at end of file +)ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_projet_task_comment.sql b/htdocs/install/mysql/tables/llx_projet_task_comment.sql index 42fe572958a..561f8276455 100644 --- a/htdocs/install/mysql/tables/llx_projet_task_comment.sql +++ b/htdocs/install/mysql/tables/llx_projet_task_comment.sql @@ -25,4 +25,4 @@ CREATE TABLE llx_projet_task_comment ( fk_task integer DEFAULT NULL, entity integer DEFAULT 1, import_key varchar(125) DEFAULT NULL -); +) ENGINE=innodb; From 8cb9e8c2da98cc65a2de0e3c650388c48c737792 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 16:26:01 +0200 Subject: [PATCH 048/111] Add $object into hooks --- htdocs/modulebuilder/template/myobject_list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 97b7421a001..e034fae2cf6 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -147,7 +147,7 @@ if (GETPOST('cancel')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } $parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -208,7 +208,7 @@ foreach($object->fields as $key => $val) foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); $sql.= " FROM ".MAIN_DB_PREFIX."myobject as t"; @@ -236,7 +236,7 @@ foreach ($search_array_options as $key => $val) } // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.=$db->order($sortfield,$sortorder); @@ -341,7 +341,7 @@ $moreforfilter.= $langs->trans('MyFilter') . ': Date: Mon, 11 Sep 2017 16:31:44 +0200 Subject: [PATCH 049/111] Save space --- htdocs/public/onlinesign/newonlinesign.php | 4 ++-- htdocs/public/paybox/newpayment.php | 4 ++-- htdocs/public/payment/newpayment.php | 4 ++-- htdocs/public/paypal/newpayment.php | 4 ++-- htdocs/public/stripe/newpayment.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index dc81934dd95..63617076a1b 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -205,8 +205,8 @@ if (! empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) } if (empty($text)) { - $text.=''."\n"; - $text.=''."\n"; + $text.=''."\n"; + $text.=''."\n"; } print $text; diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 22d2e4ddc00..0d8e930c95c 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -243,8 +243,8 @@ if (! empty($conf->global->PAYMENT_NEWFORM_TEXT)) } if (empty($text)) { - $text.=''."\n"; - $text.=''."\n"; + $text.=''."\n"; + $text.=''."\n"; } print $text; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 620ac797818..1bf86f9ffbc 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -594,8 +594,8 @@ if (! empty($conf->global->PAYMENT_NEWFORM_TEXT)) } if (empty($text)) { - $text.=''."\n"; - $text.=''."\n"; + $text.=''."\n"; + $text.=''."\n"; } print $text; diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index efbe9b1b682..310f553269b 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -348,8 +348,8 @@ if (! empty($conf->global->PAYMENT_NEWFORM_TEXT)) } if (empty($text)) { - $text.=''."\n"; - $text.=''."\n"; + $text.=''."\n"; + $text.=''."\n"; } print $text; diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index e12cb194c4d..f74e7bd0295 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -411,8 +411,8 @@ if (! empty($conf->global->PAYMENT_NEWFORM_TEXT)) } if (empty($text)) { - $text.=''."\n"; - $text.=''."\n"; + $text.=''."\n"; + $text.=''."\n"; } print $text; From adc78296aa7eae9745cfa90b089a067b23b08995 Mon Sep 17 00:00:00 2001 From: arnaud Date: Mon, 11 Sep 2017 16:56:50 +0200 Subject: [PATCH 050/111] FIX time.php crashed without project id in param --- htdocs/projet/tasks/time.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 74ec47549a2..72ad74df871 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -442,7 +442,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; $morehtmlref=''; - + // Project if (empty($withproject)) { @@ -450,10 +450,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); $morehtmlref.='
'; - + // Third party - $morehtmlref.=$langs->trans("ThirdParty").': '; - $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + $morehtmlref.=$langs->trans("ThirdParty").': '; + if (!empty($projectstatic->thirdparty)) { + $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + } $morehtmlref.=''; } From fcf82f116386c8658b5d8f2473ce7852282b3140 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 11:17:23 +0200 Subject: [PATCH 051/111] Enhancement into setup of member module --- htdocs/adherents/admin/adherent.php | 36 +--- htdocs/adherents/admin/adherent_emails.php | 190 ++++++++++++++++++ .../admin/{public.php => website.php} | 164 ++++++++------- htdocs/core/db/mysqli.class.php | 3 + htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/lib/member.lib.php | 11 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/members.lang | 6 +- htdocs/public/members/new.php | 30 ++- htdocs/societe/class/societe.class.php | 23 ++- 10 files changed, 338 insertions(+), 128 deletions(-) create mode 100644 htdocs/adherents/admin/adherent_emails.php rename htdocs/adherents/admin/{public.php => website.php} (59%) diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 8050a0ec019..93b90c01c92 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -203,7 +203,7 @@ if ($conf->facture->enabled) print ''; } print "\n"; - + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { print '
'; @@ -263,40 +263,6 @@ $helptext.='%YEAR%, %MONTH%, %DAY%'; form_constantes($constantes, 0, $helptext); -print '
'; - - -/* - * Editing global variables not related to a specific theme - */ -$constantes=array( - 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT', - 'ADHERENT_AUTOREGISTER_NOTIF_MAIL', - 'ADHERENT_AUTOREGISTER_MAIL_SUBJECT', - 'ADHERENT_AUTOREGISTER_MAIL', - 'ADHERENT_MAIL_VALID_SUBJECT', - 'ADHERENT_MAIL_VALID', - 'ADHERENT_MAIL_COTIS_SUBJECT', - 'ADHERENT_MAIL_COTIS', - 'ADHERENT_MAIL_RESIL_SUBJECT', - 'ADHERENT_MAIL_RESIL', - 'ADHERENT_MAIL_FROM', - ); - -print load_fiche_titre($langs->trans("Other"),'',''); - -$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, '; -$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, '; -$helptext.='%YEAR%, %MONTH%, %DAY%'; - -$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, '; -$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, '; -//$helptext.='%YEAR%, %MONTH%, %DAY%'; // Not supported - -form_constantes($constantes, 0, $helptext); - dol_fiche_end(); diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php new file mode 100644 index 00000000000..a4c2f937146 --- /dev/null +++ b/htdocs/adherents/admin/adherent_emails.php @@ -0,0 +1,190 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2012 J. Fernando Lagrange + * Copyright (C) 2015 Jean-François Ferry + * + * 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/adherents/admin/adherent.php + * \ingroup member + * \brief Page to setup the module Foundation + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; + +$langs->load("admin"); +$langs->load("members"); + +if (! $user->admin) accessforbidden(); + + +$type=array('yesno','texte','chaine'); + +$action = GETPOST('action','alpha'); + + +/* + * Actions + */ + +// +if ($action == 'updateall') +{ + $db->begin(); + $res1=$res2=$res3=$res4=$res5=$res6=0; + $res1=dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); + $res2=dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); + $res3=dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); + $res4=dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); + // Use vat for invoice creation + if ($conf->facture->enabled) + { + $res4=dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + $res5=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + { + $res6=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + } + } + if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) + { + setEventMessages('ErrorFailedToSaveDate', null, 'errors'); + $db->rollback(); + } + else + { + setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); + $db->commit(); + } +} + +// Action mise a jour ou ajout d'une constante +if ($action == 'update' || $action == 'add') +{ + $constname=GETPOST('constname','alpha'); + $constvalue=(GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue')); + + if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE' || $constname=='ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue=''; + if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice + { + if ($constvalue) $constvalue=0; + else $constvalue=1; + } + + $consttype=GETPOST('consttype','alpha'); + $constnote=GETPOST('constnote'); + $res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +// Action activation d'un sous module du module adherent +if ($action == 'set') +{ + $result=dolibarr_set_const($db, GETPOST('name','alpha'),GETPOST('value'),'',0,'',$conf->entity); + if ($result < 0) + { + print $db->error(); + } +} + +// Action desactivation d'un sous module du module adherent +if ($action == 'unset') +{ + $result=dolibarr_del_const($db,GETPOST('name','alpha'),$conf->entity); + if ($result < 0) + { + print $db->error(); + } +} + + + +/* + * View + */ + +$form = new Form($db); + +$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; + +llxHeader('',$langs->trans("MembersSetup"),$help_url); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("MembersSetup"),$linkback,'title_setup'); + + +$head = member_admin_prepare_head(); + +dol_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user'); + +print ''; +print ''; +print ''; + +/* + * Editing global variables not related to a specific theme + */ +$constantes=array( + 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT', + 'ADHERENT_AUTOREGISTER_NOTIF_MAIL', + 'ADHERENT_AUTOREGISTER_MAIL_SUBJECT', + 'ADHERENT_AUTOREGISTER_MAIL', + 'ADHERENT_MAIL_VALID_SUBJECT', + 'ADHERENT_MAIL_VALID', + 'ADHERENT_MAIL_COTIS_SUBJECT', + 'ADHERENT_MAIL_COTIS', + 'ADHERENT_MAIL_RESIL_SUBJECT', + 'ADHERENT_MAIL_RESIL', + 'ADHERENT_MAIL_FROM', + ); + +$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; +$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, '; +$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, '; +$helptext.='%YEAR%, %MONTH%, %DAY%'; + +$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; +$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, '; +$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, '; +//$helptext.='%YEAR%, %MONTH%, %DAY%'; // Not supported + +form_constantes($constantes, 0, $helptext); + +dol_fiche_end(); + + +llxFooter(); + +$db->close(); diff --git a/htdocs/adherents/admin/public.php b/htdocs/adherents/admin/website.php similarity index 59% rename from htdocs/adherents/admin/public.php rename to htdocs/adherents/admin/website.php index 940c6c6e457..59a80c1ef67 100644 --- a/htdocs/adherents/admin/public.php +++ b/htdocs/adherents/admin/website.php @@ -43,6 +43,12 @@ if (! $user->admin) accessforbidden(); * Actions */ +if ($action == 'setMEMBER_ENABLE_PUBLIC') +{ + if (GETPOST('value')) dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity); + else dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity); +} + if ($action == 'update') { $public=GETPOST('MEMBER_ENABLE_PUBLIC'); @@ -94,7 +100,7 @@ print ''; print ''; print ''; -dol_fiche_head($head, 'public', $langs->trans("Members"), -1, 'user'); +dol_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user'); if ($conf->use_javascript_ajax) { @@ -135,99 +141,109 @@ if ($conf->use_javascript_ajax) print $langs->trans("BlankSubscriptionFormDesc").'

'; -print '
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[13]) . '
' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . price($row[13]) . '
" . $date . "" . $ref . "" . $langs->trans("Bank") . " - " . $reflabel . "" . $langs->trans("Bank") . " - " . $val['soclib'] . ""; + //var_dump($tabpay[$key]); + print $langs->trans("Bank"); + print ' '.$val['bank_account_ref']; + if (! empty($val['soclib'])) { + print " - " . $val['soclib']; } + print "" . $val["type_payment"] . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $ref . ""; $account_ledger = $k; - + // Try to force general ledger account depending on type if ($tabtype[$key] == 'payment') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; if ($tabtype[$key] == 'payment_supplier') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; if ($tabtype[$key] == 'payment_expensereport') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; @@ -883,7 +926,11 @@ if (empty($action) || $action == 'view') { { if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + /*var_dump($tabpay[$key]); + var_dump($tabtype[$key]); + var_dump($tabbq[$key]);*/ + //print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown").''; } else print $accounttoshowsubledger; } @@ -898,8 +945,9 @@ if (empty($action) || $action == 'view') { } } else { foreach ( $tabbq[$key] as $k => $mt ) { + print ''; print '
" . $date . "" . $ref . "
'; - print ''.$langs->trans('Upgrade').': '; - print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated - print ""; - print "
\n"; - print '
'; + print ''.$langs->trans('Upgrade').': '; + print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated + print ""; + print "
\n"; + print '
'; + print ''; if ($action != 'edit') { print ''; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index d6defba0fa9..c7b3ea7342f 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -35,13 +35,13 @@ elseif ($module == 'project') { $permission=$user->rights->projet->creer; } elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; } elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; } elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; } -elseif (! isset($permission) && isset($user->rights->$module->creer)) -{ - $permission=$user->rights->$module->creer; +elseif (! isset($permission) && isset($user->rights->$module->creer)) +{ + $permission=$user->rights->$module->creer; } elseif (! isset($permission) && isset($user->rights->$module->write)) { - $permission=$user->rights->$module->write; + $permission=$user->rights->$module->write; } $formcompany= new FormCompany($db); @@ -55,8 +55,8 @@ $userstatic=new User($db);
-
trans("Nature"); ?>
@@ -72,7 +72,7 @@ if ($permission) { $var=true; if (empty($hideaddcontactforuser)) { - + ?> " /> @@ -87,10 +87,10 @@ if ($permission) { element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc; - echo $formcompany->selectTypeContact($tmpobject, '', 'type','internal'); + echo $formcompany->selectTypeContact($tmpobject, '', 'type','internal'); ?>
 
-
">
+
">
trans("ThirdPartyContacts"); ?>
socid; ?> - selectTypeContact($tmpobject, '', 'type','external'); ?>
 
-
+
">
-
From 214bad26dbf105408454e7d14ea5b49c41deb268 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 02:09:48 +0200 Subject: [PATCH 033/111] Try a fix for dol_time_plus_duree when date is 2017-09-01 00:00 and timezone > 0 --- htdocs/core/lib/date.lib.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 71912714b90..c45c5a88e29 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -115,26 +115,28 @@ function getServerTimeZoneInt($refgmtdate='now') */ function dol_time_plus_duree($time, $duration_value, $duration_unit) { + global $conf; + if ($duration_value == 0) return $time; if ($duration_unit == 'h') return $time + (3600*$duration_value); if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value); - + $deltastring='P'; - + if ($duration_value > 0){ $deltastring.=abs($duration_value); $sub= false; } if ($duration_value < 0){ $deltastring.=abs($duration_value); $sub= true; } if ($duration_unit == 'd') { $deltastring.="D"; } if ($duration_unit == 'm') { $deltastring.="M"; } if ($duration_unit == 'y') { $deltastring.="Y"; } - + $date = new DateTime(); - $date->setTimezone(new DateTimeZone('UTC')); + if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); $date->setTimestamp($time); $interval = new DateInterval($deltastring); - + if($sub) $date->sub($interval); else $date->add( $interval ); - + return $date->getTimestamp(); } From 61a0f04bbef681c1ba3709878801fe6ba73f3918 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 01:20:15 +0200 Subject: [PATCH 034/111] FIX dateSelector was not taken into account --- htdocs/core/tpl/objectline_create.tpl.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 97f50498fb0..b123a6e91c2 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -37,7 +37,9 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob $usemargins=1; } -global $dateSelector, $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax; +if (! isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine) +global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax; + if (! isset($dateSelector)) $dateSelector=1; // For backward compatibility elseif (empty($dateSelector)) $dateSelector=0; if (empty($forceall)) $forceall=0; From f8938f308d90532d6021297fe93103793b60e7c2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 11 Sep 2017 08:17:25 +0200 Subject: [PATCH 035/111] Fix: remove table prefix --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 2 +- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 2 insertions(+), 2 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 283981ad4a0..098677d96c7 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 @@ -63,7 +63,7 @@ ALTER TABLE llx_mailing MODIFY COLUMN langs varchar(64); ALTER TABLE llx_facture_fourn ADD COLUMN date_pointoftax date DEFAULT NULL; ALTER TABLE llx_facture_fourn ADD COLUMN date_valid date; -ALTER TABLE llx_bookmark DROP COLUM fk_soc; +ALTER TABLE llx_bookmark DROP COLUMN fk_soc; ALTER TABLE llx_website MODIFY COLUMN ref varchar(128); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8e210a01c6c..393f1af1a16 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -44,7 +44,7 @@ class Societe extends CommonObject public $table_element = 'societe'; public $fk_element='fk_soc'; protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object - protected $childtablesoncascade=array("llx_societe_prices", "llx_societe_log", "llx_societe_address", "llx_product_fournisseur_price", "llx_product_customer_price_log", "llx_product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "llx_categorie", "llx_notify", "llx_notfy_def"); + protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notfy_def"); /** From 7d42a58230f6c3f22372bf21d71d56f12ca31eaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 12:46:01 +0200 Subject: [PATCH 036/111] Fix no more fk_soc in this table --- htdocs/societe/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 2aa35625aa0..25526b79918 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -186,7 +186,6 @@ if (empty($reshook)) $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', 'Societe' => '/societe/class/societe.class.php', - 'Bookmark' => '/bookmarks/class/bookmark.class.php', 'Categorie' => '/categories/class/categorie.class.php', 'ActionComm' => '/comm/action/class/actioncomm.class.php', 'Propal' => '/comm/propal/class/propal.class.php', From 092b87bbda00ea514873784ec6c127fb120a96a3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 11 Sep 2017 13:36:03 +0200 Subject: [PATCH 037/111] Fix: add llx_actioncomm in $childtablesoncascade --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 393f1af1a16..161aec10d8f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -44,7 +44,7 @@ class Societe extends CommonObject public $table_element = 'societe'; public $fk_element='fk_soc'; protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object - protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notfy_def"); + protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notfy_def", "actioncomm"); /** From 59ab52c7182654ef9ea94ecf3fed6af4db3a0a27 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 13:39:03 +0200 Subject: [PATCH 038/111] FIX hidden option MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN --- htdocs/commande/card.php | 3 ++- htdocs/commande/class/commande.class.php | 3 ++- htdocs/compta/facture/card.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6d62f6c129a..03c91b69710 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -398,6 +398,7 @@ if (empty($reshook)) } // Now we create same links to contact than the ones found on origin object + /* Useless, already into the create if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { $originforcontact = $object->origin; @@ -420,7 +421,7 @@ if (empty($reshook)) } } else dol_print_error($resqlcontact); - } + }*/ // Hooks $parameters = array('objFrom' => $srcobject); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3262a563f4c..5785e73bac4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -920,7 +920,8 @@ class Commande extends CommonOrder foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; - $originidforcontact = $value->id; + if (is_object($value)) $originidforcontact = $value->id; + else $originidforcontact = $value; break; // We take first one } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 23b310fd9f7..248bc31737d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1299,6 +1299,7 @@ if (empty($reshook)) } // Now we create same links to contact than the ones found on origin object + /* Useless, already into the create if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { $originforcontact = $object->origin; @@ -1321,7 +1322,7 @@ if (empty($reshook)) } } else dol_print_error($resqlcontact); - } + }*/ // Hooks $parameters = array('objFrom' => $srcobject); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d05ad059577..572e59e737a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -498,7 +498,8 @@ class Facture extends CommonInvoice foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; - $originidforcontact = $value->id; + if (is_object($value)) $originidforcontact = $value->id; + else $originidforcontact = $value; break; // We take first one } } From b87ce172c35f389c27bbde5ae15a9eb60d811414 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 13:39:03 +0200 Subject: [PATCH 039/111] FIX hidden option MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN --- htdocs/commande/card.php | 3 ++- htdocs/commande/class/commande.class.php | 3 ++- htdocs/compta/facture/card.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ddb44153e49..b7e79def212 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -398,6 +398,7 @@ if (empty($reshook)) } // Now we create same links to contact than the ones found on origin object + /* Useless, already into the create if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { $originforcontact = $object->origin; @@ -420,7 +421,7 @@ if (empty($reshook)) } } else dol_print_error($resqlcontact); - } + }*/ // Hooks $parameters = array('objFrom' => $srcobject); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f9ebf8a4cde..235e3a1aa75 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -920,7 +920,8 @@ class Commande extends CommonOrder foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; - $originidforcontact = $value->id; + if (is_object($value)) $originidforcontact = $value->id; + else $originidforcontact = $value; break; // We take first one } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7adc13d3724..60f711688cc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1249,6 +1249,7 @@ if (empty($reshook)) } // Now we create same links to contact than the ones found on origin object + /* Useless, already into the create if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { $originforcontact = $object->origin; @@ -1271,7 +1272,7 @@ if (empty($reshook)) } } else dol_print_error($resqlcontact); - } + }*/ // Hooks $parameters = array('objFrom' => $srcobject); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b5a399675e7..1f8d17f0468 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -489,7 +489,8 @@ class Facture extends CommonInvoice foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; - $originidforcontact = $value->id; + if (is_object($value)) $originidforcontact = $value->id; + else $originidforcontact = $value; break; // We take first one } } From 646e8713f2187808875c4dfd3a7ac169e2a6dcce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 13:41:40 +0200 Subject: [PATCH 040/111] Remove duplicated logs --- htdocs/compta/facture/class/facture.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1f8d17f0468..3fa36602d39 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -430,7 +430,6 @@ class Facture extends CommonInvoice $sql.= ", ".(double) $this->multicurrency_tx; $sql.=")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -440,7 +439,6 @@ class Facture extends CommonInvoice $this->ref='(PROV'.$this->id.')'; $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $error++; @@ -749,12 +747,12 @@ class Facture extends CommonInvoice // Charge facture source $facture=new Facture($this->db); - + $this->fetch_optionals(); if(!empty($this->array_options)){ $facture->array_options = $this->array_options; } - + foreach($this->lines as &$line){ $line->fetch_optionals();//fetch extrafields } From dcc9cb4a165d88befaefc45d881e5b65b34d0a36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 14:29:27 +0200 Subject: [PATCH 041/111] Some fixes in various payment --- htdocs/core/class/html.formprojet.class.php | 3 +++ htdocs/install/mysql/tables/llx_payment_various.sql | 4 ++-- htdocs/projet/element.php | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 524bd82ddd1..798c4981eba 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -509,6 +509,9 @@ class FormProjets $sql = 'SELECT t.rowid, t.label as ref'; $projectkey='fk_origin'; break; + case "payment_various": + $sql = "SELECT t.rowid, t.num_payment as ref"; + break; case "chargesociales": default: $sql = "SELECT t.rowid, t.ref"; diff --git a/htdocs/install/mysql/tables/llx_payment_various.sql b/htdocs/install/mysql/tables/llx_payment_various.sql index e92b244b009..e719dae7d8c 100644 --- a/htdocs/install/mysql/tables/llx_payment_various.sql +++ b/htdocs/install/mysql/tables/llx_payment_various.sql @@ -19,6 +19,8 @@ create table llx_payment_various ( rowid integer AUTO_INCREMENT PRIMARY KEY, + num_payment varchar(50), -- ref + label varchar(255), tms timestamp, datec datetime, -- Create date datep date, -- date de paiement @@ -26,8 +28,6 @@ create table llx_payment_various sens smallint DEFAULT 0 NOT NULL,-- Sens of the operation: 0 for debit operation, 1 for credit operation amount double(24,8) DEFAULT 0 NOT NULL, fk_typepayment integer NOT NULL, - num_payment varchar(50), -- ref - label varchar(255), accountancy_code varchar(32), fk_projet integer DEFAULT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 0dcb710cfb5..1e4d4132944 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -448,7 +448,7 @@ $listofreferent=array( 'datefieldname'=>'datev', 'margin'=>'minus', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/compta/bank_various_payment/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&projectid='.$id.'&socid='.$socid, 'lang'=>'banks', 'buttonnew'=>'AddVariousPayment', 'testnew'=>$user->rights->banque->modifier, @@ -731,7 +731,7 @@ foreach ($listofreferent as $key => $value) if (! empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty.=','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; } - if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty) + if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, array('payment_various'))) { $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300'); if (! $selectList || ($selectList<0)) From 22b88181009d55d7fdd7c0efcdf3d4afd73ee954 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 14:41:46 +0200 Subject: [PATCH 042/111] FIX #7359 --- htdocs/fichinter/class/fichinter.class.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index eaf10c357e4..b9bb40bdd7a 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -559,9 +559,10 @@ class Fichinter extends CommonObject /** * Returns amount based on user thm * - * @return float amount + * @return float Amount */ - function getAmount() { + function getAmount() + { global $db; $amount = 0; @@ -571,13 +572,11 @@ class Fichinter extends CommonObject $thm = $this->author->thm; - foreach($this->lines as &$line) { - - $amount+=$line->qty * $thm; - + foreach($this->lines as $line) { + $amount += ($line->duration / 60 / 60 * $thm); } - return $amount; + return price2num($amount, 'MT'); } /** From 6da5a6b82fe2e3c85c9ea84498e0c638bac7f59d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 14:41:46 +0200 Subject: [PATCH 043/111] FIX #7359 Conflicts: htdocs/fichinter/class/fichinter.class.php --- htdocs/fichinter/class/fichinter.class.php | 41 +++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6142d87de7a..490cfde8c99 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -39,7 +39,7 @@ class Fichinter extends CommonObject public $fk_element='fk_fichinter'; public $table_element_line='fichinterdet'; public $picto = 'intervention'; - + /** * {@inheritdoc} */ @@ -361,7 +361,7 @@ class Fichinter extends CommonObject $this->fk_contrat = $obj->fk_contrat; $this->user_creation= $obj->fk_user_author; - + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; @@ -542,27 +542,26 @@ class Fichinter extends CommonObject /** * Returns amount based on user thm * - * @return float amount + * @return float Amount */ - function getAmount() { + function getAmount() + { global $db; - + $amount = 0; - + $this->author = new User($db); $this->author->fetch($this->user_creation); - + $thm = $this->author->thm; - - foreach($this->lines as &$line) { - - $amount+=$line->qty * $thm; - + + foreach($this->lines as $line) { + $amount += ($line->duration / 60 / 60 * $thm); } - - return $amount; + + return price2num($amount, 'MT'); } - + /** * Returns the label status * @@ -599,7 +598,7 @@ class Fichinter extends CommonObject return ''.$langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); if ($mode == 6) return ''.$langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); - + return ''; } @@ -949,7 +948,7 @@ class Fichinter extends CommonObject return -2; } - + /** * Load an object from its id and create a new one in database @@ -1001,7 +1000,7 @@ class Fichinter extends CommonObject $this->date_creation = ''; $this->date_validation = ''; $this->ref_client = ''; - + // Create clone $result=$this->create($user); if ($result < 0) $error++; @@ -1013,7 +1012,7 @@ class Fichinter extends CommonObject { $this->addline($user, $this->id, $line->desc, $line->datei, $line->duration); } - + // Hook of thirdparty module if (is_object($hookmanager)) { @@ -1043,8 +1042,8 @@ class Fichinter extends CommonObject return -1; } } - - + + /** * Adding a line of intervention into data base * From 2fdad0f11d6479b02b6c51eee21bf3558c427634 Mon Sep 17 00:00:00 2001 From: reeperbahnause Date: Sat, 9 Sep 2017 20:00:09 +0200 Subject: [PATCH 044/111] fix #7361 missing generateDocument function fix #7361 Function generateDocument was missing for Class Fichinter --- htdocs/fichinter/class/fichinter.class.php | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 490cfde8c99..90b65763832 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -561,6 +561,38 @@ class Fichinter extends CommonObject return price2num($amount, 'MT'); } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force model to use ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) + { + global $conf,$langs; + + $langs->load("interventions"); + + if (! dol_strlen($modele)) { + + $modele = 'azur'; + + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->PROPALE_ADDON_PDF)) { + $modele = $conf->global->PROPALE_ADDON_PDF; + } + } + + $modelpath = "core/modules/fichinter/doc/"; + + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + } /** * Returns the label status From e9bc5b719d51450664e31eb41ba974e0c226c195 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 14:50:00 +0200 Subject: [PATCH 045/111] Complete #7361 --- htdocs/fichinter/class/fichinter.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 90b65763832..70192c460d2 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -561,7 +561,7 @@ class Fichinter extends CommonObject return price2num($amount, 'MT'); } - + /** * Create a document onto disk according to template module. * @@ -580,12 +580,12 @@ class Fichinter extends CommonObject if (! dol_strlen($modele)) { - $modele = 'azur'; + $modele = 'soleil'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->PROPALE_ADDON_PDF)) { - $modele = $conf->global->PROPALE_ADDON_PDF; + } elseif (! empty($conf->global->FICHEINTER_ADDON_PDF)) { + $modele = $conf->global->FICHEINTER_ADDON_PDF; } } From 44405e5415fb2d3fd9aac3f444b10f436ba3a1ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 15:04:29 +0200 Subject: [PATCH 046/111] Fix #7335 #7365 Better fix --- htdocs/compta/facture/card.php | 8 ++++++++ htdocs/core/class/discount.class.php | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 60f711688cc..82eeb3d49c0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3156,6 +3156,14 @@ else if ($id > 0 || ! empty($ref)) $facthatreplace->fetch($objectidnext); print ' (' . $langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)) . ')'; } + + if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { + $discount = new DiscountAbsolute($db); + $result = $discount->fetch(0, $object->id); + if ($result > 0){ + print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(), $discount->getNomUrl(1, 'discount')).'
'; + } + } print '

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

'.$langs->trans("ThisScreenAllowsYouToSignDocFrom",$creditor).'


'.$langs->trans("WelcomeOnOnlineSignaturePage").'
'.$langs->trans("ThisScreenAllowsYouToSignDocFrom",$creditor).'


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

'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'


'.$langs->trans("WelcomeOnPaymentPage").'
'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'


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

'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'


'.$langs->trans("WelcomeOnPaymentPage").'
'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'


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

'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'


'.$langs->trans("WelcomeOnPaymentPage").'
'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'


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

'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'


'.$langs->trans("WelcomeOnPaymentPage").'
'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'

'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'
'; - -print ''; -print ''; -print ''; -print "\n"; - -// Allow public form -print '\n"; - -// Force Type -$adht = new AdherentType($db); -print '\n"; - -// Amount -print '\n"; - -// Can edit -print '\n"; - -if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled)) +$enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' '; +if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) { + // Button off, click to enable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Disabled"),'switch_off'); + $enabledisablehtml.=''; +} +else +{ + // Button on, click to disable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Activated"),'switch_on'); + $enabledisablehtml.=''; +} +print $enabledisablehtml; +print ''; + + +print '
'; + +if (! empty($conf->global->MEMBER_ENABLE_PUBLIC)) +{ + print '
'; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; -print $langs->trans("EnablePublicSubscriptionForm"); -print ''; -print $form->selectyesno("MEMBER_ENABLE_PUBLIC",(! empty($conf->global->MEMBER_ENABLE_PUBLIC)?$conf->global->MEMBER_ENABLE_PUBLIC:0),1); -print "
'; -print $langs->trans("ForceMemberType"); -print ''; -$listofval = array(-1 => $langs->trans("Undefined")); -$listofval += $adht->liste_array(); -$forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; -print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listetype)>1?1:0); -print "
'; -print $langs->trans("DefaultAmount"); -print ''; -print ''; -print "
'; -print $langs->trans("CanEditAmount"); -print ''; -print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT",(! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)?$conf->global->MEMBER_NEWFORM_EDITAMOUNT:0),1); -print "
'; + + print ''; + print ''; + print ''; + print "\n"; + + // Force Type + $adht = new AdherentType($db); + print '\n"; + + // Amount + print '\n"; + + // Can edit + print '\n"; + // Jump to an online payment page print '\n"; + + // Jump to an online payment page + print '\n"; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $langs->trans("ForceMemberType"); + print ''; + $listofval = array(-1 => $langs->trans("Undefined")); + $listofval += $adht->liste_array(); + $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; + print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listetype)>1?1:0); + print "
'; + print $langs->trans("DefaultAmount"); + print ''; + print ''; + print "
'; + print $langs->trans("CanEditAmount"); + print ''; + print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT",(! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)?$conf->global->MEMBER_NEWFORM_EDITAMOUNT:0),1); + print "
'; print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); print ''; $listofval=array(); + $listofval['-1']=$langs->trans('No'); + $listofval['all']=$langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')'; if (! empty($conf->paybox->enabled)) $listofval['paybox']='Paybox'; if (! empty($conf->paypal->enabled)) $listofval['paypal']='PayPal'; if (! empty($conf->stripe->enabled)) $listofval['stripe']='Stripe'; - print $form->selectarray("MEMBER_NEWFORM_PAYONLINE",$listofval,(! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)?$conf->global->MEMBER_NEWFORM_PAYONLINE:''),1); + print $form->selectarray("MEMBER_NEWFORM_PAYONLINE",$listofval,(! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)?$conf->global->MEMBER_NEWFORM_PAYONLINE:''),0); print "
'; + print $langs->trans("MEMBER_PAYONLINE_SENDEMAIL"); + print ''; + print ''; + print "
'; + + print '
'; + print ''; + print '
'; } -if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled)) -{ - // Jump to an online payment page - print ''; - print $langs->trans("MEMBER_PAYONLINE_SENDEMAIL"); - print ''; - print ''; - print "\n"; -} - -print ''; dol_fiche_end(); -print '
'; -print ''; -print '
'; - print ''; - -print '
'; -//print $langs->trans('FollowingLinksArePublic').'
'; -print img_picto('','object_globe.png').' '.$langs->trans('BlankSubscriptionForm').':
'; -if ($conf->multicompany->enabled) { - $entity_qr='?entity='.$conf->entity; -} else { - $entity_qr=''; +if (! empty($conf->global->MEMBER_ENABLE_PUBLIC)) +{ + print '
'; + //print $langs->trans('FollowingLinksArePublic').'
'; + print img_picto('','object_globe.png').' '.$langs->trans('BlankSubscriptionForm').':
'; + if ($conf->multicompany->enabled) { + $entity_qr='?entity='.$conf->entity; + } else { + $entity_qr=''; + } + print ''.DOL_MAIN_URL_ROOT.'/public/members/new.php'.$entity_qr.''; } -print ''.DOL_MAIN_URL_ROOT.'/public/members/new.php'.$entity_qr.''; -/* -print ''; -print ''; -print ''; -print ''; -print ''; -print '
'.$langs->trans("Description").''.$langs->trans("URL").'
'.$langs->trans("BlankSubscriptionForm").''..'
'.$langs->trans("PublicMemberList").''.img_picto('','object_globe.png').' '.''.DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.'
'.$langs->trans("PublicMemberCard").''.img_picto('','object_globe.png').' '.DOL_MAIN_URL_ROOT.'/public/members/public_card.php?id=xxx'.'
'; -*/ llxFooter(); diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 1e5306a93f4..4206e75a165 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -185,6 +185,9 @@ class DoliDBMysqli extends DoliDB { dol_syslog(get_class($this) . "::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name", LOG_DEBUG); + // Can also be + // mysqli::init(); mysql::options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0'); mysqli::options(MYSQLI_OPT_CONNECT_TIMEOUT, 5); + // return mysqli::real_connect($host, $user, $pass, $db, $port); return new mysqli($host, $login, $passwd, $name, $port); } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index dc359696c98..5d46de321da 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1251,7 +1251,7 @@ function form_constantes($tableau, $strictw3c=0, $helptext='') print ''; print ''; - print ''; + print ''; print ' - + jQuery(document).ready(function () { jQuery(".classfortooltip").tipTip({maxWidth: "'.dol_size(($conf->browser->layout == 'phone' ? 400 : 700),'width').'px", edgeOffset: 10, delay: 50, fadeIn: 50, fadeOut: 50}); - jQuery(".classfortooltiponclicktext").dialog({ width: 500, autoOpen: false }); + jQuery(".classfortooltiponclicktext").dialog({ width: '.($conf->browser->layout == 'phone' ? 400 : 700).', autoOpen: false }); jQuery(".classfortooltiponclick").click(function () { console.log("We click on tooltip for element with dolid="+$(this).attr(\'dolid\')); if ($(this).attr(\'dolid\')) From 627dd15b44953e28a20dd5a88cfc3ebced62bd23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 12:18:26 +0200 Subject: [PATCH 053/111] Suggested link for online payment use the generic link --- htdocs/adherents/card.php | 19 ++- htdocs/adherents/subscription.php | 33 ++--- htdocs/adherents/subscription/card.php | 8 +- htdocs/compta/facture/card.php | 17 ++- .../tpl/linkedobjectblockForRec.tpl.php | 2 +- htdocs/core/lib/payments.lib.php | 128 ++++++++++++++++++ 6 files changed, 163 insertions(+), 44 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 78969a8df14..7279d5b055a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1743,14 +1743,19 @@ else // Show links to link elements /*$linktoelem = $form->showLinkToObjectBlock($object,array('order')); if ($linktoelem) print ($somethingshown?'':'
').$linktoelem; - - // Link for paypal payment - /* - if (! empty($conf->paypal->enabled) && $object->statut != 0) { - include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; - print showPaypalPaymentUrl('invoice', $object->ref); - } */ + + // Shon online payment link + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + + if ($useonlinepayment) + { + print '
'; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('membersubscription', $object->ref); + } + print '
'; // List of actions on element diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8002b33b1f6..bddb8efb50b 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -789,14 +789,10 @@ if ($rowid > 0) if ($object->statut > 0) print '"; else print ''; - print "
\n"; - print '
'; - print '
'; } } - /* * List of subscriptions */ @@ -882,24 +878,21 @@ if ($rowid > 0) { dol_print_error($db); } - - - // Link for paypal payment - if (! empty($conf->paypal->enabled)) - { - include_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; - print showPaypalPaymentUrl('membersubscription',$object->ref); - } - - // Link for stripe payment - if (! empty($conf->stripe->enabled)) - { - include_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; - print showStripePaymentUrl('membersubscription',$object->ref); - } - } + + // Shon online payment link + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + + if ($useonlinepayment) + { + print '
'; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('membersubscription', $object->ref); + } + + /* * Add new subscription form */ diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 3faa45d7d84..2689a1d93be 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -402,14 +402,8 @@ if ($rowid && $action != 'edit') // Show links to link elements /*$linktoelem = $form->showLinkToObjectBlock($object,array('order')); if ($linktoelem) print ($somethingshown?'':'
').$linktoelem; - - // Link for paypal payment - /* - if (! empty($conf->paypal->enabled) && $object->statut != 0) { - include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; - print showPaypalPaymentUrl('invoice', $object->ref); - } */ + print '
'; // List of actions on element diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 248bc31737d..e40070adbbc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4307,16 +4307,15 @@ else if ($id > 0 || ! empty($ref)) $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - // Link for paypal payment - if (! empty($conf->paypal->enabled) && $object->statut != 0) { - include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; - print showPaypalPaymentUrl('invoice', $object->ref); - } - // Link for stripe payment - if (! empty($conf->stripe->enabled) && $object->statut != 0) { - include_once DOL_DOCUMENT_ROOT . '/stripe/lib/stripe.lib.php'; - print showStripePaymentUrl('invoice', $object->ref); + // Show online payment link + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + + if ($object->statut != 0 && $useonlinepayment) + { + print '
'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('invoice', $object->ref); } print '
'; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index 043778d92c3..44d5ec2ced5 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -44,7 +44,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
- + \n"; - print ''; + print ''; print "
'.$langs->trans("Description").''.$langs->trans("Description").''; $text = $langs->trans("Value"); print $form->textwithpicto($text, $helptext, 1, 'help', '', 0, 2, 'idhelptext'); diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 550ec6ad534..472c040e450 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -100,7 +100,7 @@ function member_prepare_head(Adherent $object) $head[$h][2] = 'agenda'; $h++; } - + complete_head_from_modules($conf,$langs,$object,$head,$h,'member','remove'); return $head; @@ -152,6 +152,11 @@ function member_admin_prepare_head() $head[$h][2] = 'general'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php'; + $head[$h][1] = $langs->trans("EMails"); + $head[$h][2] = 'emails'; + $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 @@ -168,9 +173,9 @@ function member_admin_prepare_head() $head[$h][2] = 'attributes_type'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/public.php'; + $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php'; $head[$h][1] = $langs->trans("BlankSubscriptionForm"); - $head[$h][2] = 'public'; + $head[$h][2] = 'website'; $h++; complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin','remove'); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ce52b74beb6..0ce5a7f1fc0 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1243,6 +1243,7 @@ MemberMainOptions=Main options AdherentLoginRequired= Manage a Login for each member AdherentMailRequired=EMail required to create a new member MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members (validation or new subscription) is on by default +VisitorCanChooseItsPaymentMode=Visitor can choose among available payment modes ##### LDAP setup ##### LDAPSetup=LDAP Setup LDAPGlobalParameters=Global parameters diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 6dca3afbdb3..5e7ad30ec3f 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -87,9 +87,9 @@ 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. PublicMemberList=Public member list -BlankSubscriptionForm=Public auto-subscription form -BlankSubscriptionFormDesc=Dolibarr can provide you a public URL to allow external visitors to ask to subscribe to the foundation. If an online payment module is enabled, a payment form will also be automatically provided. -EnablePublicSubscriptionForm=Enable the public auto-subscription form +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. +EnablePublicSubscriptionForm=Enable the public website with self-subscription form ForceMemberType=Force the member type ExportDataset_member_1=Members and subscriptions ImportDataset_member_1=Members diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index f174c51cc74..03c44514b01 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -299,11 +299,39 @@ if ($action == 'add') if (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') + if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all') + { + $urlback=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); + if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) + { + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + } + else + { + $urlback.='&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); + } + } + } + else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') { $urlback=DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); + if (! empty($conf->global->PAYBOX_SECURITY_TOKEN)) + { + if (! empty($conf->global->PAYBOX_SECURITY_TOKEN_UNIQUE)) + { + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYBOX_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + } + else + { + $urlback.='&securekey='.urlencode($conf->global->PAYBOX_SECURITY_TOKEN); + } + } } else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 161aec10d8f..a423b2b31de 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1106,17 +1106,18 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; - if ($rowid) $sql .= ' WHERE s.rowid = '.$rowid; - else if ($ref) $sql .= " WHERE s.nom = '".$this->db->escape($ref)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($ref_ext) $sql .= " WHERE s.ref_ext = '".$this->db->escape($ref_ext)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($ref_int) $sql .= " WHERE s.ref_int = '".$this->db->escape($ref_int)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($idprof1) $sql .= " WHERE s.siren = '".$this->db->escape($idprof1)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($idprof2) $sql .= " WHERE s.siret = '".$this->db->escape($idprof2)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($idprof3) $sql .= " WHERE s.ape = '".$this->db->escape($idprof3)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($idprof4) $sql .= " WHERE s.idprof4 = '".$this->db->escape($idprof4)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($idprof5) $sql .= " WHERE s.idprof5 = '".$this->db->escape($idprof5)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($idprof6) $sql .= " WHERE s.idprof6 = '".$this->db->escape($idprof6)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($email) $sql .= " WHERE email = '".$this->db->escape($email)."' AND s.entity IN (".getEntity($this->element, 1).")"; + $sql .= ' WHERE s.entity IN ('.getEntity($this->element, 1).')'; + if ($rowid) $sql .= ' AND s.rowid = '.$rowid; + if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; + if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; + if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; + if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; + if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; + if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; + if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; + if ($email) $sql .= " AND email = '".$this->db->escape($email)."'"; $resql=$this->db->query($sql); if ($resql) From cda8c6e41a7bf2cb470ca16ce6e36f8ce6715f14 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 11:51:51 +0200 Subject: [PATCH 052/111] Fix ref must be 50 --- htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php | 8 ++++++-- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 5 +++++ htdocs/install/mysql/tables/llx_contrat.sql | 8 ++++---- htdocs/langs/en_US/other.lang | 2 ++ htdocs/main.inc.php | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index 2e7858fdb08..043778d92c3 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -36,7 +36,7 @@ $var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - + $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> @@ -50,7 +50,11 @@ foreach($linkedObjectBlock as $key => $objectlink) $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?> + getLibStatut(3); + ?> + ">transnoentitiesnoconv("RemoveLink")); ?>
trans("RepeatableInvoice"); ?> getNomUrl(1); ?> date,'day'); ?>date_when,'day'); ?> rights->facture->lire) { $total = $total + $objectlink->total_ht; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 630011ab3e0..49a1e909d91 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -88,6 +88,134 @@ function payment_supplier_prepare_head(Paiement $object) { } +/** + * Return string with full Url + * + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @return string Url string + */ +function showOnlinePaymentUrl($type,$ref) +{ + global $conf, $langs; + + $langs->load("PAYMENT"); + $langs->load("paybox"); + $servicename='Online'; + + $out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'
'; + $url=getOnlinePaymentUrl(0,$type,$ref); + $out.=''; + $out.=ajax_autoselect("onlinepaymenturl", 0); + return $out; +} + + +/** + * Return string with full Url + * + * @param int $mode 0=True url, 1=Url formated with colors + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @param int $amount Amount + * @param string $freetag Free tag + * @return string Url string + */ +function getOnlinePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_free_tag') +{ + global $conf; + + $ref=str_replace(' ','',$ref); + + if ($type == 'free') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + } + } + if ($type == 'order') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'':''); + if ($mode == 1) $out.='order_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + if ($type == 'invoice') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'':''); + if ($mode == 1) $out.='invoice_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + if ($type == 'contractline') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'':''); + if ($mode == 1) $out.='contractline_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + if ($type == 'membersubscription') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'':''); + if ($mode == 1) $out.='member_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + + // For multicompany + $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + + return $out; +} + + /** * Show footer of company in HTML pages From d0a0bf57b6960fe5898968e8025115684f8e1907 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 12:52:48 +0200 Subject: [PATCH 054/111] NEW The "Show detail by account" accepts 3 values: yes, no, if non zero --- htdocs/admin/company.php | 6 +- htdocs/compta/resultat/clientfourn.php | 8 +- htdocs/compta/resultat/result.php | 110 ++++++++++++++++++------- htdocs/langs/en_US/accountancy.lang | 1 + 4 files changed, 89 insertions(+), 36 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 6170c02dd4f..bd84c1d6339 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -157,7 +157,7 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("object",'nohtml'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("fiscalmonthstart",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_TVAOPTION", GETPOST("optiontva",'alpha'),'chaine',0,'',$conf->entity); @@ -547,8 +547,8 @@ if ($action == 'edit' || $action == 'updateedit') print "
'; - print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',0,1) . '
'; + print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'SOCIETE_FISCAL_MONTH_START',0,1) . '
"; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index c194f21d862..0b52404cd7b 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -189,7 +189,8 @@ elseif ($modecompta=="BOOKKEEPING") $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $period.='     '.$langs->trans("DetailByAccount").' '. $form->selectyesno('showaccountdetail',$showaccountdetail,0); + $arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All")); + $period.='     '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0); $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesResultBookkeepingPredefined"); $description.=' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("Chartofaccounts")).')'; @@ -291,7 +292,7 @@ if ($modecompta == 'BOOKKEEPING') // Loop on detail of all accounts // This make 14 calls for each detail of account (NP, N and month m) - if ($showaccountdetail == 'yes') + if ($showaccountdetail != 'no') { $tmppredefinedgroupwhere="pcg_type = '".$db->escape($objp->pcg_type)."' AND pcg_subtype = '".$db->escape($objp->pcg_subtype)."'"; $tmppredefinedgroupwhere.= " AND fk_pcg_version = '".$charofaccountstring."'"; @@ -310,7 +311,8 @@ if ($modecompta == 'BOOKKEEPING') $resultN=$AccCat->sdc; } - if ($resultN > 0) + + if ($showaccountdetail == 'all' || $resultN > 0) { print ''; print ''; diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 4f76f2cdfa6..4917513438a 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Alexandre Spangaro + * Copyright (C) 2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,12 +57,12 @@ $nbofyear=1; $year=GETPOST('year','int'); if (empty($year)) { - $year_current = strftime("%Y",dol_now()); - $month_current = strftime("%m",dol_now()); + $year_current = strftime("%Y", dol_now()); + $month_current = strftime("%m", dol_now()); $year_start = $year_current - ($nbofyear - 1); } else { $year_current = $year; - $month_current = strftime("%m",dol_now()); + $month_current = strftime("%m", dol_now()); $year_start = $year - ($nbofyear - 1); } $date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); @@ -76,6 +77,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end // We define date_start and date_end $year_end=$year_start + ($nbofyear - 1); $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $date_startmonth = $month_start; if (! GETPOST('month')) { if (! GETPOST("year") && $month_start > $month_current) @@ -195,7 +197,8 @@ else if ($modecompta=="BOOKKEEPING") //$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $period.='     '.$langs->trans("DetailByAccount").' '. $form->selectyesno('showaccountdetail',$showaccountdetail,0); + $arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All")); + $period.='     '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0); $periodlink = $textprevyear . " " . $langs->trans("Year") . " " . $start_year . " " . $textnextyear ; $exportlink = ''; $description=$langs->trans("RulesResultBookkeepingPersonalized"). @@ -225,7 +228,16 @@ print ''; print ''.$langs->trans("PreviousPeriod").''; print ''.$langs->trans("SelectedPeriod").''; foreach($months as $k => $v){ - print ''.$langs->trans($v).''; + if (($k+1) >= $date_startmonth) + { + print ''.$langs->trans($v).''; + } +} +foreach($months as $k => $v){ + if (($k+1) < $date_startmonth) + { + print ''.$langs->trans($v).''; + } } print ''; @@ -306,16 +318,35 @@ else if ($modecompta=="BOOKKEEPING") // Detail by month foreach($months as $k => $v) { - foreach($sommes as $code => $det){ - $vars[$code] = $det['M'][$k]; + if (($k+1) >= $date_startmonth) + { + foreach($sommes as $code => $det){ + $vars[$code] = $det['M'][$k]; + } + $result = strtr($formula, $vars); + + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1); + + print '' . price($r) . ''; + $sommes[$code]['M'][$k] += $r; } - $result = strtr($formula, $vars); + } + foreach($months as $k => $v) + { + if (($k+1) < $date_startmonth) + { + foreach($sommes as $code => $det){ + $vars[$code] = $det['M'][$k]; + } + $result = strtr($formula, $vars); - //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1); + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1); - print '' . price($r) . ''; - $sommes[$code]['M'][$k] += $r; + print '' . price($r) . ''; + $sommes[$code]['M'][$k] += $r; + } } @@ -418,38 +449,57 @@ else if ($modecompta=="BOOKKEEPING") print '' . price($totCat['NP']) . ''; print '' . price($totCat['N']) . ''; + // Each month foreach($totCat['M'] as $k => $v){ - print '' . price($v) . ''; + if (($k+1) >= $date_startmonth) print '' . price($v) . ''; } + foreach($totCat['M'] as $k => $v){ + if (($k+1) < $date_startmonth) print '' . price($v) . ''; + } + print "\n"; // Loop on detail of all accounts // This make 14 calls for each detail of account (NP, N and month m) - if ($showaccountdetail == 'yes') + if ($showaccountdetail != 'no') { foreach($cpts as $i => $cpt) { $resultNP=$totPerAccount[$cpt['account_number']]['NP']; $resultN=$totPerAccount[$cpt['account_number']]['N']; - print ''; - print ''; - print ''; - print '     ' . length_accountg($cpt['account_number']); - print ' - '; - print $cpt['account_label']; - print ''; - print '' . price($resultNP) . ''; - print '' . price($resultN) . ''; - - // Make one call for each month - foreach($months as $k => $v) + if ($showaccountdetail == 'all' || $resultN > 0) { - $resultM=$totPerAccount[$cpt['account_number']]['M'][$k]; - print '' . price($resultM) . ''; - } + print ''; + print ''; + print ''; + print '     ' . length_accountg($cpt['account_number']); + print ' - '; + print $cpt['account_label']; + print ''; + print '' . price($resultNP) . ''; + print '' . price($resultN) . ''; - print "\n"; + // Make one call for each month + foreach($months as $k => $v) + { + if (($k+1) >= $date_startmonth) + { + $resultM=$totPerAccount[$cpt['account_number']]['M'][$k]; + print '' . price($resultM) . ''; + } + } + foreach($months as $k => $v) + { + if (($k+1) < $date_startmonth) + { + $resultM=$totPerAccount[$cpt['account_number']]['M'][$k]; + print '' . price($resultM) . ''; + } + } + + print "\n"; + } } } } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index db7de1a21ad..d0643c717e6 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -33,6 +33,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 MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup MainAccountForSuppliersNotDefined=Main accounting account for suppliers not defined in setup From 3001ee5fe7c4619cb8141e3b1c9cb384eccd36af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 13:05:34 +0200 Subject: [PATCH 055/111] Fix title of reports --- htdocs/compta/resultat/clientfourn.php | 6 +++--- htdocs/compta/resultat/index.php | 10 +++++----- htdocs/core/menus/init_menu_auguria.sql | 4 ++-- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- htdocs/langs/en_US/accountancy.lang | 1 + htdocs/langs/en_US/compta.lang | 5 +++-- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 0b52404cd7b..3a2d5a9a5fe 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -156,7 +156,7 @@ $total_ttc=0; // Affiche en-tete de rapport if ($modecompta=="CREANCES-DETTES") { - $name=$langs->trans("AnnualByCompanies"); + $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups"); $calcmode=$langs->trans("CalcModeDebt"); $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; @@ -170,7 +170,7 @@ if ($modecompta=="CREANCES-DETTES") } elseif ($modecompta=="RECETTES-DEPENSES") { - $name=$langs->trans("AnnualByCompanies"); + $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups"); $calcmode=$langs->trans("CalcModeEngagement"); $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; @@ -183,7 +183,7 @@ elseif ($modecompta=="RECETTES-DEPENSES") } elseif ($modecompta=="BOOKKEEPING") { - $name=$langs->trans("AnnualByCompanies"); + $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups"); $calcmode=$langs->trans("CalcModeBookkeeping"); $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 32aba15704f..49d8766127e 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -118,7 +118,7 @@ $exportlink=''; // Affiche en-tete du rapport if ($modecompta == 'CREANCES-DETTES') { - $name=$langs->trans("AnnualSummaryDueDebtMode"); + $name = $langs->trans("ReportInOut").', '.$langs->trans("ByYear"); $calcmode=$langs->trans("CalcModeDebt"); $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; @@ -132,7 +132,7 @@ if ($modecompta == 'CREANCES-DETTES') //$exportlink=$langs->trans("NotYetAvailable"); } else if ($modecompta=="RECETTES-DEPENSES") { - $name=$langs->trans("AnnualSummaryInputOutputMode"); + $name = $langs->trans("ReportInOut").', '.$langs->trans("ByYear"); $calcmode=$langs->trans("CalcModeEngagement"); $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; @@ -145,7 +145,7 @@ else if ($modecompta=="RECETTES-DEPENSES") { } else if ($modecompta=="BOOKKEEPING") { - $name=$langs->trans("AnnualSummaryDueDebtMode"); + $name = $langs->trans("ReportInOut").', '.$langs->trans("ByYear"); $calcmode=$langs->trans("CalcModeBookkeeping"); $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; @@ -636,12 +636,12 @@ if (! empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $m $subtotal_ht = 0; $subtotal_ttc = 0; - $sql = "SELECT p.label as nom, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; + $sql = "SELECT p.label as nom, date_format(".$column.",'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM " . MAIN_DB_PREFIX . "payment_salary as p"; $sql .= " WHERE p.entity = " . $conf->entity; - $sql .= " GROUP BY p.label, dm"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'"; + $sql .= " GROUP BY p.label, dm"; dol_syslog("get social salaries payments"); $result = $db->query($sql); diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index c7bce6ecf07..e51e6469fe6 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -250,7 +250,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2435__+MAX_llx_menu__, 'accountancy', 'balance', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_balance', 'AccountBalance', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__); -- Reports insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2440__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2400__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'Reportings', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 17, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2441__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2440__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ReportInOut', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 18, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2441__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2440__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'MenuReportInOut', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 18, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2443__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2441__+MAX_llx_menu__, '/compta/resultat/clientfourn.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByPredefinedAccountGroups', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 19, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2442__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2441__+MAX_llx_menu__, '/compta/resultat/result.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByPersonalizedAccountGroups', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 20, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2444__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2440__+MAX_llx_menu__, '/compta/stats/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ReportTurnover', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 21, __ENTITY__); @@ -259,7 +259,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2447__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2444__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByProductsAndServices', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 24, __ENTITY__); -- Accounting simple insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled', __HANDLER__, 'left', 2700__+MAX_llx_menu__, 'accountancy', 'ca', 9__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 0, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 11, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2711__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'ReportInOut', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2711__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'MenuReportInOut', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2712__+MAX_llx_menu__, 'accountancy', '', 2701__+MAX_llx_menu__, '/compta/resultat/clientfourn.php?leftmenu=ca', 'ByCompanies', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2713__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/stats/index.php?leftmenu=ca', 'ReportTurnover', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2714__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/casoc.php?leftmenu=ca', 'ByCompanies', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 56e9039d358..5f9550c9e78 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1122,7 +1122,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report",$langs->trans("Reportings"),1,$user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report",$langs->trans("ReportInOut"),2,$user->rights->accounting->comptarapport->lire); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report",$langs->trans("MenuReportInOut"),2,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report",$langs->trans("ByPredefinedAccountGroups"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/result.php?leftmenu=accountancy_report",$langs->trans("ByPersonalizedAccountGroups"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report",$langs->trans("ReportTurnover"),2,$user->rights->accounting->comptarapport->lire); @@ -1139,7 +1139,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Bilan, resultats $newmenu->add("/compta/resultat/index.php?leftmenu=report&mainmenu=accountancy",$langs->trans("Reportings"),0,$user->rights->compta->resultat->lire, '', $mainmenu, 'ca'); - if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/resultat/index.php?leftmenu=report",$langs->trans("ReportInOut"),1,$user->rights->compta->resultat->lire); + if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/resultat/index.php?leftmenu=report",$langs->trans("MenuReportInOut"),1,$user->rights->compta->resultat->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report",$langs->trans("ByCompanies"),2,$user->rights->compta->resultat->lire); /* On verra ca avec module compabilite expert if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->rights->compta->resultat->lire); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index d0643c717e6..33c5fcc3643 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -157,6 +157,7 @@ AccountingAccountGroupsDesc=You can define here some groups of accounting accoun ByAccounts=By accounts ByPredefinedAccountGroups=By predefined groups ByPersonalizedAccountGroups=By personalized groups +ByYear=By year NotMatch=Not Set DeleteMvt=Delete Ledger lines DelYear=Year to delete diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 0aa648c7750..54ebb4bf1ee 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -17,7 +17,8 @@ Accountparent=Parent account Accountsparent=Parent accounts Income=Income Outcome=Expense -ReportInOut=Income / Expense +MenuReportInOut=Income / Expense +ReportInOut=Balance of income and expenses ReportTurnover=Turnover PaymentsNotLinkedToInvoice=Payments not linked to any invoice, so not linked to any third party PaymentsNotLinkedToUser=Payments not linked to any user @@ -143,7 +144,7 @@ CalcModeLT2Debt=Mode %sIRPF on customer invoices%s CalcModeLT2Rec= Mode %sIRPF on suppliers invoices%s AnnualSummaryDueDebtMode=Balance of income and expenses, annual summary AnnualSummaryInputOutputMode=Balance of income and expenses, annual summary -AnnualByCompanies=Income / Expenses, By predefined groups of account +AnnualByCompanies=Balance of income and expenses, by predefined groups of account AnnualByCompaniesDueDebtMode=Balance of income and expenses, detail by predefined groups, mode %sClaims-Debts%s said Commitment accounting. AnnualByCompaniesInputOutputMode=Balance of income and expenses, detail by predefined groups, mode %sIncomes-Expenses%s said cash accounting. SeeReportInInputOutputMode=See report %sIncomes-Expenses%s said cash accounting for a calculation on actual payments made From 16092bc9f0f313a52ef3819100bbdef02e5db721 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 13:13:57 +0200 Subject: [PATCH 056/111] Clean code --- htdocs/accountancy/customer/index.php | 49 +++++++++------------ htdocs/accountancy/expensereport/index.php | 51 +++++++++------------- htdocs/accountancy/supplier/index.php | 48 +++++++++----------- 3 files changed, 61 insertions(+), 87 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 880f6329a3f..86ae7ea9b0a 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -108,29 +108,6 @@ if ($action == 'validatehistory') { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'fixaccountancycode') { - $error = 0; - $db->begin(); - - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql1 .= " SET fk_code_ventilation = 0"; - $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; - $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; - - dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } elseif ($action == 'cleanaccountancycode') { $error = 0; $db->begin(); @@ -144,7 +121,7 @@ if ($action == 'validatehistory') { $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; $sql1.=")"; - dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); if (! $resql1) { @@ -169,13 +146,29 @@ $textnextyear = ' begin(); +$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql1 .= " SET fk_code_ventilation = 0"; +$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; +$sql1 .= ' (SELECT accnt.rowid '; +$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; +$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; +$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; +dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); +$resql1 = $db->query($sql1); +if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); +} else { + $db->commit(); +} +// End clean database + print $langs->trans("DescVentilCustomer") . '
'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; print '
'; -//print '
'; $sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " , " . MAIN_DB_PREFIX . "facture as f"; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 4aa9559c084..26fcf7a4606 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -104,29 +104,6 @@ if ($action == 'validatehistory') { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'fixaccountancycode') { - $error = 0; - $db->begin(); - - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql1 .= " SET fk_code_ventilation = 0"; - $sql1 .= ' WHERE erd.fk_code_ventilation NOT IN '; - $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; - - dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } elseif ($action == 'cleanaccountancycode') { $error = 0; $db->begin(); @@ -140,7 +117,7 @@ if ($action == 'validatehistory') { $sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")"; $sql1.=")"; - dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); if (! $resql1) { @@ -168,13 +145,25 @@ print $langs->trans("DescVentilExpenseReport") . '
'; print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; print '
'; -//print '
'; -// TODO Remove this. Should be done always or into the repair.php script. -if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; -//print '
'; - - - +// Clean database +$db->begin(); +$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; +$sql1 .= " SET fk_code_ventilation = 0"; +$sql1 .= ' WHERE erd.fk_code_ventilation NOT IN '; +$sql1 .= ' (SELECT accnt.rowid '; +$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; +$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; +$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; +dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); +$resql1 = $db->query($sql1); +if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); +} else { + $db->commit(); +} +// End clean database $y = $year_current; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index abcf317ea65..96b250434ef 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -105,29 +105,6 @@ if ($action == 'validatehistory') { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'fixaccountancycode') { - $error = 0; - $db->begin(); - - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; - $sql1 .= " SET fk_code_ventilation = 0"; - $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; - $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; - - dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } elseif ($action == 'cleanaccountancycode') { $error = 0; $db->begin(); @@ -140,7 +117,7 @@ if ($action == 'validatehistory') { $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; $sql1.= ")"; - dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); if (! $resql1) { @@ -168,10 +145,25 @@ print $langs->trans("DescVentilSupplier") . '
'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; print '
'; -//print '
'; -// TODO Remove this. Should be done always or into the repair.php script. -if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; -//print '
'; +// Clean database +$db->begin(); +$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; +$sql1 .= " SET fk_code_ventilation = 0"; +$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; +$sql1 .= ' (SELECT accnt.rowid '; +$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; +$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; +$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; +dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); +$resql1 = $db->query($sql1); +if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); +} else { + $db->commit(); +} +// End clean database $y = $year_current; From 5dcbebbd46e100d346db8ea1abd683ade90c5cef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 13:48:45 +0200 Subject: [PATCH 057/111] NEW Add filters on month/year on the accountancy binding tools --- htdocs/accountancy/customer/list.php | 37 +++++++++++++++++++++- htdocs/accountancy/expensereport/list.php | 38 ++++++++++++++++++++++- htdocs/accountancy/supplier/list.php | 37 +++++++++++++++++++++- htdocs/comm/propal/list.php | 18 ++++++----- 4 files changed, 119 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 5e78d735523..0288ee872d7 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -33,6 +33,8 @@ require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("compta"); @@ -60,6 +62,10 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); + $btn_ventil = GETPOST('ventil', 'alpha'); // Load variable for pagination @@ -109,6 +115,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_month = ''; + $search_year = ''; } // Mass actions @@ -174,6 +182,7 @@ if ($massaction == 'ventil') { */ $form = new Form($db); +$formother = new FormOther($db); llxHeader('', $langs->trans("Ventilation")); @@ -216,6 +225,19 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx",$search_vat,1); } +if ($search_month > 0) +{ + if ($search_year > 0 && empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; + else if ($search_year > 0 && ! empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; + else + $sql.= " AND date_format(f.datef, '%m') = '".$db->escape($search_month)."'"; +} +else if ($search_year > 0) +{ + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; +} if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; } else { @@ -246,6 +268,15 @@ if ($result) { $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid); + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year='.urlencode($search_year); + if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice); + if ($search_ref) $param.='&search_ref='.urlencode($search_ref); + if ($search_desc) $param.='&search_desc='.urlencode($search_desc); + if ($search_amount) $param.='&search_amount='.urlencode($search_amount); + if ($search_vat) $param.='&search_vat='.urlencode($search_vat); $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") @@ -280,7 +311,11 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year,'search_year',1, 20, 5); + print ''; print ''; //print ''; print ''; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 09bb45df918..6bf18f0da20 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("compta"); @@ -58,6 +60,10 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); + $btn_ventil = GETPOST('ventil', 'alpha'); // Load variable for pagination @@ -103,6 +109,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_month = ''; + $search_year = ''; } // Mass actions @@ -169,6 +177,7 @@ if ($massaction == 'ventil') { */ $form = new Form($db); +$formother = new FormOther($db); llxHeader('', $langs->trans("ExpenseReportsVentilation")); @@ -203,6 +212,19 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("erd.tva_tx",$search_vat,1); } +if ($search_month > 0) +{ + if ($search_year > 0 && empty($search_day)) + $sql.= " AND erd.date BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; + else if ($search_year > 0 && ! empty($search_day)) + $sql.= " AND erd.date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; + else + $sql.= " AND date_format(erd.date, '%m') = '".$db->escape($search_month)."'"; +} +else if ($search_year > 0) +{ + $sql.= " AND erd.date BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; +} $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -228,6 +250,15 @@ if ($result) { $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid); + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year='.urlencode($search_year); + if ($search_expensereport) $param.='&search_expensereport='.urlencode($search_expensereport); + if ($search_label) $param.='&search_label='.urlencode($search_label); + if ($search_desc) $param.='&search_desc='.urlencode($search_desc); + if ($search_amount) $param.='&search_amount='.urlencode($search_amount); + if ($search_vat) $param.='&search_vat='.urlencode($search_vat); $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") @@ -263,7 +294,11 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year,'search_year',1, 20, 5); + print ''; print ''; print ''; print ''; @@ -313,6 +348,7 @@ if ($result) { // Ref Expense report print '' . $expensereport_static->getNomUrl(1) . ''; + // Date print '' . dol_print_date($db->jdate($objp->date), 'day') . ''; // Fees label diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 84c341400d7..ba5ecfe6bb7 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -33,6 +33,8 @@ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("compta"); @@ -60,6 +62,10 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); + $btn_ventil = GETPOST('ventil', 'alpha'); // Load variable for pagination @@ -110,6 +116,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_month = ''; + $search_year = ''; } // Mass actions @@ -176,6 +184,7 @@ if ($massaction == 'ventil') { */ $form = new Form($db); +$formother = new FormOther($db); llxHeader('', $langs->trans("SuppliersVentilation")); @@ -218,6 +227,19 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx",$search_vat,1); } +if ($search_month > 0) +{ + if ($search_year > 0 && empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; + else if ($search_year > 0 && ! empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; + else + $sql.= " AND date_format(f.datef, '%m') = '".$db->escape($search_month)."'"; +} +else if ($search_year > 0) +{ + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; +} $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -243,6 +265,15 @@ if ($result) { $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid); + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year='.urlencode($search_year); + if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice); + if ($search_ref) $param.='&search_ref='.urlencode($search_ref); + if ($search_desc) $param.='&search_desc='.urlencode($search_desc); + if ($search_amount) $param.='&search_amount='.urlencode($search_amount); + if ($search_vat) $param.='&search_vat='.urlencode($search_vat); $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") @@ -279,7 +310,11 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year,'search_year',1, 20, 5); + print ''; print ''; //print ''; print ''; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 92bb80d9655..4939d7e83f7 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -73,6 +73,10 @@ $search_zip=GETPOST('search_zip','alpha'); $search_state=trim(GETPOST("search_state")); $search_country=GETPOST("search_country",'int'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); +$search_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); + $viewstatut=GETPOST('viewstatut','alpha'); $optioncss = GETPOST('optioncss','alpha'); $object_statut=GETPOST('propal_statut','alpha'); @@ -80,9 +84,6 @@ $object_statut=GETPOST('propal_statut','alpha'); $sall=GETPOST('sall', 'alphanohtml'); $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); -$search_day=GETPOST("search_day","int"); -$search_month=GETPOST("search_month","int"); -$search_year=GETPOST("search_year","int"); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -371,9 +372,10 @@ if ($resql) 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_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year='.urlencode($search_year); + if ($search_ref) $param.='&search_ref='.urlencode($search_ref); if ($search_refcustomer) $param.='&search_refcustomer='.urlencode($search_refcustomer); if ($search_societe) $param.='&search_societe='.urlencode($search_societe); if ($search_user > 0) $param.='&search_user='.urlencode($search_user); @@ -613,7 +615,7 @@ if ($resql) // Date if (! empty($arrayfields['p.date']['checked'])) { - print ''; + print ''; //print $langs->trans('Month').': '; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; @@ -624,7 +626,7 @@ if ($resql) // Date end if (! empty($arrayfields['p.fin_validite']['checked'])) { - print ' '; + print ' '; } if (! empty($arrayfields['p.total_ht']['checked'])) { From f41147671888abc174abb0eeff1c3c3b588bf1dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 13:52:19 +0200 Subject: [PATCH 058/111] Fix default value of filter --- htdocs/compta/resultat/clientfourn.php | 2 +- htdocs/compta/resultat/result.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 3a2d5a9a5fe..8b67cf318c7 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -44,7 +44,7 @@ $date_startyear=GETPOST('date_startyear','int'); $date_endmonth=GETPOST('date_endmonth','int'); $date_endday=GETPOST('date_endday','int'); $date_endyear=GETPOST('date_endyear','int'); -$showaccountdetail = GETPOST('showaccountdetail','aZ09'); +$showaccountdetail = GETPOST('showaccountdetail','aZ09')?GETPOST('showaccountdetail','aZ09'):'no'; // Security check $socid = GETPOST('socid','int'); diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 4917513438a..3de3cea5d0f 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -41,7 +41,7 @@ $selectcpt = GETPOST('cpt_bk'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); $cancel = GETPOST('cancel','alpha'); -$showaccountdetail = GETPOST('showaccountdetail','aZ09'); +$showaccountdetail = GETPOST('showaccountdetail','aZ09')?GETPOST('showaccountdetail','aZ09'):'no'; $date_startmonth=GETPOST('date_startmonth','int'); From 531ebc4c481f90aac36637aaff98b4608e18f5c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 13:53:55 +0200 Subject: [PATCH 059/111] Fix merge --- htdocs/compta/facture/class/facture-rec.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index c88d98c00ea..858661c6557 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1554,6 +1554,4 @@ class FactureLigneRec extends CommonInvoiceLine } -======= ->>>>>>> branch '6.0' of git@github.com:Dolibarr/dolibarr.git } From c5961d8386c67bc8754d750bfdc96bbbcdb49a53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 14:34:33 +0200 Subject: [PATCH 060/111] Pass user to the delete function --- htdocs/compta/facture/class/facture-rec.class.php | 6 ++++-- htdocs/compta/facture/fiche-rec.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 858661c6557..9319bf6fdec 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -480,7 +480,7 @@ class FactureRec extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger=0, $idwarehouse=-1) + function delete(User $user, $notrigger=0, $idwarehouse=-1) { $rowid=$this->id; @@ -1361,7 +1361,9 @@ class FactureLigneRec extends CommonInvoiceLine /** * Delete line in database * - * @return int <0 if KO, >0 if OK + * @param User $user Object user + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK */ function delete(User $user, $notrigger = false) { diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 08011336976..80ffffdfb39 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -300,7 +300,7 @@ if (empty($reshook)) // Delete if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) { - $object->delete(); + $object->delete($user); header("Location: " . $_SERVER['PHP_SELF'] ); exit; } From 3d4134df7ae410a558541d3597b5925640c67cbd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 14:39:20 +0200 Subject: [PATCH 061/111] Translation --- htdocs/langs/en_US/accountancy.lang | 2 +- htdocs/langs/en_US/banks.lang | 4 ++-- htdocs/langs/en_US/projects.lang | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index cd0bd8a90e1..f81e689260c 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -229,7 +229,7 @@ AccountingJournal=Accounting journal NewAccountingJournal=New accounting journal ShowAccoutingJournal=Show accounting journal Nature=Nature -AccountingJournalType1=Various operation +AccountingJournalType1=Miscellaneous operation AccountingJournalType2=Sales AccountingJournalType3=Purchases AccountingJournalType4=Bank diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index d261fe8a53d..caed4498f3b 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -1,8 +1,8 @@ # Dolibarr language file - Source file is en_US - banks Bank=Bank MenuBankCash=Bank/Cash -MenuVariousPayment=Various payments -MenuNewVariousPayment=New various payment +MenuVariousPayment=Miscellaneous payments +MenuNewVariousPayment=New Miscellaneous payment BankName=Bank name FinancialAccount=Account BankAccount=Bank account diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 57406704bf4..e6f38971e01 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -88,7 +88,7 @@ ListShippingAssociatedProject=List of shippings associated with the project 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 various payments associated with the project +ListVariousPaymentsAssociatedProject=List of miscellaneous payments associated with the project ListActionsAssociatedProject=List of events associated with the project ListTaskTimeUserProject=List of time consumed on tasks of project ActivityOnProjectToday=Activity on project today From bc15a0f8e0c65efcce49504c5a08c26edc9b3cf3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 14:50:12 +0200 Subject: [PATCH 062/111] Fix search criteria list --- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/margin/checkMargins.php | 18 +++++++++++------- .../modulebuilder/template/myobject_list.php | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index cb910ef7ae5..54d4022f4bc 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3593,8 +3593,8 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so // Right print ''; - if ($sortfield) $options .= "&sortfield=".$sortfield; - if ($sortorder) $options .= "&sortorder=".$sortorder; + if ($sortfield) $options .= "&sortfield=".$sortfield; + if ($sortorder) $options .= "&sortorder=".$sortorder; // Show navigation bar $pagelist = ''; if ($savlimit != 0 && ($page > 0 || $num > $limit)) diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 5f6f46c4b2b..df44c6e6399 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -34,6 +34,13 @@ $langs->load("bills"); $langs->load("products"); $langs->load("margins"); +$action = GETPOST('action','alpha'); +$massaction = GETPOST('massaction','alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'margindetail'; // To manage different context of search +$backtopage = GETPOST('backtopage'); +$optioncss = GETPOST('optioncss','alpha'); + // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); @@ -143,13 +150,10 @@ llxHeader('', $title); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if (! empty($startdate)) { - $param .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); -} -if (! empty($enddate)) { - $param .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); -} -if ($optioncss != '') $param.='&optioncss='.$optioncss; +if ($search_ref != '') $param.='&search_ref='.urlencode($search_ref); +if (! empty($startdate)) $param .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); +if (! empty($enddate)) $param .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); +if ($optioncss != '') $param.='&optioncss='.$optioncss; // Show tabs $head = marges_prepare_head($user); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index e034fae2cf6..918b527a57c 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -67,10 +67,10 @@ $confirm = GETPOST('confirm','alpha'); $cancel = GETPOST('cancel', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage','alpha'); +$optioncss = GETPOST('optioncss','aZ'); $id = GETPOST('id','int'); -$backtopage = GETPOST('backtopage'); -$optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; From c9c91193decd42a8201544f11d94966af09abb68 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 14:56:56 +0200 Subject: [PATCH 063/111] Code comment --- htdocs/modulebuilder/template/myobject_list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 918b527a57c..b89491b5d48 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -60,15 +60,15 @@ dol_include_once('/mymodule/class/myobject.class.php'); // Load traductions files requiredby by page $langs->loadLangs(array("mymodule@mymodule","other")); -$action = GETPOST('action','alpha'); -$massaction = GETPOST('massaction','alpha'); -$show_files = GETPOST('show_files','int'); -$confirm = GETPOST('confirm','alpha'); -$cancel = GETPOST('cancel', 'alpha'); -$toselect = GETPOST('toselect', 'array'); +$action = GETPOST('action','alpha'); // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm','alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // To manage different context of search -$backtopage = GETPOST('backtopage','alpha'); -$optioncss = GETPOST('optioncss','aZ'); +$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id','int'); From 85cad6d5372e81730e74d7f7750ef1840b861ad1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 15:10:51 +0200 Subject: [PATCH 064/111] Add TODO --- htdocs/accountancy/journal/bankjournal.php | 8 ++++---- .../journal/expensereportsjournal.php | 5 +++-- htdocs/accountancy/journal/purchasesjournal.php | 17 +++++++++-------- htdocs/accountancy/journal/sellsjournal.php | 17 +++++++++-------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 6e44ab633d2..b16cca0eaf9 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -770,7 +770,7 @@ if (empty($action) || $action == 'view') { $obj=$db->fetch_object($resql); if ($obj->nb > 0) { - print img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); + print '
'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); print ' : '.$langs->trans("AccountancyAreaDescBank", 9, ''.$langs->transnoentitiesnoconv("MenuBankCash").''); } } @@ -781,14 +781,14 @@ if (empty($action) || $action == 'view') { if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' || empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1' || empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { - print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print '
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } print '
'; - print ''; - print ''; + print ''; + print ''; print '
'; // TODO Avoid using js. We can use a direct link with $param diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 6d53860dd61..f5832e8215e 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -518,11 +518,12 @@ if (empty($action) || $action == 'view') { print ''; } else { - print ''; + print ''; } - //print ''; + //print ''; print '
'; + // TODO Avoid using js. We can use a direct link with $param print ' '; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 8847f59c63a..c5cd4f53910 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -559,22 +559,23 @@ if (empty($action) || $action == 'view') { print ''; } else { - print ''; + print ''; } - print ''; + print ''; print ''; + // TODO Avoid using js. We can use a direct link with $param print ' '; From dc61c53d39684183f712eb1a97137c22ad3594c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 15:22:23 +0200 Subject: [PATCH 065/111] Balance automatically set on good year according to fiscal start month --- htdocs/accountancy/bookkeeping/balance.php | 25 ++++++++++++++++------ htdocs/accountancy/journal/bankjournal.php | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 50f9e18fd80..c6d0d5cf40e 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -28,7 +28,9 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; @@ -51,9 +53,8 @@ if ($search_accountancy_code_end == - 1) { $search_accountancy_code_end = ''; } -if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv.x") || GETPOST("button_export_csv")) { - $action = 'export_csv'; -} +if (GETPOST("exportcsv")) $action = 'export_csv'; + $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -66,8 +67,18 @@ $formother = new FormOther($db); $form = new Form($db); if (empty($search_date_start)) { - $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); - $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); + + $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $year_start = dol_print_date(dol_now(), '%Y'); + $year_end = $year_start + 1; + $month_end = $month_start - 1; + if ($month_end < 1) + { + $month_end = 12; + $year_end--; + } + $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); + $search_date_end = dol_get_last_day($year_end, $month_end); } if ($sortorder == "") $sortorder = "ASC"; @@ -136,7 +147,7 @@ if ($action == 'export_csv') { } else { - $title_page = $langs->trans("AccountBalance") . (($search_date_start || $search_date_end) ? ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end) : ''); + $title_page = $langs->trans("AccountBalance"); llxHeader('', $title_page); @@ -156,7 +167,7 @@ else { print '
'; - $button = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; + $button = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); $moreforfilter = ''; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index b16cca0eaf9..43538f28254 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -68,6 +68,7 @@ $in_bookkeeping = GETPOST('in_bookkeeping','aZ09'); if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; $now = dol_now(); + $action = GETPOST('action','aZ09'); // Security check From c5bf5c7e67d8623026a1a3131de7891b4e3acfc2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 15:26:44 +0200 Subject: [PATCH 066/111] Minor fixes --- htdocs/accountancy/journal/bankjournal.php | 12 ++++++------ htdocs/accountancy/journal/expensereportsjournal.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 43538f28254..bfa0c342245 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -797,15 +797,15 @@ if (empty($action) || $action == 'view') { '; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index f5832e8215e..f5ad584399e 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -510,7 +510,7 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { - print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print '
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } print '
'; From 71ce82b6b92d24d09d40d534fe871f79437d99f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 16:51:10 +0200 Subject: [PATCH 067/111] NEW Better autoselect customer or supplier fields to save clicks --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/societe/card.php | 4 ++-- htdocs/supplier_proposal/card.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index e8391a066fa..d2f7baab55a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1376,7 +1376,7 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").''; print ''; } print '' . "\n"; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 03c91b69710..156b5efd526 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1492,7 +1492,7 @@ if ($action == 'create' && $user->rights->commande->creer) }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").''; print ''; } print '' . "\n"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index de549889a91..1955ad44276 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2256,7 +2256,7 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").''; print ''; } print '' . "\n"; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 07e551fcd71..a9a8255d7db 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1459,7 +1459,7 @@ if ($action=='create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").''; } print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 1b78d7e399b..fa337bc73ca 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1487,7 +1487,7 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").''; } print ''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 25526b79918..bc51fb39375 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1044,7 +1044,7 @@ else // Prospect/Customer print ''.fieldLabel('ProspectCustomer','customerprospect',1).''; print ''; - $selected=isset($_POST['client'])?GETPOST('client'):$object->client; + $selected=GETPOST('client','int')!=''?GETPOST('client','int'):$object->client; print ''; @@ -713,7 +713,7 @@ $db->close(); * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return void */ -function fieldList($fieldlist, $obj='', $tabname='', $context='') +function fieldListJournal($fieldlist, $obj='', $tabname='', $context='') { global $conf,$langs,$db; global $form, $mysoc; From d340ce63801f4625350eae73962e110f59d7833e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 19:55:33 +0200 Subject: [PATCH 078/111] Fix bugs --- htdocs/core/lib/payments.lib.php | 11 ++++++----- .../mailinglist_mymodule_myobject.modules.php | 9 ++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 49a1e909d91..7caac7a9452 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -103,10 +103,10 @@ function showOnlinePaymentUrl($type,$ref) $langs->load("paybox"); $servicename='Online'; - $out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'
'; - $url=getOnlinePaymentUrl(0,$type,$ref); - $out.=''; - $out.=ajax_autoselect("onlinepaymenturl", 0); + $out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'
'; + $url = getOnlinePaymentUrl(0,$type,$ref); + $out.= ''; + $out.= ajax_autoselect("onlinepaymenturl", 0); return $out; } @@ -126,6 +126,7 @@ function getOnlinePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f global $conf; $ref=str_replace(' ','',$ref); + $out=''; if ($type == 'free') { @@ -210,7 +211,7 @@ function getOnlinePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f } // For multicompany - $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities return $out; } diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index b3f2a36efab..cd8612cb7d1 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -42,7 +42,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets $this->db=$db; if (is_array($conf->modules)) { - $this->enabled=in_array('mymodule',$conf->modules); + $this->enabled=in_array('mymodule',$conf->modules)?1:0; } } @@ -186,15 +186,14 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets * * @param string $filter Filter * @param string $option Options - * @return int Nb of recipients + * @return int Nb of recipients or -1 if KO */ function getNbOfRecipients($filter=1,$option='') { $a=parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"); - if ($a < 0 || $b < 0) return -1; - if ($option == '') return $a; - return ($a+$b); + if ($a < 0) return -1; + return $a; } } From 1a056d29d254930de1fac6b26a4aec2414234591 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 21:02:18 +0200 Subject: [PATCH 079/111] Debug search on dolistore --- .../admin/dolistore/class/dolistore.class.php | 275 +++++++++--------- htdocs/admin/dolistore/css/dolistore.css | 5 +- htdocs/admin/modules.php | 48 +-- htdocs/langs/en_US/admin.lang | 5 +- 4 files changed, 173 insertions(+), 160 deletions(-) diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 0c5a7f08568..18fa6e17e14 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -20,145 +20,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php'; - -/** - * Class DolistoreModel - */ -class DolistoreModel -{ - - function get_categories($parent = 0) - { - if (!isset($this->categories)) die('not possible'); - if ($parent != 0) { - $html = '
'; - + print '
'; /* @@ -409,7 +409,7 @@ if ($result > 0) // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'supplier_payment',$socid,0,'listaction'.($genallowed?'largetitle':'')); + $somethingshown = $formactions->showactions($object,'supplier_payment',$socid,1,'listaction'.($genallowed?'largetitle':'')); print '
'; //print ''; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 84ed3e28ca5..8aa6cc3ad9a 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -505,7 +505,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'myobject', $socid); + $somethingshown = $formactions->showactions($object, 'myobject', $socid, 1); print ''; } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 5506bad0fbb..c5eca27b348 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -487,7 +487,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'order', $socid); + $somethingshown = $formactions->showactions($object, 'order', $socid, 1); print ''; } diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 8e506b5d454..3c21d9e0ced 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -184,7 +184,7 @@ if (!empty($object->id)) // List of actions on element /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'project',0);*/ + $somethingshown = $formactions->showactions($object,'project',0);*/ // List of todo actions //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 336b8c64431..04d0a09a804 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1806,7 +1806,7 @@ if ($action == 'create') // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'supplier_proposal', $socid); + $somethingshown = $formactions->showactions($object, 'supplier_proposal', $socid, 1); print ''; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ca60060c438..0eac875046b 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2538,7 +2538,7 @@ else // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'user', $socid); + $somethingshown = $formactions->showactions($object, 'user', $socid, 1); print ''; diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index a32db37d3fb..678bd9f0ec2 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -517,7 +517,7 @@ else // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'usergroup', $socid); + $somethingshown = $formactions->showactions($object, 'usergroup', $socid, 1); print ''; From e11c7a08ea5dbdc204b87946da1e5f67517582f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 14:24:03 +0200 Subject: [PATCH 081/111] Fix translation --- htdocs/langs/en_US/stocks.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 81945b17f85..f2115666a36 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -55,7 +55,7 @@ IndependantSubProductStock=Product stock and subproduct stock are independant QtyDispatched=Quantity dispatched QtyDispatchedShort=Qty dispatched QtyToDispatchShort=Qty to dispatch -OrderDispatch=Goods Receptions +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 From 7767ac2aa7cd632ad550249b8f082a5baa6ff668 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 15:12:54 +0200 Subject: [PATCH 082/111] FIX Several problem with the last event box on project/tasks --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 4 ++- htdocs/core/class/html.formactions.class.php | 30 ++++++++++++++----- htdocs/core/lib/functions2.lib.php | 9 ++++-- ...terface_50_modAgenda_ActionsAuto.class.php | 5 +++- htdocs/langs/en_US/main.lang | 1 + htdocs/projet/card.php | 4 +++ htdocs/projet/tasks/task.php | 5 ++++ 8 files changed, 48 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c2dbdd46ed6..7b1c81af59c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -670,7 +670,7 @@ if ($action == 'create') } // Title - print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Title").''; + print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Label").''; // Full day print ''.$langs->trans("EventOnFullDay").''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 72d3081aca3..c337616ed41 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -860,9 +860,10 @@ class ActionComm extends CommonObject * @param string $filter Other filter * @param string $sortfield Sort on this field * @param string $sortorder ASC or DESC + * @param string $limit Limit number of answers * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='', $sortorder='') + static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='datep', $sortorder='DESC', $limit=0) { global $conf, $langs; @@ -879,6 +880,7 @@ class ActionComm extends CommonObject } if (! empty($filter)) $sql.= $filter; if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); + if ($limit) $sql.=$db->plimit($limit); dol_syslog(get_class()."::getActions", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index dccde65c9c3..15a9b781290 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -155,16 +155,18 @@ class FormActions * @param int $socid socid of user * @param int $forceshowtitle Show title even if there is no actions to show * @param string $morecss More css on table + * @param int $max Max number of record + * @param string $moreparambacktopage More param for the backtopage * @return int <0 if KO, >=0 if OK */ - function showactions($object,$typeelement,$socid=0,$forceshowtitle=0,$morecss='listactions') + function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='') { global $langs,$conf,$user; global $bc; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement); + $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', '', '', ($max?($max+1):0)); if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); $num = count($listofactions); @@ -177,12 +179,15 @@ class FormActions elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'project') $title=$langs->trans('ActionsOnProject'); elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); - else $title=$langs->trans("Actions"); + elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + else $title=$langs->trans("Actions"); - $buttontoaddnewevent = '
'; + $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); + + $buttontoaddnewevent = ''; $buttontoaddnewevent.= $langs->trans("AddEvent"); $buttontoaddnewevent.= ''; print load_fiche_titre($title, $buttontoaddnewevent, ''); @@ -197,7 +202,7 @@ class FormActions print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Action', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, 'align="center"'); print_liste_field_titre('By', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('', $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"'); print ''; @@ -205,8 +210,11 @@ class FormActions $userstatic = new User($this->db); + $cursorevent = 0; foreach($listofactions as $action) { + if ($max && $cursorevent >= $max) break; + $ref=$action->getNomUrl(1,-1); $label=$action->getNomUrl(0,38); @@ -226,7 +234,7 @@ class FormActions } print $action->type; print ''; - print ''.dol_print_date($action->datep,'dayhour'); + print ''.dol_print_date($action->datep,'dayhour'); if ($action->datef) { $tmpa=dol_getdate($action->datep); @@ -254,7 +262,15 @@ class FormActions } print ''; print ''; + + $cursorevent++; } + + if ($max && $num > $max) + { + print ''.$langs->trans("More").'...'; + } + print ''; print ''; } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 9d3e6ee1b63..f8a073d5fa9 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1808,6 +1808,11 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') $module='ficheinter'; $subelement='fichinter'; } + if ($objecttype == 'task') { + $classpath = 'projet/class'; + $module='projet'; + $subelement='task'; + } //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; @@ -2243,7 +2248,7 @@ function getModuleDirForApiClass($module) /* * Return 2 hexa code randomly - * + * * @param $min int Between 0 and 255 * @param $max int Between 0 and 255 * @return String @@ -2254,7 +2259,7 @@ function random_color_part($min=0,$max=255) { /* * Return hexadecimal color randomly - * + * * @param $min int Between 0 and 255 * @param $max int Between 0 and 255 * @return String diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 751a5fa1361..4e09fef4d43 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -747,6 +747,9 @@ class InterfaceActionsAuto extends DolibarrTriggers // Set societeforaction. if ($object->socid > 0) $societeforaction->fetch($object->socid); + $projectid = isset($object->fk_project)?$object->fk_project:0; + if ($object->element == 'project') $projectid = $object->id; + // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); @@ -754,7 +757,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; // TODO Replace with $actioncomm->email_msgid ? $object->email_content : $object->actionmsg - $actioncomm->fk_project = isset($object->fk_project)?$object->fk_project:0; + $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index e9d3b0ec141..e7171fb94b1 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -410,6 +410,7 @@ ActionRunningNotStarted=To start ActionRunningShort=In progress ActionDoneShort=Finished ActionUncomplete=Uncomplete +LatestLinkedEvents=Latest %s linked events CompanyFoundation=Company/Organisation ContactsForCompany=Contacts for this third party ContactsAddressesForCompany=Contacts/addresses for this third party diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 73f0c06bf1e..085af055f38 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1198,6 +1198,10 @@ elseif ($object->id > 0) print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'project', $socid, 1, '', 10); print '
'; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index a04a4573aea..1b43940029f 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -588,6 +588,11 @@ if ($id > 0 || ! empty($ref)) print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'task', $socid, 1, '', 10, 'withproject='.$withproject); + print '
'; } } From c44a5ede43ae14be12714d798b38a60d706d6e36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 15:12:54 +0200 Subject: [PATCH 083/111] FIX Several problem with the last event box on project/tasks Conflicts: htdocs/core/lib/functions2.lib.php --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 4 ++- htdocs/core/class/html.formactions.class.php | 30 ++++++++++++++----- htdocs/core/lib/functions2.lib.php | 6 ++++ ...terface_50_modAgenda_ActionsAuto.class.php | 5 +++- htdocs/langs/en_US/main.lang | 1 + htdocs/projet/card.php | 4 +++ htdocs/projet/tasks/task.php | 5 ++++ 8 files changed, 47 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c2dbdd46ed6..7b1c81af59c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -670,7 +670,7 @@ if ($action == 'create') } // Title - print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Title").''; + print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Label").''; // Full day print ''.$langs->trans("EventOnFullDay").''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 84e75e06cbd..6dd3cbb4f84 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -860,9 +860,10 @@ class ActionComm extends CommonObject * @param string $filter Other filter * @param string $sortfield Sort on this field * @param string $sortorder ASC or DESC + * @param string $limit Limit number of answers * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='', $sortorder='') + static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='datep', $sortorder='DESC', $limit=0) { global $conf, $langs; @@ -879,6 +880,7 @@ class ActionComm extends CommonObject } if (! empty($filter)) $sql.= $filter; if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); + if ($limit) $sql.=$db->plimit($limit); dol_syslog(get_class()."::getActions", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 7b312ea784a..785ada1429c 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -155,16 +155,18 @@ class FormActions * @param int $socid socid of user * @param int $forceshowtitle Show title even if there is no actions to show * @param string $morecss More css on table + * @param int $max Max number of record + * @param string $moreparambacktopage More param for the backtopage * @return int <0 if KO, >=0 if OK */ - function showactions($object,$typeelement,$socid=0,$forceshowtitle=0,$morecss='listactions') + function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='') { global $langs,$conf,$user; global $bc; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement); + $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', '', '', ($max?($max+1):0)); if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); $num = count($listofactions); @@ -177,12 +179,15 @@ class FormActions elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'project') $title=$langs->trans('ActionsOnProject'); elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); - else $title=$langs->trans("Actions"); + elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + else $title=$langs->trans("Actions"); - $buttontoaddnewevent = ''; + $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); + + $buttontoaddnewevent = ''; $buttontoaddnewevent.= $langs->trans("AddEvent"); $buttontoaddnewevent.= ''; print load_fiche_titre($title, $buttontoaddnewevent, ''); @@ -197,7 +202,7 @@ class FormActions print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Action', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, 'align="center"'); print_liste_field_titre('By', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('', $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"'); print ''; @@ -205,8 +210,11 @@ class FormActions $userstatic = new User($this->db); + $cursorevent = 0; foreach($listofactions as $action) { + if ($max && $cursorevent >= $max) break; + $ref=$action->getNomUrl(1,-1); $label=$action->getNomUrl(0,38); @@ -226,7 +234,7 @@ class FormActions } print $action->type; print ''; - print ''.dol_print_date($action->datep,'dayhour'); + print ''.dol_print_date($action->datep,'dayhour'); if ($action->datef) { $tmpa=dol_getdate($action->datep); @@ -254,7 +262,15 @@ class FormActions } print ''; print ''; + + $cursorevent++; } + + if ($max && $num > $max) + { + print ''.$langs->trans("More").'...'; + } + print ''; print ''; } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 181e8a7fe11..54bf70981b7 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1780,6 +1780,11 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') $module='ficheinter'; $subelement='fichinter'; } + if ($objecttype == 'task') { + $classpath = 'projet/class'; + $module='projet'; + $subelement='task'; + } //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; @@ -2212,3 +2217,4 @@ function getModuleDirForApiClass($module) return $moduledirforclass; } + diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 751a5fa1361..4e09fef4d43 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -747,6 +747,9 @@ class InterfaceActionsAuto extends DolibarrTriggers // Set societeforaction. if ($object->socid > 0) $societeforaction->fetch($object->socid); + $projectid = isset($object->fk_project)?$object->fk_project:0; + if ($object->element == 'project') $projectid = $object->id; + // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); @@ -754,7 +757,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; // TODO Replace with $actioncomm->email_msgid ? $object->email_content : $object->actionmsg - $actioncomm->fk_project = isset($object->fk_project)?$object->fk_project:0; + $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a314f59b6b5..02f3f80982e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -406,6 +406,7 @@ ActionRunningNotStarted=To start ActionRunningShort=In progress ActionDoneShort=Finished ActionUncomplete=Uncomplete +LatestLinkedEvents=Latest %s linked events CompanyFoundation=Company/Organisation ContactsForCompany=Contacts for this third party ContactsAddressesForCompany=Contacts/addresses for this third party diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index b8528e9863c..849ea5cd47d 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1198,6 +1198,10 @@ elseif ($object->id > 0) print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'project', $socid, 1, '', 10); print '
'; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index a04a4573aea..1b43940029f 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -588,6 +588,11 @@ if ($id > 0 || ! empty($ref)) print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'task', $socid, 1, '', 10, 'withproject='.$withproject); + print '
'; } } From 3deacaa5c47e53b9c3509f2979cff7c92191c1f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 17:10:04 +0200 Subject: [PATCH 084/111] Fix css pb --- htdocs/theme/eldy/style.css.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index e6e49dcc85c..32032ba583b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -441,9 +441,10 @@ hr { border: 0; border-top: 1px solid #ccc; } box-shadow: 0px 0px 6px 1px rgba(0, 0, 60, 0.2), 0px 0px 0px rgba(60,60,60,0.1); } .button:hover, .buttonDelete:hover { - -moz-box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); - -webkit-box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); - box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); + /* warning: having a larger shadow has side effect when button is completely on left of a table */ + -moz-box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); + -webkit-box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); + box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); } .button:disabled, .buttonDelete:disabled { opacity: 0.4; From 58b49f9a080bb58a64a6a2c13814dbb407d226df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 17:10:23 +0200 Subject: [PATCH 085/111] Fix position of field to avoid errors --- htdocs/compta/paiement.php | 54 ++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 37b23c03724..7a494113090 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -585,11 +585,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyAmountTTC').''; if (!empty($conf->multicurrency->enabled)) print ''.$multicurrencyalreadypayedlabel.''; if (!empty($conf->multicurrency->enabled)) print ''.$multicurrencyremaindertopay.''; + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyPaymentAmount').''; print ''.$langs->trans('AmountTTC').''; print ''.$alreadypayedlabel.''; print ''.$remaindertopay.''; print ''.$langs->trans('PaymentAmount').''; - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyPaymentAmount').''; print ' '; print "\n"; @@ -659,6 +659,29 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); print ''; + + print ''; + + // Add remind multicurrency amount + $namef = 'multicurrency_amount_'.$objp->facid; + $nameRemain = 'multicurrency_remain_'.$objp->facid; + + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + { + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + print ''; + print ''; + } + else + { + print ''; + print ''; + } + } + print ""; } // Price @@ -695,33 +718,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print ""; - // Multicurrency Price - if (! empty($conf->multicurrency->enabled)) - { - print ''; - - // Add remind multicurrency amount - $namef = 'multicurrency_amount_'.$objp->facid; - $nameRemain = 'multicurrency_remain_'.$objp->facid; - - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { - if ($action != 'add_paiement') - { - if (!empty($conf->use_javascript_ajax)) - print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); - print ''; - print ''; - } - else - { - print ''; - print ''; - } - } - print ""; - } - // Warning print ''; //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
"; @@ -754,6 +750,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($conf->multicurrency->enabled)) print ''; if (!empty($conf->multicurrency->enabled)) print ''; if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) print ''; print ''.price($sign * $total_ttc).''; print ''.price($sign * $totalrecu); if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); @@ -761,7 +758,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).''; print ''; // Autofilled - if (!empty($conf->multicurrency->enabled)) print ''; print ' '; print "\n"; } From 60078300b828e66e41f91bb0e89a3b27d18ef817 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 17:57:41 +0200 Subject: [PATCH 086/111] FIX PDF output was sharing 2 different currencies in same total --- .../commande/doc/pdf_einstein.modules.php | 5 +- .../expedition/doc/pdf_rouget.modules.php | 100 +++++++-------- .../modules/facture/doc/pdf_crabe.modules.php | 23 ++-- .../product/doc/pdf_standard.modules.php | 119 +++++++++--------- .../modules/propale/doc/pdf_azur.modules.php | 3 +- .../pdf/pdf_canelle.modules.php | 23 +++- .../pdf/pdf_muscadet.modules.php | 2 +- 7 files changed, 146 insertions(+), 129 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index c87a66de791..74a72b36581 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -862,6 +862,8 @@ class pdf_einstein extends ModelePDFCommandes // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1035,7 +1037,6 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1048,7 +1049,7 @@ class pdf_einstein extends ModelePDFCommandes //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 3f7a73a650c..8f51e9b9e40 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -84,7 +84,7 @@ class pdf_rouget extends ModelePdfExpedition } $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images - + if ($this->page_largeur < 210) // To work with US executive format { $this->posxweightvol-=20; @@ -92,7 +92,7 @@ class pdf_rouget extends ModelePdfExpedition $this->posxqtyordered-=20; $this->posxqtytoship-=20; } - + if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); @@ -139,17 +139,17 @@ class pdf_rouget extends ModelePdfExpedition if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { $objphoto = new Product($this->db); - + for ($i = 0 ; $i < $nblignes ; $i++) { if (empty($object->lines[$i]->fk_product)) continue; - + $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; - + $realpath=''; foreach ($objphoto->liste_photos($dir,1) as $key => $obj) @@ -169,17 +169,17 @@ class pdf_rouget extends ModelePdfExpedition { $filename=$obj['photo']; } - + $realpath = $dir.$filename; break; } - + if ($realpath) $realpatharray[$i]=$realpath; } } - - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; - + + if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; + if ($conf->expedition->dir_output) { // Definition de $dir et $file @@ -219,7 +219,7 @@ class pdf_rouget extends ModelePdfExpedition // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); - + $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); $heightforinfotot = 8; // Height reserved to output the info and total part @@ -282,11 +282,11 @@ class pdf_rouget extends ModelePdfExpedition $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - + // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - + $tab_top = $nexY+6; $height_incoterms += 4; } @@ -343,7 +343,7 @@ class pdf_rouget extends ModelePdfExpedition // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - + $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } @@ -400,7 +400,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->startTransaction(); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); - + $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -434,10 +434,10 @@ class pdf_rouget extends ModelePdfExpedition $pdf->commitTransaction(); } $posYAfterDescription=$pdf->GetY(); - + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); - + $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. @@ -456,29 +456,29 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxweightvol, $curY); $weighttxt=''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); } $voltxt=''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); } - + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $curY); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); } - + $pdf->SetXY($this->posxqtytoship, $curY); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C'); - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $curY); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); @@ -489,7 +489,7 @@ class pdf_rouget extends ModelePdfExpedition $nexY+=3; if ($weighttxt && $voltxt) $nexY+=2; - + // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) { @@ -548,7 +548,7 @@ class pdf_rouget extends ModelePdfExpedition } // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); @@ -612,7 +612,7 @@ class pdf_rouget extends ModelePdfExpedition }*/ if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - + $useborder=0; $index = 0; @@ -626,12 +626,12 @@ class pdf_rouget extends ModelePdfExpedition $totalOrdered=$tmparray['ordered']; $totalToShip=$tmparray['toship']; // Set trueVolume and volume_units not currently stored into database - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); $object->volume_units=$object->size_units * 3; } - + if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); @@ -640,48 +640,48 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); } - + $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); - + $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); } - + // Total Weight if ($totalWeighttoshow) { $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); - + $index++; } if ($totalVolumetoshow) { $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); - + $index++; } if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; - + $pdf->SetTextColor(0,0,0); return ($tab2_top + ($tab2_hl * $index)); } - + /** * Show table for lines * @@ -728,7 +728,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxweightvol-1, $tab_top+1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); } - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); @@ -738,14 +738,14 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); } } - + $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxqtytoship, $tab_top+1); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C'); } - + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); @@ -754,7 +754,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxpuht-1, $tab_top+1); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); } - + $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -763,7 +763,7 @@ class pdf_rouget extends ModelePdfExpedition } } - + } /** @@ -780,7 +780,7 @@ class pdf_rouget extends ModelePdfExpedition global $conf,$langs,$mysoc; $langs->load("orders"); - + $default_font_size = pdf_getPDFFontSize($outputlangs); pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); @@ -796,7 +796,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('','B', $default_font_size + 3); $w = 110; - + $posy=$this->marge_haute; $posx=$this->page_largeur-$this->marge_droite-$w; @@ -863,7 +863,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('','', $default_font_size + 1); $posy+=5; - + $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); @@ -876,7 +876,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); } - + if (! empty($object->thirdparty->code_client)) { $posy+=4; @@ -904,7 +904,7 @@ class pdf_rouget extends ModelePdfExpedition if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects - + $pdf->SetFont('','', $default_font_size - 2); $text=$linkedobject->ref; if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; @@ -939,7 +939,7 @@ class pdf_rouget extends ModelePdfExpedition $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; - + // Show sender frame $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -950,7 +950,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0,0,60); $pdf->SetFillColor(255,255,255); - + // Show sender name $pdf->SetXY($posx+2,$posy+3); $pdf->SetFont('','B',$default_font_size); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index c473740a05d..338a6019b56 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -214,9 +214,9 @@ class pdf_crabe extends ModelePDFFactures { $object->fetch_thirdparty(); - $deja_regle = $object->getSommePaiement(); - $amount_credit_notes_included = $object->getSumCreditNotesUsed(); - $amount_deposits_included = $object->getSumDepositsUsed(); + $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Definition of $dir and $file if ($object->specimen) @@ -771,7 +771,7 @@ class pdf_crabe extends ModelePDFFactures // Loop on each deposits and credit notes included - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,"; $sql.= " re.description, re.fk_facture_source,"; $sql.= " f.type, f.datef"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; @@ -796,7 +796,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); + $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $pdf->MultiCell(20, 3, $text, 0, 'L', 0); $pdf->SetXY($tab3_posx+58, $tab3_top+$y); @@ -815,7 +815,7 @@ class pdf_crabe extends ModelePDFFactures // Loop on each payment // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql - $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount,"; + $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; @@ -835,7 +835,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0); + $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); @@ -1060,6 +1060,8 @@ class pdf_crabe extends ModelePDFFactures // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1270,7 +1272,6 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1278,10 +1279,10 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,0); - $creditnoteamount=$object->getSumCreditNotesUsed(); - $depositsamount=$object->getSumDepositsUsed(); + $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if ($object->paye) $resteapayer=0; if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 29df1127242..2ceca5791a8 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -40,28 +40,28 @@ class pdf_standard extends ModelePDFProduct * @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.3 = array(5, 3) */ - public $phpmin = array(5, 2); - + public $phpmin = array(5, 2); + /** * Dolibarr version of the loaded document * @public string @@ -77,7 +77,7 @@ class pdf_standard extends ModelePDFProduct public $marge_basse; public $emetteur; // Objet societe qui emet - + /** * Constructor @@ -105,7 +105,7 @@ class pdf_standard extends ModelePDFProduct $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - + $this->option_logo = 1; // Affiche logo $this->option_codeproduitservice = 0; // Affiche code produit-service $this->option_multilang = 1; // Dispo en plusieurs langues @@ -145,7 +145,7 @@ class pdf_standard extends ModelePDFProduct $outputlangs->load("deliveries"); $nblignes = count($object->lines); - + if ($conf->produit->dir_output) { // Definition of $dir and $file @@ -160,7 +160,7 @@ class pdf_standard extends ModelePDFProduct $dir = $conf->produit->dir_output . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } - + $productFournisseur = new ProductFournisseur($this->db); $supplierprices = $productFournisseur->list_product_fournisseur_price($object->id); $object->supplierprices = $supplierprices; @@ -191,11 +191,11 @@ class pdf_standard extends ModelePDFProduct $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -242,7 +242,7 @@ class pdf_standard extends ModelePDFProduct $pdf->SetFont('','B', $default_font_size); $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->label), 0, 1); $nexY = $pdf->GetY(); - + $pdf->SetFont('','', $default_font_size); $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, dol_htmlentitiesbr($object->description), 0, 1); $nexY = $pdf->GetY(); @@ -270,7 +270,7 @@ class pdf_standard extends ModelePDFProduct $nexY = $pdf->GetY(); } - + // Affiche notes // TODO There is no public note on product yet $notetoshow=empty($object->note_public)?'':$object->note_public; @@ -424,7 +424,7 @@ class pdf_standard extends ModelePDFProduct // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; else $tvaligne=$object->lines[$i]->total_tva; - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; @@ -518,13 +518,10 @@ class pdf_standard extends ModelePDFProduct $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } */ - + // Affiche zone infos //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - // Affiche zone totaux - //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); - // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); @@ -557,7 +554,7 @@ class pdf_standard extends ModelePDFProduct } } - + /** * Show table for lines * @@ -574,42 +571,42 @@ class pdf_standard extends ModelePDFProduct function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') { global $conf; - + // Force to disable hidetop and hidebottom $hidebottom=0; if ($hidetop) $hidetop=-1; - + $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); - + // Amount in (at tab_top - 1) $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); - + if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); - + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } - + $pdf->SetDrawColor(128,128,128); $pdf->SetFont('','', $default_font_size - 1); - + // Output Rect $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param - + if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param - + $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); } - + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); @@ -619,14 +616,14 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); } } - + $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxup-1, $tab_top+1); $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); } - + $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -640,7 +637,7 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); } } - + if($conf->global->PRODUCT_USE_UNITS) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -649,7 +646,7 @@ class pdf_standard extends ModelePDFProduct 'C'); } } - + $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -659,7 +656,7 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); } } - + if ($this->atleastonediscount) { $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); @@ -670,7 +667,7 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C'); } } - + /** * Show top header of page. * @@ -684,33 +681,33 @@ class pdf_standard extends ModelePDFProduct function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") { global $conf,$langs,$hookmanager; - + $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'; else $titlekey='ProductSheet'; - + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); - + // Show Draft Watermark if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) { pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); } - + $pdf->SetTextColor(0,0,60); $pdf->SetFont('','B', $default_font_size + 3); - + $posy=$this->marge_haute; $posx=$this->page_largeur-$this->marge_droite-100; - + $pdf->SetXY($this->marge_gauche,$posy); - + // Logo $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) @@ -733,23 +730,23 @@ class pdf_standard extends ModelePDFProduct $text=$this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } - + $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $title=$outputlangs->transnoentities($titlekey); $pdf->MultiCell(100, 3, $title, '', 'R'); - + $pdf->SetFont('','B',$default_font_size); - + $posy+=5; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); - + $posy+=1; $pdf->SetFont('','', $default_font_size - 1); - + /*if ($object->ref_client) { $posy+=5; @@ -757,13 +754,13 @@ class pdf_standard extends ModelePDFProduct $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); }*/ - + /*$posy+=4; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); */ - + // Get contact /* if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) @@ -779,24 +776,24 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } }*/ - + $posy+=2; - + // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); - + if ($showaddress) { /* // Sender properties $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); - + // Show sender $posy=42; $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; $hautcadre=40; - + // Show sender frame $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -806,23 +803,23 @@ class pdf_standard extends ModelePDFProduct $pdf->SetFillColor(230,230,230); $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0,0,60); - + // Show sender name $pdf->SetXY($posx+2,$posy+3); $pdf->SetFont('','B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); $posy=$pdf->getY(); - + // Show sender information $pdf->SetXY($posx+2,$posy); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); */ } - + $pdf->SetTextColor(0,0,0); } - + /** * Show footer of page. Need this->emetteur object * @@ -838,6 +835,6 @@ class pdf_standard extends ModelePDFProduct $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } - + } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 9a928a7ce2b..8b9929f2880 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1010,6 +1010,8 @@ class pdf_azur extends ModelePDFPropales // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1186,7 +1188,6 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } 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 8737c39f67f..b488252f77c 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -717,6 +717,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $useborder=0; + // Total TTC $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0,0,60); @@ -727,6 +728,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); + $creditnoteamount=0; + $depositsamount=0; + //$creditnoteamount=$object->getSumCreditNotesUsed(); + //$depositsamount=$object->getSumDepositsUsed(); + //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + if (! empty($object->paye)) $resteapayer=0; + if ($deja_regle > 0) { $index++; @@ -743,7 +752,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); $pdf->SetFont('','', $default_font_size - 1); $pdf->SetTextColor(0,0,0); } @@ -877,6 +886,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices */ function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { + global $conf; + + $sign=1; + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $tab3_posx = 120; $tab3_top = $posy + 8; $tab3_width = 80; @@ -910,8 +924,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('','', $default_font_size - 4); + // Loop on each deposits and credit notes included + // + // Loop on each payment - $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,"; + $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; @@ -929,7 +946,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0); + $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); 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 8380ff65e9a..78ecb9d52c2 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -840,7 +840,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) From e0eef2080e2340a1f6c81651bb38be23df10f350 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 17:57:41 +0200 Subject: [PATCH 087/111] FIX PDF output was sharing 2 different currencies in same total Conflicts: htdocs/core/modules/commande/doc/pdf_einstein.modules.php htdocs/core/modules/facture/doc/pdf_crabe.modules.php htdocs/core/modules/product/doc/pdf_standard.modules.php htdocs/core/modules/propale/doc/pdf_azur.modules.php --- .../commande/doc/pdf_einstein.modules.php | 21 ++-- .../expedition/doc/pdf_rouget.modules.php | 100 +++++++++--------- .../modules/facture/doc/pdf_crabe.modules.php | 69 ++++++------ .../modules/propale/doc/pdf_azur.modules.php | 25 ++--- .../pdf/pdf_canelle.modules.php | 23 +++- .../pdf/pdf_muscadet.modules.php | 2 +- 6 files changed, 130 insertions(+), 110 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 54c1f546903..e8dee5b8068 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -216,11 +216,11 @@ class pdf_einstein extends ModelePDFCommandes $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -293,16 +293,16 @@ class pdf_einstein extends ModelePDFCommandes $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - + // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - + $tab_top = $nexY+6; $height_incoterms += 4; } } - + // Affiche notes $notetoshow=empty($object->note_public)?'':$object->note_public; if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) @@ -454,7 +454,7 @@ class pdf_einstein extends ModelePDFCommandes // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; else $tvaligne=$object->lines[$i]->total_tva; - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; @@ -561,7 +561,7 @@ class pdf_einstein extends ModelePDFCommandes $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } */ - + // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); @@ -838,6 +838,8 @@ class pdf_einstein extends ModelePDFCommandes // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1011,7 +1013,6 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1024,7 +1025,7 @@ class pdf_einstein extends ModelePDFCommandes //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) @@ -1270,7 +1271,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=2; // Show list of linked objects diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index d1697b767bd..62862e06e11 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -84,7 +84,7 @@ class pdf_rouget extends ModelePdfExpedition } $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images - + if ($this->page_largeur < 210) // To work with US executive format { $this->posxweightvol-=20; @@ -92,7 +92,7 @@ class pdf_rouget extends ModelePdfExpedition $this->posxqtyordered-=20; $this->posxqtytoship-=20; } - + if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); @@ -139,17 +139,17 @@ class pdf_rouget extends ModelePdfExpedition if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { $objphoto = new Product($this->db); - + for ($i = 0 ; $i < $nblignes ; $i++) { if (empty($object->lines[$i]->fk_product)) continue; - + $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; - + $realpath=''; foreach ($objphoto->liste_photos($dir,1) as $key => $obj) @@ -169,17 +169,17 @@ class pdf_rouget extends ModelePdfExpedition { $filename=$obj['photo']; } - + $realpath = $dir.$filename; break; } - + if ($realpath) $realpatharray[$i]=$realpath; } } - - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; - + + if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; + if ($conf->expedition->dir_output) { // Definition de $dir et $file @@ -219,7 +219,7 @@ class pdf_rouget extends ModelePdfExpedition // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); - + $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); $heightforinfotot = 8; // Height reserved to output the info and total part @@ -282,11 +282,11 @@ class pdf_rouget extends ModelePdfExpedition $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - + // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - + $tab_top = $nexY+6; $height_incoterms += 4; } @@ -343,7 +343,7 @@ class pdf_rouget extends ModelePdfExpedition // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - + $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } @@ -400,7 +400,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->startTransaction(); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); - + $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -434,10 +434,10 @@ class pdf_rouget extends ModelePdfExpedition $pdf->commitTransaction(); } $posYAfterDescription=$pdf->GetY(); - + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); - + $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. @@ -456,29 +456,29 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxweightvol, $curY); $weighttxt=''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); } $voltxt=''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); } - + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $curY); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); } - + $pdf->SetXY($this->posxqtytoship, $curY); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C'); - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $curY); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); @@ -489,7 +489,7 @@ class pdf_rouget extends ModelePdfExpedition $nexY+=3; if ($weighttxt && $voltxt) $nexY+=2; - + // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) { @@ -548,7 +548,7 @@ class pdf_rouget extends ModelePdfExpedition } // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); @@ -612,7 +612,7 @@ class pdf_rouget extends ModelePdfExpedition }*/ if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - + $useborder=0; $index = 0; @@ -626,12 +626,12 @@ class pdf_rouget extends ModelePdfExpedition $totalOrdered=$tmparray['ordered']; $totalToShip=$tmparray['toship']; // Set trueVolume and volume_units not currently stored into database - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); $object->volume_units=$object->size_units * 3; } - + if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); @@ -640,48 +640,48 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); } - + $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); - + $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); } - + // Total Weight if ($totalWeighttoshow) { $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); - + $index++; } if ($totalVolumetoshow) { $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); - + $index++; } if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; - + $pdf->SetTextColor(0,0,0); return ($tab2_top + ($tab2_hl * $index)); } - + /** * Show table for lines * @@ -728,7 +728,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxweightvol-1, $tab_top+1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); } - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); @@ -738,14 +738,14 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); } } - + $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxqtytoship, $tab_top+1); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C'); } - + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); @@ -754,7 +754,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxpuht-1, $tab_top+1); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); } - + $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -763,7 +763,7 @@ class pdf_rouget extends ModelePdfExpedition } } - + } /** @@ -780,7 +780,7 @@ class pdf_rouget extends ModelePdfExpedition global $conf,$langs,$mysoc; $langs->load("orders"); - + $default_font_size = pdf_getPDFFontSize($outputlangs); pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); @@ -796,7 +796,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('','B', $default_font_size + 3); $w = 110; - + $posy=$this->marge_haute; $posx=$this->page_largeur-$this->marge_droite-$w; @@ -863,7 +863,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('','', $default_font_size + 1); $posy+=5; - + $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); @@ -876,7 +876,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); } - + if (! empty($object->thirdparty->code_client)) { $posy+=4; @@ -904,7 +904,7 @@ class pdf_rouget extends ModelePdfExpedition if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects - + $pdf->SetFont('','', $default_font_size - 2); $text=$linkedobject->ref; if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; @@ -939,7 +939,7 @@ class pdf_rouget extends ModelePdfExpedition $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; - + // Show sender frame $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -950,7 +950,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0,0,60); $pdf->SetFillColor(255,255,255); - + // Show sender name $pdf->SetXY($posx+2,$posy+3); $pdf->SetFont('','B',$default_font_size); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 02d239105b0..be88b7d4114 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -214,9 +214,9 @@ class pdf_crabe extends ModelePDFFactures { $object->fetch_thirdparty(); - $deja_regle = $object->getSommePaiement(); - $amount_credit_notes_included = $object->getSumCreditNotesUsed(); - $amount_deposits_included = $object->getSumDepositsUsed(); + $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Definition of $dir and $file if ($object->specimen) @@ -255,16 +255,16 @@ class pdf_crabe extends ModelePDFFactures // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); $nbpayments = count($object->getListOfPayments()); - + // Create pdf instance $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -509,7 +509,7 @@ class pdf_crabe extends ModelePDFFactures $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); // Enough for 6 chars - + if ($this->situationinvoice) { $pdf->MultiCell($this->posxprogress-$this->posxqty-0.8, 4, $qty, 0, 'R'); @@ -769,9 +769,9 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('','', $default_font_size - 4); - + // Loop on each deposits and credit notes included - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,"; $sql.= " re.description, re.fk_facture_source,"; $sql.= " f.type, f.datef"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; @@ -796,7 +796,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); + $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $pdf->MultiCell(20, 3, $text, 0, 'L', 0); $pdf->SetXY($tab3_posx+58, $tab3_top+$y); @@ -815,14 +815,14 @@ class pdf_crabe extends ModelePDFFactures // Loop on each payment // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql - $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount,"; + $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1"; $sql.= " ORDER BY p.datep"; - + $resql=$this->db->query($sql); if ($resql) { @@ -835,7 +835,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0); + $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); @@ -1052,7 +1052,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - + $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); @@ -1060,6 +1060,8 @@ class pdf_crabe extends ModelePDFFactures // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1071,7 +1073,7 @@ class pdf_crabe extends ModelePDFFactures else { // FIXME amount of vat not supported with multicurrency - + //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ @@ -1141,26 +1143,26 @@ class pdf_crabe extends ModelePDFFactures } //} - + // VAT // Situations totals migth be wrong on huge amounts if ($object->situation_cycle_ref && $object->situation_counter > 1) { - + $sum_pdf_tva = 0; foreach($this->tva as $tvakey => $tvaval){ $sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object } - + if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one) $coef_fix_tva = $object->total_tva / $sum_pdf_tva; - + foreach($this->tva as $tvakey => $tvaval) { $this->tva[$tvakey]=$tvaval * $coef_fix_tva; } } - + } - + foreach($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 @@ -1270,7 +1272,6 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1278,10 +1279,10 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,0); - $creditnoteamount=$object->getSumCreditNotesUsed(); - $depositsamount=$object->getSumDepositsUsed(); + $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if ($object->paye) $resteapayer=0; if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) @@ -1416,7 +1417,7 @@ class pdf_crabe extends ModelePDFFactures if (empty($hidetop)) { $pdf->SetXY($this->posxqty-1, $tab_top+1); - + if($this->situationinvoice) { $pdf->MultiCell($this->posxprogress-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); @@ -1430,14 +1431,14 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); } } - + if ($this->situationinvoice) { $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height); - + if (empty($hidetop)) { - + $pdf->SetXY($this->posxprogress, $tab_top+1); - + if($conf->global->PRODUCT_USE_UNITS) { $pdf->MultiCell($this->posxunit-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); @@ -1450,9 +1451,9 @@ class pdf_crabe extends ModelePDFFactures { $pdf->MultiCell($this->postotalht-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); } - + } - + } if($conf->global->PRODUCT_USE_UNITS) { @@ -1617,7 +1618,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax,"day",false,$outputlangs), '', 'R'); } - + if ($object->type != 2) { $posy+=3; @@ -1648,7 +1649,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($w, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=1; // Show list of linked objects diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index d2ecfb60d81..54f3a4e351e 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -273,7 +273,7 @@ class pdf_azur extends ModelePDFPropales $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -322,19 +322,19 @@ class pdf_azur extends ModelePDFPropales $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0; $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; - + //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); - + $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); $tab_height = 130; @@ -383,7 +383,7 @@ class pdf_azur extends ModelePDFPropales $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs); if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email; if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone; - } + } if ($notetoshow) { $tab_top = 88 + $height_incoterms; @@ -552,14 +552,14 @@ class pdf_azur extends ModelePDFPropales // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; else $tvaligne=$object->lines[$i]->total_tva; - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; $localtax2_rate=$object->lines[$i]->localtax2_tx; $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; - + $localtax2_type=$object->lines[$i]->localtax2_type; + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; @@ -667,7 +667,7 @@ class pdf_azur extends ModelePDFPropales { $posy=$this->_signature_area($pdf, $object, $posy, $outputlangs); } - + // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); @@ -1010,6 +1010,8 @@ class pdf_azur extends ModelePDFPropales // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1186,7 +1188,6 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1479,7 +1480,7 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=2; // Show list of linked objects diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 1e7e6f4bcad..2578509cf71 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -717,6 +717,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $useborder=0; + // Total TTC $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0,0,60); @@ -727,6 +728,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); + $creditnoteamount=0; + $depositsamount=0; + //$creditnoteamount=$object->getSumCreditNotesUsed(); + //$depositsamount=$object->getSumDepositsUsed(); + //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + if (! empty($object->paye)) $resteapayer=0; + if ($deja_regle > 0) { $index++; @@ -743,7 +752,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); $pdf->SetFont('','', $default_font_size - 1); $pdf->SetTextColor(0,0,0); } @@ -877,6 +886,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices */ function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { + global $conf; + + $sign=1; + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $tab3_posx = 120; $tab3_top = $posy + 8; $tab3_width = 80; @@ -910,8 +924,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('','', $default_font_size - 4); + // Loop on each deposits and credit notes included + // + // Loop on each payment - $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,"; + $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; @@ -929,7 +946,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0); + $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); 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 c882ed89800..2be42687f80 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -840,7 +840,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) From a5a08006e92c04701d10efa8bf9d1de328f78c3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 19:27:21 +0200 Subject: [PATCH 088/111] FIX multicompany better accuracy in rounding and with revenue stamp. --- htdocs/core/class/commonobject.class.php | 27 ++++++----- htdocs/core/lib/price.lib.php | 60 ++++++++++++++++-------- 2 files changed, 56 insertions(+), 31 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b32aa8cca05..7fbd6125015 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2263,6 +2263,8 @@ abstract class CommonObject $error=0; + $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; + // Define constants to find lines to sum $fieldtva='total_tva'; $fieldlocaltax1='total_localtax1'; @@ -2315,7 +2317,6 @@ abstract class CommonObject $obj = $this->db->fetch_object($resql); // Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none' - $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' { $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); @@ -2333,11 +2334,14 @@ abstract class CommonObject } } - $this->total_ht += $obj->total_ht; // The only field visible at end of line detail + $this->total_ht += $obj->total_ht; // The field visible at end of line detail $this->total_tva += $obj->total_tva; $this->total_localtax1 += $obj->total_localtax1; $this->total_localtax2 += $obj->total_localtax2; $this->total_ttc += $obj->total_ttc; + $this->multicurrency_total_ht += $obj->multicurrency_total_ht; // The field visible at end of line detail + $this->multicurrency_total_tva += $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; @@ -2346,7 +2350,7 @@ abstract class CommonObject $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; - if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat + if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency { $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); $diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1); @@ -2370,26 +2374,25 @@ abstract class CommonObject } // Add revenue stamp to total - $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0; // Situations totals - if ($this->situation_cycle_ref && $this->situation_counter > 1) { + if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) { $prev_sits = $this->get_prev_sits(); - foreach ($prev_sits as $sit) { + foreach ($prev_sits as $sit) { // $sit is an object Facture loaded with a fetch. $this->total_ht -= $sit->total_ht; $this->total_tva -= $sit->total_tva; $this->total_localtax1 -= $sit->total_localtax1; $this->total_localtax2 -= $sit->total_localtax2; $this->total_ttc -= $sit->total_ttc; + $this->multicurrency_total_ht -= $sit->multicurrency_total_ht; + $this->multicurrency_total_tva -= $sit->multicurrency_total_tva; + $this->multicurrency_total_ttc -= $sit->multicurrency_total_ttc; } } - // Multicurrency - $this->multicurrency_total_ht += $this->total_ht * $multicurrency_tx; - $this->multicurrency_total_tva += $this->total_tva * $multicurrency_tx; - $this->multicurrency_total_ttc += $this->total_ttc * $multicurrency_tx; - $this->db->free($resql); // Now update global field total_ht, total_ttc and tva @@ -2403,7 +2406,7 @@ abstract class CommonObject if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; if ($this->element == 'propal') $fieldttc='total'; if ($this->element == 'expensereport') $fieldtva='total_tva'; - if ($this->element == 'supplier_proposal') $fieldttc='total'; + if ($this->element == 'supplier_proposal') $fieldttc='total'; if (empty($nodatabaseupdate)) { diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 2fe652f6ac9..dca5ef8e50f 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -50,8 +50,8 @@ * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) * @param double $multicurrency_tx Currency rate (1 by default) - * @param double $pu_ht_devise Amount in currency - * @return array [ + * @param double $pu_devise Amount in currency + * @return array [ * 0=total_ht, * 1=total_vat, (main vat only) * 2=total_ttc, (total_ht + main vat + local taxes) @@ -65,15 +65,16 @@ * 10=total_tax2 for total_ht, * 11=pu_tax1 for pu_ht, !! should not be used * 12=pu_tax2 for pu_ht, !! should not be used - * 13=!! should not be used + * 13=?? !! should not be used * 14=total_tax1 for total_ht_without_discount, - * 15=total_tax2 for total_ht_without_discount] + * 15=total_tax2 for total_ht_without_discount, + * * 16=multicurrency_total_ht * 17=multicurrency_total_tva * 18=multicurrency_total_ttc * 19=multicurrency_pu_ht */ -function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_ht_devise=0) +function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_devise=0) { global $conf,$mysoc,$db; @@ -101,10 +102,10 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress); $countryid=$seller->country_id; - + if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate; if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate; - + if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; @@ -143,14 +144,15 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } else dol_print_error($db); } - + // pu calculation from pu_devise if pu empty - if(empty($pu) && !empty($pu_ht_devise)) { - $pu = $pu_ht_devise / $multicurrency_tx; - } else { - $pu_ht_devise = $pu * $multicurrency_tx; + if(empty($pu) && !empty($pu_devise)) { + $pu = $pu_devise / $multicurrency_tx; } - + if(empty($pu_devise) && !empty($multicurrency_tx)) { + $pu_devise = $pu * $multicurrency_tx; + } + // initialize total (may be HT or TTC depending on price_base_type) $tot_sans_remise = $pu * $qty * $progress / 100; $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); @@ -338,13 +340,33 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; } } - + // Multicurrency - $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); - $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); - $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); - $result[19] = price2num($pu_ht_devise, 'MU'); - + if ($conf->multicurrency->enabled && $multicurrency_tx != 1) + { + // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. + $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0); + + $result[16] = $newresult[0]; + $result[17] = $newresult[1]; + $result[18] = $newresult[2]; + $result[19] = $newresult[3]; + $result[20] = $newresult[4]; + $result[21] = $newresult[5]; + $result[22] = $newresult[6]; + $result[23] = $newresult[7]; + $result[24] = $newresult[8]; + $result[25] = $newresult[9]; + $result[26] = $newresult[10]; + /* + $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); + $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); + $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); + $result[19] = price2num($pu_devise, 'MU'); + */ + } + + //var_dump($result); // initialize result array //for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i]; From 9b22f046f5e30205f28445d49ad68269116fe2f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 19:27:21 +0200 Subject: [PATCH 089/111] FIX multicompany better accuracy in rounding and with revenue stamp. --- htdocs/core/class/commonobject.class.php | 27 ++++++----- htdocs/core/lib/price.lib.php | 60 ++++++++++++++++-------- 2 files changed, 56 insertions(+), 31 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 16450fd9feb..ab7afea77a4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2239,6 +2239,8 @@ abstract class CommonObject $error=0; + $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; + // Define constants to find lines to sum $fieldtva='total_tva'; $fieldlocaltax1='total_localtax1'; @@ -2291,7 +2293,6 @@ abstract class CommonObject $obj = $this->db->fetch_object($resql); // Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none' - $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' { $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); @@ -2309,11 +2310,14 @@ abstract class CommonObject } } - $this->total_ht += $obj->total_ht; // The only field visible at end of line detail + $this->total_ht += $obj->total_ht; // The field visible at end of line detail $this->total_tva += $obj->total_tva; $this->total_localtax1 += $obj->total_localtax1; $this->total_localtax2 += $obj->total_localtax2; $this->total_ttc += $obj->total_ttc; + $this->multicurrency_total_ht += $obj->multicurrency_total_ht; // The field visible at end of line detail + $this->multicurrency_total_tva += $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; @@ -2322,7 +2326,7 @@ abstract class CommonObject $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; - if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat + if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency { $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); $diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1); @@ -2346,26 +2350,25 @@ abstract class CommonObject } // Add revenue stamp to total - $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0; // Situations totals - if ($this->situation_cycle_ref && $this->situation_counter > 1) { + if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) { $prev_sits = $this->get_prev_sits(); - foreach ($prev_sits as $sit) { + foreach ($prev_sits as $sit) { // $sit is an object Facture loaded with a fetch. $this->total_ht -= $sit->total_ht; $this->total_tva -= $sit->total_tva; $this->total_localtax1 -= $sit->total_localtax1; $this->total_localtax2 -= $sit->total_localtax2; $this->total_ttc -= $sit->total_ttc; + $this->multicurrency_total_ht -= $sit->multicurrency_total_ht; + $this->multicurrency_total_tva -= $sit->multicurrency_total_tva; + $this->multicurrency_total_ttc -= $sit->multicurrency_total_ttc; } } - // Multicurrency - $this->multicurrency_total_ht += $this->total_ht * $multicurrency_tx; - $this->multicurrency_total_tva += $this->total_tva * $multicurrency_tx; - $this->multicurrency_total_ttc += $this->total_ttc * $multicurrency_tx; - $this->db->free($resql); // Now update global field total_ht, total_ttc and tva @@ -2379,7 +2382,7 @@ abstract class CommonObject if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; if ($this->element == 'propal') $fieldttc='total'; if ($this->element == 'expensereport') $fieldtva='total_tva'; - if ($this->element == 'supplier_proposal') $fieldttc='total'; + if ($this->element == 'supplier_proposal') $fieldttc='total'; if (empty($nodatabaseupdate)) { diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 2fe652f6ac9..dca5ef8e50f 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -50,8 +50,8 @@ * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) * @param double $multicurrency_tx Currency rate (1 by default) - * @param double $pu_ht_devise Amount in currency - * @return array [ + * @param double $pu_devise Amount in currency + * @return array [ * 0=total_ht, * 1=total_vat, (main vat only) * 2=total_ttc, (total_ht + main vat + local taxes) @@ -65,15 +65,16 @@ * 10=total_tax2 for total_ht, * 11=pu_tax1 for pu_ht, !! should not be used * 12=pu_tax2 for pu_ht, !! should not be used - * 13=!! should not be used + * 13=?? !! should not be used * 14=total_tax1 for total_ht_without_discount, - * 15=total_tax2 for total_ht_without_discount] + * 15=total_tax2 for total_ht_without_discount, + * * 16=multicurrency_total_ht * 17=multicurrency_total_tva * 18=multicurrency_total_ttc * 19=multicurrency_pu_ht */ -function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_ht_devise=0) +function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_devise=0) { global $conf,$mysoc,$db; @@ -101,10 +102,10 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress); $countryid=$seller->country_id; - + if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate; if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate; - + if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; @@ -143,14 +144,15 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } else dol_print_error($db); } - + // pu calculation from pu_devise if pu empty - if(empty($pu) && !empty($pu_ht_devise)) { - $pu = $pu_ht_devise / $multicurrency_tx; - } else { - $pu_ht_devise = $pu * $multicurrency_tx; + if(empty($pu) && !empty($pu_devise)) { + $pu = $pu_devise / $multicurrency_tx; } - + if(empty($pu_devise) && !empty($multicurrency_tx)) { + $pu_devise = $pu * $multicurrency_tx; + } + // initialize total (may be HT or TTC depending on price_base_type) $tot_sans_remise = $pu * $qty * $progress / 100; $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); @@ -338,13 +340,33 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; } } - + // Multicurrency - $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); - $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); - $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); - $result[19] = price2num($pu_ht_devise, 'MU'); - + if ($conf->multicurrency->enabled && $multicurrency_tx != 1) + { + // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. + $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0); + + $result[16] = $newresult[0]; + $result[17] = $newresult[1]; + $result[18] = $newresult[2]; + $result[19] = $newresult[3]; + $result[20] = $newresult[4]; + $result[21] = $newresult[5]; + $result[22] = $newresult[6]; + $result[23] = $newresult[7]; + $result[24] = $newresult[8]; + $result[25] = $newresult[9]; + $result[26] = $newresult[10]; + /* + $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); + $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); + $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); + $result[19] = price2num($pu_devise, 'MU'); + */ + } + + //var_dump($result); // initialize result array //for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i]; From 38621b622e797bcebc034ac14c8281dca20537a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 20:11:51 +0200 Subject: [PATCH 090/111] Fix specimen not complete for multicompany --- htdocs/compta/facture/class/facture.class.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3fa36602d39..9cc9a63f313 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3828,6 +3828,9 @@ class Facture extends CommonInvoice $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) { @@ -3836,6 +3839,9 @@ class Facture extends CommonInvoice $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) { @@ -3844,6 +3850,9 @@ class Facture extends CommonInvoice $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) @@ -3853,15 +3862,22 @@ class Facture extends CommonInvoice $line->total_ht=100; $line->total_ttc=119.6; $line->total_tva=19.6; - $line->remise_percent=00; + $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; $xnbp++; + $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->revenuestamp = 0; @@ -3877,6 +3893,9 @@ class Facture extends CommonInvoice $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]; From dc38ec50515bc9a4d41f1d7cb5d923c75a10422a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 20:48:24 +0200 Subject: [PATCH 091/111] Fix regression --- htdocs/core/lib/price.lib.php | 7 +++++++ test/phpunit/PricesTest.php | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index dca5ef8e50f..b8eeeae432c 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -365,6 +365,13 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[19] = price2num($pu_devise, 'MU'); */ } + else + { + $result[16] = price2num($result[0], 'MT'); + $result[17] = price2num($result[1], 'MT'); + $result[18] = price2num($result[2], 'MT'); + $result[19] = price2num($result[3], 'MU'); + } //var_dump($result); // initialize result array diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 3e09450b9cb..46d36db3b27 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -159,16 +159,16 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.56, 9.34795),$result1,'Test1 FR'); - + $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0),$result1,'Test1 FR'); + // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 $mysoc->country_code='FR'; $mysoc->country_id=1; $result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20),$result1,'Test1 FR'); - + $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0),$result1,'Test1 FR'); + /* * Country Spain */ From 6d40f797d261e21e7c04d73bc872473fbeb80814 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 21:50:14 +0200 Subject: [PATCH 092/111] Fix regression --- htdocs/core/lib/price.lib.php | 17 ++++++++++++----- test/phpunit/PricesTest.php | 36 +++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index b8eeeae432c..0cb1f755450 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -342,7 +342,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } // Multicurrency - if ($conf->multicurrency->enabled && $multicurrency_tx != 1) + if ($multicurrency_tx != 1) { // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0); @@ -367,10 +367,17 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } else { - $result[16] = price2num($result[0], 'MT'); - $result[17] = price2num($result[1], 'MT'); - $result[18] = price2num($result[2], 'MT'); - $result[19] = price2num($result[3], 'MU'); + $result[16] = $result[0]; + $result[17] = $result[1]; + $result[18] = $result[2]; + $result[19] = $result[3]; + $result[20] = $result[4]; + $result[21] = $result[5]; + $result[22] = $result[6]; + $result[23] = $result[7]; + $result[24] = $result[8]; + $result[25] = $result[9]; + $result[26] = $result[10]; } //var_dump($result); diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 46d36db3b27..50c0d20ad10 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -1,4 +1,7 @@ * Copyright (C) 2015 Juanjo Menent * @@ -141,6 +144,11 @@ class PricesTest extends PHPUnit_Framework_TestCase global $mysoc; $mysoc=new Societe($db); + // To force status that say module multicompany is on + //$conf->multicurrency=new stdClass(); + //$conf->multicurrency->enabled = 0; + + /* * Country France */ @@ -151,7 +159,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24),$result1,'Test1 FR'); + $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0),$result1,'Test1 FR'); // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value) $mysoc->country_code='FR'; @@ -159,7 +167,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0),$result1,'Test1 FR'); + $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0),$result1,'Test1b FR'); // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 $mysoc->country_code='FR'; @@ -167,7 +175,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0),$result1,'Test1 FR'); + $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0),$result1,'Test1c FR'); /* * Country Spain @@ -181,7 +189,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10),$result2,'Test1 ES'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test1 ES'); // 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect) $mysoc->country_code='ES'; @@ -191,7 +199,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10),$result2,'Test2 ES'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test2 ES'); // -------------------------------------------------------- @@ -203,7 +211,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10),$result2,'Test3 ES'); + $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0),$result2,'Test3 ES'); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect) $mysoc->country_code='ES'; @@ -213,7 +221,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10),$result2,'Test4 ES'); + $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0),$result2,'Test4 ES'); // -------------------------------------------------------- @@ -224,7 +232,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1); // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10),$result2,'Test5 ES for service'); + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19),$result2,'Test5 ES for service'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a service and not a product $mysoc->country_code='ES'; @@ -234,7 +242,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10),$result2,'Test6 ES for product'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test6 ES for product'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a product and not a service $mysoc->country_code='ES'; @@ -244,7 +252,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10),$result2,'Test6 ES for service'); + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19),$result2,'Test6 ES for service'); // -------------------------------------------------------- @@ -256,7 +264,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10),$result2,'Test7 ES for product'); + $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0),$result2,'Test7 ES for product'); // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect), we provide a service and not a product $mysoc->country_code='ES'; @@ -265,7 +273,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1); print __METHOD__." result2=".join(', ',$result2)."\n"; - $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10),$result2,'Test8 ES for service'); + $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19),$result2,'Test8 ES for service'); /* @@ -282,7 +290,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ',$result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10),$result3,'Test9 CI'); + $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0),$result3,'Test9 CI'); // 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect) $mysoc->country_code='CI'; @@ -292,7 +300,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ',$result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10),$result3,'Test10 CI'); + $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0),$result3,'Test10 CI'); return true; } From 4b8862c1ecb9a1a56f7c3d09f1c61c0fbfe45298 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 21:54:16 +0200 Subject: [PATCH 093/111] Remove useless import --- test/phpunit/PricesTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 50c0d20ad10..d3b1efaf072 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -1,7 +1,4 @@ * Copyright (C) 2015 Juanjo Menent * From d7b84bd35fa7d6fa111d7acece2477fc5e825287 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 22:56:24 +0200 Subject: [PATCH 094/111] Fix responsive --- htdocs/societe/rib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 92b3ef01552..615fba52659 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -440,7 +440,8 @@ if ($socid && $action != 'edit' && $action != "create") $var = false; if (is_array($rib_list)) { - print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; print ''; print_liste_field_titre("LabelRIB"); @@ -617,6 +618,7 @@ if ($socid && $action != 'edit' && $action != "create") } print '
'; + print ''; } else { dol_print_error($db); } From 322af9e2dfbd26759626f14ca2ffcad3f1d0c1e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 08:25:04 +0200 Subject: [PATCH 095/111] Fix travis --- htdocs/projet/class/task.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 371d214c7f8..910583782b9 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1950,7 +1950,7 @@ class TaskComment extends CommonObject * @param int $ref ref object * @return int <0 if KO, 0 if not found, >0 if OK */ - function fetch($id) + function fetch($id, $ref='') { global $langs; From 51e59597656745e8deba6d1a4756e796ba53af2d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 08:26:13 +0200 Subject: [PATCH 096/111] Fix travis --- htdocs/admin/dolistore/class/dolistore.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 18fa6e17e14..8fa25cce1a8 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -41,7 +41,7 @@ class Dolistore /** * Constructor * - * @param array $options + * @param array $options Options */ function __construct($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) { From 205989b64b6934389c2ab99c10c89f6db3041386 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:16:57 +0200 Subject: [PATCH 097/111] Fix phpunit --- htdocs/admin/defaultvalues.php | 4 ++-- htdocs/core/lib/functions.lib.php | 25 +++++++++++++++++++------ htdocs/langs/en_US/admin.lang | 4 ++-- test/phpunit/CodingPhpTest.php | 4 ++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index dfb40ef4b94..3565a2f5f20 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -248,8 +248,8 @@ print ''; print ''; // Page $texthelp=$langs->trans("PageUrlForDefaultValues"); -if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php'); -else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php'); +if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); +else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/card.php?abc=val1&def=val2'); $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder); // Field diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 54d4022f4bc..6380a9b0398 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -306,12 +306,25 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) // Else, retreive default values if we are not doing a sort elseif (! isset($_GET['sortfield']) && ! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set { - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) { if (! empty($user->default_values)) // $user->default_values defined from menu default values { - //var_dump($user->default_values[$relativepathstring]['createform']); - if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname]; + $qualified=1; + if (isset($user->default_values[$relativepathstring]['createform_queries'])) // Even if paramname is sortfield, data are stored into ['sortorder...'] + { + $tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['createform_queries']); + $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + foreach($tmpqueryarraytohave as $tmpquerytohave) + { + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0; + } + } + if ($qualified) + { + //var_dump($user->default_values[$relativepathstring]['createform']); + if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname]; + } } } // Management of default search_filters and sort order @@ -327,7 +340,7 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) if (isset($user->default_values[$relativepathstring]['sortorder_queries'])) // Even if paramname is sortfield, data are stored into ['sortorder...'] { $tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['sortorder_queries']); - $tmpqueryarraywehave=explode('&', $_SERVER['QUERY_STRING']); + $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); foreach($tmpqueryarraytohave as $tmpquerytohave) { if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0; @@ -352,7 +365,7 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) if (isset($user->default_values[$relativepathstring]['sortorder_queries'])) { $tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['sortorder_queries']); - $tmpqueryarraywehave=explode('&', $_SERVER['QUERY_STRING']); + $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); foreach($tmpqueryarraytohave as $tmpquerytohave) { if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0; @@ -377,7 +390,7 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) if (isset($user->default_values[$relativepathstring]['filters_queries'])) { $tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['filters_queries']); - $tmpqueryarraywehave=explode('&', $_SERVER['QUERY_STRING']); + $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); foreach($tmpqueryarraytohave as $tmpquerytohave) { if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5277db3dea4..f1aa542d7ae 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -451,8 +451,8 @@ DependsOn=This module need the module(s) 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 -PageUrlForDefaultValuesList=
For page that list thirdparties, it is %s +PageUrlForDefaultValuesCreate=
For form to create a new thirdparty, it is %s,
If we want default only if url has some parameter, we can use %s +PageUrlForDefaultValuesList=
For page that list thirdparties, it is %s,
If we want default only if url has some parameter, we 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. diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 1a11f3fc1c8..7deb7f9e655 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -199,13 +199,13 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase preg_match_all('/(...................)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) { - if ($val[1] != 'dol_escape_htmltag(') + if ($val[1] != 'dol_escape_htmltag(' && $val[1] != 'l_string_nohtmltag(') { $ok=false; break; } } - $this->assertTrue($ok, 'Found a $_SERVER[\'QUERY_STRING\'] without dol_escape_htmltag around in file '.$file['fullname'].' ('.$val[1].'$_SERVER[\'QUERY_STRING\']). Bad.'); + $this->assertTrue($ok, 'Found a $_SERVER[\'QUERY_STRING\'] without dol_escape_htmltag neither dol_string_nohtmltag around it, in file '.$file['fullname'].' ('.$val[1].'$_SERVER[\'QUERY_STRING\']). Bad.'); // Test that first param of print_liste_field_titre is a translation key and not the translated value From 6a650be43db045bf2a61d33f18d84fff5f9f3b88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:24:17 +0200 Subject: [PATCH 098/111] Try to reduce travis load --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 27a7c64bf46..4517a57a713 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,11 +57,15 @@ env: matrix: fast_finish: true allow_failures: - - php: 7.1 - php: nightly - #- env: DB=postgresql - # TODO - #- env: DB=sqlite + # We exclude some combinations not usefull to save Travis CPU + exclude: + - php: 5.4 + env: DB=postgresql + - php: 5.5 + env: DB=postgresql + - php: 5.6 + env: DB=postgresql notifications: email: From 3cd4aa434db60fdc0fadef7c6454c8693015242e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:33:10 +0200 Subject: [PATCH 099/111] Try to reduce travis load --- .travis.yml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4517a57a713..9d180e8758c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,14 +7,9 @@ sudo: required language: php -php: -- '5.3' -- '5.4' -- '5.5' -- '5.6' -- '7.0' -- '7.1' -- nightly +# Start on every boot +services: +- memcached addons: mariadb: '10.0' @@ -33,16 +28,21 @@ addons: - libapache2-mod-fastcgi # We need pgloader for import mysql database into pgsql - pgloader - -# Start on every boot -services: -- memcached + +php: +- '5.3' +- '5.4' +- '5.5' +- '5.6' +- '7.0' +- '7.1' +- hhvm +- nightly env: global: # Set to true for very verbose output - DEBUG=false - matrix: # MariaDB overrides MySQL installation so it's not possible to test both yet #- DB=mysql - DB=mariadb @@ -57,6 +57,7 @@ env: matrix: fast_finish: true allow_failures: + - php: hhvm - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: @@ -66,6 +67,8 @@ matrix: env: DB=postgresql - php: 5.6 env: DB=postgresql + - php: nightly + env: DB=postgresql notifications: email: From e51dd970d3e4b3c514951ad89a7369f566a81d89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:34:52 +0200 Subject: [PATCH 100/111] Try to reduce travis load --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 9d180e8758c..df5d3d91061 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,7 @@ env: global: # Set to true for very verbose output - DEBUG=false + matrix: # MariaDB overrides MySQL installation so it's not possible to test both yet #- DB=mysql - DB=mariadb From b7c8b30fac9d9b6cd7336f947783486b6db2e6e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:36:38 +0200 Subject: [PATCH 101/111] Try to reduce travis load --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index df5d3d91061..0920ab83a9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,11 +62,13 @@ matrix: - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: - - php: 5.4 + - php: '5.4' env: DB=postgresql - - php: 5.5 + - php: '5.5' env: DB=postgresql - - php: 5.6 + - php: '5.6' + env: DB=postgresql + - php: hhvm env: DB=postgresql - php: nightly env: DB=postgresql From 93cfde15b29464aac825b25f0a322897ba82d502 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:37:57 +0200 Subject: [PATCH 102/111] Try to reduce travis load --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0920ab83a9d..cbbffd28f0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,6 +68,8 @@ matrix: env: DB=postgresql - php: '5.6' env: DB=postgresql + - php: '7.0' + env: DB=postgresql - php: hhvm env: DB=postgresql - php: nightly From 3b56663e4dbaa0f6d52714299f745924d4cf2fa5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:40:10 +0200 Subject: [PATCH 103/111] Reduce travis load --- .travis.yml | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 509578e57ef..cbbffd28f0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,14 +7,9 @@ sudo: required language: php -php: -- '5.3' -- '5.4' -- '5.5' -- '5.6' -- '7.0' -- '7.1' -- nightly +# Start on every boot +services: +- memcached addons: mariadb: '10.0' @@ -33,10 +28,16 @@ addons: - libapache2-mod-fastcgi # We need pgloader for import mysql database into pgsql - pgloader - -# Start on every boot -services: -- memcached + +php: +- '5.3' +- '5.4' +- '5.5' +- '5.6' +- '7.0' +- '7.1' +- hhvm +- nightly env: global: @@ -57,11 +58,22 @@ env: matrix: fast_finish: true allow_failures: - - php: 7.1 + - php: hhvm - php: nightly - #- env: DB=postgresql - # TODO - #- env: DB=sqlite + # We exclude some combinations not usefull to save Travis CPU + exclude: + - php: '5.4' + env: DB=postgresql + - php: '5.5' + env: DB=postgresql + - php: '5.6' + env: DB=postgresql + - php: '7.0' + env: DB=postgresql + - php: hhvm + env: DB=postgresql + - php: nightly + env: DB=postgresql notifications: email: @@ -305,6 +317,9 @@ script: php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log php upgrade2.php 5.0.0 6.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade500600-2.log php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log + php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log + php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log + php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log cd - set +e echo From 76f94f32ae9e6f887d9f0ee7000b5ed198d1b9ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:53:39 +0200 Subject: [PATCH 104/111] Fix deletion of company --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a423b2b31de..d702e4beb14 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -44,7 +44,7 @@ class Societe extends CommonObject public $table_element = 'societe'; public $fk_element='fk_soc'; protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object - protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notfy_def", "actioncomm"); + protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); /** From 2390d20232e13e11d301c4d2520c04ee3311d0a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:53:39 +0200 Subject: [PATCH 105/111] Update travis --- .travis.yml | 3 ++- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cbbffd28f0f..bac020e13c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ # from Dolibarr GitHub repository. # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ +# We use dist: precise to have php 5.3 available dist: precise sudo: required @@ -36,7 +37,7 @@ php: - '5.6' - '7.0' - '7.1' -- hhvm +#- hhvm only with dist: trusty - nightly env: diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a423b2b31de..d702e4beb14 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -44,7 +44,7 @@ class Societe extends CommonObject public $table_element = 'societe'; public $fk_element='fk_soc'; protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object - protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notfy_def", "actioncomm"); + protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); /** From aafc108260a49c4d9697e2e44a70dbafd4c46631 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 10:08:49 +0200 Subject: [PATCH 106/111] Remove hhvm --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cbbffd28f0f..bac020e13c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ # from Dolibarr GitHub repository. # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ +# We use dist: precise to have php 5.3 available dist: precise sudo: required @@ -36,7 +37,7 @@ php: - '5.6' - '7.0' - '7.1' -- hhvm +#- hhvm only with dist: trusty - nightly env: From ed013c1b7e007a05d1b0983864107ed4a66cb729 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 10:21:04 +0200 Subject: [PATCH 107/111] Compatibilty php 7.2 --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7fbd6125015..e37c525b513 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4142,7 +4142,7 @@ abstract class CommonObject * * @param int $rowid Id of line. Use the id of object if not defined. Deprecated. Function must be called without parameters. * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters. - * @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optional loaded + * @return int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded */ function fetch_optionals($rowid=null,$optionsArray=null) { @@ -4176,7 +4176,7 @@ abstract class CommonObject if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility // Request to get complementary values - if (count($optionsArray) > 0) + if (is_array($optionsArray) && count($optionsArray) > 0) { $sql = "SELECT rowid"; foreach ($optionsArray as $name => $label) From 9523bf5fbd6793e82734bbedc6b66f034a05ee57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 10:23:17 +0200 Subject: [PATCH 108/111] Remove useless code --- test/phpunit/PricesTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 50c0d20ad10..d3b1efaf072 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -1,7 +1,4 @@ * Copyright (C) 2015 Juanjo Menent * From fe1ce5b3ac41d99d531732bda017455e8ced459d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 11:44:47 +0200 Subject: [PATCH 109/111] Fix php 7.2 compatibility --- htdocs/core/lib/json.lib.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 6b868663aa7..ac2372c5825 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -42,19 +42,21 @@ if (! function_exists('json_encode')) * * @param mixed $elements PHP Object to json encode * @return string Json encoded string - * @deprecated PHP >= 5.3 supports native json_encode * @see json_encode() */ function dol_json_encode($elements) { - dol_syslog('dol_json_encode() is deprecated. Please update your code to use native json_encode().', LOG_WARNING); + dol_syslog("For better permorfance, enable the native json in your PHP", LOG_WARNING); - $num=count($elements); + $num=0; if (is_object($elements)) // Count number of properties for an object { - $num=0; foreach($elements as $key => $value) $num++; } + else + { + $num=count($elements); + } //var_dump($num); // determine type From 7d5dc08a0a71b8cd4c131c1dbce08e25f90c4a35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Sep 2017 14:45:11 +0200 Subject: [PATCH 110/111] Fix PHP7.2 --- htdocs/includes/tcpdi/tcpdi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/tcpdi/tcpdi.php b/htdocs/includes/tcpdi/tcpdi.php index 48fdd8198f5..999ff99ea5b 100644 --- a/htdocs/includes/tcpdi/tcpdi.php +++ b/htdocs/includes/tcpdi/tcpdi.php @@ -580,7 +580,7 @@ class TCPDI extends FPDF_TPL { * close all files opened by parsers */ function _closeParsers() { - if ($this->state > 2 && count($this->parsers) > 0) { + if ($this->state > 2 && is_array($this->parsers) && count($this->parsers) > 0) { $this->cleanUp(); return true; } From 14d000f011d879f0af7cf0ee221d906c2c409baf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 12:01:32 +0200 Subject: [PATCH 111/111] Update time.php --- htdocs/projet/tasks/time.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 72ad74df871..8b85c299fdc 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -453,7 +453,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; - if (!empty($projectstatic->thirdparty)) { + if (is_object($projectstatic->thirdparty)) { $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); } $morehtmlref.=''; @@ -464,7 +464,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; print '
'; - print '
'; + print '
'; print '
'; // Date start - Date end