<?php if(!defined('BASEPATH')) exit('No direct script access allowed');?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>管理页面</title>
<?php $this->load->view('common/inc_styles.php');?>
<?php
$use_chengjiao = $this->bgkcrm_mysql->get_rows('ziduan', array('table_name' => 'kehu', 'name' => 'chengjiao'), 'liebiao');
?>
</head>

<body class="mainbody">
<div class="mian-page-div">
<!--帮管客CRM客户管理系统免费版 bgk100.com 侵权必究！--> 
  
  <!--导航栏-->
  <?php $this->load->view('common/inc_head.php');?>
  <!--/导航栏--> 
  
  <!--工具栏-->
  <div class="toolbar">
    <div class="l-list">
      <ul class="icon-list">
        <li><a class="btn2 <?php echo $timetype=='' ? 'hover' : ''?>" href="?"><i class="fa fa-list"></i><?php echo $this->bgkcrm->zf_hetong?>列表</a></li>
        <li><a class="btn2 <?php echo $timetype=='d' ? 'hover' : ''?>" href="?otype=timetype&timetype=d"><i class="fa fa-clock-o"></i>今日记录</a></li>
        <li><a class="btn2 <?php echo $timetype=='w' ? 'hover' : ''?>" href="?otype=timetype&timetype=w"><i class="fa fa-clock-o"></i>本周记录</a></li>
        <li><a class="btn2 <?php echo $timetype=='m' ? 'hover' : ''?>" href="?otype=timetype&timetype=m"><i class="fa fa-clock-o"></i>本月记录</a></li>
        <li><a class="btn2 <?php echo $timetype=='d2_10' ? 'hover' : ''?>" href="?otype=timetype&timetype=d2_10"><i class="fa fa-clock-o"></i>10天内到期</a></li>
        <li><a class="btn2 <?php echo $timetype=='m2' ? 'hover' : ''?>" href="?otype=timetype&timetype=m2"><i class="fa fa-clock-o"></i>本月到期</a></li>
        <?php if ($this->bgkcrm->check_lever_v(42)){?>
        <li><a class="btn2 color1 alert1" href="<?php echo site_url('common/choose_kehu')?>?choose_type=hetong" data-title="新增<?php echo $this->bgkcrm->zf_hetong?>【第一步：选择<?php echo $this->bgkcrm->zf_hetong?><?php echo $this->bgkcrm->zf_kehu?>】" data-width="1100" data-height="550"><i class="fa fa-plus"></i>新增<?php echo $this->bgkcrm->zf_hetong?></a></li>
        <script>function ChoseOK(i){{$.dialog.open('<?php echo site_url('hetong/add')?>?cid='+i, {title: '新增<?php echo $this->bgkcrm->zf_hetong?>【第二步：录入<?php echo $this->bgkcrm->zf_hetong?>信息】', <?php if($this->bgkcrm->is_mobile()==1){ //手机端?>width: '100%', height: '100%'<?php }else{?>width: 620, height: 550<?php }?>,fixed: true,lock:false}); };}</script>
        <?php }?>
        <span id="timo2">
        <li><a class="btn2" href="javascript:location.reload();"><i class="fa fa-refresh"></i>刷新</a></li>
        </span> <span id="timo1">
        <form name="searchForm" action="?sou=soufast" method="post">
          <li class="btn-sou-input">
            <input name="keyword" type="text" value="<?php echo $keyword?>" class="input input-sou1" placeholder="<?php echo $this->bgkcrm->zf_kehu?>名称、联系人">
          </li>
          <label class="btn2 color4 btn-sou-ks">
            <input type="submit" name="submit" value="" />
            搜索</label>
          <li class="btn-sou-gj"><a class="btn2 search-toggle">高级搜索 <i class="fa fa-angle-double-down"></i></a></li>
        </form>
        </span>
      </ul>
    </div>
    <div class="clear"></div>
    <div class="biaodan-list sousuo-gj" <?php if ($sou=="soudetail"){?>style="display:block;"<?php }?>>
      <form name="searchForm" action="?sou=soudetail" method="post">
        <?php $this->load->view('common/ziduan_sousuo.php');?>
        <div class="clear" style="height:5px;"></div>
        <div class="soubtn">
          <input type="submit" class="btn2 sousuo" value="立即搜索" />
          <input type="button" class="btn2 close" value="清空条件" onClick=window.location.href="?" />
        </div>
      </form>
    </div>
    <div class="biaodan-list daochu-gj" <?php if ($sou=="daochu"){?>style="display:block;"<?php }?>>
      <form name="searchForm" action="?sou=daochu" method="post">
        <?php $this->load->view('common/ziduan_sousuo.php');?>
        <div class="clear" style="height:5px;"></div>
        <div class="soubtn">
          <input type="submit" class="btn2 sousuo" value="立即导出" />
          <input type="button" class="btn2 close" value="清空条件" onClick=window.location.href="?" />
        </div>
      </form>
    </div>
  </div>
  <!--/工具栏--> 
  
  <!--列表-->
  <form method="post">
    <div class="table-container">
      <div class="">
        <table class="table tree_table">
          <thead>
            <tr class="">
              <th width="60" nowrap class="<?php if($this->bgkcrm->show_bianhao!=1){ echo 'no-m none'; }?>"><a class="paixu" ziduan="id" paixu=""> 编号 </a></th>
              <th width="150" class="td_l bhh head-name" vname="head-name"> <?php foreach($ziduan_xitong as $arr=>$n) {
		  if($n["name"]=="name"){//客户名称?>
                <a class="paixu" ziduan="<?php echo $n['name']?>" paixu=""> <?php echo $n['title']?> </a>
                <?php }}?>
              </th>
              <?php 
//自定义字段表头
if (count($ziduan_liebiao)>0) {
foreach($ziduan_liebiao as $arr=>$v) {
	if($v['liebiao']==1){
?>
              <?php if($v['lb_teshu']==1){//特殊字段?>
              <!--特殊字段开始-->
              <?php if($v['qx_view']==NULL||($v['qx_view']!=NULL&&in_array($this->bgkcrm->realname,explode(',', $v['qx_view'])))){//权限范围内?>
              <th width="<?php echo $v['name']=='content'||$v['name']=='shenhebeizhu'||$v['name']=='solvecontent'||$v['name']=='address'?160:100?>" class="td_c bhh lb_teshu head-<?php echo $v['name']?>" vname="head-<?php echo $v['name']?>"> <a class="paixu" ziduan="<?php echo $v['name']?>" paixu=""> <?php echo $v['title']?> </a> </th>
              <?php }?>
              <!--特殊字段结束-->
              <?php }else{//普通字段?>
              <!--普通字段结束-->
              <?php if($v['qx_view']==NULL||($v['qx_view']!=NULL&&in_array($this->bgkcrm->realname,explode(',', $v['qx_view'])))){//权限范围内?>
              <th width="<?php echo $v['name']=='content'||$v['name']=='shenhebeizhu'||$v['name']=='solvecontent'||$v['name']=='address'?160:100?>" class="td_c bhh head-<?php echo $v['name']?>" vname="head-<?php echo $v['name']?>"> <a class="paixu" ziduan="<?php echo $v['name']?>" paixu=""> <?php echo $v['title']?> </a> </th>
              <?php }?>
              <!--普通字段结束-->
              <?php }?>
              <?php			
}}}
?>
            </tr>
          </thead>
          <?php 
	if (count($list)>0) {
	foreach($list as $arr=>$row) {?>
          <tbody>
            <tr class="tr" onclick=window.location.href="javascript:<?php if($this->bgkcrm->is_mobile()==1){ //手机端?>M_ChoseOK(<?php echo $row['id']?>);<?php }else{?>$.dialog.open.origin.ChoseOKhetong(<?php echo $row['id']?>);$.dialog.close();<?php }?>" style="cursor:pointer;" title="点击选中<?php echo $this->bgkcrm->zf_hetong?>">
              <td class="td_c <?php if($this->bgkcrm->show_bianhao!=1){ echo 'no-m none'; }?>"><?php echo $row['id']?></td>
              <td  class="td_l body-name" vname="body-name"><a class="cid<?php echo $row['cid']?>" onClick="Views('hetong',<?php echo $row['cid']?>,'<?php echo $row['name']?>')"><?php echo $row['name']?> </a>
                <?php 
				if($use_chengjiao==1){
				$yichengjiao = $this->bgkcrm_mysql->get_rows('kehu',array('isdel'=>0,'id'=>$row['cid']),'chengjiao');
		echo $yichengjiao=='是' ? '<span class="chengjiao" title="有订单或者合同记录即为已成交"> 成交 </span>' : '' ;
				}?>
                <?php
		$isshare = $this->bgkcrm_mysql->get_rows('kehu',array('isdel'=>0,'id'=>$row['cid']),'isshare');
		$share_users = $this->bgkcrm_mysql->get_rows('kehu',array('isdel'=>0,'id'=>$row['cid']),'share_users');
		
		if($this->session->userdata('roleid')==0&&$isshare=='是'){?>
                <span class="sharebtn" title="共享类<?php echo $this->bgkcrm->zf_kehu?>" nowuser="<?php echo $row['nowuser']?>" share_users="<?php echo $share_users?>"><i class="fabtn color3 fa fa-share-alt-square"></i></span>
                <?php }else{?>
                <?php if($isshare=='是'&&$row['nowuser']==$this->bgkcrm->realname){?>
                <span class="sharebtn" title="我共享给别人" nowuser="<?php echo $row['nowuser']?>" share_users="<?php echo $share_users?>"><i class="fabtn color3 fa fa-share-alt-square"></i></span>
                <?php }else if($isshare=='是'&&$row['nowuser']!=$this->bgkcrm->realname&&in_array($this->bgkcrm->realname,explode(",",$share_users))){?>
                <span class="sharebtn" title="别人共享给我" nowuser="<?php echo $row['nowuser']?>" share_users="<?php echo $share_users?>"><i class="fabtn fa fa-share-alt-square fa-flip-horizontal" style="background-color:#4dd0a4;"></i></span>
                <?php }?>
                <?php }?></td>
              <?php
//自定义字段内容
if (count($ziduan_liebiao)>0) {
foreach($ziduan_liebiao as $arr=>$v) {
if($v['liebiao']==1){
?>
              <?php if($v['lb_teshu']==1){//特殊字段?>
              <!--特殊字段开始-->
              <?php if($v['qx_view']==NULL||($v['qx_view']!=NULL&&in_array($this->bgkcrm->realname,explode(',', $v['qx_view'])))){//权限范围内?>
              <?php if($v['name']=='qkmoney'){?>
              <td class="td_c lb_teshu zd_<?php echo $v['type']?>"><?php echo $row[$v['name']];?></td>
              <?php }?>
              <?php if($v['name']=='shenhe'){?>
              <td class="td_c lb_teshu zd_<?php echo $v['type']?>"><?php if($v['name']=='shenhe'){?>
                <?php if ($this->bgkcrm->check_lever_v(46)){?>
                <a class="btn1 alert1 shenhe" href="<?php echo site_url('hetong/shenhe')?>?id=<?php echo $row['id']?>" data-title="审核" data-width="620" data-height="300"><i class="fa fa-exclamation-circle"></i><?php echo $row['shenhe']?></a>
                <?php }else{?>
                <?php echo $row['shenhe']?>
                <?php }?>
                <?php }?></td>
              <?php }?>
              <?php }?>
              <!--特殊字段结束-->
              
              <?php }else{//普通字段?>
              <!--普通字段结束-->
              <?php if($v['qx_view']==NULL||($v['qx_view']!=NULL&&in_array($this->bgkcrm->realname,explode(',', $v['qx_view'])))){//权限范围内?>
              <td class="td_c zd_<?php echo $v['type']?> body-<?php echo $v['name']?>" <?php echo $v['lie_width']>0? 'style="max-width:'.$v['lie_width'].'px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="'.$row[$v['name']].'"' : ''?> vname="body-<?php echo $v['name']?>"><?php
//时间字段转化
if($v['type']=='datetime'){
    if($row[$v['name']]=='0000-00-00 00:00:00'||empty($row[$v['name']])){
		echo '';	
	}else{
		switch ($v['content'])
		{
		case "yyyy-MM-dd":
			 echo date("Y-m-d",strtotime($row[$v['name']]));
			 break;
		case "yyyy-MM-dd HH:mm":
			 echo date("Y-m-d H:i",strtotime($row[$v['name']]));
			 break;
		case "yyyy-MM-dd HH:mm:ss":
			 echo date("Y-m-d H:i:s",strtotime($row[$v['name']]));
			 break;
		default:
			 echo $row[$v['name']];
		}
	}
	
}elseif($v['type']=='upload_img'){
echo empty($row[$v['name']])?'-':'<span class="picview"><img class="view_img" src="'.$row[$v['name']].'" /></span>';
}elseif($v['type']=='upload_file'){
echo empty($row[$v['name']])?'-':'<a class="btn1 color6" href="'.$row[$v['name']].'" target="_blank"><i class="fa fa-arrow-circle-down"></i>下载</a>';
}else{
echo $row[$v['name']];
}
?></td>
              <?php }?>
              <!--普通字段结束-->
              <?php }?>
              <?php			
}}}
?>
            </tr>
          </tbody>
          <?php 
 }} 
?>
        </table>
        <?php if (count($list)<=0) {?>
        <div class="nodata"><i class="fa fa-clock-o"></i> 暂无任何记录！</div>
        <?php }?>
        <script>
$(function() {
  $(".shenhe").each(function(){
    if($.trim($(this).text())=="合同有效"){
		$(this).css("background","#0DA0B3");
	}else if($.trim($(this).text())=="合同无效"){
		$(this).css("background","#9E9E9E");
		$(this).parent().parent().css("color","#8E8C8C");
	}
  });
  

  $(".zd_money").each(function(){
	  var thisval=$(this).html();
	  $(this).html(thisval.replace(".00",""));
  });
})
</script> 
      </div>
    </div>
    <div class="clear"></div>
    <!--工具栏-->
    <div class="b-toolbar">
      <div class="inner"> 
        <!--菜单按钮列--> 
        
        <!--/菜单按钮列--> 
        
        <!--分页代码开始-->
        <?php $this->load->view('common/inc_pages.php');?>
        <!--分页代码结束--> 
      </div>
    </div>
    <!--/工具栏-->
    
  </form>
  <!--/列表--> 
  
  <!--工具栏-->
  <div class="h30"></div>
  <div class="page-footer view_btn">
    <div class="btn-wrap">
      <?php if ($this->bgkcrm->check_lever_v(42)){?>
      <a class="btn editdo alert1" href="/index.php/hetong/add?cid=<?php echo $cid?>" data-title="新增<?php echo $this->bgkcrm->zf_hetong?>" data-width="620" data-height="500">新增</a>
      <?php }?>
      <a class="btn close" onclick="art.dialog.close();parent.layclose();">关闭</a> </div>
  </div>
  <!--/工具栏--> 
  
  <!--底部-->
  <?php $this->load->view('common/inc_foot.php');?>
  <!--/底部--> 
  
  <script>
function M_ChoseOK(ht_id){
    location.href='/index.php/caiwu/add?ht_id='+ht_id+'&cid=<?php echo $this->input->get('cid')?>&outin=<?php echo $this->input->get('outin')?>';	  
}
</script> 
</div>
<!--帮管客CRM客户管理系统免费版 www.bgk100.com 版权所有，侵权必究！-->
</body>
</html>