<?php
    $conf_basedir	= "../../";	//相对主目录的位置
    $conf_where		= "admin";	//选择调用相应模块
    $directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
    include_once($conf_basedir."base.inc.php");
    checkAuth('32');	//判断登录和权限
    $tbl='block_img';
    include_once("block_pic_func.php");

	if ($actiontype=='del') 
    {  
        doact($actiontype,$actionid);
        echo "<script>alert('删除成功！');</script>";
    }


    $css="<link href='http://esfadmin.house365.com/script/css/autocomplete.css' rel='stylesheet' type='text/css' /><link href='http://esfadmin.house365.com/script/cms/cms_files/lz3.css' rel='stylesheet' type='text/css'>";
    $js = "<script type='text/javascript' src='http://esfadmin.house365.com/script/js/showpic.js'></script>
    <script type='text/javascript' src='http://esfadmin.house365.com/script/js/public.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.core.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.position.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.widget.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.autocomplete.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/cms/cms_files/jquery-1.js' /></script>
<script type='text/javascript' src='http://esfadmin.house365.com/script/cms/js/newAdd.js'></script>";
    

    //小区确定
    if($blockid > 0){

        $q = "select blockname,b_img from block where id = '".$blockid."'";
        $binfo = $db->GetRow($q);
        $bname = $binfo['blockname'];
        $bimg = $binfo['b_img'];
    }

   
    //获得数据总条数
    $sql = "select count(*) as count_num from $tbl a left join block b on a.bi_blockid=b.id where ".$wherecond."";
    $totalrows = $dbback->GetAll($sql);
    $numrows=$totalrows[0]['count_num'];

    //获得各类图片数量
    $sql = "select bi_type,id,count(*) as count_num from $tbl  where bi_blockid=".$blockid." group by bi_type";
    $type_num_array = $dbback->GetAll($sql);
  if(isset($type_num_array) && !empty($type_num_array)){
    foreach($type_num_array as $value)
    {
        if($value['bi_type']==0 or $value['bi_type']==51 or $value['bi_type']==52 or $value['bi_type']==53 or $value['bi_type']==54 or $value['bi_type']==55)
        {
              $type_num[$value['bi_type']]=$value['count_num'];
          if(empty($type_num['id'][$value['bi_type']]) && !isset($type_num['id'][$value['bi_type']]))
            {
              $type_num['id'][$value['bi_type']]=$value['id'];
            }

        }else{
              $type_num[999]+=$value['count_num'];
              if(empty($type_num['id'][999]) && !isset($type_num['id'][999]))
            {
              $type_num['id'][999]=$value['id'];
            }
        }
         
    }}

    //获得数据当前页面数据
    $sql = "select a.*,b.blockname,b.id as bid from $tbl a left join block b on a.bi_blockid=b.id where bi_blockid=".$blockid." order by a.bi_type";
    
    $data_info = $dbback->GetAll($sql);



    //读出当前的图片信息

    $sql = "select * from $tbl where id=".$pic_id."";
    
    $data_pic = $dbback->GetAll($sql);

    switch($data_pic[0]['bi_type'])
    {
        case 0:
        $data_pic[0]['bi_type']=0;
        break;

        case 51:
        $data_pic[0]['bi_type']=51;
        break;

        
        case 52:
        $data_pic[0]['bi_type']=52;
        break;
        
        case 53:
        $data_pic[0]['bi_type']=53;
        break;
        
        case 54:
        $data_pic[0]['bi_type']=54;
        break;
        
        case 55:
        $data_pic[0]['bi_type']=55;
        break;

        default:
        $data_pic[0]['bi_type']=999;
        break;
    }
    
     foreach($data_info as $key=>$value)
     {
         if($data_pic[0]['bi_type']==999)
         {
             if($value['bi_type']!=0 && $value['bi_type']!=51 && $value['bi_type']!=52 && $value['bi_type']!=53 && $value['bi_type']!=54 && $value['bi_type']!=55 && $value['bi_type']!=56)
             {
             $data_info1[]=$value;
             }
         }elseif($data_pic[0]['bi_type']==$value['bi_type'])
         {
            $data_info1[]=$value;
         }
     }

/*     foreach($data_info as $key=>$value)
     {
         if($data_pic[0]['bi_type']==999)
         {
             if($value['bi_type']==0 or $value['bi_type']==51 or $value['bi_type']==52 or $value['bi_type']==53 or $value['bi_type']==54 or $value['bi_type']==55 or $value['bi_type']==56)
             {
             $data_info1[]=$value;
             }
         }elseif($data_pic[0]['bi_type']!=$value['bi_type'])
         {
            $data_info1[]=$value;
         }
     }*/

    //引用模版文件
    include_once(Template("header"));
    include_once(Template("block/block_pic_detail"));
    include_once(Template("footer"));
?>