\n"; if ($default!='') $code .= ""; $ord = ''; $sql = new sqls("$table:$field1,$field2", $where, $ord); foreach ($sql->response as $response) { $ht = ($selected==$response[$field1])?' selected':''; $code .= "\n"; } $code .= "\n"; return $code; } function sel_db1($name, $table, $part1, $part2, $where='', $selected='', $default='- Select -', $class='' , $extra='', $width='238', $ord='', $disabled = 0) { if ($disabled == 1) $disabled = 'disabled'; else $disabled = ''; $code = " {$response[$field2]}
"; } return $code; } function sel_arr($name, $wid='', $array, $selected='', $default='- Select -', $class='' , $extra='') { if ($wid!='') $wid = ""; $code = "\n"; return $code; } function sel_arrr($name, $wid='', $array, $selected='', $default='- Select -', $class='' , $extra='') { if ($wid!='') $wid = "style='width:{$wid}px'"; $code = "\n"; return $code; } function sel_mdY($mm='mon', $dd='day', $yy='yer', $selected='', $class='', $y0=0, $y1=0, $mmc='- Month -', $ddc='- Day -', $yyc='- Year -') { $cm = ''; $cd = ''; $cy = ''; if ($selected!='') { $cm = date('m', $selected); $cd = date('d', $selected); $cy = date('Y', $selected); } $ms = array('01'=>'January', '02'=>'February', '03'=>'March', '04'=>'April', '05'=>'May', '06'=>'June', '07'=>'July', '08'=>'August', '09'=>'September', '10'=>'October', '11'=>'November', '12'=>'December'); $ds = array('01'=>1, '02'=>2, '03'=>3, '04'=>4, '05'=>5, '06'=>6, '07'=>7, '08'=>8, '09'=>9, '10'=>10, '11'=>11, '12'=>12, '13'=>13, '14'=>14, '15'=>15, '16'=>16, '17'=>17, '18'=>18, '19'=>19, '20'=>20, '21'=>21, '22'=>22, '23'=>23, '24'=>24, '25'=>25, '26'=>26, '27'=>27, '28'=>28, '29'=>29, '30'=>30, '31'=>31); if ($y0==0) $y0 = date('Y')-1; if ($y1==0) $y1 = date('Y')+5; $ys = array(); for ($i=$y0; $i<=$y1; $i++) $ys[]=$i; $code = ''; $code .= "\n"; $code .= "\n"; $code .= "\n"; return $code; } function sel_hi($hh='hor', $mm='min', $selected='', $class='') { $cm = -1; $ch = -1; if ($selected!='') { $cm = date('i', $selected); $ch = date('H', $selected); } $code = "\n\n"; return $code; } function sel_yyyy($name='yer', $selected='', $top='- Year -', $extra='', $start='', $end='') { $cy = ''; if (strlen($selected)==4) $cy = $selected; if (strlen($selected)>4) $cy = date('Y', $selected); if ($start=='') $start = date('Y')-1; if ($end =='') $end = date('Y')+5; $ys = array(); for ($i=$start; $i<=$end; $i++) $ys[]=$i; $code = ''; $code .= "\n"; return $code; } function sel_mm($name='mon', $selected='', $top='- Month -', $extra='') { $code = "\n"; return $code; } ?> $error"); } ?> array(),'msg'=>array()); var $fields = Array('name'=>array(),'js'=>array('hed'=>array(),'msg'=>array()),); var $man = Array(); var $nrf = 0; function jsValid($form='form1') { $this->form = $form; $this->func['hed'][]='minSize'; $this->func['msg'][]='Please enter at least &1 characters.'; $this->func['hed'][]='isNull'; $this->func['msg'][]='The field must be null'; $this->func['hed'][]='notNull'; $this->func['msg'][]='This field is required'; $this->func['hed'][]='isSNull'; $this->func['msg'][]='Please select a value'; $this->func['hed'][]='maxSize'; $this->func['msg'][]='The size of the value cannot be greater than &1'; $this->func['hed'][]='eqSize'; $this->func['msg'][]='The size of the value must be &1'; $this->func['hed'][]='minVal'; $this->func['msg'][]='The value must be greater than &1'; $this->func['hed'][]='maxVal'; $this->func['msg'][]='The value must be smaller than &1'; $this->func['hed'][]='betVal'; $this->func['msg'][]='The value must be greater than &1 and less than &2'; $this->func['hed'][]='eqVal'; $this->func['msg'][]='The value must be &1'; $this->func['hed'][]='neqVal'; $this->func['msg'][]='The value must not be &1'; $this->func['hed'][]='teqVals'; $this->func['msg'][]='The values must be equal'; $this->func['hed'][]='isMail'; $this->func['msg'][]='Please enter a valid email address'; $this->func['hed'][]='isImage'; $this->func['msg'][]='Only JPG and PNG files are accepted'; $this->func['hed'][]='eqs'; $this->func['msg'][]='Please enter &1 characters'; } function addf($names, $valid='notNull', $error='') { $names = explode(',',$names); foreach ($names as $name) { $this->fields['name'][] = $name; $this->fields['valid'][] = $valid; $this->fields['error'][] = $error; } } function addm($text) { $this->man[]=$text; } function show($include_js=1,$echo_return=1) { global $base_url; $func_name = "check_".$this->form; $script = "\r\n\n"; if ($include_js==1) $script .= ""; if ($echo_return==1) echo $script; else return $script; } } ?> array(),'msg'=>array()); var $fields = Array('name'=>array(),'js'=>array('hed'=>array(),'msg'=>array()), 'captn'=>array()); var $man = Array(); var $nrf = 0; function form_valid($form='form1') { $this->form = $form; $this->func['hed'][]='minSize'; $this->func['msg'][]='Please enter at least &1 characters.'; $this->func['hed'][]='isNull'; $this->func['msg'][]='The field must be null'; $this->func['hed'][]='required'; $this->func['msg'][]='Please enter a value for {caption}'; $this->func['hed'][]='isSNull'; $this->func['msg'][]='Please select a value'; $this->func['hed'][]='maxSize'; $this->func['msg'][]='The size of the value cannot be greater than &1'; $this->func['hed'][]='eqSize'; $this->func['msg'][]='The size of the value must be &1'; $this->func['hed'][]='minVal'; $this->func['msg'][]='The value must be greater than &1'; $this->func['hed'][]='maxVal'; $this->func['msg'][]='The value must be smaller than &1'; $this->func['hed'][]='betVal'; $this->func['msg'][]='The value must be greater than &1 and less than &2'; $this->func['hed'][]='eqVal'; $this->func['msg'][]='The value must be &1'; $this->func['hed'][]='neqVal'; $this->func['msg'][]='The value must not be &1'; $this->func['hed'][]='teqVals'; $this->func['msg'][]='The values must be equal'; $this->func['hed'][]='isMail'; $this->func['msg'][]='Please enter a valid email address'; $this->func['hed'][]='isImage'; $this->func['msg'][]='Only JPG and PNG files are accepted'; } function addf($names, $valid='notNull', $error='', $captn='') { $names = explode(',',$names); foreach ($names as $name) { $this->fields['name'][] = $name; $this->fields['valid'][] = $valid; $this->fields['error'][] = $error; $this->fields['captn'][] = $captn; } } function addm($text) { $this->man[]=$text; } function show($include_js=1,$echo_return=1) { global $base_url; $func_name = "check_".$this->form; $script = "\n\n"; if ($include_js==1) $script .= ""; if ($echo_return==1) echo $script; else return $script; } } ?> array(), 'td2' => array()); var $td1extra = ''; var $td2extra = ''; var $fields = array('name'=> array(), 'code' => array(), 'type' => array()); var $jsvalid = array('field' => array(), 'valid' => array(), 'ermsg' => array(), 'captn' => array()); var $jsvalids = ''; var $js_m = array(); var $jsv = 0; var $gened_tr = 0; var $title = ''; var $field_wid = 230; var $enctype = ''; var $sub_val = 'Submit'; var $cnc_val = 'Cancel'; var $cnc_loc; var $last_tr; var $submitted = 0; function form($name, $title='', $width='100%', $action='', $method='POST') { global $_SERVER, $_POST, $_GET; if ($action=='') $action = $_SERVER['PHP_SELF']; $this->name = $name; $this->title = $title; $this->action = $action; $this->method = $method; $this->width = $width; $this->cnc_loc = $_SERVER['PHP_SELF']; if ($this->method=='POST') $this->submitted = ((isset($_POST["fsbm_{$this->name}"]))?1:0); if ($this->method=='GET') $this->submitted = ((isset($_GET["fsbm_{$this->name}"]))?1:0); $this->ah("fsbm_{$this->name}",1); } function add_js($name, $caption, $validation) { if ($validation=='') return; $validation = explode('~', $validation); foreach ($validation as $cv) { $cv = explode('|', $cv); $msg = (count($cv)>1) ? $cv[1] : ''; $this->jsvalid['field'][] = $name; $this->jsvalid['valid'][] = $cv[0]; $this->jsvalid['ermsg'][] = $msg; $this->jsvalid['captn'][] = $caption; $this->jsv=1; } } function add_jsm($text) { $this->js_m[] = $text; $this->jsv=1; } function get_vars($ignore='') { $ignore = explode(',', $ignore); $ignore[] = "fsbm_{$this->name}"; $str = array(); for ($i=0; $ifields['name']); $i++) { $cname = $this->fields['name'][$i]; if (!in_array($cname, $ignore)) $str[] = $cname; } $str = implode(',', $str); return $str; } function ah() { $na = func_num_args(); $alist = func_get_args(); $cx=0; $name = ''; $value = ''; foreach ($alist as $arg) { if ($cx==0) $name = $arg; if ($cx==1) { $this->fields['name'][] = $name; $this->fields['code'][] = ""; $this->fields['type'][] = 'hidden'; $this->fields['text'][] = ''; } $cx=1-$cx; } } // ADD 2-COLUMN TEXT function t1($text) { $this->fields['code'][] = $text; $this->fields['text'][] = ''; $this->fields['type'][] = 'text1'; } function t2($text1, $text2) { $this->fields['code'][] = $text2; $this->fields['text'][] = $text1; $this->fields['type'][] = 'text2'; } // ADD TEXTBOX function at($caption, $name, $value='', $validation='', $class='input', $extra='', $width='') { if ($width == '') $width = $this->field_wid; $this->fields['name'][] = $name; $this->fields['code'][] = ""; $this->fields['type'][] = 'text'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($name, $caption, $validation); } // ADD PASSWORD FIELD function ap($caption, $name, $value='', $validation='', $class='input', $extra='', $width='') { if ($width == '') $width = $this->field_wid; $this->fields['name'][] = $name; $this->fields['code'][] = ""; $this->fields['type'][] = 'text'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($name, $caption, $validation); } // ADD FILE UPLOAD function af($caption, $name, $validation='', $class='input', $extra='', $width='') { if ($width == '') $width = $this->field_wid; $this->fields['name'][] = $name; $this->fields['code'][] = ""; $this->fields['type'][] = 'text'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($name, $caption, $validation); $this->enctype = ' enctype="multipart/form-data"'; } // ADD TEXTAREA function ata($caption, $name, $value='', $validation='', $class='input', $extra='', $width='', $height='85') { if ($width == '') $width = $this->field_wid; $this->fields['name'][] = $name; $this->fields['code'][] = ""; $this->fields['type'][] = 'textarea'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($name, $caption, $validation); } // ADD SELECT - ARRAY function as_arr($caption, $name, $array, $value='', $validation='', $default='- Select -', $class='input', $extra='', $width='') { if ($width == '') $width = $this->field_wid+7; $this->fields['name'][] = $name; $this->fields['code'][] = sel_arr($name, $width, $array, $value, $default, $class, $extra); $this->fields['type'][] = 'select'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($name, $caption, $validation); } // ADD SELECT - DATABASE function as_db($caption, $name, $table, $field1, $field2, $where='', $value='', $validation='', $default='- Select -', $class='input', $extra='', $width='') { if ($width == '') $width = $this->field_wid+7; $this->fields['name'][] = $name; $this->fields['code'][] = sel_db($name, $table, $field1, $field2, $where, $value, $default, $class, $extra, $width); $this->fields['type'][] = 'select'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($name, $caption, $validation); } // ADD SELECT - DATABASE function as_db1($caption, $name, $table, $field1, $field2, $where='', $value='', $validation='', $default='- Select -', $class='input', $extra='', $width='') { if ($width == '') $width = $this->field_wid+7; $this->fields['name'][] = $name; $this->fields['code'][] = sel_db1($name, $table, $field1, $field2, $where, $value, $default, $class, $extra='', $width); $this->fields['type'][] = 'select'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($name, $caption, $validation); } // ADD SELECT - ARRAY function as_mdY($caption, $mm='mon', $dd='day', $yy='yer', $selected='', $validation='', $class='input') { $this->fields['name'][] = "$mm,$dd,$yy"; $this->fields['code'][] = sel_mdY($mm, $dd, $yy, $selected, $class); $this->fields['type'][] = 'select'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($mm, 'Month', $validation); $this->add_js($dd, 'Day', $validation); $this->add_js($yy, 'Year', $validation); } // ADD SELECT - YEAR function as_yyyy($caption, $yy='yer', $selected='', $validation='', $start='', $end='', $top='- Year -', $extra='', $class='input') { if ($start=='') $start = date('Y')-5; if ($end=='') $end = date('Y')+5; $this->fields['name'][] = $yy; $this->fields['code'][] = sel_yyyy($yy, $selected, $top, $extra, $start, $end); $this->fields['type'][] = 'select'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($yy, 'Year', $validation); } // ADD SELECT - MONTH function as_mm($caption, $mm='mon', $selected='', $validation='', $top='- Month -', $extra='', $class='input') { $this->fields['name'][] = $mm; $this->fields['code'][] = sel_mm($mm, $selected, $top, $extra); $this->fields['type'][] = 'select'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($mm, 'Month', $validation); } // ADD SELECT - ARRAY function as_hi($caption, $hh='hor', $mm='miny', $selected='', $validation='', $class='input') { $this->fields['name'][] = "$hh,$mm"; $this->fields['code'][] = sel_hi($hh, $mm, $selected, $class); $this->fields['type'][] = 'select'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); $this->add_js($hh, 'Hour', $validation); $this->add_js($mm, 'Minute', $validation); } // ADD CHECKBOX - DB function as_ck($caption, $name, $table, $field1, $field2, $where='', $value='', $validation='') { $this->fields['name'][] = "$name"; $this->fields['code'][] = sel_ck($name, $table, $field1, $field2, $where, $value); $this->fields['type'][] = 'checkbox'; $this->fields['text'][] = $caption.':'.(($validation!='')?' *':''); } // ADD YES-NO function ayn($caption, $name, $value='') { if ($value=='') $value='Y'; $value = strtoupper($value); $ck_yes = ($value=='Y')?'checked':''; $ck_no = ($value=='N')?'checked':''; $this->fields['name'][] = $name; $this->fields['code'][] = " Yes     No"; $this->fields['type'][] = 'radio'; $this->fields['text'][] = $caption.':'; } // ADD TRUE-FALSE function atf($caption, $name, $value='') { if ($value=='') $value='N'; $value = strtoupper($value); $ckd = ($value=='Y')?'checked':''; $this->fields['name'][] = $name; $this->fields['code'][] = ""; $this->fields['type'][] = 'checkbox'; $this->fields['text'][] = $caption.':'; } function gen_tr() { for ($i=0; $ifields['type']); $i++) { if ($this->fields['type'][$i]=='text1') { $this->tr['td1'][] = "td1extra}>{$this->fields['code'][$i]}"; $this->tr['td2'][] = ""; } elseif ($this->fields['type'][$i]=='text2') { $this->tr['td1'][] = "td1extra}>{$this->fields['text'][$i]}"; $this->tr['td2'][] = "td1extra}>{$this->fields['code'][$i]}"; } elseif ($this->fields['type'][$i]!='hidden') { $this->tr['td1'][] = "td1extra}>{$this->fields['text'][$i]}"; $this->tr['td2'][] = "td2extra}>{$this->fields['code'][$i]}"; } } $this->last_tr = "\n\n
sub_val}\">    "; if ($this->cnc_val!='') $this->last_tr .= "cnc_val}\" onclick=\"location.replace('{$this->cnc_loc}');\">\n"; $this->gened_tr = 1; } function show() { if ($this->gened_tr==0) $this->gen_tr(); // JavaScript validation $this->jsvalids = ''; if ($this->jsv==1) { $cj = new form_valid($this->name); for ($i=0; $ijsvalid['field']); $i++) $cj-> addf($this->jsvalid['field'][$i], $this->jsvalid['valid'][$i], $this->jsvalid['ermsg'][$i], $this->jsvalid['captn'][$i]); foreach ($this->js_m as $cjsm) $cj->addm($cjsm); $this->jsvalids = $cj->show(1,0); } $this->html .= $this->jsvalids; if ($this->title!='') $this->html .= table_header($this->title, $this->width); $this->html .= "\n\n
name\" action=\"$this->action\" method=\"$this->method\" ".(($this->jsv==1)?"onsubmit=\"return check_{$this->name}()\"":'')."$this->enctype>\n"; // add hidden fields for ($i=0; $ifields['type']); $i++) if ($this->fields['type'][$i] == 'hidden') $this->html .= $this->fields['code'][$i]."\n"; // add TR's $this->html .= "width}\">\n"; for ($i=0; $itr['td1']); $i++) $this->html .= "\n{$this->tr['td1'][$i]}\n{$this->tr['td2'][$i]}\n\n"; $this->html .= $this->last_tr; $this->html .= "
"; if ($this->title!='') $this->html .= table_footer(); return $this->html; } } ?>