From c4d8a25c5a09f018fd42a9b346085c36fa8a87ee Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 10 Aug 2020 13:40:55 +0200 Subject: [PATCH 01/46] fix external module multidiroutput --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 23b631bae53..cb139edd29b 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2992,7 +2992,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if ($partofdirinoriginalfile && ($fuser->rights->$modulepart->$partofdirinoriginalfile->{$lire} || $fuser->rights->$modulepart->$partofdirinoriginalfile->{$read})) $accessallowed = 1; if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed = 1; //} - $original_file = $conf->$modulepart->dir_output.'/'.$original_file; + $original_file = $conf->$modulepart->multidir_output[$entity].'/'.$original_file; } // For modules who wants to manage different levels of permissions for documents From 6928b6543c9f6db15e1c7fc8ba257602debd1c52 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 16 Sep 2020 21:24:24 +0200 Subject: [PATCH 02/46] Revert "FIX Yogosha report 4425 (backport)" This reverts commit 23c4cfe913429a38b3e4f9edec33bdfb0166d274. --- htdocs/core/lib/functions.lib.php | 37 +++++++------------------------ htdocs/document.php | 9 ++++---- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3f4229589dd..97ad5d58969 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7705,16 +7705,19 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param if (empty($conf->use_javascript_ajax)) return ''; - $isAllowedForPreview = dolIsAllowedForPreview($relativepath); + $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml'); + //$mime_preview[]='vnd.oasis.opendocument.presentation'; + //$mime_preview[]='archive'; + $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview); if ($alldata == 1) { - if (isAllowedForPreview) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:''), 'mime'=>dol_mimetype($relativepath), ); + if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:''), 'mime'=>dol_mimetype($relativepath), ); else return array(); } - // old behavior, return a string - if ($isAllowedForPreview) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:'')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')'; + // old behavior + if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:'')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')'; else return ''; } @@ -7738,30 +7741,6 @@ function ajax_autoselect($htmlname, $addlink = '') return $out; } -/** - * Return if a file is qualified for preview - * - * @param string $file Filename we looking for information - * @return int 1 If allowed, 0 otherwise - * @see dol_mimetype(), image_format_supported() from images.lib.php - */ -function dolIsAllowedForPreview($file) { - global $conf; - - // Check .noexe extension in filename - if (preg_match('/\.noexe$/i', $file)) return 0; - - // Check mime types - $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'webp'); - if (!empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) $mime_preview[] = 'svg+xml'; - //$mime_preview[]='vnd.oasis.opendocument.presentation'; - //$mime_preview[]='archive'; - $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview); - if ($num_mime !== false) return 1; - - // By default, not allowed for preview - return 0; -} /** * Return mime type of a file @@ -7770,7 +7749,7 @@ function dolIsAllowedForPreview($file) { * @param string $default Default mime type if extension not found in known list * @param int $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language, 4=css of font fa * @return string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive) - * @see dolIsAllowedForPreview(), image_format_supported() from images.lib.php + * @see image_format_supported() from images.lib.php */ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) { diff --git a/htdocs/document.php b/htdocs/document.php index ccd404f7315..2b37792d69a 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -156,13 +156,12 @@ if (isset($_GET["attachment"])) $attachment = GETPOST("attachment", 'alpha')?tru if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; // Define mime type -$type = 'application/octet-stream'; // By default +$type = 'application/octet-stream'; if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha'); else $type=dol_mimetype($original_file); -// Security: Force to octet-stream if file is a dangerous file. For example when it is a .noexe file -if (!dolIsAllowedForPreview($original_file)) { - $type = 'application/octet-stream'; -} +// Security: Force to octet-stream if file is a dangerous file +if (preg_match('/\.noexe$/i', $original_file)) $type = 'application/octet-stream'; + // Security: Delete string ../ into $original_file $original_file = str_replace("../", "/", $original_file); From 55e3f8365e74477f0e582cae10638bfc44848aec Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 16 Sep 2020 21:36:55 +0200 Subject: [PATCH 03/46] FIX Yogosha report 4434 (backport) --- htdocs/adherents/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index c6ec8569a09..f8289e04cb2 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -286,7 +286,7 @@ if (empty($reshook)) $object->firstname = trim(GETPOST("firstname", 'alpha')); $object->lastname = trim(GETPOST("lastname", 'alpha')); $object->gender = trim(GETPOST("gender", 'alpha')); - $object->login = trim(GETPOST("login", 'alpha')); + $object->login = trim(GETPOST("login", 'alphanohtml')); $object->pass = trim(GETPOST("pass", 'alpha')); $object->societe = trim(GETPOST("societe", 'alpha')); @@ -453,7 +453,7 @@ if (empty($reshook)) $facebook=GETPOST("member_facebook", 'alpha'); $linkedin=GETPOST("member_linkedin", 'alpha'); $email=preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); - $login=GETPOST("member_login", 'alpha'); + $login=GETPOST("member_login", 'alphanohtml'); $pass=GETPOST("password", 'alpha'); $photo=GETPOST("photo", 'alpha'); //$comment=GETPOST("comment",'none'); @@ -914,7 +914,7 @@ else // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'" autofocus="autofocus">'; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'" autofocus="autofocus">'; } // Password @@ -1171,7 +1171,7 @@ else // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">'; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">'; } // Password From f453e43ccafd649c6bffce6eab6ac1135fafd455 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 18 Sep 2020 01:37:15 +0200 Subject: [PATCH 04/46] FIX Yogosha report 4425 (backport) --- htdocs/document.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/document.php b/htdocs/document.php index 2b37792d69a..ccd404f7315 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -156,12 +156,13 @@ if (isset($_GET["attachment"])) $attachment = GETPOST("attachment", 'alpha')?tru if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; // Define mime type -$type = 'application/octet-stream'; +$type = 'application/octet-stream'; // By default if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha'); else $type=dol_mimetype($original_file); -// Security: Force to octet-stream if file is a dangerous file -if (preg_match('/\.noexe$/i', $original_file)) $type = 'application/octet-stream'; - +// Security: Force to octet-stream if file is a dangerous file. For example when it is a .noexe file +if (!dolIsAllowedForPreview($original_file)) { + $type = 'application/octet-stream'; +} // Security: Delete string ../ into $original_file $original_file = str_replace("../", "/", $original_file); From 6d7f5ef0a8dcfccdcbde227fb109035e7d36c117 Mon Sep 17 00:00:00 2001 From: Pascal Hubrecht Date: Tue, 22 Sep 2020 12:40:26 +0200 Subject: [PATCH 05/46] Fix label inversion Private and public labels where inverted. --- htdocs/fichinter/class/fichinter.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 488040ff5d3..f370b8bb571 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -58,8 +58,8 @@ class Fichinter extends CommonObject 'datet' =>array('type'=>'date', 'label'=>'Datet', 'enabled'=>1, 'visible'=>-1, 'position'=>95), 'duree' =>array('type'=>'double', 'label'=>'Duree', 'enabled'=>1, 'visible'=>-1, 'position'=>100), 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>105, 'showoncombobox'=>1), - 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>110), - 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>115), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>115), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>120), 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>125), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>130), From fcfe5423f42245af690a5466f6c246b6a4a8cc21 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Sep 2020 16:34:38 +0200 Subject: [PATCH 06/46] FIX missing field entity --- htdocs/compta/paiement/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index e14581f6531..d3dec6fde82 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -318,7 +318,7 @@ dol_fiche_end(); * List of invoices */ -$sql = 'SELECT f.rowid as facid, f.ref, f.type, f.total_ttc, f.paye, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid'; +$sql = 'SELECT f.rowid as facid, f.ref, f.type, f.total_ttc, f.paye, f.entity, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s'; $sql .= ' WHERE pf.fk_facture = f.rowid'; $sql .= ' AND f.fk_soc = s.rowid'; From 0fc6e9b84f9cc12c8d8161df600e1dc8dc8d3163 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 23 Sep 2020 10:54:49 +0200 Subject: [PATCH 07/46] FIX - Backtick not work with postgresql --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 7055898ada6..37bb2962724 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -98,7 +98,8 @@ ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0; ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0; ALTER TABLE llx_bom_bomline ADD COLUMN disable_stock_change smallint DEFAULT 0; -ALTER TABLE llx_bom_bomline DROP COLUMN `rank`; +-- VMYSQL4.1 ALTER TABLE llx_bom_bomline DROP COLUMN `rank`; +-- VPGSQL8.2 ALTER TABLE llx_bom_bomline DROP COLUMN rank; create table llx_categorie_warehouse ( From 905f676c71318adedab7ed4cdc3297b8d683a0f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Sep 2020 19:27:55 +0200 Subject: [PATCH 08/46] Fix 12.0.3 --- 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 ffd2e9bd5ff..94ecf930724 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', '12.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (!defined('DOL_VERSION')) define('DOL_VERSION', '12.0.3'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (!defined('EURO')) define('EURO', chr(128)); From 732bb708269e68ec08099af015828db008be7858 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 24 Sep 2020 11:47:41 +0200 Subject: [PATCH 09/46] fix sql --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 1 + htdocs/install/mysql/tables/llx_actioncomm_reminder.sql | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 1f7740de467..8e3d0e1ee69 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -306,6 +306,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value ALTER TABLE llx_actioncomm_reminder ADD COLUMN entity integer NOT NULL DEFAULT 1; ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_actioncomm integer NOT NULL; ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_email_template integer; +ALTER TABLE llx_actioncomm_reminder CHANGE offsetunit offsetunit VARCHAR(10); ALTER TABLE llx_actioncomm_reminder DROP INDEX uk_actioncomm_reminder_unique; ALTER TABLE llx_actioncomm_reminder ADD UNIQUE uk_actioncomm_reminder_unique (fk_user, typeremind, offsetvalue, offsetunit, fk_actioncomm); diff --git a/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql b/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql index 78dd00d6ea5..ff992227d0d 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql @@ -21,7 +21,7 @@ CREATE TABLE llx_actioncomm_reminder( typeremind varchar(32) NOT NULL, fk_user integer NOT NULL, offsetvalue integer NOT NULL, - offsetunit varchar(1) NOT NULL, + offsetunit varchar(10) NOT NULL, status integer NOT NULL DEFAULT 0, entity integer NOT NULL DEFAULT 1, fk_actioncomm integer NOT NULL, From 101405b052a576a3b506934e3cd3eaf3f5862190 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 24 Sep 2020 12:31:28 +0200 Subject: [PATCH 10/46] fix notification creation => must create for every user linked to the event --- htdocs/comm/action/card.php | 31 +++++++++++-------- htdocs/comm/action/class/actioncomm.class.php | 8 +++-- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 0fe69fa10ea..be100a97656 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -48,7 +48,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda")); +$langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda", "mails")); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); @@ -393,7 +393,7 @@ if (empty($reshook) && $action == 'add') $moreparam = ''; if ($user->id != $object->userownerid) $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. - //Create eminder + //Create reminder if ($addreminder == 'on'){ $actionCommReminder = new ActionCommReminder($db); @@ -401,23 +401,28 @@ if (empty($reshook) && $action == 'add') $actionCommReminder->dateremind = $dateremind; $actionCommReminder->typeremind = $remindertype; - $actionCommReminder->fk_user = $user; $actionCommReminder->offsetunit = $offsetunit; $actionCommReminder->offsetvalue = $offsetvalue; $actionCommReminder->status = $actionCommReminder::STATUS_TODO; $actionCommReminder->fk_actioncomm = $object->id; if ($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail; - $res = $actionCommReminder->create($user); + // the notification must be created for every user assigned to the event + foreach ($object->userassigned as $userassigned) + { + $actionCommReminder->fk_user = $userassigned['id']; + $res = $actionCommReminder->create($user); - if ($res <= 0){ - // If error - $error++; - $langs->load("errors"); - $error = $langs->trans('ErrorReminderActionCommCreation').' '.$actionCommReminder->error; - setEventMessages($error, $actionCommReminder->errors, 'errors'); - $action = 'create'; $donotclearsession = 1; - } + if ($res <= 0){ + // If error + $db->rollback(); + $langs->load("errors"); + $error = $langs->trans('ErrorReminderActionCommCreation'); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; + break; + } + } } if ($error) { @@ -1236,7 +1241,7 @@ if ($action == 'create') } }); - $("#selectremindertype").click(function(){ + $("#selectremindertype").change(function(){ var selected_option = $("#selectremindertype option:selected").val(); if(selected_option == "email") { $("#select_actioncommsendmodel_mail").closest("tr").show(); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index a5084bfac74..113f860962f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1958,9 +1958,10 @@ class ActionComm extends CommonObject * * @param string $type Type of reminder 'browser' or 'email' * @param int $fk_user Id of user + * @param bool $onlypast true = get only past reminder, false = get all reminders linked to this * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function loadReminders($type = '', $fk_user = 0) + public function loadReminders($type = '', $fk_user = 0, $onlypast = true) { global $conf, $langs, $user; @@ -1971,7 +1972,10 @@ class ActionComm extends CommonObject //Select all action comm reminders for event $sql = "SELECT rowid as id, typeremind, dateremind, status, offsetvalue, offsetunit, fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; - $sql .= " WHERE fk_actioncomm = ".$this->id." AND dateremind <= '".$this->db->idate(dol_now())."'"; + $sql .= " WHERE fk_actioncomm = ".$this->id; + if ($onlypast) { + $sql .= " AND dateremind <= '".$this->db->idate(dol_now())."'"; + } if ($type) { $sql .= " AND typeremind ='".$this->db->escape($type)."'"; } From e6eff6511e03149d7ce2f96deed2686c6837b09d Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 24 Sep 2020 15:20:30 +0200 Subject: [PATCH 11/46] fix reminder offsetunit and display problems --- htdocs/comm/action/card.php | 8 +++++--- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index be100a97656..5179b4c0ab1 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -397,7 +397,7 @@ if (empty($reshook) && $action == 'add') if ($addreminder == 'on'){ $actionCommReminder = new ActionCommReminder($db); - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i'); + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); $actionCommReminder->dateremind = $dateremind; $actionCommReminder->typeremind = $remindertype; @@ -1697,6 +1697,7 @@ if ($id > 0) print $langs->trans("Done"); print ' '; } + print '
'; } } } @@ -1985,7 +1986,7 @@ if ($id > 0) { $filtreuserid = $user->id; if ($user->rights->agenda->allactions->read) $filtreuserid = 0; - $object->loadReminders('', $filteruserid); + $object->loadReminders('', $filteruserid, false); print ''.$langs->trans("Reminders").''; @@ -1996,7 +1997,7 @@ if ($id > 0) print $TRemindTypes[$actioncommreminder->typeremind]; if ($actioncommreminder->fk_user > 0) { $tmpuserstatic->fetch($actioncommreminder->fk_user); - print ' ('.$tmpuser->getNomUrl(0, '', 0, 0, 16).')'; + print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; } print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { @@ -2008,6 +2009,7 @@ if ($id > 0) print $langs->trans("Done"); print ' '; } + print '
'; } } diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 8e3d0e1ee69..1f7740de467 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -306,7 +306,6 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value ALTER TABLE llx_actioncomm_reminder ADD COLUMN entity integer NOT NULL DEFAULT 1; ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_actioncomm integer NOT NULL; ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_email_template integer; -ALTER TABLE llx_actioncomm_reminder CHANGE offsetunit offsetunit VARCHAR(10); ALTER TABLE llx_actioncomm_reminder DROP INDEX uk_actioncomm_reminder_unique; ALTER TABLE llx_actioncomm_reminder ADD UNIQUE uk_actioncomm_reminder_unique (fk_user, typeremind, offsetvalue, offsetunit, fk_actioncomm); From b269af5bf602b040a34742852d46ee472d0ec60f Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 24 Sep 2020 15:26:35 +0200 Subject: [PATCH 12/46] delete reminders on ActionComm::delete --- htdocs/comm/action/class/actioncomm.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 113f860962f..c6fd2183459 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -925,6 +925,18 @@ class ActionComm extends CommonObject } } + if (!$error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; + $sql .= " WHERE fk_actioncomm = ".$this->id; + + $res = $this->db->query($sql); + if (!$res) { + $this->error = $this->db->lasterror(); + $error++; + } + } + // Removed extrafields if (!$error) { $result = $this->deleteExtraFields(); From 6aad3b47f5cbd798c3139010d1c84e627f686b3a Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 24 Sep 2020 15:28:41 +0200 Subject: [PATCH 13/46] remove fields size modification --- htdocs/install/mysql/tables/llx_actioncomm_reminder.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql b/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql index ff992227d0d..78dd00d6ea5 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm_reminder.sql @@ -21,7 +21,7 @@ CREATE TABLE llx_actioncomm_reminder( typeremind varchar(32) NOT NULL, fk_user integer NOT NULL, offsetvalue integer NOT NULL, - offsetunit varchar(10) NOT NULL, + offsetunit varchar(1) NOT NULL, status integer NOT NULL DEFAULT 0, entity integer NOT NULL DEFAULT 1, fk_actioncomm integer NOT NULL, From 5244c05abbee09cadf213e74bbfb1151028c389d Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 24 Sep 2020 15:30:29 +0200 Subject: [PATCH 14/46] reminders in the future can be displayed too --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 5179b4c0ab1..6c9f7f55f08 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1669,7 +1669,7 @@ if ($id > 0) { $filtreuserid = $user->id; if ($user->rights->agenda->allactions->read) $filtreuserid = 0; - $object->loadReminders('', $filteruserid); + $object->loadReminders('', $filteruserid, false); print '
'; From 554948d3e21d3a73e312a1df80501b2ac4a05754 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 24 Sep 2020 15:34:52 +0200 Subject: [PATCH 15/46] bad user for getNomUrl --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6c9f7f55f08..d158528ce0f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1685,7 +1685,7 @@ if ($id > 0) print $TRemindTypes[$actioncommreminder->typeremind]; if ($actioncommreminder->fk_user > 0) { $tmpuserstatic->fetch($actioncommreminder->fk_user); - print ' ('.$tmpuser->getNomUrl(0, '', 0, 0, 16).')'; + print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; } print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { From d38c557fba732229f71b99c8494bd4e1651ba8f9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 21 Jun 2020 19:52:15 +0200 Subject: [PATCH 16/46] FIX Can create user but not update user with activedirectory --- htdocs/core/class/ldap.class.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index ea4ec500405..b09db176852 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -55,6 +55,10 @@ class Ldap /** * Version du protocole ldap */ + public $ldapProtocolVersion; + /** + * Server DN + */ public $domain; /** * User administrateur Ldap @@ -466,8 +470,6 @@ class Ldap */ public function modify($dn, $info, $user) { - global $conf; - dol_syslog(get_class($this)."::modify dn=".$dn." info=".join(',', $info)); // Check parameters @@ -492,7 +494,11 @@ class Ldap $this->dump($dn, $info); //print_r($info); - $result = @ldap_modify($this->connection, $dn, $info); + // For better compatibility with Samba4 AD + if ($this->serverType == "activedirectory") { + unset($info['cn']); // For avoid error : Operation not allowed on RDN (Code 67) + } + $result=@ldap_modify($this->connection, $dn, $info); if ($result) { @@ -520,9 +526,7 @@ class Ldap */ public function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true) { - global $conf; - - dol_syslog(get_class($this)."::modify dn=".$dn." newrdn=".$newrdn." newparent=".$newparent." deleteoldrdn=".($deleteoldrdn ? 1 : 0)); + dol_syslog(get_class($this)."::modify dn=".$dn." newrdn=".$newrdn." newparent=".$newparent." deleteoldrdn=".($deleteoldrdn?1:0)); // Check parameters if (!$this->connection) @@ -571,8 +575,6 @@ class Ldap */ public function update($dn, $info, $user, $olddn, $newrdn = false, $newparent = false) { - global $conf; - dol_syslog(get_class($this)."::update dn=".$dn." olddn=".$olddn); // Check parameters @@ -589,7 +591,7 @@ class Ldap if (!$olddn || $olddn != $dn) { - if (!empty($olddn) && !empty($newrdn) && !empty($newparent) && $conf->global->LDAP_SERVER_PROTOCOLVERSION === '3') + if (! empty($olddn) && ! empty($newrdn) && ! empty($newparent) && $this->ldapProtocolVersion === '3') { // This function currently only works with LDAPv3 $result = $this->rename($olddn, $newrdn, $newparent, $user, true); @@ -631,8 +633,6 @@ class Ldap */ public function delete($dn) { - global $conf; - dol_syslog(get_class($this)."::delete Delete LDAP entry dn=".$dn); // Check parameters From 7a9332815c6e852e564d8ad47cae19cb06d4d1c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Sep 2020 12:22:24 +0200 Subject: [PATCH 17/46] Fix migration --- htdocs/install/mysql/migration/3.2.0-3.3.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index 91c155d3d84..c0efe6d68b3 100644 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -315,6 +315,7 @@ ALTER TABLE llx_c_chargesociales ADD COLUMN accountancy_code varchar(15) DEFAULT -- Tables for accountancy expert DROP TABLE llx_accountingaccount; +DROP TABLE llx_accounting_account; DROP TABLE llx_accountingsystem; DROP TABLE llx_accounting_system; From 0dcd85485aba5e1b7566d6a3bf616aeed556114f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Sep 2020 12:36:32 +0200 Subject: [PATCH 18/46] Fix migration --- htdocs/install/mysql/migration/3.3.0-3.4.0.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index 0f84c92ef22..88d9ae1b685 100644 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -102,6 +102,10 @@ ALTER TABLE llx_expedition DROP FOREIGN KEY fk_expedition_fk_shipping_method; ALTER TABLE llx_expedition DROP INDEX idx_expedition_fk_expedition_methode; ALTER TABLE llx_expedition CHANGE COLUMN fk_expedition_methode fk_shipping_method integer; +-- This table and constraint should not exists as it appears in more recent version, but we may have it if we load an old dump +-- on a newly created database and we want to be sure upgrade of rowid into autoincrement done later will works. +ALTER TABLE llx_reception DROP FOREIGN KEY fk_reception_fk_shipping_method; + ALTER TABLE llx_c_shipment_mode ADD COLUMN tracking VARCHAR(255) NOT NULL DEFAULT '' AFTER description; --ALTER TABLE llx_c_shipment_mode DROP COLUMN CASCADE; From fcbc48fa287d80a51c041ed9e8298186e42d0bda Mon Sep 17 00:00:00 2001 From: root Date: Fri, 25 Sep 2020 14:24:26 +0200 Subject: [PATCH 19/46] Bug fix last_gen should be date_last_gen --- htdocs/compta/facture/class/facture-rec.class.php | 2 +- htdocs/fichinter/class/fichinterrec.class.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 8a13cf0f814..c5bd8a987ac 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -155,7 +155,7 @@ class FactureRec extends CommonInvoice 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105), 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110), 'modelpdf' =>array('type'=>'varchar(255)', 'label'=>'Modelpdf', 'enabled'=>1, 'visible'=>-1, 'position'=>115), - 'last_gen' =>array('type'=>'varchar(7)', 'label'=>'Last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>120), + 'date_last_gen' =>array('type'=>'varchar(7)', 'label'=>'Last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>120), 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'Unit frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>125), 'date_when' =>array('type'=>'datetime', 'label'=>'Date when', 'enabled'=>1, 'visible'=>-1, 'position'=>130), 'date_last_gen' =>array('type'=>'datetime', 'label'=>'Date last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>135), diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 679d231d6a8..a09547b3164 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -567,14 +567,14 @@ class FichinterRec extends Fichinter if ($user->rights->fichinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter_rec "; $sql .= " SET frequency='".$this->db->escape($freq)."'"; - $sql .= ", last_gen='".$this->db->escape($courant)."'"; + $sql .= ", date_last_gen='".$this->db->escape($courant)."'"; $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); if ($resql) { $this->frequency = $freq; - $this->last_gen = $courant; + $this->date_last_gen = $courant; return 0; } else { dol_print_error($this->db); From ec54e33d81e0c89ffc6c08c656eba15a7d91d768 Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Sun, 27 Sep 2020 11:11:31 +0200 Subject: [PATCH 20/46] NEW: Introducing new modal boxes in TakePOS --- htdocs/takepos/css/pos.css.php | 73 ++++++++++++++++++++++++++++++++++ htdocs/takepos/index.php | 55 +++++++++++++++---------- 2 files changed, 106 insertions(+), 22 deletions(-) diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 4666de59a8e..e320142ff35 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -669,3 +669,76 @@ div#moreinfo, div#infowarehouse { padding-right: 4px; } } + +/* Modal box */ +.modal { + display: none; /* Hidden by default */ + position: fixed; + z-index: 1; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgb(0,0,0); + background-color: rgba(0,0,0,0.4); +} + +/* The Close Button */ +.close { + color: #aaa; + float: right; + font-size: 28px; + font-weight: bold; +} + +.close:hover, +.close:focus { + color: black; + text-decoration: none; + cursor: pointer; +} + +.modal-header { + padding: 2px 16px; + background-color: #2b4161; + color: white; +} + +.modal-body {padding: 2px 16px;} + +.modal-footer { + padding: 2px 16px; + background-color: #2b4161; + color: white; +} + +.modal-content { + position: relative; + background-color: #fefefe; + margin: 15% auto; /* 15% from the top and centered */ + padding: 0; + border: 1px solid #888; + width: 40%; + box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19); + animation-name: animatetop; + animation-duration: 0.4s +} + +@keyframes animatetop { + from {top: -300px; opacity: 0} + to {top: 0; opacity: 1} +} + +.block { + display: block; + width: 100%; + border: none; + color: white; + background-color: #8c907e; + padding: 14px 28px; + font-size: 16px; + cursor: pointer; + text-align: center; + margin: 2px; +} \ No newline at end of file diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 73b039d97e9..04c0fbecac5 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -728,27 +728,12 @@ function CashReport(rowid) // Popup to select the terminal to use function TerminalsDialog() { - jQuery("#dialog-info").dialog({ - resizable: false, - height: global->TAKEPOS_NUM_TERMINALS / 3 * 20); ?>, - width: dol_optimize_smallscreen ? 316 : 400); ?>, - modal: true, - buttons: { - 'trans("Terminal")) ?> 1': function() { - location.href='index.php?setterminal=1'; - } - global->TAKEPOS_NUM_TERMINALS; $i++) - { - print ", - '".dol_escape_js($langs->trans("Terminal"))." ".$i."': function() { - location.href='index.php?setterminal=".$i."'; - } - "; - } - ?> - } - }); + var modal = document.getElementById("ModalTerminal"); + var span = document.getElementsByClassName("close")[0]; + span.onclick = function() { + modal.style.display = "none"; + } + modal.style.display = "block"; } function DirectPayment(){ @@ -774,6 +759,8 @@ function WeighingScale(){ }); } + + $( document ).ready(function() { PrintCategories(0); LoadProducts(0); @@ -802,7 +789,6 @@ $( document ).ready(function() { '.$langs->trans('TerminalSelect').''; $keyCodeForEnter = $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} > 0 ? $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} : ''; ?>
@@ -853,6 +839,31 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { } ?> + + + + +
From 494348356a4eee3f32616bd639fd9bbac4ebaed5 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 27 Sep 2020 11:35:07 +0200 Subject: [PATCH 21/46] Fix travis --- htdocs/takepos/index.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 04c0fbecac5..6444a51f3ec 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -759,8 +759,6 @@ function WeighingScale(){ }); } - - $( document ).ready(function() { PrintCategories(0); LoadProducts(0); @@ -849,10 +847,10 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { From bf167ca91d2e66786b81bff2953551d3a905631a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 28 Sep 2020 09:40:55 +0200 Subject: [PATCH 28/46] Fix unused variable --- htdocs/accountancy/admin/productaccount.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 79bfef57d3a..08b81ddaabb 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -602,7 +602,7 @@ if ($result) // Accounting account buy intra (In EEC) print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy_intra; + if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; $codesell = length_accountg($obj->accountancy_code_buy_intra); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid @@ -612,7 +612,7 @@ if ($result) // Accounting account buy export (Out of EEC) print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy_export; + if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; $codesell = length_accountg($obj->accountancy_code_buy_export); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid From 17347bf575627d71069ee93dd3f54d6021f44f0f Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 28 Sep 2020 11:08:27 +0200 Subject: [PATCH 29/46] New Add column vat rate in page to define accounting account on product/service --- htdocs/accountancy/admin/productaccount.php | 28 +++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 08b81ddaabb..d88800016a8 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -57,6 +57,7 @@ $changeaccount_sell = GETPOST('changeaccount_sell', 'array'); $search_ref = GETPOST('search_ref', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); $search_current_account = GETPOST('search_current_account', 'alpha'); $search_current_account_valid = GETPOST('search_current_account_valid', 'alpha'); if ($search_current_account_valid == '') $search_current_account_valid = 'withoutvalidaccount'; @@ -102,6 +103,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_ref = ''; $search_label = ''; $search_desc = ''; + $search_vat = ''; $search_onsell = ''; $search_onpurchase = ''; $search_current_account = ''; @@ -136,7 +138,7 @@ if ($action == 'update') { if (!empty($chk_prod)) { $accounting = new AccountingAccount($db); - //$msg .= '
' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
'; + //$msg .= '
' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
'; $arrayofdifferentselectedvalues = array(); $cpt = 0; $ok = 0; $ko = 0; @@ -152,7 +154,7 @@ if ($action == 'update') { } if ($result <= 0) { // setEventMessages(null, $accounting->errors, 'errors'); - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$sql.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$sql.'
'; $ko++; } else { $db->begin(); @@ -243,7 +245,7 @@ $pcgverid = $conf->global->CHARTOFACCOUNTS; $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); if (empty($pcgvercode)) $pcgvercode = $pcgverid; -$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy,"; +$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,"; $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; $sql .= " p.tms, p.fk_product_type as product_type,"; @@ -311,6 +313,9 @@ if (strlen(trim($search_label))) { if (strlen(trim($search_desc))) { $sql .= natural_search("p.description", $search_desc); } +if (strlen(trim($search_vat))) { + $sql .= natural_search("p.tva_tx", price2num($search_vat), 1); +} if ($search_onsell != '' && $search_onsell != '-1') $sql .= natural_search('p.tosell', $search_onsell, 1); if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql .= natural_search('p.tobuy', $search_onpurchase, 1); @@ -343,6 +348,7 @@ if ($result) if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref); if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); + if ($search_vat > 0) $param .= '&search_vat='.urlencode($search_vat); if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); @@ -411,6 +417,8 @@ if ($result) print ''; print ''; print ''; + print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print ''; // On sell if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { @@ -437,7 +445,8 @@ if ($result) print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); - // On sell / On purchase + print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); + // On sell / On purchase if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); $fieldtosortaccount = "p.accountancy_code_sell"; @@ -553,11 +562,16 @@ if ($result) { // TODO ADJUST DESCRIPTION SIZE // print '' . $obj->description . ''; - // TODO: we shoul set a user defined value to adjust user square / wide screen size - $trunclengh = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; - print ''.nl2br(dol_trunc($obj->description, $trunclengh)).''; + // TODO: we should set a user defined value to adjust user square / wide screen size + $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + print ''.nl2br(dol_trunc($obj->description, $trunclength)).''; } + // VAT + print ''; + print vatrate($obj->tva_tx); + print ''; + if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') print ''.$product_static->getLibStatut(3, 0).''; From 988a532bed7502235120246146deaa26a9807229 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 28 Sep 2020 16:37:17 +0200 Subject: [PATCH 30/46] fix br --- htdocs/comm/action/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index d158528ce0f..07bc0dd481b 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1697,7 +1697,7 @@ if ($id > 0) print $langs->trans("Done"); print ' '; } - print '
'; + print '
'; } } } @@ -2009,7 +2009,7 @@ if ($id > 0) print $langs->trans("Done"); print ' '; } - print '
'; + print '
'; } } From 6c1700d84a7dc3396222459ccae107700b688df2 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 28 Sep 2020 08:12:12 +0200 Subject: [PATCH 31/46] Fix contratcs are always zero on statistics board --- htdocs/contrat/class/contrat.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 1153f89689d..58be7fdcb45 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2329,7 +2329,7 @@ class Contrat extends CommonObject { while ($obj = $this->db->fetch_object($resql)) { - $this->nb["Contracts"] = $obj->nb; + $this->nb["contracts"] = $obj->nb; } $this->db->free($resql); return 1; From 43c167f0c8a21bb96dea59a19e11182cdc9f4322 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 20:47:36 +0200 Subject: [PATCH 32/46] Fix init var --- htdocs/core/class/CMailFile.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 2c158fefc39..709b0f25189 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1544,6 +1544,7 @@ class CMailFile $i = 0; foreach ($arrayaddress as $val) { + $regs = array(); if (preg_match('/^(.*)<(.*)>$/i', trim($val), $regs)) { $name = trim($regs[1]); From 572b012344731dba71c1cb8ab63cd41f4b75c159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Mon, 28 Sep 2020 22:06:15 +0200 Subject: [PATCH 33/46] Fix API $includeparentid when get product --- htdocs/product/class/api_products.class.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index a90c9dd5b1b..6c75d96fe89 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -72,15 +72,16 @@ class Products extends DolibarrApi * @param int $id ID of product * @param int $includestockdata Load also information about stock (slower) * @param bool $includesubproducts Load information about subproducts + * @param bool $includeparentid Load also ID of parent product (if product is a variant of a parent product) * @return array|mixed Data without useless information * * @throws RestException 401 * @throws RestException 403 * @throws RestException 404 */ - public function get($id, $includestockdata = 0, $includesubproducts = false) + public function get($id, $includestockdata = 0, $includesubproducts = false, $includeparentid = false) { - return $this->_fetch($id, '', '', '', $includestockdata, $includesubproducts); + return $this->_fetch($id, '', '', '', $includestockdata, $includesubproducts, $includeparentid); } /** @@ -91,6 +92,7 @@ class Products extends DolibarrApi * @param string $ref Ref of element * @param int $includestockdata Load also information about stock (slower) * @param bool $includesubproducts Load information about subproducts + * @param bool $includeparentid Load also ID of parent product (if product is a variant of a parent product) * * @return array|mixed Data without useless information * @@ -100,9 +102,9 @@ class Products extends DolibarrApi * @throws RestException 403 * @throws RestException 404 */ - public function getByRef($ref, $includestockdata = 0, $includesubproducts = false) + public function getByRef($ref, $includestockdata = 0, $includesubproducts = false, $includeparentid = false) { - return $this->_fetch('', $ref, '', '', $includestockdata, $includesubproducts); + return $this->_fetch('', $ref, '', '', $includestockdata, $includesubproducts, $includeparentid); } /** @@ -113,6 +115,7 @@ class Products extends DolibarrApi * @param string $ref_ext Ref_ext of element * @param int $includestockdata Load also information about stock (slower) * @param bool $includesubproducts Load information about subproducts + * @param bool $includeparentid Load also ID of parent product (if product is a variant of a parent product) * * @return array|mixed Data without useless information * @@ -122,9 +125,9 @@ class Products extends DolibarrApi * @throws RestException 403 * @throws RestException 404 */ - public function getByRefExt($ref_ext, $includestockdata = 0, $includesubproducts = false) + public function getByRefExt($ref_ext, $includestockdata = 0, $includesubproducts = false, $includeparentid = false) { - return $this->_fetch('', '', $ref_ext, '', $includestockdata, $includesubproducts); + return $this->_fetch('', '', $ref_ext, '', $includestockdata, $includesubproducts, $includeparentid); } /** @@ -135,6 +138,7 @@ class Products extends DolibarrApi * @param string $barcode Barcode of element * @param int $includestockdata Load also information about stock (slower) * @param bool $includesubproducts Load information about subproducts + * @param bool $includeparentid Load also ID of parent product (if product is a variant of a parent product) * * @return array|mixed Data without useless information * @@ -144,9 +148,9 @@ class Products extends DolibarrApi * @throws RestException 403 * @throws RestException 404 */ - public function getByBarcode($barcode, $includestockdata = 0, $includesubproducts = false) + public function getByBarcode($barcode, $includestockdata = 0, $includesubproducts = false, $includeparentid = false) { - return $this->_fetch('', '', '', $barcode, $includestockdata, $includesubproducts); + return $this->_fetch('', '', '', $barcode, $includestockdata, $includesubproducts, $includeparentid); } /** From 9662c4110aa4c3287a4df58e50cdfdfe524bc99a Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Tue, 29 Sep 2020 01:26:18 +0100 Subject: [PATCH 34/46] new:bankline_prepare_head for bank lines --- htdocs/compta/bank/line.php | 14 ++----- htdocs/core/lib/payments.lib.php | 63 +++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 7502d4644f5..7548b65bb1c 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -32,6 +32,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other')); @@ -246,16 +247,7 @@ foreach ($cats as $cat) { $arrayselected[] = $cat->id; } -$tabs = array( - array( - DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$rowid, - $langs->trans('BankTransaction') - ), - array( - DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$rowid, - $langs->trans('Info') - ) -); +$head = bankline_prepare_head($rowid); $sql = "SELECT b.rowid,b.dateo as do,b.datev as dv, b.amount, b.label, b.rappro,"; @@ -296,7 +288,7 @@ if ($result) print ''; print ''; - dol_fiche_head($tabs, 0, $langs->trans('LineRecord'), 0, 'accountline', 0); + dol_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'account', 0); $linkback = ''.$langs->trans("BackToList").''; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 969eb05328c..02b5727e174 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -2,6 +2,7 @@ /** * Copyright (C) 2013 Marcos García * Copyright (C) 2018 Frédéric France + * Copyright (C) 2020 Abbes Bahfir * * 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 @@ -28,15 +29,15 @@ function payment_prepare_head(Paiement $object) { - global $langs, $conf; + global $langs, $conf; - $h = 0; - $head = array(); + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("Payment"); - $head[$h][2] = 'payment'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$object->id; + $head[$h][1] = $langs->trans("Payment"); + $head[$h][2] = 'payment'; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -44,14 +45,50 @@ function payment_prepare_head(Paiement $object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment'); - $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id; - $head[$h][1] = $langs->trans("Info"); - $head[$h][2] = 'info'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; - complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment', 'remove'); - return $head; + return $head; +} + +/** + * Returns an array with the tabs for the "Bannkline" section + * It loads tabs from modules looking for the entity payment + * + * @param Bankline $object Current payment object + * @return array Tabs for the Bankline section + */ +function bankline_prepare_head($id) +{ + + global $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$id; + $head[$h][1] = $langs->trans('BankTransaction'); + $head[$h][2] = 'bankline'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline'); + + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + + complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline', 'remove'); + + return $head; } /** From 3e612d2a9448497c0a304d0f3ae61b2de948e418 Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Tue, 29 Sep 2020 12:13:41 +0200 Subject: [PATCH 35/46] Added support for styling in lines --- htdocs/core/class/extrafields.class.php | 3 +++ htdocs/includes/odtphp/Segment.php | 10 +++------- htdocs/includes/odtphp/odf.php | 24 ++++++++++++++++++++---- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index b2f8905aba9..dcac977566b 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2097,6 +2097,9 @@ class ExtraFields if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_key = price2num($value_arr); + } elseif (in_array($key_type, array('text'))) { + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. + $value_key = GETPOST($keysuffix."options_".$key.$keyprefix, 'alpha'); } else { if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index cd8bec8c4ff..ca8797ba577 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -231,14 +231,10 @@ class Segment implements IteratorAggregate, Countable //throw new SegmentException("var $key not found in {$this->getName()}"); } - $value=$this->odf->htmlToUTFAndPreOdf($value); + $tag = $this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT'); - $value = $encode ? htmlspecialchars($value) : $value; - $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value; - - $value=$this->odf->preOdfToOdf($value); - - $this->vars[$this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT')] = $value; + $this->vars[$tag] = $this->odf->convertVarToOdf($value, $encode, $charset); + return $this; } /** diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 45e442462b4..88341da4adf 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -141,7 +141,23 @@ class Odf //} } + $this->vars[$tag] = $this->convertVarToOdf($value, $encode, $charset); + + return $this; + } + + /** + * Replaces html tags in odt tags and returns a compatible string + * @param string $key Name of the variable within the template + * @param string $value Replacement value + * @param bool $encode If true, special XML characters are encoded + * @param string $charset Charset + * @return string + */ + public function convertVarToOdf($value, $encode = true, $charset = 'ISO-8859') + { $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value; + $convertedValue = $value; // Check if the value includes html tags if ($this->_hasHtmlTag($value) === true) { @@ -155,7 +171,7 @@ class Odf '' ); - $this->vars[$tag] = $this->_replaceHtmlWithOdtTag($this->_getDataFromHtml($value), $customStyles, $fontDeclarations); + $convertedValue = $this->_replaceHtmlWithOdtTag($this->_getDataFromHtml($value), $customStyles, $fontDeclarations); foreach ($customStyles as $key => $val) { array_push($automaticStyles, '' . $val . ''); @@ -179,9 +195,9 @@ class Odf } $this->contentXml = str_replace('', $fonts . '', $this->contentXml); } - else $this->vars[$tag] = preg_replace('/(\r\n|\r|\n)/i', "", $value); - - return $this; + else $convertedValue = preg_replace('/(\r\n|\r|\n)/i', "", $value); + + return $convertedValue; } /** From 4611333ee6f7cc600e48430bebd6ebde601bc137 Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Tue, 29 Sep 2020 12:17:25 +0200 Subject: [PATCH 36/46] Added support for styling in lines --- htdocs/includes/odtphp/Segment.php | 10 +++------- htdocs/includes/odtphp/odf.php | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index cd8bec8c4ff..ca8797ba577 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -231,14 +231,10 @@ class Segment implements IteratorAggregate, Countable //throw new SegmentException("var $key not found in {$this->getName()}"); } - $value=$this->odf->htmlToUTFAndPreOdf($value); + $tag = $this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT'); - $value = $encode ? htmlspecialchars($value) : $value; - $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value; - - $value=$this->odf->preOdfToOdf($value); - - $this->vars[$this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT')] = $value; + $this->vars[$tag] = $this->odf->convertVarToOdf($value, $encode, $charset); + return $this; } /** diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 45e442462b4..88341da4adf 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -141,7 +141,23 @@ class Odf //} } + $this->vars[$tag] = $this->convertVarToOdf($value, $encode, $charset); + + return $this; + } + + /** + * Replaces html tags in odt tags and returns a compatible string + * @param string $key Name of the variable within the template + * @param string $value Replacement value + * @param bool $encode If true, special XML characters are encoded + * @param string $charset Charset + * @return string + */ + public function convertVarToOdf($value, $encode = true, $charset = 'ISO-8859') + { $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value; + $convertedValue = $value; // Check if the value includes html tags if ($this->_hasHtmlTag($value) === true) { @@ -155,7 +171,7 @@ class Odf '' ); - $this->vars[$tag] = $this->_replaceHtmlWithOdtTag($this->_getDataFromHtml($value), $customStyles, $fontDeclarations); + $convertedValue = $this->_replaceHtmlWithOdtTag($this->_getDataFromHtml($value), $customStyles, $fontDeclarations); foreach ($customStyles as $key => $val) { array_push($automaticStyles, '' . $val . ''); @@ -179,9 +195,9 @@ class Odf } $this->contentXml = str_replace('', $fonts . '', $this->contentXml); } - else $this->vars[$tag] = preg_replace('/(\r\n|\r|\n)/i', "", $value); - - return $this; + else $convertedValue = preg_replace('/(\r\n|\r|\n)/i', "", $value); + + return $convertedValue; } /** From 82b3b5612d0ba37ab0b79811789679cfe2597650 Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Tue, 29 Sep 2020 12:19:19 +0200 Subject: [PATCH 37/46] Update extrafields.class.php That change should not be included in the PR --- htdocs/core/class/extrafields.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index dcac977566b..b2f8905aba9 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2097,9 +2097,6 @@ class ExtraFields if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_key = price2num($value_arr); - } elseif (in_array($key_type, array('text'))) { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. - $value_key = GETPOST($keysuffix."options_".$key.$keyprefix, 'alpha'); } else { if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); From 1f8f2c0cc39e22637f755766eb98f2ffb5b8afcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Sep 2020 13:13:47 +0200 Subject: [PATCH 38/46] NEW Add 2 rules for emailcollector: Message send/not sent from Dolibarr --- htdocs/admin/emailcollector_card.php | 8 +++--- .../core/modules/modEmailCollector.class.php | 27 ++++++++++--------- .../class/emailcollector.class.php | 2 ++ .../class/emailcollectorfilter.class.php | 2 +- htdocs/langs/en_US/admin.lang | 4 ++- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 9d5dcbc32e3..1420cc0263e 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -496,6 +496,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea 'X3'=>'---', 'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1), 'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1), + 'withtrackingidinmsgid'=>array('label'=>'WithDolTrackingIDInMsgId', 'data-noparam'=>1), + 'withouttrackingidinmsgid'=>array('label'=>'WithoutDolTrackingIDInMsgId', 'data-noparam'=>1), 'X4'=>'---', 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), 'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1) @@ -538,7 +540,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''.$rulefilter['rulevalue'].''; print ''; - print ' '.img_delete().''; + print ' '.img_delete().''; print ''; print ''; } @@ -630,7 +632,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Delete print ''; print ''.img_edit().''; - print ' '.img_delete().''; + print ' '.img_delete().''; print ''; print ''; $i++; @@ -677,7 +679,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } - print ''; + print ''; } print '
'."\n"; } diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index befebc84fea..86bf582edf2 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -306,23 +306,26 @@ class modEmailCollector extends DolibarrModules } } else dol_print_error($this->db); - $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Answers' and entity = ".$conf->entity; + $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity; $tmpresql = $this->db->query($tmpsql); if ($tmpresql) { if ($this->db->num_rows($tmpresql) == 0) { - $descriptionA1 = 'This collector will scan your mailbox "Sent" directory to find emails that was sent as an answer of a Ticket (Module Ticket must be enabled) directly from your email browser instead of from Dolibarr. If such an email is found, the event of answer is recorded into Dolibarr.'; + $descriptionA1 = 'This collector will scan your mailbox "Sent" directory to find emails that was sent as an answer of another email directly from your email software and not from Dolibarr. If such an email is found, the event of answer is recorded into Dolibarr.'; $sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; - $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Answers', 'Example to collect answers to tickets', '".$this->db->escape($descriptionA1)."', 'Sent', '".$this->db->idate(dol_now())."', ".$user->id.", 0)"; - /* - $sqlforexampleA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleA3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)"; - $sqlforexampleA3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'to', 'support@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - $sqlforexampleA4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleA4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'ticket', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; - */ + $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Responses_Out', 'Example to collect answers to emails done from email software', '".$this->db->escape($descriptionA1)."', 'Sent', '".$this->db->idate(dol_now())."', ".$user->id.", 0)"; + + $sqlforexampleFilterA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; + $sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity."), 'isanswer', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; + $sqlforexampleFilterA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; + $sqlforexampleFilterA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity."), 'withouttrackingidinmsgid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; + $sqlforexampleActionA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)"; + $sqlforexampleActionA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity."), 'recordevent', '".$this->db->idate(dol_now())."', ".$user->id.", 1)"; + $sql[] = $sqlforexampleA1; + $sql[] = $sqlforexampleFilterA1; + $sql[] = $sqlforexampleFilterA2; + $sql[] = $sqlforexampleActionA1; } } @@ -330,7 +333,7 @@ class modEmailCollector extends DolibarrModules $tmpresql = $this->db->query($tmpsql); if ($tmpresql) { if ($this->db->num_rows($tmpresql) == 0) { - $descriptionB1 = 'This collector will scan your mailbox to find all emails that are an answer of an email sent from your application. An event with the email response will be recorded at the good place (Module Agenda must be enabled). For example, if your send a commercial proposal, order or invoice by email and your customer answers your email, the system will automatically find the answer and add it into your ERP.'; + $descriptionB1 = 'This collector will scan your mailbox to find all emails that are an answer of an email sent from your application. An event (Module Agenda must be enabled) with the email response will be recorded at the good place. For example, if your send a commercial proposal, order, invoice or message for a ticket by email from the application, and your customer answers your email, the system will automatically find the answer and add it into your ERP.'; $sqlforexampleB1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; $sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses_In', 'Example to collect any input email responses', '".$this->db->escape($descriptionB1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)"; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index b070b69b4c9..943b7c73fb3 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1006,6 +1006,8 @@ class EmailCollector extends CommonObject if ($rule['type'] == 'smaller') $search .= ($search ? ' ' : '').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; if ($rule['type'] == 'larger') $search .= ($search ? ' ' : '').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'withtrackingidinmsgid') { $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/'; } + if ($rule['type'] == 'withouttrackingidinmsgid') { $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/'; } if ($rule['type'] == 'withtrackingid') { $searchfilterdoltrackid++; $searchhead .= '/References.*@'.preg_quote($host, '/').'/'; } if ($rule['type'] == 'withouttrackingid') { $searchfilternodoltrackid++; $searchhead .= '! /References.*@'.preg_quote($host, '/').'/'; } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index 40c8a91d235..cb8db05fa34 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -165,7 +165,7 @@ class EmailCollectorFilter extends CommonObject $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); return -1; } - if (!in_array($this->type, array('seen', 'unseen', 'unanswered', 'answered', 'withtrackingid', 'withouttrackingid', 'isanswer', 'isnotanswer')) && empty($this->rulevalue)) + if (!in_array($this->type, array('seen', 'unseen', 'unanswered', 'answered', 'withtrackingidinmsgid', 'withouttrackingidinmsgid', 'withtrackingid', 'withouttrackingid', 'isanswer', 'isnotanswer')) && empty($this->rulevalue)) { $langs->load("errors"); $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SearchString")); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1498639d731..63ce07f7d79 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1988,6 +1988,8 @@ LoadThirdPartyFromName=Load third party searching on %s (load only) LoadThirdPartyFromNameOrCreate=Load third party searching on %s (create if not found) WithDolTrackingID=Message from a conversation initiated by a first email sent from Dolibarr WithoutDolTrackingID=Message from a conversation initiated by a first email NOT sent from Dolibarr +WithDolTrackingIDInMsgId=Message sent from Dolibarr +WithoutDolTrackingIDInMsgId=Message NOT sent from Dolibarr CreateCandidature=Create candidature FormatZip=Zip MainMenuCode=Menu entry code (mainmenu) @@ -2030,7 +2032,7 @@ ImportSetup=Setup of module Import InstanceUniqueID=Unique ID of the instance SmallerThan=Smaller than LargerThan=Larger than -IfTrackingIDFoundEventWillBeLinked=Note that If a tracking ID of an object is found into incoming email, or if the email is an answer of an email aready collected and linked to an object, the event will be automatically linked to the known related object too. +IfTrackingIDFoundEventWillBeLinked=Note that If a tracking ID of an object is found into email, or if the email is an answer of an email aready collected and linked to an object, the created event will be automatically linked to the known related object. WithGMailYouCanCreateADedicatedPassword=With a GMail account, if you enabled the 2 steps validation, it is recommanded to create a dedicated second password for the application instead of using your own account passsword from https://myaccount.google.com/. EmailCollectorTargetDir=It may be a desired behaviour to move the email into another tag/directory when it was processed successfully. Just set name of directory here to use this feature (Do NOT use special characters in name). Note that you must also use a read/write login account. EmailCollectorLoadThirdPartyHelp=You can use this action to use the email content to find and load an existing thirdparty in your database. The found (or created) thirdparty will be used for following actions that need it. In the parameter field you can use for example 'EXTRACT:BODY:Name:\s([^\s]*)' if you want to extract the name of the thirdparty from a string 'Name: name to find' found into the body. From 1ed6312f4b0d83131ac8f74f2f3b41b74a796d3b Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 29 Sep 2020 14:08:49 +0200 Subject: [PATCH 39/46] add modification of the notifications --- htdocs/comm/action/card.php | 136 +++++++++++++++++++++++++++++------- 1 file changed, 109 insertions(+), 27 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 07bc0dd481b..94119fbee5c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -393,7 +393,7 @@ if (empty($reshook) && $action == 'add') $moreparam = ''; if ($user->id != $object->userownerid) $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. - //Create reminder + //Create reminders if ($addreminder == 'on'){ $actionCommReminder = new ActionCommReminder($db); @@ -639,9 +639,51 @@ if (empty($reshook) && $action == 'update') $categories = GETPOST('categories', 'array'); $object->setCategories($categories); + $object->loadReminders(); + if (!empty($object->reminders)) + { + foreach ($object->reminders as $reminder) + { + $reminder->delete($user); + } + $object->reminders = array(); + } + + //Create reminders + if ($addreminder == 'on'){ + $actionCommReminder = new ActionCommReminder($db); + + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); + + $actionCommReminder->dateremind = $dateremind; + $actionCommReminder->typeremind = $remindertype; + $actionCommReminder->offsetunit = $offsetunit; + $actionCommReminder->offsetvalue = $offsetvalue; + $actionCommReminder->status = $actionCommReminder::STATUS_TODO; + $actionCommReminder->fk_actioncomm = $object->id; + if ($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail; + + // the notification must be created for every user assigned to the event + foreach ($object->userassigned as $userassigned) + { + $actionCommReminder->fk_user = $userassigned['id']; + $res = $actionCommReminder->create($user); + + if ($res <= 0){ + // If error + $langs->load("errors"); + $error = $langs->trans('ErrorReminderActionCommCreation'); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; + break; + } + } + } + unset($_SESSION['assignedtouser']); - $db->commit(); + if (!$error) $db->commit(); + else $db->rollback(); } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); @@ -1673,38 +1715,78 @@ if ($id > 0) print '
'; - print ''; - - print ''; + + print '
'; + + print '
'.$langs->trans("Reminders").''; - if (count($object->reminders) > 0) { - if (count($object->reminders) > 0) { - $tmpuserstatic = new User($db); + $checked = 'checked'; + $keys = array_keys($object->reminders); + $firstreminderId = array_shift($keys); - foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { - print $TRemindTypes[$actioncommreminder->typeremind]; - if ($actioncommreminder->fk_user > 0) { - $tmpuserstatic->fetch($actioncommreminder->fk_user); - print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; - } - print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; - if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { - print ' - '; - print $langs->trans("NotSent"); - print ' '; - } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) { - print ' - '; - print $langs->trans("Done"); - print ' '; - } - print '
'; - } - } + $actionCommReminder = $object->reminders[$firstreminderId]; + + } + else + { + $checked = ''; + $actionCommReminder = new ActionCommReminder($db); + $actionCommReminder->offsetvalue = 10; + $actionCommReminder->offsetunit = 'i'; + $actionCommReminder->typeremind = 'email'; } + print '
'.$langs->trans("AddReminder").'
'; + + //Reminder + print ''; + + //Time Type + print ''; + + //Reminder Type + $TRemindTypes = array(); + if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['email'] = $langs->trans('EMail'); + if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['browser'] = $langs->trans('BrowserPush'); + print ''; + + $hide = ''; + if ($actionCommReminder->typeremind == 'browser') $hide = 'style="display:none;"'; + + //Mail Model + print ''; print '
'.$langs->trans("ReminderTime").''; + print ''; + print '
'.$langs->trans("TimeType").''; + print $form->selectTypeDuration('offsetunit', $actionCommReminder->offsetunit); + print '
'.$langs->trans("ReminderType").''; + print $form->selectarray('selectremindertype', $TRemindTypes, $actionCommReminder->typeremind); + print '
'.$langs->trans("EMailTemplates").''; + print $form->selectModelMail('actioncommsend', 'actioncomm_send', 1); print '
'; + + print "\n".''."\n"; } dol_fiche_end(); From a61f79c039e081eced1ad0420a46f7a4799b95d6 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 29 Sep 2020 14:10:24 +0200 Subject: [PATCH 40/46] only update reminders if event is not past --- htdocs/comm/action/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 94119fbee5c..3818f459893 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -640,7 +640,7 @@ if (empty($reshook) && $action == 'update') $object->setCategories($categories); $object->loadReminders(); - if (!empty($object->reminders)) + if (!empty($object->reminders) && $object->datep > dol_now()) { foreach ($object->reminders as $reminder) { @@ -650,7 +650,7 @@ if (empty($reshook) && $action == 'update') } //Create reminders - if ($addreminder == 'on'){ + if ($addreminder == 'on' && $object->datep > dol_now()){ $actionCommReminder = new ActionCommReminder($db); $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); From babcc3bc910229b2eff852d9a4f06c5377c522f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Sep 2020 16:39:47 +0200 Subject: [PATCH 41/46] Update line.php --- htdocs/compta/bank/line.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 7548b65bb1c..4e2998792d8 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -288,7 +288,7 @@ if ($result) print ''; print ''; - dol_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'account', 0); + dol_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0); $linkback = ''.$langs->trans("BackToList").''; From ac897b5b4d62750f94e8d2e8ff518789fb0b1092 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Sep 2020 17:06:08 +0200 Subject: [PATCH 42/46] Fix css --- htdocs/takepos/css/pos.css.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 503ae0123f9..973bbabba2d 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -716,7 +716,8 @@ div#moreinfo, div#infowarehouse { width: 40%; box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19); animation-name: animatetop; - animation-duration: 0.4s + animation-duration: 0.4s; + min-width: 200px; } @keyframes animatetop { From 82da38df65e53f0a9834f697c6c598ca66812901 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Sep 2020 19:57:10 +0200 Subject: [PATCH 43/46] Removed dead code --- htdocs/admin/pdf.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 95487fc0bc3..363edca6c80 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -89,18 +89,6 @@ if ($action == 'update') exit; } -if ($action == 'activate_pdfsecurity') -{ - dolibarr_set_const($db, "PDF_SECURITY_ENCRYPTION", "1", 'chaine', 0, '', $conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); - exit; -} elseif ($action == 'disable_pdfsecurity') -{ - dolibarr_del_const($db, "PDF_SECURITY_ENCRYPTION", $conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); - exit; -} - /* From 879d0413985bd48704f7b1ff4f21e23cd0d1e3e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Sep 2020 20:48:40 +0200 Subject: [PATCH 44/46] Can force the typeof check of GETPOST into $fields for type text. --- htdocs/core/actions_addupdatedelete.inc.php | 9 +++++++-- htdocs/core/class/commonobject.class.php | 6 +++--- htdocs/core/tpl/commonfields_edit.tpl.php | 14 +++++++++++--- .../template/class/myobject.class.php | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 4d4c12ce473..cee75415eee 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -141,8 +141,13 @@ if ($action == 'update' && !empty($permissiontoadd)) if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Set value to update - if (in_array($object->fields[$key]['type'], array('text', 'html'))) { - $value = GETPOST($key, 'restricthtml'); + if (preg_match('/^(text|html)/', $object->fields[$key]['type'])) { + $tmparray = explode(':', $object->fields[$key]['type']); + if (!empty($tmparray[1])) { + $value = GETPOST($key, $tmparray[1]); + } else { + $value = GETPOST($key, 'restricthtml'); + } } elseif ($object->fields[$key]['type'] == 'date') { $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif ($object->fields[$key]['type'] == 'datetime') { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 384c778d602..46567edf369 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5800,7 +5800,7 @@ abstract class CommonObject } elseif (in_array($type, array('mail', 'phone', 'url'))) { $out = ''; - } elseif ($type == 'text') + } elseif (preg_match('/^text/', $type)) { if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { @@ -5810,7 +5810,7 @@ abstract class CommonObject } else { $out = ''; } - } elseif ($type == 'html') + } elseif (preg_match('/^html/', $type)) { if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { @@ -6584,7 +6584,7 @@ abstract class CommonObject return 'Error bad setup of extrafield'; } } else $value = ''; - } elseif ($type == 'text' || $type == 'html') + } elseif (preg_match('/^(text|html)/', $type)) { $value = dol_htmlentitiesbr($value); } elseif ($type == 'password') diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index ace640d9b79..ad1a3bd2330 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -45,15 +45,23 @@ foreach ($object->fields as $key => $val) print ''; if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); else print $langs->trans($val['label']); print ''; print ''; if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key; - elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key) ?GETPOST($key, 'restricthtml') : $object->$key; - else $value = GETPOSTISSET($key) ?GETPOST($key, 'alpha') : $object->$key; + elseif (preg_match('/^(text|html)/', $val['type'])) { + $tmparray = explode(':', $val['type']); + if (!empty($tmparray[1])) { + $check = $tmparray[1]; + } else { + $check = 'restricthtml'; + } + $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key; + } + else $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key; //var_dump($val.' '.$key.' '.$value); if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0); else print $object->showInputField($val, $key, $value, '', '', '', 0); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 399dd3b10b8..8465f804d5c 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -70,7 +70,7 @@ class MyObject extends CommonObject /** - * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) From 1e176fad8fed1d8e89c9009f5e2cf0fc2069b51d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Sep 2020 21:28:07 +0200 Subject: [PATCH 45/46] Fix GETPOST on array --- htdocs/core/class/html.formmail.class.php | 18 ++++++++++-------- htdocs/core/lib/functions.lib.php | 10 ++++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index fcd7199137c..e2749c5e183 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -653,7 +653,7 @@ class FormMail extends Form $out .= ' <'.$this->tomail.'>'; if ($this->withtofree) { - $out .= '
'.$langs->trans("and").' withto) : "").'" />'; + $out .= '
'.$langs->trans("and").' withto) : "").'" />'; } } else { // Note withto may be a text like 'AllRecipientSelected' @@ -663,7 +663,7 @@ class FormMail extends Form // The free input of email if (!empty($this->withtofree)) { - $out .= 'withto) : "")).'" />'; + $out .= 'withto) : "")).'" />'; } // The select combo if (!empty($this->withto) && is_array($this->withto)) @@ -675,7 +675,9 @@ class FormMail extends Form { $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtoselected = GETPOST("receiver", 'restricthtml'); // Array of selected value + + $withtoselected = GETPOST("receiver", 'array'); // Array of selected value + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { $withtoselected = array_keys($tmparray); @@ -699,7 +701,7 @@ class FormMail extends Form { $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtoselected = GETPOST("receiveruser", 'restricthtml'); // Array of selected value + $withtoselected = GETPOST("receiveruser", 'array'); // Array of selected value if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { $withtoselected = array_keys($tmparray); @@ -743,7 +745,7 @@ class FormMail extends Form { $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtoccselected = GETPOST("receivercc"); // Array of selected value + $withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value $out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', null, ""); } } @@ -763,7 +765,7 @@ class FormMail extends Form { $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtoselected = GETPOST("receiverccuser", 'restricthtml'); // Array of selected value + $withtoselected = GETPOST("receiverccuser", 'array'); // Array of selected value if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { $withtoselected = array_keys($tmparray); @@ -1060,7 +1062,7 @@ class FormMail extends Form if (!empty($this->withtocccreadonly)) { $out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : ""; } else { - $out .= 'withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />'; + $out .= 'withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />'; if (!empty($this->withtoccc) && is_array($this->withtoccc)) { $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time @@ -1068,7 +1070,7 @@ class FormMail extends Form foreach ($tmparray as $key => $val) { $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtocccselected = GETPOST("receiverccc"); // Array of selected value + $withtocccselected = GETPOST("receiverccc", 'array'); // Array of selected value $out .= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null, null, "90%"); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f34f2997af2..4fe156b249b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -545,12 +545,18 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null } // Check rule - if ($check == 'array') { + if (preg_match('/^array/', $check)) { // If 'array' or 'array:restricthtml' or 'array:aZ09' if (!is_array($out) || empty($out)) { $out = array(); } else { + $tmparray = explode(':', $check); + if (!empty($tmparray[1])) { + $tmpcheck = $tmparray[1]; + } else { + $tmpcheck = 'alphanohtml'; + } foreach ($out as $outkey => $outval) { - $out[$outkey] = checkVal($outval, 'alphanohtml', $filter, $options); + $out[$outkey] = checkVal($outval, $tmpcheck, $filter, $options); } } } From f063a144c12e991d716cacbe18e3c5ff5e76e9e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Sep 2020 21:51:39 +0200 Subject: [PATCH 46/46] NEW Can add event to log into blockedlog module with a constant. --- htdocs/blockedlog/class/blockedlog.class.php | 7 +++++++ .../interface_50_modBlockedlog_ActionsBlockedLog.class.php | 1 + 2 files changed, 8 insertions(+) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 7bb252394c3..b8d0304c5eb 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -185,6 +185,13 @@ class BlockedLog // $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all POS modules $moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || !empty($conf->global->BANK_ENABLE_POS_CASHCONTROL)); if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE'] = 'logCASHCONTROL_VALIDATE'; + + if (!empty($conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED)) { + $tmparrayofmoresupportedevents = explode(',', $conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED); + foreach ($tmparrayofmoresupportedevents as $val) { + $this->trackedevents[$val] = 'log'.$val; + } + } } /** diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 19eab2e5974..0800d66eea3 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -83,6 +83,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers || $action === 'CASHCONTROL_VALIDATE' || (in_array($object->element, array('facture', 'supplier_invoice')) && $action === 'DOC_DOWNLOAD' && $object->statut != 0) || (in_array($object->element, array('facture', 'supplier_invoice')) && $action === 'DOC_PREVIEW' && $object->statut != 0) + || (!empty($conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED) && in_array($action, explode(',', $conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED))) ) { $qualified++;