 <? $code ="".$_GET["id"]."" ?>
 <?php
      include('include/connect.php'); 
      $strSql="SELECT * FROM tb_programe,tbairline,tbtrip where tb_programe.programe_id = tbtrip.trip_programe_code
       && tb_programe.programe_airline = tbairline.airline_id && programe_id = '".$_GET["id"]."' ";
      $rs = mysql_query($strSql,$conn) or die("Error : ".mysql_error());
       ?> 

<?php 
    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];

      if($strDay==$strDay2){
        return "$strDay $strMonthThai $strYear";
      }

      return "$strDay2-$strDay $strMonthThai $strYear";
    }
    ?>


    <!-- start: page -->
            <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>
        <div class="box-header" data-original-title>
         <h4><i class="halflings-icon user"></i><span class="break"></span>Period For <?=$code?></h4>
         <!-- Modal Bootstrap -->
         
         <a class="mb-xs mt-xs mr-xs btn btn btn-success" data-toggle="modal" data-target="#modalBootstrap"><i class="fa fa-plus-square-o fa-x"></i> เพิ่ม period</a>
         <a class="mb-xs mt-xs mr-xs btn btn btn-danger" href="?url=period_del_all&id=<?=$code;?>"><i class='fa fa-trash-o fa-x'></i> ลบหลายperiod</a>
        <!--  <a class="mb-xs mt-xs mr-xs btn btn-success" href="#"><i class="fa fa-plus-square-o"></i> แก้ไข period</a> -->
          </div>
              </header>
              <div class="panel-body">
                <table class="table table-bordered table-striped mb-none" id="datatable-default">
                  <thead>
                    <tr>
                  <th class="text-center" style="width:5%;">#</th>
                                  <th style="width:30%;">ชื่อโปรแกรม</th>
                                  <th style="width:30%;">เดินทาง</th>
                                  <th style="width:15%">Actions</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php
                            $i=0;                
                
                            while($dbarr= mysql_fetch_array($rs)){

                            echo "<tr class='gradeX'>";  $i++ ;
                            echo "<td class='center'>$i</td>";
                            echo "<td class='center'>$dbarr[programe_name]</td>";
                            echo "<td class='center'>".DateGoBack($dbarr[trip_date_go],$dbarr[trip_date_back]) ."</td>";
                            echo "<td class='center'>";
                            echo "<a class='btn btn-info' href='?url=period_edit&id=$dbarr[trip_id]'>
                                    <i class='fa fa-edit fa-x'></i> 
                                  </a>";
                            echo "<a class='btn btn-danger delete-confirm' data-toggle='modal' data-target='#modalBootstrap2' id='$dbarr[trip_id]' data-item-del='$dbarr[programe_code]_$dbarr[airline_code]&nbsp;วันเดินทางไป&nbsp;$dbarr[trip_date_go]&nbsp;วันเดินทางกลับ&nbsp;$dbarr[trip_date_back]'>
                                    <i class='fa fa-trash-o fa-x'></i> 
                                  </a>";
                            echo "</td>";
                            echo "</tr>";
                        }
                          ?>
                  </tbody>
                </table>
              </div>
            </section>


      <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">คุณต้องการที่จะลบ PERIOD <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 period_del" data-dismiss="modal">Delete</a>
    </div>
              </div>
              </div>
              </div>


    <?php
      include('include/connect.php'); 
      $strSql2="SELECT * FROM tb_programe,tbairline,tbtrip where tb_programe.programe_id = tbtrip.trip_programe_code
       && tb_programe.programe_airline = tbairline.airline_id && programe_id = '".$_GET["pid"]."' ";
      $rss = mysql_query($strSql2,$conn) or die("Error : ".mysql_error());
      $r = mysql_fetch_array($rss);
       ?> 


                  <div class="modal fade" id="modalBootstrap" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <form class="form-horizontal"  method="post" action="?url=period_addall">
                    <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>
                          <h4 class="modal-title" id="myModalLabel" style="color: #ff2a00;">เลือกจำนวน period ที่ต้องการ</h4>
                        </div>
    <div class="modal-body" style="height: 350px;color: #ff2a00;">
      <center>
      <input type="text" class="form-control" id="code" name="code" value="<?php echo $code;?>" readonly><br>
      <select id="num_day" data-plugin-selectTwo data-rel="chosen" name="num_day" style="width:200px;">
        <option value="0">-- เลือก จำนวนวัน --</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
        <option value="9">9</option>
        <option value="10">10</option>
        <option value="11">11</option>
        <option value="12">12</option>
        <option value="13">13</option>
        <option value="14">14</option>
        <option value="15">15</option>
        <option value="16">16</option>
        <option value="17">17</option>
        <option value="18">18</option>
        <option value="19">19</option>
      </select> <br><br>

      <select data-plugin-selectTwo id="num_p" data-rel="chosen" name="num_p" style="width:200px;">
        <option value="0">-- เลือก จำนวนแถว--</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
        <option value="9">9</option>
        <option value="10">10</option>
        <option value="11">11</option>
        <option value="12">12</option>
        <option value="13">13</option>
        <option value="14">14</option>
        <option value="15">15</option>
        <option value="16">16</option>
        <option value="17">17</option>
        <option value="18">18</option>
        <option value="19">19</option>
        <option value="20">20</option>
        <option value="21">21</option>
        <option value="22">22</option>
        <option value="23">23</option>
        <option value="24">24</option>
        <option value="25">25</option>
        <option value="26">26</option>
        <option value="27">27</option>
        <option value="28">28</option>
        <option value="29">29</option>
        <option value="30">30</option>
        <option value="31">31</option>
        <option value="32">32</option>
      </select> <br><br>

       <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">ราคาเริ่มต้น</label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="inputDefault" name="price">
                        </div>
                      </div>
        <div class="form-group">
                        <label class="col-md-3 control-label" for="inputDefault">ผู้เดินทาง</label>
                        <div class="col-md-6">
                          <input type="text" class="form-control" id="inputDefault" name="size">
                        </div>
                      </div>
    </div>
      <div class="modal-footer">
                  <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>
                    </div>
                  </form>
                  </div>
                </div>

