<?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>iPayLinks 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" 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>
    <style type="text/css">
    p{margin-bottom: 8.5px;}
    a{text-decoration: none;}
    .navbar-header h1{display: inline-block;margin-left: 30px;margin-right: 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;}
    .export_form_area{display: inline-block;padding: 6px;border: 1px solid #ccc;background-color: #ccc;}
    </style>
  </head>
  <body>
    <div id="wrapper" class="chkVisible print-none">
    <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="http://www.mycht.cn/webht.php/index/index">
              <img width="150" style="height:40px;" src="/css/nav/img/6000.png">
          </a>
          <h1>iPayLinks Notes</h1>

          <div class="export_form_area ">

            <form class="form-inline " method="post" id="search_list2" action="/webht.php/apps/pay/ipaylinksservice/export_list/">
              <div class="form-group ">
                <label for="from_date" class="">Date From</label>
                <input type="text" class="form-control" id="from_date" name="from_date" required>
              </div>
              <div class="form-group ">
                <label for="to_date" class="">To</label>
                <input type="text" class="form-control" id="to_date" name="to_date" required>
              </div>
              <div class="form-group ">
                <label for="currency" class="">Currency</label>
                <select class="form-control" id="currency" name="currency">
                  <option value="">All</option>
                  <option value="CNY">CNY</option>
                  <option value="USD">USD</option>
                  <option value="EUR">EUR</option>
                  <option value="CAD">CAD</option>
                  <option value="AUD">AUD</option>
                  <option value="GBP">GBP</option>
                </select>
              </div>
              <button type="submit" class="btn btn-primary">Export</button>
            </form>
          </div>
        </div>
            <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 id="content">
      <div class="container-fluid marginTop">
        <div class="row">
          <!-- left -->
          <div class="col-md-4 col-xs-24 print-none">
            <div class="row">
                <form method="post" id="search_list" action="http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/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 hidden-xs links">
                <li><a class="text-primary" href="http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/note_list">&gt;全部收款邮件</a></li>
                <li class="btn-sm"></li>
                <li><a class="text-primary" href="http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/note_faillist" >&gt;错误通知列表</a></li>
                <li class="btn-sm"></li>
                <li><a class="text-primary" href="http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/batch_send_note" 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" >
                <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 print-none"><strong>通知时间</strong></li>
                      <li class="col-sm-2 print-none"><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;">
                      <?php if ($item->IPL_dealId) { ?>
                          <a class="seen" target="_blank" href="http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/receipt/<?php echo $item->IPL_dealId; ?>">
                      <?php } else {?>
                          <a class="seen" target="_blank" href="#">
                      <?php } ?>
                              <?php echo $item->IPL_orderId . ' / ' . $item->IPL_orderAmount . $item->IPL_currencyCode ; ?>
                          </a></li>

                      <li class="col-sm-5 nopadding-L" style="overflow:hidden;word-break: break-all;">
                      <?php if ($item->IPL_payType == 'refund') {
                        echo "退款";
                      } else {
                        echo $item->IPL_payerName . "<br>" . $item->IPL_payerEmail;
                      } ?>
                      </li>

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

                      <li class="col-sm-3 nopadding-L" style="overflow:hidden;word-break: break-all;"><?php echo $item->IPL_acquiringTime; ?></li>
                      <li class="col-sm-3 nopadding-L print-none" ><?php echo $item->IPL_noticeTime; ?></li>
                      <li class="col-sm-2 print-none" >
                          <?php
                          $show_send = '';
                          $class_css = '';
                          if ($item->IPL_sent == 'send') {
                              $show_send = $item->IPL_sent;
                          } else if ($item->IPL_sent == 'closeRecord') {
                              $show_send = "已忽略";
                          } else if (strcmp(trim($item->IPL_stateCode), "2") && $item->IPL_stateCode != NULL) {
                              $class_css = 'btn-danger';
                              $show_send = $paytext[intval(trim($item->IPL_stateCode))];
                          } else {
                              $class_css = 'btn-danger';
                              $show_send = $item->IPL_sent;
                          }
                          ?><a href="javascript:void(0);" title="<?php echo $item->IPL_resultMsg; ?>" onclick="show_order_modal('<?php echo $item->IPL_dealId; ?>', '<?php echo $item->IPL_orderId; ?>','<?php echo $item->IPL_noticeTime; ?>','<?php echo $item->IPL_orderId; ?>', '<?php echo $item->IPL_sn; ?>')" class="btn btn-sm <?php echo $class_css; ?>"><?php echo $show_send; ?></a>
                      </li>
                  </ul>

              <?php } ?>
          </div>
          <!-- </div> -->
            <div class="pay_footer text-right print-none">
              <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>

  </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 = 'http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/note_list?date=' + dateText;
          }
      });
      $(".ui-datepicker").css('width', '15.7em');

      var dateFormat = "yy-mm-dd",
        from = $( "#from_date" )
          .datepicker({
            dateFormat: dateFormat,
            changeMonth: true,
            changeYear: true,
            numberOfMonths: 1
          })
          .on( "change", function() {
            to.datepicker( "option", "minDate", getDate( this ) );
          }),
        to = $( "#to_date" ).datepicker({
          dateFormat: dateFormat,
          changeMonth: true,
          changeYear: true,
          numberOfMonths: 1
        })
        .on( "change", function() {
          from.datepicker( "option", "maxDate", getDate( this ) );
        });

      function getDate( element ) {
        var date;
        try {
          date = $.datepicker.parseDate( dateFormat, element.value );
        } catch( error ) {
          date = null;
        }

        return date;
      }
  });
      function show_order_modal(pn_txn_id, pn_invoice,noticeTime,old_order, pn_id) {
        if (pn_txn_id) {
          $.ajax({
              type: "get",
              dataType: "json",
              url: '/webht.php/apps/pay/ipaylinksservice/note_modal/' + pn_txn_id + '/' + pn_invoice + '/' + pn_id,
              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/ipaylinksservice/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: 'http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/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>
