From e519bf0c402c35ddb75a9d340f96ef67e489e496 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Feb 2012 16:24:36 +0100 Subject: [PATCH] Fix: Fix TODO Doxygen --- htdocs/core/class/html.formother.class.php | 996 +++++++++++---------- 1 file changed, 501 insertions(+), 495 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index e39c4ad26dd..c1640110553 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -37,355 +37,436 @@ */ class FormOther { - var $db; - var $error; + var $db; + var $error; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function FormOther($db) - { - $this->db = $db; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function FormOther($db) + { + $this->db = $db; - return 1; - } + return 1; + } - /** + /** * 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 Affiche valeur vide dans liste - * @return void - */ - function select_export_model($selected='',$htmlname='exportmodelid',$type='',$useempty=0) - { - $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."export_model"; - $sql.= " WHERE type = '".$type."'"; - $sql.= " ORDER BY rowid"; - $result = $this->db->query($sql); - if ($result) - { - print ''; + if ($useempty) + { + print ''; + } - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid) - { - print ''; - $i++; - } - print ""; - } - else { - dol_print_error($this->db); - } - } + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($selected == $obj->rowid) + { + print ''; + $i++; + } + print ""; + } + else { + dol_print_error($this->db); + } + } - /** + /** * 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 - * @return void - */ - function select_import_model($selected='',$htmlname='importmodelid',$type='',$useempty=0) - { - $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."import_model"; - $sql.= " WHERE type = '".$type."'"; - $sql.= " ORDER BY rowid"; - $result = $this->db->query($sql); - if ($result) - { - print ''; + if ($useempty) + { + print ''; + } - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid) - { - print ''; - $i++; - } - print ""; - } - else { - dol_print_error($this->db); - } - } + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($selected == $obj->rowid) + { + print ''; + $i++; + } + print ""; + } + else { + dol_print_error($this->db); + } + } - /** - * Retourne la liste des ecotaxes avec tooltip sur le libelle - * - * @param string $selected code ecotaxes pre-selectionne - * @param string $htmlname nom de la liste deroulante - * @return void - */ - function select_ecotaxes($selected='',$htmlname='ecotaxe_id') - { - global $langs; + /** + * Retourne la liste des ecotaxes avec tooltip sur le libelle + * + * @param string $selected code ecotaxes pre-selectionne + * @param string $htmlname nom de la liste deroulante + * @return void + */ + function select_ecotaxes($selected='',$htmlname='ecotaxe_id') + { + global $langs; - $sql = "SELECT e.rowid, e.code, e.libelle, e.price, e.organization,"; - $sql.= " p.libelle as pays"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_pays as p"; - $sql.= " WHERE e.active = 1 AND e.fk_pays = p.rowid"; - $sql.= " ORDER BY pays, e.organization ASC, e.code ASC"; + $sql = "SELECT e.rowid, e.code, e.libelle, e.price, e.organization,"; + $sql.= " p.libelle as pays"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_pays as p"; + $sql.= " WHERE e.active = 1 AND e.fk_pays = p.rowid"; + $sql.= " ORDER BY pays, e.organization ASC, e.code ASC"; $resql=$this->db->query($sql); - if ($resql) - { - print ''; - return 0; - } - else - { - dol_print_error($this->db); - return 1; - } - } + if ($resql) + { + print ''; + return 0; + } + else + { + dol_print_error($this->db); + return 1; + } + } - /** - * Return a HTML select list to select a percent - * - * @param string $selected pourcentage pre-selectionne - * @param string $htmlname nom de la liste deroulante - * @param int $increment increment value - * @param int $start start value - * @param int $end end value - * @return string HTML select string - */ - function select_percent($selected=0,$htmlname='percent',$disabled=0,$increment=5,$start=0,$end=100) - { - $return = ''; - for ($i = $start ; $i <= $end ; $i += $increment) - { - if ($selected == $i) - { - $return.= ''; - } + for ($i = $start ; $i <= $end ; $i += $increment) + { + if ($selected == $i) + { + $return.= ''; + } - $return.= ''; + $return.= ''; - return $return; - } + return $return; + } - /** - * Return select list for categories (to use in form search selectors) - * - * @param int $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members) - * @param string $selected Preselected value - * @param string $htmlname Name of combo list - * @return string Html combo list code - */ - function select_categories($type,$selected=0,$htmlname='search_categ') - { - global $langs; - require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); + /** + * Return select list for categories (to use in form search selectors) + * + * @param int $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members) + * @param string $selected Preselected value + * @param string $htmlname Name of combo list + * @return string Html combo list code + */ + function select_categories($type,$selected=0,$htmlname='search_categ') + { + global $langs; + require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); - // Load list of "categories" - $static_categs = new Categorie($this->db); - $tab_categs = $static_categs->get_full_arbo($type); + // Load list of "categories" + $static_categs = new Categorie($this->db); + $tab_categs = $static_categs->get_full_arbo($type); - // Print a select with each of them - $moreforfilter =''; + $moreforfilter.=''; - if (is_array($tab_categs)) - { - foreach ($tab_categs as $categ) - { - $moreforfilter.=''; - // Get list of users allowed to be viewed - $sql_usr = "SELECT u.rowid, u.name as name, u.firstname, u.login"; - $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")"; - if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.fk_societe = ".($user->societe_id?$user->societe_id:0); + // Get list of users allowed to be viewed + $sql_usr = "SELECT u.rowid, u.name as name, u.firstname, u.login"; + $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")"; + if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.fk_societe = ".($user->societe_id?$user->societe_id:0); // Add existing sales representatives of company - if (empty($user->rights->user->user->lire) && $user->societe_id) - { + if (empty($user->rights->user->user->lire) && $user->societe_id) + { $sql_usr.=" UNION "; $sql_usr.= "SELECT u2.rowid, u2.name as name, u2.firstname, u2.login"; $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql_usr.= " WHERE u2.entity IN (0,".$conf->entity.")"; $sql_usr.= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->societe_id; - } + } $sql_usr.= " ORDER BY name ASC"; //print $sql_usr;exit; $resql_usr = $this->db->query($sql_usr); - if ($resql_usr) - { - while ($obj_usr = $this->db->fetch_object($resql_usr)) - { - $moreforfilter.=''; - } - $this->db->free($resql_usr); - } - else - { - dol_print_error($this->db); - } - $moreforfilter.=''; + $moreforfilter.='>'; + $moreforfilter.=$obj_usr->firstname." ".$obj_usr->name." (".$obj_usr->login.')'; + $moreforfilter.=''; + } + $this->db->free($resql_usr); + } + else + { + dol_print_error($this->db); + } + $moreforfilter.=''; - return $moreforfilter; - } + return $moreforfilter; + } - /** - * 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 - * @return void - */ - function selectProjectTasks($selectedtask='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0, $mode=0, $useempty=0) - { - global $user, $langs; + /** + * 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 + * @return void + */ + function selectProjectTasks($selectedtask='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0, $mode=0, $useempty=0) + { + global $user, $langs; - require_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php"); + 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); - if ($tasksarray) - { - print ''; - } - else - { - print '
'.$langs->trans("NoProject").'
'; - } - } + //print $modeproject.'-'.$modetask; + $task=new Task($this->db); + $tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $projectid, 0, $mode); + if ($tasksarray) + { + print ''; + } + else + { + print '
'.$langs->trans("NoProject").'
'; + } + } + /** + * Write all lines of a project (if parent = 0) + * + * @param int &$inc Cursor counter + * @param int $parent Id parent + * @param Object $lines Line object + * @param int $level Level + * @param int $selectedtask Id selected task + * @param int $selectedproject Id selected project + * @return void + */ + private function _pLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selectedproject=0) + { + global $langs, $user, $conf; - /** - * 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 Name of form - * @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 - */ - function select_color($set_color='', $prefix='f_color', $form_name='objForm', $showcolorbox=1, $arrayofcolors='') - { - global $langs; - if (! is_array($arrayofcolors) || count($arrayofcolors) < 1) - { - $langs->load("other"); - print ''; + $lastprojectid=0; + + $numlines=count($lines); + for ($i = 0 ; $i < $numlines ; $i++) + { + if ($lines[$i]->fk_parent == $parent) + { + $var = !$var; + + // Break on a new project + if ($parent == 0) + { + if ($lines[$i]->fk_project != $lastprojectid) + { + if ($i > 0 && $conf->browser->firefox) print ''; + print '\n"; + + $lastprojectid=$lines[$i]->fk_project; + $inc++; + } + } + + // Print task + if ($lines[$i]->id > 0) + { + print '\n"; + $inc++; + } + + $level++; + if ($lines[$i]->id) $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject); + $level--; + } + } + } + + /** + * 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 Name of form + * @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 + */ + function select_color($set_color='', $prefix='f_color', $form_name='objForm', $showcolorbox=1, $arrayofcolors='') + { + global $langs; + if (! is_array($arrayofcolors) || count($arrayofcolors) < 1) + { + $langs->load("other"); + print ''; print ''; print ''; print ''; - } - else // In most cases, this is not used. We used instead function with no specific list of colors - { + } + else // In most cases, this is not used. We used instead function with no specific list of colors + { print ''; print ''; - print ''; - print ''; - } - } + print ''; + } + } - /** - * Creation d'un icone de couleur - * - * @param string $color Couleur de l'image - * @param string $module Nom du module - * @param string $name Nom de l'image - * @param int $x Largeur de l'image en pixels - * @param int $y Hauteur de l'image en pixels - */ - function CreateColorIcon($color,$module,$name,$x='12',$y='12') - { - global $conf; + /** + * Creation d'un icone de couleur + * + * @param string $color Couleur de l'image + * @param string $module Nom du module + * @param string $name Nom de l'image + * @param int $x Largeur de l'image en pixels + * @param int $y Hauteur de l'image en pixels + * @return void + */ + function CreateColorIcon($color,$module,$name,$x='12',$y='12') + { + global $conf; - $file = $conf->$module->dir_temp.'/'.$name.'.png'; + $file = $conf->$module->dir_temp.'/'.$name.'.png'; - // On cree le repertoire contenant les icones - if (! file_exists($conf->$module->dir_temp)) - { - dol_mkdir($conf->$module->dir_temp); - } + // On cree le repertoire contenant les icones + if (! file_exists($conf->$module->dir_temp)) + { + dol_mkdir($conf->$module->dir_temp); + } - // On cree l'image en vraies couleurs - $image = imagecreatetruecolor($x,$y); + // On cree l'image en vraies couleurs + $image = imagecreatetruecolor($x,$y); - $color = substr($color,1,6); + $color = substr($color,1,6); - $rouge = hexdec(substr($color,0,2)); //conversion du canal rouge - $vert = hexdec(substr($color,2,2)); //conversion du canal vert - $bleu = hexdec(substr($color,4,2)); //conversion du canal bleu + $rouge = hexdec(substr($color,0,2)); //conversion du canal rouge + $vert = hexdec(substr($color,2,2)); //conversion du canal vert + $bleu = hexdec(substr($color,4,2)); //conversion du canal bleu - $couleur = imagecolorallocate($image,$rouge,$vert,$bleu); - //print $rouge.$vert.$bleu; - imagefill($image,0,0,$couleur); //on remplit l'image - // On cree la couleur et on l'attribue a une variable pour ne pas la perdre - ImagePng($image,$file); //renvoie une image sous format png - ImageDestroy($image); - } + $couleur = imagecolorallocate($image,$rouge,$vert,$bleu); + //print $rouge.$vert.$bleu; + imagefill($image,0,0,$couleur); //on remplit l'image + // On cree la couleur et on l'attribue a une variable pour ne pas la perdre + ImagePng($image,$file); //renvoie une image sous format png + ImageDestroy($image); + } /** * Return HTML combo list of week @@ -541,7 +623,7 @@ class FormOther */ function select_month($selected='',$htmlname='monthid',$useempty=0) { - global $langs; + global $langs; require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); @@ -569,36 +651,42 @@ class FormOther } /** - * Return HTML combo list of years + * 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) - * @return void + * @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 + * @return void */ - function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') + function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') { - print $this->selectyear($selected,$htmlname,$useempty,$min_year,$max_year,$offset,$invert,$option); + print $this->selectyear($selected,$htmlname,$useempty,$min_year,$max_year,$offset,$invert,$option); } /** - * Return HTML combo list of years + * 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) - * @return void + * @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 + * @return void */ - function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') + function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') { - $out=''; + $out=''; $currentyear = date("Y")+$offset; - $max_year = $currentyear+$max_year; + $max_year = $currentyear+$max_year; $min_year = $currentyear-$min_year; if(empty($selected)) $selected = $currentyear; @@ -610,21 +698,21 @@ class FormOther } if (! $invert) { - for ($y = $max_year; $y >= $min_year; $y--) - { - $selected_html=''; - if ($selected > 0 && $y == $selected) $selected_html = ' selected="selected"'; - $out.= ''; - } + for ($y = $max_year; $y >= $min_year; $y--) + { + $selected_html=''; + if ($selected > 0 && $y == $selected) $selected_html = ' selected="selected"'; + $out.= ''; + } } else { - for ($y = $min_year; $y <= $max_year; $y++) - { - $selected_html=''; - if ($selected > 0 && $y == $selected) $selected_html = ' selected="selected"'; - $out.= ''; - } + for ($y = $min_year; $y <= $max_year; $y++) + { + $selected_html=''; + if ($selected > 0 && $y == $selected) $selected_html = ' selected="selected"'; + $out.= ''; + } } $out.= "\n"; @@ -633,130 +721,48 @@ class FormOther /** * Show form to select addresse - * + * * @param int $page Page - * @param string $selected Id condition pre-selectionne - * @param string $htmlname Nom du formulaire select + * @param string $selected Id condition pre-selectionne + * @param int $socid Id of third party + * @param string $htmlname Nom du formulaire select * @param string $origin Origine de l'appel pour pouvoir creer un retour - * @param int $originid Id de l'origine + * @param int $originid Id de l'origine * @return void */ - function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='') + function form_address($page, $selected, $socid, $htmlname='address_id', $origin='', $originid='') { - global $langs,$conf; - if ($htmlname != "none") - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - $this->select_address($selected, $socid, $htmlname, 1); - print ''; - $langs->load("companies"); - print '   '.$langs->trans("AddAddress").''; - print '
'; - } - else - { - if ($selected) - { - require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php"); - $address=new Address($this->db); - $result=$address->fetch_address($selected); - print ''.$address->label.''; - } - else - { - print " "; - } - } + global $langs,$conf; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + $this->select_address($selected, $socid, $htmlname, 1); + print ''; + $langs->load("companies"); + print '   '.$langs->trans("AddAddress").''; + print '
'; + } + else + { + if ($selected) + { + require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php"); + $address=new Address($this->db); + $result=$address->fetch_address($selected); + print ''.$address->label.''; + } + else + { + print " "; + } + } } } - -/** - * Write all lines of a project (if parent = 0) - * - * @param int &$inc Cursor counter - * @param int $parent Id parent - * @param Object $lines Line object - * @param int $level Level - * @param int $selectedtask Id selected task - * @param int $selectedproject Id selected project - * @return void - * TODO why this function is here ? - */ -function PLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selectedproject=0) -{ - global $langs, $user, $conf; - - $lastprojectid=0; - - $numlines=count($lines); - for ($i = 0 ; $i < $numlines ; $i++) - { - if ($lines[$i]->fk_parent == $parent) - { - $var = !$var; - - // Break on a new project - if ($parent == 0) - { - if ($lines[$i]->fk_project != $lastprojectid) - { - if ($i > 0 && $conf->browser->firefox) print ''; - print '\n"; - - $lastprojectid=$lines[$i]->fk_project; - $inc++; - } - } - - // Print task - if ($lines[$i]->id > 0) - { - print '\n"; - $inc++; - } - - $level++; - if ($lines[$i]->id) PLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject); - $level--; - } - } -} - ?>