<?php
//模組反安裝移除項目資料
function neillibrary_deletefunction_itemall($modulesid=""){
//刪除項目
$dbneme="neillibrary_dateitem";
$where="  where   modulesid = '".$modulesid."'   order by  itemid  DESC";  //where數值 
$delettimeArr=databasetablewhile($dbneme,$where);  
foreach($delettimeArr as $key=> $val){	
//刪除neillibrary_dateitem資料
deletefunction($where=" where `itemid` = '".$delettimeArr[$key]['itemid']."'",$DBname="neillibrary_dateitem");
}
}

	
	
//項目下拉選單
function neilalbum_dateitemenu($modulesid="",$oid="",$dateval="",$menutype="",$menuurl="",$concat=""){
$dbneme="neillibrary_dateitem";
$where="  where `modulesid` = '".$modulesid."'  && `enable` = '1'  order by  btnsort  ASC";  //where數值
$dateitemoption=databasetablewhile($dbneme,$where); 
foreach($dateitemoption as $key=> $val){
if(empty($menutype)){	
$dateval['itemenuoption'].=optionselect($dataid=$dateitemoption[$key]['itemid'],$optionname=$dateitemoption[$key]['itemtext'],$oid,$value=$dateitemoption[$key]['itemid']);
}else{
$dateval['itemenuoption'].=optionselect($dataid=$dateitemoption[$key]['itemid'],$optionname=$dateitemoption[$key]['itemtext'],$oid,$value=$menuurl.$dateitemoption[$key]['itemid'].$concat);
}
}
return $dateval;

}
	
	
	
	
	
	
//項目管理	
function neillibrary_dateitem_table(){	
 global $xoopsDB,$xoopsModule,$itemid;	
 

if(empty($itemid)){  //新增
$neillibrary_dateitem_table_form['7']="<h3>"._MA_DATEITEMPHP02."</h3>";
//POST類型
$neillibrary_dateitem_table_form['9']="<input type='hidden' name='op' value='dateitem_save_news'>";
$neillibrary_dateitemList['enable']=1;

}else{  //編輯
$neillibrary_dateitem_table_form['7']="<h3>"._MA_DATEITEMPHP05."</h3>";
//開啟neil_address資料表
//批次轉換htmlspecialchars
$neillibrary_dateitemList=htmlspecialcharsbatch($allowvar=array("itemtext"),$eachvar=moduledb($dbneme="neillibrary_dateitem",$where="  where `itemid` = '".$itemid."'  && `modulesid` = '".$xoopsModule->getVar("dirname")."'   "));



//POST類型
$neillibrary_dateitem_table_form['9']="<input type='hidden' name='op' value='dateitem_updated'><input type='hidden' name='itemid' value='".$neillibrary_dateitemList['itemid']."'>";
}



//項目名稱
$neillibrary_dateitem_table_form['0']=inputtext($class="",$name="itemtext",$value="".$neillibrary_dateitemList['itemtext']."",$placeholder=""._MS_SHARED21._MA_DATEITEMPHP04."");
//是否啟用
$neillibrary_dateitem_table_form['1']=radioinline($class="",$name="enable",$text=array(_MS_SHARED04,_MS_SHARED03),$checked="".$neillibrary_dateitemList['enable'].""); 


//TABLE區塊
$neillibrary_dateitemArr=databasetablewhile($dbneme="neillibrary_dateitem",$where="   where `modulesid` = '".$xoopsModule->getVar("dirname")."' order by  btnsort  ASC");  

	
foreach($neillibrary_dateitemArr as $key=> $val){	

$td['enable']=enable($envar=$neillibrary_dateitemArr[$key]['enable']);

if($neillibrary_dateitemArr[$key]['itemid']==$itemid) $colorstyle[$key]="color1";
	
$neillibrary_dateitem_table_form['6'].="<tr class='deletetr{$key} tr ".$colorstyle[$key]."' id='".$neillibrary_dateitemArr[$key]['itemid']."'  >
        <td>".$neillibrary_dateitemArr[$key]['itemid']."</td>
        <td>".$neillibrary_dateitemArr[$key]['itemtext']."</td>
        <td>".$td['enable']."</td>
        <td><a href='" .XOOPS_URL. "/modules/". $xoopsModule->getVar("dirname")."/admin/dateitem.php?itemid=".$neillibrary_dateitemArr[$key]['itemid']."'  class='btn btn-sm btn-info  active'>"._MS_SHARED08."</a>   
     <a id='deletebotton{$key}' type='button' mane='156,".$neillibrary_dateitemArr[$key]['itemid'].",".$neillibrary_dateitemArr[$key]['itemtext'].","._MA_DATEITEMPHP06.",,neillibrary_dateitem,".$xoopsModule->getVar("dirname").",,itemid'  class='btn btn-sm btn-danger   deleteeach'>"._MS_SHARED09."</a>     
     </tr>";
}

 
$neillibrary_dateitem_table_form['5']="
<table class='table sortable basictable' name='164,".$xoopsModule->getVar("dirname").",2,".$pageid.",".$typesid.",".$sortid.",".$suid.",neillibrary_dateitem,itemid'>
    <thead>
      <tr>
      
        <th style='width: 6%'>"._MS_SHARED06."</th>	
        <th style='width: 35%'>"._MA_DATEITEMPHP04."</th>
              <th style='width: 10%'>"._MS_SHARED10."</th>  
                 <th style='width: 12%'>"._MS_SHARED07."</th>  
      </tr>
    </thead>
    <tbody>
   ".$neillibrary_dateitem_table_form['6']."
     
    </tbody>
  </table>
   <span id='helpBlock' class='help-block text-center'>"._MS_SHARED143."</span>	   		
";
 
$main.="

	<div class='container'>
  <h2>"._MA_DATEITEMPHP01."&nbsp;<label for='sel2'>project management</label>&nbsp; <a class='btn btn-warning active'  href='" . XOOPS_URL . "/modules/".$xoopsModule->getVar("dirname")."/admin/dateitem.php'>"._MS_SHARED25."</a></h2>	
    <div class='row'>
    ";
//左邊區塊
$main.="
<form method='post'  action='{$_SERVER['PHP_SELF']}' >	
  <div class='col-md-4'>".$neillibrary_dateitem_table_form['7']."<hr />
 
 

 

<div  class='form-group'>	
<label class='col-sm-3 control-label'>"._MA_DATEITEMPHP04."</label>
 		 <div class='col-sm-9'> ".$neillibrary_dateitem_table_form['0']." 
  	   <br /></div> 
 	 	</div> 	

	
 	
<div  class='form-group'>	
<label class='col-sm-3 control-label'>"._MS_SHARED44."</label>
 		 <div class='col-sm-9'> ".$neillibrary_dateitem_table_form['1']." 
  	   <br /><br /><br /></div> 
 	 	</div> 				   	  
   

  	  
 
  ".$neillibrary_dateitem_table_form['9']."	
 <button  type='submit' class='btn btn-primary btn-lg btn-block button'>"._MS_SHARED01."</button>
  	  
  	  </div>
   </form> 	  
  	  
    ";
//右邊區塊
$main.="

  <div class='col-md-8'><h3>"._MA_DATEITEMPHP03."</h3><hr />
  	  ".$neillibrary_dateitem_table_form['5']."
    	  </div>
  	  	  

  	     	 
    ";
$main.="
</div>

<script src='".XOOPS_URL."/modules/neillibrary/js/tpl-jquery/jquery-ui/jquery-ui.js'></script>
<script>var itemsvar='.tr'; dragmenufunction();</script>  	  
<script>
    $('.basictable').basictable({
        breakpoint: 640,
        orceResponsive: true,
    });
</script> 
	";
 
if(!empty(modulesmidvar($modulesid="xLanguage",$var="isactive"))){
$main.="<script>neillibrary_llanguagetext(afterid='#buttonbar_mod');</script>";
}
	


  return $main;
}

//編輯項目
function neillibrary_dateitem_updated(){
 global $xoopsDB,$itemid;	
 
//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar="",$postvar=$_POST,$sqltags=array("itemtext"));  
 
$setvar="set itemtext='{$_POST['itemtext']}',enable='{$_POST['enable']}'  where itemid='".$itemid."'";
update($dbname="neillibrary_dateitem",$set=$setvar);  
 

}


//新增項目
function neillibrary_dateitem_save_news(){
 global $xoopsDB,$xoopsModule;	

//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar="",$postvar=$_POST,$sqltags=array("itemtext"));  
 
 
$valuesvar="
(itemtext,modulesid,btnsort,enable) 
values(
'{$_POST['itemtext']}','".$xoopsModule->getVar("dirname")."','0','{$_POST['enable']}')";	  
insert($dbname="neillibrary_dateitem",$values=$valuesvar);


}




?>