<?php
//input物件
//text
function inputtext($class="",$name="",$value="",$placeholder="",$id="",$typeval="",$autocomplete="") {
	$typeval=empty($typeval) ? 'text' : $typeval;
	$inputtext="<input type='".$typeval."' id='".$id."' class='".$class." form-control' name='".$name."' autocomplete='".$autocomplete."'  value='".$value."' placeholder='".$placeholder."'  aria-label='".$placeholder."'>";
	return $inputtext;
}
//textarea
function inputtextarea($class="",$name="",$id="",$rows="",$cols="",$value="",$placeholder="") {
	$inputtextarea="<textarea aria-label='".$placeholder."' placeholder='".$placeholder."' class='".$class." form-control' name='".$name."'  id='".$id."' rows='".$rows."' cols='".$cols."'>".$value."</textarea>";
	return $inputtextarea;
}
//radio物件群組(0/1選項)
function radioinline($class="",$name="",$text="",$checked="",$id="",$disabled="") {
	$time_val=mt_rand(3,timedate($datevar="His"));	
	foreach($text as $key=> $val) {
		
		if($checked==$key) {
			$checkedtrue="checked=checked";
	    	//if(empty($id)){
	    	$for_name[$key]="for='".$time_val."_checked_".$key."'";
	     	$id_name[$key]="id='".$time_val."_checked_".$key."'";
	    	//} 
	    	
		}
		$radioinline.="<label id='".$id."' class='radio-inline' ".$for_name[$key]." >
      <input  ".$disabled." class='".$class."' type='radio' ' name='".$name."' ".$id_name[$key]."  ".$checkedtrue." value='".$key."'>".$val."
      </label>";
		unset($checkedtrue);
	}
	return $radioinline;
}



//radio物件單組(多選自訂$value)
function radioinlinelist($dataid="",$class="",$name="",$text="",$value="",$oid="",$id="") {
	$dataid==$oid ? $checkedtrue="checked='checked'": '';
	$time_val=mt_rand(3,timedate($datevar="His"));	
	if(empty($id)){
	$for_name[0]="for='".$time_val."_checked_".$value."'";
	$id_name[0]="id='".$time_val."_checked_".$value."'";
	}else{
	$id_name[1]="id='".$id."'";
	}
	$radioinline.="<label   ".$id_name[1]."  class='radio-inline' ".$for_name[0]." >
    <input   ".$id_name[0]."  class='".$class."'  type='radio' name='".$name."' ".$checkedtrue." value='".$value."'>".$text."
    </label>";
	unset($checkedtrue);
	return $radioinline;
}
//checkbox物件
function checkbox($dataid="",$name="",$value="",$optionname="",$oid="",$i="",$class="") {
	$dataid==$oid ? $checked="checked='checked'": '';
	if(!empty($i)) $for_box="for='checkbox".$i."'";
	$checkboxinline="<label ".$for_box."  class='".$class." checkbox-inline checkboxeach'><input id='checkbox".$i."' ".$checked."  type='checkbox' name='".$name."'  value='".$value."'>".$optionname."</label>";
	unset($checked);
	return $checkboxinline;
}
//option物件無URL
function optionselect($dataid="",$optionname="",$oid="",$value="",$id="") {
	$dataid==$oid ? $selected="selected='selected'": '';
	if(!empty($id)) {
		$idbix="id=".$id."";
	}
	$option="<option ".$idbix." ".$selected."   value=".$value."  data-id=".$dataid." >".$optionname."</option>";
	unset($selected);
	return $option;
}
//file物件
function typefile($multiple="",$name="",$id="",$class="",$label="") {
	if(!empty($multiple)) {
		$multiple='multiple';
	}
	$typefile="<input aria-label='".$label."' type='file' class='".$class." form-control' ".$multiple." name='".$name."' id='".$id."' >";
	return $typefile;
}
?>