StringLen = ""; $this->FirstOption = "----Select----"; $this->ValueOnly = True; $this->KeyOnly = False; } function ListBoxNo() { if (func_num_args() < 2) {die ("Minimum 2 arguments required for the function found only " . func_num_args());} $arg_list = func_get_args(); $startno = $arg_list[0]; $endno = $arg_list[1]; $selected = $arg_list[2]; $this->KeyOnly = True; $numberArray = array_fill($startno, $endno, ''); $listBoxData = $this->ListBoxArray($numberArray, $selected); return $listBoxData; } /*-------------------------------------------------------------------------------- Usage : listBox (sql, selectparam, selected, first, stringlen) Input : sql = Sql query. Should return two data 1. option value 2. option text selectparam = Name of the list box selected = The options to be selected while displaying the list box. Multiple options can be seleted by passing a array. first = First option to tbe displayed $stringlen = Length if the option text to be displayed. 0 or empty if all text to be displayed Returns : Displays the list box Comments: Checked with single option - ok Bug : 2004-06-28 Single option not working if the selection is text -- Solved 2004-07-24 If the Multiple select array has one element the selection will not work. -- Solved --------------------------------------------------------------------------------*/ function ListBoxDb() { if (func_num_args() < 1) {die ("Minimum 1 arguments required for the function found only " . func_num_args());} $arg_list = func_get_args(); $sqlquery = $arg_list[0]; $selected = $arg_list[1]; //print_r($sqlquery); $db = new etamineDB(); $db->SetResultType(MYSQL_NUM); $optionData = $db->DbGetMultipleRecords($sqlquery, "FirstVal"); //print_r($optionData); $listBoxData = $this->ListBoxArray($optionData, $selected); return $listBoxData; } function ListBoxArray() { if (func_num_args() < 1) {die ("Minimum 1 arguments required for the function found only " . func_num_args());} $arg_list = func_get_args(); $OptionDataArray = $arg_list[0]; $selected = $arg_list[1]; $util = new etamineUtil(); $selectedarray = explode(",",$selected); if (!empty($this->FirstOption)) {$listBoxData .= "";} if (is_array($OptionDataArray)) { while($CellData = each($OptionDataArray)) { $text = $util->ShowCharc($CellData['value'], $this->StringLen); $value = $CellData['key']; if ($this->KeyOnly) {$text = $value;} else if ($this->ValueOnly) {$value = $text;} if ($this->FormatText) {$text = sprintf("%02d", $text);} $listBoxData .= ""; } } $util=""; return $listBoxData; } function SetStringLen($length) { $this->StringLen = $length; } function SetFirstOption($firstoption) { $this->FirstOption = $firstoption; } function SetFormatText($formattext) { $this->FormatText = $formattext; } function IsValueOnly($bool) { $this->ValueOnly = $bool; } function IsKeyOnly($bool) { $this->KeyOnly = $bool; } } class etamineListBox { var $StringLen; var $FirstOption; var $SelectedOption = array(); var $FormatText = 0; function ListBox() { $this->StringLen = ""; $this->FirstOption = "---Select---"; $this->ValueOnly = True; $this->KeyOnly = False; } function ListBoxNo() { if (func_num_args() < 2) {die ("Minimum 2 arguments required for the function found only " . func_num_args());} $arg_list = func_get_args(); $startno = $arg_list[0]; $endno = $arg_list[1]; $selected = $arg_list[2]; $this->KeyOnly = True; $numberArray = array_fill($startno, $endno, ''); $listBoxData = $this->ListBoxArray($numberArray, $selected); return $listBoxData; } /*-------------------------------------------------------------------------------- Usage : listBox (sql, selectparam, selected, first, stringlen) Input : sql = Sql query. Should return two data 1. option value 2. option text selectparam = Name of the list box selected = The options to be selected while displaying the list box. Multiple options can be seleted by passing a array. first = First option to tbe displayed $stringlen = Length if the option text to be displayed. 0 or empty if all text to be displayed Returns : Displays the list box Comments: Checked with single option - ok Bug : 2004-06-28 Single option not working if the selection is text -- Solved 2004-07-24 If the Multiple select array has one element the selection will not work. -- Solved --------------------------------------------------------------------------------*/ function ListBoxDb() { if (func_num_args() < 1) {die ("Minimum 1 arguments required for the function found only " . func_num_args());} $arg_list = func_get_args(); $sqlquery = $arg_list[0]; $selected = $arg_list[1]; $db = new etamineDB(); $db->SetResultType(MYSQL_NUM); $optionData = $db->DbGetMultipleRecords($sqlquery, "FirstVal"); //$db->DbClose(); //$db=""; $listBoxData = $this->ListBoxArray($optionData, $selected); return $listBoxData; } function ListBoxArray() { if (func_num_args() < 1) {die ("Minimum 1 arguments required for the function found only " . func_num_args());} $arg_list = func_get_args(); $OptionDataArray = $arg_list[0]; $selected = $arg_list[1]; $util = new etamineUtil(); if (!empty($this->FirstOption)) {$listBoxData .= "";} if (is_array($OptionDataArray)) { while($CellData = each($OptionDataArray)) { $text = $util->ShowCharc($CellData['value'], $this->StringLen); $value = $CellData['key']; if ($this->KeyOnly) {$text = $value;} else if ($this->ValueOnly) {$value = $text;} if ($this->FormatText) {$text = sprintf("%02d", $text);} $listBoxData .= ""; } } $util=""; return $listBoxData; } function SetEditOption($position="End") { $this->StringLen = $length; } function SetStringLen($length) { $this->StringLen = $length; } function SetFirstOption($firstoption) { $this->FirstOption = $firstoption; } function SetFormatText($formattext) { $this->FormatText = $formattext; } function IsValueOnly($bool) { $this->ValueOnly = $bool; } function IsKeyOnly($bool) { $this->KeyOnly = $bool; } } ?>