?
Path : /home/admin/public_html/modules/users/ |
Current File : /home/admin/public_html/modules/users/com_category.php |
<? class category extends backoff { function get_sub_cat($parent,$option){ global $user_login; $u=$user_login['ID']; $access=$user_login['Access']; if($parent!=''){ $option.=" "; } $rs=$this->Query("SELECT * FROM usertype where usertype_parent='$parent'"); while($arr=mysql_fetch_array($rs)){ $id=$arr['usertype_id']; $name=$arr['usertype_name']; if($parent!=''){ echo"<OPTION VALUE=\"$id\">$option $name</OPTION>"; }else{echo"<OPTION VALUE=\"$id\">-$name</OPTION>"; } $this->get_sub_cat($arr['usertype_id'],$option); }//end while } function select_multi_cat(){ ?> <br> <script> function jsLink(link){ var id=document.webForm.parent_group; if(id.selectedIndex==-1){ alert('Select Parent Group'); id.focus(); }else{ location.href=link; } }//end function function swapEditPage() { var selector=document.getElementById('parent_group'); //alert(selector.options[selector.selectedIndex].value); alert(document.getElementById('Edit').location.href="";); } </script> <table width="99%" class="table_data"><tr><td><br> <form method="post" name="webForm" action="<?echo"$PHPSELF?mod=user&ac=new_category";?>"> <table width="800" height="102" class="Table_action" > <tr> <th width="800" height="21">Group</th> </tr> <tr> <td width="800" height="77" align="center"> <table width="800" height="400" border=0> <tr> <td width="200" height="13" valign="top"> <b>ชื่อหมวดหมู่ทั้งหมด</b><br><br> จากรายการเมื่อคุณเลือก<br> หมวดหมู่ หมวดหมู่นั้นจะ<br> เป็น Parent ของหมวดหมู่ที่<br> คุณกำลังจะเพิ่ม คลิกที่ เพิ่มหมวดหมู่<br> </td> <td width="200" height="13" valign=top> <SELECT MULTIPLE id="parent_group" name="parent_group" style="width:200px;height:200px;" id="parent" class="backend_inputbox" onchange="swapEditPage()"> <option value=""> หมวดหมู่หลัก </option> <? $space=" "; $this->get_sub_cat($parent='',$space); ?> </SELECT> </td> <td width="400" valign=top> <IFRAME id="Edit" SRC="modules/users/com_edit_category.php" width="350" height="370" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" background="#FFF2CF"> </IFRAME> </td> </tr> <tr> <td width="50" height="13"></td> <td width="300" height="13"><input type="button"value=" เพิ่มหมวดหมู่ " onclick="jsLink('admin.php?mod=user&ac=new_group&parent='+document.webForm.parent.value)"> | <input type="button" value=" แก้ไข" onclick="jsLink('admin.php?mod=user&ac=edit_cat&cat_id='+document.webForm.parent.value)"> | <input type="button" value=" ลบ " onclick="if(document.webForm.parent.selectedIndex!=-1){if(confirm('ยืนยันการลบ')){jsLink('admin.php?mod=user&ac=del_cat&id='+document.webForm.parent.value)}}else{alert('Select Category');}"> </td> <td width="200" height="13"></td> </tr> </table> </td> </tr> <tr> <th width="450" height="21"></th> </tr> </table> </form> </td></tr></table> <? }//end listData function Search(){ $output.="<table width=\"350\" height=\"20\"><form method=\"GET\" action=\"$link\" name=\"search\"><tr><td width=\"100%\"> <input type='hidden' name='option' value='search'> <input type='hidden' name='page' value='1'> <select size=\"1\" name=\"key\">"; $keysearch=array('name'=>"Category Name"); foreach($keysearch as $key=>$value){ if($_GET['key']==$key){ $output.="<option value=\"$key\" selected>$value</option>"; }//end if $_GET['key'] else{ $output.="<option value=\"$key\">$value</option>"; } } if($_GET){ foreach ($_GET as $key => $value){ if($key != "key" && $key != "keyword" && $key !="search"&&$key!="page"){ $output.= "<input type='hidden' name='$key' value='$value'>\n"; } } } $output.="</select>"; if($_GET['keyword']!=""){ $output.="<input type='textbox' name='keyword' size=\"20\" value=".$_GET['keyword'].">"; }else{ $output.="<input type='textbox' name='keyword' size=\"25\">"; } $output.="<input type='submit' value=\"search\" size=10>"; $output.="</td></tr></form></table>"; return $output; } function listData($table,$condition,$orderby,$sort,$chksort,$header_txt,$header_td_width,$link){ $this->_header_txt=$header_txt; $output.="<table width=\"99%\" class=table_data><tr><td>"; $output.="<table width=\"100%\" height=\"1\" class=table_option> <tr> <td width=\"350\" align=\"left\" height=\"15\"></td> <td width=\"250\" align=\"left\" height=\"15\"></td> <td width=\"150\" align=\"left\" height=\"15\">".$this->Search()."</td> </tr> <tr></table>"; //$output=$this->PerPageDropList($link); foreach($header_txt as $table_colum => $header_txt_name){ if($orderby==$header_txt_name){$orderby2="binary $table_colum";} } //start $check sort if($chksort=='Yes'){ if($sort=="Min2Max"){ $sort="Max2Min"; $sort2="ASC";$sort3=$sort; }else if($sort=="Max2Min"){ $sort="Min2Max"; $sort2="DESC";$sort3=$sort; } }else{ if($sort=="Min2Max"){ $sort="Min2Max";$sort2="ASC";$sort3="Max2Min"; }else if($sort=="Max2Min"){ $sort="Max2Min";$sort2="DESC";$sort3="Min2Max"; } } //end if check chsort='Yes' if($_GET['option']=="search"){ $key=$_GET['key'];$keyword=$_GET['keyword']; $search=" and $key LIKE '%$keyword%'"; $condition=$search; } if($orderby2==""){$orderby2="parent";$sort2='ASC';} $this->_Start = ($this->_Page * $this->_Limit) - $this->_Limit; $sql= "SELECT * FROM $table $condition ORDER BY $orderby2 $sort2 "; $this->setQuery($sql); $result=$this->QueryReturn(); $this->_total=$this->NumRows(); $this->_Next_Page = ceil($this->_total/$this->_Limit); $sql.= " LIMIT " . $this->_Start . "," . $this->_Limit; $this->setQuery($sql); $result2=$this->QueryReturn(); $this->PageNavigator(); //set output table data Header Colum $link2=$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&ac=deltrick"; $output.=" <table width=\"100%\" class=\"Table_backend\"><tr>"; $output.="<form method=\"POST\" action=\"$link2\" name=\"backend_form\" >"; $output.="<th width=\"20\"></th>"; $i=0; if($sort2=="ASC"){$sortgif="sort_d.gif";}else{$sortgif="sort_u.gif";} $link_sort=$PHPSELF."?"; if($_GET){ foreach ($_GET as $key => $value){ if($key != "orderby"&&$key!="sort"&&$key!="chksort"){ $link_sort.="$key=$value&"; } } } foreach($header_txt as $table_colum => $header_txt_name){ if($orderby==$header_txt_name){ $output.="<th width=$header_td_width[$i] ><a href=\"$link_sort&orderby=$header_txt_name&sort=$sort3&chksort=Yes\" title=\"Sort $header_txt_name by $sort3\"><img src=\"images/$sortgif\" border=0>$header_txt_name</a></th>"; }else{ $output.="<th width=$header_td_width[$i] ><a href=\"$link_sort&orderby=$header_txt_name&sort=$sort3&chksort=Yes\" title=\"Sort $header_txt_name Order $sort3\">$header_txt_name</a></th>"; } $i++; }//end forsearch $output.="<th width=\"20\"> </th><th width=\"20\"> </th>"; $output.="</tr>"; $data_colum=Array(); $tooltip=Array(); $count=0; while($arr=mysql_fetch_array($result2)) { $id=$arr['id']; $msg="<br><img src=$_Config_image_bookstore_path/$picture width=100 border=0>"; $ChkColor=$this->_total -$count; if($ChkColor%2!=0){$color="#f8f8f9";}else{$color="#f3f3f3";} $j=0; foreach($header_txt as $colum => $key){ $data_colum[$j]=$arr[$colum]; $j++; }//end foreach $link=$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; $output.="<tr bgcolor=\"$color\">"; $output.="<td width=\"20\"></td>"; for($i=0;$i<count($data_colum);$i++){ $output.="<td width=\"$header_td_width[$i]\" height=\"20\">"; if($i==0){ $r=chang_field($this,'blog_cat','id','name',$data_colum[$i]); if($r==''){$output.='-';}else{$output.=$r;} }else if($i==1){ $output.="<a href=\"$PHPSELF?mod=data&m=$m&ac=edit_cat&cat_id=$id\">$data_colum[$i]</a></td>"; }else{ $output.="$data_colum[$i]</td>"; }//end if $i==1 } $link=$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&ac=del_cat&id=$id"; $comment="ยืนยันคำสั่งลบข้อมูล"; $alt="ลบข้อมูล"; $output.="<td width=\"20\"><a href=\"$PHPSELF?mod=data&m=$m&ac=edit_cat&cat_id=$id\">$data_colum[$i]<img src=\"images/bt_edit.png\" border=0 heith=15></a></td><td width=\"20\" >"; if($p==0){$output.=confirm_del($link,$comment,$alt);} $output.="</td>"; $count++; } $output.="</tr>"; $output.="</td></tr></form> </table>"; $output.="<table width=\"100%\" class=Table_backend border=0> <tr> <td width=\"1\" valign=\"top\" align=\"center\" height=\"15\" class=table_backend_bottom><img src=\"images/space.gif\" height=\"24\"></td> <td width=\"250\" align=\"left\" height=\"15\" class=table_backend_bottom>".$this->PageLink()."</td> <td width=\"250\" align=\"center\" height=\"15\" class=table_backend_bottom>".$this->total_record()."</td> <td width=\"250\" align=\"right\" height=\"15\" class=table_backend_bottom>".$this->PreNext()."</td> </tr></table> <table width=\"100%\" border=0> <tr><center> <td width=\"350\" align=\"left\" height=\"15\"></td> <td width=\"200\" align=\"right\" height=\"15\">".$this->set_per_page()."</td> <td width=\"150\" align=\"left\" height=\"15\">".$this->PerPageDropList()."</td> <td width=\"200\" align=\"right\" height=\"15\">".$this->jump2page()."</td> </tr> </table> "; $output.="</td></tr></table>";//end table class table_data return $output; }//end listData }//end class BackEndData ?>