From 202712be9449d018090090f8f070263e1ae31034 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Oct 2017 22:02:07 +0200 Subject: [PATCH] Work on module builder --- .../class/accountingjournal.class.php | 2 +- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/bookmarks/class/bookmark.class.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- .../deplacement/class/deplacement.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contact/class/contact.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/core/ajax/selectobject.php | 86 +++++++ htdocs/core/class/commonobject.class.php | 51 +--- htdocs/core/class/dolgraph.class.php | 8 +- .../core/class/emailsenderprofile.class.php | 2 +- htdocs/core/class/fiscalyear.class.php | 2 +- htdocs/core/class/html.form.class.php | 226 ++++++++++++++++-- htdocs/core/lib/ajax.lib.php | 4 +- htdocs/core/lib/functions.lib.php | 166 +++++++------ htdocs/don/class/don.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 2 +- .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/holiday/class/holiday.class.php | 2 +- htdocs/hrm/class/establishment.class.php | 2 +- .../template/class/myobject.class.php | 33 +-- htdocs/product/class/product.class.php | 2 +- .../inventory/class/inventory.class.php | 2 +- htdocs/projet/class/project.class.php | 2 +- htdocs/societe/ajax/company.php | 2 - htdocs/societe/class/societe.class.php | 30 ++- .../class/supplier_proposal.class.php | 2 +- htdocs/theme/eldy/style.css.php | 3 + htdocs/theme/md/style.css.php | 3 + htdocs/user/class/user.class.php | 2 +- htdocs/user/class/usergroup.class.php | 2 +- htdocs/website/class/websiteaccount.class.php | 4 +- 36 files changed, 480 insertions(+), 184 deletions(-) create mode 100644 htdocs/core/ajax/selectobject.php diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index cb72c321118..41cce96995f 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -29,7 +29,7 @@ class AccountingJournal extends CommonObject public $element='accounting_journal'; public $table_element='accounting_journal'; public $fk_element = ''; - protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe var $rowid; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 33be4abb8e6..81167eebc5e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -43,7 +43,7 @@ class Adherent extends CommonObject { public $element='member'; public $table_element='adherent'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe var $mesgs; diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index b72089e61b8..1beb4b36871 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -30,7 +30,7 @@ class Bookmark extends CommonObject { public $element='bookmark'; public $table_element='bookmark'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'bookmark'; var $db; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 36d551ea577..a89608654fd 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -36,7 +36,7 @@ class ActionComm extends CommonObject public $element='action'; public $table_element = 'actioncomm'; public $table_rowid = 'id'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='action'; /** diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 19e70235e9e..6827a3b0a4e 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -48,7 +48,7 @@ class Propal extends CommonObject public $table_element='propal'; public $table_element_line='propaldet'; public $fk_element='fk_propal'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='propal'; /** diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e475615a3d1..00032262c70 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -46,7 +46,7 @@ class Commande extends CommonOrder public $table_element_line = 'commandedet'; public $class_element_line = 'OrderLine'; public $fk_element = 'fk_commande'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'order'; /** diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index c0a4ef94613..c67fce127c2 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -35,7 +35,7 @@ class Deplacement extends CommonObject public $table_element='deplacement'; public $table_element_line = ''; public $fk_element = ''; - protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe var $datec; // Creation date var $dated; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a1997318aad..0104bfd903e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -52,7 +52,7 @@ class Facture extends CommonInvoice public $table_element='facture'; public $table_element_line = 'facturedet'; public $fk_element = 'fk_facture'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='bill'; /** diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 7e9437f5442..8dba39b4b54 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -39,7 +39,7 @@ class Contact extends CommonObject { public $element='contact'; public $table_element='socpeople'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $civility_id; // In fact we store civility_code public $civility_code; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 5ff8dd182bb..86c85b19d0a 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -44,7 +44,7 @@ class Contrat extends CommonObject public $table_element='contrat'; public $table_element_line='contratdet'; public $fk_element='fk_contrat'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='contract'; /** diff --git a/htdocs/core/ajax/selectobject.php b/htdocs/core/ajax/selectobject.php new file mode 100644 index 00000000000..0c52c490512 --- /dev/null +++ b/htdocs/core/ajax/selectobject.php @@ -0,0 +1,86 @@ + + * + * 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/core/ajax/selectobject.php + * \brief File to return Ajax response on a selection list request + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); + +require '../../main.inc.php'; + +$objectdesc=GETPOST('objectdesc', 'alpha'); +$htmlname=GETPOST('htmlname', 'aZ09'); +$sqlfilter=GETPOST('sqlfilter', 'alpha'); +$outjson=(GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); +$action=GETPOST('action', 'alpha'); +$id=GETPOST('id', 'int'); + + +/* + * View + */ + +//print ''."\n"; + +dol_syslog(join(',', $_GET)); +//print_r($_GET); + + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +$form = new Form($db); + +//$langs->load("companies"); + +top_httphead(); + +if (empty($htmlname)) return; + + +$InfoFieldList = explode(":", $objectdesc); +$classname=$InfoFieldList[0]; +$classpath=$InfoFieldList[1]; +if (! empty($classpath)) +{ + dol_include_once($classpath); + if ($classname && class_exists($classname)) + { + $objecttmp = new $classname($db); + } +} +if (! is_object($objecttmp)) +{ + dol_syslog('Error bad param objectdesc', LOG_WARNING); + print 'Error bad param objectdesc'; +} + +// When used from jQuery, the search term is added as GET param "term". +$searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):'')); + +// TODO Add a security test to avoid to get content of all tables + +$arrayresult=$form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1); + +$db->close(); + +if ($outjson) print json_encode($arrayresult); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fb42e1bfbde..2c637872e8d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4668,7 +4668,13 @@ abstract class CommonObject */ function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0, $objectid=0) { - global $conf,$langs; + global $conf,$langs,$form; + + if (! is_object($form)) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $form=new Form($this->db); + } $label=$val['label']; $type =$val['type']; @@ -4696,7 +4702,6 @@ abstract class CommonObject $hidden=(abs($val['visible'])!=1 ? 1 : 0); $help=$val['help']; - if ($computed) { if (! preg_match('/^search_/', $keyprefix)) return ''.$langs->trans("AutomaticallyCalculated").''; @@ -4756,10 +4761,6 @@ abstract class CommonObject // 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); } @@ -4817,7 +4818,7 @@ abstract class CommonObject } $out.=''; - } - else - { - dol_syslog('Error bad setup of type for field '.$InfoFieldList, LOG_WARNING); - $out.='Error bad setup of type for field '.join(',', $InfoFieldList); - } + $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' + $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, (($val['notnull'] == 1)?0:1)); } elseif ($type == 'password') { diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index d603d1b6cc1..f2885a50951 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -81,14 +81,16 @@ class DolGraph /** * Constructor + * + * @param string $library 'jflot' (default) or 'artichow' (no more supported) */ - function __construct() + function __construct($library='jflot') { global $conf; global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet; // To use old feature - if (isset($conf->global->MAIN_GRAPH_LIBRARY) && $conf->global->MAIN_GRAPH_LIBRARY == 'artichow') + if ($library == 'artichow') { $this->_library='artichow'; @@ -586,7 +588,7 @@ class DolGraph } /** - * Build a graph onto disk using correct library + * Build a graph into memory using correct library (may also be wrote on disk, depending on library used) * * @param string $file Image file name to use to save onto disk (also used as javascript unique id) * @param string $fileurl Url path to show image if saved onto disk diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index e792a4c3f0a..7f34165030b 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -46,7 +46,7 @@ class EmailSenderProfile extends CommonObject /** * @var array Does emailsenderprofile support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ - protected $ismultientitymanaged = 1; + public $ismultientitymanaged = 1; /** * @var string String with name of icon for emailsenderprofile */ diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 38804442033..5e5ff6e3ce8 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -32,7 +32,7 @@ class Fiscalyear extends CommonObject public $table_element='accounting_fiscalyear'; public $table_element_line = ''; public $fk_element = ''; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe var $rowid; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9902efd03e5..341a05159cf 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -727,7 +727,7 @@ class Form * @param string $page Defined the form action * @param string $htmlname Name of html select object * @param string $htmloption Options html on select object - * @param int $forcecombo Force to use standard combo box (no ajax use) + * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) * @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return string HTML string with select and input */ @@ -959,7 +959,7 @@ class Form * @param int $filter Filter on thirdparty * @param int $limit Limit on number of returned lines * @param array $ajaxoptions Options for ajax_autocompleter - * @param int $forcecombo Force to use combo box + * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) * @return string Return select box for thirdparty. * @deprecated 3.8 Use select_company instead. For exemple $form->select_thirdparty(GETPOST('socid'),'socid','',0) => $form->select_company(GETPOST('socid'),'socid','',1,0,0,array(),0) */ @@ -976,7 +976,7 @@ class Form * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)') * @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty') * @param int $showtype Show third party type in combolist (customer, prospect or supplier) - * @param int $forcecombo Force to use combo box + * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param int $limit Maximum number of elements * @param string $morecss Add more css styles to the SELECT component @@ -1007,11 +1007,7 @@ class Form // mode 1 $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter.($showtype?'&showtype='.$showtype:''); $out.= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); - $out.=''; + $out.=''; if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : '; else if ($hidelabel > 1) { if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("RefOrLabel").'"'; @@ -1020,7 +1016,7 @@ class Form $out.= img_picto($langs->trans("Search"), 'search'); } } - $out.= 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + $out.= 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; if ($hidelabel == 3) { $out.= img_picto($langs->trans("Search"), 'search'); } @@ -1043,7 +1039,7 @@ class Form * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client in (1,3)') * @param string $showempty Add an empty field (Can be '1' or text to use on empty line like 'SelectThirdParty') * @param int $showtype Show third party type in combolist (customer, prospect or supplier) - * @param int $forcecombo Force to use combo box + * @param int $forcecombo Force to use standard HTML select component without beautification * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param string $filterkey Filter on key value * @param int $outputmode 0=HTML select string, 1=Array @@ -1152,17 +1148,23 @@ class Form if ($obj->fournisseur) $label.=($obj->client?', ':'').$langs->trans("Supplier"); if ($obj->client || $obj->fournisseur) $label.=')'; } - if ($selected > 0 && $selected == $obj->rowid) + + if (empty($outputmode)) { - $out.= ''; + if ($selected > 0 && $selected == $obj->rowid) + { + $out.= ''; + } + else + { + $out.= ''; + } } else { - $out.= ''; + array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label)); } - array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label)); - $i++; if (($i % 10) == 0) $out.="\n"; } @@ -5121,6 +5123,200 @@ class Form } + /** + * Generic method to select a component from a combo list. + * This is the generic method that will replace all specific existing methods. + * + * @param string $objectdesc Objectclassname:Objectclasspath + * @param string $htmlname Name of HTML select component + * @param int $preselectedvalue Preselected value (ID of element) + * @param string $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) + * @param string $searchkey Search criteria + * @param string $placeholder Place holder + * @param string $morecss More CSS + * @param string $moreparams More params provided to ajax call + * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) + * @return string Return HTML string + * @see selectForFormsList select_thirdparty + */ + function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty='', $searchkey='', $placeholder='', $morecss='', $moreparams='', $forcecombo=0) + { + global $conf, $user; + + $objecttmp = null; + + $InfoFieldList = explode(":", $objectdesc); + $classname=$InfoFieldList[0]; + $classpath=$InfoFieldList[1]; + if (! empty($classpath)) + { + dol_include_once($classpath); + if ($classname && class_exists($classname)) + { + $objecttmp = new $classname($db); + } + } + if (! is_object($objecttmp)) + { + dol_syslog('Error bad setup of type for field '.$InfoFieldList, LOG_WARNING); + return 'Error bad setup of type for field '.join(',', $InfoFieldList); + } + + $prefixforautocompletemode=$objecttmp->element; + if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode='company'; + $confkeyforautocompletemode=strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT + + dol_syslog(get_class($this)."::selectForForms", LOG_DEBUG); + + $out=''; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->$confkeyforautocompletemode) && ! $forcecombo) + { + $objectdesc=$classname.':'.$classpath; + + // No immediate load of all database + $urloption='htmlname='.$htmlname.'&outjson=1&objectdesc='.$objectdesc.($moreparams?$moreparams:''); + // Activate the auto complete using ajax call. + $out.= ajax_autocompleter($preselectedvalue, $htmlname, DOL_URL_ROOT.'/core/ajax/selectobject.php', $urloption, $conf->global->$confkeyforautocompletemode, 0, array()); + $out.= ''; + if ($placeholder) $placeholder=' placeholder="'.$placeholder.'"'; + $out.= ''; + } + else + { + // Immediate load of all database + $out.=$this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo); + } + + return $out; + } + + /** + * Output html form to select an object. + * Note, this function is called by selectForForms or by ajax selectobject.php + * + * @param Object $objecttmp Object + * @param string $htmlname Name of HTML select component + * @param int $preselectedvalue Preselected value (ID of element) + * @param string $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) + * @param string $searchkey Search value + * @param string $placeholder Place holder + * @param string $morecss More CSS + * @param string $moreparams More params provided to ajax call + * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) + * @param int $outputmode 0=HTML select string, 1=Array + * @return string Return HTML string + * @see selectForForms + */ + function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty='', $searchkey='', $placeholder='', $morecss='', $moreparams='', $forcecombo=0, $outputmode=0) + { + global $conf, $langs, $user; + + $prefixforautocompletemode=$objecttmp->element; + if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode='company'; + $confkeyforautocompletemode=strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT + + $fieldstoshow='t.ref'; + if (! empty($objecttmp->fields)) + { + $tmpfieldstoshow=''; + foreach($objecttmp->fields as $key => $val) + { + if ($val['showoncombobox']) $tmpfieldstoshow.=($tmpfieldstoshow?',':'').'t.'.$key; + } + if ($tmpfieldstoshow) $fieldstoshow = $tmpfieldstoshow; + } + + $out=''; + $outarray=array(); + + $num=0; + + // Search data + $sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX .$objecttmp->table_element." as t"; + if ($objecttmp->ismultientitymanaged == 2) + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE t.entity IN (".getEntity($objecttmp->table_element).")"; + if ($objecttmp->ismultientitymanaged == 1 && ! empty($user->societe_id)) $sql.= " AND t.fk_soc = ".$user->societe_id; + if ($searchkey != '') $sql.=natural_search(explode(',',$fieldstoshow), $searchkey); + if ($objecttmp->ismultientitymanaged == 2) + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND t.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.=$this->db->order($fieldstoshow,"ASC"); + //$sql.=$this->db->plimit($limit, 0); + + // Build output string + $resql=$this->db->query($sql); + if ($resql) + { + if ($conf->use_javascript_ajax && ! $forcecombo) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $comboenhancement =ajax_combobox($htmlname, null, $conf->global->$confkeyforautocompletemode); + $out.= $comboenhancement; + } + + // Construct $out and $outarray + $out.= ''."\n"; + } + else + { + dol_print_error($this->db); + } + + $this->result=array('nbofelement'=>$num); + + if ($outputmode) return $outarray; + return $out; + } + + /** * Return a HTML select string, built from an array of key+value. * Note: Do not apply langs->trans function on returned content, content may be entity encoded twice. diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 0ee1ea98a5b..5410e973aac 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -27,9 +27,9 @@ /** * Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: /societe/ajaxcompanies.php). * The HTML field must be an input text with id=search_$htmlname. - * This use the jQuery "autocomplete" function. + * This use the jQuery "autocomplete" function. If we want to use the select2, we must also convert the input into select on funcntions that call this method. * - * @param string $selected Preselecte value + * @param string $selected Preselected value * @param string $htmlname HTML name of input field * @param string $url Url for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list) * @param string $urloption More parameters on URL request diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1a5b8e4b6a9..0b08e230c3a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -321,56 +321,27 @@ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=N } } // Else, retreive default values if we are not doing a sort - elseif (! isset($_GET['sortfield']) && ! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set + elseif (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set { if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) { - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' + // Search default value from $object->field + global $object; + if (is_object($object) && isset($object->fields[$paramname]['default'])) { - if (isset($user->default_values[$relativepathstring]['createform'])) - { - foreach($user->default_values[$relativepathstring]['createform'] as $defkey => $defval) - { - $qualified = 0; - if ($defkey != '_noquery_') - { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) - { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; - } - if (! $foundintru) $qualified=1; - //var_dump($defkey.'-'.$qualified); - } - else $qualified = 1; - - if ($qualified) - { - //var_dump($user->default_values[$relativepathstring][$defkey]['createform']); - if (isset($user->default_values[$relativepathstring]['createform'][$defkey][$paramname])) - { - $out = $user->default_values[$relativepathstring]['createform'][$defkey][$paramname]; - break; - } - } - } - } + $out = $object->fields[$paramname]['default']; } } - // Management of default search_filters and sort order - //elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) - elseif (! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' + if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) { - //var_dump($user->default_values[$relativepathstring]); - if ($paramname == 'sortfield' || $paramname == 'sortorder') // Sorted on which fields ? ASC or DESC ? + // Now search in setup to overwrite default values + if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' { - if (isset($user->default_values[$relativepathstring]['sortorder'])) // Even if paramname is sortfield, data are stored into ['sortorder...'] + if (isset($user->default_values[$relativepathstring]['createform'])) { - foreach($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) + foreach($user->default_values[$relativepathstring]['createform'] as $defkey => $defval) { $qualified = 0; if ($defkey != '_noquery_') @@ -389,67 +360,108 @@ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=N if ($qualified) { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , - foreach($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) + //var_dump($user->default_values[$relativepathstring][$defkey]['createform']); + if (isset($user->default_values[$relativepathstring]['createform'][$defkey][$paramname])) { - if ($out) $out.=', '; - if ($paramname == 'sortfield') - { - $out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace); - } - if ($paramname == 'sortorder') - { - $out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace); - } + $out = $user->default_values[$relativepathstring]['createform'][$defkey][$paramname]; + break; } - //break; // No break for sortfield and sortorder so we can cumulate fields (is it realy usefull ?) } } } } - elseif (isset($user->default_values[$relativepathstring]['filters'])) + } + // Management of default search_filters and sort order + //elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + elseif (! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' { - foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) + //var_dump($user->default_values[$relativepathstring]); + if ($paramname == 'sortfield' || $paramname == 'sortorder') // Sorted on which fields ? ASC or DESC ? { - $qualified = 0; - if ($defkey != '_noquery_') + if (isset($user->default_values[$relativepathstring]['sortorder'])) // Even if paramname is sortfield, data are stored into ['sortorder...'] { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) + foreach($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; - } - if (! $foundintru) $qualified=1; - //var_dump($defkey.'-'.$qualified); - } - else $qualified = 1; + $qualified = 0; + if ($defkey != '_noquery_') + { + $tmpqueryarraytohave=explode('&', $defkey); + $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru=0; + foreach($tmpqueryarraytohave as $tmpquerytohave) + { + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + } + if (! $foundintru) $qualified=1; + //var_dump($defkey.'-'.$qualified); + } + else $qualified = 1; - if ($qualified) + if ($qualified) + { + $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , + foreach($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) + { + if ($out) $out.=', '; + if ($paramname == 'sortfield') + { + $out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace); + } + if ($paramname == 'sortorder') + { + $out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace); + } + } + //break; // No break for sortfield and sortorder so we can cumulate fields (is it realy usefull ?) + } + } + } + } + elseif (isset($user->default_values[$relativepathstring]['filters'])) + { + foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) { - if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) + $qualified = 0; + if ($defkey != '_noquery_') { - // We made a search from quick search menu, do we still use default filter ? - if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) + $tmpqueryarraytohave=explode('&', $defkey); + $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru=0; + foreach($tmpqueryarraytohave as $tmpquerytohave) + { + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + } + if (! $foundintru) $qualified=1; + //var_dump($defkey.'-'.$qualified); + } + else $qualified = 1; + + if ($qualified) + { + if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) + { + // We made a search from quick search menu, do we still use default filter ? + if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) + { + $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , + $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); + } + } + else { $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); } + break; } - else - { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , - $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); - } - break; } } } } } } - } // Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable paramaters) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 0a683fea355..6bd44d7f385 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -37,7 +37,7 @@ class Don extends CommonObject public $element='don'; // Id that identify managed objects public $table_element='don'; // Name of table without prefix where object is stored public $fk_element = 'fk_donation'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe var $picto = 'generic'; var $date; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 32e11c871e9..995805116b6 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -47,7 +47,7 @@ class Expedition extends CommonObject public $fk_element="fk_expedition"; public $table_element="expedition"; public $table_element_line="expeditiondet"; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'sending'; var $socid; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5ece6d204dc..e3e29e83335 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -43,7 +43,7 @@ class CommandeFournisseur extends CommonOrder public $table_element='commande_fournisseur'; public $table_element_line = 'commande_fournisseurdet'; public $fk_element = 'fk_commande'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='order'; /** diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8bc3b2102f0..c0439ecf3ff 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -44,7 +44,7 @@ class FactureFournisseur extends CommonInvoice public $table_element='facture_fourn'; public $table_element_line='facture_fourn_det'; public $fk_element='fk_facture_fourn'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='bill'; /** diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 8fe8a14430a..c1d43722271 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -34,7 +34,7 @@ class Holiday extends CommonObject { public $element='holiday'; public $table_element='holiday'; - protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'holiday'; /** diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 413cb0cb584..8a99788d040 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -32,7 +32,7 @@ class Establishment extends CommonObject public $table_element='establishment'; public $table_element_line = ''; public $fk_element = 'fk_establishment'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='building'; public $id; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 66037ae8722..987b599ee31 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -43,11 +43,10 @@ class MyObject extends CommonObject * @var string Name of table without prefix where object is stored */ public $table_element = 'myobject'; - /** * @var array Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ - protected $ismultientitymanaged = 0; + public $ismultientitymanaged = 0; /** * @var string String with name of icon for myobject */ @@ -55,18 +54,20 @@ class MyObject extends CommonObject /** - * 'type' if the field format. - * 'label' the translation key. - * '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_...). - * 'position' is the sort order of field. - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. - * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'help' is a string visible as a tooltip on field - * 'comment' is not used. You can store here any text of your choice. + * 'type' if the field format. + * 'label' the translation key. + * '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_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'showoncombobox' if field must be shown into the label of combobox */ // BEGIN MODULEBUILDER PROPERTIES @@ -75,7 +76,7 @@ class MyObject extends CommonObject */ public $fields=array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), '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'), @@ -89,7 +90,7 @@ class MyObject extends CommonObject 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>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')), + 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), ); public $rowid; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 311c05858a3..c39b6902edf 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -47,7 +47,7 @@ class Product extends CommonObject public $table_element='product'; public $fk_element='fk_product'; protected $childtables=array('supplier_proposaldet', 'propaldet','commandedet','facturedet','contratdet','facture_fourn_det','commande_fournisseurdet'); // To test if we can delete object - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** * {@inheritdoc} diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 63790b7789c..9b48c5164d4 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -47,7 +47,7 @@ class Inventory extends CommonObject /** * @var array Does inventory support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ - protected $ismultientitymanaged = 1; + public $ismultientitymanaged = 1; /** * @var string String with name of icon for inventory */ diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 4ade2a31f41..3977cc5ed27 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -37,7 +37,7 @@ class Project extends CommonObject public $table_element = 'projet'; //!< Name of table without prefix where object is stored public $table_element_line = 'projet_task'; public $fk_element = 'fk_projet'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'projectpub'; /** diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 93af8509e32..349e19b0c26 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -28,7 +28,6 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); require '../../main.inc.php'; @@ -74,7 +73,6 @@ else require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $langs->load("companies"); - $langs->load("main"); top_httphead(); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 65b1e19c537..e238fe1ae75 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -43,15 +43,37 @@ class Societe extends CommonObject public $element='societe'; public $table_element = 'societe'; public $fk_element='fk_soc'; + public $fieldsforcombobox='nom,name_alias'; protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); - /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int */ - protected $ismultientitymanaged = 1; + public $ismultientitymanaged = 1; + + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @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'), + 'nom' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'note_public' =>array('type'=>'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), + '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'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), + ); + public $entity; @@ -368,6 +390,10 @@ class Societe extends CommonObject var $fk_multicurrency; var $multicurrency_code; + + // END MODULEBUILDER PROPERTIES + + /** * To contains a clone of this when we need to save old properties of object * @var Societe diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index a1d45d2d0c1..80b28dae333 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -48,7 +48,7 @@ class SupplierProposal extends CommonObject public $table_element='supplier_proposal'; public $table_element_line='supplier_proposaldet'; public $fk_element='fk_supplier_proposal'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='propal'; /** diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index d7cd32fb352..02f2eb0a4ad 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4178,6 +4178,9 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +.select2-container--default .select2-selection--single .select2-selection__rendered { + color: unset; +} .select2-default { color: #999 !important; /*opacity: 0.2;*/ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ffc6cc1a2c6..b94bdcf501e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4198,6 +4198,9 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +.select2-container--default .select2-selection--single .select2-selection__rendered { + color: unset; +} .select2-container .select2-choice { border-bottom: 1px solid #ccc; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 3a7894c050b..0a4d5f0ea1d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -40,7 +40,7 @@ class User extends CommonObject { public $element='user'; public $table_element='user'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $id=0; public $ldap_sid; diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index d0a82972325..7c326097669 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -36,7 +36,7 @@ class UserGroup extends CommonObject { public $element='usergroup'; public $table_element='usergroup'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='group'; public $entity; // Entity of group diff --git a/htdocs/website/class/websiteaccount.class.php b/htdocs/website/class/websiteaccount.class.php index 52187724fc9..fbbb0d987e5 100644 --- a/htdocs/website/class/websiteaccount.class.php +++ b/htdocs/website/class/websiteaccount.class.php @@ -47,7 +47,7 @@ class WebsiteAccount extends CommonObject /** * @var array Does websiteaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ - protected $ismultientitymanaged = 0; + public $ismultientitymanaged = 0; /** * @var string String with name of icon for websiteaccount @@ -88,7 +88,7 @@ class WebsiteAccount extends CommonObject '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')), + '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:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1,), ); public $rowid;