From 7b661685cc20134011f21beab4cf16cb57fd103f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 15:22:46 +0200 Subject: [PATCH 1/9] Debug modBlockedLog module --- htdocs/blockedlog/class/blockedlog.class.php | 25 +++++++++++++------ htdocs/compta/bank/class/account.class.php | 2 +- htdocs/compta/salaries/card.php | 8 +++--- .../salaries/class/paymentsalary.class.php | 2 +- htdocs/compta/salaries/index.php | 2 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 4 ++- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 4bce16fb796..0fefb5baf00 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -155,10 +155,16 @@ class BlockedLog */ public function setObjectData(&$object) { - if($object->element=='payment') { + // Set date + if ($object->element=='payment') + { $this->date_object = $object->datepaye; } - else{ + if ($object->element=='payment_salary') + { + $this->date_object = $object->datev; + } + else { $this->date_object = $object->date; } @@ -168,7 +174,8 @@ class BlockedLog $this->object_data=new stdClass(); - if($this->element === 'facture') { + if ($this->element === 'facture') + { if(empty($object->thirdparty))$object->fetch_thirdparty(); $this->object_data->thirdparty = new stdClass(); @@ -182,14 +189,16 @@ class BlockedLog $this->object_data->total_localtax1= (double) $object->total_localtax1; $this->object_data->total_localtax2= (double) $object->total_localtax2; $this->object_data->note_public = (double) $object->note_public; - $this->object_data->note_private= (double) $object->note_private; - } - elseif($this->element==='payment'){ - + elseif($this->element === 'payment') + { $this->object_data->amounts = $object->amounts; - } + elseif($this->element === 'payment_salary') + { + $this->object_data->amounts = array($object->amount); + } + } /** diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 8ad1ccd2ecf..824b3f50f26 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -386,7 +386,7 @@ class Account extends CommonObject * Add an entry into table ".MAIN_DB_PREFIX."bank * * @param int $date Date operation - * @param string $oper 1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ... + * @param string $oper 1,2,3,4... (deprecated) or 'TYP','VIR','PRE','LIQ','VAD','CB','CHQ'... * @param string $label Descripton * @param float $amount Amount * @param string $num_chq Numero cheque ou virement diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 47d4c027185..a456777f631 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -73,6 +73,8 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); if (empty($datev)) $datev=$datep; + $type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement'); + $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user","int") : 0; $object->datev=$datev; @@ -82,7 +84,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $object->datesp=$datesp; $object->dateep=$dateep; $object->note=GETPOST("note"); - $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; + $object->type_payment=($type_payment > 0 ? $type_payment : 0); $object->num_payment=GETPOST("num_payment"); $object->fk_user_author=$user->id; @@ -101,7 +103,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors'); $error++; } - if (empty($object->type_payment) || $object->type_payment < 0) + if (empty($type_payment) || $type_payment < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); $error++; @@ -292,7 +294,7 @@ if ($action == 'create') // Type payment print ''; print fieldLabel('PaymentMode','selectpaymenttype',1).''; - $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype"); + $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype", '', 2); print ''; // Number diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 7fbbaf43d48..57d2d94f1a3 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -349,7 +349,7 @@ class PaymentSalary extends CommonObject $sql.= ", '".$this->db->idate($this->datev)."'"; $sql.= ", ".$this->amount; $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); - $sql.= ", '".$this->db->escape($this->type_payment)."'"; + $sql.= ", ".$this->db->escape($this->type_payment); $sql.= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", '".$this->db->escape($this->label)."'"; diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 6928d3e38f6..2da142aff15 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -114,7 +114,7 @@ $sql.= " AND s.entity = ".$conf->entity; // Search criteria if ($search_ref) $sql.=" AND s.rowid=".$search_ref; -if ($search_user) $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email', 'u.note'), $search_user); +if ($search_user) $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); if ($search_label) $sql.=natural_search(array('s.label'), $search_label); if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1); if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 39dae7c209e..635a4649902 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -48,6 +48,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers { if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') { $amounts= (double) $object->total_ttc; @@ -72,7 +74,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $b=new BlockedLog($this->db); $b->action = $action; $b->amounts= $amounts; - $b->setObjectData($object); + $b->setObjectData($object); // Set field ref_object, fk_object, element, object_data $res = $b->create($user); From 9dc4933ba006078137072d1e35337c204ddc1d30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 15:32:01 +0200 Subject: [PATCH 2/9] Debug --- htdocs/core/menus/init_menu_auguria.sql | 6 +++--- htdocs/loan/class/loan.class.php | 2 +- htdocs/loan/index.php | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 33039b390fd..4d4801c35fe 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -209,9 +209,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2302__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/reglement.php?leftmenu=tax_vat', 'List', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2303__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?leftmenu=tax_vat', 'ReportByCustomers', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/quadri_detail.php?leftmenu=tax_vat', 'ReportByQuarter', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled', __HANDLER__, 'left', 2350__+MAX_llx_menu__, 'billing', 'tax_various', 2200__+MAX_llx_menu__, '/bank/various_payment/index.php?leftmenu=tax_various&mainmenu=billing', 'MenuVariousPayment', 1, 'banks', '$user->rights->banque->lire', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2351__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/bank/various_payment/card.php?leftmenu=tax_various&action=create', 'MenuNewVariousPayment', 2, 'various_payment', '$user->rights->banque->modifier', '', 0, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2352__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/bank/various_payment/index.php?leftmenu=tax_various', 'List', 2, 'various_payment', '$user->rights->banque->lire', '', 0, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled', __HANDLER__, 'left', 2350__+MAX_llx_menu__, 'billing', 'tax_various', 2200__+MAX_llx_menu__, '/compta/bank/various_payment/index.php?leftmenu=tax_various&mainmenu=billing', 'MenuVariousPayment', 1, 'banks', '$user->rights->banque->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2351__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/compta/bank/various_payment/card.php?leftmenu=tax_various&action=create', 'MenuNewVariousPayment', 2, 'various_payment', '$user->rights->banque->modifier', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2352__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/compta/bank/various_payment/index.php?leftmenu=tax_various', 'List', 2, 'various_payment', '$user->rights->banque->lire', '', 0, 3, __ENTITY__); -- Accounting Expert insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accountancy', 9__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); -- Setup diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 734c2356b3a..d598a6ece97 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -421,7 +421,7 @@ class Loan extends CommonObject if ($withpicto) $result.=($link.$linkclose.img_object($langs->trans("ShowLoan").': '.$this->label,'bill', 'class="classfortooltip"').$linkend.' '); if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.$linkclose.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend; + if ($withpicto != 2) $result.=$link.$linkclose.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend; return $result; } diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index 7b96c13358f..d1436287db3 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -76,9 +76,9 @@ $sql.= " SUM(pl.amount_capital) as alreadypayed"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl"; $sql.= " ON l.rowid = pl.fk_loan"; $sql.= " WHERE l.entity = ".$conf->entity; -if ($search_amount) $sql.=" AND l.capital='".$db->escape(price2num(trim($search_amount)))."'"; -if ($search_ref) $sql.=" AND l.rowid = ".$db->escape($search_ref); -if ($search_label) $sql.=" AND l.label LIKE '%".$db->escape($search_label)."%'"; +if ($search_amount) $sql.= natural_search("l.capital", $search_amount, 1); +if ($search_ref) $sql.= " AND l.rowid = ".$db->escape($search_ref); +if ($search_label) $sql.= natural_search("l.label", $search_label); if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; @@ -104,12 +104,12 @@ if ($resql) $var=true; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_ref) $param.="&search_ref=".$search_ref; - if ($search_label) $param.="&search_label=".$search_user; - if ($search_amount) $param.="&search_amount=".$search_amount_ht; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_ref) $param.="&search_ref=".urlencode($search_ref); + if ($search_label) $param.="&search_label=".urlencode($search_user); + if ($search_amount) $param.="&search_amount=".urlencode($search_amount_ht); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); print '
'."\n"; if ($optioncss != '') print ''; From d2f723045caa79d566194fd6a779804edef06601 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 17:30:05 +0200 Subject: [PATCH 3/9] Work on website and modulebuilder --- htdocs/core/actions_addupdatedelete.inc.php | 133 +++++ .../install/mysql/migration/6.0.0-7.0.0.sql | 10 +- .../mysql/tables/llx_websiteaccount.sql | 9 +- htdocs/langs/en_US/modulebuilder.lang | 2 +- .../template/class/myobject.class.php | 18 +- .../modulebuilder/template/myobject_card.php | 116 +--- htdocs/product/inventory/card.php | 107 +--- htdocs/societe/website.php | 13 +- htdocs/website/class/websiteaccount.class.php | 35 +- htdocs/website/websiteaccount_card.php | 529 ++++++++++++++++++ 10 files changed, 720 insertions(+), 252 deletions(-) create mode 100644 htdocs/core/actions_addupdatedelete.inc.php create mode 100644 htdocs/website/websiteaccount_card.php diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php new file mode 100644 index 00000000000..91d5b29dce6 --- /dev/null +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -0,0 +1,133 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/actions_addupdatedelete.inc.php + * \brief Code for common actions cancel / add / update / delete + */ + + +// $action or $cancel must be defined +// $object must be defined +// $permissiontoadd must be defined +// $permissiontodelete must be defined +// $backurlforlist must be defined +// $backtopage may be defined + +if ($cancel) +{ + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action=''; +} + +// Action to add record +if ($action == 'add' && ! empty($permissiontoadd)) +{ + foreach ($object->fields as $key => $val) + { + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields + + $object->$key=GETPOST($key,'alpha'); + if ($val['notnull'] > 0 && $object->$key == '') + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); + } + } + + if (! $error) + { + $result=$object->createCommon($user); + if ($result > 0) + { + // Creation OK + $urltogo=$backtopage?$backtopage:$backurlforlist; + header("Location: ".$urltogo); + exit; + } + else + { + // Creation KO + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + $action='create'; + } + } + else + { + $action='create'; + } +} + +// Action to update record +if ($action == 'update' && ! empty($permissiontoadd)) +{ + foreach ($object->fields as $key => $val) + { + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields + + $object->$key=GETPOST($key,'alpha'); + if ($val['notnull'] > 0 && $object->$key == '') + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); + } + } + + if (! $error) + { + $result=$object->updateCommon($user); + if ($result > 0) + { + $action='view'; + } + else + { + // Creation KO + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + $action='edit'; + } + } + else + { + $action='edit'; + } +} + +// Action to delete +if ($action == 'confirm_delete' && ! empty($permissiontodelete)) +{ + $result=$object->deleteCommon($user); + if ($result > 0) + { + // Delete OK + setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".$backurlforlist); + exit; + } + else + { + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + } +} diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 792b745f649..cd94b97fa43 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -171,10 +171,11 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN fk_user integer NULL; CREATE TABLE llx_websiteaccount( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - login varchar(64) NOT NULL, - label varchar(255), - note_public text, - note_private text, + login varchar(64) NOT NULL, + pass_crypted varchar(128), + pass_temp varchar(128), -- temporary password when asked for forget password + date_last_login datetime, + date_previous_login datetime, date_creation datetime NOT NULL, tms timestamp NOT NULL, fk_user_creat integer NOT NULL, @@ -184,6 +185,7 @@ CREATE TABLE llx_websiteaccount( fk_soc integer ) ENGINE=innodb; + ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_rowid (rowid); ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_login (login); ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_import_key (import_key); diff --git a/htdocs/install/mysql/tables/llx_websiteaccount.sql b/htdocs/install/mysql/tables/llx_websiteaccount.sql index 7fb846cd2f3..cc88c2ece3a 100644 --- a/htdocs/install/mysql/tables/llx_websiteaccount.sql +++ b/htdocs/install/mysql/tables/llx_websiteaccount.sql @@ -17,10 +17,11 @@ CREATE TABLE llx_websiteaccount( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - login varchar(64) NOT NULL, - label varchar(255), - note_public text, - note_private text, + login varchar(64) NOT NULL, + pass_crypted varchar(128), + pass_temp varchar(128), -- temporary password when asked for forget password + date_last_login datetime, + date_previous_login datetime, date_creation datetime NOT NULL, tms timestamp NOT NULL, fk_user_creat integer NOT NULL, diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 75a0e16c0ba..6dece001bc0 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -71,7 +71,7 @@ NoWidget=No widget GoToApiExplorer=Go to API explorer ListOfPermissionsDefined=List of defined permissions EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) -VisibleDesc=Is the field visible into list ? (Examples: 0=not visible, 1=visible by default on list, -1=not shown by default on list but can be added into list to be viewed) +VisibleDesc=Is the field visible into list ? (Examples: 0=Not visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) IsAMeasureDesc=Can the value of field be cumulated to get a total into list ? (Examples: 1 or 0) SearchAllDesc=Is the field used to make a search from the quick search tool ? (Examples: 1 or 0) SpecDefDesc=Enter here all documentation you want to provide with your module that is not already defined by other tabs. You can use .md or better, the rich .asciidoc syntax. diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 030ecd0b1c2..6c14cd6dc77 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -57,8 +57,8 @@ class MyObject extends CommonObject /** * 'type' if the field format. * 'label' the translation key. - * 'enabled' is a condition when the filed must be managed. - * 'visible' says if field is visible in list (-1 means not shown by default but can be added into list to be viewed). + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'index' if we want an index in database. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). @@ -74,20 +74,20 @@ class MyObject extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200'), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Amount'), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>45), 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>46), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501), - //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>502), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>510), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'position'=>511), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>1, 'position'=>1000), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), ); diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index cc4e3a605cd..283a7082435 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -112,108 +112,12 @@ if (empty($reshook)) { $error=0; - if ($cancel) - { - if (! empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } - $action=''; - } + $permissiontoadd = $user->rights->mymodule->create; + $permissiontodelete = $user->rights->mymodule->delete; + $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1); - // Action to add record - if ($action == 'add' && ! empty($user->rights->mymodule->create)) - { - foreach ($object->fields as $key => $val) - { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields - - $object->$key=GETPOST($key,'alpha'); - if ($val['notnull'] > 0 && $object->$key == '') - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); - } - } - - if (! $error) - { - $result=$object->createCommon($user); - if ($result > 0) - { - // Creation OK - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); - header("Location: ".$urltogo); - exit; - } - else - { - // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - $action='create'; - } - } - else - { - $action='create'; - } - } - - // Action to update record - if ($action == 'update' && ! empty($user->rights->mymodule->create)) - { - foreach ($object->fields as $key => $val) - { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields - - $object->$key=GETPOST($key,'alpha'); - if ($val['notnull'] > 0 && $object->$key == '') - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); - } - } - - if (! $error) - { - $result=$object->updateCommon($user); - if ($result > 0) - { - $action='view'; - } - else - { - // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - $action='edit'; - } - } - else - { - $action='edit'; - } - } - - // Action to delete - if ($action == 'confirm_delete' && ! empty($user->rights->mymodule->delete)) - { - $result=$object->deleteCommon($user); - if ($result > 0) - { - // Delete OK - setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".dol_buildpath('/mymodule/myobject_list.php',1)); - exit; - } - else - { - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } + // Actions cancel, add, update or delete + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -270,7 +174,9 @@ if ($action == 'create') print ''."\n"; foreach($object->fields as $key => $val) { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'date_validation', 'tms', 'fk_user_creat', 'fk_user_modif', 'fk_user_valid', 'import_key'))) continue; + if (abs($val['visible']) != 1) continue; // Discard such field from form + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field + print ''; print ''."\n"; foreach($object->fields as $key => $val) { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; + if (abs($val['visible']) != 1) continue; // Discard such field from form + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field print ' 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); - $action=''; - } + $permissiontoadd = $user->rights->inventory->create; + $permissiontodelete = $user->rights->inventory->delete; + $backurlforlist = dol_buildpath('/inventory/inventory_list.php',1); - // Action to add record - if ($action == 'add' && ! empty($user->rights->inventory->create)) - { - foreach ($object->fields as $key => $val) - { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'date_validation', 'tms', 'fk_user_creat', 'fk_user_modif', 'fk_user_validation', 'import_key'))) continue; // Ignore special fields - - $object->$key=GETPOST($key,'alpha'); - if ($val['notnull'] && $object->$key == '') - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); - } - } - - if (! $error) - { - $result=$object->createCommon($user); - if ($result > 0) - { - // Creation OK - $urltogo=$backtopage?$backtopage:dol_buildpath('/inventory/inventory_list.php',1); - header("Location: ".$urltogo); - exit; - } - else - { - // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - $action='create'; - } - } - else - { - $action='create'; - } - } - - // Action to update record - if ($action == 'update' && ! empty($user->rights->inventory->create)) - { - foreach ($object->fields as $key => $val) - { - $object->$key=GETPOST($key,'alpha'); - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; - if ($val['notnull'] && $object->$key == '') - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); - } - } - - if (! $error) - { - $result=$object->updateCommon($user); - if ($result > 0) - { - $action='view'; - } - else - { - // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - $action='edit'; - } - } - else - { - $action='edit'; - } - } - - // Action to delete - if ($action == 'confirm_delete' && ! empty($user->rights->inventory->delete)) - { - $result=$object->deleteCommon($user); - if ($result > 0) - { - // Delete OK - setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".dol_buildpath('/inventory/inventory_list.php',1)); - exit; - } - else - { - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } + // Actions cancel, add, update or delete + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; } diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index ef8659016b1..c5b7b4b5cb8 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -230,7 +230,7 @@ dol_fiche_end(); $morehtmlcenter = ''; if (! empty($conf->website->enabled)) { if (! empty($user->rights->societe->lire)) { - $morehtmlcenter .= '' . $langs->trans("AddWebsiteAccount") . ''; + $morehtmlcenter .= '' . $langs->trans("AddWebsiteAccount") . ''; } else { $morehtmlcenter .= '' . $langs->trans("AddAction") . ''; } @@ -378,7 +378,6 @@ print '
'; foreach($objectwebsiteaccount->fields as $key => $val) { - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; $align=''; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; @@ -412,16 +411,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -// Rest of fields search -foreach($objectwebsiteaccount->fields as $key => $val) -{ - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; -} // Action column print ''."\n"; print ''; foreach($objectwebsiteaccount->fields as $key => $val) { - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; $align=''; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; @@ -449,16 +448,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -// Rest of fields title -foreach($objectwebsiteaccount->fields as $key => $val) -{ - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; -} print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print ''."\n"; @@ -491,7 +480,6 @@ while ($i < min($num, $limit)) print ''; foreach($objectwebsiteaccount->fields as $key => $val) { - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Discard some field output at end $align=''; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; @@ -540,30 +528,6 @@ while ($i < min($num, $limit)) $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - // Rest of fields - foreach($objectwebsiteaccount->fields as $key => $val) - { - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Keep only field not yet already output - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { - print ''; - if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); - elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); - elseif ($key == 'status') print $objectwebsiteaccount->getLibStatut(3); - else print $obj->$key; - print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) - { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; - $totalarray['val']['t.'.$key] += $obj->$key; - } - } - } // Action column print '\n"; $var=True; foreach($extrafields->attribute_type as $key => $value) { - + print ''; print "\n"; print "\n"; diff --git a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php index 2b0a22c51fa..c8d6cf4cae1 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php @@ -39,7 +39,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); @@ -94,7 +94,7 @@ print "\n"; $var=True; foreach($extrafields->attribute_type as $key => $value) { - + print ''; print "\n"; print "\n"; diff --git a/htdocs/user/admin/group_extrafields.php b/htdocs/user/admin/group_extrafields.php index 8dad702935f..0f11c3cd141 100644 --- a/htdocs/user/admin/group_extrafields.php +++ b/htdocs/user/admin/group_extrafields.php @@ -38,7 +38,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/user/admin/user_extrafields.php b/htdocs/user/admin/user_extrafields.php index 28bf22da654..b38f64c4600 100644 --- a/htdocs/user/admin/user_extrafields.php +++ b/htdocs/user/admin/user_extrafields.php @@ -37,7 +37,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 1431c30b903..4fff1e385e2 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -65,6 +65,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +$thirdpartyid = GETPOST('thirdpartyid', 'int'); // Initialize technical objects $object=new WebsiteAccount($db); @@ -166,6 +167,7 @@ if ($action == 'create') print ''; print ''; print ''; + print ''; dol_fiche_head(array(), ''); From 0b120dd1a9fb7cc997f57423c8ccd3bdba623692 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 18:45:34 +0200 Subject: [PATCH 6/9] Prepare code to remove hooks on extrafield update --- htdocs/core/class/commonobject.class.php | 28 ++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index aa3fb034e32..a2c756c9d2a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4246,7 +4246,7 @@ abstract class CommonObject /** * Call trigger based on this instance. * Some context information may also be provided into array property this->context. - * NB: Error from trigger are stacked in interface->errors + * NB: Error from trigger are stacked in interface->errors * NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction. * * @param string $trigger_name trigger's name to execute @@ -4399,11 +4399,15 @@ abstract class CommonObject * Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * This function delete record with all extrafields and insert them again from the array $this->array_options. * - * @return int -1=error, O=did nothing, 1=OK + * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) + * @param User $userused Object user + * @return int -1=error, O=did nothing, 1=OK */ - function insertExtraFields() + function insertExtraFields($trigger='',$userused=null) { - global $conf,$langs; + global $conf,$langs,$user; + + if (empty($userused)) $userused=$user; $error=0; @@ -4529,6 +4533,22 @@ abstract class CommonObject if (! $resql) { $this->error=$this->db->lasterror(); + $error++; + } + else + { + if ($trigger) + { + // Call trigger + $this->context=array('extrafieldaddupdate'=>1); + $result=$this->call_trigger($trigger, $userused); + if ($result < 0) $error++; + // End call trigger + } + } + + if ($error) + { $this->db->rollback(); return -1; } From f24204c79a6aaa8930013c08620c06efb6396274 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 19:04:40 +0200 Subject: [PATCH 7/9] Error management after extrafield update --- htdocs/comm/card.php | 8 +++++-- htdocs/comm/propal/card.php | 6 ++++- htdocs/commande/card.php | 4 +++- htdocs/compta/facture/card.php | 6 +++-- htdocs/compta/facture/fiche-rec.php | 24 +++++++------------ htdocs/contrat/card.php | 18 +++++++------- htdocs/core/tpl/admin_extrafields_add.tpl.php | 8 +++---- htdocs/expedition/card.php | 8 ++++--- htdocs/expedition/shipment.php | 8 ++++--- htdocs/expensereport/card.php | 8 ++++--- htdocs/livraison/card.php | 4 +++- htdocs/product/stock/productlot_card.php | 8 ++++--- htdocs/societe/card.php | 8 ++++++- htdocs/supplier_proposal/card.php | 8 ++++++- 14 files changed, 76 insertions(+), 50 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 1b3d231382c..8fb590d61b4 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -186,8 +186,12 @@ if (empty($reshook)) if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); - if ($result < 0) $error++; + $result = $object->insertExtraFields(); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) $action = 'edit_extras'; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 835d5971ed2..eedc6002dcc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1176,7 +1176,11 @@ if (empty($reshook)) if (! $error) { $result = $object->insertExtraFields(); - if ($result < 0) $error++; + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) $action = 'edit_extras'; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 1402cc75870..549eab79d2f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1226,7 +1226,9 @@ if (empty($reshook)) // some hooks if (empty($reshook)) { $result = $object->insertExtraFields(); - if ($result < 0) { + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } else if ($reshook < 0) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a6f37ae4fc3..03ba1dccccc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2041,8 +2041,10 @@ if (empty($reshook)) // some hooks if (empty($reshook)) { $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; } } else if ($reshook < 0) $error ++; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index fbdabad8fa0..622b1bc7731 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -386,22 +386,16 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) - $error ++; + if ($ret < 0) $error++; - if (! $error) { - - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) - $error ++; - - if ($error) { - $action = 'edit_extras'; - setEventMessages($object->error, $object->errors, 'errors'); - } + if (! $error) { + $result = $object->insertExtraFields(); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } } // Add a new line diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index fd5898879ae..14913f5d2ee 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -821,21 +821,19 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) - $error ++; + if ($ret < 0) $error++; if (! $error) { - - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) - $error ++; + $result = $object->insertExtraFields(); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } if ($error) { $action = 'edit_extras'; - setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action=='setref_supplier') diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index e04f4e0cb92..fa8d3d6dea4 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -151,10 +151,10 @@ $langs->load("modulebuilder");
'; $searchpicto=$form->showFilterButtons(); diff --git a/htdocs/website/class/websiteaccount.class.php b/htdocs/website/class/websiteaccount.class.php index 267eae9ac57..8ef6cbb3a02 100644 --- a/htdocs/website/class/websiteaccount.class.php +++ b/htdocs/website/class/websiteaccount.class.php @@ -58,8 +58,8 @@ class WebsiteAccount extends CommonObject /** * 'type' if the field format. * 'label' the translation key. - * 'enabled' is a condition when the filed must be managed. - * 'visible' says if field is visible in list (-1 means not shown by default but can be added into list to be viewed). + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'index' if we want an index in database. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). @@ -75,24 +75,27 @@ class WebsiteAccount extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), - 'login' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Login',), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1,), - 'note_public' => array('type'=>'text', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>45, 'notnull'=>-1,), - 'note_private' => array('type'=>'text', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>46, 'notnull'=>-1,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Active')), + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), + 'login' => array('type'=>'varchar(64)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Login',), + 'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1,), + 'pass_temp' => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>30, 'notnull'=>-1,), + 'date_last_login' => array('type'=>'datetime', 'label'=>'LastConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>50, 'notnull'=>0,), + 'date_previous_login' => array('type'=>'datetime', 'label'=>'PreviousConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>51, 'notnull'=>0,), + //'note_public' => array('type'=>'text', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>45, 'notnull'=>-1,), + //'note_private' => array('type'=>'text', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>46, 'notnull'=>-1,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), + 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), + 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1, 'default'=>1, 'arrayofkeyval'=>array('1'=>'Active','0'=>'Disabled')), 'fk_soc' => array('type'=>'integer', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1,), ); public $rowid; public $login; - public $label; - public $note_public; - public $note_private; + public $pass_crypted; + public $date_last_login; + public $date_previous_login; public $date_creation; public $tms; public $fk_user_creat; diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php new file mode 100644 index 00000000000..1431c30b903 --- /dev/null +++ b/htdocs/website/websiteaccount_card.php @@ -0,0 +1,529 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/Website/websiteaccount_card.php + * \ingroup website + * \brief Page to create/edit/view websiteaccount + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res) die("Include of main fails"); + +include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); +include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); +dol_include_once('/website/class/websiteaccount.class.php'); +//dol_include_once('/website/lib/websiteaccount.lib.php'); + +// Load traductions files requiredby by page +$langs->loadLangs(array("website","other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new WebsiteAccount($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('websiteaccountcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('websiteaccount'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all",'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'website', $id); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + + + +/* + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error=0; + + $permissiontoadd = $user->rights->website->write; + $permissiontodelete = $user->rights->website->delete; + $backurlforlist = dol_buildpath('/website/websiteaccount_list.php',1); + + // Actions cancel, add, update or delete + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $trigger_name='MYOBJECT_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; + $trackid='websiteaccount'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + +/* + * VIEW + * + * Put here all code to build page + */ + +$form=new Form($db); +$formfile=new FormFile($db); + +llxHeader('','WebsiteAccount',''); + +// Example : Adding jquery code +print ''; + + +// Part to create +if ($action == 'create') +{ + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("WebsiteAccount"))); + + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head(array(), ''); + + print ''."\n"; + + foreach($object->fields as $key => $val) + { + if (abs($val['visible']) != 1) continue; // Discard such field from form + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field + + print ''; + print ''; + print $langs->trans($val['label']); + print ''; + print ''; + print ''; + } + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + + print '
'; + $defaultcss='minwidth100'; + if ($val['type'] == 'text') + { + print ''; + } + elseif (is_array($val['arrayofkeyval'])) + { + print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')); + } + else + { + $cssforinput = empty($val['css'])?$defaultcss:$val['css']; + print ''; + } + print '
'."\n"; + + dol_fiche_end(); + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create doe not post form + print '
'; + + print ''; +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') +{ + print load_fiche_titre($langs->trans("WebsiteAccount")); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''."\n"; + foreach($object->fields as $key => $val) + { + if (abs($val['visible']) != 1) continue; // Discard such field from form + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field + + print ''.$langs->trans($val['label']).''; + print ''; + print ''; + } + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + $defaultcss='minwidth100'; + if ($val['type'] == 'text') + { + print ''; + } + elseif (is_array($val['arrayofkeyval'])) + { + print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')!=''?GETPOST($key, 'int'):$object->$key); + } + else + { + $cssforinput = empty($val['css'])?$defaultcss:$val['css']; + print ''; + } + print '
'; + + dol_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals($object->id, $extralabels); + + $head = websiteaccountPrepareHead($object); + dol_fiche_head($head, 'card', $langs->trans("WebsiteAccount"), -1, 'websiteaccount@website'); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteWebsiteAccount'), $langs->trans('ConfirmDeleteWebsiteAccount'), 'confirm_delete', '', 0, 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); + }*/ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + if (! $formconfirm) { + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->website->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->website->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->website->creer) + { + if ($action != 'classify') + { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + */ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + foreach($object->fields as $key => $val) + { + if (abs($val['visible']) != 1) continue; // Discard such field from form + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field + + print ''.$langs->trans($val['label']).''; + print ''; + print ''; + + //if ($key == 'targetsrcfile3') break; // key used for break on second column + } + + print '
'; + print dol_escape_htmltag($object->$key, 1, 1); + print '
'; + print '
'; + print '
'; + print '
'; + print '
'; + print ''; + + $alreadyoutput = 1; + foreach($object->fields as $key => $val) + { + if ($alreadyoutput) + { + //if ($key == 'targetsrcfile3') $alreadyoutput = 0; // key used for break on second column + continue; + } + + if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue; + + print ''.$langs->trans($val['label']).''; + print ''; + print ''; + } + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print dol_escape_htmltag($object->$key, 1, 1); + print '
'; + print '
'; + print '
'; + print '
'; + + print '

'; + + dol_fiche_end(); + + + // Buttons for actions + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + // Send + print ''."\n"; + + if ($user->rights->website->write) + { + print ''."\n"; + } + + /* + if ($user->rights->sellyoursaas->create) + { + if ($object->status == 1) + { + print ''."\n"; + } + else + { + print ''."\n"; + } + } + */ + + if ($user->rights->website->delete) + { + print ''."\n"; + } + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + // Documents + $comref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->website->dir_output . '/' . $comref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->website->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->website->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('website', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('websiteaccount')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + $MAXEVENT = 10; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT); + + print '
'; + } + + // Presend form + $modelmail='websiteaccount'; + $defaulttopic='Information'; + $diroutput = $conf->website->dir_output; + $trackid = 'websiteaccount'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; +} + + +// End of page +llxFooter(); +$db->close(); From 72441de1ec0975156c42d493eba889066f7cedbb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 17:35:53 +0200 Subject: [PATCH 4/9] Fix length of fk_mainmenu and fk_leftmenu --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 4 ++++ htdocs/install/mysql/tables/llx_menu.sql | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index cd94b97fa43..cffa2ccfe0b 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -169,6 +169,10 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_lim_reglement datetime DE ALTER TABLE llx_accounting_bookkeeping ADD COLUMN fk_user integer NULL; +ALTER TABLE llx_menu MODIFY fk_mainmenu varchar(100); +ALTER TABLE llx_menu MODIFY fk_leftmenu varchar(100); + + CREATE TABLE llx_websiteaccount( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, login varchar(64) NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_menu.sql b/htdocs/install/mysql/tables/llx_menu.sql index e77584d1c40..18862ff496a 100644 --- a/htdocs/install/mysql/tables/llx_menu.sql +++ b/htdocs/install/mysql/tables/llx_menu.sql @@ -30,8 +30,8 @@ CREATE TABLE llx_menu mainmenu varchar(100) NOT NULL, -- Name family/module for top menu (home, companies, ...) leftmenu varchar(100) NULL, -- Name family/module for left menu (setup, info, ...) fk_menu integer NOT NULL, -- 0 or Id of mother menu line, or -1 if we use fk_mainmenu and fk_leftmenu - fk_mainmenu varchar(24), -- - fk_leftmenu varchar(24), -- + fk_mainmenu varchar(100), -- + fk_leftmenu varchar(100), -- position integer NOT NULL, -- Sort order of entry url varchar(255) NOT NULL, -- Relative (or absolute) url to go target varchar(100) NULL, -- Target of Url link From 9f0f5eb5e8051129911da5f0005b15cf1b19ae1d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 18:05:43 +0200 Subject: [PATCH 5/9] Fix translation of extrafields type --- .../adherents/admin/adherent_extrafields.php | 2 +- .../admin/adherent_type_extrafields.php | 2 +- htdocs/admin/agenda_extrafields.php | 2 +- htdocs/admin/bank_extrafields.php | 2 +- htdocs/admin/expedition_extrafields.php | 2 +- htdocs/admin/expeditiondet_extrafields.php | 4 +- htdocs/admin/expensereport_extrafields.php | 2 +- htdocs/admin/livraison_extrafields.php | 2 +- htdocs/admin/livraisondet_extrafields.php | 4 +- htdocs/admin/order_extrafields.php | 2 +- htdocs/admin/orderdet_extrafields.php | 2 +- htdocs/admin/resource_extrafields.php | 2 +- htdocs/admin/supplierinvoice_extrafields.php | 2 +- .../admin/supplierinvoicedet_extrafields.php | 2 +- htdocs/admin/supplierorder_extrafields.php | 2 +- htdocs/admin/supplierorderdet_extrafields.php | 2 +- .../admin/categorie_extrafields.php | 2 +- htdocs/comm/admin/propal_extrafields.php | 4 +- htdocs/comm/admin/propaldet_extrafields.php | 2 +- .../admin/facture_cust_extrafields.php | 2 +- .../admin/facture_rec_cust_extrafields.php | 2 +- .../admin/facturedet_cust_extrafields.php | 2 +- .../admin/facturedet_rec_cust_extrafields.php | 2 +- htdocs/contrat/admin/contract_extrafields.php | 2 +- .../contrat/admin/contractdet_extrafields.php | 2 +- htdocs/don/admin/donation_extrafields.php | 2 +- .../fichinter/admin/fichinter_extrafields.php | 2 +- .../admin/fichinterdet_extrafields.php | 2 +- htdocs/product/admin/product_extrafields.php | 2 +- .../product/admin/product_lot_extrafields.php | 2 +- htdocs/projet/admin/project_extrafields.php | 2 +- .../projet/admin/project_task_extrafields.php | 2 +- htdocs/societe/admin/contact_extrafields.php | 2 +- htdocs/societe/admin/societe_extrafields.php | 2 +- htdocs/societe/website.php | 38 +------------------ .../admin/supplier_proposal_extrafields.php | 4 +- .../supplier_proposaldet_extrafields.php | 4 +- htdocs/user/admin/group_extrafields.php | 2 +- htdocs/user/admin/user_extrafields.php | 2 +- htdocs/website/websiteaccount_card.php | 2 + 40 files changed, 46 insertions(+), 80 deletions(-) diff --git a/htdocs/adherents/admin/adherent_extrafields.php b/htdocs/adherents/admin/adherent_extrafields.php index 542b4f29a57..8b82fa7be48 100644 --- a/htdocs/adherents/admin/adherent_extrafields.php +++ b/htdocs/adherents/admin/adherent_extrafields.php @@ -37,7 +37,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/adherents/admin/adherent_type_extrafields.php b/htdocs/adherents/admin/adherent_type_extrafields.php index 8e0d5f9eaa8..1fd89cc1bd4 100644 --- a/htdocs/adherents/admin/adherent_type_extrafields.php +++ b/htdocs/adherents/admin/adherent_type_extrafields.php @@ -40,7 +40,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index b331611e511..ec7701a1a13 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -44,7 +44,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 794483350f1..ccdde0eecb6 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -39,7 +39,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/expedition_extrafields.php b/htdocs/admin/expedition_extrafields.php index 8c24c49cb23..09e0e8b9a92 100644 --- a/htdocs/admin/expedition_extrafields.php +++ b/htdocs/admin/expedition_extrafields.php @@ -47,7 +47,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/expeditiondet_extrafields.php b/htdocs/admin/expeditiondet_extrafields.php index 283eeab452a..ff388d8a69a 100644 --- a/htdocs/admin/expeditiondet_extrafields.php +++ b/htdocs/admin/expeditiondet_extrafields.php @@ -7,7 +7,7 @@ * Copyright (C) 2013 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Claudio Aschieri - * + * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index d1d3aacc9cc..8635c336a2b 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -44,7 +44,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/livraison_extrafields.php b/htdocs/admin/livraison_extrafields.php index 84037ae9b80..5c9a17edc7a 100644 --- a/htdocs/admin/livraison_extrafields.php +++ b/htdocs/admin/livraison_extrafields.php @@ -47,7 +47,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/livraisondet_extrafields.php b/htdocs/admin/livraisondet_extrafields.php index 22a7e89d724..47e5b2eb975 100644 --- a/htdocs/admin/livraisondet_extrafields.php +++ b/htdocs/admin/livraisondet_extrafields.php @@ -7,7 +7,7 @@ * Copyright (C) 2013 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Claudio Aschieri - * + * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index 043d6bbadd9..c2ecb2a5bc0 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -44,7 +44,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 5120fd5c931..db86f7ba2fe 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -45,7 +45,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index c3d90fac3e5..6f8eeaa167e 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -43,7 +43,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 4e0bd1d0dd2..ad04e1f5256 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -48,7 +48,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index 26b3b42e970..469a00732dd 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -48,7 +48,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index bcad8121afc..55ca530e27f 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -44,7 +44,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 97d505144bb..55491385027 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -45,7 +45,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index c72ef73e970..c20dff5db42 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -37,7 +37,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index 8d2ecd88277..33c38282847 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -38,7 +38,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); @@ -87,7 +87,7 @@ if ($action != 'create' && $action != 'edit') /* ************************************************************************** */ /* */ -/* Creation of an optional field */ +/* Creation of an optional field */ /* */ /* ************************************************************************** */ diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index 80f5afdaeed..270274327e6 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -45,7 +45,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index c7a43c737de..2e985c8a009 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -39,7 +39,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 1bc9272a32f..0cbea0c8d89 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -40,7 +40,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index 3a5f8c3387f..b17e3c416d2 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -40,7 +40,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 8c2a0b3365a..0951dff721b 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -40,7 +40,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index 509c5307ef8..abfc2b2b65d 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -41,7 +41,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php index 39c691e7ddc..e2eb2bacc6c 100644 --- a/htdocs/contrat/admin/contractdet_extrafields.php +++ b/htdocs/contrat/admin/contractdet_extrafields.php @@ -41,7 +41,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/don/admin/donation_extrafields.php b/htdocs/don/admin/donation_extrafields.php index df9b2f527bb..d1dbb6dccfa 100644 --- a/htdocs/don/admin/donation_extrafields.php +++ b/htdocs/don/admin/donation_extrafields.php @@ -36,7 +36,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/fichinter/admin/fichinter_extrafields.php b/htdocs/fichinter/admin/fichinter_extrafields.php index bab7572e60a..1afe5feaeed 100644 --- a/htdocs/fichinter/admin/fichinter_extrafields.php +++ b/htdocs/fichinter/admin/fichinter_extrafields.php @@ -41,7 +41,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php index 5fadc3f4c2c..cd21b3d9590 100644 --- a/htdocs/fichinter/admin/fichinterdet_extrafields.php +++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php @@ -41,7 +41,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/product/admin/product_extrafields.php b/htdocs/product/admin/product_extrafields.php index 304b0d68333..e7b6a0bd33c 100644 --- a/htdocs/product/admin/product_extrafields.php +++ b/htdocs/product/admin/product_extrafields.php @@ -39,7 +39,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/product/admin/product_lot_extrafields.php b/htdocs/product/admin/product_lot_extrafields.php index fb1cdfcb704..225b1fff45c 100644 --- a/htdocs/product/admin/product_lot_extrafields.php +++ b/htdocs/product/admin/product_lot_extrafields.php @@ -40,7 +40,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/projet/admin/project_extrafields.php b/htdocs/projet/admin/project_extrafields.php index 26a6286f034..eb27110e88c 100644 --- a/htdocs/projet/admin/project_extrafields.php +++ b/htdocs/projet/admin/project_extrafields.php @@ -39,7 +39,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/projet/admin/project_task_extrafields.php b/htdocs/projet/admin/project_task_extrafields.php index 58f91e863fc..9f47376d02d 100644 --- a/htdocs/projet/admin/project_task_extrafields.php +++ b/htdocs/projet/admin/project_task_extrafields.php @@ -39,7 +39,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/societe/admin/contact_extrafields.php b/htdocs/societe/admin/contact_extrafields.php index 2a60252f7f8..f97ceedcca3 100644 --- a/htdocs/societe/admin/contact_extrafields.php +++ b/htdocs/societe/admin/contact_extrafields.php @@ -37,7 +37,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/societe/admin/societe_extrafields.php b/htdocs/societe/admin/societe_extrafields.php index a722ec61b86..8826f1e4750 100644 --- a/htdocs/societe/admin/societe_extrafields.php +++ b/htdocs/societe/admin/societe_extrafields.php @@ -38,7 +38,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index c5b7b4b5cb8..16bbc0554d2 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -230,7 +230,7 @@ dol_fiche_end(); $morehtmlcenter = ''; if (! empty($conf->website->enabled)) { if (! empty($user->rights->societe->lire)) { - $morehtmlcenter .= '' . $langs->trans("AddWebsiteAccount") . ''; + $morehtmlcenter .= '' . $langs->trans("AddWebsiteAccount") . ''; } else { $morehtmlcenter .= '' . $langs->trans("AddAction") . ''; } @@ -424,7 +424,6 @@ print '
'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined diff --git a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php index 8d6d437f466..0e84519e406 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php @@ -32,7 +32,7 @@ $form = new Form($db); // List of supported format $tmptype2label=ExtraFields::$type2label; $type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); $action=GETPOST('action', 'alpha'); $attrname=GETPOST('attrname', 'alpha'); @@ -90,7 +90,7 @@ print "
".$extrafields->attribute_pos[$key]."".$extrafields->attribute_label[$key]."
".$extrafields->attribute_label[$key]."".$key."
- textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0)?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0)?> - textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0)?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0,'', 0, 2, 'helpvalue1')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?>
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 8cecd906529..7e9213a2c9a 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -173,9 +173,11 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { $result = $object->insertExtraFields(); - if ($result < 0) { - $error++; - } + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } else if ($reshook < 0) $error++; } diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 80274f9b579..957d9864e16 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -191,9 +191,11 @@ if (empty($reshook)) // some hooks if (empty($reshook)) { $result = $object->insertExtraFields(); - if ($result < 0) { - $error++; - } + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } else if ($reshook < 0) $error++; } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 3af4709ee6c..29a058f2d33 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -296,9 +296,11 @@ if (empty($reshook)) // some hooks if (empty($reshook)) { $result = $object->insertExtraFields(); - if ($result < 0) { - $error++; - } + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } else if ($reshook < 0) $error++; } diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 8cff2b885b0..b0de98ae2eb 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -207,7 +207,9 @@ if ($action == 'update_extras') $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { $result = $object->insertExtraFields(); - if ($result < 0) { + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } else if ($reshook < 0) diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 70d907ae5e9..3a8f4cbff4e 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -136,9 +136,11 @@ if (empty($reshook)) // some hooks if (empty($reshook)) { $result = $object->insertExtraFields(); - if ($result < 0) { - $error++; - } + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } else if ($reshook < 0) $error++; } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 3d3bfa1b6d1..5e02cb99eaf 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -290,11 +290,17 @@ if (empty($reshook)) $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error++; + if (! $error) { $result = $object->insertExtraFields(); - if ($result < 0) $error++; + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } + if ($error) $action = 'edit_extras'; } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index cfdb94c42bb..75ea0cd12ed 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -930,11 +930,17 @@ if (empty($reshook)) $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error++; + if (! $error) { $result = $object->insertExtraFields(); - if ($result < 0) $error++; + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } + if ($error) $action = 'edit_extras'; } } From f381361c8b4fc1d6dc0b689a33bb0d4dc6205d6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 19:57:36 +0200 Subject: [PATCH 8/9] Work on modulebuilder --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/modulebuilder.lib.php | 6 +++++- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 8 ++++---- .../modulebuilder/template/class/myobject.class.php | 11 ++++++----- htdocs/website/class/websiteaccount.class.php | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index aef8f98648f..9902efd03e5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -504,7 +504,7 @@ class Form global $conf, $langs; $alt = ''; - if ($tooltiptrigger) $alt=$langs->trans("ClickToShowHelp"); + if ($tooltiptrigger) $alt=$langs->transnoentitiesnoconv("ClickToShowHelp"); //For backwards compatibility if ($type == '0') $type = 'info'; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 28cd88e6a7e..aadea327d77 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -251,7 +251,11 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', foreach($object->fields as $key => $val) { $i++; - $texttoinsert.= "\t".$key." ".$val['type']; + + $type = $val['type']; + $type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php' + + $texttoinsert.= "\t".$key." ".$type; if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; else diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index def07fa432f..d41302be808 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -210,10 +210,10 @@ else - textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0)?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0)?> - textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0)?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0,'', 0, 2, 'helpvalue1')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?> diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 6c14cd6dc77..66037ae8722 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -74,13 +74,14 @@ class MyObject extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200'), - 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Amount'), - 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>45), - 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>46), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text'), + 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>'LinkToThirparty'), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), diff --git a/htdocs/website/class/websiteaccount.class.php b/htdocs/website/class/websiteaccount.class.php index 8ef6cbb3a02..52187724fc9 100644 --- a/htdocs/website/class/websiteaccount.class.php +++ b/htdocs/website/class/websiteaccount.class.php @@ -89,7 +89,7 @@ class WebsiteAccount extends CommonObject 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,), 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1, 'default'=>1, 'arrayofkeyval'=>array('1'=>'Active','0'=>'Disabled')), - 'fk_soc' => array('type'=>'integer', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1,), ); public $rowid; public $login; From bb996019c29d1eb78747942dd1caaa8d0c9a7a44 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Oct 2017 11:42:14 +0200 Subject: [PATCH 9/9] NEW Support visibility on extrafields --- htdocs/api/class/api_dictionary.class.php | 69 ++- htdocs/core/actions_extrafields.inc.php | 4 +- htdocs/core/class/commonobject.class.php | 565 +++++++++++++++++- htdocs/core/class/extrafields.class.php | 83 ++- htdocs/core/tpl/admin_extrafields_add.tpl.php | 18 +- .../core/tpl/admin_extrafields_edit.tpl.php | 19 +- .../core/tpl/admin_extrafields_view.tpl.php | 1 - htdocs/core/tpl/extrafields_view.tpl.php | 3 +- .../install/mysql/migration/6.0.0-7.0.0.sql | 2 +- .../install/mysql/tables/llx_extrafields.sql | 3 +- htdocs/langs/en_US/modulebuilder.lang | 2 +- .../modulebuilder/template/myobject_card.php | 4 +- htdocs/website/websiteaccount_card.php | 28 +- 13 files changed, 665 insertions(+), 136 deletions(-) diff --git a/htdocs/api/class/api_dictionary.class.php b/htdocs/api/class/api_dictionary.class.php index b0d5bb00b0a..d551f3d866f 100644 --- a/htdocs/api/class/api_dictionary.class.php +++ b/htdocs/api/class/api_dictionary.class.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; class Dictionary extends DolibarrApi { private $translations = null; - + /** * Constructor */ @@ -52,11 +52,11 @@ class Dictionary extends DolibarrApi * @param int $page Page number {@min 0} * @param int $active Payment type is active or not {@min 0} {@max 1} * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')" - * + * * @url GET payment/types * * @return array [List of payment types] - * + * * @throws 400 RestException * @throws 200 OK */ @@ -104,7 +104,7 @@ class Dictionary extends DolibarrApi return $list; } - + /** * Get the list of countries. * @@ -121,9 +121,9 @@ class Dictionary extends DolibarrApi * @param string $lang Code of the language the label of the countries must be translated to * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return List of countries - * + * * @url GET countries - * + * * @throws RestException */ function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') @@ -135,7 +135,7 @@ class Dictionary extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t"; $sql.=" WHERE 1 = 1"; // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -144,7 +144,7 @@ class Dictionary extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $this->db->order($sortfield, $sortorder); if ($limit) { @@ -152,7 +152,7 @@ class Dictionary extends DolibarrApi $page = 0; } $offset = $limit * $page; - + $sql .= $this->db->plimit($limit, $offset); } @@ -177,7 +177,7 @@ class Dictionary extends DolibarrApi } else { throw new RestException(503, 'Error when retrieving list of countries : '.$country->error); } - + return $list; } @@ -187,9 +187,9 @@ class Dictionary extends DolibarrApi * @param int $id ID of country * @param string $lang Code of the language the name of the * country must be translated to - * + * * @url GET countries/{id} - * + * * @throws RestException */ function getCountryByID($id, $lang = '') @@ -217,16 +217,16 @@ class Dictionary extends DolibarrApi function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); - + unset($object->error); unset($object->errors); - + return $object; } /** * Translate the name of the country to the given language. - * + * * @param Ccountry $country Country * @param string $lang Code of the language the name of the * country must be translated to @@ -249,8 +249,8 @@ class Dictionary extends DolibarrApi } } } - } - + } + /** * Get the list of events types. * @@ -262,7 +262,7 @@ class Dictionary extends DolibarrApi * @param string $module To filter on module events * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return List of events types - * + * * @url GET events * * @throws RestException @@ -312,9 +312,9 @@ class Dictionary extends DolibarrApi } return $list; - } - - + } + + /** * Get the list of extra fields. * @@ -323,7 +323,7 @@ class Dictionary extends DolibarrApi * @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')" * @return List of events types - * + * * @url GET extrafields * * @throws RestException @@ -335,7 +335,7 @@ class Dictionary extends DolibarrApi if ($type == 'thirdparty') $type='societe'; if ($type == 'contact') $type='socpeople'; - $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed"; + $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t"; $sql.= " WHERE t.entity IN (".getEntity('extrafields').")"; if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'"; @@ -373,7 +373,6 @@ class Dictionary extends DolibarrApi $list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; $list[$tab->elementtype][$tab->name]['perms']=$tab->perms; $list[$tab->elementtype][$tab->name]['list']=$tab->list; - $list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden; } } } @@ -388,9 +387,9 @@ class Dictionary extends DolibarrApi } return $list; - } - - + } + + /** * Get the list of towns. * @@ -402,9 +401,9 @@ class Dictionary extends DolibarrApi * @param string $town To filter on city name * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return List of towns - * + * * @url GET towns - * + * * @throws RestException */ function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $sqlfilters = '') @@ -426,8 +425,8 @@ class Dictionary extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - - + + $sql.= $this->db->order($sortfield, $sortorder); if ($limit) { @@ -435,10 +434,10 @@ class Dictionary extends DolibarrApi $page = 0; } $offset = $limit * $page; - + $sql .= $this->db->plimit($limit, $offset); } - + $result = $this->db->query($sql); if ($result) { @@ -450,9 +449,9 @@ class Dictionary extends DolibarrApi } else { throw new RestException(503, 'Error when retrieving list of towns : '.$this->db->lasterror()); } - + return $list; - } + } /** * Get the list of payments terms. diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index b6e70059da3..798a43b8d96 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -174,7 +174,7 @@ if ($action == 'add') (GETPOST('alwayseditable', 'alpha')?1:0), (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list - (GETPOST('ishidden', 'alpha')?1:0), + 0, GETPOST('computed_value','alpha'), (GETPOST('entitycurrentorall', 'alpha')?0:''), GETPOST('langfile', 'alpha') @@ -336,7 +336,7 @@ if ($action == 'update') (GETPOST('alwayseditable', 'alpha')?1:0), (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list - (GETPOST('ishidden', 'alpha')?1:0), + 0, GETPOST('default_value','alpha'), GETPOST('computed_value','alpha'), (GETPOST('entitycurrentorall', 'alpha')?0:''), diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a2c756c9d2a..fb42e1bfbde 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4651,14 +4651,572 @@ abstract class CommonObject else return 0; } + + /** + * Return HTML string to put an input field into a page + * Code very similar with showInputField of extra fields + * + * @param array $val Array of properties for field to show + * @param string $key Key of attribute + * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) + * @param string $moreparam To add more parametes on html input tag + * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) + * @param mixed $showsize Value for css to define size. May also be a numeric. + * @param int $objectid Current object id + * @return string + */ + function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0, $objectid=0) + { + global $conf,$langs; + + $label=$val['label']; + $type =$val['type']; + $size =$val['css']; + + // Convert var to be able to share same code than showInputField of extrafields + if (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar + if (is_array($val['arrayofkeyval'])) $type='select'; + if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link'; + + //$elementtype=$this->attribute_elementtype[$key]; // seems to not be used + $default=$val['default']; + $computed=$val['computed']; + $unique=$val['unique']; + $required=$val['required']; + $param=$val['param']; + if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; + if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) + { + $type='link'; + $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); + } + $langfile=$val['langfile']; + $list=$val['list']; + $hidden=(abs($val['visible'])!=1 ? 1 : 0); + $help=$val['help']; + + + if ($computed) + { + if (! preg_match('/^search_/', $keyprefix)) return ''.$langs->trans("AutomaticallyCalculated").''; + else return ''; + } + + if (empty($showsize)) + { + if ($type == 'date') + { + //$showsize=10; + $showsize = 'minwidth100imp'; + } + elseif ($type == 'datetime') + { + //$showsize=19; + $showsize = 'minwidth200imp'; + } + elseif (in_array($type,array('int','double','price'))) + { + //$showsize=10; + $showsize = 'maxwidth75'; + } + elseif ($type == 'url') + { + $showsize='minwidth400'; + } + elseif ($type == 'boolean') + { + $showsize=''; + } + else + { + if (round($size) < 12) + { + $showsize = 'minwidth100'; + } + else if (round($size) <= 48) + { + $showsize = 'minwidth200'; + } + else + { + //$showsize=48; + $showsize = 'minwidth400'; + } + } + } + + if (in_array($type,array('date','datetime'))) + { + $tmp=explode(',',$size); + $newsize=$tmp[0]; + + $showtime = in_array($type,array('datetime')) ? 1 : 0; + + // Do not show current date when field not required (see select_date() method) + if (!$required && $value == '') $value = '-1'; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + global $form; + if (! is_object($form)) $form=new Form($this->db); + + // TODO Must also support $moreparam + $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1); + } + elseif (in_array($type,array('int','integer'))) + { + $tmp=explode(',',$size); + $newsize=$tmp[0]; + $out=''; + } + elseif (preg_match('/varchar/', $type)) + { + $out=''; + } + elseif (in_array($type, array('mail', 'phone', 'url'))) + { + $out=''; + } + elseif ($type == 'text') + { + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); + $out=$doleditor->Create(1); + } + elseif ($type == 'boolean') + { + $checked=''; + if (!empty($value)) { + $checked=' checked value="1" '; + } else { + $checked=' value="1" '; + } + $out=''; + } + elseif ($type == 'price') + { + if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. + $value=price($value); + } + $out=' '.$langs->getCurrencySymbol($conf->currency); + } + elseif ($type == 'double') + { + if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. + $value=price($value); + } + $out=' '; + } + elseif ($type == 'select') + { + $out = ''; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); + } + + $out.=''; + } + elseif ($type == 'sellist') + { + $out = ''; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); + } + + $out.=''; + } + elseif ($type == 'checkbox') + { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $form = new Form($db); + + $value_arr=explode(',',$value); + $out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); + + } + elseif ($type == 'radio') + { + $out=''; + foreach ($param['options'] as $keyopt => $val) + { + $out.=''.$val.'
'; + } + } + elseif ($type == 'chkbxlst') + { + if (is_array($value)) { + $value_arr = $value; + } + else { + $value_arr = explode(',', $value); + } + + if (is_array($param['options'])) { + $param_list = array_keys($param['options']); + $InfoFieldList = explode(":", $param_list[0]); + // 0 : tableName + // 1 : label field name + // 2 : key fields name (if differ of rowid) + // 3 : key field parent (for dependent lists) + // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value + $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid'); + + if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) { + list ( $parentName, $parentField ) = explode('|', $InfoFieldList[3]); + $keyList .= ', ' . $parentField; + } + if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) { + if (strpos($InfoFieldList[4], 'extra.') !== false) { + $keyList = 'main.' . $InfoFieldList[2] . ' as rowid'; + } else { + $keyList = $InfoFieldList[2] . ' as rowid'; + } + } + + $fields_label = explode('|', $InfoFieldList[1]); + if (is_array($fields_label)) { + $keyList .= ', '; + $keyList .= implode(', ', $fields_label); + } + + $sqlwhere = ''; + $sql = 'SELECT ' . $keyList; + $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; + if (! empty($InfoFieldList[4])) { + + // can use SELECT request + if (strpos($InfoFieldList[4], '$SEL$')!==false) { + $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); + } + + // current object id can be use into filter + if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { + $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); + } else { + $InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]); + } + + // We have to join on extrafield table + if (strpos($InfoFieldList[4], 'extra') !== false) { + $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; + $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4]; + } else { + $sqlwhere .= ' WHERE ' . $InfoFieldList[4]; + } + } else { + $sqlwhere .= ' WHERE 1=1'; + } + // Some tables may have field, some other not. For the moment we disable it. + if (in_array($InfoFieldList[0], array ('tablewithentity'))) + { + $sqlwhere .= ' AND entity = ' . $conf->entity; + } + // $sql.=preg_replace('/^ AND /','',$sqlwhere); + // print $sql; + + $sql .= $sqlwhere; + dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + + $data=array(); + + while ( $i < $num ) { + $labeltoshow = ''; + $obj = $this->db->fetch_object($resql); + + // Several field into label (eq table:code|libelle:rowid) + $fields_label = explode('|', $InfoFieldList[1]); + if (is_array($fields_label)) { + $notrans = true; + foreach ( $fields_label as $field_toshow ) { + $labeltoshow .= $obj->$field_toshow . ' '; + } + } else { + $labeltoshow = $obj->{$InfoFieldList[1]}; + } + $labeltoshow = dol_trunc($labeltoshow, 45); + + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + foreach ( $fields_label as $field_toshow ) { + $translabel = $langs->trans($obj->$field_toshow); + if ($translabel != $obj->$field_toshow) { + $labeltoshow = dol_trunc($translabel, 18) . ' '; + } else { + $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; + } + } + + $data[$obj->rowid]=$labeltoshow; + + } else { + if (! $notrans) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); + if ($translabel != $obj->{$InfoFieldList[1]}) { + $labeltoshow = dol_trunc($translabel, 18); + } else { + $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); + } + } + if (empty($labeltoshow)) + $labeltoshow = '(not defined)'; + + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + $data[$obj->rowid]=$labeltoshow; + } + + if (! empty($InfoFieldList[3])) { + $parent = $parentName . ':' . $obj->{$parentField}; + } + + $data[$obj->rowid]=$labeltoshow; + } + + $i ++; + } + $this->db->free($resql); + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $form = new Form($db); + + $out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); + + } else { + print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; + } + } + $out .= ''; + } + elseif ($type == 'link') + { + $out=''; + + $param_list=array_keys($param['options']); + // 0 : ObjectName + // 1 : classPath + $InfoFieldList = explode(":", $param_list[0]); + dol_include_once($InfoFieldList[1]); + if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) + { + $valuetoshow=$value; + if (!empty($value)) + { + $object = new $InfoFieldList[0]($this->db); + $resfetch=$object->fetch($value); + if ($resfetch > 0) + { + $valuetoshow=$object->ref; + if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique) + } + } + $out.=''; + } + else + { + dol_syslog('Error bad setup of type for field '.$InfoFieldList, LOG_WARNING); + $out.='Error bad setup of type for field '.join(',', $InfoFieldList); + } + } + elseif ($type == 'password') + { + // If prefix is 'search_', field is used as a filter, we use a common text field. + $out=''; + } + if (!empty($hidden)) { + $out=''; + } + /* Add comments + if ($type == 'date') $out.=' (YYYY-MM-DD)'; + elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; + */ + return $out; + } + + + /** * Function to show lines of extrafields with output datas * * @param Extrafields $extrafields Extrafield Object * @param string $mode Show output (view) or input (edit) for extrafield * @param array $params Optional parameters - * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) - * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) * * @return string */ @@ -4677,6 +5235,9 @@ abstract class CommonObject $e = 0; foreach($extrafields->attribute_label as $key=>$label) { + if (empty($extrafields->attribute_list[$key])) continue; // 0 = Never visible field + if (($mode == 'create' || $mode == 'edit') && abs($extrafields->attribute_list[$key]) != 1) continue; // <> -1 and <> 1 = not visible on forms, only on list + // Load language if required if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 7130287b6bd..012a3ce7acc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -140,8 +140,8 @@ class ExtraFields * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Into list view by default (-1, 0 or 1) - * @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) + * @param int $list Visibilty + * @param int $ishidden Deprecated. Us visibility instead. * @param string $computed Computed value * @param string $entity Entity of extrafields * @param string $langfile Language file @@ -279,8 +279,8 @@ class ExtraFields * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Into list view by default (-1, 0 or 1) - * @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) + * @param int $list Visibily + * @param int $ishidden Deprecated. Use visibility instead. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value * @param string $entity Entity of extrafields @@ -328,7 +328,6 @@ class ExtraFields $sql.= " perms,"; $sql.= " langs,"; $sql.= " list,"; - $sql.= " ishidden,"; $sql.= " fielddefault,"; $sql.= " fieldcomputed,"; $sql.= " fk_user_author,"; @@ -349,7 +348,6 @@ class ExtraFields $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; $sql.= " ".$list.","; - $sql.= " ".$ishidden.","; $sql.= " ".($default?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql .= " " . $user->id . ","; @@ -483,8 +481,8 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Into list view by default - * @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) + * @param int $list Visibility + * @param int $ishidden Deprecated. Use visiblity instead. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value * @param string $entity Entity of extrafields @@ -589,8 +587,8 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Into list view by default - * @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) + * @param int $list Visiblity + * @param int $ishidden Deprecated. Use visility instead. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value * @param string $entity Entity of extrafields @@ -639,7 +637,6 @@ class ExtraFields $sql.= " alwayseditable,"; $sql.= " param,"; $sql.= " list,"; - $sql.= " ishidden,"; $sql.= " fielddefault,"; $sql.= " fieldcomputed,"; $sql.= " fk_user_author,"; @@ -660,7 +657,6 @@ class ExtraFields $sql.= " '".$alwayseditable."',"; $sql.= " '".$param."',"; $sql.= " ".$list.", "; - $sql.= " ".$ishidden.", "; $sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql .= " " . $user->id . ","; @@ -714,7 +710,7 @@ class ExtraFields // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,ishidden,fielddefault,fieldcomputed"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed"; $sql .= ",entity"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; @@ -749,7 +745,6 @@ class ExtraFields $this->attribute_perms[$tab->name]=$tab->perms; $this->attribute_langfile[$tab->name]=$tab->langs; $this->attribute_list[$tab->name]=$tab->list; - $this->attribute_hidden[$tab->name]=$tab->ishidden; $this->attribute_entityid[$tab->name]=$tab->entity; // New usage @@ -767,7 +762,6 @@ class ExtraFields $this->attributes[$tab->elementtype]['perms'][$tab->name]=$tab->perms; $this->attributes[$tab->elementtype]['langfile'][$tab->name]=$tab->langs; $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; - $this->attributes[$tab->elementtype]['ishidden'][$tab->name]=$tab->ishidden; $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; if (!empty($conf->multicompany->enabled)) @@ -802,12 +796,13 @@ class ExtraFields /** * Return HTML string to put an input field into a page + * Code very similar with showInputField of common object * * @param string $key Key of attribute * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) * @param string $moreparam To add more parametes on html input tag - * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keysuffix Prefix string to add after name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Suffix string to add before name and id of field (can be used to avoid duplicate names) * @param mixed $showsize Value for css to define size. May also be a numeric. * @param int $objectid Current object id * @return string @@ -816,10 +811,12 @@ class ExtraFields { global $conf,$langs; + $keyprefix = $keyprefix.'options_'; // Because we work on extrafields + $label=$this->attribute_label[$key]; $type =$this->attribute_type[$key]; $size =$this->attribute_size[$key]; - $elementtype=$this->attribute_elementtype[$key]; + $elementtype=$this->attribute_elementtype[$key]; // Seems not used $default=$this->attribute_default[$key]; $computed=$this->attribute_computed[$key]; $unique=$this->attribute_unique[$key]; @@ -831,7 +828,7 @@ class ExtraFields if ($computed) { - if ($keyprefix != 'search_') return ''.$langs->trans("AutomaticallyCalculated").''; + if (! preg_match('/^search_/', $keyprefix)) return ''.$langs->trans("AutomaticallyCalculated").''; else return ''; } @@ -847,7 +844,7 @@ class ExtraFields //$showsize=19; $showsize = 'minwidth200imp'; } - elseif (in_array($type,array('int','double','price'))) + elseif (in_array($type,array('int','integer','double','price'))) { //$showsize=10; $showsize = 'maxwidth75'; @@ -893,26 +890,26 @@ class ExtraFields if (! is_object($form)) $form=new Form($this->db); // TODO Must also support $moreparam - $out = $form->select_date($value, $keyprefix.'options_'.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1); + $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1); } - elseif (in_array($type,array('int'))) + elseif (in_array($type,array('int','integer'))) { $tmp=explode(',',$size); $newsize=$tmp[0]; - $out=''; + $out=''; } - elseif ($type == 'varchar') + elseif (preg_match('/varchar/', $type)) { - $out=''; + $out=''; } elseif (in_array($type, array('mail', 'phone', 'url'))) { - $out=''; + $out=''; } elseif ($type == 'text') { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keyprefix.'options_'.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); + $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); $out=$doleditor->Create(1); } elseif ($type == 'boolean') @@ -923,21 +920,21 @@ class ExtraFields } else { $checked=' value="1" '; } - $out=''; + $out=''; } elseif ($type == 'price') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } - $out=' '.$langs->getCurrencySymbol($conf->currency); + $out=' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } - $out=' '; + $out=' '; } elseif ($type == 'select') { @@ -945,10 +942,10 @@ class ExtraFields if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($keyprefix.'options_'.$key.$keysuffix, array(), 0); + $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; $out.=''; foreach ($param['options'] as $key => $val) { @@ -967,10 +964,10 @@ class ExtraFields if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($keyprefix.'options_'.$key.$keysuffix, array(), 0); + $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; if (is_array($param['options'])) { $param_list=array_keys($param['options']); @@ -1132,7 +1129,7 @@ class ExtraFields $form = new Form($db); $value_arr=explode(',',$value); - $out=$form->multiselectarray($keyprefix.'options_'.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); + $out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); } elseif ($type == 'radio') @@ -1140,11 +1137,11 @@ class ExtraFields $out=''; foreach ($param['options'] as $keyopt => $val) { - $out.=''.$val.'
'; + $out.='/>
'; } } elseif ($type == 'chkbxlst') @@ -1286,7 +1283,7 @@ class ExtraFields require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $form = new Form($db); - $out=$form->multiselectarray($keyprefix.'options_'.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); + $out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); } else { print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; @@ -1316,7 +1313,7 @@ class ExtraFields if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique) } } - $out.=''; + $out.=''; } else { @@ -1327,10 +1324,10 @@ class ExtraFields elseif ($type == 'password') { // If prefix is 'search_', field is used as a filter, we use a common text field. - $out=''; + $out=''; } if (!empty($hidden)) { - $out=''; + $out=''; } /* Add comments if ($type == 'date') $out.=' (YYYY-MM-DD)'; @@ -1352,7 +1349,7 @@ class ExtraFields { global $conf,$langs; - $elementtype=$this->attribute_elementtype[$key]; + $elementtype=$this->attribute_elementtype[$key]; // seems not used $label=$this->attribute_label[$key]; $type=$this->attribute_type[$key]; $size=$this->attribute_size[$key]; diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index fa8d3d6dea4..2d8304b7f99 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -67,15 +67,15 @@ $langs->load("modulebuilder"); { console.log("We enter a computed formula"); jQuery("#default_value").val(''); - /* jQuery("#unique, #required, #alwayseditable, #ishidden, #list").removeAttr('checked'); */ - jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', true); - jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").hide(); + /* jQuery("#unique, #required, #alwayseditable, #list").removeAttr('checked'); */ + jQuery("#default_value, #unique, #required, #alwayseditable, #list").attr('disabled', true); + jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").hide(); } else { console.log("No computed formula"); - jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); - jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); + jQuery("#default_value, #unique, #required, #alwayseditable, #list").attr('disabled', false); + jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").show(); } if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } @@ -173,15 +173,11 @@ $langs->load("modulebuilder"); trans("Required"); ?>> trans("AlwaysEditable"); ?>> - -global->MAIN_CAN_HIDE_EXTRAFIELDS)) { ?> -trans("Hidden"); ?>> - multicompany->enabled) { ?> trans("AllEntities"); ?>> - -textwithpicto($langs->trans("ByDefaultInList"), $langs->trans("VisibleDesc")); ?> + +textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index d41302be808..fcd073d77db 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -65,15 +65,15 @@ $langs->load("modulebuilder"); { console.log("We enter a computed formula"); jQuery("#default_value").val(''); - /* jQuery("#unique, #required, #alwayseditable, #ishidden, #list").removeAttr('checked'); */ - jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', true); - jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").hide(); + /* jQuery("#unique, #required, #alwayseditable, #list").removeAttr('checked'); */ + jQuery("#default_value, #unique, #required, #alwayseditable, #list").attr('disabled', true); + jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").hide(); } else { console.log("No computed formula"); - jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); - jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); + jQuery("#default_value, #unique, #required, #alwayseditable, #list").attr('disabled', false); + jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").show(); } if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } @@ -143,7 +143,6 @@ $param=$extrafields->attributes[$elementtype]['param'][$attrname]; $perms=$extrafields->attributes[$elementtype]['perms'][$attrname]; $langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname]; $list=$extrafields->attributes[$elementtype]['list'][$attrname]; -$ishidden=$extrafields->attributes[$elementtype]['hidden'][$attrname]; $entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname]; if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) @@ -232,15 +231,11 @@ else trans("Required"); ?>> trans("AlwaysEditable"); ?>> - -global->MAIN_CAN_HIDE_EXTRAFIELDS)) { ?> - trans("Hidden"); ?>> - multicompany->enabled) { ?> trans("AllEntities"); ?>> - -textwithpicto($langs->trans("ByDefaultInList"), $langs->trans("VisibleDesc")); ?> + +textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 29d57b8463c..e9f880e2696 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -81,7 +81,6 @@ if (count($extrafields->attributes[$elementtype]['type'])) print ''.yn($extrafields->attributes[$elementtype]['required'][$key])."\n"; print ''.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."\n"; print ''.$extrafields->attributes[$elementtype]['list'][$key]."\n"; - if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''.yn($extrafields->attributes[$elementtype]['ishidden'][$key])."\n"; // Add hidden option on not working feature. Why hide if user can't see it. if (! empty($conf->multicompany->enabled)) { print ''.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).''; } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 56eb8652d2b..973308b2e25 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -59,8 +59,7 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][ } else { - if (! empty($extrafields->attributes[$object->table_element]['ishidden'][$key])) print ''; - else print ''; + print ''; print ''; print ''; print 'global->MYMODULE_MYOPTION) -VisibleDesc=Is the field visible into list ? (Examples: 0=Not visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) +VisibleDesc=Is the field visible ? (Examples: 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) IsAMeasureDesc=Can the value of field be cumulated to get a total into list ? (Examples: 1 or 0) SearchAllDesc=Is the field used to make a search from the quick search tool ? (Examples: 1 or 0) SpecDefDesc=Enter here all documentation you want to provide with your module that is not already defined by other tabs. You can use .md or better, the rich .asciidoc syntax. diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 283a7082435..f7a059d54d5 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -99,7 +99,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu /* - * ACTIONS + * Actions * * Put here all code to do according to value of "action" parameter */ @@ -133,7 +133,7 @@ if (empty($reshook)) /* - * VIEW + * View * * Put here all code to build page */ diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 4fff1e385e2..6e15430802a 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -100,9 +100,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu /* - * ACTIONS - * - * Put here all code to do according to value of "action" parameter + * Actions */ $parameters=array(); @@ -132,9 +130,7 @@ if (empty($reshook)) /* - * VIEW - * - * Put here all code to build page + * View */ $form=new Form($db); @@ -188,22 +184,10 @@ if ($action == 'create') print $langs->trans($val['label']); print ''; print ''; print ''; }
'; - $defaultcss='minwidth100'; - if ($val['type'] == 'text') - { - print ''; - } - elseif (is_array($val['arrayofkeyval'])) - { - print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')); - } - else - { - $cssforinput = empty($val['css'])?$defaultcss:$val['css']; - print ''; - } + if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int'); + elseif ($val['type'] == 'text') $value = GETPOST($key, 'none'); + else $value = GETPOST($key, 'alpha'); + print $object->showInputField($val, $key, $value, '', '', '', 0, 0); print '