<?php
/*!
* 查询支付记录
* @author LYT <lyt@hainatravel.com>
* @date   2017-09-06
*/
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Alipay Notes - China Highlights</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name="referrer" content="always">
    <link href="//data.chinahighlights.com/css/min.php?f=/public/css/global.min.css,/css/ui.core.css,/css/ui.datepicker.css,/css/ui.theme.css,/css/calendar.css&amp;v=20170811" rel="stylesheet" type="text/css" />
    <style type="text/css">
    .modal-open { overflow: hidden }
    .modal { display: none; overflow: hidden; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1050; -webkit-overflow-scrolling: touch; outline: 0 }
    .modal.fade .modal-dialog { -webkit-transform: translate(0, -25%); -ms-transform: translate(0, -25%); -o-transform: translate(0, -25%); transform: translate(0, -25%); -webkit-transition: -webkit-transform .3s ease-out; -moz-transition: -moz-transform .3s ease-out; -o-transition: -o-transform .3s ease-out; transition: transform .3s ease-out }
    .modal.in .modal-dialog { -webkit-transform: translate(0, 0); -ms-transform: translate(0, 0); -o-transform: translate(0, 0); transform: translate(0, 0) }
    .modal-open .modal { overflow-x: hidden; overflow-y: auto }
    .modal-dialog { position: relative; width: auto; margin: 10px }
    .modal-content { position: relative; background-color: #fff; border: 1px solid #999; border: 1px solid rgba(0,0,0,.2); border-radius: 6px; -webkit-box-shadow: 0 3px 9px rgba(0,0,0,.5); box-shadow: 0 3px 9px rgba(0,0,0,.5); background-clip: padding-box; outline: 0 }
    .modal-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1040; background-color: #000 }
    .modal-backdrop.fade { opacity: 0; filter: alpha(opacity=0) }
    .modal-backdrop.in { opacity: .5; filter: alpha(opacity=50) }
    .modal-header { padding: 15px; border-bottom: 1px solid #e5e5e5; min-height: 16.43px }
    .modal-header .close { margin-top: -2px }
    .modal-title { margin: 0; line-height: 1.428571429 }
    .modal-body { position: relative; padding: 30px }
    .modal-footer { padding: 30px; text-align: right; border-top: 1px solid #e5e5e5 }
    .modal-footer .btn+.btn { margin-left: 5px; margin-bottom: 0 }
    .modal-footer .btn-group .btn+.btn { margin-left: -1px }
    .modal-footer .btn-block+.btn-block { margin-left: 0 }
    .modal-scrollbar-measure { position: absolute; top: -9999px; width: 50px; height: 50px; overflow: scroll }
    @media (min-width:768px) {
    .modal-dialog { width: 600px; margin: 30px auto }
    .modal-content { -webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5); box-shadow: 0 5px 15px rgba(0,0,0,.5) }
    .modal-sm { width: 300px }
    }
    @media (min-width:992px) {
    .modal-lg { width: 900px }
    }
    p{margin-bottom: 8.5px;}
    a{text-decoration: none;}
    .navbar-header h1{display: inline-block;margin-left: 30px;}
    .pageTitle{margin-left: 300px;}
    .pageTitle h1{color: #fff;border:none;font-size: 30px;}
    .mobileTitle h1{color: #fff;border:none;font-size: 20px;}
    .pay_form{padding: 30px 15px 15px 15px ;box-shadow: 0 0 10px #999;background: #fff;border-radius: 5px; }
    .pay_form .form-group{padding-left: 50px;padding-right: 50px;}
    .pay_form .control-label{text-align: left;}
    .pay_form .result_info{padding-top: 25px;}
    .pay_form .btn-danger{background: #a31022;}
    .pay_footer{padding: 30px 0 10px;font-size: 12px;}
    .line{border-bottom: 1px solid #cacaca;margin-left: 20px!important;margin-right: 20px!important;}
    .btn{text-decoration: none;font-size: 14px;}
    .mail_list {margin: 0;padding: 8px 15px;border-bottom: 1px solid #ccc;overflow: hidden;    }
    /*.input-group{border: 1px solid #ccc;}*/
    .input-group-btn{border: 1px solid #ccc;padding: 5px;}
    .search-btn{cursor: pointer; background: url(//data.chinahighlights.com/css/images/global/site-search-button.png) no-repeat center center;}
    .center-block{display: block;margin: 0 auto;}
    .brand_text {color: #fff; padding: 2px 3px; border-radius: 4px;font-style: italic;}
    .cht-color {background-color: #A31022;}
    .trippest-color {background-color: #E83201;}
    </style>
    <style type="text/css" media="screen and (max-width:767px)">
    .pay_form .form-group{padding-left: 0!important;padding-right: 0!important;}
    .pay_form .result_info{padding-top: 5px!important;}
    </style>
  </head>
  <body>
    <div id="wrapper" class="chkVisible">
    <div class="navbar-header" style="float:none;border-bottom: 1px solid #ccc;">
          <a class="navbar-brand text-muted" style="height: 52px;padding-top: 7px;padding-left: 30px;" href="/webht.php/index/index">
              <img width="150" style="height:40px;" src="/css/nav/img/6000.png">
          </a>
          <h1>Alipay Notes</h1>

          <ul class="nav navbar-nav navbar-right pull-right" style="margin:7.5px 0;">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?php $userdata=$this->session->userdata('admin_chtcdn'); echo $userdata['OPI_Name']; ?> <span class="caret"></span></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href="<?php echo site_url('login/logout'); ?>">退出</a></li>
              </ul>
            </li>
          </ul>
        </div>
    </div>
    <div id="content">
      <div class="container-fluid marginTop">
        <div class="row">
          <!-- left -->
          <div class="col-md-4 col-xs-24">
            <div class="row">
                <form method="post" id="search_list" action="/webht.php/apps/pay/AlipayTradeService/note_list/">
                    <div class="input-group">
                        <input type="text" name="keywords" value="<?php echo isset($search_key) ? $search_key : ''; ?>" class="form-control" placeholder="订单号/交易号" style="height: 33px;-webkit-box-shadow: inset 0 0px 0px rgba(0,0,0,0.075);box-shadow: inset 0 0px 0px rgba(0,0,0,0.075);border-bottom:1px solid #ddd;">
                        <span class="input-group-addon search-btn" onclick="$('#search_list').submit();"></span>
                    </div>
                    <div id="datepicker"></div>
                </form>
            </div>
            <p class="btn-lg"></p>
            <ul class="list-unstyled links">
                <li><a class="text-primary" href="/webht.php/apps/pay/AlipayTradeService/note_list">&gt;全部收款邮件</a></li>
                <li class="btn-sm"></li>
                <li><a class="text-primary" href="/webht.php/apps/pay/AlipayTradeService/note_faillist" >&gt;错误通知列表</a></li>
                <li class="btn-sm"></li>
                <li><a class="text-primary" href="/webht.php/apps/pay/AlipayTradeService/send_alipay" target="_blank">&gt;手动处理通知</a></li>
                <li class="btn-sm"></li>
                <li><a class="text-primary" href="http://share.chtcdn.com/info.php/sendmail/send_mail" target="_blank">&gt;发送邮件</a></li>
                <li class="btn-lg"></li>
            </ul>
            <div class="well well-sm hidden-xs " >
                <h4>通知状态:</h4>
                <p>1.send 表示通知正确发送给外联</p>
                <p>2.unsend 表示通知在等待处理，5~10分钟系统处理一遍</p>
                <p>3.sendfail 状态的需要手工设置正确的订单号</p>
                <p>4.Pending 还未到账，需要人工检查，确认支付或者取消，需要手工关闭此通知</p>
                <p>5.Denied 银行拒付，需要手工关闭此通知</p>
            </div>
          </div>
          <!-- end left -->
          <div class=" pay_form_div col-sm-20 col-xs-24" style="min-height:1024px;border-left:1px solid #ddd;">
              <ul class="row mail_list hidden-xs">
                  <a href="javascript:void(0);" style="cursor:default;color:#000;">
                      <li class="col-sm-1 "><strong>#</strong></li>
                      <li class="col-sm-6 "><strong>主题</strong></li>
                      <li class="col-sm-5 "><strong>付款人</strong></li>
                      <li class="col-sm-4 "><strong>交易号</strong></li>
                      <li class="col-sm-3 "><strong>收单时间</strong></li>
                      <li class="col-sm-3 "><strong>通知时间</strong></li>
                      <li class="col-sm-2 "><strong>通知状态</strong></li>
                  </a>
              </ul>
              <?php
              foreach ($notelist as $key => $item) {
                  ?>
                  <ul class="row mail_list">

                      <li class="col-sm-1 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"><?php echo ($key + 1); ?></li>
                      <li class="col-sm-6 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;">

                      <span class="brand_text <?php echo strtolower(str_replace(" ","",$item->fundsource))."-color"; ?>"><?php echo $item->fundsource; ?></span>


                      <?php if ($item->ALI_dealId) { ?>
                          <a class="seen" target="_blank" href="/webht.php/apps/pay/AlipayTradeService/receipt/<?php echo $item->ALI_dealId; ?>">
                      <?php } else {?>
                          <a class="seen" target="_blank" href="#">
                      <?php } ?>
                              <?php echo $item->ALI_orderId . ' / ' . $item->ALI_orderAmount . $item->ALI_currencyCode ; ?>
                          </a></li>

                      <li class="col-sm-5 nopadding-L" style="overflow:hidden;word-break: break-all;">
                      <?php //echo $item->ALI_payerName; ?>
                      <?php echo $item->ALI_payerEmail; ?>
                      </li>

                      <li class="col-sm-4 nopadding-L" style="overflow:hidden;word-break: break-all;"><?php echo $item->ALI_dealId; ?></li>

                      <li class="col-sm-3 nopadding-L" style="overflow:hidden;word-break: break-all;"><?php echo $item->ALI_acquiringTime; ?></li>
                      <li class="col-sm-3 nopadding-L" ><?php echo $item->ALI_noticeTime; ?></li>
                      <li class="col-sm-2" >
                          <?php
                          $show_send = '';
                          $class_css = '';
                          if ($item->ALI_sent == 'send' || substr($item->ALI_sent, 0, 5) == "send-") {
                              $show_send = 'send';
                          } else if (strcmp(trim($item->ALI_resultMsg), "TRADE_SUCCESS")) {
                              $class_css = 'btn-danger';
                              // $show_send = $paytext[intval(trim($item->ALI_resultMsg))];
                              $show_send = strstr($item->ALI_resultMsg, "_");
                          } else {
                              $class_css = 'btn-danger';
                              $show_send = $item->ALI_sent;
                          }
                          ?><a href="javascript:void(0);" title="<?php echo $item->ALI_resultMsg; ?>" onclick="show_order_modal('<?php echo $item->ALI_dealId; ?>', '<?php echo $item->ALI_orderId; ?>','<?php echo $item->ALI_noticeTime; ?>','<?php echo $item->ALI_orderId; ?>')" class="btn btn-sm <?php echo $class_css; ?>"><?php echo $show_send; ?></a>
                      </li>
                  </ul>

              <?php } ?>
          </div>
          <!-- </div> -->
            <div class="pay_footer text-right">
              <p>©  1998 China Highlights.
                <a href="https://www.chinahighlights.com/privacy.htm" rel="nofollow">Privacy Statement</a>
              </p>
            </div>
        </div>
      </div>
    </div>
    <div id="main" class="container">
    </div>

    <!-- 手动设置订单号 -->
    <div class="modal" id="modal_set_orderid" tabindex="-1" role="dialog" aria-labelledby="orderidModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="orderidModalLabel">订单号修正操作</h4>
                </div>
                <div class="modal-body" id="modal_set_orderid_body">
                    ...
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary pull-left" onclick="close_note();" >关闭此订单通知</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="submit_order_modal();">保存并发送通知</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal" role="dialog" id="loading">
      <img src="https://data.chinahighlights.com/pic/flight-loading.gif" class="center-block" style="margin-top: 50px;">
    </div>

  </body>
  <script src="//data.chinahighlights.com/js/min.php?f=/js/jquery-1.8.2.min.js&v=20170811" type="text/javascript"></script>
  <script type="text/javascript">
    jQuery.browser={};(function(){jQuery.browser.msie=false; jQuery.browser.version=0;if(navigator.userAgent.match(/MSIE ([0-9]+)./)){ jQuery.browser.msie=true;jQuery.browser.version=RegExp.$1;}})();
  </script>
  <script src="//data.chinahighlights.com/js/min.php?f=/public/js/bootstrap.min.js,/js/jquery.form.min.js,/js/ui.core.js,/js/ui.datepicker.js,/js/jquery.ui.widget.min.js&v=20170811" type="text/javascript"></script>
  <script language="javascript">
  $(document).ready(function() {
      $('#datepicker').datepicker({
          defaultDate: '<?php echo $date; ?>',
          dateFormat: 'yy-mm-dd',
          onSelect: function(dateText) {
              window.location.href = '/webht.php/apps/pay/AlipayTradeService/note_list?date=' + dateText;
          }
      });
      $(".ui-datepicker").css('width', '25.7em');


  });
      function show_order_modal(pn_txn_id, pn_invoice,noticeTime,old_order) {
        if (pn_txn_id) {
          $.ajax({
              type: "get",
              dataType: "json",
              url: '/webht.php/apps/pay/AlipayTradeService/note_modal/' + pn_txn_id + '/' + pn_invoice + '/' + noticeTime,
              success: function(data, textStatus) {
                  $('#modal_set_orderid_body').html(data);
                  $('#modal_set_orderid').modal('show');
              },
              error: function(msg) {
                  alert('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC...');
              }
          });
        } else {
          $.ajax({
              type: "get",
              dataType: "json",
              url: '/webht.php/apps/pay/AlipayTradeService/note_order_modal/' + old_order + '/' + pn_invoice + '/' + noticeTime,
              success: function(data, textStatus) {
                  $('#modal_set_orderid_body').html(data);
                  $('#modal_set_orderid').modal('show');
              },
              error: function(msg) {
                  alert('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC...');
              }
          });
        }
      }

      function close_note() {
          var pn_txn_id = $('#pn_txn_id').val();
          if (confirm('是否关闭此通知： ' + pn_txn_id)) {
              $.ajax({
                  type: "get",
                  dataType: "json",
                  url: '/webht.php/apps/pay/AlipayTradeService/close_note/' + pn_txn_id,
                  success: function(data, textStatus) {
                      alert(data);
                  },
                  error: function(msg) {
                      alert('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC...');
                  }
              });
          }
      }

      function submit_order_modal() {
          $('#form_modal_orderid').ajaxSubmit({
              success: function(data, textStatus) {
                  alert(data);
              },
              error: function(msg) {
                  alert('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC...');
              },
              dataType: 'json',
              timeout: 30000
          });
          return false;
      }
  </script>
</html>
