<?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');?>
</head>

<body class="mainbody">
<div class="mian-page-div"> 
  
  <!--导航栏-->
  <?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->common_model->zf_dingdan?>列表</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>
        <?php if ($this->common_model->check_lever_v(32)){?>
        <li><a class="btn2 color1 alert1" href="<?php echo site_url('common/choose_kehu')?>?choose_type=dingdan" data-title="新增<?php echo $this->common_model->zf_dingdan?>【第一步：选择<?php echo $this->common_model->zf_dingdan?><?php echo $this->common_model->zf_kehu?>】" data-width="1100" data-height="550"><i class="fa fa-plus"></i>新增订单</a></li>
        <script>function ChoseOK(i){{$.dialog.open('<?php echo site_url('dingdan/add')?>?cid='+i, {title: '新增<?php echo $this->common_model->zf_dingdan?>【第二步：录入<?php echo $this->common_model->zf_dingdan?>信息】', <?php if($this->common_model->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>
        <?php if ($this->common_model->check_lever_v(39)){?>
        <li class="m-no"><a class="btn2 freeno daochu-toggle"><i class="fa fa-sign-out"></i>数据导出</a></li>
        <?php }?>
        <?php if ($this->common_model->check_lever_v(208)){?>
        <li class="m-no"><a class="btn2 color10 alert1" href="<?php echo site_url('ziduan/index')?>?style=1&type=dingdan" data-title="字段设置" data-width="1100" data-height="550"><i class="fa fa-navicon"></i>字段设置</a></li>
        <?php }?>
        </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->common_model->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-list">
        <table class="table tree_table">
          <thead>
            <tr class="">
              <th width="60" nowrap class="<?php if($this->common_model->show_bianhao!=1){?>no-m none<?php }?>"><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->common_model->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->common_model->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			
}}}
?>
              <th width="100" class="td_c none" nowrap>管理</th>
            </tr>
          </thead>
          <?php 
	if (count($list)>0) {
	foreach($list as $arr=>$row) {?>
          <tbody>
            <tr class="tr" onclick=window.location.href="javascript:<?php if($this->common_model->is_mobile()==1){ //手机端?>M_ChoseOK(<?php echo $row['id']?>);<?php }else{?>$.dialog.open.origin.ChoseOKdingdan(<?php echo $row['id']?>);$.dialog.close();<?php }?>" style="cursor:pointer;" title="点击选中<?php echo $this->common_model->zf_dingdan?>">
              <td class="td_c <?php if($this->common_model->show_bianhao!=1){?>no-m none<?php }?>"><?php echo $row['id']?></td>
              <td  class="td_l body-name" vname="body-name"><a class="cid<?php echo $row['cid']?>" onClick="Views('dingdan',<?php echo $row['cid']?>,'<?php echo $row['name']?>')">
                <?php $yichengjiao = $this->mysql_model->get_rows('kehu',array('isdel'=>0,'id'=>$row['cid']),'chengjiao');
		echo $yichengjiao=='是' ? '<span class="btn1 chengjiao"> 成交 </span>' : '' ; echo $row['name']?>
                </a>
                <?php
		$isshare = $this->mysql_model->get_rows('kehu',array('isdel'=>0,'id'=>$row['cid']),'isshare');
		$share_users = $this->mysql_model->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->common_model->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->common_model->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->common_model->realname&&in_array($this->common_model->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->common_model->realname,explode(',', $v['qx_view'])))){//权限范围内?>
              <td class="td_c lb_teshu zd_<?php echo $v['type']?> body-<?php echo $v['name']?>" vname="body-<?php echo $v['name']?>"><?php if($v['name']=='shenhe'){?>
                <?php if ($this->common_model->check_lever_v(116)){?>
                <a class="btn1 alert1 shenhe" href="<?php echo site_url('dingdan/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 }else{//普通字段?>
              <!--普通字段结束-->
              <?php if($v['qx_view']==NULL||($v['qx_view']!=NULL&&in_array($this->common_model->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;"' : ''?> 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			
}}}
?>
              <td class="td_c bhh none"><?php if ($this->common_model->check_lever_v(36)){?>
                <a class="btn1 shoukuan alert1" href="<?php echo site_url('dingdan/shenhe')?>?id=<?php echo $row['id']?>" data-title="审核" data-width="500" data-height="250"><i class="fa fa-edit"></i>审核</a>
                <?php }?>
                <?php if ($this->common_model->check_lever_v(37)){?>
                <a class="btn1 mingxi alert1" href="<?php echo site_url('dingdan/chanpin')?>?id=<?php echo $row['id']?>" data-title="<?php echo $this->common_model->zf_chanpin?>" data-width="1020" data-height="550"><i class="fa fa-shopping-cart"></i><?php echo $this->common_model->zf_chanpin?></a>
                <?php }?>
                <?php if ($this->common_model->check_lever_v(35)){?>
                
                <!--<a class="btn1 shoukuan alert1" href="<?php echo site_url('dingdan/shoukuan')?>?id=<?php echo $row['id']?>" data-title="收款" data-width="500" data-height="250"><i class="fa fa-edit"></i>收款</a>-->
                
                <?php }?>
                <?php if ($this->common_model->check_lever_v(33)){?>
                <a class="btn1 edit alert1" href="<?php echo site_url('dingdan/edit')?>?cid=<?php echo $row['cid']?>&id=<?php echo $row['id']?>" data-title="编辑" data-width="620" data-height="550"><i class="fa fa-edit"></i>编辑</a>
                <?php }?>
                <?php if ($this->common_model->check_lever_v(34)){?>
                <a class="btn1 del alert1" href="<?php echo site_url('dingdan/dels')?>?id=<?php echo $row['id']?>" data-title="删除" data-width="500" data-height="220"><i class="fa fa-trash-o"></i>删除</a>
                <?php }?></td>
            </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->common_model->check_lever_v(32)){?>
      <input type="button" value="新增" class="btn editdo alert1" href="/index.php/dingdan/add?cid=<?php echo $cid?>" data-title="新增<?php echo $this->common_model->zf_dingdan?>" data-width="620" data-height="500">
      <?php }?>
      <input type="button" value="关闭" class="btn close" onclick="art.dialog.close();parent.layclose();">
    </div>
  </div>
  <!--/工具栏--> 
  
  <!--底部-->
  <?php $this->load->view('common/inc_foot.php');?>
  <!--/底部--> 
  
  <script>
function M_ChoseOK(dd_id){
    location.href='/index.php/caiwu/add?dd_id='+dd_id;	  
}
</script> 
</div>
</body>
</html>