
<?
// $num = $_POST['num_p'];

$id = $_GET['iv'];
$r = $db->findByPK('tbiv','iv_id',$id)->executeRow();

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

$num_day = $_POST['num_day'];
$numday  = $num_day - 1;

$ads = $_POST['price'];
$ci_b = $_POST['size'];


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


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


?>  
<style>
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
  border: 1px solid #ddd;
}

th, td {
  text-align: center;
  padding: 8px;
}

tr:nth-child(even){background-color: #f2f2f2}
</style>

            <section class="panel">
              <header class="panel-heading"  style="margin-bottom:20px;">
                <h2 class="panel-title">PASSENGER &nbsp; &nbsp; <?=$r['adult_num'];?> &nbsp; ท่าน &nbsp; &nbsp;  
             <!--   <a href="?url=" data-link="?url="  class="btn btn-success with-shadow-success" style="position: absolute;right: 16px;top: 10px;">เพิ่มหน้าพาสใหม่</a> -->
                    <input type="hidden" class="form-control"name="namepro" id="namepro"  value="<?=$r['iv_namepro']?>">
                      <input type="hidden" class="form-control"name="namepro" id="namepro"  value="<?=$r['iv_namepro']?>">
                      <input class="form-control" name="pro_dategopr" id="pro_dategopr"
                      value="<?echo ''.datethai($r['pro_datego']).' - '.datethai($r['pro_dateback']).'';?>"  type="hidden">
                      <input type="hidden" class="form-control" id="iv_admin" name="iv_admin"  value="<?=$r['iv_admin']?>"/>
                      <input type="hidden" class="form-control" id="iv_new" name="iv_new" value="IM<?=$r['iv_id']?>">
              </header>

  <div class="row">   
        <div class="col-xl-12">

<?if($ca_book == '0'){?>
         <form class="form-horizontal" name="form_pass" id="form_pass" method="post" code="<?=$code;?>">
  <table>
    <tr style="    background: #e0331e;">
      <th align="center">ไม่พบข้อมูล กรุณากด SUBMIT!</th>
    </tr>
            <?
      $x =1;
      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>
<?}else{?>

<form class="form-horizontal" name="form_pass" id="form_pass" method="post" code="<?=$code;?>">
<table class="table table-bordered table-striped mb-none" id="datatable-tabletoolss">
    <tr style="    background: #e0331e;">
      <th align="center" class="text-center" style="width:30px;">NO</th>
      <th align="center" style="width:100px;">Passport</th>
      <th align="center">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.com/'.$path_f.'/'.$cp['pass_pic'];
                          $path2 = 'https://www.imaginetourservice.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-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-4"></div>
        <div class="col-md-4"></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.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>
</section>



<?/*
<form class="form-horizontal" name="form_pass" id="form_pass" method="post" code="<?=$code;?>">
  <table>
    <tr style="    background: #e0331e;">
      <th align="center">Passport</th>
      <th align="center">Passport DETAIL</th>
    </tr>
            <?
      $x =1;
      $book_ccc = $db->findByAttributes('tbpass',array('pass_iv =' => $id ))->execute();
      while($x <= $num) {
      ?>
    <tr>
      <td>
        <label class="control-label text-center header-form" style="float:none;text-align:center;" for="image_field2">
                      <i class="fa fa-file-picture-o" style="margin-bottom:15px;"></i>PASS</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="image_field2" type="file" name="files[]">
                    <input type="hidden" id="imgfiles-logo" name="image_field2<?=$x?>" >
                    <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>

     </td>
       <td> <input class="form-control" type="text" 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"><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 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="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-show" 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>


