From d0a1c523ca9245384fe440d1661bdacbe7b91039 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Dec 2018 19:35:38 +0100 Subject: [PATCH 1/8] FIX several critical bugs in migration of directory of users --- htdocs/ecm/class/ecmfiles.class.php | 11 +++++++++-- htdocs/install/upgrade2.php | 11 ++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 42af7f92635..70e79a6a3e5 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -180,8 +180,15 @@ class EcmFiles extends CommonObject if (empty($this->date_m)) $this->date_m = dol_now(); // If ref not defined - $ref = dol_hash($this->filepath.'/'.$this->filename, 3); - if (! empty($this->ref)) $ref=$this->ref; + $ref = ''; + if (! empty($this->ref)) + { + $ref=$this->ref; + } + else { + include_once DOL_DOCUMENT_ROOT.'/lib/security.lib.php'; + $ref = dol_hash($this->filepath.'/'.$this->filename, 3); + } $maxposition=0; if (empty($this->position)) // Get max used diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 13d7d341961..9e5072ba211 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4860,7 +4860,8 @@ function migrate_user_photospath() } if ($dir) { - $origin = $dir .'/'. get_exdir($fuser->id,2,0,0,$fuser,'user'); + //print "Process user id ".$fuser->id."
\n"; + $origin = $dir .'/'. get_exdir($fuser->id,2,0,1,$fuser,'user'); // Use old behaviour to get x/y path $destin = $dir .'/'. $fuser->id; $origin_osencoded=dol_osencode($origin); @@ -4888,8 +4889,10 @@ function migrate_user_photospath() { if ($thumb == '.' || $thumb == '..') continue; + //print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.'
'."\n"; print '.'; - dol_move($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb, 0, 0, 0, 0); + dol_copy($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb, 0, 0); + //var_dump('aaa');exit; } } // dol_delete_dir($origin.'/'.$file); @@ -4899,8 +4902,10 @@ function migrate_user_photospath() { if (! dol_is_file($destin.'/'.$file)) { + //print $origin.'/'.$file.' -> '.$destin.'/'.$file.'
'."\n"; print '.'; - dol_move($origin.'/'.$file, $destin.'/'.$file, 0, 0, 0, 1); + dol_copy($origin.'/'.$file, $destin.'/'.$file, 0, 0); + //var_dump('eee');exit; } } } From a44dca7e718a849e4d2d68ac2fd96e370fc66bd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 8 Dec 2018 11:37:47 +0100 Subject: [PATCH 2/8] Removed deprecated table --- .../install/mysql/migration/8.0.0-9.0.0.sql | 1 + .../mysql/tables/llx_ticket_logs.key.sql | 17 - .../install/mysql/tables/llx_ticket_logs.sql | 25 -- htdocs/ticket/class/ticketlogs.class.php | 364 ------------------ 4 files changed, 1 insertion(+), 406 deletions(-) delete mode 100755 htdocs/install/mysql/tables/llx_ticket_logs.key.sql delete mode 100755 htdocs/install/mysql/tables/llx_ticket_logs.sql delete mode 100644 htdocs/ticket/class/ticketlogs.class.php diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 040739e8ce7..98dc051e984 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -228,3 +228,4 @@ ALTER TABLE llx_emailcollector_emailcollectoraction ADD UNIQUE INDEX uk_emailcol ALTER TABLE llx_societe_rib ADD COLUMN comment varchar(255); ALTER TABLE llx_societe_rib ADD COLUMN ipaddress varchar(68); +DROP TABLE llx_ticket_logs; diff --git a/htdocs/install/mysql/tables/llx_ticket_logs.key.sql b/htdocs/install/mysql/tables/llx_ticket_logs.key.sql deleted file mode 100755 index 16bf0d9d977..00000000000 --- a/htdocs/install/mysql/tables/llx_ticket_logs.key.sql +++ /dev/null @@ -1,17 +0,0 @@ --- SQL definition for module ticket --- Copyright (C) 2013 Jean-François FERRY --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . - -ALTER TABLE llx_ticket_logs ADD CONSTRAINT fk_ticket_logs_fk_track_id FOREIGN KEY (fk_track_id) REFERENCES llx_ticket (track_id); diff --git a/htdocs/install/mysql/tables/llx_ticket_logs.sql b/htdocs/install/mysql/tables/llx_ticket_logs.sql deleted file mode 100755 index 6efbb779f40..00000000000 --- a/htdocs/install/mysql/tables/llx_ticket_logs.sql +++ /dev/null @@ -1,25 +0,0 @@ --- SQL definition for module ticket --- Copyright (C) 2013 Jean-François FERRY --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . - -CREATE TABLE llx_ticket_logs -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1, - fk_track_id varchar(128), - fk_user_create integer, - datec datetime, - message text -)ENGINE=innodb; diff --git a/htdocs/ticket/class/ticketlogs.class.php b/htdocs/ticket/class/ticketlogs.class.php deleted file mode 100644 index 66cecd6eb5e..00000000000 --- a/htdocs/ticket/class/ticketlogs.class.php +++ /dev/null @@ -1,364 +0,0 @@ - - * Copyright (C) 2018 Frédéric France - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file ticket/class/ticketlogs.class.php - * \ingroup ticket - * \brief This file CRUD class file (Create/Read/Update/Delete) for ticket logs - */ - -// Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . "/core/class/commonobject.class.php"; -//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; -//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; - - -/** - * Class of log for ticket - */ -class Ticketlogs// extends CommonObject -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error; - - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); - - /** - * @var string ID to identify managed object - */ - public $element = 'ticketlogs'; - - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'ticketlogs'; //!< Name of table without prefix where object is stored - - /** - * @var int ID - */ - public $id; - - /** - * @var string trackid - */ - public $fk_track_id; - - /** - * @var int user create ID - */ - public $fk_user_create; - - public $datec = ''; - public $message; - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } - - /** - * Create object into database - * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; - $error = 0; - - // Clean parameters - - if (isset($this->fk_track_id)) { - $this->fk_track_id = trim($this->fk_track_id); - } - - if (isset($this->fk_user_create)) { - $this->fk_user_create = (int) $this->fk_user_create; - } - - if (isset($this->message)) { - $this->message = trim($this->message); - } - - // Check parameters - // Put here code to add control on parameters values - - // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "ticket_logs("; - - $sql .= "fk_track_id,"; - $sql .= "fk_user_create,"; - $sql .= "datec,"; - $sql .= "message"; - - $sql .= ") VALUES ("; - - $sql .= " " . (!isset($this->fk_track_id) ? 'NULL' : "'" . $this->db->escape($this->fk_track_id) . "'") . ","; - $sql .= " " . (!isset($this->fk_user_create) ? 'NULL' : "'" . $this->db->escape($this->fk_user_create) . "'") . ","; - $sql .= " " . (!isset($this->datec) || dol_strlen($this->datec) == 0 ? 'NULL' : "'" . $this->db->idate($this->datec). "'") . ","; - $sql .= " " . (!isset($this->message) ? 'NULL' : "'" . $this->db->escape($this->message) . "'") . ""; - - $sql .= ")"; - - $this->db->begin(); - - dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = "Error " . $this->db->lasterror(); - } - - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "ticket_logs"); - - //if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - //} - } - - // Commit or rollback - if ($error) { - foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return $this->id; - } - } - - /** - * Load object in memory from the database - * - * @param int $id Id object - * @return int <0 if KO, >0 if OK - */ - public function fetch($id) - { - global $langs; - $sql = "SELECT"; - $sql .= " t.rowid,"; - - $sql .= " t.fk_track_id,"; - $sql .= " t.fk_user_create,"; - $sql .= " t.datec,"; - $sql .= " t.message"; - - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket_logs as t"; - $sql .= " WHERE t.rowid = " . $id; - - dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - - $this->fk_track_id = $obj->fk_track_id; - $this->fk_user_create = $obj->fk_user_create; - $this->datec = $this->db->jdate($obj->datec); - $this->message = $obj->message; - } - $this->db->free($resql); - - return 1; - } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); - return -1; - } - } - - /** - * Update object into database - * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = 0, $notrigger = 0) - { - global $conf, $langs; - $error = 0; - - // Clean parameters - - if (isset($this->fk_track_id)) { - $this->fk_track_id = trim($this->fk_track_id); - } - - if (isset($this->fk_user_create)) { - $this->fk_user_create = (int) $this->fk_user_create; - } - - if (isset($this->message)) { - $this->message = trim($this->message); - } - - // Check parameters - // Put here code to add a control on parameters values - - // Update request - $sql = "UPDATE " . MAIN_DB_PREFIX . "ticket_logs SET"; - - $sql .= " fk_track_id=" . (isset($this->fk_track_id) ? "'" . $this->db->escape($this->fk_track_id) . "'" : "null") . ","; - $sql .= " fk_user_create=" . ($this->fk_user_create > 0 ? $this->fk_user_create : "null") . ","; - $sql .= " datec=" . (dol_strlen($this->datec) != 0 ? "'" . $this->db->idate($this->datec) . "'" : 'null') . ","; - $sql .= " message=" . (isset($this->message) ? "'" . $this->db->escape($this->message) . "'" : "null") . ""; - - $sql .= " WHERE rowid=" . $this->id; - - $this->db->begin(); - - dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = "Error " . $this->db->lasterror(); - } - - //if (!$error) { - //if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - //} - //} - - // Commit or rollback - if ($error) { - foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } - - /** - * Delete object in database - * - * @param User $user User that deletes - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete($user, $notrigger = 0) - { - global $conf, $langs; - $error = 0; - - $this->db->begin(); - - //if (!$error) { - //if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - //} - //} - - if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_logs"; - $sql .= " WHERE rowid=" . $this->id; - - dol_syslog(get_class($this) . "::delete sql=" . $sql); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = "Error " . $this->db->lasterror(); - } - } - - // Commit or rollback - if ($error) { - foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } - - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - public function initAsSpecimen() - { - global $user; - - $this->id = 0; - - $this->fk_track_id = ''; - $this->fk_user_create = $user->id; - $this->datec = ''; - $this->message = ''; - } -} From 25f66bd024f49ccce675f79d009fe659faca5818 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 8 Dec 2018 14:44:52 +0100 Subject: [PATCH 3/8] Code comment --- .../core/triggers/interface_50_modAgenda_ActionsAuto.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 09725355f43..bd96128a3d7 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -757,7 +757,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } // TODO Merge all previous cases into this generic one - else + else // $action = TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ... { // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function) // Load translation files required by the page From be7e424862bd183db49e216ffd79c2627bfbf256 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Dec 2018 00:16:59 +0100 Subject: [PATCH 4/8] FIX thirdparty not set on some events --- .../core/triggers/interface_50_modAgenda_ActionsAuto.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index bd96128a3d7..43c3f7a15e4 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -799,7 +799,8 @@ class InterfaceActionsAuto extends DolibarrTriggers if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid); } // Set societeforaction. - if ($object->socid > 0) $societeforaction->fetch($object->socid); + if ($object->socid > 0) $societeforaction->fetch($object->socid); + elseif ($object->fk_soc > 0) $societeforaction->fetch($object->fk_soc); $projectid = isset($object->fk_project)?$object->fk_project:0; if ($object->element == 'project') $projectid = $object->id; From 9c68e29773779e7d799114789f43ac147cf7b63a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Dec 2018 00:24:30 +0100 Subject: [PATCH 5/8] Typo --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d609b7a347a..ad6a71f4531 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,7 +37,7 @@ NEW: add option PROPOSAL_AUTO_ADD_AUTHOR_AS_CONTACT NEW: Add option to display thirdparty adress in combolist NEW: Add option to swap sender/recipient address on PDF NEW: Add option to display thirdparty adress in combolist -NEW: Add project on pament of salaries +NEW: Add project on payment of salaries NEW: Add SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME and NEW: Add somes hooks in bank planned entries NEW: Add supplier ref in item reception page From 541c978a68dfaa7b6bd8e0f87f34e270e7671b88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Dec 2018 00:39:21 +0100 Subject: [PATCH 6/8] Update doc --- ChangeLog | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad6a71f4531..ef4ee57b6f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,10 +36,8 @@ NEW: Add option PDF_DISABLE_MYCOMPANY_LOGO to disable logo on PDF NEW: add option PROPOSAL_AUTO_ADD_AUTHOR_AS_CONTACT NEW: Add option to display thirdparty adress in combolist NEW: Add option to swap sender/recipient address on PDF -NEW: Add option to display thirdparty adress in combolist NEW: Add project on payment of salaries NEW: Add SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME and -NEW: Add somes hooks in bank planned entries NEW: Add supplier ref in item reception page NEW: Advanced permission to ignore price min NEW: Allow to enter a timespent with a numeric value @@ -85,6 +83,7 @@ NEW: Withdraw request massaction can include already partially paid invoices For developers: NEW: Add lib for multiselect with checkboxes NEW: Add function isValidMXRecord +NEW: Add somes hooks in bank planned entries NEW: Add hook changeRoundingMode in update_price NEW: Add hook formconfirm to contractcard NEW: Add hook for virtual stock From ac48996bd37ce35ade4d48e3308b1e5df96f7f8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Dec 2018 23:41:36 +0100 Subject: [PATCH 7/8] FIX Look and feel v8 --- htdocs/adherents/list.php | 47 +- htdocs/adherents/subscription/list.php | 616 +++++++++++++++++-------- 2 files changed, 458 insertions(+), 205 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 39d0069ac7c..8eb7109d9ed 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -79,8 +79,9 @@ $pagenext = $page + 1; if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Adherent($db); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('memberlist')); $extrafields = new ExtraFields($db); @@ -348,8 +349,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( -// 'presend'=>$langs->trans("SendByMail"), -// 'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); @@ -603,6 +604,7 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="c print "\n"; $i = 0; +$totalarray=array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -631,6 +633,7 @@ while ($i < min($num, $limit)) if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''.$obj->rowid.''; + if (! $i) $totalarray['nbfield']++; } // Ref @@ -639,6 +642,7 @@ while ($i < min($num, $limit)) print ""; print $memberstatic->getNomUrl(-1, 0, 'card', 'ref'); print "\n"; + if (! $i) $totalarray['nbfield']++; } // Civility if (! empty($arrayfields['d.civility']['checked'])) @@ -646,6 +650,7 @@ while ($i < min($num, $limit)) print ""; print $obj->civility; print "\n"; + if (! $i) $totalarray['nbfield']++; } // Firstname if (! empty($arrayfields['d.firstname']['checked'])) @@ -653,6 +658,7 @@ while ($i < min($num, $limit)) print ""; print $obj->firstname; print "\n"; + if (! $i) $totalarray['nbfield']++; } // Lastname if (! empty($arrayfields['d.lastname']['checked'])) @@ -660,6 +666,7 @@ while ($i < min($num, $limit)) print ""; print $obj->lastname; print "\n"; + if (! $i) $totalarray['nbfield']++; } // Company if (! empty($arrayfields['d.company']['checked'])) @@ -672,11 +679,13 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['d.login']['checked'])) { print "".$obj->login."\n"; + if (! $i) $totalarray['nbfield']++; } // Moral/Physique if (! empty($arrayfields['d.morphy']['checked'])) { print "".$memberstatic->getmorphylib($obj->morphy)."\n"; + if (! $i) $totalarray['nbfield']++; } // Type label if (! empty($arrayfields['t.libelle']['checked'])) @@ -686,6 +695,7 @@ while ($i < min($num, $limit)) print ''; print $membertypestatic->getNomUrl(1,32); print ''; + if (! $i) $totalarray['nbfield']++; } // Address if (! empty($arrayfields['d.address']['checked'])) @@ -693,6 +703,7 @@ while ($i < min($num, $limit)) print ''; print $obj->address; print ''; + if (! $i) $totalarray['nbfield']++; } // Zip if (! empty($arrayfields['d.zip']['checked'])) @@ -828,6 +839,36 @@ while ($i < min($num, $limit)) $i++; } +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + } + else print ''; + } + } + print ''; +} + +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; +} + $db->free($resql); $parameters=array('sql' => $sql); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 4ef43e8f316..9eed2238f80 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -28,12 +28,18 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -$langs->load("members"); +$langs->load(array("members","companies")); -$filter=$_GET["filter"]; -$statut=isset($_GET["statut"])?$_GET["statut"]:1; +$action=GETPOST('action','aZ09'); +$massaction=GETPOST('massaction','alpha'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); + +$filter=GETPOST("filter","alpha"); +$statut=(GETPOSTISSET("statut")?GETPOST("statut","alpha"):1); $search_ref=GETPOST('search_ref','alpha'); $search_lastname=GETPOST('search_lastname','alpha'); +$search_firstname=GETPOST('search_firstname','alpha'); $search_login=GETPOST('search_login','alpha'); $search_note=GETPOST('search_note','alpha'); $search_account=GETPOST('search_account','int'); @@ -67,6 +73,20 @@ $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, $fieldstosearchall = array( ); $arrayfields=array( + 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), + 'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), + 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), + 't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1), + 'd.bank'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1, 'enabled'=>(! empty($conf->banque->enabled))), + /*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0), + 'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/ + 'd.datedebut'=>array('label'=>$langs->trans("DateSubscription"), 'checked'=>1, 'position'=>100), + 'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>101), + 'd.amount'=>array('label'=>$langs->trans("Amount"), 'checked'=>1, 'position'=>102), + 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), +// 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) ); // Security check @@ -74,7 +94,7 @@ $result=restrictedArea($user,'adherent','','','cotisation'); /* - * Actions + * Actions */ if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } @@ -111,15 +131,16 @@ if (empty($reshook)) */ $form=new Form($db); +$subscription=new Subscription($db); +$adherent=new Adherent($db); +$accountstatic=new Account($db); -llxHeader('',$langs->trans("ListOfSubscriptions"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); - +$now=dol_now(); // List of subscriptions $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo,"; $sql.= " c.rowid as crowid, c.subscription,"; -$sql.= " c.dateadh,"; -$sql.= " c.datef,"; +$sql.= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,"; $sql.= " c.fk_bank as bank, c.note,"; $sql.= " b.fk_account"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; @@ -136,253 +157,444 @@ if ($search_ref) if (is_numeric($search_ref)) $sql.= " AND (c.rowid = ".$db->escape($search_ref).")"; else $sql.=" AND 1 = 2"; // Always wrong } -if ($search_lastname) $sql.= natural_search(array('d.firstname','d.lastname','d.societe'), $search_lastname); +if ($search_lastname) $sql.= natural_search(array('d.lastname','d.societe'), $search_lastname); +if ($search_firstname) $sql.= natural_search(array('d.firstname'), $search_firstname); if ($search_login) $sql.= natural_search('c.subscription', $search_login); if ($search_note) $sql.= natural_search('c.note', $search_note); -if ($search_account > 0) $sql.= " AND b.fk_account = ".$search_account; +if ($search_account > 0) $sql.= " AND b.fk_account = ".urldecode($search_account); if ($search_amount) $sql.= natural_search('c.subscription', $search_amount, 1); + +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + $sql.= $db->order($sortfield,$sortorder); +// Count total nb of records with no order and no limits $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + if ($resql) $nbtotalofrecords = $db->num_rows($resql); + else dol_print_error($db); if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 { $page = 0; $offset = 0; } } - +// Add limit $sql.= $db->plimit($limit+1, $offset); $result = $db->query($sql); -if ($result) +if (! $result) { - $num = $db->num_rows($result); + dol_print_error($db); + exit; +} - $arrayofselected=is_array($toselect)?$toselect:array(); +$num = $db->num_rows($result); - $i = 0; +$arrayofselected=is_array($toselect)?$toselect:array(); - $title=$langs->trans("ListOfSubscriptions"); - if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')'; +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/adherents/subscription/card.php?id='.$id); + exit; +} - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($statut != '') $param.="&statut=".$statut; - if ($date_select) $param.="&date_select=".$date_select; - if ($search_lastname) $param.="&search_lastname=".$search_lastname; - if ($search_login) $param.="&search_login=".$search_login; - if ($search_acount) $param.="&search_account=".$search_account; - if ($search_amount) $param.="&search_amount=".$search_amount; - if ($optioncss != '') $param.='&optioncss='.$optioncss; +llxHeader('',$langs->trans("ListOfSubscriptions"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); - // List of mass actions available - $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), - ); - if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); +$i = 0; - $newcardbutton=''; - if ($user->rights->adherent->cotisation->creer) - { - $newcardbutton=''.$langs->trans('NewSubscription').''; - $newcardbutton.= ''; - $newcardbutton.= ''; - } +$title=$langs->trans("ListOfSubscriptions"); +if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')'; - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($statut != '') $param.="&statut=".urlencode($statut); +if ($date_select) $param.="&date_select=".urlencode($date_select); +if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); +if ($search_login) $param.="&search_login=".urlencode($search_login); +if ($search_acount) $param.="&search_account=".urlencode($search_account); +if ($search_amount) $param.="&search_amount=".urlencode($search_amount); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit); +// List of mass actions available +$arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), +); +if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); - $topicmail="Information"; - $modelmail="subscription"; - $objecttmp=new Subscription($db); - $trackid='sub'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; +$newcardbutton=''; +if ($user->rights->adherent->cotisation->creer) +{ + $newcardbutton=''.$langs->trans('NewSubscription').''; + $newcardbutton.= ''; + $newcardbutton.= ''; +} - if ($sall) - { - print $langs->trans("Filter")." (".$langs->trans("Ref").", ".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; - } +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; - $moreforfilter = ''; +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit); - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$topicmail="Information"; +$modelmail="subscription"; +$objecttmp=new Subscription($db); +$trackid='sub'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - print '
'; - print ''."\n"; +if ($sall) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; +} - // Line for filters fields - print ''; +$moreforfilter = ''; +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + +print '
'; +print '
'."\n"; + + +// Line for filters fields +print ''; + +// Line numbering +if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) +{ + print ''; +} + +// Ref +if (! empty($arrayfields['d.ref']['checked'])) +{ print ''; +} +if (! empty($arrayfields['d.lastname']['checked'])) +{ print ''; + print ''; +} +if (! empty($arrayfields['d.firstname']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.login']['checked'])) +{ print ''; +} - print ''; +if (! empty($arrayfields['t.libelle']['checked'])) +{ + print ''; +} - if (! empty($conf->banque->enabled)) - { - print ''; - } +if (! empty($arrayfields['d.bank']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['d.date_debut']['checked'])) +{ print ''; +} +if (! empty($arrayfields['d.date_fin']['checked'])) +{ print ''; +} +if (! empty($arrayfields['d.amount']['checked'])) +{ print ''; - - // Action column - print ''; - - print "\n"; - - - print ''; - print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"c.rowid",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Name",$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"c.note",$param,"",'align="left"',$sortfield,$sortorder); - if (! empty($conf->banque->enabled)) - { - print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"b.fk_account",$pram,"","",$sortfield,$sortorder); - } - print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"c.dateadh",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre("DateEnd",$_SERVER["PHP_SELF"],"c.datef",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"c.subscription",$param,"",'align="right"',$sortfield,$sortorder); - //print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print_liste_field_titre('', $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - - - // Static objects - $subscription=new Subscription($db); - $adherent=new Adherent($db); - $accountstatic=new Account($db); - - $total=0; - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($result); - $total+=$obj->subscription; - - $subscription->ref=$obj->crowid; - $subscription->id=$obj->crowid; - - $adherent->lastname=$obj->lastname; - $adherent->firstname=$obj->firstname; - $adherent->ref=$obj->rowid; - $adherent->id=$obj->rowid; - $adherent->statut=$obj->statut; - $adherent->login=$obj->login; - $adherent->photo=$obj->photo; - - - - print ''; - - // Ref - print ''; - - // Lastname - print ''; - - // Login - print ''; - - // Libelle - print ''; - - // Banque - if (! empty($conf->banque->enabled)) - { - if ($obj->fk_account > 0) - { - $accountstatic->id=$obj->fk_account; - $accountstatic->fetch($obj->fk_account); - //$accountstatic->label=$obj->label; - print ''; - } - else - { - print "\n"; - } - } - - // Date start - print '\n"; - - // Date end - print '\n"; - - // Price - print ''; - - print ''; - - print ""; - - $i++; - } - - // Total - - print ''; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - if (! empty($conf->banque->enabled)) - { - print ''; - } - print ''; - print ''; - print '\n"; - print ''; - print "\n"; - - print "
 '; print ''; - print ''; + print ''; print ''; - print ''; + print ''; + print ''; - print $form->select_comptes($search_account, 'search_account', 0, '', 1); - print ''; + print $form->select_comptes($search_account, 'search_account', 0, '', 1); + print '  '; print ''; print ''; - $searchpicto=$form->showFilterButtons(); - print $searchpicto; - print '
'.$subscription->getNomUrl(1).''.$adherent->getNomUrl(-1).''.$adherent->login.''; - print dol_trunc($obj->note,32); - print ''.$accountstatic->getNomUrl(1).'"; - print "'.dol_print_date($db->jdate($obj->dateadh),'day')."'.dol_print_date($db->jdate($obj->datef),'day')."'.price($obj->subscription).'
".$langs->trans("Total")."      '.price($total)."
"; - print '
'; - print '
'; } -else +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (! empty($arrayfields['d.datec']['checked'])) { - dol_print_error($db); + print ''; + print ''; } +// Date modification +if (! empty($arrayfields['d.tms']['checked'])) +{ + print ''; + print ''; +} + +// Action column +print ''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print ''; + +print "\n"; + + +print ''; +if (! empty($arrayfields['d.ref']['checked'])) +{ + print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"c.rowid",$param,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['d.lastname']['checked'])) +{ + print_liste_field_titre("LastName",$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['d.firstname']['checked'])) +{ + print_liste_field_titre("FirstName",$_SERVER["PHP_SELF"],"d.firstname",$param,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['d.login']['checked'])) +{ + print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['t.libelle']['checked'])) +{ + print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"c.note",$param,"",'align="left"',$sortfield,$sortorder); +} +if (! empty($arrayfields['d.bank']['checked'])) +{ + print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"b.fk_account",$pram,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['d.date_debut']['checked'])) +{ + print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"c.dateadh",$param,"",'align="center"',$sortfield,$sortorder); +} +if (! empty($arrayfields['d.date_fin']['checked'])) +{ + print_liste_field_titre("DateEnd",$_SERVER["PHP_SELF"],"c.datef",$param,"",'align="center"',$sortfield,$sortorder); +} +if (! empty($arrayfields['d.amount']['checked'])) +{ + print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"c.subscription",$param,"",'align="right"',$sortfield,$sortorder); +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + +// Hook fields +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'],$_SERVER["PHP_SELF"],"d.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); +print "\n"; + + +$total=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($result); + $total+=$obj->subscription; + + $subscription->ref=$obj->crowid; + $subscription->id=$obj->crowid; + + $adherent->lastname=$obj->lastname; + $adherent->firstname=$obj->firstname; + $adherent->ref=$obj->rowid; + $adherent->id=$obj->rowid; + $adherent->statut=$obj->statut; + $adherent->login=$obj->login; + $adherent->photo=$obj->photo; + + + print ''; + + // Ref + if (! empty($arrayfields['d.ref']['checked'])) + { + print ''.$subscription->getNomUrl(1).''; + if (! $i) $totalarray['nbfield']++; + } + + // Lastname + if (! empty($arrayfields['d.lastname']['checked'])) + { + $adherent->firstname = ''; + print ''.$adherent->getNomUrl(-1).''; + $adherent->firstname = $obj->firstname; + if (! $i) $totalarray['nbfield']++; + } + // Firstname + if (! empty($arrayfields['d.firstname']['checked'])) + { + print ''.$adherent->firstname.''; + if (! $i) $totalarray['nbfield']++; + } + + // Login + if (! empty($arrayfields['d.login']['checked'])) + { + print ''.$adherent->login.''; + if (! $i) $totalarray['nbfield']++; + } + + // Label + if (! empty($arrayfields['t.libelle']['checked'])) + { + print ''; + print dol_trunc($obj->note,128); + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Banque + if (! empty($arrayfields['d.bank']['checked'])) + { + print ""; + if ($obj->fk_account > 0) + { + $accountstatic->id=$obj->fk_account; + $accountstatic->fetch($obj->fk_account); + //$accountstatic->label=$obj->label; + print $accountstatic->getNomUrl(1); + } + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + + // Date start + if (! empty($arrayfields['d.date_start']['checked'])) + { + print ''.dol_print_date($db->jdate($obj->dateadh),'day')."\n"; + if (! $i) $totalarray['nbfield']++; + } + // Date end + if (! empty($arrayfields['d.date_end']['checked'])) + { + print ''.dol_print_date($db->jdate($obj->datef),'day')."\n"; + if (! $i) $totalarray['nbfield']++; + } + // Price + if (! empty($arrayfields['d.amount']['checked'])) + { + print ''.price($obj->subscription).''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='d.amount'; + $totalarray['val']['d.amount'] += $obj->subscription; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['d.datec']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['d.tms']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print ''; + if (! $i) $totalarray['nbfield']++; + + print "\n"; + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + } + else print ''; + } + } + print ''; +} + +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; +} + +$db->free($resql); + +$parameters=array('sql' => $sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ""; +print ''; +print ''; + // End of page llxFooter(); From ff8f235b7ef97d3e96299eefce5a29b53a860182 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Dec 2018 00:15:22 +0100 Subject: [PATCH 8/8] Fix regression when disabling table --- htdocs/ticket/class/ticket.class.php | 65 +++++++++++----------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 76c9eb8856e..e904adfdb81 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -898,11 +898,6 @@ class Ticket extends CommonObject if ($res < 0) $error++; } - if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_logs"; - $sql .= " WHERE fk_track_id = '" . $this->db->escape($this->track_id) . "'"; - $resql = $this->db->query($sql); - } if (!$error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_msg"; $sql .= " WHERE fk_track_id = '" . $this->db->escape($this->track_id) . "'"; @@ -1487,15 +1482,17 @@ class Ticket extends CommonObject * 1- create entry into database for message storage * 2- if trigger, send an email to ticket contacts * - * @param User $user User that create - * @param string $message Log message - * @param int $noemail 0=send email after, 1=disable emails - * @return int <0 if KO, >0 if OK + * @param User $user User that create + * @param string $message Log message + * @param int $noemail 0=send email after, 1=disable emails + * @return int <0 if KO, >0 if OK */ public function createTicketLog(User $user, $message, $noemail = 0) { global $conf, $langs; + $error = 0; + $this->db->begin(); // Clean parameters @@ -1507,37 +1504,23 @@ class Ticket extends CommonObject return -1; } - // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "ticket_logs("; - $sql .= "entity,"; - $sql .= "datec,"; - $sql .= "fk_track_id,"; - $sql .= "fk_user_create,"; - $sql .= "message"; - $sql .= ") VALUES ("; - $sql .= " " . $conf->entity . ","; - $sql .= " '" . $this->db->idate(dol_now()) . "',"; - $sql .= " '" . $this->db->escape($this->track_id) . "',"; - $sql .= " " . ($user->id > 0 ? $user->id : 'NULL') . ","; - $sql .= " '" . $this->db->escape($message) . "'"; - $sql .= ")"; + // TODO Should call the trigger TICKET_MODIFY with $this->context with all data to record event + // so the event is stored by the agenda/event trigger - dol_syslog(get_class($this) . "::create_ticket_log sql=" . $sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - if ($conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL && !$noemail) { - $this->sendLogByEmail($user, $message); - } + if (!$error) { + $this->db->commit(); - if (!$error) { - $this->db->commit(); - return 1; - } - } else { - $this->db->rollback(); - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::create_ticket_log " . $this->error, LOG_ERR); - return -1; + if ($conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL && !$noemail) { + $this->sendLogByEmail($user, $message); + } + + return 1; + } + else + { + $this->db->rollback(); + + return -1; } } @@ -1647,6 +1630,8 @@ class Ticket extends CommonObject } // Cache deja charge + // TODO Read the table llx_actioncomm + /* $sql = "SELECT rowid, fk_user_create, datec, message"; $sql .= " FROM " . MAIN_DB_PREFIX . "ticket_logs"; $sql .= " WHERE fk_track_id ='" . $this->db->escape($this->track_id) . "'"; @@ -1669,7 +1654,9 @@ class Ticket extends CommonObject $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::loadCacheLogsTicket " . $this->error, LOG_ERR); return -1; - } + }*/ + + return 0; } /**