<?php
include_once XOOPS_ROOT_PATH . "/modules/neothemesadmin/block_function.php";
include_once XOOPS_ROOT_PATH . "/modules/neothemesadmin/function.php";

function picturemove_block_show($options){
global $xoopsDB, $xoTheme,$xoopsModule;	

$xoTheme->addStylesheet(XOOPS_URL.'/modules/neillibrary/js/OwlCarousel/css/owl.carousel2.css');	
$xoTheme->addStylesheet(XOOPS_URL.'/modules/neillibrary/js/OwlCarousel/css/owl.theme.css');		


switch ($options[2]){	
case "0":  	  	 //最新
$order="order by  sortid  DESC";	
break; 
case "1":      //排序
$order="order by sortidsort  ASC";	
break; 
case "2":      //隨機
$order="order by RAND()";
break; 



}

$img_date = date("H:i:s");
$xoops_theme = $GLOBALS['xoopsConfig']['theme_set'];


//權限檢查
$DBdata=neothemesadmin_permissioncheck($where="  where `of_sortid` = '0' && `categoryid` = '".$options[0]."'  &&  `enable` = '1' ".$order." ",$dbneme1="neoblockmenubutton",$dbneme2="neoblockmenubutton",$total=$options[1]);


$dbneme="neoblockmenubutton";  //資料表名稱
$where="  ".$DBdata."  &&  `categoryid` = '".$options[0]."'  ".$order."  limit ".$options[1]."";		
	
$neoblockmenusortArr=databasetablewhile($dbneme,$where); 
$block['picturemove']=$neoblockmenusortArr;
foreach($neoblockmenusortArr as $key=> $val){
$block['picturemove'][$key]['buttonimg']="uploads/neothemesadmin/".$neoblockmenusortArr[$key]['buttonimg'].".png?state=".$img_date."";	 
$target=pagemethod($types=$neoblockmenusortArr[$key]['target']);
$block['picturemove'][$key]['target']=$target['way'];
}


if(check_mobile()){
$block['imgQuantity']=$options[5];
}else{
$block['imgQuantity']=$options[4];
}


 //  $themefolder=neil_modulessetting($modulesid="neothemesadmin",$total="");	
    $block['bid']=$options[3];
    $block['menuadmin']=_MB_MENUADMINBUTTON;
    $block['menusortid']=$options[0];  
  //  $block['themefolder']=$themefolder['themefolder'];   

   
   

    return $block;
}

//區塊編輯函式
function picturemove_block_edit($options)
{
  global $xoopsDB, $xoTheme;
  
	
neillibrary_bootstrap3blockscss($typevar="3");	

//取得變數
$op=isset($_REQUEST['op'])?$_REQUEST['op']:"";
$bid=isset($_REQUEST['bid'])?$_REQUEST['bid']:"";
	
$bid=bidnamefunction($op=$op,$bid=$bid);
  
$dbneme="neoblockmenusort";
$where="  where  `enable` = '1' && `radiogstyle` = 'img' order by  sorting  ASC";  //where數值 	
$sortoption=databasetablewhile($dbneme,$where);  
//下拉選單(分類)
foreach($sortoption as $key=> $val){
$options_table_form['0'].=optionselect($dataid=$sortoption[$key]['sortid'],$optionname=$sortoption[$key]['sorttitle'],$oid=$options[0],$value=$sortoption[$key]['sortid'],$id="");
}  



//顯示顯示按鈕數量
$options_table_form['1']=inputtext($class="",$name="options[1]",$value="".$options[1]."",$placeholder="",$id="");	
 
  	    
//排列方式
$options_table_form['2']=radioinline($class="",$name="options[2]",$text=array(_MB_SHOWTHENUMBER3,_MB_SHOWTHENUMBER4,_MB_SHOWTHENUMBER5),$checked=$options[2]); 

//電腦版橫列顯示數量
$options_table_form['3']=inputtext($class="",$name="options[4]",$value="".$options[4]."",$placeholder="",$id="");	

//手機版橫列顯示數量
$options_table_form['4']=inputtext($class="",$name="options[5]",$value="".$options[5]."",$placeholder="",$id="");	
  


    $form = "{$option['js']}
  <table  class='table'>
  <tr><th>
  " . _MB_CHOOSECATEGORY. "
  </th><td>
	<select size='1'  name='options[0]' id='options[0]'  >
".$options_table_form['0']."											
	</select>
  </td></tr> 	  
  	  
  <tr><th>
  " . _MB_SHOWTHENUMBER. "
  </th><td>
".$options_table_form['1']."
  </td></tr>
   <tr><th>
  " . _MASLIDINGMENU02. "
  </th><td>
".$options_table_form['2']."
  </td></tr>
  <input type='hidden' name='options[3]'  value='".$bid."'> 
	  
  <tr><th>
  " . _MASLIDINGMENU03. "
  </th><td>
".$options_table_form['3']."
  </td></tr> 	  	     	  
   <tr><th>
  " . _MASLIDINGMENU04. "
  </th><td>
".$options_table_form['4']."
  </td></tr>  
  </table>
	  
  ";
    return $form;
}
