mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 09:02:59 +01:00
Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into NEW_deposit_payment_terms
This commit is contained in:
@@ -193,12 +193,12 @@ class Form
|
||||
* @param object $object Object
|
||||
* @param boolean $perm Permission to allow button to edit parameter
|
||||
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datepickerhour', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...')
|
||||
* @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of value). Use '' to use same than $value
|
||||
* @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value). Use '' to use same than $value
|
||||
* @param object $extObject External object
|
||||
* @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
|
||||
* @param string $moreparam More param to add on the form action href URL
|
||||
* @param int $notabletag Do no output table tags
|
||||
* @param string $formatfunc Call a specific function to output field
|
||||
* @param string $formatfunc Call a specific function to output field in view mode (For example: 'dol_print_email')
|
||||
* @param string $paramid Key of parameter for id ('id', 'socid')
|
||||
* @return string HTML edit field
|
||||
*/
|
||||
@@ -214,7 +214,7 @@ class Form
|
||||
}
|
||||
|
||||
// When option to edit inline is activated
|
||||
if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) { // TODO add jquery timepicker and support select
|
||||
if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|day|datepicker|dayhour|datehourpicker/', $typeofdata)) { // TODO add jquery timepicker and support select
|
||||
$ret .= $this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
|
||||
} else {
|
||||
$editmode = (GETPOST('action', 'aZ09') == 'edit'.$htmlname);
|
||||
@@ -236,7 +236,7 @@ class Form
|
||||
} elseif (preg_match('/^(numeric|amount)/', $typeofdata)) {
|
||||
$tmp = explode(':', $typeofdata);
|
||||
$valuetoshow = price2num($editvalue ? $editvalue : $value);
|
||||
$ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($valuetoshow != '' ?price($valuetoshow) : '').'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').' autofocus>';
|
||||
$ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($valuetoshow != '' ? price($valuetoshow) : '').'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').' autofocus>';
|
||||
} elseif (preg_match('/^(checkbox)/', $typeofdata)) {
|
||||
$tmp = explode(':', $typeofdata);
|
||||
$ret .= '<input type="checkbox" id="' . $htmlname . '" name="' . $htmlname . '" value="' . $value . '"' . ($tmp[1] ? $tmp[1] : '') . '/>';
|
||||
@@ -1005,6 +1005,7 @@ class Form
|
||||
$langs->load("dict");
|
||||
|
||||
$out = '';
|
||||
$moreattrib = '';
|
||||
$incotermArray = array();
|
||||
|
||||
$sql = "SELECT rowid, code";
|
||||
@@ -1347,7 +1348,7 @@ class Form
|
||||
if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid = s.fk_pays";
|
||||
}
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
|
||||
@@ -1357,7 +1358,7 @@ class Form
|
||||
if ($filter) {
|
||||
$sql .= " AND (".$filter.")";
|
||||
}
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) {
|
||||
@@ -1444,7 +1445,7 @@ class Form
|
||||
$label .= ' ('.$obj->name_alias.')';
|
||||
}
|
||||
|
||||
if ($conf->global->SOCIETE_SHOW_VAT_IN_LIST && !empty($obj->tva_intra)) {
|
||||
if (!empty($conf->global->SOCIETE_SHOW_VAT_IN_LIST) && !empty($obj->tva_intra)) {
|
||||
$label .= ' - '.$obj->tva_intra.'';
|
||||
}
|
||||
|
||||
@@ -2602,7 +2603,7 @@ class Form
|
||||
|
||||
if (!$forcecombo) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
$out .= ajax_combobox($htmlname, $events, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
|
||||
$out .= ajax_combobox($htmlname, $events, getDolGlobalInt("PRODUIT_USE_SEARCH_TO_SELECT"));
|
||||
}
|
||||
|
||||
$out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
|
||||
@@ -4391,6 +4392,7 @@ class Form
|
||||
if (!empty($unit_type)) {
|
||||
$sql .= " AND unit_type = '".$this->db->escape($unit_type)."'";
|
||||
}
|
||||
$sql .= " ORDER BY sortorder";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql && $this->db->num_rows($resql) > 0) {
|
||||
@@ -5207,7 +5209,8 @@ class Form
|
||||
print '<input type="hidden" name="action" value="setavailability">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$this->selectAvailabilityDelay($selected, $htmlname, -1, $addempty);
|
||||
print '<input type="submit" class="button smallpaddingimp" value="'.$langs->trans("Modify").'">';
|
||||
print '<input type="submit" name="modify" class="button smallpaddingimp" value="'.$langs->trans("Modify").'">';
|
||||
print '<input type="submit" name="cancel" class="button smallpaddingimp" value="'.$langs->trans("Cancel").'">';
|
||||
print '</form>';
|
||||
} else {
|
||||
if ($selected) {
|
||||
@@ -6884,6 +6887,418 @@ class Form
|
||||
$optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtypem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of projects in Ajax if Ajax activated or go to selectTicketsList
|
||||
*
|
||||
* @param int $selected Preselected tickets
|
||||
* @param string $htmlname Name of HTML select field (must be unique in page).
|
||||
* @param string $filtertype To add a filter
|
||||
* @param int $limit Limit on number of returned lines
|
||||
* @param int $status Ticket status
|
||||
* @param string $selected_input_value Value of preselected input text (for use with ajax)
|
||||
* @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after)
|
||||
* @param array $ajaxoptions Options for ajax_autocompleter
|
||||
* @param int $socid Thirdparty Id (to get also price dedicated to this customer)
|
||||
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @param string $morecss Add more css on select
|
||||
* @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...])
|
||||
* @param string $nooutput No print, return the output into a string
|
||||
* @return void|string
|
||||
*/
|
||||
public function selectProjects($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 0, $status = 1, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $selected_combinations = null, $nooutput = 0)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$out = '';
|
||||
|
||||
// check parameters
|
||||
if (is_null($ajaxoptions)) $ajaxoptions = array();
|
||||
|
||||
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
|
||||
$placeholder = '';
|
||||
|
||||
if ($selected && empty($selected_input_value)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$projecttmpselect = new Project($this->db);
|
||||
$projecttmpselect->fetch($selected);
|
||||
$selected_input_value = $projecttmpselect->ref;
|
||||
unset($projecttmpselect);
|
||||
}
|
||||
|
||||
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
|
||||
|
||||
if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel").' : ';
|
||||
elseif ($hidelabel > 1) {
|
||||
$placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
|
||||
if ($hidelabel == 2) {
|
||||
$out .= img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
}
|
||||
$out .= '<input type="text" class="minwidth100" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
|
||||
if ($hidelabel == 3) {
|
||||
$out .= img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
} else {
|
||||
$out .= $this->selectProjectsList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
|
||||
}
|
||||
|
||||
if (empty($nooutput)) print $out;
|
||||
else return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of projects.
|
||||
* Called by selectProjects.
|
||||
*
|
||||
* @param int $selected Preselected project
|
||||
* @param string $htmlname Name of select html
|
||||
* @param string $filtertype Filter on project type
|
||||
* @param int $limit Limit on number of returned lines
|
||||
* @param string $filterkey Filter on project ref or subject
|
||||
* @param int $status Ticket status
|
||||
* @param int $outputmode 0=HTML select string, 1=Array
|
||||
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @param string $morecss Add more css on select
|
||||
* @return array Array of keys for json
|
||||
*/
|
||||
public function selectProjectsList($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
|
||||
{
|
||||
global $langs, $conf, $user, $db;
|
||||
|
||||
$out = '';
|
||||
$outarray = array();
|
||||
|
||||
$selectFields = " p.rowid, p.ref";
|
||||
|
||||
$sql = "SELECT ";
|
||||
$sql .= $selectFields;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql .= ' WHERE p.entity IN ('.getEntity('project').')';
|
||||
|
||||
// Add criteria on ref/label
|
||||
if ($filterkey != '') {
|
||||
$sql .= ' AND (';
|
||||
$prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
|
||||
// For natural search
|
||||
$scrit = explode(' ', $filterkey);
|
||||
$i = 0;
|
||||
if (count($scrit) > 1) $sql .= "(";
|
||||
foreach ($scrit as $crit) {
|
||||
if ($i > 0) $sql .= " AND ";
|
||||
$sql .= "p.ref LIKE '".$this->db->escape($prefix.$crit)."%'";
|
||||
$sql .= "";
|
||||
$i++;
|
||||
}
|
||||
if (count($scrit) > 1) $sql .= ")";
|
||||
$sql .= ')';
|
||||
}
|
||||
|
||||
$sql .= $this->db->plimit($limit, 0);
|
||||
|
||||
// Build output string
|
||||
dol_syslog(get_class($this)."::selectProjectsList search projects", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
|
||||
|
||||
$num = $this->db->num_rows($result);
|
||||
|
||||
$events = null;
|
||||
|
||||
if (!$forcecombo) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
$out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
|
||||
}
|
||||
|
||||
$out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
|
||||
|
||||
$textifempty = '';
|
||||
// Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
|
||||
//if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
|
||||
if (!empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
|
||||
if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
|
||||
else $textifempty .= $langs->trans("All");
|
||||
} else {
|
||||
if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
|
||||
}
|
||||
if ($showempty) $out .= '<option value="0" selected>'.$textifempty.'</option>';
|
||||
|
||||
$i = 0;
|
||||
while ($num && $i < $num) {
|
||||
$opt = '';
|
||||
$optJson = array();
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
$this->constructProjectListOption($objp, $opt, $optJson, $selected, $filterkey);
|
||||
// Add new entry
|
||||
// "key" value of json key array is used by jQuery automatically as selected value
|
||||
// "label" value of json key array is used by jQuery automatically as text for combo box
|
||||
$out .= $opt;
|
||||
array_push($outarray, $optJson);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$out .= '</select>';
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
if (empty($outputmode)) return $out;
|
||||
return $outarray;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* constructProjectListOption.
|
||||
* This define value for &$opt and &$optJson.
|
||||
*
|
||||
* @param resource $objp Result set of fetch
|
||||
* @param string $opt Option (var used for returned value in string option format)
|
||||
* @param string $optJson Option (var used for returned value in json format)
|
||||
* @param string $selected Preselected value
|
||||
* @param string $filterkey Filter key to highlight
|
||||
* @return void
|
||||
*/
|
||||
protected function constructProjectListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
|
||||
{
|
||||
global $langs, $conf, $user, $db;
|
||||
|
||||
$outkey = '';
|
||||
$outval = '';
|
||||
$outref = '';
|
||||
$outlabel = '';
|
||||
$outtype = '';
|
||||
|
||||
$label = $objp->label;
|
||||
|
||||
$outkey = $objp->rowid;
|
||||
$outref = $objp->ref;
|
||||
$outlabel = $objp->label;
|
||||
$outtype = $objp->fk_product_type;
|
||||
|
||||
$opt = '<option value="'.$objp->rowid.'"';
|
||||
$opt .= ($objp->rowid == $selected) ? ' selected' : '';
|
||||
$opt .= '>';
|
||||
$opt .= $objp->ref;
|
||||
$objRef = $objp->ref;
|
||||
if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
|
||||
$outval .= $objRef;
|
||||
|
||||
$opt .= "</option>\n";
|
||||
$optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtypem);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return list of members in Ajax if Ajax activated or go to selectTicketsList
|
||||
*
|
||||
* @param int $selected Preselected tickets
|
||||
* @param string $htmlname Name of HTML select field (must be unique in page).
|
||||
* @param string $filtertype To add a filter
|
||||
* @param int $limit Limit on number of returned lines
|
||||
* @param int $status Ticket status
|
||||
* @param string $selected_input_value Value of preselected input text (for use with ajax)
|
||||
* @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after)
|
||||
* @param array $ajaxoptions Options for ajax_autocompleter
|
||||
* @param int $socid Thirdparty Id (to get also price dedicated to this customer)
|
||||
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @param string $morecss Add more css on select
|
||||
* @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...])
|
||||
* @param string $nooutput No print, return the output into a string
|
||||
* @return void|string
|
||||
*/
|
||||
public function selectMembers($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 0, $status = 1, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $selected_combinations = null, $nooutput = 0)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$out = '';
|
||||
|
||||
// check parameters
|
||||
if (is_null($ajaxoptions)) $ajaxoptions = array();
|
||||
|
||||
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
|
||||
$placeholder = '';
|
||||
|
||||
if ($selected && empty($selected_input_value)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
$adherenttmpselect = new Member($this->db);
|
||||
$adherenttmpselect->fetch($selected);
|
||||
$selected_input_value = $adherenttmpselect->ref;
|
||||
unset($adherenttmpselect);
|
||||
}
|
||||
|
||||
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
|
||||
|
||||
if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel").' : ';
|
||||
elseif ($hidelabel > 1) {
|
||||
$placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
|
||||
if ($hidelabel == 2) {
|
||||
$out .= img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
}
|
||||
$out .= '<input type="text" class="minwidth100" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
|
||||
if ($hidelabel == 3) {
|
||||
$out .= img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
} else {
|
||||
$out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
|
||||
}
|
||||
|
||||
if (empty($nooutput)) print $out;
|
||||
else return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of adherents.
|
||||
* Called by selectMembers.
|
||||
*
|
||||
* @param int $selected Preselected adherent
|
||||
* @param string $htmlname Name of select html
|
||||
* @param string $filtertype Filter on adherent type
|
||||
* @param int $limit Limit on number of returned lines
|
||||
* @param string $filterkey Filter on adherent ref or subject
|
||||
* @param int $status Ticket status
|
||||
* @param int $outputmode 0=HTML select string, 1=Array
|
||||
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @param string $morecss Add more css on select
|
||||
* @return array Array of keys for json
|
||||
*/
|
||||
public function selectMembersList($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
|
||||
{
|
||||
global $langs, $conf, $user, $db;
|
||||
|
||||
$out = '';
|
||||
$outarray = array();
|
||||
|
||||
$selectFields = " p.rowid, p.ref";
|
||||
|
||||
$sql = "SELECT ";
|
||||
$sql .= $selectFields;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as p";
|
||||
$sql .= ' WHERE p.entity IN ('.getEntity('adherent').')';
|
||||
|
||||
// Add criteria on ref/label
|
||||
if ($filterkey != '') {
|
||||
$sql .= ' AND (';
|
||||
$prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
|
||||
// For natural search
|
||||
$scrit = explode(' ', $filterkey);
|
||||
$i = 0;
|
||||
if (count($scrit) > 1) $sql .= "(";
|
||||
foreach ($scrit as $crit) {
|
||||
if ($i > 0) $sql .= " AND ";
|
||||
$sql .= "p.ref LIKE '".$this->db->escape($prefix.$crit)."%'";
|
||||
$sql .= "";
|
||||
$i++;
|
||||
}
|
||||
if (count($scrit) > 1) $sql .= ")";
|
||||
$sql .= ')';
|
||||
}
|
||||
|
||||
$sql .= $this->db->plimit($limit, 0);
|
||||
|
||||
// Build output string
|
||||
dol_syslog(get_class($this)."::selectMembersList search adherents", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
|
||||
|
||||
$num = $this->db->num_rows($result);
|
||||
|
||||
$events = null;
|
||||
|
||||
if (!$forcecombo) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
$out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
|
||||
}
|
||||
|
||||
$out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
|
||||
|
||||
$textifempty = '';
|
||||
// Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
|
||||
//if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
|
||||
if (!empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
|
||||
if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
|
||||
else $textifempty .= $langs->trans("All");
|
||||
} else {
|
||||
if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
|
||||
}
|
||||
if ($showempty) $out .= '<option value="0" selected>'.$textifempty.'</option>';
|
||||
|
||||
$i = 0;
|
||||
while ($num && $i < $num) {
|
||||
$opt = '';
|
||||
$optJson = array();
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
$this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
|
||||
// Add new entry
|
||||
// "key" value of json key array is used by jQuery automatically as selected value
|
||||
// "label" value of json key array is used by jQuery automatically as text for combo box
|
||||
$out .= $opt;
|
||||
array_push($outarray, $optJson);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$out .= '</select>';
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
if (empty($outputmode)) return $out;
|
||||
return $outarray;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* constructMemberListOption.
|
||||
* This define value for &$opt and &$optJson.
|
||||
*
|
||||
* @param resource $objp Result set of fetch
|
||||
* @param string $opt Option (var used for returned value in string option format)
|
||||
* @param string $optJson Option (var used for returned value in json format)
|
||||
* @param string $selected Preselected value
|
||||
* @param string $filterkey Filter key to highlight
|
||||
* @return void
|
||||
*/
|
||||
protected function constructMemberListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
|
||||
{
|
||||
global $langs, $conf, $user, $db;
|
||||
|
||||
$outkey = '';
|
||||
$outval = '';
|
||||
$outref = '';
|
||||
$outlabel = '';
|
||||
$outtype = '';
|
||||
|
||||
$label = $objp->label;
|
||||
|
||||
$outkey = $objp->rowid;
|
||||
$outref = $objp->ref;
|
||||
$outlabel = $objp->label;
|
||||
$outtype = $objp->fk_product_type;
|
||||
|
||||
$opt = '<option value="'.$objp->rowid.'"';
|
||||
$opt .= ($objp->rowid == $selected) ? ' selected' : '';
|
||||
$opt .= '>';
|
||||
$opt .= $objp->ref;
|
||||
$objRef = $objp->ref;
|
||||
if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
|
||||
$outval .= $objRef;
|
||||
|
||||
$opt .= "</option>\n";
|
||||
$optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtypem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to select a component from a combo list.
|
||||
@@ -7075,7 +7490,7 @@ class Form
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttable ON parenttable.rowid = t.".$tmparray[0];
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') {
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
}
|
||||
@@ -7103,7 +7518,7 @@ class Form
|
||||
}
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') {
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
$sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
}
|
||||
@@ -7722,7 +8137,7 @@ class Form
|
||||
}
|
||||
} else { // There is no list of fields already customized for user
|
||||
foreach ($array as $key => $val) {
|
||||
if ($array[$key]['checked'] < 0) {
|
||||
if (!empty($array[$key]['checked']) && $array[$key]['checked'] < 0) {
|
||||
$array[$key]['checked'] = 0;
|
||||
}
|
||||
}
|
||||
@@ -7750,7 +8165,7 @@ class Form
|
||||
}
|
||||
|
||||
// Note: $val['checked'] <> 0 means we must show the field into the combo list
|
||||
$listoffieldsforselection .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.((empty($val['checked']) && $val['checked'] != '-1') ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>';
|
||||
$listoffieldsforselection .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.((empty($val['checked']) || $val['checked'] == '-1') ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>';
|
||||
$listcheckedstring .= (empty($val['checked']) ? '' : $key.',');
|
||||
}
|
||||
}
|
||||
@@ -8312,7 +8727,7 @@ class Form
|
||||
*/
|
||||
public function showrefnav($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $morehtmlright = '')
|
||||
{
|
||||
global $langs, $conf, $hookmanager, $extralanguages;
|
||||
global $conf, $langs, $hookmanager, $extralanguages;
|
||||
|
||||
$ret = '';
|
||||
if (empty($fieldid)) {
|
||||
@@ -8324,7 +8739,7 @@ class Form
|
||||
|
||||
// Preparing gender's display if there is one
|
||||
$addgendertxt = '';
|
||||
if (!empty($object->gender)) {
|
||||
if (property_exists($object, 'gender') && !empty($object->gender)) {
|
||||
$addgendertxt = ' ';
|
||||
switch ($object->gender) {
|
||||
case 'man':
|
||||
@@ -8338,6 +8753,15 @@ class Form
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
$addadmin = '';
|
||||
if (property_exists($object, 'admin')) {
|
||||
if (!empty($conf->multicompany->enabled) && !empty($object->admin) && empty($object->entity)) {
|
||||
$addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
|
||||
} elseif (!empty($object->admin)) {
|
||||
$addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
|
||||
}
|
||||
}*/
|
||||
|
||||
// Add where from hooks
|
||||
if (is_object($hookmanager)) {
|
||||
@@ -8470,7 +8894,7 @@ class Form
|
||||
$ret .= dol_htmlentities($fullname).$addgendertxt.((!empty($object->societe) && $object->societe != $fullname) ? ' ('.dol_htmlentities($object->societe).')' : '');
|
||||
}
|
||||
} elseif (in_array($object->element, array('contact', 'user', 'usergroup'))) {
|
||||
$ret .= dol_htmlentities($object->getFullName($langs)).$addgendertxt;
|
||||
$ret .= dol_htmlentities($object->getFullName($langs));
|
||||
} elseif (in_array($object->element, array('action', 'agenda'))) {
|
||||
$ret .= $object->ref.'<br>'.$object->label;
|
||||
} elseif (in_array($object->element, array('adherent_type'))) {
|
||||
@@ -8718,7 +9142,7 @@ class Form
|
||||
}
|
||||
$ret .= '<table class="nobordernopadding centpercent">';
|
||||
if ($object->photo) {
|
||||
$ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||
$ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">'.$langs->trans("Delete").'</label><br><br></td></tr>';
|
||||
}
|
||||
$ret .= '<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"'.($capture ? ' capture="'.$capture.'"' : '').'></td></tr>';
|
||||
$ret .= '</table>';
|
||||
@@ -9355,11 +9779,12 @@ class Form
|
||||
*
|
||||
* @param string $save_label Alternative label for save button
|
||||
* @param string $cancel_label Alternative label for cancel button
|
||||
* @param array $morefields Add additional buttons between save and cancel
|
||||
* @param array $morebuttons Add additional buttons between save and cancel
|
||||
* @param bool $withoutdiv Option to remove enclosing centered div
|
||||
* @param string $morecss More CSS
|
||||
* @return string Html code with the buttons
|
||||
*/
|
||||
public function buttonsSaveCancel($save_label = 'Save', $cancel_label = 'Cancel', $morefields = array(), $withoutdiv = 0)
|
||||
public function buttonsSaveCancel($save_label = 'Save', $cancel_label = 'Cancel', $morebuttons = array(), $withoutdiv = 0, $morecss = '')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@@ -9383,8 +9808,8 @@ class Form
|
||||
|
||||
!empty($save_label) ? $buttons[] = $save : '';
|
||||
|
||||
if (!empty($morefields)) {
|
||||
$buttons[] = $morefields;
|
||||
if (!empty($morebuttons)) {
|
||||
$buttons[] = $morebuttons;
|
||||
}
|
||||
|
||||
!empty($cancel_label) ? $buttons[] = $cancel : '';
|
||||
@@ -9393,7 +9818,7 @@ class Form
|
||||
|
||||
foreach ($buttons as $button) {
|
||||
$addclass = empty($button['addclass']) ? '' : $button['addclass'];
|
||||
$retstring .= '<input type="submit" class="button button-'.$button['name'].' '.$addclass.'" name="'.$button['name'].'" value="'.dol_escape_htmltag($langs->trans($button['label_key'])).'">';
|
||||
$retstring .= '<input type="submit" class="button button-'.$button['name'].($morecss ? ' '.$morecss : '').' '.$addclass.'" name="'.$button['name'].'" value="'.dol_escape_htmltag($langs->trans($button['label_key'])).'">';
|
||||
}
|
||||
$retstring .= $withoutdiv ? '': '</div>';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user