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

$gp2 = $db->findByPK('tbpayment','payment_iv',$id)->execute();
$gp22 = $db->findByPK('tbpayment','payment_iv',$id)->execute();

$datetoday = date("d/m/Y");


$num = $r['adult_num'];
$code = $r['iv_id'];


 $todays1 = date("dd/mm/YYYY");


$book_ccc = $db->findByAttributes('tbpass',array('pass_iv =' => $id ))->execute();
$ca_book = 0;
while($c = mysql_fetch_assoc($book_ccc)){
    $ca_book++;
  }

// $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";
    // }
         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";
    }


$sum_ad= $r['adult_price'] * $r['adult_num'];
$sum_c= $r['c_price'] * $r['c_num'];
$sum_nb= $r['nb_price'] * $r['nb_num'];
$sum_s= $r['s_price'] * $r['s_num'];


$custom= $r['custom1_price'] * $r['custom1_num'];
$custom2= $r['custom2_price'] * $r['custom2_num'];

$custom3= $r['custom3_price'] * $r['custom3_num'];
$custom4= $r['custom4_price'] * $r['custom4_num'];


if($r['custom1_val'] == '0' ){
$ccustom= $r['custom1_price'] * $r['custom1_num'];
$ccustom_name_1= $r['custom1_name'];
}else{
$ccustom= '0';
$ccustom_name_1= '';
}
if($r['custom2_val'] == '0' ){
$ccustom2= $r['custom2_price'] * $r['custom2_num'];
$ccustom_name_2= $r['custom2_name'];
}else{
$ccustom2= '0';
$ccustom_name_2= '';
}
if($r['custom3_val'] == '0' ){
$ccustom3= $r['custom3_price'] * $r['custom3_num'];
$ccustom_name_3= $r['custom3_name'];
}else{
$ccustom3= '0';
$ccustom_name_2= '';
}
if($r['custom4_val'] == '0' ){
$ccustom4= $r['custom4_price'] * $r['custom4_num'];
$ccustom_name_4= $r['custom4_name'];
}else{
$ccustom4= '0';
$ccustom_name_4= $r['custom4_name'];
}

$sum_dis= $r['discount_price'] * $r['discount_sum'];
$sum_dis2= $r['cus_de_price'] * $r['cus_de_num'];
$sum_dis3= $r['cus_de_price2'] * $r['cus_de_num2'];

$sum_dis4= $r['cus_de_price3'] * $r['cus_de_num3'];
// $sum_nb
// $sum_s


$sum_mus =  $r['mus_price'] * $r['mus_num'];
$total=$sum_ad + $sum_c + $sum_nb + $sum_s + $custom + $custom2 + $custom3 + $custom4 - $sum_dis - $sum_dis2 - $sum_dis3 - $sum_dis4;


$dis_c = $sum_dis - $sum_dis2 - $sum_dis3 - $sum_dis4;
$plus_c = $custom + $custom2 + $custom3 + $custom4;

$book_all = $r['adult_num']+$r['c_num']+$r['nb_num'];



// $gp_top = $db->findorderid('tbreceipt,tbpayment','tbreceipt.receipt_pay = tbpayment.payment_id && payment_iv',$id,'payment_iv asc ,payment_iv')->execute();

// $p_c = 0;
// while($ccc = mysql_fetch_assoc($gp_top)){
// 	$p_c += $ccc['receipt_total'];
// }

$gp222 = $db->findByPK('tbpayment','payment_iv',$id)->execute();
while($gpm2 = mysql_fetch_array($gp222)){
          $re_custom = $db->findByPK('tbreceipt','receipt_pay',$gpm2['payment_id'])->executeRow();
          $p_c += $re_custom['receipt_total'];
      }

// if($gpm['payment_type'] == 'DEP'){

$gp_dep = $db->findByPK('tbpayment','payment_iv',$id)->execute();
while($gp_dep2 = mysql_fetch_array($gp_dep)){
          $re_dep = $db->findByPK('tbreceipt','receipt_pay',$gp_dep2['payment_id'])->executeRow();
          if($gp_dep2['payment_type'] == 'DEP'){
          $p_dep += $re_dep['receipt_total'];
      }
      }

      $total_pay = $total - $p_c;


$gpland = $db->findByPK('tbpayment','payment_iv',$id)->execute();
while($land_pay = mysql_fetch_array($gpland)){
     if ($land_pay['payment_ref'] == '1') {
       $p_land += $land_pay['payment_total'];
     }
      }
   $total_pay_land = $r['iv_land_total'] - $p_land;

   $total_land_sent = $p_c - $p_land;

$com_sale = $r['iv_com_sale'] * $book_all;


if(!empty($r['mus_time'])){
  $timemus = $r['mus_time'];
}else{
 $timemus = '15:00';
}
if(!empty($r['date_line_time'])){
$timedateline = $r['date_line_time'];
}else{
 $timedateline = '15:00';
}

 ?>

<div id="content">



  <div class="container-fluid p-4" style="    font-family: 'Kanit', sans-serif;">
          	<div class="row">
          		<div class="col-md-8 text-dark">
          		<h4 style="">IM<?=$id;?> : <?=$r['iv_codepro'];?>/<?=$r['iv_namepro'];?></h4>
          		<h4> วันเดินทาง : <?=datethai($r['pro_datego']);?> - <?=datethai($r['pro_dateback']);?></h4>
          		<h3 style="margin-bottom:5px;margin-top:5px;">เซลล์ : <?=$r['iv_admin'];?></h3>
              <h5 style="margin-bottom:20px;margin-top:5px;">ลูกค้า : <?=$r['cus_name'];?> : <?=$r['cus_tel'];?></h5>
          		</div>
          		<div class="col-md-4 text-dark" style="margin-bottom:20px;">
          		<!-- <a class="btn btn-success btn-block" value="PRINT" onclick="printWindow();"><i class="halflings-icon white print"></i> PRINT </a> -->
                           <? if ($r['iv_status_2'] == '0') { if ($total_pay == '0') {?>
                           	<a class='btn btn-success changestatus_iv btn-block' href='#' status ='1' id='<?=$r[iv_id];?>'>สถานะ ชำระครบแล้ว</a>
                           	<?}else{?>
                            <a class='btn btn-primary changestatus_iv btn-block' href='#' status ='1' id='<?=$r[iv_id];?>'>สถานะ ปกติ</a>
                           <?}}else{?>
                           	<a class='btn btn-dark changestatus_iv btn-block' href='#' status ='0' id='<?=$r[iv_id];?>'>สถานะ ยกเลิกแล้ว</a>
                           <?}?>
          	</div>
          	</div>


          </div>

          <!-- start: page -->
          <div class="container-fluid p-4" style="    font-family: 'Kanit', sans-serif;">
          	<div class="row">
          		<div class="col-md-3 col-4 col-xs-4">
          			<section class="panel">
          			<button type="button" class="btn btn-danger btn-block"data-toggle='modal' data-target='#iv_data_update'>แก้ไขอินวอย <br>IM<?=$id;?></button>
          		</section>
          		</div>
          		<div class="col-md-3 col-4 col-xs-4">
          			<section class="panel">
          			<button type="button" class="btn btn-primary btn-block" data-toggle='modal' data-target='#payin_data_update'>จ่ายเงิน <br>IM<?=$id;?></button>
          		</section>
          		</div>

          		<div class="col-md-3 col-4 col-xs-4">
          			<section class="panel">
          			<button type="button" class="btn btn-secondary text-muted btn-block" data-toggle='modal' data-target='#doc_data_update'>เพิ่มเอกสาร <br>IM<?=$id;?></button>
          		</section>
          		</div>

          		<div class="col-md-3 col-4 col-xs-4">
          			<section class="panel">

          			<!-- <button type="button" class="btn btn-warning btn-block" data-toggle='modal' data-target='#iv_pass_update'>PASSPORT<br>IM<?=$id;?></button> -->
                <a  class="btn btn-warning btn-block" href="#passports">PASSPORT<br>IM<?=$id;?></a>

          		</section>
          		</div>


          	</div>


  <div class="row m-auto" style="padding-top:20px;padding-bottom:20px;font-family: 'Kanit', sans-serif;">
<div class="col-xl-2 col-md-2 col-xs-6">
<div class="panel panel-default">
  <div class="panel-heading text-center">สถานะ BOOK LAND</div>
  <div class="panel-body text-center">
  <?if(!empty($r['iv_status_work1'])){?>
  <span class="text-success"><?=$r['iv_status_work1'];?></span> 
  <?}else{?>
  <span class="text-danger">ยังไม่มีการดำเนินการ</span> 
  <?}?>
  </div>
</div>
</div>

<div class="col-xl-2 col-md-2 col-xs-6">
<div class="panel panel-default">
  <div class="panel-heading text-center">เอกสารที่ได้จากลูกค้า</div>
  <div class="panel-body text-center">
  <?if(!empty($r['iv_status_work2'])){?>
  <span class="text-success"><?=$r['iv_status_work2'];?></span> 
  <?}else{?>
  <span class="text-danger">ยังไม่มีการดำเนินการ</span> 
  <?}?>
  </div>
</div>
</div>

<div class="col-xl-2 col-md-2 col-xs-6">
<div class="panel panel-default">
  <div class="panel-heading text-center">เอกสารที่ได้ส่งให้ LAND</div>
  <div class="panel-body text-center">
  <?if(!empty($r['iv_status_work3'])){?>
  <span class="text-success"><?=$r['iv_status_work3'];?></span> 
  <?}else{?>
  <span class="text-danger">ยังไม่มีการดำเนินการ</span> 
  <?}?>
  </div>
</div>
</div>


<div class="col-xl-2 col-md-2 col-xs-6">
<div class="panel panel-default">
  <div class="panel-heading text-center">ใบนัดหมาย</div>
  <div class="panel-body text-center">
  <?if(!empty($r['iv_status_work4'])){?>
  <span class="text-success"><?=$r['iv_status_work4'];?></span> 
  <?}else{?>
  <span class="text-danger">ยังไม่มีการดำเนินการ</span> 
  <?}?>
  </div>
</div>
</div>



<div class="col-xl-2 col-md-2 col-xs-6">
<div class="panel panel-default">
  <div class="panel-heading text-center">แก้ไขสถานะ</div>
  <div class="panel-body text-center">
      <button type="button" class="btn btn-danger btn-block" data-toggle='modal' data-target='#work_status'>แก้ไขสถานะ</button>
  </div>
</div>
</div>


<div class="col-xl-2 col-md-2 col-xs-6">
<div class="panel panel-default">
  <div class="panel-heading text-center">ค่า Com ของคุณ</div>
  <div class="panel-body text-center">
  <h3 class="text-primary" style="margin-top:1px;"><?=$com_sale;?></h3> 
  </div>
</div>
</div>

  </div>

          </div>


            <div class="row" style="font-family: 'Kanit', sans-serif;">
              <div class="col-lg-12">
               <section class="panel panel-danger">
                  <header class="panel-heading">
                    <div class="panel-actions">
                      <a href="#" class="fa fa-caret-down"></a>
                    </div>
                    <h2 class="panel-title">รายละเอียด ( IM<?=$id;?> )</h2>
                  </header>
                  <div class="panel-body">

                    <div class="form-horizontal form-bordered" action="" method="post" enctype="multipart/form-data" 
                     code="<?=$id;?>" style="padding-bottom:30px;">

   <div class="row">
<div class="col-md-12 text-center">
   <div class="box-header" data-original-title style="padding-top:20px;padding-bottom:20px;">

<ul class="nav nav-tabs" id="myTab" role="tablist">
  <li class="nav-item active">
    <a style="margin-bottom:20px;" class="text-center mb-3" 
            id="nav-home-tab" data-toggle="tab" href="#nav-custoummer" role="tab" aria-controls="nav-custoummer">ข้อมูลใบจอง (สำหรับลูกค้า)</a>
  </li>
  <li class="nav-item">
    <a style="margin-bottom:20px;" class="text-center mb-3" 
            id="nav-home-tab" data-toggle="tab" href="#nav-whos" role="tab" aria-controls="nav-whos">ข้อมูลใบจอง (โฮลเซล)</a>
  </li>
  <li class="nav-item">
     <a  style="margin-bottom:20px;" class="btn btn-danger" data-toggle='modal' data-toggle='iv_data2_update' data-target='#iv_data2_update'>จัดการข้อมูล <?=$r['iv_wholesale'];?></a>
  </li>
</ul>


          </div>
</div>
     <div class="col-md-12">
          <div class="tab-content" id="nav-tabContent">
<div class="tab-pane active" id="nav-custoummer" role="tabpanel" aria-labelledby="nav-custoummer-tab">
          <div class="row">
            <div class="col-md-6">
                         <div class="alert alert-warning" role="alert" style="margin-top:20px;">
             <h2 class="text-danger">NOTE :</h2>
             <span style="font-size:1.6rem;"><?=$r['iv_note'];?></span>
            </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="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">เบอร์ติดต่อ / EMAIL <span class="required">*</span></label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="cus_tel" name="iv_tel"  value="<?=$r['cus_tel']?>" disabled style = "margin-bottom:5px;">
                           <input type="text" class="form-control" id="cus_mail" name="cus_mail"  value="<?=$r['cus_mail']?>" 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-system.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-system.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-system.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-system.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>
             <div class="col-md-6">
                 <h4 class="d-flex justify-content-between align-items-center" style="margin-bottom:20px;margin-top:20px;">
            <h4 class="text-danger" style="margin-bottom:20px;">ข้อมูลรายการ IM<?=$id;?> (ส่วนของลูกค้า)</h4>
          </h4>
          <ul class="list-group mb-3">
             <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-dark">จำนวนผู้เดินทาง</h5>
              </div>
              <h4 class="text-muted"><?=$book_all;?> ท่าน (ท่านละ <?=$r[adult_price];?>)</h4>
            </li>

            <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-dark">ราคาทั้งหมด</h5>
              </div>
              <h4 class="text-muted"><?=number_format($total);?></h4>
            </li>

               <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-dark">พักเดี่ยว / ราคาเพิ่ม / ส่วนลด</h5>
              </div>
              <h4 class="text-success"> +<?=number_format($sum_s);?> / +<?=number_format($plus_c);?> / <span class="text-danger">(-<?=number_format($dis_c);?>)</span> </h4>
            </li>
            <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-primary">งวดมัดจำ (ยอด <?=$sum_mus;?>)</h5>
              </div>
              <h4 class="text-primary">จ่ายแล้ว <?=number_format($p_dep);?></h4>
            </li>
            <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-success">จ่ายแล้ว</h5>
              </div>
              <h4 class="text-success"><?=number_format($p_c);?></h4>
            </li>


            <li class="list-group-item d-flex justify-content-between lh-condensed text-danger">
              <div>
                <h5 class="my-0 text-danger">เหลือที่ลูกค้าต้องจ่าย</h5>
              </div>
              <h4 class="text-danger"><?=number_format($total_pay);?></h4>
            </li>


          </ul>

             </div>

</div>

          </div>


          	
            
	<div class="tab-pane" id="nav-whos" role="tabpanel" aria-labelledby="nav-whos-tab">
 <div class="row">
  <div class="col-md-6">
  <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">Wholesale<span class="required">*</span></label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="inputDefault" name="iv_wholesale" value="<?=$r['iv_wholesale']?>" 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="inputDefault" name="iv_land_total" value="<?=$r['iv_land_total']?>" disabled/>
                        </div>
</div>

  <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">Commission<span class="required">*</span></label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="inputDefault" name="iv_com" value="<?=$r['iv_com']?>" 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">
                          <?
                $doc2 = $db->findorderid('tbdoc,tbiv','tbdoc.doc_iv = tbiv.iv_id && doc_iv',$id,'doc_id asc ,doc_id')->execute();
                while ($docc2 = mysql_fetch_array($doc2)){
                if($docc2['doc_type'] == '1'){?>
                <? if(!empty($docc2['doc_ref'])){?>
                  <a href="<?=$docc2[doc_ref]?>" target="_blank" class="btn btn-danger"><?=$docc2[doc_text]?></a>
                <?}?>
                <? if(!empty($docc2['doc_file'])){?>
                  <a href="<?=$docc2[doc_file]?>" class="btn btn-danger"><?=$docc2[doc_text]?></a>
                <?}?>
                <?}?>
                <?}?>
                        </div>
</div>



            <div class="alert alert-danger" role="alert" style="margin-top:20px;">
             <h2>NOTE :</h2>
             <?=$r['iv_note'];?>
            </div>


    </div>
             <div class="col-md-6">
                 <h4 class="d-flex justify-content-between align-items-center" style="margin-bottom:20px;margin-top:20px;">
            <h4 class="text-danger" style="margin-bottom:20px;">ข้อมูลรายการ IM<?=$id;?> (LAND)</h4>
          </h4>
          <ul class="list-group mb-3">

             <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-dark">Wholesale</h5>
              </div>
              <h4 class="text-muted"><?=$r[iv_wholesale];?></h4>
            </li>

             <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-dark">จำนวนผู้เดินทาง</h5>
              </div>
              <h4 class="text-muted"><?=$book_all;?> ท่าน (ท่านละ <?=$r[adult_price];?>)</h4>
            </li>

            <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-dark">ราคาที่ต้องจ่าย LAND</h5>
              </div>
              <h4 class="text-muted"><?=number_format($r[iv_land_total]);?></h4>
            </li>

            <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-dark">พักเดี่ยว / ราคาเพิ่ม / ส่วนลด</h5>
              </div>
              <h4 class="text-success"> +<?=number_format($sum_s);?> / +<?=number_format($plus_c);?> / <span class="text-danger">(-<?=number_format($dis_c);?>)</span> </h4>
            </li>

             <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-dark">Commission</h5>
              </div>
              <h4 class="text-muted"><?=number_format($r[iv_com]);?></h4>
            </li>


            <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                <h5 class="my-0 text-success">จ่าย LAND แล้ว</h5>
              </div>
              <h4 class="text-success"><?=number_format($p_land);?></h4>
            </li>


            <li class="list-group-item d-flex justify-content-between lh-condensed text-danger">
              <div>
                <h5 class="my-0 text-danger">เหลือที่ต้องจ่าย LAND</h5>
              </div>
              <h4 class="text-danger"><?=number_format($total_pay_land);?></h4>
            </li>

            <li class="list-group-item d-flex justify-content-between lh-condensed text-success">
              <div>
                <h5 class="my-0 text-success">ยอดคงเหลือเข้าออฟฟิศ</h5>
              </div>
              <h4 class="text-success"><?=number_format($total_land_sent);?> 
              <span style="font-size:0.8rem;" class="text-dark">(ลูกค้าจ่าย <?=number_format($p_c);?> - จ่ายให้ land <?=number_format($p_land);?>) </span></h4>
            </li>


          </ul>

             </div>

</div>



    </div>



          </div>

     </div>

   </div>

 </div>



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





          <!-- start: page -->

    <div class="row">
      <div class="col-md-6">
 <section class="panel">
           <header class="panel-heading bg-primary">
                    <div class="panel-actions">
                      <a href="#" class="fa fa-caret-down"></a>
                    </div>
                    <h2 class="panel-title text-white" style="color:#fff;">บันทึกการจ่ายเงิน <span style="font-size:1.5rem;font-weight:400;" class="label label-dark"> CUSTOMMER</span>
                    </h2>
                  </header>
                  <div class="panel-body" style="overflow-x:auto;">
        <table class="table table-bordered table-striped mb-none" id="datatable-tabletoolss2">
                  <thead>
                    <tr>
                      <th>NO</th>
                      <th>PIC</th>
                      <th>วันที่ชำระ</th>
                      <th>ประเภทการจ่าย</th>
                      <th>PAY-IN</th>
                      <th>ธนาคาร</th>
                      <th>ใบเสร็จ</th>
                      <th>ชำระแล้ว</th>
                      <th>SALES</th>
                      <th>Actions</th>
                    </tr>
                  </thead>
                  <tbody>

     <?    $i=0;
          while($gpm = mysql_fetch_array($gp2)){
          if ($gpm['payment_ref'] == '0') {
          $re_custom = $db->findByPK('tbreceipt','receipt_pay',$gpm['payment_id'])->executeRow();?>
          <?
          if($gpm['payment_type'] == 'DEP'){
            $paytype = '<span class="badge bg-primary" style="   font-weight: 500;padding: 10px;font-size: 1.2rem;">งวดมัดจำ</span>';
          }else if($gpm['payment_type'] == 'PAY'){
            $paytype = '<span class="badge bg-success" style="font-weight: 500;padding: 10px;font-size: 1.2rem;">งวดยอดทั้งหมด</span>';
          }else{
            $paytype = '<span class="badge bg-warning" style="font-weight: 500;padding: 10px;font-size: 1.2rem;">งวดส่วนที่เหลือ</span>';
          }

          if($gpm['payment_bank'] == '0'){
            $bankname = 'ยังไม่เลือกธนาคาร';
          }else if($gpm['payment_bank'] == 'KBANK'){
           $bankname = 'ธ.กสิกรไทย';
          }else if($gpm['payment_bank'] == 'BBL'){
            $bankname = 'ธ.กรุงเทพ';
          }else if($gpm['payment_bank'] == 'KTB'){
            $bankname = 'ธ.กรุงไทย';
          }else if($gpm['payment_bank'] == 'TMB'){
            $bankname = 'ธ.ทหารไทย';
          }else if($gpm['payment_bank'] == 'SCB'){
            $bankname = 'ธ.ไทยพานิชย์';
          }else if($gpm['payment_bank'] == 'GSB'){
            $bankname = 'ธ.ออมสิน';
          }else if($gpm['payment_bank'] == 'BAY'){
            $bankname = 'ธ.กรุงศรีอยุธยา';
          }else if($gpm['payment_bank'] == 'CITI'){
            $bankname = 'ธ.ซิตี้แบงค์';
          }else if($gpm['payment_bank'] == 'KKP'){
            $bankname = 'ธ.เกียรตินาคิน';
          }else if($gpm['payment_bank'] == 'CIMB'){
            $bankname = 'ธ.ซีไอเอ็มบีไทย';
          }else if($gpm['payment_bank'] == 'TISCO'){
            $bankname = 'ธ.ทิสโก้';
          }else if($gpm['payment_bank'] == 'TBANK'){
            $bankname = 'ธ.ธนชาติ';
          }else if($gpm['payment_bank'] == 'UOBT'){
            $bankname = 'ธ.ยูโอบี';
          }else if($gpm['payment_bank'] == 'SCBT'){
            $bankname = 'ธ.สแตนดาร์ดชาร์เตอร์ดไทย';
          }else{
            $bankname = 'ไม่พบธนาคาร';
          }
          ?>
                <?php
                    echo "<tr>";  $i++ ;
                    echo "<td>$i</td>";
                    echo "    <td class='center'>
                    <img data-enlargable src='https://www.imaginetourservice-system.com/payin/$gpm[payment_pic]'' style='width:100px;' id='$pay[payment_id]'>
                    </td>";
                    echo "    <td> ".DateThai($gpm[payment_date])."</td>";
                    echo "    <td class='center'>$paytype</td>";
                            echo "<td class='center'>
                      <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-system.com/payin/$gpm[payment_pic]' data-toggle='modal' data-target='#Modal'>
                        <i class='halflings-icon file white'></i>PRINT
                      </a>
                            </td>";

                            echo " <td class='center'>$bankname";
                            echo "</td>";

                           echo "<td class='center'>";
                          if ($_SESSION['admin_status'] == 2) {
                          if($re_custom['receipt_status'] == '0'){
                          echo "<a href='#' class='changestatus_re' status ='1' id='$re_custom[receipt_id]'>
                          <span class='btn btn-danger btn-block'>อนุมัติใบเสร็จ</span></a>";
                          }else{
                          echo "<a href='https://www.imaginetourservice-system.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'){
                          echo "<a href='https://www.imaginetourservice-system.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(!empty($re_custom['receipt_id'])){
                          echo "<a href='https://www.imaginetourservice-system.com/receipt_export.php?id=$re_custom[receipt_id]' style='font-size:0.9rem;' target='_blank' class='btn btn-edit-color btn-block'><i class='halflings-icon file white'></i>ออกใบเสร็จแล้ว
                          </a>";
                          echo "<a href='https://www.imaginetourservice-system.com/receipt_export2.php?id=$re_custom[receipt_id]' style='font-size:0.9rem;' target='_blank' class='btn btn-edit-color btn-block'><i class='halflings-icon file white'></i>ออกตามยอดโอน
                          </a>";
                           }

                          }
                          }

                          if($re_custom['receipt_id'] == ''){
                          echo " <a href='?url=receipt_ex2&iv=$gpm[payment_id]' class='btn btn-edit-color btn-block' style='background:#000;'><i class='halflings-icon file white'></i>ออกใบเสร็จ
                          </a>";
                          }
                          echo "</td>";  
     

                          // echo "<td class='center'>
                          //   <a class='btn btn-danger' href='?url=iv_edit&iv=$gpm[iv_id]'>
                          //   <i class='fa fa-edit fa-x'></i>  </a>";
                          // echo "</td>";  
                            


                        echo " <td class='center'>".number_format($re_custom[receipt_total])."";
                        echo "</td>";
                        echo " <td class='center'><span style='font-weight: 600;'>$r[iv_admin]</span>";
                        echo "</td>";
                        echo " <td class='center'>
                        <a  class='btn btn-danger delete-confirm'
                        data-toggle='modal' data-target='#modalBootstrap2' id='$gpm[payment_id];' data-item-del='' >
                        <i class='fa fa-trash-o fa-x'></i>
                          </a>
                            ";
                          echo "</td>";
                          echo "</tr>";


                   } }//mysql_close($link);
                    ?> 
                  </tbody>
                </table>
                  </div>
                </section>

      </div>
      <div class="col-md-6">
    <section class="panel">
           <header class="panel-heading bg-primary">
                    <div class="panel-actions">
                      <a href="#" class="fa fa-caret-down"></a>
                    </div>
                    <h2 class="panel-title text-white" style="color:#fff;">บันทึกการจ่ายเงิน <span style="font-size:1.5rem;font-weight:400;" class="label label-dark"> LAND</span></h2>
                  </header>
                  <div class="panel-body" style="overflow-x:auto;">
        <table class="table table-bordered table-striped mb-none" id="datatable-tabletoolss">
                  <thead>
                    <tr>
                      <th>NO</th>
                      <th>PIC</th>
                      <th>วันที่ชำระ</th>
                      <th>ประเภทการจ่าย</th>
                      <th>PAY-IN</th>
                      <th>ธนาคาร</th>
                      <th>ชำระแล้ว</th>
                      <th>SALES</th>
                      <th>Actions</th>
                    </tr>
                  </thead>
                  <tbody>

     <?    $i=0;
          while($gpm = mysql_fetch_array($gp22)){
          if ($gpm['payment_ref'] == '1') {?>
          <?
          if($gpm['payment_type'] == 'DEP'){
            $paytype = '<span class="badge bg-primary" style="   font-weight: 500;padding: 10px;font-size: 1.2rem;">งวดมัดจำ</span>';
          }else if($gpm['payment_type'] == 'PAY'){
            $paytype = '<span class="badge bg-success" style="font-weight: 500;padding: 10px;font-size: 1.2rem;">งวดยอดทั้งหมด</span>';
          }else{
            $paytype = '<span class="badge bg-warning" style="font-weight: 500;padding: 10px;font-size: 1.2rem;">งวดส่วนที่เหลือ</span>';
          }

          if($gpm['payment_bank'] == '0'){
            $bankname = 'ยังไม่เลือกธนาคาร';
          }else if($gpm['payment_bank'] == 'KBANK'){
           $bankname = 'ธ.กสิกรไทย';
          }else if($gpm['payment_bank'] == 'BBL'){
            $bankname = 'ธ.กรุงเทพ';
          }else if($gpm['payment_bank'] == 'KTB'){
            $bankname = 'ธ.กรุงไทย';
          }else if($gpm['payment_bank'] == 'TMB'){
            $bankname = 'ธ.ทหารไทย';
          }else if($gpm['payment_bank'] == 'SCB'){
            $bankname = 'ธ.ไทยพานิชย์';
          }else if($gpm['payment_bank'] == 'GSB'){
            $bankname = 'ธ.ออมสิน';
          }else if($gpm['payment_bank'] == 'BAY'){
            $bankname = 'ธ.กรุงศรีอยุธยา';
          }else if($gpm['payment_bank'] == 'CITI'){
            $bankname = 'ธ.ซิตี้แบงค์';
          }else if($gpm['payment_bank'] == 'KKP'){
            $bankname = 'ธ.เกียรตินาคิน';
          }else if($gpm['payment_bank'] == 'CIMB'){
            $bankname = 'ธ.ซีไอเอ็มบีไทย';
          }else if($gpm['payment_bank'] == 'TISCO'){
            $bankname = 'ธ.ทิสโก้';
          }else if($gpm['payment_bank'] == 'TBANK'){
            $bankname = 'ธ.ธนชาติ';
          }else if($gpm['payment_bank'] == 'UOBT'){
            $bankname = 'ธ.ยูโอบี';
          }else if($gpm['payment_bank'] == 'SCBT'){
            $bankname = 'ธ.สแตนดาร์ดชาร์เตอร์ดไทย';
          }else{
            $bankname = 'ไม่พบธนาคาร';
          }
          ?>
                <?php
                    echo "<tr>";  $i++ ;
                    echo "<td>$i</td>";
                    echo "    <td class='center'>
                    <img data-enlargable src='https://www.imaginetourservice-system.com/payin/$gpm[payment_pic]'' style='width:100px;'>
                    </td>";
                    echo "    <td> ".DateThai($gpm[payment_date])."</td>";
                    echo "    <td class='center'>$paytype</td>";
                            echo "<td class='center'>
                      <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-system.com/payin/$gpm[payment_pic]' data-toggle='modal' data-target='#Modal'>
                        <i class='halflings-icon file white'></i>PRINT
                      </a>
                            </td>";
                            echo " <td class='center'>$bankname";
                            echo "</td>";
                          // echo "<td class='center'>
                          //   <a class='btn btn-danger' href='?url=iv_edit&iv=$gpm[iv_id]'>
                          //   <i class='fa fa-edit fa-x'></i>  </a>";
                          // echo "</td>";  
                        echo " <td class='center'>".number_format($gpm[payment_total])."";
                        echo "</td>";
                        echo " <td class='center'><span style='font-weight: 600;'>$r[iv_admin]</span>";
                        echo "</td>";
                        echo " <td class='center'>
                        <a  class='btn btn-danger delete-confirm'
                        data-toggle='modal' data-target='#modalBootstrap2' id='$gpm[payment_id];' data-item-del='' >
                        <i class='fa fa-trash-o fa-x'></i>
                          </a>
                            ";
                          echo "</td>";
                          echo "</tr>";


                   } }//mysql_close($link);
                    ?> 
                  </tbody>
                </table>
                  </div>
                </section>

      </div>
    </div>






 <!-- start: page -->
 <div class="row">
 	<div class="col-md-6">
<section class="panel">
                  <header class="panel-heading bg-warning" style="position: relative;">
                    <div class="panel-actions">
                      <a href="#" class="fa fa-caret-down"></a>
                    </div>
                    <h2 class="panel-title" style="color:#fff;">Passport</h2>
                     
                  </header>
                  <div class="panel-body" style="overflow-x:auto;">
                 <!--     <button type="button" class="btn btn-danger text-white btn-block" data-toggle='modal' data-target='#pass_data_add' style="margin-bottom:10px;">เพิ่มหน้าพาส <br>IM<?=$id;?></button> -->

  <div class="row" id="passports">   
<div class="col-xl-12">
<?if($ca_book == '0'  || $ca_book < $r['adult_num']){?>
 <form class="form-horizontal" name="form_pass_data" id="form_pass_data" method="post" code="<?=$code;?>">
  <table>
    <?$x =1;
      $num = $r['adult_num'] - $ca_book;?>
    <tr style=" background: #e0331e;">
      <th align="center">กรุณาเพิ่มหน้าพาส อีก <?=$num;?> ท่าน ให้ครบ</th>
    </tr>
    <?
      while($x <= $num) {
      ?>
    <tr>
       <td> <input class="form-control" type="hidden" id="name<?=$x?>" name="name<?=$x?>" value="<?=$ads?>"> </td>
    </tr>
    <? $x++ ?> <? } ?>
  </table>
                
                <input class="text" type="hidden" id="allx" type="text" name="allx" style="text-transform:uppercase" value="<?=$x-1?>">
                <input class="text" type="hidden" id="code" type="text" name="code" style="text-transform:uppercase" value="<?=$code?>">
                
               <div class="col-md-12 text-center p-5 mb-5" style="margin-top:20px;margin-bottom: 20px;">
                <div class="form-actions">
                  <button type="submit" id="PackageBT" class="btn btn-danger btn-block"><i class="fa fa-save"></i> SUBMIT</button>
                </div>
                </div>
            </form>


        <table class="table table-bordered table-striped mb-none" id="datatable-tabletoolss">
                  <thead>
                    <tr>
                      <th>NO</th>
                      <th style="width:120px;">PIC</th>
                      <th>Passport num</th>
                      <th>Actions</th>
                    </tr>
                  </thead>
                  <tbody>


     <? 
      $i =0;
      $x =1;
      $book_pass22 = $db->findByAttributes('tbpass',array('pass_iv =' => $id ))->execute();
// $r = $db->findByPK('tb_programe','programe_id',$_GET['id'])->executeRow();
$book_pass = $db->findorderid('tbpass,tbiv','tbpass.pass_iv = tbiv.iv_id && pass_iv',$id,'pass_id asc ,pass_id')->execute();
     while ($gpm = mysql_fetch_array($book_pass)){
      $x++
          ?>
          <?
 if($gpm['pass_pic'] == ''){
                      $input = 'block';
                      $showimg = 'none';
                    } else {
                      $input = 'none';
                      $showimg = 'block';
                    }
          ?>
                <?php
                      $folder = '../pass';
                        $path_f = 'pass';
                        $path = 'https://www.imaginetourservice-system.com/'.$path_f.'/'.$gpm['pass_pic'];
                      $path2 = 'https://www.imaginetourservice-system.com/'.$path_f.'/'.$gpm['pass_pic'];
                    echo "<tr>";  $i++ ;
                    echo "<td>$i</td>";
                   echo " <td class='center'> 
                          <img id='imgfield-img<?=$gpm[pass_id]?>' class='img-link' src='".$folder."/".$gpm[pass_pic]."' data-img='".$gpm[pass_pic]."' style='width:150px;margin-bottom:15px;'>
                        <a  class='btn btn-edit-color btn-block i-pass' id='BUTTON".$gpm[pass_id]."' folder='<?=$folder;?>' data-id='".$gpm[pass_id]."'
                          data-img='https://www.imaginetourservice-system.com/pass/".$gpm[pass_pic]."' data-toggle='modal' data-target='#Modal2'>
                        <i class='halflings-icon file white'></i>PRINT
                      </a> ";
                    echo "</td>";
                    echo "<td>".$gpm[pass_num]."</td>";
                        echo " <td class='center'>
                        <a  class='btn btn-danger delete-confirm'
                        data-toggle='modal' data-target='#modalBootstrap3' id='$gpm[pass_id];' data-item-del='' >
                        <i class='fa fa-trash-o fa-x'></i>
                          </a>
                            ";
                          echo "</td>";
                    echo "</tr>";

                  }//mysql_close($link);
                    ?> 
                  </tbody>
                </table>
                
<?}else{?>

<form class="form-horizontal" name="form_pass_data" id="form_pass_data" method="post" code="<?=$code;?>">
<table class="table table-bordered table-striped mb-none" id="datatable-tabletoolss">
    <tr style="background: #e0331e;color:#fff;">
      <th align="center" class="text-center" style="width:30px;color:#fff;">NO</th>
      <th align="center" style="width:100px;color:#fff;">Passport</th>
      <th align="center" style="color:#fff;">Passport DETAIL</th>
    </tr>
            <?
      $i =0;
      $x =1;
      $book_pass22 = $db->findByAttributes('tbpass',array('pass_iv =' => $id ))->execute();
// $r = $db->findByPK('tb_programe','programe_id',$_GET['id'])->executeRow();
$book_pass = $db->findorderid('tbpass,tbiv','tbpass.pass_iv = tbiv.iv_id && pass_iv',$id,'pass_id asc ,pass_id')->execute();
     while ($cp = mysql_fetch_array($book_pass)){
      $x++
      ?>
        <?
                    if($cp['pass_pic'] == ''){
                      $input = 'block';
                      $showimg = 'none';
                    } else {
                      $input = 'none';
                      $showimg = 'block';
                    }
                    ?>
    <tr><?$i++?>
      <td class="text-danger"><h2><?=$i;?></h2></td>
      <td>
            <input type="hidden" class="input-xlarge focused" id="edits" name="edits" value="edits">
            <input type="hidden" class="input-xlarge focused" id="idpro<?=$x?>" name="idpro<?=$x?>" value="<?=$cp[pass_id];?>">
      <input class="input-file imgfieldlogo3" id="fileupload<?=$cp[pass_id]?>" type="file" name="files[]" style="display: <?=$input;?>;" data-id="<?=$cp[pass_id]?>">
                    <input type="hidden" name="image_field<?=$x;?>" id="N<?=$cp[pass_id]?>" value="<?=$cp[pass_pic]?>">
                    <ul class="img-list" id="img-list<?=$cp[pass_id]?>" style="display: <?=$showimg;?>;">
                      <li class="imgfield-msg" id="imgfield-msg<?=$cp[pass_id]?>">
                        <?php
                        $folder = '../pass';
                        $path_f = 'pass';
                          $path = 'https://www.imaginetourservice-system.com/'.$path_f.'/'.$cp['pass_pic'];
                          $path2 = 'https://www.imaginetourservice-system.com/'.$path_f.'/'.$cp['pass_pic'];
                        ?>
                          <img id="imgfield-img<?=$cp[pass_id]?>" class="img-link" src="<? echo $folder;?>/<? echo $cp['pass_pic'];?>" data-img="<? echo $cp['pass_pic'];?>" style="width:200px;margin-bottom:15px;">
<!--                   <a href="#" class="pass_del_payin" id="imgfiles">
                    <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" id="P<?=$cp[pass_id]?>" style="height:30px !important; display: none;">
                      <div class="bar" id="PB<?=$cp[pass_id]?>"></div>
                    </div>

     </td>
       <td> 
<!--         <div class="col-md-2"><label>รายละเอียด</label></div> -->
<div class="row">
  <div class="col-md-12" style="margin-bottom:15px;">
      <input class="form-control" type="text" id="pass_num<?=$x?>" name="pass_num<?=$x?>" value="<?=$cp[pass_num];?>" placeholder="Passport num">
  </div>
        <div class="col-md-2">
                <select class="form-control" id="pass_title_eg<?=$x?>" name="pass_title_eg<?=$x?>">
        <option value="MR" <? 
                  if($cp['pass_title_eg'] == 'MR'){
                    echo "selected";
                  } 
                  ?>>MR</option>
                  <option value="MSTR" <? 
                  if($cp['pass_title_eg'] == 'MSTR'){
                    echo "selected";
                  } 
                  ?>>MSTR</option>
                  <option value="MRS" <? 
                  if($cp['pass_title_eg'] == 'MRS'){
                    echo "selected";
                  } 
                  ?>>MRS</option>
                  <option value="MISS" <? 
                  if($cp['pass_title_eg'] == 'MISS'){
                    echo "selected";
                  } 
                  ?>>MISS</option>
                  <option value="MS" <? 
                  if($cp['pass_title_eg'] == 'MS'){
                    echo "selected";
                  } 
                  ?>>MS</option>
                  <option value="PHRA" <? 
                  if($cp['pass_title_eg'] == 'PHRA'){
                    echo "selected";
                  } 
                  ?>>PHRA</option>
                  <option value="PHRAKHRU" <? 
                  if($cp['pass_title_eg'] == 'PHRAKHRU'){
                    echo "selected";
                  } 
                  ?>>PHRAKHRU</option>
                  <option value="PHRAMAHA" <? 
                  if($cp['pass_title_eg'] == 'PHRAMAHA'){
                    echo "selected";
                  } 
                  ?>>PHRAMAHA</option>
                  <option value="PHRAATHIKAN" <? 
                  if($cp['pass_title_eg'] == 'PHRAATHIKAN'){
                    echo "selected";
                  } 
                  ?>>PHRAATHIKAN</option>
                </select>
          </div>
         <div class="col-md-5">
          <input class="form-control" type="text" id="pass_name_eg<?=$x?>" name="pass_name_eg<?=$x?>" value="<?=$cp[pass_name_eg];?>" placeholder="FIRSTNAME">
        </div>
         <div class="col-md-5">
          <input class="form-control" type="text" id="pass_lastname_eg<?=$x?>" name="pass_lastname_eg<?=$x?>" value="<?=$cp[pass_lastname_eg];?>" placeholder="LASTNAME">
        </div>
</div>

<div class="row" style="margin-top:10px;">
        <div class="col-md-2">
        <select class="form-control" id="pass_title_th<?=$x?>" name="pass_title_th<?=$x?>">
  <option value="นาย" <? 
                      if($cp['pass_title_th'] == 'นาย'){
                        echo "selected";
                      } 
                      ?>>นาย</option>
                      <option value="นาง" <? 
                      if($cp['pass_title_th'] == 'นาง'){
                        echo "selected";
                      } 
                      ?>>นาง</option>
                      <option value="น.ส." <? 
                      if($cp['pass_title_th'] == 'น.ส.'){
                        echo "selected";
                      } 
                      ?>>น.ส.</option>
                      <option value="ด.ช." <? 
                      if($cp['pass_title_th'] == 'ด.ช.'){
                        echo "selected";
                      } 
                      ?>>ด.ช.</option>
                      <option value="ด.ญ." <? 
                      if($cp['pass_title_th'] == 'ด.ญ.'){
                        echo "selected";
                      } 
                      ?>>ด.ญ.</option>
                      <option value="พระ" <? 
                      if($cp['pass_title_th'] == 'พระ'){
                        echo "selected";
                      } 
                      ?>>พระ</option>
                      <option value="พระครู" <? 
                      if($cp['pass_title_th'] == 'พระครู'){
                        echo "selected";
                      } 
                      ?>>พระครู</option>
                      <option value="พระมหา" <? 
                      if($cp['pass_title_th'] == 'พระมหา'){
                        echo "selected";
                      } 
                      ?>>พระมหา</option>
                      <option value="พระอธิการ" <? 
                      if($cp['pass_title_th'] == 'พระอธิการ'){
                        echo "selected";
                      } 
                      ?>>พระอธิการ</option>
                    </select>
          </div>
         <div class="col-md-5">
          <input class="form-control" type="text" id="pass_name_th<?=$x?>" name="pass_name_th<?=$x?>" value="<?=$cp[pass_name_th];?>" placeholder="ชื่อจริง">
        </div>
         <div class="col-md-5">
          <input class="form-control" type="text" id="pass_lastname_th<?=$x?>" name="pass_lastname_th<?=$x?>" value="<?=$cp[pass_lastname_th];?>" placeholder="นามสกุล">
        </div>
        <div class="col-md-12 text-right" style="margin-top:5px;">
           <a  class='btn btn-edit-color i-pass' id='BUTTON<?=$cp[pass_id];?>' folder='<?=$folder;?>' data-id='<?=$cp[pass_id];?>'
                          data-img='https://www.imaginetourservice-system.com/pass/<?=$cp[pass_pic];?>' data-toggle='modal' data-target='#Modal2'>
                        <i class='halflings-icon file white'></i>PRINT
                      </a>
                   <a  class='btn btn-danger delete-confirm'
                        data-toggle='modal' data-target='#modalBootstrap3' id='<?=$cp[pass_id];?>' data-item-del='' >
                        <i class='fa fa-trash-o fa-x'></i>
                   </a>
        </div>
        <div class="col-md-4 d-none"></div>
<!--         <div class="col-md-4" style="margin-top:10px;">
                       <a  class='btn btn-edit-color btn-block i-pass' id="BUTTON<?=$cp[pass_id]?>" folder="<?=$folder;?>" data-id="<?=$cp[pass_id]?>"
                          data-img="https://www.imaginetourservice-system.com/pass/<? echo $cp['pass_pic'];?>" data-toggle='modal' data-target='#Modal'>
                        <i class='halflings-icon file white'></i>PRINT
                      </a>
        </div> -->
</div>

      </td>
    </tr>
   <?} ?>
  </table>
           
                <input class="text" type="hidden" id="allx" type="text" name="allx" style="text-transform:uppercase" value="<?=$x?>">
                <input class="text" type="hidden" id="code" type="text" name="code" style="text-transform:uppercase" value="<?=$code?>">
                
               <div class="col-md-12 text-center p-5 mb-5" style="margin-top:20px;margin-bottom: 20px;">
                <div class="form-actions">
                  <button type="submit" id="PackageBT" class="btn btn-danger"><i class="fa fa-save"></i> บันทึก</button>
                  <button type="reset" onclick="window.history.back();return false;" class="btn btn-cancel-color">ยกเลิก</button>
                </div>
                </div>
            </form>
<?}?>
      
        </div><!--/span-->
      
      </div>

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



 	 	<div class="col-md-6">
<section class="panel">
                  <header class="panel-heading">
                    <div class="panel-actions">
                      <a href="#" class="fa fa-caret-down"></a>
                    </div>
                    <h2 class="panel-title">คลังเอกสาร</h2>
                  </header>
                  <div class="panel-body" style="overflow-x:auto;">
        <table class="table table-bordered table-striped mb-none" id="datatable-tabletoolss">
                  <thead>
                    <tr>
                      <th>NO</th>
                      <th>รายละเอียดเอกสาร</th>
                      <th>FILE</th>
                      <th>วันที่อัพโหลด</th>
                      <th>Actions</th>
                    </tr>
                  </thead>
                  <tbody>
                <?
                $doc_num = 0;
                $doc = $db->findorderid('tbdoc,tbiv','tbdoc.doc_iv = tbiv.iv_id && doc_iv',$id,'doc_id asc ,doc_id')->execute();
                while ($docc = mysql_fetch_array($doc)){
                	echo "<tr>"; $doc_num++;
                	echo "<td>".$doc_num."</td>";
                	echo "<td>".$docc[doc_text]."</td>";
                  echo "<td>";
                  if(!empty($docc['doc_ref'])){
                    echo "<a href='".$docc[doc_ref]."' target='_blank' class='btn btn-dark' style='margin-right:6px;font-size:0.7rem;'><i class='fa fa-link' aria-hidden='true'></i> ".$docc[doc_text]."</a>";
                  }
                  if(!empty($docc['doc_file'])){
                    echo "<a href='https://www.imaginetourservice-system.com/b_end/pdf/".$docc[doc_file]."' target='_blank' class='btn btn-danger' style='margin-right:6px;font-size:0.7rem;''>".$docc[doc_file]."</a>";
                  }
                  echo "</td>";

                	// echo "<td><a href='https://www.imaginetourservice-system.com/b_end/pdf/".$docc[doc_file]."' target='_blank'>".$docc[doc_file]."</a></td>";
                	echo "<td>".DateThai($docc[doc_date])."</td>";
                        echo " <td class='center'>
                        <a  class='btn btn-danger delete-confirm'
                        data-toggle='modal' data-target='#modalBootstrap4' id='$docc[doc_id];' data-item-del='' >
                        <i class='fa fa-trash-o fa-x'></i>
                          </a>
                            ";
                          echo "</td>";
                	echo "</tr>";
                }
                ?>


                 </tbody>
                 </table>
                  </div>

 </div>
                
<div style="height:450px;"></div>


</div>


      <div class="modal fade" id="modalBootstrap2" 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">คุณต้องการที่จะลบ Pay-IN<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=period_delete" class="mb-xs mt-xs mr-xs btn btn-danger payin2_del" data-dismiss="modal">Delete</a>
    </div>
              </div>
              </div>
              </div>


      <div class="modal fade" id="modalBootstrap3" 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">คุณต้องการที่จะลบ Passport<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=period_delete" class="mb-xs mt-xs mr-xs btn btn-danger pass2_del" data-dismiss="modal">Delete</a>
    </div>
              </div>
              </div>
              </div>


      <div class="modal fade" id="modalBootstrap4" 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">คุณต้องการที่จะลบ เอกสารนี้<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=period_delete" class="mb-xs mt-xs mr-xs btn btn-danger doc2_del" data-dismiss="modal">Delete</a>
    </div>
              </div>
              </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;    width: 100%;"></center>
    </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>


<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" 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">
        <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>


  <div class="modal fade" id="Modal2" 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="clicked2()" 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-show2" style="max-height:auto;width:100%;"></center>
    </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

<?include 'modal_data.php';?>

