<?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
      }

      .padding {
    padding: 3rem !important
}
/* การ์ดลูกค้า */
    .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");

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="#">Customer</a></li>
    <li class="breadcrumb-item active" aria-current="page">ข้อมูลลูกค้า</li>
  </ol>
</nav>
<!-- <ul class="nav justify-content-center">
  <li class="nav-item">
    <a class="nav-link active" href="#">Active</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" href="#">Link</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" href="#">Link</a>
  </li>
  <li class="nav-item">
    <a class="nav-link disabled" href="#">Disabled</a>
  </li>
</ul> -->
<div class="row">
  
  <div class="col-sm-3 mb-12">
    <div class="card">
      <div class="card-body">
        <h5 class="card-title">Orders <span style="text-align: center; font-size:12px;"> (รายการสั่งซื้อ) ปี: 64</span></h5>
        <p class="m-0 font-weight-bold"  style="text-align: center; font-size:42px;color: #315675;"> <?php echo e(number_format($sumsale[0]->couorder), 2); ?></p>
      </div>
    </div>
  </div>
  <div class="col-sm-3 mb-12">
      <div class="card">
        <div class="card-body">
        <h5 class="card-title">ยอดขาย  <span style="text-align: center; font-size:12px;">/ บาท ปี: 64</span></h5>
          <p class="m-0 font-weight-bold "  style="text-align: center; font-size:42px;color: #166A54;"> <?php echo e(number_format($sumsale[0]->sumsale), 2); ?></p>
        </div>
      </div>
  </div>
  <div class="col-sm-3 mb-12">
    <div class="card">
      <div class="card-body">
      <h5 class="card-title">เก็บเงินปลายทาง <span style="text-align: center; font-size:12px;">/ บาท ปี: 64</span></h5>
        <p class="m-0 font-weight-bold "  style="text-align: center; font-size:42px;color: #7A3311;"><?php echo e(number_format($sumcod[0]->sumsalecod), 2); ?></p>
      </div>
    </div>
  </div>
  <div class="col-sm-3 mb-12">
  <div class="card" style="background-color:#315675; color: #FFF;">
      <div class="card-body">
        <h5 class="card-title">Customer <span style="text-align: center; font-size:12px;"> (ลูกค้าทั้งหมด)</span></h5> 
        <p class="m-0 font-weight-bold"  style="text-align: center; font-size:42px; color: #FFF;"><?php echo e(number_format($sumcus[0]->countcus), 2); ?></p>
      </div>
    </div>
  </div>
</div>
<div class="row">
    <div class="col-sm-2 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($ccusinw[0]->countcusinw), 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" style="">
            <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($ccusnoinw[0]->countcusall), 2); ?></p> 
            </div>
          </div>
      </div>
    </div>
    <div class="col-sm-3 mb-12">
      <div class="bd-callout bd-callout-success">
        <div class="row">
            <div class="col" style="">
            <p class="m-0 font-weight-bold text-dark" style="text-align: center; font-size: 16px;">Social Media</p>
            <p class="m-0 font-weight-bold text-success"  style="text-align: center; font-size: 18px;"><?php echo e(number_format($cccussoc[0]->sumsalesocial), 2); ?> บ. <a href="#" class="badge badge-primary"><?php echo e(number_format($cccussoc[0]->countcussocial), 2); ?> บิลขาย</a></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" style="">
            <p class="m-0 font-weight-bold text-dark" style="text-align: center; font-size: 16px;">E-Commerce</p>
            <p class="m-0 font-weight-bold text-success"  style="text-align: center; font-size: 18px;"><?php echo e(number_format($cccusecom[0]->sumsaleecom), 2); ?> บ. <a href="#" class="badge badge-success"><?php echo e(number_format($cccusecom[0]->countcusecom), 2); ?> บิลขาย</a></p> 
            </div>
          </div>
      </div>
    </div>
    <div class="col-sm-3 mb-12">
      <div class="bd-callout bd-callout-success">
        <div class="row">
            <div class="col" style="">
            <p class="m-0 font-weight-bold text-dark" style="text-align: center; font-size: 16px;">Platform อื่นๆ</p>
            <p class="m-0 font-weight-bold text-success"  style="text-align: center; font-size: 18px;"><?php echo e(number_format($cccusarter[0]->sumsaleorter), 2); ?> บ. <a href="#" class="badge badge-info"><?php echo e(number_format($cccusarter[0]->countcusorter), 2); ?>  บิลขาย</a></p> 
            </div>
          </div>
      </div>
    </div>
</div>


<!-- DataTales Example -->
<div class="card mb-4"  style="margin-top: 15px;">
  <div class="card-header py-3">
    <div class="row">
      <div class="col-12 mb-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;">  </span></p>
     </div>
  </div></div>

<div class="card-body" id="allmt" style="font-size: 12px;">
  <div class="table-responsive" > <!-- Button trigger modal -->
              <!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
                Launch demo modal
              </button>   -->
    <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: right; font-size: 12px;" >ยอดสั่งซื้อ/บาท</th>
          <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;" >Social</th>
          <th class="text-nowrap" scope="col" style="text-align: center; font-size: 12px;" > เบอร์โทร</th>
        </tr>
      </thead>
      <?php
      $i = 1;
      $SumTotalnet = 0;
      ?>
      <tbody>
       <?php $__currentLoopData = $cusallslae; $__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: center; 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">
                     
              
              
            </div>
          </div>          
         </td>

         <td class="text-nowrap" style="text-align: left;font-size:14px;"><a href="showcus/<?php echo e($x->idCus); ?>" target="_blank"><?php echo e($x->CusName); ?> <?php echo e($x->LastName); ?></a> </td>
         <td class="text-nowrap" style="font-size:14px;text-align: center;">
         <?php if($x->total <= 3000): ?> <span style="color:#984858 ; width: 150px;"> Member </span>
          <?php elseif($x->total <= 50000): ?> <span style="color:#14B4B2; width: 150px;"> Gold Member </span> 
           <?php elseif($x->total <= 500000): ?> <span style="color:#143DB4; width: 150px;"> VIP </span> 
           <?php else: ?><span style="color:#B921BE; width: 150px;"> VVIP </span> 
           <?php endif; ?> </td>
         <td class="text-nowrap" style="font-size:14px;text-align: right;"><?php echo e(number_format($x->total)); ?></td>
         <td class="text-nowrap" style="text-align: center;font-size:14px;"> <?php if(is_null($x->nameSocial)): ?> <p> ไม่ได้ระบุข้อมูล </p> <?php else: ?> <?php echo e($x->nameSocial); ?> <?php endif; ?></td>
         <td class="text-nowrap"style="text-align: center;font-size:14px;"><?php echo e($x->Mobile1); ?></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>

<!-- Modal ลูกค้า-->
<div class="modal fade" id="exampleModalCenter" 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"></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">
                                
                                    <input type="hidden" name="idcusmodal" id="idcusmodal"></input>
                              
                                <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="printpdf/$x->idCus" 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>


<?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 fndelbill(id){

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

  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"];
          $("#idcusmodal").empty();
          
          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){
          $('#idcusmodal').val(items2[x].idCus);
          $("#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');
          }
    });
    
    $("#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 /home/cp325668/public_html/except/resources/views/customer/showTbcus.blade.php ENDPATH**/ ?>