<?php $__env->startSection("content"); ?>

<?php
$strYear = date("Y");

function DateThai($strDate)
{
  $strYear = date("Y",strtotime($strDate))+543;
  $strMonth= date("n",strtotime($strDate));
  $strWeek= date("w",strtotime($strDate));
  $strDay= date("j",strtotime($strDate));
  $strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
  $thai_day_arr = Array("อา","จ","อ","พ","พฤ","ศ","ส");
  $strMonthThai=$strMonthCut[$strMonth];
  $strWeekThai=$thai_day_arr[$strWeek];
  return "$strWeekThai $strDay $strMonthThai $strYear";
}

function Numphon($strNum)
{
  
  $n3 = substr($strNum,6,4);
  $n2 = substr($strNum,3,3);
  $n1 = substr($strNum,0,3);
  $nump = $n1."-".$n2."-".$n3;
  return "$nump";
}


?>
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="#">Stock</a></li>
    <li class="breadcrumb-item active" aria-current="page">ออเดอร์รอแพ็ค</li>
  </ol>
</nav>
<nav aria-label="breadcrumb">
<div class="col-12 mb-12" style="text-align: right; font-size: 14px;">
           <!-- Example split danger button -->
          <div class="btn-group">
            <button type="button" class="btn btn-info btn-sm">ปริ้นรายงานหลายรายการ</button>
            <button type="button" class="btn btn-info dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              <span class="sr-only">Toggle Dropdown</span>
            </button>
            <div class="dropdown-menu">
              <a class="dropdown-item" href="#"  data-toggle="modal" data-target="#reportSalesModalCenter">ปริ้นรายการรอส่งแบบกำหนดวัน</a>
              <a class="dropdown-item" href="printbillallwaitpac" target="_blank">ปริ้นบิลรอแพ๊คเกจรวม</a> 
              <a class="dropdown-item" href="printadallwaitpac" target="_blank">ปริ้นที่อยู่จัดส่งรวม</a>  
                
            </div>
          </div>
         </div>
</nav>

<nav>
  <div class="nav nav-tabs" id="nav-tab" role="tablist" style="font-size: 14px;">
    <a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">รายการรอแพ๊ค <?php if($counnopac[0]->cnopac == 0): ?><?php else: ?><span class="badge badge-danger"><?php echo e(number_format($counnopac[0]->cnopac)); ?></span><?php endif; ?></a>
    <a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">รายการรอเลขพัสดุ <?php if($counnotan[0]->cnotan == 0): ?><?php else: ?><span class="badge badge-danger"><?php echo e(number_format($counnotan[0]->cnotan)); ?></span><?php endif; ?></a>
    <a class="nav-item nav-link" id="nav-finish-tab" data-toggle="tab" href="#nav-finish" role="tab" aria-controls="nav-finish" aria-selected="false">รายการส่งของแล้ว <span class="badge badge-success"><?php echo e(number_format($counnofin[0]->cnofin)); ?></span></a>
  </div>
</nav>
<div class="tab-content" id="nav-tabContent">
  <div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">
    <!-- DataTales Example -->
    <div class="card mb-4">
      <div class="card-header py-3">
        <div class="row">
          <div class="col-6 mb-6">
           <h6 class="m-0 font-weight-bold text-primary" ><a style="color:#880E4F;">ตารางข้อมูลรับออเดอร์เพื่อแพ็คสินค้า</a></h6>
         </div>
     
         <div class="col-3 mb-3" style="text-align: right;">
           <h6 class="m-0 font-weight-bold text-primary"></h6>
         </div>
         <div class="col-3 mb-3" style="text-align: right;">
           <h6 class="m-0 font-weight-bold text-primary"></h6>
         </div>
       </div>
     </div>
     <div class="card-body" style="font-size: 14px;">
      <div class="table-responsive" >
        <table class="table table-sm" id="PdTable" width="100%" cellspacing="0">
          <thead>
            <tr>
              <th style="text-align: left;" width="2%">#</th>
              <th scope="col" style="text-align: left;" width="8%">ตัวเลือก</th>
              <th scope="col" style="text-align: left;" width="8%">เลขที่รายการ</th>
              <th scope="col" style="text-align: center;" width="5%">สั่งเมื่อ</th>
              <th scope="col" style="text-align: left;">ลูกค้า</th>
              <th scope="col" style="text-align: center;">เจ้าหน้าที่ขาย</th>
              <th scope="col" style="text-align: center;">ระบบ</th>
              <th scope="col" style="text-align: right;">วันที่รายการ</th>


            </tr>
          </thead>
          <?php
          $i = 1;
          ?>
          <tbody style="font-size: 12px;">
           <?php $__currentLoopData = $mt; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
           <?php
           $tm = \Carbon\Carbon::createFromTimeStamp(strtotime($x->dateCreate));
           ?>
           <tr style="font-size: 14px;">
            <td style="text-align: left;"><?php echo e($i++); ?>.</td>
            <td class="text-nowrap" style="text-align: left; font-size: 12px;">
              <a href="#" class="btn btn-primary btn-circle btn-sm" onClick="show('<?php echo e($x->idSale); ?>','<?php echo e($x->DocCode); ?>','<?php echo e(addslashes($x->CusName)); ?>','<?php echo e($x->LastName); ?>','<?php echo e($x->PROVINCE_NAME); ?>','<?php echo e(number_format($x->TotalNet)); ?>','<?php echo e(addslashes($x->PsNnameF)); ?>','<?php echo e($x->nameSocial); ?>','<?php echo e($x->NamePay); ?>','<?php echo e(DateThai($x->dateCreate)); ?>','<?php echo e(Numphon($x->Mobile1)); ?>','<?php echo e($x->Email); ?>','<?php echo e($x->namePromotion); ?>','<?php echo e($x->AddressText); ?>','<?php echo e(addslashes($x->Note)); ?>','<?php echo e($x->codeInden); ?>')">
                <i class="fas fa-search" style="font-size: 12px;"></i>
              </a>  
              <a  class="btn btn-primary btn-info btn-sm" href="printpdf/<?php echo e($x->idSale); ?>/<?php echo e($x->idCus); ?>" target="_blank">
                <i class="fas fa-print" style="font-size: 12px;"></i>
              </a> 
          <!-- <a  class="btn btn-primary btn-info btn-sm" href="printpdf/<?php echo e($x->idSale); ?>" target="_blank">
            <i class="fas fa-print"></i>
          </a>   --> 

        </td>
        <td class="text-nowrap" style="text-align: left;"><?php echo e($x->DocCode); ?></td>
        <td class="text-nowrap" style="text-align: center;"><?php echo $tm->diffForHumans(); ?></td>
        <td class="text-nowrap"style="text-align: left;"><?php echo e($x->CusName); ?></td>
        <td class="text-nowrap"style="text-align: center;"><?php echo e($x->PsNnameF); ?></td>
        <td class="text-nowrap"style="text-align: center;"><?php echo e($x->nameSocial); ?></td>
        <td class="text-nowrap" style="text-align: right;"><?php echo e(DateThai($x->dateCreate)); ?></td>
      </tr>
      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </tbody>
  </table>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">
  <!-- DataTales Example -->
  <div class="card mb-4">
    <div class="card-header py-3">
      <div class="row">
        <div class="col-6 mb-6">
         <h6 class="m-0 font-weight-bold text-primary"><a style="color:#D84315;">ตารางข้อมูลออเดอร์รอจัดส่ง</a></h6>
       </div>
       <div class="col-3 mb-3" style="text-align: right;">
         <h6 class="m-0 font-weight-bold text-primary"></h6>
       </div>
       <div class="col-3 mb-3" style="text-align: right;">
         <h6 class="m-0 font-weight-bold text-primary"></h6>
       </div>
     </div>
   </div>
   <div class="card-body" style="font-size: 14px;">
    <div class="table-responsive" >
      <table class="table table-sm" id="PdTable" width="100%" cellspacing="0">
        <thead>
          <tr>
            <th style="text-align: center;">#</th>
            <th scope="col" style="text-align: left;" width="12%">ตัวเลือก</th>
            <th scope="col" style="text-align: left;" width="8%">เลขที่รายการ</th>
            <th scope="col" style="text-align: center;"width="10%">รับรายการเมื่อ</th>
            <th scope="col" style="text-align: left;">ลูกค้า</th>
            <th scope="col" style="text-align: center;">เจ้าหน้าที่ขาย</th>
            <th scope="col" style="text-align: center;">ระบบ</th>
            <th scope="col" style="text-align: right;">วันที่รายการ</th>


          </tr>
        </thead>
        <?php
        $i = 1;
        ?>
        <tbody>
         <?php $__currentLoopData = $mtApprov; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
         <?php
         $tm = \Carbon\Carbon::createFromTimeStamp(strtotime($x->dateStstcok));
         ?>
         <tr style="font-size: 14px;">
          <td style="text-align: center;"><?php echo e($i++); ?>.</td>
          <td class="text-nowrap" style="text-align: left;">
            <a href="#" class="btn btn-info btn-circle btn-sm" onClick="showpack('<?php echo e($x->idSale); ?>','<?php echo e($x->DocCode); ?>','<?php echo e(addslashes($x->CusName)); ?>','<?php echo e($x->LastName); ?>','<?php echo e($x->PROVINCE_NAME); ?>','<?php echo e(number_format($x->TotalNet)); ?>','<?php echo e(addslashes($x->PsNnameF)); ?>','<?php echo e($x->nameSocial); ?>','<?php echo e($x->NamePay); ?>','<?php echo e(DateThai($x->dateCreate)); ?>','<?php echo e(Numphon($x->Mobile1)); ?>','<?php echo e($x->Email); ?>','<?php echo e($x->namePromotion); ?>','<?php echo e($x->AddressText); ?>','<?php echo e(addslashes($x->Note)); ?>','<?php echo e($x->codeInden); ?>')">
              <i class="fas fa-search" style="font-size: 12px;"></i>
            </a> 
            <a  class="btn btn-primary btn-info btn-sm" style="font-size: 12px;" href="printpdf/<?php echo e($x->idSale); ?>/<?php echo e($x->idCus); ?>" target="_blank">
              ปริ้นบิล
            </a> 
            <a  class="btn btn-primary btn-warning btn-sm" style="font-size: 12px;" href="printpdfsk/<?php echo e($x->idSale); ?>/<?php echo e($x->idCus); ?>" target="_blank">
              ปริ้นที่อยู่
            </a> 
          <!-- <a  class="btn btn-primary btn-info btn-sm" href="printpdf/<?php echo e($x->idSale); ?>" target="_blank">
            <i class="fas fa-print"></i>
          </a>   --> 

        </td>
        <td class="text-nowrap" style="text-align: left;"><?php echo e($x->DocCode); ?></td>
        <td class="text-nowrap" style="text-align: center;"><?php echo $tm->diffForHumans(); ?></td>
        <td class="text-nowrap"style="text-align: left;"><?php echo e($x->CusName); ?></td>
        <td class="text-nowrap"style="text-align: center;"><?php echo e($x->PsNnameF); ?></td>
        <td class="text-nowrap"style="text-align: center;"><?php echo e($x->nameSocial); ?></td>
        <td class="text-nowrap" style="text-align: right;"><?php echo e(DateThai($x->dateCreate)); ?></td>
      </tr>
      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </tbody>
  </table>
</div>
</div>
</div>
</div>

<div class="tab-pane fade" id="nav-finish" role="tabpanel" aria-labelledby="nav-finish-tab">
  <!-- DataTales Example -->
  <div class="card mb-4">
    <div class="card-header py-3">
      <div class="row">
        <div class="col-6 mb-6">
         <h6 class="m-0 font-weight-bold text-primary"><a style="color:#004D40;">ตารางข้อมูลออเดอร์จัดส่งแล้วประจำวัน</a></h6>
       </div>
       <div class="col-3 mb-3" style="text-align: right;">
         <h6 class="m-0 font-weight-bold text-primary"></h6>
       </div>
       <div class="col-3 mb-3" style="text-align: right;">
         <h6 class="m-0 font-weight-bold text-primary"></h6>
       </div>
     </div>
   </div>
   <div class="card-body" style="font-size: 14px;">
    <div class="table-responsive" >
      <table class="table table-sm" id="PdTable" width="100%" cellspacing="0">
        <thead>
          <tr>
            <th style="text-align: left;">#</th>
            <th scope="col" style="text-align: left;">ตัวเลือก</th>
            <th scope="col" style="text-align: left;">เลขที่รายการ</th>
            <th scope="col" style="text-align: center;">รับรายการเมื่อ</th>
            <th scope="col" style="text-align: left;">ลูกค้า</th>
            <th scope="col" style="text-align: center;">เจ้าหน้าที่ขาย</th>
            <th scope="col" style="text-align: center;">ระบบ</th>
            <th scope="col" style="text-align: right;">วันที่รายการ</th>


          </tr>
        </thead>
        <?php
        $i = 1;
        ?>
        <tbody style="font-size: 14px;">
         <?php $__currentLoopData = $finish; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
         <?php
         $tm = \Carbon\Carbon::createFromTimeStamp(strtotime($x->dateStstcok));
         ?>
         <tr>
          <td style="text-align: center;"><?php echo e($i++); ?>.</td>
          <td class="text-nowrap" style="text-align: left; font-size: 12px;">
            
            <a  class="btn btn-primary btn-info btn-sm" style="font-size: 12px;" href="printpdf/<?php echo e($x->idSale); ?>/<?php echo e($x->idCus); ?>" target="_blank">
              ปริ้นบิล
            </a> 
            <a  class="btn btn-primary btn-warning btn-sm" style="font-size: 12px;" href="printpdfsk/<?php echo e($x->idSale); ?>/<?php echo e($x->idCus); ?>" target="_blank">
              ปริ้นที่อยู่
            </a> 
          <!-- <a  class="btn btn-primary btn-info btn-sm" href="printpdf/<?php echo e($x->idSale); ?>" target="_blank">
            <i class="fas fa-print"></i>
          </a>   --> 

        </td>
        <td class="text-nowrap" style="text-align: left;"><?php echo e($x->DocCode); ?></td>
        <td class="text-nowrap" style="text-align: center;"><?php echo $tm->diffForHumans(); ?></td>
        <td class="text-nowrap"style="text-align: left;"><?php echo e($x->CusName); ?></td>
        <td class="text-nowrap"style="text-align: center;"><?php echo e($x->PsNnameF); ?></td>
        <td class="text-nowrap"style="text-align: center;"><?php echo e($x->nameSocial); ?></td>
        <td class="text-nowrap" style="text-align: right;"><?php echo e(DateThai($x->dateCreate)); ?></td>
      </tr>
      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </tbody>
  </table>
</div>
</div>
</div>
</div>

</div>

<!-- Modal -->
<div class="modal fade" id="ShowPdModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-xl" role="document">
    <div class="modal-content">
      <div class="modal-header" style="background:#330099">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #FFFF;">ข้อมูลบิลขาย</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>

      <form action="<?php echo url('packupdateapprove'); ?>" method="post" id="formApprove">
       <?php echo csrf_field(); ?>
       <div class="modal-body">

         <div class="form-row">
          <div class="form-group col-md-4">
            <label for="vDocCode">เลขที่รายการ :</label>
            <input type="hidden" class="form-control" name="Input_idSale" id="Input_idSale" >
            <input type="text" class="form-control" id="vDocCode" name="vDocCode" placeholder="เลขที่รายการ" disabled>
          </div>
          <div class="form-group col-md-4">
            <label for="vDateCreate">วันที่รายการ :</label>
            <input type="text" class="form-control" name="vDateCreate" id="vDateCreate" placeholder="วันที่รายการ" disabled>
          </div>
          <div class="form-group col-md-4">
            <label for="vPsNnameF">เจ้าหน้าที่ขาย :</label>
            <input type="text" class="form-control" name="vPsNnameF" id="vPsNnameF" placeholder="เจ้าหน้าที่ขาย" disabled>
          </div>
        </div>
        <div class="form-row">
        <!-- <div class="form-group col-md-6">
          <label for="vAddressText">ที่อยู่จัดส่ง :</label>
          <textarea class="form-control" name="vAddressText" id="vAddressText" rows="3" disabled></textarea>
        </div> -->
        <div class="form-group col-md-6">
          <label for="vNote">หมายเหตุ :</label>
          <textarea class="form-control" name="vNote" id="vNote" rows="3" disabled></textarea>
        </div>
      </div>

      
      <div class="form-row">
       <div class="col-lg-12 mb-12">
        <div class="row">
          <div class="col-lg-6 mb-6"> <p class="font-weight-bold" for="inputProvince" style="text-align: left; color: #00897B; ">ตารางสินค้า</p></div>
        </div>
      </div>
      <div class="col-lg-12 mb-12">
        <div class="table-responsive">
          <table class="table table-bordered table-sm">
            <thead>
              <tr>
                <th scope="col" style="text-align: center;">#</th>
                <th scope="col" style="text-align: center;">lot no.</th>
                <th scope="col" style="text-align: center;">รายการสินค้า</th>
                <th scope="col" style="text-align: center;">จำนวน</th>
                <th scope="col" style="text-align: center;">หน่วย</th>

              </tr>
            </thead>
            <tbody id="tdDt">

            </tbody>
          </table>
        </div>
      </div>
    </div>    
    <div class="form-row">
      <div class="form-group col-md-8">
      </div>
     <!--  <div class="form-group col-md-4">
        <label for="vTotalNet">รวมเป็นเงินสุทธิ[บาท]</label>
        <input type="text" class="form-control font-weight-bold " name="vTotalNet" id="vTotalNet" style="font-size: 18px; text-align: right; color: #00796B;" min="0.01" step="0.01" readonly="" value="0">
      </div> -->
    </div>   
  </div>
</form>

<div class="modal-footer">
  <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  <button type="button" id="btApprove" class="btn btn-primary">รับรายการ</button>
</div>
</div>
</div>
</div>

<!-- Modal -->
<div class="modal fade" id="ShowOdPackModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-xl" role="document">
    <div class="modal-content">
      <div class="modal-header" style="background:#330099">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #FFFF;">ข้อมูลรายการสินค้า</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>

      <form action="<?php echo url('updateapprove2Ts'); ?>" method="post" id="formApprovets">
       <?php echo csrf_field(); ?>
       <div class="modal-body">

         <div class="form-row">
          <div class="form-group col-md-4">
            <label for="vDocCode">เลขที่รายการ :</label>
            <input type="hidden" class="form-control" name="PInput_idSale" id="PInput_idSale" >
            <input type="text" class="form-control" id="PvDocCode" name="PvDocCode" placeholder="เลขที่รายการ" readonly="">
          </div>
          <div class="form-group col-md-4">
            <label for="vDateCreate">วันที่รายการ :</label>
            <input type="text" class="form-control" name="PvDateCreate" id="PvDateCreate" placeholder="วันที่รายการ" disabled>
          </div>
          <div class="form-group col-md-4">
            <label for="vPsNnameF">เจ้าหน้าที่ขาย :</label>
            <input type="text" class="form-control" name="PvPsNnameF" id="PvPsNnameF" placeholder="เจ้าหน้าที่ขาย" disabled>
          </div>
        </div>
        <div class="form-row">
        <!-- <div class="form-group col-md-6">
          <label for="vAddressText">ที่อยู่จัดส่ง :</label>
          <textarea class="form-control" name="vAddressText" id="vAddressText" rows="3" disabled></textarea>
        </div> -->
        <div class="form-group col-md-6">
          <label for="vNote">หมายเหตุ :</label>
          <textarea class="form-control" name="PvNote" id="PvNote" rows="3" disabled></textarea>
        </div>
        <div class="col-lg-4 mb-4">
          <label for="vPsNnameF">Tacking :</label>
          <span class="form-required" style="color: #CC0000">*</span>
          <table class="table" style="border: 1px solid #ddd;">
            <tbody>
              <tr>
                <th style="width: 80%; color: #00897B;text-align: right;">
                  <input type="text" class="form-control font-weight-bold " name="inputTack" id="inputTack" style="font-size: 20px; text-align: center; color: #B71C1C;" value="">
                </th>

              </tr>

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

      
      <div class="form-row">
       <div class="col-lg-12 mb-12">
        <div class="row">
          <div class="col-lg-6 mb-6"> <p class="font-weight-bold" for="inputProvince" style="text-align: left; color: #00897B; ">ตารางสินค้า</p></div>
        </div>
      </div>
      <div class="col-lg-12 mb-12">
        <div class="table-responsive">
          <table class="table table-bordered table-sm">
            <thead>
              <tr>
                <th scope="col" style="text-align: center;">#</th>
                <th scope="col" style="text-align: center;">lot no.</th>
                <th scope="col" style="text-align: center;">รายการสินค้า</th>
                <th scope="col" style="text-align: center;">จำนวน</th>
                <th scope="col" style="text-align: center;">หน่วย</th>

              </tr>
            </thead>
            <tbody id="tdDtpack">

            </tbody>
          </table>
        </div>
      </div>
    </div>    
    <div class="form-row">
      <div class="form-group col-md-8">
      </div>
     <!--  <div class="form-group col-md-4">
        <label for="vTotalNet">รวมเป็นเงินสุทธิ[บาท]</label>
        <input type="text" class="form-control font-weight-bold " name="vTotalNet" id="vTotalNet" style="font-size: 18px; text-align: right; color: #00796B;" min="0.01" step="0.01" readonly="" value="0">
      </div> -->
    </div>   
  </div>
</form>

<div class="modal-footer">
  <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  <button type="button" id="btApproveTs" class="btn btn-primary">บันทึก</button>
</div>
</div>
</div>
</div>

<!--  Modal  reportsales -->
<div class="modal fade" id="reportSalesModalCenter" 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="exampleModalCenterTitle">กรุณากำหนดข้อมูลที่ต้องการปริ้น</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form action="<?php echo url('pdfprintallpd2date'); ?>" method="post" id="formreport" target="_blank">
         <?php echo csrf_field(); ?>
         <div class="form-group">
          <div class="form-label">เลือกช่วงข้อมูล</div>
          <div class="custom-controls-stacked">
            <label class="custom-control custom-radio">
              <input type="radio" id="inlineRadio1" value=""   class="custom-control-input" name="phase_type" >
              <input type="hidden" id="txtMMday" name="mm"  value="1" disabled="disabled"/>
              <div class="custom-control-label">ค้นหาตามช่วงวันที่ : 
                <input type="text" id="txtDay1" size="10" name="date1" class="form-control date-picker" data-mask="00/00/0000" data-mask-clearifnotmatch="true" placeholder="จากวันที่" disabled="disabled" />
                <div class="col-lg-12"> <span>
                  <a>ถึง</a>
                </span>
              </div>
              <input type="text" id="txtDay2" size="10" name="date2" class="form-control date-picker" data-mask="00/00/0000" data-mask-clearifnotmatch="true" placeholder="ถึงวันที่" disabled="disabled"/>
            </div>
          </label>
          <label class="custom-control custom-radio">
            <input type="radio" id="inlineRadio2" value=""  class="custom-control-input" name="phase_type" >
            <input type="hidden" id="txtMMmon" name="mm"  value="2" disabled="disabled"/>
            <div class="custom-control-label">ค้นหาตามช่วงเดือนปีนี้ :
              <select name="month"  id="selMount" class="form-control custom-select" disabled="disabled">                   
                <option value="01">มกราคม</option>
                <option value="02">กุมภาพันธ์</option>
                <option value="03">มีนาคม</option>
                <option value="04">เมษายน</option>
                <option value="05">พฤษภาคม</option>
                <option value="06">มิถุนายน</option>
                <option value="07">กรกฎาคม</option>
                <option value="08">สิงหาคม</option>
                <option value="09">กันยายน</option>
                <option value="10">ตุลาคม</option>
                <option value="11">พฤศจิกายน</option>
                <option value="12">ธันวาคม</option>
              </select>
            </div>
          </label>
          <label class="custom-control custom-radio">
            <input type="radio" id="inlineRadio3" value="" rel="txt3"  checked="checked" class="custom-control-input" name="phase_type">
            <div class="custom-control-label">ค้นหาทั้งปี :
              <input type="text" id="txtYear" name="year" class="form-control date-picker" data-mask="00/00/0000" data-mask-clearifnotmatch="true" value="<?php echo e($strYear); ?>"/>
              <input type="hidden" id="txtMMYear" name="mm"  value="3"/>
            </div>
          </label>              
        </div>
      </div>
    </form>
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
    <button type="button" class="btn btn-primary" id="printsales" target="_blank">แสดงหน้าปริ้น</button>
  </div>
</div>
</div>
</div>


<?php $__env->stopSection(); ?>
<?php $__env->startSection("script"); ?>
<script type="text/javascript">

  // $(document).ready( function () {
  //   $('#PdTable').DataTable();
  // });


  $('#btApprove').click(function(){

   swal({
    title: "การบันทึกข้อมูล",
    text: "คุณต้องการยืนยันการรับหรือไม่",
    icon: "warning",
    buttons: true,
    dangerMode: true,
  })
   .then((willDelete) => {
    if (willDelete) {
      swal("ทำรายการสำเร็จ", {
        icon: "success",
      });
      $("#formApprove").submit();
    } else {
      swal("ยกเลิกการบันทึก");
    }
  });

 })

  $('#btApproveTs').click(function(){

    if(($("#inputTack").val() == "")){
      swal({
        title: "ไม่สามารถบันทึกได้ !!!",
        text: "กรุณากรอก Tacking",
        icon: "info",
        button: "ตกลง",
      });

      return false;
    }else{
      swal({
        title: "การบันทึกข้อมูล",
        text: "คุณต้องการยืนยันการส่งสินค้าหรือไม่",
        icon: "warning",
        buttons: true,
        dangerMode: true,
      })
      .then((willDelete) => {
        if (willDelete) {
          swal("ทำรายการสำเร็จ", {
            icon: "success",
          });
          $("#formApprovets").submit();
        } else {
          swal("ยกเลิกการบันทึก");
        }
      });
    }

  })

  function del(id){
    swal({
      title: "คุณต้องการลบสินค้านี้หรือไม่ ?",
      icon: "error",
      buttons: true,
      confirm: true,

    })
    .then((willOk) => {
      if (willOk) {

        $.ajax({
          url:'<?php echo e(url("delpd")); ?>',
          type:'GET',
          data:{id},
          success:function(ret){
            if(ret ==1){
              swal("ลบประเภทสินค้าแล้ว", {icon: "success"});
              window.location.href = "<?php echo e(url('dtpd')); ?>";
            }else{
              swal("ขออภัย", "ไม่สามารถลบสินค้าได้เพราะมีรายการขายอยู่");
            }
          },
          error:function(err){
            console.log(err.responseText);
          }

        });
      } 
    });

  }

  function edit(idSale,DocCode,CusName,LastName,PROVINCE_NAME,TotalNet,PsNnameF,nameSocial,NamePay,dateCreate,Mobile1,Email,namePromotion,AddressText,Note){

    $('#inputId').val(id);
    $('#vEname').val(name);
    $('#vEidtype').val(idtype);
    $('#vEtypename').val(typename);
    $('#vECost').val(Cost);
    $('#vEprice').val(price);
    $('#vEidUnit').val(idUnit);
    $('#vEUnitName').val(UnitName);
    $('#vEWeight').val(Weight);
    $('#vEidWeight').val(idWeight);
    $('#vEnameWeight').val(nameWeight);
    $('#vEnote').val(note);
    $('#vEPdDetail').val(PdDetail);
    $('#vEPdDes').val(PdDescription);

    $('#EditPdModal').modal('show');
  }
  function show(idSale,DocCode,CusName,LastName,PROVINCE_NAME,TotalNet,PsNnameF,nameSocial,NamePay,dateCreate,Mobile1,Email,namePromotion,AddressText,Note,codeInden){

    $('#vCusName').val(CusName +" "+ LastName);
    $('#vCodeInden').val(codeInden);
    $('#vPromotion').val(namePromotion);
    $('#vDocCode').val(DocCode);
    $('#vDateCreate').val(dateCreate);
    $('#vNameSocial').val(nameSocial);
    $('#vNamePay').val(NamePay);
    $('#vMobile1').val(Mobile1);
    $('#vPsNnameF').val(PsNnameF);
    $('#vAddressText').val(AddressText);
    $('#vNote').val(Note);
    $('#vTotalNet').val(TotalNet);
    $('#Input_idSale').val(idSale);
    $.ajax({
      url:'<?php echo e(url("finepddtsale")); ?>/'+idSale,
      type:'GET',
      dataType:'json',
      cache:false,
      
      success:function(ret){
        console.log(ret);
        $("#tdDt").empty();
        var showdt = ret["dt"];
        var rows = 1;
        for(x in showdt){

          var PriceM = numeral(showdt[x].PriceM).format('0,0');
          var Price = numeral(showdt[x].Price).format('0,0');
          var d = numeral(showdt[x].totalNet).format('0,0');
          var Amount = numeral(showdt[x].Amount).format('0,0');
          str = '<tr>'
          +'<td  class="text-nowrap" scope="row" style="text-align: center;">'
          +rows
          +'. '
          +'</td>'
          +'<td class="text-nowrap" style="text-align: center;"><input type="hidden" name="numlotT[]" value="'+showdt[x].LotNo+'">'
          +showdt[x].LotNo
          +'</td>'
          +'<td class="text-nowrap" scope="row" style="text-align: left; color: #00897B;"><input type="hidden" name="idPdPkLotT[]" value="'+showdt[x].idPdPkLot+'"><input type="hidden" name="idPd" value="'+showdt[x].idPdPk+'">'
          +showdt[x].PdName
          +'</td>'

          +'<td class="text-nowrap" style="text-align: center;"><input type="hidden" name="AmountT[]" value="'+showdt[x].Amount+'">'
          +Amount
          +'</td>'
          +'<td class="text-nowrap" style="text-align: center;">'
          +showdt[x].UnitName
          +'</td>'

          $("#tdDt").append(str);
          rows++;
        }

        $('#ShowPdModal').modal('show');
      },
      error:function(err){
        console.log(err);
      }
    });

    
  }

  function showpack(idSale,DocCode,CusName,LastName,PROVINCE_NAME,TotalNet,PsNnameF,nameSocial,NamePay,dateCreate,Mobile1,Email,namePromotion,AddressText,Note,codeInden){

    $('#PvCusName').val(CusName +" "+ LastName);
    $('#PvCodeInden').val(codeInden);
    $('#PvPromotion').val(namePromotion);
    $('#PvDocCode').val(DocCode);
    $('#PvDateCreate').val(dateCreate);
    $('#PvNameSocial').val(nameSocial);
    $('#PvNamePay').val(NamePay);
    $('#PvMobile1').val(Mobile1);
    $('#PvPsNnameF').val(PsNnameF);
    $('#PvAddressText').val(AddressText);
    $('#PvNote').val(Note);
    $('#PvTotalNet').val(TotalNet);
    $('#PInput_idSale').val(idSale);
    $.ajax({
      url:'<?php echo e(url("finepddtsale")); ?>/'+idSale,
      type:'GET',
      dataType:'json',
      cache:false,
      
      success:function(ret){
        console.log(ret);
        $("#tdDtpack").empty();
        var showdt = ret["dt"];
        var rows = 1;
        for(x in showdt){
   
          var PriceM = numeral(showdt[x].PriceM).format('0,0');
          var Price = numeral(showdt[x].Price).format('0,0');
          var d = numeral(showdt[x].totalNet).format('0,0');
          var Amount = numeral(showdt[x].Amount).format('0,0');
          str = '<tr>'
          +'<td  class="text-nowrap" scope="row" style="text-align: center;">'
          +rows
          +'. '
          +'</td>'
          +'<td class="text-nowrap" style="text-align: center;"><input type="hidden" name="numlotT[]" value="'+showdt[x].LotNo+'">'
          +showdt[x].LotNo
          +'</td>'
          +'<td class="text-nowrap" scope="row" style="text-align: left; color: #00897B;"><input type="hidden" name="idPdPkLotT[]" value="'+showdt[x].idPdPkLot+'"><input type="hidden" name="idPd" value="'+showdt[x].idPdPk+'">'
          +showdt[x].PdName
          +'</td>'

          +'<td class="text-nowrap" style="text-align: center;"><input type="hidden" name="AmountT[]" value="'+showdt[x].Amount+'">'
          +Amount
          +'</td>'
          +'<td class="text-nowrap" style="text-align: center;">'
          +showdt[x].UnitName
          +'</td>'

          $("#tdDtpack").append(str);
          rows++;
        }

        $('#ShowOdPackModal').modal('show');
      },
      error:function(err){
        console.log(err);
      }
    });

    
  }


   function addslashes(str) {
    str = str.replace(/\\/g, '\\\\');
    str = str.replace(/\'/g, '\\\'');
    str = str.replace(/\"/g, '\\"');
    str = str.replace(/\0/g, '\\0');
    return str;
  }

  
  $( "input[name='phase_type']").change(function() {
    if($("#inlineRadio1").prop('checked')==true){
      $("#txtDay1").prop('disabled', false);
      $("#txtDay2").prop('disabled', false);
      $("#txtMMday").prop('disabled', false);
      $("#txtMMYear").prop('disabled', true);
      $("#txtMMmon").prop('disabled', true);
      $("#selMount").prop('disabled', true);
      $("#txtYear").prop('disabled', true);
    }
    else if($("#inlineRadio2").prop('checked')==true){
      $("#txtDay1").prop('disabled', true);
      $("#txtDay2").prop('disabled', true);
      $("#txtMMday").prop('disabled', true);
      $("#txtMMYear").prop('disabled', true);
      $("#txtMMmon").prop('disabled', false);
      $("#selMount").prop('disabled', false);
      $("#txtYear").prop('disabled', true);
    }
    else if($("#inlineRadio3").prop('checked')==true){
      $("#txtDay1").prop('disabled', true);
      $("#txtDay2").prop('disabled', true);
      $("#selMount").prop('disabled', true);
      $("#txtYear").prop('disabled', false);
      $("#txtMMday").prop('disabled', true);
      $("#txtMMYear").prop('disabled', false);
      $("#txtMMmon").prop('disabled', true);
    }

  });



  function createdatepicker(id){
    $('#'+id).datepicker({
      format: "dd/mm/yyyy",
      todayBtn: "linked",
      clearBtn: true,
      language: "th",
      daysOfWeekHighlighted: "0",
      autoclose: true,
      todayHighlight: true
    });
  }
  function createYpicker(id){
    $('#'+id).datepicker({
      format: "yyyy",
      todayBtn: "linked",
      clearBtn: true,
      language: "th",
      minViewMode: 2,
      maxViewMode: 2,
      daysOfWeekHighlighted: "0",
      autoclose: true,
      todayHighlight: true
    });
  }
  function createMpicker(id){
    $('#'+id).datepicker({
      format: "mm",
      todayBtn: "linked",
      clearBtn: true,
      minViewMode: 1,
      maxViewMode: 1,
      language: "th",
      daysOfWeekHighlighted: "0",
      autoclose: true,
      todayHighlight: true
    });
  }

  $(function(){

    createdatepicker('txtDay1');
    createdatepicker('txtDay2');
    createdatepicker('txtDay11');
    createdatepicker('txtDay12');
    createMpicker('txtMount');
    createYpicker('txtYear');
    createYpicker('txtYear1');
  });

  $('#printsales').click(function(){
   $("#formreport").submit();
 })

</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make("layout.menu", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\except\resources\views/stock/approvepack.blade.php ENDPATH**/ ?>