<?php $__env->startSection("style"); ?>
<style>
    .bd-callout {
      padding: 1.25rem;
      margin-top: 1.25rem;
      margin-bottom: 1.25rem;
      border: 1px solid #eee;
      border-left-width: .25rem;
      border-radius: .25rem
      }

      .bd-callout h4 {
      margin-top: 0;
      margin-bottom: .25rem
      }

      .bd-callout p:last-child {
      margin-bottom: 0
      }

      .bd-callout code {
      border-radius: .25rem
      }

      .bd-callout+.bd-callout {
      margin-top: -.25rem
      }

      .bd-callout-info {
      border-left-color: #5bc0de
      }

      .bd-callout-info h4 {
      color: #5bc0de
      }

      .bd-callout-warning {
      border-left-color: #f0ad4e
      }

      .bd-callout-warning h4 {
      color: #f0ad4e
      }

      .bd-callout-danger {
      border-left-color: #d9534f
      }

      .bd-callout-danger h4 {
      color: #d9534f
      }

      .bd-callout-primary{
      border-left-color: #007bff
      }

      .bd-callout-primaryh4 {
      color: #007bff
      }

      .bd-callout-success{
      border-left-color: #28a745
      }

      .bd-callout-successh4 {
      color: #28a745
      }

      .bd-callout-default{
      border-left-color: #6c757d
      }

      .bd-callout-defaulth4 {
      color: #6c757d
      }

      /* การ์ดลูกค้า */
    .user-card-full {
        overflow: hidden
    }

    .card {
        border-radius: 5px;
        -webkit-box-shadow: 0 1px 20px 0 rgba(69, 90, 100, 0.08);
        box-shadow: 0 1px 20px 0 rgba(69, 90, 100, 0.08);
        border: none;
        margin-bottom: 30px
    }

    .m-r-0 {
        margin-right: 0px
    }

    .m-l-0 {
        margin-left: 0px
    }

    .user-card-full .user-profile {
        border-radius: 5px 0 0 5px
    }

    .bg-c-lite-green {
        background: -webkit-gradient(linear, left top, right top, from(#f29263), to(#ee5a6f));
        background: linear-gradient(to right, #ee5a6f, #f29263)
    }

    .user-profile {
        padding: 20px 0
    }

    .card-block {
        padding: 1.25rem
    }

    .m-b-25 {
        margin-bottom: 25px
    }

    .img-radius {
        border-radius: 5px
    }

    h6 {
        font-size: 14px
    }

    .card .card-block p {
        line-height: 25px
    }

    @media  only screen and (min-width: 1400px) {
        p {
            font-size: 14px
        }
    }

    .card-block {
        padding: 1.25rem
    }

    .b-b-default {
        border-bottom: 1px solid #e0e0e0
    }

    .m-b-20 {
        margin-bottom: 20px
    }

    .p-b-5 {
        padding-bottom: 5px !important
    }

    .card .card-block p {
        line-height: 25px
    }

    .m-b-10 {
        margin-bottom: 10px
    }

    .text-muted {
        color: #919aa3 !important
    }

    .b-b-default {
        border-bottom: 1px solid #e0e0e0
    }

    .f-w-600 {
        font-weight: 600
    }

    .m-b-20 {
        margin-bottom: 20px
    }

    .m-t-40 {
        margin-top: 20px
    }

    .p-b-5 {
        padding-bottom: 5px !important
    }

    .m-b-10 {
        margin-bottom: 10px
    }

    .m-t-40 {
        margin-top: 20px
    }

    .user-card-full .social-link li {
        display: inline-block
    }

    .user-card-full .social-link li a {
        font-size: 20px;
        margin: 0 10px 0 0;
        -webkit-transition: all 0.3s ease-in-out;
        transition: all 0.3s ease-in-out
    }
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection("content"); ?>

<?php
$strYear = date("Y");
$dat2Date = date("d/m/Y");
$sumLastYear = 0 ;
$sumpic = 0 ;
$contpro = 0;
$sumprice = 0;
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="#">Sale</a></li>
    <li class="breadcrumb-item active" aria-current="page">ข้อมูลการขาย</li>
  </ol>
</nav>
<div class="row">
    <div class="col-sm-3 mb-12">
      <div class="bd-callout bd-callout-primary">
        <div class="row">
          <div class="col">
          <p class="m-0 font-weight-bold text-dark" style="text-align: center; font-size: 16px;">ยอดขายวันนี้</p>
          <p class="m-0 font-weight-bold text-primary"  style="text-align: center; font-size: 18px;"><?php echo e(number_format($sum[0]->Sumtotal), 2); ?></p>
          </div>
        </div>  
      </div>
    </div>
    <div class="col-sm-3 mb-12">
      <div class="bd-callout bd-callout-primary">
        <div class="row">
          <div class="col">
          <p class="m-0 font-weight-bold text-dark" style="text-align: center; font-size: 16px;">ยอดขายเดือนนี้</p>
          <p class="m-0 font-weight-bold text-primary"  style="text-align: center; font-size: 18px;"><?php echo e(number_format($sum2date[0]->Sumtotal), 2); ?></p>
          </div>
        </div>  
      </div>
    </div>
    <div class="col-sm-2 mb-12">
      <div class="bd-callout bd-callout-success">
        <div class="row">
          <div class="col">
          <p class="m-0 font-weight-bold text-dark" style="text-align: center; font-size: 16px;">รายการจองสินค้าประจำวัน</p>
          <p class="m-0 font-weight-bold text-success"  style="text-align: center; font-size: 18px;"><?php echo e(number_format($counnotan[0]->cnotan)); ?></p>
          </div>
        </div>  
      </div>
    </div>
    <div class="col-sm-2 mb-12">
      <div class="bd-callout bd-callout-success">
        <div class="row">
          <div class="col">
          <p class="m-0 font-weight-bold text-dark" style="text-align: center; font-size: 16px;">จ่ายเงินแล้ว</p>
          <p class="m-0 font-weight-bold text-success"  style="text-align: center; font-size: 18px;"><?php echo e(number_format($counallbill[0]->cbill)); ?></p>
          </div>
        </div>  
      </div>
    </div>
    <div class="col-sm-2 mb-12">
      <div class="bd-callout bd-callout-success">
        <div class="row">
          <div class="col">
          <p class="m-0 font-weight-bold text-dark" style="text-align: center; font-size: 16px;">รายการที่จัดส่งเสร็จ</p>
          <p class="m-0 font-weight-bold text-success"  style="text-align: center; font-size: 18px;"><?php echo e(number_format($countw8app[0]->cunw8app)); ?></p>
          </div>
        </div>  
      </div>
    </div>
  
  </div>
<div class="card">
  <div class="card-body">
  <div class="row">
    <div class="col-9 mb-12">
      <div class="row">
          <div class="row" style="padding-left: 10px">
            <div class="col-md-12 col-12">
              <p><span class="m-0 font-weight-bold text-primary" id="h6text"  style="font-size:16px;">ตารางข้อมูลรายการขาย </span><span class="m-0 font-weight-bold text-dark"  style="font-size:14px;"> <?php echo e($datetext); ?> </span></p>
              
            </div>
          </div>
          <div class="row" style="padding-left: 20px">
            <div class="col-12">
              <a  class="btn btn-success btn-success btn-sm" style="color: #FFF" data-toggle="modal" data-target="#show2dateModalCenter"> <i class="fas fa-cog"></i> ตั้งค่าการค้นหา</a>
            </div>
          </div>
          <!-- <div class="row" style="padding-left: 20px">
            <div class="col-12">
              <a  class="btn btn-primary btn-primary btn-sm" style="color: #FFF" data-toggle="modal" data-target="#reportSalesModalCenter"> <i class="fas fa-print"></i> ปริ้นรายงานยอดขาย</a>
            </div>
          </div> -->
          <div class="row" style="padding-left: 20px">
            <div class="col-12">
              <div class="btn-group">
                <button type="button" class="btn btn-primary btn-sm"> <i class="fas fa-print"></i> ออกรายงาน</button>
                <button type="button" class="btn btn-primary btn-sm 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>              
                </div>
              </div>
            </div>
          </div>
          <!-- <div class="row" style="padding-left: 20px">
            <div class="col-12">
              <a  class="btn btn-outline-info btn-sm" href="saleorder"> <i class="fas fa-cart-plus"></i> ออกใบเสนอราคา</a>
            </div>
          </div> -->
          <!-- <div class="row" style="padding-left: 20px">
            <div class="col-12">
              <a  class="btn btn-outline-primary btn-sm" href="sale"> <i class="fas fa-cart-plus"></i> เพิ่มรายการขาย</a>
            </div>
          </div> -->

        </div>
    </div>
    <div class="col-3 mb-12 " style="text-align: right;">
      <div class="row">
        <div class="col-md-12 col-12">
        <p class="m-0 font-weight-bold text-info"  style="text-align: right; font-size: 22px;"><span class="font-weight-light" style="color:#afb9c8;font-size: 16px;">ยอดขายรวม : </span> <?php echo e(number_format($sumtb[0]->Sumtotal)); ?>.-</p>
        <!-- <input type="text" class="form-control" name="vSumTotalnet" id="vSumTotalnet" style="text-align: right; color: #1B5E20; size: 18px;"  value="<?php echo e(number_format($sum[0]->Sumtotal)); ?>" disabled> -->
        </div>
      </div>
    </div>
    </div>
  </div>
</div>

<div class="card">
  <div class="card-body">
  <div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
    
    <button type="button"  onclick="window.location.href='add/sale/menu'" class="btn btn-primary btn-sm"><i class="fas fa-cart-plus"></i>  เพิ่มรายการเบิกสินค้า</button> 
    <button type="button" id="btNewInv"  class="btn btn-outline-danger"><i class="fas fa-file-invoice"></i> ใบแจ้งหนี้ </button>
    <button type="button" id="btNewOrder"  class="btn btn-outline-info"><i class="far fa-file-alt"></i> ออเดอร์ใหม่รอเปิดบิล  <?php if($countod[0]->od == 0): ?><?php else: ?><span class="badge badge-pill badge-info"><?php echo e(number_format($countod[0]->od)); ?></span><?php endif; ?></button>
    <button type="button" id="btall" class="btn btn btn-outline-primary" ><i class="far fa-file-alt"></i> รายการเบิกทั้งหมด <span class="badge badge-primary" name="adgecounall" id="vcountmt" ></span></button>
  </div>

  <div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
    
    
    <button type="button" onclick="window.location.href='approvewihtpack'" class="btn btn-outline-danger">รายการค้างส่ง <?php if($counnopac[0]->cnopac == 0): ?><?php else: ?><span class="badge badge-pill badge-danger"><?php echo e(number_format($counnopac[0]->cnopac)); ?></span><?php endif; ?></button>
    
  </div>
  </div>
</div>

<!-- DataTales Example -->
<div class="card mb-4">
  <div class="card-header py-3">
    <div class="row">
      <div class="col-12 mb-12">

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

<div class="card-body" id="allmt" style="font-size: 12px;">
  <div class="table-responsive" >
    <table class="table table-sm" id="PdTable" width="100%" cellspacing="0">
      <thead>
        <tr>
          <th style="text-align: center; font-size: 12px;">#</th>
          <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;" >ตัวเลือก</th>
          <th class="text-nowrap" scope="col" style="text-align: left; font-size: 12px;" >เลขที่รายการ</th>
          <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;" >สั่งเมื่อ</th>
          <th class="text-nowrap" scope="col" style="text-align: left; font-size: 12px;" >ชื่อลูกค้า</th>
          <th class="text-nowrap" scope="col" style="text-align: right; font-size: 12px;" >ราคาขาย</th>
          <th class="text-nowrap" scope="col" style="text-align: right; font-size: 12px;" >โปรโมชั่น</th>
          <th class="text-nowrap" scope="col" style="text-align: right; font-size: 12px;" >ส่วนลด</th>
          <th class="text-nowrap" scope="col" style="text-align: right; font-size: 12px;" >รวมสุทธิ</th>
          <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;" >เจ้าหน้าที่ขาย</th>
          <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;">ระบบ</th>
          <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;" >การชำระเงิน</th>
          <!-- <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;" >สถานะชำระเงิน</th>
          <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;">สถานะการจัดส่ง</th> -->
          <!-- <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;">หมายเลข Tacking</th> -->
          <th class="text-nowrap" scope="col" style="text-align: right; font-size: 12px;" >วันที่รายการ</th>

        </tr>
      </thead>
      <?php
      $i = 1;
      $SumTotalnet = 0;
      ?>
      <tbody>
       <?php $__currentLoopData = $mt; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
       <?php
       $tm = \Carbon\Carbon::createFromTimeStamp(strtotime($x->dateCreate));
       ?>
       <tr>

        <td style="text-align: center;"><?php echo e($i++); ?>.</td>
        <td class="text-nowrap" style="text-align: left; font-size: 12px;">
          <div class="btn-group">
            <button type="button" class="btn btn-primary btn-sm"> ตัวเลือก</button>
            <button type="button" class="btn btn-primary btn-sm 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="#"  onClick="show('<?php echo e($x->idSale); ?>','<?php echo e($x->DocCode); ?>','<?php echo e($x->CusName); ?>','<?php echo e($x->LastName); ?>','<?php echo e($x->PROVINCE_NAME); ?>','<?php echo e(number_format($x->TotalNet)); ?>','<?php echo e($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); ?>','<?php echo e($x->numeTack); ?>','<?php echo e($x->DiscountAmout); ?>','<?php echo e($x->priceTarn); ?>')"><i class="fas fa-search"></i> แสดงข้อมูลทั้งหมด</a>
              <a class="dropdown-item" href="edit/sale/<?php echo e($x->idSale); ?>"> <i class="fas fa-edit"></i> แก้ไขข้อมูล</a>
              <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="printpdf/<?php echo e($x->idSale); ?>/<?php echo e($x->idCus); ?>" target="_blank" > <i class="fas fa-file-invoice"></i> ปริ้นรายการขาย</a>
              </div>
            </div>
          </div>          
          <!-- <a  class="btn btn-primary btn-info btn-sm" href="printpdf/<?php echo e($x->idSale); ?>/<?php echo e($x->idCus); ?>" target="_blank" hover="ใบเสร็จ">
          <i class="fas fa-file-invoice"></i>
          </a> 
          <a  class="btn btn-primary btn-info btn-sm" href="printpdfsk/<?php echo e($x->idSale); ?>/<?php echo e($x->idCus); ?>" target="_blank">
          <i class="far fa-address-card"></i>
          </a> -->
          <?php if($x->numeTack == NULL): ?>
          <a  class="btn btn-danger btn-info btn-sm" onclick="fndelbill('<?php echo e($x->idSale); ?>')" target="_blank" style="color: #fff; font-size:12px;">
            ยกเลิกบิล
          </a> 
          <?php else: ?>
          <button class="btn btn-danger btn-info btn-sm" target="_blank" style="color: #fff" disabled>
          <i class="far fa-window-close"></i>
           </button>  
           <?php endif; ?> 

         </td>
         <td class="text-nowrap" style="font-size:14px;"><a href="#"  onClick="show('<?php echo e($x->idSale); ?>','<?php echo e($x->DocCode); ?>','<?php echo e($x->CusName); ?>','<?php echo e($x->LastName); ?>','<?php echo e($x->PROVINCE_NAME); ?>','<?php echo e(number_format($x->TotalNet)); ?>','<?php echo e($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); ?>','<?php echo e($x->numeTack); ?>','<?php echo e($x->DiscountAmout); ?>','<?php echo e($x->priceTarn); ?>')"> <?php echo e($x->DocCode); ?></a></td>
         <td class="text-nowrap" style="text-align: center;font-size:14px;"><?php echo $tm->diffForHumans(); ?></td>
         <td class="text-nowrap" style="text-align: left;font-size:14px;"><a href="#"  onclick="showCusModal('<?php echo e($x->idCus); ?>')"><?php echo e($x->CusName); ?> <?php echo e($x->LastName); ?></a> </td>
         <td class="text-nowrap"style="text-align: center;font-size:14px;"><?php echo e(number_format($x->Total)); ?></td>
         <td class="text-nowrap"style="text-align: center;font-size:14px;"><?php echo e($x->namePromotion); ?></td>
         <td class="text-nowrap"style="text-align: center;font-size:14px;"><?php echo e(number_format($x->DiscountAmout)); ?></td>
         <td class="text-nowrap"style="text-align: right;font-size:14px;"><?php echo e(number_format($x->TotalNet)); ?></td>
         <td class="text-nowrap"style="text-align: center;font-size:14px;"><?php echo e($x->PsNnameF); ?></td>
         <td class="text-nowrap"style="text-align: center;font-size:14px;"><img src="<?php echo e($x->partImg); ?>" class="rounded" alt="..."></td>
         <td class="text-nowrap" style="text-align: center;font-size:14px;"><?php echo e($x->NamePay); ?></td>
         <!-- <td class="text-nowrap" style="text-align: center;font-size:14px;"><?php if(is_null($x->stPay)): ?>  <span class="badge badge-danger">รอการชำระ</span> <?php else: ?> <span class="badge badge-success">ชำระเงินแล้ว</span> <?php endif; ?></td>
         <td class="text-nowrap" style="text-align: center;font-size:14px;"><?php if(is_null($x->numeTack)): ?>  <span class="badge badge-warning">รอจัดส่ง</span> <?php else: ?> <span class="badge badge-success">จัดส่งแล้ว</span> <?php endif; ?></td> -->
         <!-- <td class="text-nowrap" style="text-align: center;font-size:14px;"><?php echo e($x->numeTack); ?></td> -->
         <td class="text-nowrap" style="text-align: right;font-size:14px;"><?php echo e(DateThai($x->dateCreate)); ?></td>
         
       </tr>
       <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
      <input type="text" style="display:none" id="countMt" value="<?php echo e($i); ?>"></input>
     </tbody>
   </table>
 </div>
</div>

<!-- table OD-->
<div class="card-body" id="allorder" style="display:none" style="font-size: 12px;">
  <div class="table-responsive" >
    <table class="table table-sm" id="PdODTable" width="100%" cellspacing="0"  style="font-size: 12px;">
      <thead>
        <tr>
          <th style="text-align: center;">#</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >ตัวเลือก</th>
          <th class="text-nowrap" scope="col" style="text-align: left;" >เลขที่รายการ</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >สั่งเมื่อ</th>
          <th class="text-nowrap" scope="col" style="text-align: left;" >ชื่อลูกค้า</th>
          <th class="text-nowrap" scope="col" style="text-align: right;" >ราคาขาย</th>
          <th class="text-nowrap" scope="col" style="text-align: right;" >ส่วนลด</th>
          <th class="text-nowrap" scope="col" style="text-align: right;" >รวมสุทธิ</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >เจ้าหน้าที่ขาย</th>
          <th class="text-nowrap" scope="col" style="text-align: center;">ระบบ</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >การชำระเงิน</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >สถานะชำระเงิน</th>
          <th class="text-nowrap" scope="col" style="text-align: center;">สถานะเปิดบิล</th>
          <th class="text-nowrap" scope="col" style="text-align: center;">หมายเลข Tacking</th>
          <th class="text-nowrap" scope="col" style="text-align: right;" >วันที่รายการ</th>

        </tr>
      </thead>
      <?php
      $i = 1;
      $SumTotalnet = 0;
      ?>
      <tbody  style="font-size: 12px;">
       <?php $__currentLoopData = $mtod; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
       <?php
       $tm = \Carbon\Carbon::createFromTimeStamp(strtotime($x->dateCreate));
       ?>
       <tr>
        <td style="text-align: center;"><?php echo e($i++); ?>.</td>
        <td class="text-nowrap" style="text-align: left;">
          <a href="#" class="btn btn-primary btn-circle btn-sm" onClick="showod('<?php echo e($x->idSaleOd); ?>','<?php echo e($x->DocCode); ?>','<?php echo e($x->CusName); ?>','<?php echo e($x->LastName); ?>','<?php echo e($x->PROVINCE_NAME); ?>','<?php echo e(number_format($x->TotalNet)); ?>','<?php echo e($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); ?>','<?php echo e($x->numeTack); ?>','<?php echo e($x->DiscountAmout); ?>','<?php echo e($x->priceTarn); ?>')">
            <i class="fas fa-search"></i>
          </a> 
          <a  class="btn btn-primary btn-warning btn-sm" href="edit/saleorder/<?php echo e($x->idSaleOd); ?>"><i class="fas fa-edit"></i></a>
          <a  class="btn btn-primary btn-info btn-sm" href="printquotationpdf/<?php echo e($x->idSaleOd); ?>/<?php echo e($x->idCus); ?>" target="_blank" hover="ใบเสนอราคา">
          <i class="fas fa-file-invoice"></i>
          </a> 
          <a  class="btn btn-primary btn-info btn-sm" href="printinvoicepdf/<?php echo e($x->idSaleOd); ?>/<?php echo e($x->idCus); ?>" target="_blank">
          <i class="fas fa-file-invoice-dollar"></i>
          </a>
          <!-- <?php if($x->numeTack == NULL): ?>
          <a  class="btn btn-danger btn-info btn-sm" onclick="fndelbill('<?php echo e($x->idSaleOd); ?>')" target="_blank" style="color: #fff;font-size: 12px;">
            ยกเลิกออเดอร์
          </a> 
          <?php else: ?>
          <button class="btn btn-danger btn-info btn-sm" target="_blank" style="color: #fff" disabled>
          <i class="far fa-window-close"></i>
           </button>  
           <?php endif; ?>  -->

         </td>
         <td class="text-nowrap" style="font-size: 14px;"><?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;"><a href="#"  onclick="showCusModal('<?php echo e($x->idCus); ?>')"><?php echo e($x->CusName); ?> <?php echo e($x->LastName); ?></a> </td>
         <td class="text-nowrap"style="text-align: center;"><?php echo e(number_format($x->Total)); ?></td>
         <td class="text-nowrap"style="text-align: center;"><?php echo e(number_format($x->DiscountAmout)); ?></td>
         <td class="text-nowrap"style="text-align: right;"><?php echo e(number_format($x->TotalNet)); ?></td>
         <td class="text-nowrap"style="text-align: center;"><?php echo e($x->PsNnameF); ?></td>
         <td class="text-nowrap"style="text-align: center;"><img src="<?php echo e($x->partImg); ?>" class="rounded" alt="..."></td>
         <td class="text-nowrap" style="text-align: center;"><?php echo e($x->NamePay); ?></td>
         <td class="text-nowrap" style="text-align: center;"><?php if($x->stPay == 0): ?>  <span class="badge badge-danger">รอการชำระ</span> <?php else: ?> <span class="badge badge-success">ชำระเงินแล้ว</span> <?php endif; ?></td>
         <td class="text-nowrap" style="text-align: center;"><?php if(is_null($x->numeTack)): ?>  <span class="badge badge-danger">รอเปิดบิล</span> <?php else: ?> <span class="badge badge-success">เปิดบิลแล้ว</span> <?php endif; ?></td>
         <td class="text-nowrap" style="text-align: center;"><?php echo e($x->numeTack); ?></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>

<!-- table Inv-->
<div class="card-body" id="allinv" style="display:none" style="font-size: 12px;">
  <div class="table-responsive" >
    <table class="table table-sm" id="PdODTable" width="100%" cellspacing="0"  style="font-size: 12px;">
      <thead>
        <tr>
          <th style="text-align: center;">#</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >ตัวเลือก</th>
          <th class="text-nowrap" scope="col" style="text-align: left;" >เลขที่รายการ</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >สั่งเมื่อ</th>
          <th class="text-nowrap" scope="col" style="text-align: left;" >ชื่อลูกค้า</th>
          <th class="text-nowrap" scope="col" style="text-align: right;" >ราคาขาย</th>
          <th class="text-nowrap" scope="col" style="text-align: right;" >ส่วนลด</th>
          <th class="text-nowrap" scope="col" style="text-align: right;" >รวมสุทธิ</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >เจ้าหน้าที่ขาย</th>
          <th class="text-nowrap" scope="col" style="text-align: center;">ระบบ</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >การชำระเงิน</th>
          <th class="text-nowrap" scope="col" style="text-align: center;" >สถานะชำระเงิน</th>
          <th class="text-nowrap" scope="col" style="text-align: center;">สถานะเปิดบิล</th>
          <th class="text-nowrap" scope="col" style="text-align: center;">หมายเลข Tacking</th>
          <th class="text-nowrap" scope="col" style="text-align: right;" >วันที่รายการ</th>

        </tr>
      </thead>
      <?php
      $i = 1;
      $SumTotalnet = 0;
      ?>
      <tbody  style="font-size: 12px;">
       <?php $__currentLoopData = $mtinv; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
       <?php
       $tm = \Carbon\Carbon::createFromTimeStamp(strtotime($x->dateCreate));
       ?>
       <tr>
        <td style="text-align: center;"><?php echo e($i++); ?>.</td>
        <td class="text-nowrap" style="text-align: left;">
          <a href="#" class="btn btn-primary btn-circle btn-sm" onClick="showod('<?php echo e($x->idSaleOd); ?>','<?php echo e($x->DocCode); ?>','<?php echo e($x->CusName); ?>','<?php echo e($x->LastName); ?>','<?php echo e($x->PROVINCE_NAME); ?>','<?php echo e(number_format($x->TotalNet)); ?>','<?php echo e($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); ?>','<?php echo e($x->numeTack); ?>','<?php echo e($x->DiscountAmout); ?>','<?php echo e($x->priceTarn); ?>')">
            <i class="fas fa-search"></i>
          </a> 
          <a  class="btn btn-primary btn-warning btn-sm" href="edit/invoice/<?php echo e($x->idSaleOd); ?>"><i class="fas fa-edit"></i></a> 
          <a  class="btn btn-primary btn-info btn-sm" href="printinvoicepdf/<?php echo e($x->idSaleOd); ?>/<?php echo e($x->idCus); ?>" target="_blank">
          <i class="fas fa-file-invoice-dollar"></i>
          </a>
          <!-- <?php if($x->numeTack == NULL): ?>
          <a  class="btn btn-danger btn-info btn-sm" onclick="fndelbill('<?php echo e($x->idSaleOd); ?>')" target="_blank" style="color: #fff;font-size: 12px;">
            ยกเลิกออเดอร์
          </a> 
          <?php else: ?>
          <button class="btn btn-danger btn-info btn-sm" target="_blank" style="color: #fff" disabled>
          <i class="far fa-window-close"></i>
           </button>  
           <?php endif; ?>  -->

         </td>
         <td class="text-nowrap" style="font-size: 14px;"><?php echo e($x->docCodeInvoice); ?></td>
         <td class="text-nowrap" style="text-align: center;"><?php echo $tm->diffForHumans(); ?></td>
         <td class="text-nowrap" style="text-align: left;"><a href="#" onclick="showCusModal('<?php echo e($x->idCus); ?>')"><?php echo e($x->CusName); ?> <?php echo e($x->LastName); ?></a> </td>
         <td class="text-nowrap"style="text-align: center;"><?php echo e(number_format($x->Total)); ?></td>
         <td class="text-nowrap"style="text-align: center;"><?php echo e(number_format($x->DiscountAmout)); ?></td>
         <td class="text-nowrap"style="text-align: right;"><?php echo e(number_format($x->TotalNet)); ?></td>
         <td class="text-nowrap"style="text-align: center;"><?php echo e($x->PsNnameF); ?></td>
         <td class="text-nowrap"style="text-align: center;"><img src="<?php echo e($x->partImg); ?>" class="rounded" alt="..."></td>
         <td class="text-nowrap" style="text-align: center;"><?php echo e($x->NamePay); ?></td>
         <td class="text-nowrap" style="text-align: center;"><?php if($x->stPay == 0): ?>  <span class="badge badge-danger">รอการชำระ</span> <?php else: ?> <span class="badge badge-success">ชำระเงินแล้ว</span> <?php endif; ?></td>
         <td class="text-nowrap" style="text-align: center;"><?php if(is_null($x->numeTack)): ?>  <span class="badge badge-danger">รอเปิดบิล</span> <?php else: ?> <span class="badge badge-success">เปิดบิลแล้ว</span> <?php endif; ?></td>
         <td class="text-nowrap" style="text-align: center;"><?php echo e($x->numeTack); ?></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 class="row">
    <div class="col-lg-12 mb-12" >
      <div class="card">
          <div class="card-body">
            <h5 class="card-title" style="color:#04499C;">โปรโมชั่นที่ใช้ <span class="m-0 font-weight-bold"  style="font-size:12px;color:#BE0C52;">[ <?php echo e($datetext); ?> ]</span></h5>
            <table class="table table-sm ">
              <thead>
                <tr style="background-color:#0666A5; color: #FFF;font-size:14px;">
                  <th scope="col" style="font-size: 14px;">#</th>
                  <th scope="col" style="font-size: 14px;">โปรโมชั่น</th>
                  <th scope="col" style="text-align: right;font-size: 12px;">จำนวน/ครั้ง</th>
                  <th scope="col" style="text-align: right;font-size: 12px;">ยอดลดจากโปร/บาท</th>
                 
                </tr>
              </thead>
              <?php
              $i = 1;

              ?>
              <tbody>
              <?php $__currentLoopData = $sumpro; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                  <th scope="row" style="font-size: 14px;"><?php echo e($i++); ?>.</th>
                  <td style="font-size: 14px;"><?php echo e($x->namePromotion); ?></td>
                  <td style="text-align: right; font-size: 16px;"><?php echo e(number_format($x->contpro)); ?></td>
                  <td style="text-align: right; font-size: 16px;"><?php echo e(number_format($x->sumprice)); ?>.-</td>
                </tr>
                <?php
                $contpro += $x->contpro;
                $sumprice += $x->sumprice;
                ?>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </tbody>
              <tfoot>
                <tr style="background-color:#087DC8; color: #FFF;">
                  <td></td>
                  <td style="text-align: right; font-size: 16px;">ยอดรวม :</td>
                  <td style="text-align: right; font-size:16px;"><?php echo e(number_format($contpro)); ?></td>
                  <td style="text-align: right; font-size:16px;"><?php echo e(number_format($sumprice)); ?>.-</td>
                </tr>
              </tfoot>
            </table>
          </div>
        </div>
      </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-12 mb-12" style="padding:10px;">
      <div class="card">
          <div class="card-body">
            <h5 class="card-title" style="color:#04499C;">เปรียบเทียบยอดขาย <span class="m-0 font-weight-bold"  style="font-size:12px;color:#BE0C52;">[ <?php echo e($datetext); ?> ]</span> <span class="m-0 font-weight-bold"  style="font-size:12px;color:#08686C;">[ระบบ: <?php echo e($dsocialtxt); ?> ]</span></h5>
            <table class="table table-sm ">
              <thead>
                <tr style="background-color:#0666A5; color: #FFF;font-size:14px;">
                  <th scope="col" style="font-size: 14px;">#</th>
                  <th scope="col" style="font-size: 14px;">สินค้า</th>
                  <th scope="col" style="text-align: right;font-size: 12px;">จำนวน/ชิ้น</th>
                  <th scope="col" style="text-align: right;font-size: 12px;">ยอดขาย/บาท</th>
                 
                </tr>
              </thead>
              <?php
              $i = 1;

              ?>
              <tbody>
              <?php $__currentLoopData = $cat; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                  <th scope="row" style="font-size: 14px;"><?php echo e($i++); ?>.</th>
                  <td style="font-size: 14px;"><?php echo e($x->PdName); ?></td>
                  <td style="text-align: right; font-size: 16px;"><?php echo e(number_format($x->sumpic)); ?></td>
                  <td style="text-align: right; font-size: 16px;"><?php echo e(number_format($x->LastYear)); ?>.-</td>
                </tr>
                <?php
                $sumLastYear += $x->LastYear;
                $sumpic += $x->sumpic;
                ?>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </tbody>
              <tfoot>
                <tr style="background-color:#FFF; color: #2B2B2B;">
                  <td></td>
                  <td style="text-align: right; font-size: 14px;">ยอดขาย :</td>
                  <td style="text-align: right; font-size:14px;"></td>
                  <td style="text-align: right; font-size:14px;"> <?php echo e(number_format($sumLastYear)); ?>.-</td>
                </tr>
                <tr style="background-color:#FFF; color: #D62349;">
                  <td></td>
                  <td style="text-align: right; font-size: 14px;">ส่วนลด :</td>
                  <td style="text-align: right; font-size:14px;"></td>
                  <td style="text-align: right; font-size:14px;">- <?php echo e(number_format($sumdis[0]->disc)); ?>.-</td>
                </tr>
                <tr style="background-color:#FFF; color: #0E8C68;">
                  <td></td>
                  <td style="text-align: right; font-size: 14px;">ค่าขนส่ง :</td>
                  <td style="text-align: right; font-size:14px;"></td>
                  <td style="text-align: right; font-size:14px;">+ <?php echo e(number_format($sumtan[0]->tannn)); ?>.-</td>
                </tr>
                <tr style="background-color:#087DC8; color: #FFF;">
                  <td></td>
                  <td style="text-align: right; font-size: 16px;">ยอดรวม :</td>
                  <td style="text-align: right; font-size:16px;"><?php echo e(number_format($sumpic)); ?></td>
                  <td style="text-align: right; font-size:16px;"><?php echo e(number_format($sumLastYear + $sumtan[0]->tannn - $sumdis[0]->disc)); ?>.-</td>
                </tr>
              </tfoot>
            </table>
          </div>
        </div>
      </div>
    </div>
    <div class="col-lg-6 mb-12" style="padding:10px;">
      <div class="card">
          <div class="card-body">
            <h5 class="card-title" style="color:#04499C;">รายการจำนวนสั่งซื้อจากระบบ <span class="m-0 font-weight-bold"  style="font-size:12px;color:#BE0C52;">[ <?php echo e($datetext); ?> ]</span></h5>
            <table class="table table-sm ">
              <thead>
                <tr style="background-color:#0666A5; color: #FFF;font-size:12px;">
                  <th scope="col" >#</th>
                  <th scope="col" >ระบบ</th>
                  <th scope="col" ></th>
                  <th scope="col" style="text-align: right;">จำนวน /รายการ</th>
                  <th scope="col" style="text-align: right;">ยอดขาย /บาท</th>
                </tr>
              </thead>
              <?php
              $i = 1;
              ?>
              <tbody>
              <?php $__currentLoopData = $datasumso; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                  <th scope="row" style="font-size: 14px;"><?php echo e($i++); ?>.</th>
                  <td class="text-nowrap"style="text-align: center;"><img src="<?php echo e($x->partImg); ?>" class="rounded" alt="..."></td>
                  <td style="font-size: 12px;"><?php echo e($x->nameSocial); ?></td>
                  <td style="text-align: right; font-size: 16px;"><?php echo e(number_format($x->sumso)); ?></td>
                  <td style="text-align: right; font-size: 16px;"><?php echo e(number_format($x->sumtotal)); ?>.-</td>
                </tr>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </tbody>
              <tfoot>
                <tr style="background-color:#087DC8; color: #FFF;">
                  <td></td>
                  <td style="text-align: right; font-size: 16px;"></td>
                  <td style="text-align: right; font-size: 16px;"></td>
                  <td style="text-align: right; font-size:16px;"></td>
                  <td style="text-align: right; font-size:16px;"></td>
                </tr>
              </tfoot>
            </table>
          </div>
        </div>
    </div>
    <div class="col-lg-6 mb-12" style="padding:10px;">
      <div class="card">
          <div class="card-body">
            <h5 class="card-title" style="color:#048E88;">Top 10 จังหวัดขายดี</h5>
            <table class="table table-sm ">
              <thead>
                <tr style="background-color:#06A890; color: #FFF;font-size:12px;">
                  <th scope="col" >#</th>
                  <th scope="col" >จังหวัด</th>
                  <th scope="col" style="text-align: right;">จำนวน /ลูกค้า</th>
                </tr>
              </thead>
              <?php
              $i = 1;
              ?>
              <tbody>
              <?php $__currentLoopData = $top10pv; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                  <th scope="row" style="font-size: 14px;"><?php echo e($i++); ?>.</th>
                  <td style="font-size: 14px;"><?php echo e($x->PROVINCE_NAME); ?></td>
                  <td style="text-align: right; font-size: 16px;"><?php echo e(number_format($x->sumpc)); ?></td>
                </tr>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </tbody>
              <tfoot>
                <tr style="background-color:#05B59A; color: #FFF;">
                  <td></td>
                  <td style="text-align: right; font-size: 16px;"></td>
                  <td style="text-align: right; font-size: 16px;"></td>
                  <td style="text-align: right; font-size:16px;"></td>
                </tr>
              </tfoot>
            </table>
          </div>
        </div>
    </div>
</div>


<!-- Modal MT-->
<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>
      <div class="modal-body" style="font-size: 14px;">

        <div class="form-row">
          <div class="form-group input-group-sm col-md-6">
            <label for="vCusName">ชื่อลูกค้า :</label>
            <input type="text" class="form-control" name="vCusName" id="vCusName"  disabled>
          </div>
          <div class="form-group input-group-sm col-md-3">
            <label for="vCodeInden">เลขที่ผู้เสียภาษี :</label>
            <input type="number" class="form-control" name="vCodeInden" id="vCodeInden" placeholder="ไม่มี" disabled>
          </div>
          <div class="form-group input-group-sm col-md-3">
           <label for="vPromotion">โปรโมชั่นที่ใช้ :</label>
           <input type="text" class="form-control" name="vPromotion" id="vPromotion"  placeholder="ไม่มี" disabled>
         </div>
       </div>
       <div class="form-row">
        <div class="form-group input-group-sm col-md-4">
          <label for="vDocCode">เลขที่รายการ :</label>
          <input type="text" class="form-control" id="vDocCode" name="vDocCode" placeholder="เลขที่รายการ" disabled>
        </div>
        <div class="form-group input-group-sm col-md-4">
          <label for="vDateCreate">วันที่รายการ :</label>
          <input type="text" class="form-control" name="vDateCreate" id="vDateCreate" placeholder="วันที่รายการ" disabled>
        </div>
        <div class="form-group input-group-sm col-md-4">
          <label for="vNameSocial">จากระบบ :</label>
          <input type="text" class="form-control" id="vNameSocial" name="vNameSocial" placeholder="จากระบบ" disabled>
        </div>
        <div class="form-group input-group-sm col-md-4">
          <label for="vNamePay">การชำระเงิน :</label>
          <input type="text" class="form-control" name="vNamePay" id="vNamePay" placeholder="การชำระเงิน" disabled>
        </div>
        <div class="form-group input-group-sm col-md-4">
          <label for="vMobile1">เบอร์โทร :</label>

          <input type="text" class="form-control" id="vMobile1" name="vMobile1" placeholder="เบอร์โทร" disabled>
        </div>
        <div class="form-group input-group-sm 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 input-group-sm col-md-6">
          <label for="vAddressText">ที่อยู่จัดส่ง :</label>
          <textarea class="form-control" name="vAddressText" id="vAddressText" rows="3" disabled></textarea>
        </div>
        <div class="form-group input-group-sm 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="form-group input-group-sm col-md-6">
          <label for="vNote">หมายเลข Tacking :</label>
          <input type="" name="" class="form-control" name="vnumeTack" id="vnumeTack" rows="3" disabled>
        </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>
                <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 input-group-sm col-md-4">
        <label for="vpriceTarn">ค่าขนส่ง [บาท]</label>
        <input type="text" class="form-control font-weight-bold " name="vpriceTarn" id="vpriceTarn" style="font-size: 14px; text-align: right; color: #00796B;" min="0.01" step="0.01" readonly="" value="0">
      </div>
      <div class="form-group col-md-8">
      </div>
      <div class="form-group input-group-sm col-md-4">
        <label for="vDis">ส่วนลดจากโปรโมชั่น[บาท]</label>
        <input type="text" class="form-control font-weight-bold " name="vDis" id="vDis" style="font-size: 14px; text-align: right; color: #BF360C;" readonly="" value="0">
      </div>
      <div class="form-group col-md-8">
      </div>
      <div class="form-group input-group-sm 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>
  <div class="modal-footer">
    <button type="button" id="Btopenbill" class="btn btn-outline-primary" style="display:none">ทำรายการเปิดบิลขาย</button>
    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  </div>
</div>
</div>
</div>

<!-- Modal OD-->
<!-- <div class="modal fade" id="ShowPdOdModal" 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>
      <div class="modal-body">

        <div class="form-row">
          <div class="form-group col-md-6">
            <label for="vCusNameOd">ชื่อลูกค้า :</label>
            <input type="text" class="form-control" name="vCusNameOd" id="vCusNameOd"  disabled>
          </div>
          <div class="form-group col-md-3">
            <label for="vCodeIndenOd">เลขที่ผู้เสียภาษี :</label>
            <input type="number" class="form-control" name="vCodeIndenOd" id="vCodeIndenOd" placeholder="ไม่มี" disabled>
          </div>
          <div class="form-group col-md-3">
           <label for="vPromotionOd">โปรโมชั่นที่ใช้ :</label>
           <input type="text" class="form-control" name="vPromotionOd" id="vPromotionOd"  placeholder="ไม่มี" disabled>
         </div>
       </div>
       <div class="form-row">
        <div class="form-group col-md-4">
          <label for="vDocCodeOd">เลขที่รายการ :</label>
          <input type="text" class="form-control" id="vDocCodeOd" name="vDocCodeOd" placeholder="เลขที่รายการ" disabled>
        </div>
        <div class="form-group col-md-4">
          <label for="vDateCreateOd">วันที่รายการ :</label>
          <input type="text" class="form-control" name="vDateCreateOd" id="vDateCreateOd" placeholder="วันที่รายการ" disabled>
        </div>
        <div class="form-group col-md-4">
          <label for="vNameSocialOd">จากระบบ :</label>
          <input type="text" class="form-control" id="vNameSocialOd" name="vNameSocialOd" placeholder="จากระบบ" disabled>
        </div>
        <div class="form-group col-md-4">
          <label for="vNamePayOd">การชำระเงิน :</label>
          <input type="text" class="form-control" name="vNamePayOd" id="vNamePayOd" placeholder="การชำระเงิน" disabled>
        </div>
        <div class="form-group col-md-4">
          <label for="vMobile1Od">เบอร์โทร :</label>

          <input type="text" class="form-control" id="vMobile1Od" name="vMobile1Od" placeholder="เบอร์โทร" disabled>
        </div>
        <div class="form-group col-md-4">
          <label for="vPsNnameFOd">เจ้าหน้าที่ขาย :</label>
          <input type="text" class="form-control" name="vPsNnameFOd" id="vPsNnameFOd" placeholder="เจ้าหน้าที่ขาย" disabled>
        </div>
      </div>
      <div class="form-row">
        <div class="form-group col-md-6">
          <label for="vAddressTextOd">ที่อยู่จัดส่ง :</label>
          <textarea class="form-control" name="vAddressTextOd" id="vAddressTextOd" rows="3" disabled></textarea>
        </div>
        <div class="form-group col-md-6">
          <label for="vNoteOd">หมายเหตุ :</label>
          <textarea class="form-control" name="vNoteOd" id="vNoteOd" rows="3" disabled></textarea>
        </div>
      </div>
      <div class="form-row">
        <div class="form-group col-md-6">
          <label for="vNoteOd">หมายเลข Tacking :</label>
          <input type="" name="" class="form-control" name="vnumeTackOd" id="vnumeTackOd" rows="3" disabled>
        </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>
                <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="tdDtOd">

            </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="vpriceTarnOd">ค่าขนส่ง [บาท]</label>
        <input type="text" class="form-control font-weight-bold " name="vpriceTarnOd" id="vpriceTarnOd" style="font-size: 14px; text-align: right; color: #00796B;" min="0.01" step="0.01" readonly="" value="0">
      </div>
      <div class="form-group col-md-8">
      </div>
      <div class="form-group col-md-4">
        <label for="vDisOd">ส่วนลดจากโปรโมชั่น[บาท]</label>
        <input type="text" class="form-control font-weight-bold " name="vDisOd" id="vDisOd" style="font-size: 14px; text-align: right; color: #BF360C;" readonly="" value="0">
      </div>
      <div class="form-group col-md-8">
      </div>
      <div class="form-group col-md-4">
        <label for="vTotalNetOd">รวมเป็นเงินสุทธิ[บาท]</label>
        <input type="text" class="form-control font-weight-bold " name="vTotalNetOd" id="vTotalNetOd" style="font-size: 18px; text-align: right; color: #00796B;" min="0.01" step="0.01" readonly="" value="0">
      </div>
    </div>   
  </div>
  <div class="modal-footer">

    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  </div>
</div>
</div>
</div> -->

<!-- ModalEdit -->
<div class="modal fade" id="EditPdModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header" style="background:#A0522D">
        <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('editpddata'); ?>" method="post" id="formEdit">
       <?php echo csrf_field(); ?>
       <div class="modal-body">

         <div class="form-row">
          <div class="form-group col-md-6">
            <label for="inputName">ชื่อสินค้า</label>
            <span class="form-required" style="color: #CC0000">*</span>
            <input type="text" class="form-control" id="vEname" name="vEname" placeholder="ชื่อสินค้า">
            <input type="hidden" name="inputId" id="inputId">
          </div>
          <div class="form-group col-md-6">
            <label for="inputType">ประเภทสินค้า</label>
            <span class="form-required" style="color: #CC0000">*</span>
            <select id="vEidtype" name="vEidtype" class="form-control">

              <option value=""></option>

            </select>
          </div>
        </div>
        <div class="form-group">
          <label for="vEPdDetail">ข้อมูลเพิ่มเติม</label>
          <span class="form-required" style="color: #CC0000">*</span>
          <input type="text" class="form-control" name="vEPdDetail" id="vEPdDetail" placeholder="">
        </div>
        <div class="form-group">
          <label for="vEPdDes">ลักษณะสินค้า</label>
          <input type="text" class="form-control" name="vEPdDes" id="vEPdDes" placeholder="">
        </div>
        <div class="form-row">
          <div class="form-group col-md-6">
            <label for="vECost">ราคาต้นทุน[บาท]</label>
            <span class="form-required" style="color: #CC0000">*</span>
            <input type="number" class="form-control" name="vECost" id="vECost" min="0.01" step="0.01">
          </div>
          <div class="form-group col-md-6">
            <label for="vEprice">ราคาขาย[บาท]</label>
            <span class="form-required" style="color: #CC0000">*</span>
            <input type="number" class="form-control" name="vEprice" id="vEprice" min="0.01" step="0.01">
          </div>
        </div>
        <div class="form-row">
          <div class="form-group col-md-4">
            <label for="inputUnit">หน่วยบรรจุ</label>
            <span class="form-required" style="color: #CC0000">*</span>
            <select id="vEidUnit" name="vEidUnit" class="form-control">


              <option value=""></option>
              
            </select>
          </div>
          <div class="form-group col-md-4">
            <label for="vEWeight">น้ำหนัก</label>
            <span class="form-required" style="color: #CC0000">*</span>
            <input type="number" class="form-control" name="vEWeight" id="vEWeight" min="0.01" step="0.01">
          </div>
          <div class="form-group col-md-4">
            <label for="vEidWeight">หน่วยน้ำหนัก</label>
            <span class="form-required" style="color: #CC0000">*</span>
            <select id="vEidWeight" name="vEidWeight" class="form-control">

              <option value=""></option>
              
            </select>
          </div>
          <div class="form-group col-md-12">
            <label for="vEnote">หมายเหตุ</label>
            <textarea class="form-control" name="vEnote" id="vEnote" rows="3"></textarea>
          </div>
        </div>     
      </div>
    </form>
    <div class="modal-footer">
      <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      <button type="button" id="btSmEdit" class="btn btn-primary">Save changes</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" style="background: #880E4F; color: #FFFF">
        <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('delbill'); ?>" method="post" id="formdel">
         <?php echo csrf_field(); ?>
         <div class="form-group">
          <label for="inputCancelbill">สาเหตุ</label>
          <span class="form-required" style="color: #CC0000">*</span>
          <input type="hidden" name="idbill" id="idbill" value="">
          <textarea type="text" class="form-control" name="inputCancelbill" id="inputCancelbill"></textarea>
        </div>
      </form>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      <button type="button" id="btCancel" 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('printreportsales'); ?>" method="post" id="formreport" target="_blank">
         <?php echo csrf_field(); ?>
         <div class="form-group col-md-12" style="padding-left:20px">
            <label for="inputSoc">เลือกระบบโซเชียล</label>
            <select id="inputSoc" name="inputSoc" class="form-control" >
              <option value="0" selected>ทั้งหมด</option>
              <?php $__currentLoopData = $dsocial; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($x->idSocial); ?>"><?php echo e($x->nameSocial); ?></option>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
          </div>
         <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>

<!-- Modal ลูกค้า-->
<div class="modal fade" id="showCusModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"  aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document" >
    <div class="row container d-flex justify-content-center" style="padding-right: 1px;">
        <div class="col-xl-12 col-md-12 col-12">
            <div class="card user-card-full">
                <div class="row m-l-0 m-r-0">
                    <div class="col-sm-4  bg-c-lite-green user-profile">
                        <div class="card-block text-center text-white">
                            <div class="m-b-25"> <img src="https://img.icons8.com/bubbles/100/000000/user.png" class="img-radius" alt="User-Profile-Image"> </div>
                            <h6 class="f-w-600" id="namecusmodal"></h6>
                            <p id="grademodal">VVIP</p><i class=" mdi mdi-square-edit-outline feather icon-edit m-t-10 f-16"></i>
                          </div>
                        </div>
                    <div class="col-sm-8 ">
                        <div class="card-block">
                            <h6 class="m-b-20 m-t-40 p-b-5 b-b-default f-w-600">Sales</h6>
                              <div class="row">
                                  <div class="col-sm-6">
                                      <p class="m-b-10 f-w-600">ยอดสั่งซื้อทั้งหมด</p>
                                      <h6 class="text-muted f-w-400" id="sumnetmodel"></h6>
                                  </div>
                                  <div class="col-sm-6">
                                      <p class="m-b-10 f-w-600">รายการสั่งซื้อ</p>
                                      <h6 class="text-muted f-w-400" id="countbillmodel"></h6>
                                  </div>
                                  <div class="col-sm-6">
                                      <p class="m-b-10 f-w-600">ใช้ส่วนลด</p>
                                      <h6 class="text-muted f-w-400" id="sumdis"></h6>
                                  </div>
                              </div>
                            <h6 class="m-b-20 m-t-40 p-b-5 b-b-default f-w-600">Information</h6>
                            <div class="row">
                                <div class="col-sm-6">
                                    <p class="m-b-10 f-w-600">เลขที่ผู้เสียภาษี</p>
                                    <h6 class="text-muted f-w-400" id="idcardmodel"></h6>
                                </div>
                                <div class="col-sm-6">
                                    <p class="m-b-10 f-w-600">Email</p>
                                    <h6 class="text-muted f-w-400" id="emailmodel"></h6>
                                </div>
                                <div class="col-sm-6">
                                    <p class="m-b-10 f-w-600">Phone</p>
                                    <h6 class="text-muted f-w-400" id="phonmodel"></h6>
                                </div>
                                <div class="col-sm-6">
                                    <p class="m-b-10 f-w-600">Social</p>
                                    <h6 class="text-muted f-w-400" id="socialmodel"></h6>
                                </div>
                                <div class="col-sm-6">
                                    <p class="m-b-10 f-w-600">วันที่สมาชิก</p>
                                    <h6 class="text-muted f-w-400"  id="datemodel"></h6>
                                </div>
                                <div class="col-sm-12">
                                    <p class="m-b-10 f-w-600">Address</p>
                                    <h6 class="text-muted f-w-400" id="textaddmodel"></h6>
                                </div>
                            </div>
                            <!-- <a href="#!" style="font-size:14px" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="facebook" data-abc="true">ดูเพิ่มเติม</a> -->
                            <div class="row">
                                <div class="col-sm-6">                            
                                </div>  
                            </div>                   
                        </div>  
                    </div>   
                </div>
            </div>
        </div>
    </div>   
  </div>
</div>

<!--  Modal show2date -->
<div class="modal fade" id="show2dateModalCenter" 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('showsaletb2date'); ?>" method="post" id="form2date" >
         <?php echo csrf_field(); ?>
         <div class="form-group col-md-12" style="padding-left:20px"> 
            <label for="inputSoc">เลือกระบบโซเชียล</label>
            <select id="inputSoc" name="inputSoc" class="form-control" >
              <option value="0" selected>ทั้งหมด</option>
              <?php $__currentLoopData = $dsocial; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($x->idSocial); ?>"><?php echo e($x->nameSocial); ?></option>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
          </div>
         <div class="form-group">
        
          <div class="form-label">เลือกช่วงข้อมูล</div>
          <div class="custom-controls-stacked">
            <label class="custom-control custom-radio">
              <input type="radio" id="inlineRadio11" value=""   class="custom-control-input" name="phase_type" >
              <input type="hidden" id="txtMMday1" name="mm"  value="1" disabled="disabled"/>
              <div class="custom-control-label">ค้นหาตามช่วงวันที่ : 
                <input type="text" id="txtDay11" 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="txtDay12" 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="inlineRadio12" value=""  class="custom-control-input" name="phase_type" >
            <input type="hidden" id="txtMMmon1" name="mm"  value="2" disabled="disabled"/>
            <div class="custom-control-label">ค้นหาตามช่วงเดือนปีนี้ :
              <select name="month"  id="selMount1" 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="inlineRadio13" value="" rel="txt3"  checked="checked" class="custom-control-input" name="phase_type">
            <div class="custom-control-label">ค้นหาทั้งปี :
              <input type="text" id="txtYear1" 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="txtMMYear1" name="mm"  value="3"/>
            </div>
          </label>  
        
      </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="btnsuc2date" >แสดง</button>
  </div>
</div>
</div>
</div>




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

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

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

  $('#btnsuc2date').click(function(){
   $("#form2date").submit();
 })

  $('#btCancel').click(function(){
    if(($("#inputCancelbill").val() == "")){
      swal({
        title: "ไม่สามารถยกเลิกได้ !!!",
        text: "กรุณาระบุสาเหตุการยกเลิก",
        icon: "info",
        button: "ตกลง",
      });

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

   }
 })



  $('#btSmEdit').click(function(){
    if(($("#vEname").val() == "")){
      swal({
        title: "ไม่สามารถบันทึกได้ !!!",
        text: "กรุณากรอกชื่อสินค้า",
        icon: "info",
        button: "ตกลง",
      });

      return false;

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

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

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

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

      return false;
    }else{
     swal({
      title: "การบันทึกข้อมูล",
      text: "คุณต้องการบันทึกแก้ไขสินค้าหรือไม่",
      icon: "warning",
      buttons: true,
      dangerMode: true,
    })
     .then((willDelete) => {
      if (willDelete) {
        swal("บันทึกสำเร็จ", {
          icon: "success",
        });
        $("#formedit").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 showCusModal(idCus){
    
    $.ajax({
        url:'<?php echo e(url("showdatacusmodal")); ?>/'+idCus,
        type:'GET',
        dataType:'json',
        cache:false,
        success:function(ret){
          console.log(ret);
          items = ret["cusallslae"];
          items2 = ret["cusalldt"];
          
          for(x in items){
            if(items[x].total <= 3000 ){
              $("#grademodal").text('Member'); 
            }else if(items[x].total<= 50000 ){
              $("#grademodal").text('Gold Member'); 
            }else if(items[x].total<= 500000 ){
              $("#grademodal").text('VIP '); 
            }else {
              $("#grademodal").text('VVIP '); 
            }
          $("#sumnetmodel").text(numeral(items[x].total).format('0,0')); 
          $("#countbillmodel").text(numeral(items[x].coubill).format('0,0'));
          $("#sumdis").text(numeral(items[x].dis).format('0,0'));

            }
          for(x in items2){
          $("#namecusmodal").text(items2[x].NameUser);
          $("#idcardmodel").text(items2[x].codeInden); 
          $("#emailmodel").text(items2[x].Email);
          $("#phonmodel").text(items2[x].Mobile1);
          $("#socialmodel").text(items2[x].nameSocial);
          $("#datemodel").text(items2[x].DateCreate);
          $("#textaddmodel").text(items2[x].AddressText);
            }
            
          },
          error:function(err){
            alert('Error');
          }
    });
    
    $("#showCusModalCenter").modal('show');
  }

  function fndelbill(id){

    $('#idbill').val(id);
    
    $('#exampleModalCenter').modal('show');
  }

  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,numeTack,DiscountAmout,priceTarn){

    $('#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);
    $('#vnumeTack').val(numeTack);
    $('#vDis').val(DiscountAmout);
    $('#vpriceTarn').val(priceTarn);

    $.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 PriceBfDis = numeral(showdt[x].PriceBfDis).format('0,0');
          var d = numeral(showdt[x].totalNet).format('0,0');
          var Amount = numeral(showdt[x].Amount).format('0,0');
          str = '<tr>'
          +'<td scope="row" style="text-align: center;">'
          +rows
          +'. '
          +'</td>'
          +'<td style="text-align: center;"><input type="hidden" name="numlotT" value="'+showdt[x].LotNo+'">'
          +showdt[x].LotNo
          +'</td>'
          +'<td scope="row" style="text-align: left; color: #00897B;"><input type="hidden" name="idPdPkLot" value="'+showdt[x].idPdPkLot+'"><input type="hidden" name="idPd" value="'+showdt[x].idPdPk+'">'
          +showdt[x].PdName
          +'</td>'
          +'<td style="text-align: right; "><input type="hidden" name="PriceM" value="\''+showdt[x].PriceM+'\'">'
          +PriceM
          +'</td>'
          +'<td style="text-align: center;"><input type="hidden" name="Amount" value="'+showdt[x].Amount+'">'
          +Amount
          +'</td>'
          +'<td style="text-align: right;"><input type="hidden" name="priceT" value="\''+showdt[x].Price+'\'">'
          +Price
          +'</td>'
          +'<td style="text-align: right;"><input type="hidden" name="dis" value="\''+showdt[x].PriceBfDis+'\'">'
          +PriceBfDis
          +'</td>'
          +'<td class="text-nowrap"style="text-align: right;">'+d+'</td>';
          $("#tdDt").append(str);
          rows++;
        }

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

    
  }

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

      $('#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);
      $('#vnumeTack').val(numeTack);
      $('#vDis').val(DiscountAmout);
      $('#vpriceTarn').val(priceTarn);

      $.ajax({
        url:'<?php echo e(url("finepddtodsale")); ?>/'+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 PriceBfDis = numeral(showdt[x].PriceBfDis).format('0,0');
            var d = numeral(showdt[x].totalNet).format('0,0');
            var Amount = numeral(showdt[x].Amount).format('0,0');
            str = '<tr>'
            +'<td scope="row" style="text-align: center;">'
            +rows
            +'. '
            +'</td>'
            +'<td style="text-align: center;"><input type="hidden" name="numlotT" value=""> -'
            +'</td>'
            +'<td scope="row" style="text-align: left; color: #00897B;"><input type="hidden" name="idPdPkLot" value="'+showdt[x].idPdPkLot+'"><input type="hidden" name="idPd" value="'+showdt[x].idPdPk+'">'
            +showdt[x].PdName
            +'</td>'
            +'<td style="text-align: right; "><input type="hidden" name="PriceM" value="\''+showdt[x].PriceM+'\'">'
            +PriceM
            +'</td>'
            +'<td style="text-align: center;"><input type="hidden" name="Amount" value="'+showdt[x].Amount+'">'
            +Amount
            +'</td>'
            +'<td style="text-align: right;"><input type="hidden" name="priceT" value="\''+showdt[x].Price+'\'">'
            +Price
            +'</td>'
            +'<td style="text-align: right;"><input type="hidden" name="dis" value="\''+showdt[x].PriceBfDis+'\'">'
            +PriceBfDis
            +'</td>'
            +'<td class="text-nowrap"style="text-align: right;">'+d+'</td>';
            $("#tdDt").append(str);
            rows++;
          }

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


  }

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

  });

  $( "input[name='phase_type']").change(function() {
    if($("#inlineRadio11").prop('checked')==true){
      $("#txtDay11").prop('disabled', false);
      $("#txtDay12").prop('disabled', false);
      $("#txtMMday1").prop('disabled', false);
      $("#txtMMYear1").prop('disabled', true);
      $("#txtMMmon1").prop('disabled', true);
      $("#selMount1").prop('disabled', true);
      $("#txtYear1").prop('disabled', true);
    }
    else if($("#inlineRadio12").prop('checked')==true){
      $("#txtDay11").prop('disabled', true);
      $("#txtDay12").prop('disabled', true);
      $("#txtMMday1").prop('disabled', true);
      $("#txtMMYear1").prop('disabled', true);
      $("#txtMMmon1").prop('disabled', false);
      $("#selMount1").prop('disabled', false);
      $("#txtYear1").prop('disabled', true);
    }
    else if($("#inlineRadio13").prop('checked')==true){
      $("#txtDay11").prop('disabled', true);
      $("#txtDay12").prop('disabled', true);
      $("#selMount1").prop('disabled', true);
      $("#txtYear1").prop('disabled', false);
      $("#txtMMday1").prop('disabled', true);
      $("#txtMMYear1").prop('disabled', false);
      $("#txtMMmon1").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');
  });

  $("#btNewOrder").click(function(){
    $("#allmt").hide(100);
    $("#allorder").show(300);
    $("#allinv").hide(100);
    $("#h6text").text("ตารางข้อมูลใบเสนอราคา");
    $("#exampleModalLabel").text("ข้อมูลใบเสนอราคา");
    $("#Btopenbill").show();
  });

  $("#btall").click(function(){
    $("#allorder").hide(100);
    $("#allmt").show(300);
    $("#allinv").hide(100);
    $("#h6text").text("ตารางข้อมูลรายการขาย");
    $("#exampleModalLabel").text("ข้อมูลบิลขาย");
    $("#Btopenbill").hide();
    
  });

  $("#btNewInv").click(function(){
    $("#allinv").show(300);
    $("#allorder").hide(100);
    $("#allmt").hide(100);
    $("#h6text").text("ตารางข้อมูลรายการขาย");
    $("#exampleModalLabel").text("ข้อมูลบิลขาย");
    $("#Btopenbill").hide();
    
  });
  
  $( document ).ready(function() {
    input = $("#countMt").val() - 1
        $("#vcountmt").text(numeral(input).format('0,0'));
    });

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

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