
 <?
$id = $_GET['iv'];
$r = $db->findByPK('tbiv','iv_id',$id)->executeRow();
$gp = $db->findByPK('tbpayment','payment_iv',$id)->execute();
$re_custom = $db->findByPK('tbreceipt','receipt_book',$id)->executeRow();

    function DateThai($strDate){
      $strYear = date("Y",strtotime($strDate))+543;
      $strMonth= date("n",strtotime($strDate));
      $strDay= date("j",strtotime($strDate));
      $strHour= date("H",strtotime($strDate));
      $strMinute= date("i",strtotime($strDate));
      $strSeconds= date("s",strtotime($strDate));
      $strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
      $strMonthThai=$strMonthCut[$strMonth];
      return "$strDay $strMonthThai $strYear";
    }
    
     function DateGoBack($DateGo,$DateBack){
      $strYear = date("Y",strtotime($DateBack))+543;
      $strMonth= date("n",strtotime($DateBack));
      $strDay = date("j",strtotime($DateBack));
      $strDay2 = date("j",strtotime($DateGo));
      $strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
      $strMonthThai=$strMonthCut[$strMonth];
      return "$strDay2 $strMonthThai $strYear - $strDay $strMonthThai $strYear";
    }

 ?>
          <!-- start: page -->
            <div class="row">
              <div class="col-lg-12">
                <section class="panel">
                  <header class="panel-heading">
                    <div class="panel-actions">
                      <a href="#" class="fa fa-caret-down"></a>
                      <a href="#" class="fa fa-times"></a>
                    </div>
                    <h2 class="panel-title">Pay-in ( IM<?=$id;?> )</h2>
                  </header>
                  <div class="panel-body">
                     <form class="form-horizontal form-bordered" action="" name="form_payment" id="form_payment" method="post" enctype="multipart/form-data" 
                     code="<?=$id;?>">
           <div class="box-header" data-original-title>
            <h4 style="color:black;"><i class="icon-group icon-fw"></i><span class="break"></span> <i class="fa fa-user"></i> ข้อมูลใบจอง </h4>
          </div>
                 <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">Booking Detail <span class="required">*</span></label>
                        <div class="col-md-6">
                          <!-- <input type=hidden name=id value='<? echo $id;?>'> -->
                          <input type="text" class="form-control" id="inputDefault" name="cus_name" value="<?=$r['cus_name']?>" disabled/>
                        </div>
                      </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">ชื่อเซลล์ <span class="required">*</span></label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="iv_admin" name="iv_admin"  value="<?=$r['iv_admin']?>" disabled/>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">เลขที่ใบจอง <span class="required">*</span></label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="iv_new" name="iv_new" value="IM<?=$r['iv_id']?>" disabled/>
                        </div>
                      </div>
                     <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">ชื่อโปรแกรมทัวร์ <span class="required">*</span></label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="iv_namepro" name="iv_namepro" value="<?=$r['iv_namepro']?>" disabled/>
                        </div>
                      </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">วันเดินทาง<span class="required" >*</span></label>
                        <div class="col-md-6">
                          <input class="form-control" name="pro_dategopr" id="pro_dategopr"
                           value="<?echo ''.datethai($r['pro_datego']).' - '.datethai($r['pro_dateback']).'';?>"  disabled>
                        </div>
                      </div>
                     <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">ขาไป (วันออกเดินทาง) <span class="required" >*</span></label>
                        <div class="col-md-6">
                          <input class="form-control" type="date" id="date" name="pro_datego" value="<?=$r['pro_datego']?>" disabled>
                        </div>
                      </div>
                     <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">ขากลับ (วันกลับเดินทาง) <span class="required">*</span></label>
                        <div class="col-md-6">
                          <input class="form-control" type="date" id="date" name="pro_dateback" value="<?=$r['pro_dateback']?>" disabled>
                        </div>
                      </div>
                     <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">INVOICE :</label>
                        <div class="col-md-6">
                          <a href='https://www.imaginetourservice.com/ivnew.php?id=<?=$r[iv_id];?>' target='blank' class='btn btn-edit-color'><i class='halflings-icon file white'></i>IM<?=$r[iv_id];?></a>
                        </div>
                      </div>

                     <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">INVOICE REF :</label>
                        <div class="col-md-6">
                <?if(!empty($r['iv_ref1'])){?>
                <a href='https://www.imaginetourservice.com/ivnew.php?id=<?=$r[iv_ref1];?>' target='blank' class='btn btn-edit-color'><i class='halflings-icon file white'></i>IM<?=$r[iv_ref1];?></a>
                <?}?>
                <?if(!empty($r['iv_ref2'])){?>
                <a href='https://www.imaginetourservice.com/ivnew.php?id=<?=$r[iv_ref2];?>' target='blank' class='btn btn-edit-color'><i class='halflings-icon file white'></i>IM<?=$r[iv_ref2];?></a>
                <?}?>
                <?if(!empty($r['iv_ref3'])){?>
                <a href='https://www.imaginetourservice.com/ivnew.php?id=<?=$r[iv_ref3];?>' target='blank' class='btn btn-edit-color'><i class='halflings-icon file white'></i>IM<?=$r[iv_ref3];?></a>
                <?}?>
                        </div>
                      </div>

   <div class=" text-center" id="chkimgfieldlogo2">
               <div class="box-header" data-original-title>
            <h4 style="color:black;"><i class="icon-group icon-fw"></i><span class="break"></span> <i class="fa fa-user"></i> PAY-IN </h4>
          </div>
                      <div class="row">       
                    <div class="col-md-6">
                      <label class="control-label text-center header-form" style="float:none;text-align:center;" for="imgfieldlogo2">
                      <i class="fa fa-file-picture-o" style="margin-bottom:15px;"></i>PAYIN</label>
                  <!-- <label class="control-label" for="imgfield">รูปภาพ</label> -->
                    <ul class="img-list" id="img-list-logo">
                      <li>
                        <a href="#" class="imgfield-msg img-logo-del2" id="imgfield-logo-msg">
                          <img id="imgfield-logo-img" style="width: 50%;margin-bottom:15px;">
                          <span class="text-content"><span>ลบรูปภาพนี้ ?</span></span>
                        </a>
                      </li>
                    </ul>
                  <div class="btn btn-danger">
                    <input class="input-file" id="imgfieldlogo2" type="file" name="files[]">
                    <input type="hidden" id="imgfiles-logo" name="image_field2" >
                    <input class="input-xlarge focused" id="imgfield-msgg" type="text" disabled="" style="display: none;">
                  </div>
                    <?//<a href="#" class="imgfield-msg img-del" id="imgfield-msg"><img id="imgfield-img"></a>?>
                    <div class="progress progress-warning progress-striped active input-xlarge" id="progress-logo" style="height:30px !important; display: none;">
                      <div class="bar"></div>
                    </div>
                </div>

                <div class="col-md-6">
                     <div class="">
                       <div class="row" style="margin-bottom:15px;">
                        <label class="col-md-3 control-label" for="inputDefault" style="color:red;">TYPE <span class="required">*</span></label>
                        <div class="col-md-6">
                           <select data-plugin-selectTwo name='payment_type' id='payment_type' data-rel="chosen" class="form-control populate placeholder">
                          <option value="0">-- ชำระค่า --</option>
                          <option value="DEP">มัดจำ</option>
                          <option value="PAY">ยอดทั้งหมด</option>
                          <option value="ETC">ส่วนที่เหลือ</option>
                        </select>
                        </div>
                      </div>
                        <div class="row" style="margin-bottom:15px;">
                        <label class="col-md-3 control-label" for="inputDefault" style="color:red;">INVOICE <span class="required">*</span></label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="inputDefault" name="payment_iv" value="<?=$id?>"/>
                        </div>
                        </div>
                        <div class="row" style="margin-bottom:15px;">
                        <label class="col-md-3 control-label" for="inputDefault" style="color:red;">DATE <span class="required">*</span></label>
                        <div class="col-md-6">
                           <input class="form-control" type="date" id="date" name="payment_date" value="" required="">
                        </div>
                          </div>
                       <div class="row" style="margin-bottom:15px;">
                        <label class="col-md-3 control-label" for="inputDefault" style="color:red;">BANK <span class="required">*</span></label>
                        <div class="col-md-6">
                          <select data-plugin-selectTwo name='payment_bank' id='payment_bank' data-rel="chosen" class="form-control populate placeholder">
                          <option value="0">--เลือกธนาคาร--</option>
                          <option value="KBANK">ธ.กสิกรไทย</option>
                          <option value="BBL">ธ.กรุงเทพ</option>
                          <option value="KTB">ธ.กรุงไทย</option>
                          <option value="TMB">ธ.ทหารไทย</option>
                          <option value="SCB">ธ.ไทยพานิชย์</option>
                          <option value="GSB">ธ.ออมสิน</option>
                          <option value="BAY">ธ.กรุงศรีอยุธยา</option>
                          <option value="CITI">ธ.ซิตี้แบงค์</option>
                          <option value="KKP">ธ.เกียรตินาคิน</option>
                          <option value="CIMB">ธ.ซีไอเอ็มบีไทย</option>
                          <option value="TISCO">ธ.ทิสโก้</option>
                          <option value="TBANK">ธ.ธนชาติ</option>
                          <option value="UOBT">ธ.ยูโอบี</option>
                          <option value="SCBT">ธ.สแตนดาร์ดชาร์เตอร์ดไทย</option>
                        </select>
                        </div>
                      </div>

                </div>

                      </div>


                </div>
                <footer class="panel-footer" style="background:#fff;">
                    <div class="row">
   <div class="col-md-12 text-center" style="margin-top:20px;">
                <div class="form-actions">
                  <button type="submit" id="PackageBT" class="btn btn-danger btn-xl"><i class="fa fa-save"></i> บันทึก</button>
                  <button type="reset" onclick="window.history.back();return false;" class="btn btn-cancel-color">ยกเลิก</button>
                </div>
                </div>
                    </div>
                  </footer>

                    </form>
  <hr>
          <div class="row" style="margin-bottom:20px;margin-top:40px;">
           <? while($gpm = mysql_fetch_array($gp)){
          $re_custom = $db->findByPK('tbreceipt','receipt_pay',$gpm['payment_id'])->executeRow();?>
          <?
          if($gpm['payment_type'] == 'DEP'){
            $paytype = 'งวดมัดจำ';
          }else if($gpm['payment_type'] == 'PAY'){
            $paytype = 'งวดยอดทั้งหมด';
          }else{
            $paytype = 'งวดส่วนที่เหลือ';
          }
         
          ?>
          <div class="col-md-12">
           <div class="box-header" data-original-title>
            <h4 style="color:black;"><i class="icon-group icon-fw"></i><span class="break"></span> <i class="fa fa-money" aria-hidden="true"></i> PAY-IN (<?=$paytype;?>)</h4>
          </div>
   <div class="text-center" id="chkimgfieldlogo2">
                      <div class="row">
                    <div class="col-md-6">
                     <!--  <label class="control-label text-center header-form" style="float:none;text-align:center;" for="imgfieldlogo2">
                      <i class="fa fa-file-picture-o" style="margin-bottom:15px;"></i>PAYIN</label> -->
                  <!-- <label class="control-label" for="imgfield">รูปภาพ</label> -->
                    <ul class="img-list" id="img-list-logo">
                      <li>
                        <a href="#" class="imgfield-msg img-logo-del2" id="imgfield-logo-msg">
                          <img id="imgfield-logo-img" style="width: 50%;margin-bottom:15px;">
                          <img id="imgfield-img" src="https://www.imaginetourservice.com/payin/<? echo $gpm['payment_pic'];?>" style="width: 50%;margin-bottom:15px;">
                          <span class="text-content"><span>ลบรูปภาพนี้ ?</span></span>
                        </a>
                      </li>
                    </ul>
                    <?//<a href="#" class="imgfield-msg img-del" id="imgfield-msg"><img id="imgfield-img"></a>?>
                    <div class="progress progress-warning progress-striped active input-xlarge" id="progress-logo" style="height:30px !important; display: none;">
                      <div class="bar"></div>
                    </div>
                </div>

                <div class="col-md-6">
                     <div class="">
                       <div class="row" style="margin-bottom:15px;">
                        <label class="col-md-3 control-label" for="inputDefault" style="color:red;">TYPE <span class="required">*</span></label>
                        <div class="col-md-6">
                           <select data-plugin-selectTwo name='payment_type' id='payment_type' data-rel="chosen" class="form-control populate placeholder" disabled style="background-color:#000;">
                          <option value="0" <?if($gpm['payment_type'] == '0'){ echo 'selected'; }?>>-- ชำระค่า --</option>
                          <option value="DEP" <?if($gpm['payment_type'] == 'DEP'){ echo 'selected'; }?>> มัดจำ</option>
                          <option value="PAY" <?if($gpm['payment_type'] == 'PAY'){ echo 'selected'; }?>>ยอดทั้งหมด</option>
                          <option value="ETC" <?if($gpm['payment_type'] == 'ETC'){ echo 'selected'; }?>>ส่วนที่เหลือ</option>
                        </select>
                        </div>
                      </div>
                        <div class="row" style="margin-bottom:15px;">
                        <label class="col-md-3 control-label" for="inputDefault" style="color:red;">INVOICE <span class="required">*</span></label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="inputDefault" name="payment_iv" value="<?=$id?>" disabled/>
                        </div>
                        </div>
                        <div class="row" style="margin-bottom:15px;">
                        <label class="col-md-3 control-label" for="inputDefault" style="color:red;">DATE <span class="required">*</span></label>
                        <div class="col-md-6">
                           <input class="form-control" type="date" id="date" name="payment_date" value="<?=$gpm['payment_date']?>" disabled>
                        </div>
                      </div>
                       <div class="row" style="margin-bottom:15px;">
                        <label class="col-md-3 control-label" for="inputDefault" style="color:red;">BANK <span class="required">*</span></label>
                        <div class="col-md-6">
                          <select data-plugin-selectTwo name='payment_bank' id='payment_bank' data-rel="chosen" class="form-control populate placeholder" disabled>
                          <option value="0" <?if($gpm['payment_bank'] == '0'){ echo 'selected'; }?>>--เลือกธนาคาร--</option>
                          <option value="KBANK"  <?if($gpm['payment_bank'] == 'KBANK'){ echo 'selected'; }?>>ธ.กสิกรไทย</option>
                          <option value="BBL"  <?if($gpm['payment_bank'] == 'BBL'){ echo 'selected'; }?>>ธ.กรุงเทพ</option>
                          <option value="KTB"  <?if($gpm['payment_bank'] == 'KTB'){ echo 'selected'; }?>>ธ.กรุงไทย</option>
                          <option value="TMB" <?if($gpm['payment_bank'] == 'TMB'){ echo 'selected'; }?>>ธ.ทหารไทย</option>
                          <option value="SCB" <?if($gpm['payment_bank'] == 'SCB'){ echo 'selected'; }?>>ธ.ไทยพานิชย์</option>
                          <option value="GSB" <?if($gpm['payment_bank'] == 'GSB'){ echo 'selected'; }?>>ธ.ออมสิน</option>
                          <option value="BAY" <?if($gpm['payment_bank'] == 'BAY'){ echo 'selected'; }?>>ธ.กรุงศรีอยุธยา</option>
                          <option value="CITI" <?if($gpm['payment_bank'] == 'CITI'){ echo 'selected'; }?>>ธ.ซิตี้แบงค์</option>
                          <option value="KKP" <?if($gpm['payment_bank'] == 'KKP'){ echo 'selected'; }?>>ธ.เกียรตินาคิน</option>
                          <option value="CIMB" <?if($gpm['payment_bank'] == 'CIMB'){ echo 'selected'; }?>>ธ.ซีไอเอ็มบีไทย</option>
                          <option value="TISCO" <?if($gpm['payment_bank'] == 'TISCO'){ echo 'selected'; }?>>ธ.ทิสโก้</option>
                          <option value="TBANK" <?if($gpm['payment_bank'] == 'TBANK'){ echo 'selected'; }?>>ธ.ธนชาติ</option>
                          <option value="UOBT" <?if($gpm['payment_bank'] == 'UOBT'){ echo 'selected'; }?>>ธ.ยูโอบี</option>
                          <option value="SCBT" <?if($gpm['payment_bank'] == 'SCBT'){ echo 'selected'; }?>>ธ.สแตนดาร์ดชาร์เตอร์ดไทย</option>
                        </select>
                        </div>
                      </div>
                       <div class="row" style="margin-bottom:15px;">
                        <label class="col-md-3 control-label" for="inputDefault" style="color:red;">ออกใบเสร็จ <span class="required">*</span></label>
                        <div class="col-md-6">
                          <?if($gpm['payment_id'] == $re_custom['receipt_pay']){?>
                         <?if ($_SESSION['admin_status'] == 2) {?>
                         <?if($re_custom['receipt_status'] == '0'){?>
                                          <a href='#' class='changestatus_re' status ='1' id='<?=$re_custom[receipt_id];?>'>
                          <span class='btn btn-danger btn-block'>อนุมัติใบเสร็จ</span>
                          </a>

                          <?}else{?>
                          <a href='https://www.imaginetourservice.com/receipt_export.php?id=<?=$re_custom[receipt_id];?>' target='blank' class='btn btn-edit-color btn-block'><i class='halflings-icon file white'></i>ออกใบเสร็จแล้ว
                          </a>
                          <?}?>

                          <?}else{?>
                           <?if($re_custom['receipt_status'] == '0'){?>
                          <a href='https://www.imaginetourservice.com/receipt_export.php?id=<?=$re_custom[receipt_id];?>' target='blank' class='btn btn-edit-color btn-block'><i class='halflings-icon file white'></i>รออนุมัติใบเสร็จ</a>
                          <?}else{?>
                          <a href='https://www.imaginetourservice.com/receipt_export.php?id=<?=$re_custom[receipt_id];?>' target='blank' class='btn btn-edit-color btn-block'><i class='halflings-icon file white'></i>ออกใบเสร็จแล้ว
                          </a>
                          <?}?>
                          <?}?>
                          <?}else{?>
                          <a href='?url=receipt_ex&iv=<?=$gpm[payment_id];?>' target='blank' class='btn btn-edit-color btn-block' style="background:#000;"><i class='halflings-icon file white'></i>ออกใบเสร็จ
                          </a>
                          <?}?>
                        <a  class='btn btn-edit-color btn-block payin_del'
                        data-toggle='modal' data-target='#modalBootstrap' id='<?=$gpm[payment_id];?>' data-item-del='' style="background:#000;"><i class='halflings-icon file white'></i>ลบเปอินนี้
                          </a>

                      <a  class='btn btn-edit-color btn-block i-pass' id="BUTTON<?=$gpm[payment_id]?>" folder="<?=$folder;?>" data-id="<?=$gpm[payment_id]?>"
                          data-img="https://www.imaginetourservice.com/payin/<? echo $gpm['payment_pic'];?>" data-toggle='modal' data-target='#Modal'>
                        <i class='halflings-icon file white'></i>PRINT
                      </a>

                      </div>
                      </div>
                </div>

                      </div>


                </div>
                   <hr>
                 </div>

                 </div> 
   <?}?>

                  </div>
                </section>

            </div>
            </div>


<!--     <div class="modal fade" id="modalBootstrap" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
     <div class="modal-content">
     <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <div class="swal-icon swal-icon--warning">
    <span class="swal-icon--warning__body">
      <span class="swal-icon--warning__dot"></span>
    </span>
  </div>
       <h4 class="modal-title text-danger text-center"  id="myModalLabel">คุณต้องการที่จะลบ PAYIN <span class="del-item"></span></h4>
      </div>
    <div class="modal-footer" style="margin-top: 0;">
      <a href="#" class="mb-xs mt-xs mr-xs btn btn-default" data-dismiss="modal">Cancel</a>
      <a href="?url=payin_delete" class="mb-xs mt-xs mr-xs btn btn-danger payin_del"   data-dismiss="modal">Delete</a>
    </div>
              </div>
              </div>
              </div> -->
              
<!-- <div class="modal fade" id="myModal">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">×</button>
      <button href="" onclick="clicked()" class="btn btn-large btn-success" id="print-btn"><i class="halflings-icon white print"></i> Print this image</button>
    </div>
    <div class="modal-body">
      <center><img src="" id="img-show" style="max-height: 500px;"></center>
    </div>
  </div> -->

  <div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
   <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">×</button>
      <button href="" onclick="clicked()" class="btn btn-large btn-success" id="print-btn"><i class="halflings-icon white print"></i> Print this image</button>
    </div>
    <div class="modal-body">
      <center><img src="" id="img-show" style="max-height: 500px;"></center>
    </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>