<?php
$status=array('-1'=>lang_show('notpass'),'0'=>lang_show('wpass'),'1'=>lang_show('auditpass')); 
if(isset($_GET['step']))
{
	if($_GET['step']=="del")
	{
		$db->query("delete from ".CERTIFICATION." where id='$_GET[deid]'");
		$sql="update ".COMPANY." set certification='0' where company_id in (select company_id from ".CERTIFICATION." where id='$_GET[deid]')";
		$db->query($sql);
	}
}
if(isset($_POST['del']))
{
	$ids=implode(",",$_POST['del']);
	$sql="update  ".CERTIFICATION." set statu=1 where id in ($ids)";
	$db->query($sql);
	
	$sql="update ".COMPANY." set certification='1' where company_id in (select company_id from ".CERTIFICATION." where id in ($ids))";
	$db->query($sql);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE><?php echo lang_show('admin_system');?></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="main.js"></script>
</HEAD>
<body>
<script>
function do_select()
{
	 var box_l = document.getElementsByName("del[]").length;
	 for(var j = 0 ; j < box_l ; j++)
	 {
	  	if(document.getElementsByName("del[]")[j].checked==true)
	  	  document.getElementsByName("del[]")[j].checked = false;
		else
		  document.getElementsByName("del[]")[j].checked = true;
	 }
}
</script>
<div class="bigbox">
  <div class="bigboxhead"><?php echo lang_show('business_info_list');?></div>
  <div class="bigboxbody">
    <form method="get" action="">
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="searh_left"><?php echo lang_show('key_word');?></td>
          <td><input class="text" type="text" name="key" value="<?php if(isset($_GET['key']))echo $_GET['key'];?>">
            <input name="m" type="hidden" value="company" />
            <input name="s" type="hidden" value="business_info_list.php" />
          </td>
        </tr>
        <tr>
          <td><?php echo lang_show('statu');?></td>
          <td><select class="select" name="statu">
		  	    <option value=""><?php echo lang_show('all');?></option>
                 <?php
				 foreach($status as $key=>$v)
				 {
				   ?>
                   <option value="<?php echo "$key"; ?>" <?php if($_GET['statu']=="$key") echo "selected"; ?>><?php echo $v; ?></option>
                   <?php
				 }
				 ?>
            </select>
          </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input class="btn" type="submit" name="Submit" value="<?php echo lang_show('search');?>"></td>
        </tr>
      </table>
    </form>
　
    <form method="post" action="">
      <table width="100%" border="0" cellpadding="2" cellspacing="0" >
        <tr class="theader">
          <td width="116"><input onclick="$('.del').attr('checked','true');" name="" type="checkbox" class="checkbox" value="" />
            <?php echo lang_show('business_info_name');?> </td>
          <td width="170"><?php echo lang_show('business_info_uptime');?></td>
          <td width="348"><?php echo lang_show('business_info_com');?></td>
          <td width="132"><?php echo lang_show('business_info_regtime');?></td>
          <td width="78"><?php echo lang_show('statu');?></td>
          <td width="108" align="center" ><?php echo lang_show('manager');?></td>
        </tr>
        <?php
	if(isset($_GET['key']))
		$psql=" and (b.company like '%$_GET[key]%') ";
	if(!empty($_SESSION['province']))
		$psql.=" and b.province='$_SESSION[province]'";
	if(!empty($_SESSION['city']))
		$psql.=" and b.city='$_SESSION[city]'";
	if(isset($_GET['statu']))
		$psql.=" and a.statu='$_GET[statu]'";
	$sql="SELECT a.*,b.company FROM ".CERTIFICATION." a,".COMPANY." b WHERE
	  	 a.company_id=b.company_id $psql order by id desc ";
	//=============================
	include_once("../includes/page_utf_class.php");
	$page = new Page;
	$page->listRows=20;
	if (!$page->__get('totalRows')){
		$db->query($sql);
		$page->totalRows = $db->num_rows();
	}
	$sql .= "  limit ".$page->firstRow.",20";
	$pages = $page->prompt();
	//=====================
	$db->query($sql);
	$re=$db->getRows();
	$coun_num=$db->num_rows();
	for($i=0;$i<$coun_num;$i++)
	{ 
	?>
        <tr onMouseOver="mouseOver(this)" onMouseOut="mouseOut(this,'odd')">
          <td><input class="del" type="checkbox" class="checkbox" name="del[]" value="<?php echo $re[$i]['id'];?>" >
            <?php echo $re[$i]['person_name']; ?></td>
          <td align="left"><?php echo $re[$i]['uptime']; ?></td>
          <td align="left"><?php echo $re[$i]['company']; ?></td>
          <td align="left"><?php echo $re[$i]['com_reg_time']; ?></td>
          <td><?php $key=$re[$i]['statu'];echo $status[$key]; ?></td>
          <td align="center"><a href="module.php?m=company&s=business_info_detail.php&id=<?php echo $re[$i]['id']; ?>"><?php echo $editimg;?></a> <a href="module.php?m=company&s=business_info_list.php&step=del&deid=<?php echo $re[$i]['id']; ?>" onClick="return confirm('<?php echo lang_show('are_you_sure');?>')"><?php echo $delimg;?></a> </td>
        </tr>
        <?php 
    	}
		?>
        <tr>
          <td><input class="btn" name="" type="submit" value="<?php echo lang_show('audit');?>" /></td>
          <td colspan="5" align="right"><div class="page"><?php echo $pages?></div></td>
        </tr>
      </table>
    </form>
  </div>
</div>
</body>
</html>
