* Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Marc Barilley/Ocebo * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2019 Thibault FOUCART * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 MDW * * 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/class/html.formother.class.php * \ingroup core * \brief Fichier de la class des functions predefinie de composants html autre */ /** * Class permettant la generation de composants html autre * Only common components are here. */ class FormOther { private $db; /** * @var string Error code (or message) */ public $error; /** * Constructor * * @param DoliDB $db Database handler */ public function __construct($db) { $this->db = $db; } /** * Return the HTML code for scanner tool. * This must be called into an existing
* * @param string $jstoexecuteonadd Name of javascript function to call once the barcode scanning session is complete and user has click on "Add". * @param string $mode 'all' (both product and lot barcode) or 'product' (product barcode only) or 'lot' (lot number only) * @param int $warehouseselect 0 (disable warehouse select) or 1 (enable warehouse select) * @return string HTML component */ public function getHTMLScannerForm($jstoexecuteonadd = 'barcodescannerjs', $mode = 'all', $warehouseselect = 0) { global $langs; $out = ''; $out .= ''."\n"; $out .= '
'; $out .= '
'.img_picto('', 'barcode', 'class="pictofixedwidth"').'Barcode scanner tool...

'; if ($mode == 'product') { $out .= ''; } elseif ($mode == 'lot') { $out .= ''; } else { // $mode = 'all' $out .= '
'; $out .= '
'; $out .= '
'; } $stringaddbarcode = $langs->trans("QtyToAddAfterBarcodeScan", "tmphtml"); $htmltoreplaceby = ''; $stringaddbarcode = str_replace("tmphtml", $htmltoreplaceby, $stringaddbarcode); $out .= $stringaddbarcode.':
'; if ($warehouseselect > 0) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($this->db); $formproduct->loadWarehouses(); $out .= img_picto('', 'stock', 'class="pictofixedwidth"'); $out .= $formproduct->selectWarehouses('', "warehousenew", '', 0, 0, 0, '', 0, 1); $out .= '
'; $out .= '
'; } $out .= ''; /*print '
'.$langs->trans("or").'
'; print '
'; print '     Qty
'; */ $out .= '
'; $out .= '
'; $out .= ''; $out .= ''; $out .= '
'; $out .= '
'; $out .= '
'; $out .= ''; $out .= ''; $out .= '
'; return $out; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML select list of export models * * @param string $selected Id modele pre-selectionne * @param string $htmlname Nom de la zone select * @param string $type Type des modeles recherches * @param int $useempty Show an empty value in list * @param int $fk_user User we want templates * @return void */ public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null) { // phpcs:enable global $conf, $langs, $user; $sql = "SELECT rowid, label, fk_user"; $sql .= " FROM ".$this->db->prefix()."export_model"; $sql .= " WHERE type = '".$this->db->escape($type)."'"; if (!getDolGlobalString('EXPORTS_SHARE_MODELS')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. $sql .= " AND fk_user IN (0, ".((int) $fk_user).")"; } $sql .= " ORDER BY label"; $result = $this->db->query($sql); if ($result) { print '"; print ajax_combobox($htmlname); } else { dol_print_error($this->db); } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of export models * * @param string $selected Id modele pre-selectionne * @param string $htmlname Nom de la zone select * @param string $type Type des modeles recherches * @param int $useempty Affiche valeur vide dans liste * @param int $fk_user User that has created the template * @return void */ public function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0, $fk_user = null) { // phpcs:enable global $conf, $langs, $user; $sql = "SELECT rowid, label, fk_user"; $sql .= " FROM ".$this->db->prefix()."import_model"; $sql .= " WHERE type = '".$this->db->escape($type)."'"; if (!getDolGlobalString('EXPORTS_SHARE_MODELS')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. $sql .= " AND fk_user IN (0, ".((int) $fk_user).")"; } $sql .= " ORDER BY label"; $result = $this->db->query($sql); if ($result) { print '"; print ajax_combobox($htmlname); } else { dol_print_error($this->db); } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of ecotaxes with label * * @param string $selected Preselected ecotaxes * @param string $htmlname Name of combo list * @return integer */ public function select_ecotaxes($selected = '', $htmlname = 'ecotaxe_id') { // phpcs:enable global $langs; $sql = "SELECT e.rowid, e.code, e.label, e.price, e.organization,"; $sql .= " c.label as country"; $sql .= " FROM ".$this->db->prefix()."c_ecotaxe as e,".$this->db->prefix()."c_country as c"; $sql .= " WHERE e.active = 1 AND e.fk_pays = c.rowid"; $sql .= " ORDER BY country, e.organization ASC, e.code ASC"; dol_syslog(get_class($this).'::select_ecotaxes', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { print ''; return 0; } else { dol_print_error($this->db); return 1; } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of revenue stamp for country * * @param string $selected Value of preselected revenue stamp * @param string $htmlname Name of combo list * @param string $country_code Country Code * @return string HTML select list */ public function select_revenue_stamp($selected = '', $htmlname = 'revenuestamp', $country_code = '') { // phpcs:enable global $langs; $out = ''; $sql = "SELECT r.taux, r.revenuestamp_type"; $sql .= " FROM ".$this->db->prefix()."c_revenuestamp as r,".$this->db->prefix()."c_country as c"; $sql .= " WHERE r.active = 1 AND r.fk_pays = c.rowid"; $sql .= " AND c.code = '".$this->db->escape($country_code)."'"; dol_syslog(get_class($this).'::select_revenue_stamp', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $out .= ''; return $out; } else { dol_print_error($this->db); return ''; } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select list to select a percent * * @param integer $selected pourcentage pre-selectionne * @param string $htmlname nom de la liste deroulante * @param int $disabled Disabled or not * @param int $increment increment value * @param int $start start value * @param int $end end value * @param int $showempty Add also an empty line * @return string HTML select string */ public function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0) { // phpcs:enable $return = ''; return $return; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list for categories (to use in form search selectors) * * @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @param integer $selected Preselected value * @param string $htmlname Name of combo list * @param int $nocateg Show also an entry "Not categorized" * @param int|string $showempty Add also an empty line * @param string $morecss More CSS * @return string Html combo list code * @see select_all_categories() */ public function select_categories($type, $selected = 0, $htmlname = 'search_categ', $nocateg = 0, $showempty = 1, $morecss = '') { // phpcs:enable global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // For backward compatibility if (is_numeric($type)) { dol_syslog(__METHOD__.': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); } // Load list of "categories" $static_categs = new Categorie($this->db); $tab_categs = $static_categs->get_full_arbo($type); $moreforfilter = ''; // Print a select with each of them $moreforfilter .= ''; // Enhance with select2 if ($conf->use_javascript_ajax) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox('select_categ_'.$htmlname); $moreforfilter .= $comboenhancement; } return $moreforfilter; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list for categories (to use in form search selectors) * * @param int|string $selected Preselected value * @param string $htmlname Name of combo list (example: 'search_sale') * @param User $user Object user * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status * @param int|string $showempty 1=show also an empty value or text to show for empty * @param string $morecss More CSS * @param int $norepresentative Show also an entry "Not categorized" * @return string Html combo list code */ public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '', $norepresentative = 0) { // phpcs:enable global $conf, $langs, $hookmanager; global $action; $langs->load('users'); $out = ''; $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectSalesRep', array(), $this, $action); // Select each sales and print them in a select input $out .= ''; // Enhance with select2 if ($conf->use_javascript_ajax) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox($htmlname); if ($comboenhancement) { $out .= $comboenhancement; } } return $out; } /** * Return list of project and tasks * * @param int $selectedtask Pre-selected task * @param int $projectid Project id * @param string $htmlname Name of html select * @param int $modeproject 1 to restrict on projects owned by user * @param int $modetask 1 to restrict on tasks associated to user * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists * @param int $useempty 0=Allow empty values * @param int $disablechildoftaskid 1=Disable task that are child of the provided task id * @param string $filteronprojstatus Filter on project status ('-1'=no filter, '0,1'=Draft+Validated status) * @param string $morecss More css * @return void */ public function selectProjectTasks($selectedtask = 0, $projectid = 0, $htmlname = 'task_parent', $modeproject = 0, $modetask = 0, $mode = 0, $useempty = 0, $disablechildoftaskid = 0, $filteronprojstatus = '', $morecss = '') { global $user, $langs; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; //print $modeproject.'-'.$modetask; $task = new Task($this->db); $tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode, '', $filteronprojstatus); if ($tasksarray) { print ''; print ajax_combobox($htmlname); } else { print '
'.$langs->trans("NoProject").'
'; } } /** * Write lines of a project (all lines of a project if parent = 0) * * @param int $inc Cursor counter * @param int $parent Id of parent task we want to see * @param array $lines Array of task lines * @param int $level Level * @param int $selectedtask Id selected task * @param int $selectedproject Id selected project * @param int $disablechildoftaskid 1=Disable task that are child of the provided task id * @return void */ private function _pLineSelect(&$inc, $parent, $lines, $level = 0, $selectedtask = 0, $selectedproject = 0, $disablechildoftaskid = 0) { global $langs, $user, $conf; $lastprojectid = 0; $numlines = count($lines); for ($i = 0; $i < $numlines; $i++) { if ($lines[$i]->fk_task_parent == $parent) { //var_dump($selectedproject."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines // Break on a new project if ($parent == 0) { // We are on a task at first level if ($lines[$i]->fk_project != $lastprojectid) { // Break found on project if ($i > 0) { print ''; } print '\n"; $lastprojectid = $lines[$i]->fk_project; $inc++; } } $newdisablechildoftaskid = $disablechildoftaskid; // Print task if (isset($lines[$i]->id)) { // We use isset because $lines[$i]->id may be null if project has no task and are on root project (tasks may be caught by a left join). We enter here only if '0' or >0 // Check if we must disable entry $disabled = 0; if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_task_parent == $disablechildoftaskid))) { $disabled++; if ($lines[$i]->fk_task_parent == $disablechildoftaskid) { $newdisablechildoftaskid = $lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too } } print '\n"; $inc++; } $level++; if ($lines[$i]->id) { $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid); } $level--; } } } /** * Output a HTML thumb of color or a text if not defined. * * @param string $color String with hex (FFFFFF) or comma RGB ('255,255,255') * @param string $textifnotdefined Text to show if color not defined * @return string Show color string * @see selectColor() */ public static function showColor($color, $textifnotdefined = '') { $textcolor = 'FFF'; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; if (colorIsLight($color)) { $textcolor = '000'; } $color = colorArrayToHex(colorStringToArray($color, array()), ''); if ($color) { return ''; } else { return $textifnotdefined; } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a HTML code to select a color * * @param string $set_color Pre-selected color * @param string $prefix Name of HTML field * @param string $form_name Deprecated. Not used. * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') * @return void * @deprecated Use instead selectColor * @see selectColor() */ public function select_color($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = []) { // phpcs:enable print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors); } /** * Output a HTML code to select a color. Field will return an hexa color like '334455'. * * @param string $set_color Pre-selected color with format '#......' * @param string $prefix Name of HTML field * @param string $form_name Deprecated. Not used. * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code * @param array $arrayofcolors Array of possible colors to choose in the selector. All colors are possible if empty. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') * @param string $morecss Add css style into input field * @param string $setpropertyonselect Set this CSS property after selecting a color * @param string $default Default color * @return string * @see showColor() */ public static function selectColor($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = [], $morecss = '', $setpropertyonselect = '', $default = '') { // Deprecation warning if ($form_name) { dol_syslog(__METHOD__.": form_name parameter is deprecated", LOG_WARNING); } global $langs, $conf; $out = ''; if (!is_array($arrayofcolors) || count($arrayofcolors) < 1) { // Case of selection of any color $langs->load("other"); if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax) && !getDolGlobalInt('MAIN_USE_HTML5_COLOR_SELECTOR')) { $out .= ''; $out .= ''; $out .= ''; $out .= ''; } else { $color = ($set_color !== '' ? $set_color : ($default !== '' ? $default : 'FFFFFF')); $out .= ''; $out .= ''; } } else { // In most cases, this is not used. We used instead function with no specific list of colors if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax)) { $out .= ''; $out .= ''; $out .= ''; } $out .= ''; } return $out; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create an image for color * * @param string $color Color of image * @param string $module Name of module * @param string $name Name of image * @param int $x Largeur de l'image en pixels * @param int $y Hauteur de l'image en pixels * @return void */ public function CreateColorIcon($color, $module, $name, $x = 12, $y = 12) { // phpcs:enable global $conf; $file = $conf->$module->dir_temp.'/'.$name.'.png'; // We create temp directory if (!file_exists($conf->$module->dir_temp)) { dol_mkdir($conf->$module->dir_temp); } // On cree l'image en vraies couleurs $image = imagecreatetruecolor($x, $y); $color = substr($color, 1, 6); $red = hexdec(substr($color, 0, 2)); // Red channel conversion $green = hexdec(substr($color, 2, 2)); // Green channel conversion $blue = hexdec(substr($color, 4, 2)); // Blue channel conversion $couleur = imagecolorallocate($image, $red, $green, $blue); //print $red.$green.$blue; imagefill($image, 0, 0, $couleur); // Fill the image // Create the colr and store it in a variable to maintain it imagepng($image, $file); // Returns an image in PNG format imagedestroy($image); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML combo list of week * * @param string $selected Preselected value * @param string $htmlname Nom de la zone select * @param int $useempty Affiche valeur vide dans liste * @return string */ public function select_dayofweek($selected = '', $htmlname = 'weekid', $useempty = 0) { // phpcs:enable global $langs; $week = array( 0 => $langs->trans("Day0"), 1 => $langs->trans("Day1"), 2 => $langs->trans("Day2"), 3 => $langs->trans("Day3"), 4 => $langs->trans("Day4"), 5 => $langs->trans("Day5"), 6 => $langs->trans("Day6") ); $select_week = ''; $select_week .= ajax_combobox($htmlname); return $select_week; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML combo list of month * * @param string $selected Preselected value * @param string $htmlname Name of HTML select object * @param int $useempty Show empty in list * @param int $longlabel Show long label * @param string $morecss More Css * @param bool $addjscombo Add js combo * @return string */ public function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0, $morecss = 'minwidth50 maxwidth75imp valignmiddle', $addjscombo = false) { // phpcs:enable global $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if ($longlabel) { $montharray = monthArray($langs, 0); // Get array } else { $montharray = monthArray($langs, 1); } $select_month = ''; // Add code for jquery to use multiselect if ($addjscombo) { // Enhance with select2 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $select_month .= ajax_combobox($htmlname); } return $select_month; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML combo list of years * * @param string $selected Preselected value (''=current year, -1=none, year otherwise) * @param string $htmlname Name of HTML select object * @param int $useempty Affiche valeur vide dans liste * @param int $min_year Offset of minimum year into list (by default current year -10) * @param int $max_year Offset of maximum year into list (by default current year + 5) * @param int $offset Offset * @param int $invert Invert * @param string $option Option * @param string $morecss More CSS * @param bool $addjscombo Add js combo * @return void * @deprecated */ public function select_year($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp', $addjscombo = false) { // phpcs:enable print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss, $addjscombo); } /** * Return HTML combo list of years * * @param string $selected Preselected value (''=current year, -1=none, year otherwise) * @param string $htmlname Name of HTML select object * @param int $useempty Affiche valeur vide dans liste * @param int $min_year Offset of minimum year into list (by default current year -10) * @param int $max_year Offset of maximum year into list (by default current year + 5) * @param int $offset Offset * @param int $invert Invert * @param string $option Option * @param string $morecss More css * @param bool $addjscombo Add js combo * @return string */ public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle width75', $addjscombo = false) { $out = ''; $currentyear = idate("Y") + $offset; $max_year = $currentyear + $max_year; $min_year = $currentyear - $min_year; if (empty($selected) && empty($useempty)) { $selected = $currentyear; } $out .= '\n"; // Add code for jquery to use multiselect if ($addjscombo) { // Enhance with select2 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); } return $out; } /** * Get array with HTML tabs with boxes of a particular area including personalized choices of user. * Class 'Form' must be known. * * @param User $user Object User * @param string $areacode Code of area for pages - 0 = Home page ... See getListOfPagesForBoxes() * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlista'=>, 'boxlistb'=>) */ public static function getBoxesArea($user, $areacode) { global $conf, $langs, $db; include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; $confuserzone = 'MAIN_BOXES_'.$areacode; // $boxactivated will be array of boxes enabled into global setup // $boxidactivatedforuser will be array of boxes chose by user $selectboxlist = ''; $boxactivated = InfoBox::listBoxes($db, 'activated', $areacode, (empty($user->conf->$confuserzone) ? null : $user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup) $boxidactivatedforuser = array(); foreach ($boxactivated as $box) { if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) { $boxidactivatedforuser[$box->id] = $box->id; // We keep only boxes to show for user } } // Define selectboxlist $arrayboxtoactivatelabel = array(); if (!empty($user->conf->$confuserzone)) { $boxorder = ''; $langs->load("boxes"); // Load label of boxes foreach ($boxactivated as $box) { if (!empty($boxidactivatedforuser[$box->id])) { continue; // Already visible for user } $label = $langs->transnoentitiesnoconv($box->boxlabel); //if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')'; if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') { $label .= ' '; } $arrayboxtoactivatelabel[$box->id] = array('label' => $label, 'data-html' => img_picto('', $box->boximg, 'class="pictofixedwidth"').$langs->trans($label)); // We keep only boxes not shown for user, to show into combo list } foreach ($boxidactivatedforuser as $boxid) { if (empty($boxorder)) { $boxorder .= 'A:'; } $boxorder .= $boxid.','; } //var_dump($boxidactivatedforuser); // Class Form must have been already loaded $selectboxlist .= ''."\n"; $selectboxlist .= ''; $selectboxlist .= ''; $selectboxlist .= ''; $selectboxlist .= ''; $selectboxlist .= ''; $selectboxlist .= ''; $selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth300 hideonprint', 0, 'hidden selected', 0, 0); if (empty($conf->use_javascript_ajax)) { $selectboxlist .= ' '; } $selectboxlist .= '
'; if (!empty($conf->use_javascript_ajax)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $selectboxlist .= ajax_combobox("boxcombo"); } } // Javascript code for dynamic actions if (!empty($conf->use_javascript_ajax)) { $selectboxlist .= ''."\n"; } // Define boxlista and boxlistb $boxlista = ''; $boxlistb = ''; $nbboxactivated = count($boxidactivatedforuser); if ($nbboxactivated) { // Load translation files required by the page $langs->loadLangs(array("boxes", "projects")); $emptybox = new ModeleBoxes($db); $boxlista .= "\n\n"; // Define $box_max_lines $box_max_lines = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5)); $ii = 0; foreach ($boxactivated as $key => $box) { if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) { continue; } if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) { $box->box_order = 'A'.sprintf("%02d", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0 } if (preg_match('/^A/i', $box->box_order)) { // column A $ii++; //print 'box_id '.$boxactivated[$ii]->box_id.' '; //print 'box_order '.$boxactivated[$ii]->box_order.'
'; // Show box $box->loadBox($box_max_lines); $boxlista .= $box->showBox(null, null, 1); } } if ($conf->browser->layout != 'phone') { $emptybox->box_id = 'A'; $emptybox->info_box_head = array(); $emptybox->info_box_contents = array(); $boxlista .= $emptybox->showBox(array(), array(), 1); } $boxlista .= "\n"; $boxlistb .= "\n\n"; $ii = 0; foreach ($boxactivated as $key => $box) { if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) { continue; } if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) { $box->box_order = 'B'.sprintf("%02d", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0 } if (preg_match('/^B/i', $box->box_order)) { // colonne B $ii++; //print 'box_id '.$boxactivated[$ii]->box_id.' '; //print 'box_order '.$boxactivated[$ii]->box_order.'
'; // Show box $box->loadBox($box_max_lines); $boxlistb .= $box->showBox(null, null, 1); } } if ($conf->browser->layout != 'phone') { $emptybox->box_id = 'B'; $emptybox->info_box_head = array(); $emptybox->info_box_contents = array(); $boxlistb .= $emptybox->showBox(array(), array(), 1); } $boxlistb .= "\n"; } return array('selectboxlist' => count($boxactivated) ? $selectboxlist : '', 'boxactivated' => $boxactivated, 'boxlista' => $boxlista, 'boxlistb' => $boxlistb); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select list of a dictionary * * @param string $htmlname Name of select zone * @param string $dictionarytable Dictionary table * @param string $keyfield Field for key * @param string $labelfield Label field * @param string $selected Selected value * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @param string $moreattrib More attributes on HTML select tag * @return void */ public function select_dictionary($htmlname, $dictionarytable, $keyfield = 'code', $labelfield = 'label', $selected = '', $useempty = 0, $moreattrib = '') { // phpcs:enable global $langs, $conf; $langs->load("admin"); $sql = "SELECT rowid, ".$keyfield.", ".$labelfield; $sql .= " FROM ".$this->db->prefix().$dictionarytable; $sql .= " ORDER BY ".$labelfield; dol_syslog(get_class($this)."::select_dictionary", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $i = 0; if ($num) { print '"; } else { print $langs->trans("DictionaryEmpty"); } } else { dol_print_error($this->db); } } /** * Return an html string with a select combo box to choose yes or no * * @param string $htmlname Name of html select field * @param string $value Pre-selected value * @param int $option 0 return automatic/manual, 1 return 1/0 * @param bool $disabled true or false * @param int $useempty 1=Add empty line * @return string See option */ public function selectAutoManual($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) { global $langs; $automatic = "automatic"; $manual = "manual"; if ($option) { $automatic = "1"; $manual = "0"; } $disabled = ($disabled ? ' disabled' : ''); $resultautomanual = ''."\n"; return $resultautomanual; } /** * Return HTML select list to select a group by field * * @param mixed $object Object analyzed * @param array $search_groupby Array of preselected fields * @param array $arrayofgroupby Array of groupby to fill * @param string $morecss More CSS * @param string $showempty '1' or 'text' * @return string HTML string component */ public function selectGroupByField($object, $search_groupby, &$arrayofgroupby, $morecss = 'minwidth200 maxwidth250', $showempty = '1') { global $langs, $extrafields, $form; $arrayofgroupbylabel = array(); foreach ($arrayofgroupby as $key => $val) { $arrayofgroupbylabel[$key] = $val['label']; } $result = $form->selectarray('search_groupby', $arrayofgroupbylabel, $search_groupby, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); return $result; } /** * Return HTML select list to select a group by field * * @param mixed $object Object analyzed * @param array $search_xaxis Array of preselected fields * @param array $arrayofxaxis Array of groupby to fill * @param string $showempty '1' or 'text' * @param string $morecss More css * @return string HTML string component */ public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1', $morecss = 'minwidth250 maxwidth500') { global $form; $arrayofxaxislabel = array(); foreach ($arrayofxaxis as $key => $val) { $arrayofxaxislabel[$key] = $val['label']; } $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); return $result; } }