<?php
    $rs = $db->findAll('tbbooking')->execute();
        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("","มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
      $strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
      $strMonthThai=$strMonthCut[$strMonth];
      return "$strDay2 - $strDay $strMonthThai $strYear";
    }


$start = $_POST['m1'];
$td_date_chk = strtotime($start);
$td_date_st = date('Y-m-d', $td_date_chk);

$last = $_POST['m2'];
$lt_date_chk = strtotime($last);
$lt_date_st = date('Y-m-d', $lt_date_chk);



   // $todays = date("m/d/Y");
   $todays = date("Y-m-d");

  $todays2 = date("Y-m-d");

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

   $book_today = $db->findByAttributes('tbbooking',array('book_date =' => $todays1))->execute();


   if ($_SESSION['admin_status'] == 0 || $_SESSION['admin_status'] == 2 || $_SESSION['admin_id'] == 51) {
    $book_t = $db->findByAttributes('tbiv',array('iv_date =' => $todays))->execute();
    $rs = $db->findAll('tbiv')->execute();
    $rstime = $db->findAll('tbiv')->execute();
    $book_dep = $db->findByAttributes('tbiv',array('mus_date =' => $todays))->execute();  
   }else{
    // $book_t = $db->findByAttributes('tbiv',array('iv_date =' => $todays))->execute();
    if($_SESSION['admin_id'] == 49){
    $admintest = 'เฟิร์น';
    $book_t = $db->findByAttributes('tbiv',array('iv_date =' => $todays, 'iv_admin =' => 'เฟิร์น'))->execute();
    $book_t2 = $db->findByAttributes('tbiv',array('iv_date =' => $todays, 'iv_admin =' => $admin_id))->execute();
    $book_ad = $db->findByAttributes('tbiv',array('admin_nickname =' => $admin_id))->execute();
    $rs = $db->findByAttributes('tbiv',array('iv_admin =' => 'เฟิร์น'))->execute();
    $rs2 = $db->findByAttributes('tbiv',array('iv_admin =' => $admin_id))->execute();
    $rstime = $db->findByAttributes('tbiv',array('iv_admin =' => 'เฟิร์น'))->execute();
    $book_dep = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' => 'เฟิร์น'))->execute();
    $book_dateline = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' => 'เฟิร์น'))->execute();
    

    }else if($_SESSION['admin_id'] == 51){
    // $book_t = $db->findByAttributes('tbiv',array('iv_date =' => $todays, 'iv_admin =' => 'หนุงหนิง'))->execute();
    // $book_t2 = $db->findByAttributes('tbiv',array('iv_date =' => $todays, 'iv_admin =' => $admin_id))->execute();
    // $book_ad = $db->findByAttributes('tbiv',array('admin_nickname =' => $admin_id))->execute();
    // $rs = $db->findByAttributes('tbiv',array('iv_admin =' => 'หนุงหนิง'))->execute();
    // $rs2 = $db->findByAttributes('tbiv',array('iv_admin =' => $admin_id))->execute();
    // $rstime = $db->findByAttributes('tbiv',array('iv_admin =' => 'หนุงหนิง'))->execute();
    // $book_dep = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' =>'หนุงหนิง'))->execute();
    // $book_dateline = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' => 'หนุงหนิง'))->execute();
    $book_ad = $db->findAll('tbiv')->execute();
    $rs = $db->findByAttributes('tbiv',array('admin_id =' => $admin_id))->execute();

    }else if($_SESSION['admin_id'] == 52){
    $book_t = $db->findByAttributes('tbiv',array('iv_date =' => $today, 'iv_admin =' => 'Patra'))->execute();
    $book_t2 = $db->findByAttributes('tbiv',array('iv_date =' => $today, 'iv_admin =' => $admin_id))->execute();
    $book_ad = $db->findByAttributes('tbiv',array('admin_nickname =' => $admin_id))->execute();
    $rs = $db->findByAttributes('tbiv',array('iv_admin =' => 'Patra'))->execute();
    $rs2 = $db->findByAttributes('tbiv',array('iv_admin =' => $admin_id))->execute();
    $rstime = $db->findByAttributes('tbiv',array('iv_admin =' => 'Patra'))->execute();
        $book_dep = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' =>'Patra'))->execute();
        $book_dateline = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' => 'Patra'))->execute();

    }else if($_SESSION['admin_id'] == 53){
    $book_t = $db->findByAttributes('tbiv',array('iv_date =' => $today, 'iv_admin =' => 'เล็ก'))->execute();
    $book_t2 = $db->findByAttributes('tbiv',array('iv_date =' => $today, 'iv_admin =' => $admin_id))->execute();
    $book_ad = $db->findByAttributes('tbiv',array('admin_nickname =' => $admin_id))->execute();
    $rs = $db->findByAttributes('tbiv',array('iv_admin =' => 'เล็ก'))->execute();
    $rs2 = $db->findByAttributes('tbiv',array('iv_admin =' => $admin_id))->execute();
    $rstime = $db->findByAttributes('tbiv',array('iv_admin =' => 'เล็ก'))->execute();
    $book_dep = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' =>'เล็ก'))->execute();
    $book_dateline = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' => 'เล็ก'))->execute();


    }else if($_SESSION['admin_id'] == 56){
    $book_t = $db->findByAttributes('tbiv',array('iv_date =' => $today, 'iv_admin =' => 'Nok'))->execute();
    $book_t2 = $db->findByAttributes('tbiv',array('iv_date =' => $today, 'iv_admin =' => $admin_id))->execute();
    $book_ad = $db->findByAttributes('tbiv',array('admin_nickname =' => $admin_id))->execute();
    $rs = $db->findByAttributes('tbiv',array('iv_admin =' => 'Nok'))->execute();
    $rs2 = $db->findByAttributes('tbiv',array('iv_admin =' => $admin_id))->execute();
    $rstime = $db->findByAttributes('tbiv',array('iv_admin =' => 'Nok'))->execute();
    $book_dep = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' =>'Nok'))->execute();
    $book_dateline = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' => 'Nok'))->execute();
    }else if($_SESSION['admin_id'] == 55){
    $book_t = $db->findByAttributes('tbiv',array('iv_date =' => $today, 'iv_admin =' => 'Noon'))->execute();
    $book_t2 = $db->findByAttributes('tbiv',array('iv_date =' => $today, 'iv_admin =' => $admin_id))->execute();
    $book_ad = $db->findByAttributes('tbiv',array('admin_nickname =' => $admin_id))->execute();
    $rs = $db->findByAttributes('tbiv',array('iv_admin =' => 'Noon'))->execute();
    $rs2 = $db->findByAttributes('tbiv',array('iv_admin =' => $admin_id))->execute();
    $rstime = $db->findByAttributes('tbiv',array('iv_admin =' => 'Noon'))->execute();
    $book_dep = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' =>'Noon'))->execute();
    $book_dateline = $db->findByAttributes('tbiv',array('mus_date =' => $todays, 'iv_admin =' => 'Noon'))->execute();


    }else{
    // $book_ad = $db->findByAttributes('tbiv',array('admin_id =' => $admin_id))->execute();
    $book_ad = $db->findAll('tbiv')->execute();
    $rs = $db->findByAttributes('tbiv',array('admin_id =' => $admin_id))->execute();
   }

   }


 if(!empty($_POST['m1']) || !empty($_POST['m2'])){
   $date_cc = DateGoBack($_POST['m1'],$_POST['m2']);
 }else{
   $date_cc = 'ALL';
 }
?>

  <section class="panel panel-danger" style="font-family: 'Kanit', sans-serif;">
  <div class="panel-body">
  <form  class="form-horizontal form-bordered" action=""  style="margin:0;" method="post" action="">
            <div class="form-group row">

                        <label class="col-md-2 control-label" for="inputDefault"><h5 style="margin:0;font-size: 18px;line-height: 3;">ค้นหาวันออกเดินทาง</h5></label>
                        <div class="col-md-3">
                          <label>วันเริ่มต้น</label>
                         <input class="form-control" type="date" id="m1" name="m1" value="<?=$_POST[m1]?>" style="margin-bottom:5px;">
                        </div>
                        <div class="col-md-3">
                          <label>วันสินสุด</label>
                         <input class="form-control" type="date" id="m2" name="m2" value="<?=$_POST[m2]?>" style="margin-bottom:5px;">
                        </div>
                      <div class="col-md-3">
                <div class="form-actions">
                  <button type="submit" id="PackageBT" class="btn btn-danger btn-block" style="line-height: 3;margin-top: 20px;margin-bottom: 20px;">ค้นหาใบจองง!!</button>
                </div>
                </div>
            </div>
   </form>
<?if(!empty($_POST['m1']) || !empty($_POST['m1']) ){?>
  <div class="row">
    <div class="col-md-6">
  <a class="btn btn-dark btn-block" target="_blank" style="font-size:1.8rem;"
   href="https://imaginetourservice.com/com_report_sale.php?id=<?=$_SESSION[admin_id];?>&m1=<?=$_POST[m1];?>&m2=<?=$_POST[m2];?>">REPORT : <?=$date_cc;?> </a>
 </div>
    <div class="col-md-6">
   
   <a class="btn btn-success btn-block" target="_blank" style="font-size:1.8rem;"
   href="https://imaginetourservice.com/back_end/com_report_sale_export.php?id=<?=$_SESSION[admin_id];?>&m1=<?=$_POST[m1];?>&m2=<?=$_POST[m2];?>">REPORT : <?=$date_cc;?> (excel)</a>     
    </div>
  </div>

<?}?>
          </div>
        </section>


  <section class="panel" style="color:red;">

<!-- <h5 class="text-semibold text-dark text-uppercase mb-md mt-lg">BOOKING</h5> -->
<div class="row">
<!-- <?=$allbook;?> -->
<div class="col-md-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">Maindatabase 
<span style="font-size:1.5rem;font-weight:400;" class="label label-dark"> <?=$date_cc;?></span>
<a href="?url=iv_form" data-link="?url=iv_form" class="btn btn-success with-shadow-success " style="position: absolute;right: 16px;top:15px;">ออก INVOICE ใหม่</a></h2>
</header>

          <header class="panel-heading" style="color:#fff;background: #4b4b4b;">
             <div class="row">
              <!-- <div class="col-md-1"> <label>ผู้ขาย :</label></div> -->
            <div class="col-md-3">
                <label>สถานะ :</label>
                <select class="form-control status-dropdown">
                <option value="">All</option>
                <option value="สถานะปกติ">สถานะปกติ</option>
                <option value="ชำระครบแล้ว">ชำระครบแล้ว</option>
                <option value="ยกเลิกแล้ว">ยกเลิกแล้ว</option>
              </select>
            </div>

            <div class="col-md-2">
                <label>SALE :</label>
               <!--  <select class="form-control status-iv"> -->
                <select data-plugin-selectTwo id='admin_nickname' name="admin_nickname" data-rel="chosen" class="form-control populate placeholder status-iv">
               <!--  <option value="">All</option> -->
                      <?
                      $sql = "select * from tbadmin;";
                                    $result = mysql_query($sql);
                                    echo '<option value="">-- SALE --</option>';
                                    while ($data = mysql_fetch_array($result) ) {
                                    echo "<option value=$data[admin_nickname] ";
                        if($_SESSION['admin_id'] == $data[admin_id]){
                          echo "selected";
                        }
                      echo ">$data[admin_nickname]</option>";
                                  }
                    ?>

              </select>
            </div>

            </div>
              </header>

<div class="panel-body text-dark">
                    <table class="table table-bordered table-striped mb-none datatable maindata" id="datatable-database">
                      <thead>
                          <tr>
                            <th>#</th>
                            <th style="width:260px;">เลขที่ใบจอง</th>
                            <th>SALE</th>
                            <th  style="width:100px;margin:auto;">ประเทศ</th>
                              <th style="width:150px;margin:auto;">Wholesale</th>
                            <th style="text-align:center;width:230px;">วันที่เดินทาง</th>
                            <th>จำนวน</th>
                            <th style="text-align:center;">ส่วนลด<br>ราคาเพิ่มเติม</th>
                            <th style="background: #30a7ff;text-align:center;color: #fff;" class="bg-primary">จ่ายแล้วทั้งหมด</th>
                            <th style="background: rgb(26 178 0);text-align:center;color: #fff;" class="bg-primary">ราคารวม</th>
                            <th style="background: rgb(26 178 0);text-align:center;color: #fff;" class="bg-danger">ส่วนที่เหลือ</th>
                            <th style="background: #30a7ff;text-align:center;color: #fff;" class="bg-primary">Total<br>Commission</th>
                            <!-- <th>สถานะ</th> -->
                            <th style="width:150px;">NOTE</th>
                            <th style="text-align:center;width:140px;">#</th>
                          </tr>
                      </thead>
                          <tbody>
                       <?php
                       $i=0;
                       $i1=0;
                        while($dbarr= mysql_fetch_array($rstime)){ 
            $g_date = $dbarr['pro_datego'];
            $g_explode = explode("-", $g_date);
            $g_year = $g_explode[0];
            $g_month = $g_explode[1];
            $g_day = $g_explode[2];

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


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

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


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


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

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


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

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

$total=$sum_ad + $sum_c + $sum_nb + $sum_s + $custom + $custom2 + $custom3 + $custom4 - $sum_dis - $sum_dis2 - $sum_dis3 - $sum_dis4;

// $total_pay = $dbarr['iv_pay_total'] - $total;

$gp222 = $db->findByPK('tbpayment','payment_iv',$dbarr['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;
$dis_c = $sum_dis - $sum_dis2 - $sum_dis3 - $sum_dis4;
$plus_c = $custom + $custom2 + $custom3 + $custom4;

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

if ($dbarr['iv_status_2'] == '0') {
  if ($total_pay == '0') {
  $iv_status = "<span class='label label-success' style='font-weight:400;'>ชำระครบแล้ว</span>";
  $iv_can = '';
  }else{
  $iv_status = "<a class='#' href='#' status ='1' id='$dbarr[iv_id]'>
  <span class='label label-primary' style='font-weight:400;'>สถานะปกติ</span></a>";
  $iv_can = '';
  }
}else{
  // $iv_status = "<a class='changestatus_iv' href='#' status ='0' id='$dbarr[iv_id]'><span class='label label-dark' style='font-weight:400;'>ยกเลิกแล้ว</span></a>";
 $iv_status = "<a class='#' href='#' status ='0' id='$dbarr[iv_id]'><span class='label label-dark' style='font-weight:400;'>ยกเลิกแล้ว</span></a>";
  $iv_can = 'background: #00000045;';
}

                         // if ($dbarr['iv_status_2'] == '0') {
                         //    echo "<td style='line-height:21pt;text-align:center;'  class='text-danger'>
                         //     <a class='btn btn-success changestatus_iv' href='#' status ='1' id='$dbarr[iv_id]'>ปกติ</a>
                         //     </td>";
                         //    }else{
                         //    echo "<td style='line-height:21pt;text-align:center;'  class='text-danger'>
                         //     <a class='btn btn-dark changestatus_iv' href='#' status ='0' id='$dbarr[iv_id]'>ยกเลิก</a>
                         //     </td>";
                         //    }
// if($g_date <= $td_date_st){}
             ?>
             <?
              $payin = $db->findByPK('tbpayment','payment_iv',$dbarr['iv_id'])->executeRow();?>




                      <?if(!empty($_POST['m1']) || !empty($_POST['m2'])){?>  

                      <? if($g_date >= $td_date_st && $g_date <= $lt_date_st){$i++?>

                          <tr style="<?=$iv_can;?>">
                             <td style="text-align:center;"> <?=$i;?></td>
                            <td style="line-height:1.4;"><a href="https://www.imaginetourservice.com/ivnew.php?id=<?=$dbarr[iv_id];?>" target="_blank">
                              IM<?=$dbarr['iv_id'];?></a> <br> <span style="font-size:0.9rem;">( คุณ <?=$dbarr[cus_name];?> : <?=$dbarr[cus_tel];?> )</span><br>
                              <span style="font-size:1rem;font-weight:400;" class="label label-dark">BOOKTIME : <?=DateThai($dbarr[iv_date]);?></span> 
                              <?=$iv_status;?>
                            </td>
                            <td style="text-align:center;"><?=$dbarr['iv_admin'];?></td>
                            <td style="text-align:center;margin:auto;"><?=$dbarr['iv_country'];?></td>
                            <td style="text-align:center;line-height:1.2;font-size:1.2rem;margin:auto;"><?=$dbarr['iv_wholesale'];?></td>
                            <td style="text-align:center;line-height:1.4;"><?=DateGoBack($dbarr['pro_datego'],$dbarr['pro_dateback']);?>
                            <p style="margin-bottom:0;font-size:1rem;"><?=$dbarr['iv_codepro'];?> : <?=$dbarr['iv_namepro'];?></p>
                            
                          </td>
                            <td style="text-align:center;"><i class='fa fa-user' aria-hidden='true'></i> <?=$book_all;?></td>
                             <td style="text-align:left;line-height:1.1;">(<?=number_format($dis_c);?>) <br> +<?=number_format($plus_c);?>
                            </td>
                            <td style="text-align:center;    background: #31a7ff24;" class="text-primary"><?=number_format($dbarr['iv_pay_total']);?></td>
                              <td style="text-align:center;    background: rgb(26 178 0 / 24%);color:#000;" class="text-dark"><?=number_format($total);?></td>
                              <td style="text-align:center;    background: rgb(254 9 1 / 14%);color:#000;" class="text-dark"><?=number_format($total_pay);?></td>
                              <td style="text-align:center;    background: #31a7ff24;" class="text-primary"><?=number_format($dbarr['iv_com']);?></td>
                            <td style="text-align:center;line-height:1.2;font-size:0.9rem;"><?=$dbarr['iv_note'];?></td>
                            <td class="">
                                    <a href="?url=maindatabase_update&id=<?=$dbarr[iv_id];?>" target="_blank" class="btn btn-danger"><i class="fa fa-pencil fa-1x" aria-hidden="true"></i></a>
                            </td>
                          </tr>
                        <?}?>
                        <?}else{$i1++?>
                          <tr style="<?=$iv_can;?>">
                             <td style="text-align:center;"><?=$i1;?></td>
                            <td style="line-height:1.4;"><a href="https://www.imaginetourservice.com/ivnew.php?id=<?=$dbarr[iv_id];?>" target="_blank">
                              IM<?=$dbarr['iv_id'];?></a><br> <span style="font-size:0.9rem;">( คุณ <?=$dbarr[cus_name];?> : <?=$dbarr[cus_tel];?> )</span><br>
                              <span style="font-size:1rem;font-weight:400;" class="label label-dark">BOOKTIME : <?=DateThai($dbarr[iv_date]);?></span> 
                              <?=$iv_status;?>
                            </td>
                            <td style="text-align:center;"><?=$dbarr['iv_admin'];?></td>
                            <td style="text-align:center;margin:auto;"><?=$dbarr['iv_country'];?></td>
                            <td style="text-align:center;line-height:1.2;font-size:1.2rem;margin:auto;"><?=$dbarr['iv_wholesale'];?></td>
                            <td style="text-align:center;line-height:1.4;"><?=DateGoBack($dbarr['pro_datego'],$dbarr['pro_dateback']);?>
                            <p style="margin-bottom:0;font-size:1rem;"><?=$dbarr['iv_codepro'];?> : <?=$dbarr['iv_namepro'];?></p>
                            
                          </td>
                            <td style="text-align:center;"><i class='fa fa-user' aria-hidden='true'></i> <?=$book_all;?></td>
                             <td style="text-align:left;line-height:1.1;">(<?=number_format($dis_c);?>) <br> +<?=number_format($plus_c);?>
                            </td>
                            <td style="text-align:center;    background: #31a7ff24;" class="text-primary"><?=number_format($p_c);?></td>
                              <td style="text-align:center;    background: rgb(26 178 0 / 24%);color:#000;" class="text-dark"><?=number_format($total);?></td>
                              <td style="text-align:center;    background: rgb(254 9 1 / 14%);color:#000;" class="text-dark"><?=number_format($total_pay);?></td>
                              <td style="text-align:center;    background: #31a7ff24;" class="text-primary"><?=number_format($dbarr['iv_com']);?></td>
                           <? /* if ($dbarr['iv_status_2'] == '0') {
                            echo "<td style='line-height:21pt;text-align:center;'  class='text-danger'>
                             <a class='btn btn-success changestatus_iv' href='#' status ='1' id='$dbarr[iv_id]'>ปกติ</a>
                             </td>";
                            }else{
                            echo "<td style='line-height:21pt;text-align:center;'  class='text-danger'>
                             <a class='btn btn-dark changestatus_iv' href='#' status ='0' id='$dbarr[iv_id]'>ยกเลิก</a>
                             </td>";
                            } */?>
                            <td style="text-align:center;line-height:1.2;font-size:0.9rem;"><?=$dbarr['iv_note'];?></td>
                            <td class="">
                            <a href="?url=maindatabase_update&id=<?=$dbarr[iv_id];?>" target="_blank" class="btn btn-primary"><i class="fa fa-pencil fa-1x" aria-hidden="true"></i></a>
                            <?if ($dbarr['iv_status_2'] == '0') {?>
                            <a class='changestatus_iv btn btn-danger' href='#' status ='1' id='<?=$dbarr[iv_id];?>'><i class='fa fa-trash-o fa-1x'></i></a>
                            <?}else{?>
                            <a class='changestatus_iv btn btn-danger' href='#' status ='0' id='<?=$dbarr[iv_id];?>'><i class="fa-solid fa-arrows-rotate fa-1x"></i></a>
                            <?}?>
                            </td>
                          </tr>
                        <?}$p_c = 0;?>






                         <?  } ?>

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





   </div>

</section>

<!-- 
<div class="modal rightbook fade" id="booknow" tabindex="-1" role="dialog" aria-labelledby="booknow" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered modal-fullscreen-xxl-down modal-xl" style="height: 100%;">
    <div class="modal-content book_now_modal">
 <div class="container-fluid">
      <div class="row">
      <div class="modal-header bg_dark_menu" style="border-bottom: 0px solid #dee2e6;">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      </div>
      <div class="modal-body row mt-0 mb-0">

        <h5>TEST</h5>

        </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> -->

