<?php $__env->startSection("content"); ?>
<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-lg-12 mb-12">
    <div class="row">
      <form action="<?php echo url('savesaledataold'); ?>" method="post" id="form1" class="col-lg-12 mb-12">
        <?php echo csrf_field(); ?>
        <!-- เพิ่มสินค้าใหม่ -->
        <div class="card shadow mb-4">
         <div class="card-header py-3">
          <h6 class="m-0 font-weight-bold text-primary">ข้อมูล</h6>
        </div>
        <div class="card-body">
          <div class="form-row">
            <div class="form-group col-md-7" style="border-right: 1px #bec5cb solid;">

             <div class="form-row">
              <div class="col-md-6 form-group">
                <label><p class="font-weight-bold" for="inputProvince" style="text-align: left; color: #00897B; ">ชื่อลูกค้า</p>
                </label>
                <div class="row gutters-xs">
                  <div class="col">
                    <input type="hidden" class="form-control col-md-7" id="idpsuser" name="idpsuser">
                    <input type="text" name="username" id="username" class="form-control" placeholder="ขื่อลูกค้า" readonly>
                  </div>
                  <span class="col-auto">
                    <button class="btn btn-secondary" id="userfide" type="button"  data-toggle="modal" data-target="#personModal"><i class="fas fa-user-plus"></i></button>
                  </span>
                </div>
              </div>

            </div>

            <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 class="col-lg-6 mb-6" style="text-align: right;"><button type="button" class="btn btn-info btn-sm" onClick="show()" ><i class="fas fa-plus-circle"></i> เพิ่มสินค้า</button></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="trpdlot">

                  </tbody>
                </table>
              </div>
            </div>
            <!--Start โปรโมชั่น-->
            <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: #9E9D24; ">ตารางโปรโมชั่น</p></div>
                <div class="col-lg-6 mb-6" style="text-align: right;"><button type="button" class="btn btn-warning btn-sm" ><i class="fas fa-plus-circle"></i> เพิ่มโปรโมชั่น</button></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;">รายการโปรโมชั่น</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>
                        <tr>
                          <th scope="row" style="text-align: center;">1</th>
                          <td style="text-align: left; color: #00897B;">ลดจากราคาขาย</td>
                          <!-- <td  style="text-align: right;"><input style="text-align: right; width:140px;" type="number" class="form-control" maxlength="9"  name="amoun" id="amoun" value="6"></td>
                          <td style="text-align: right;">590</td>
                          <td style="text-align: right;">590</td>
                          <td style="text-align: right; color: #1E88E5;" class="font-weight-bold">3,540</td> -->
                          <td style="text-align: center; color: #C2185B;">ลบ</td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
                <!--end โปรโมชั่น -->
                <div class="col-lg-12 mb-12">
                  <div class="row">
                   <div class="col-lg-12 mb-12">
                    <div class="row">
                     <div class="col-lg-12 mb-12"> <p class="font-weight-bold" for="inputProvince" style="text-align: left; color: #C51162; ">โปรโมชั่นที่ใช้</p></div>
                     <!-- <div class="col-lg-4 mb-4">
                      <table class="table" style="border: 1px solid #ddd;">
                        <tbody>
                          <tr>
                            <th style="width: 80%; color: #00897B;text-align: right;">
                              <input type="text" class="form-control font-weight-bold " name="inputProMo" id="inputProMo" style="font-size: 20px; text-align: center; color: #B71C1C;" value="">
                            </th>
                            <td > 
                              <button type="button" id="btSPro" class="btn btn-danger">ค้นหา</button>
                            </td>
                          </tr>

                        </tbody>
                      </table>
                    </div> -->
                   <div class="col-lg-8 mb-8" id="carddic">
           
                  </div>
                </div>
              </div>
              <div class="col-lg-6 mb-6"></div>
              <div class="col-lg-6 mb-6" style="text-align: right;"> <div class="table-responsive" style="margin-top: 10px;">
                <table class="table" style="border: 1px solid #ddd; line-height: 0.5;">
                  <tbody>
                    <tr>
                      <th style="width: 40%; color: #00897B;text-align: right; padding-top: 25px">ยอดขาย[฿] :</th>
                      <td ><input type="text" class="form-control" name="price_total" id="price_total" style="font-size: 14px; text-align: right;" min="0.01" step="0.01" readonly="" value="0"></td>
                    </tr>
                    <tr>
                      <th style="width: 40%; color: #00897B;padding-top: 25px">ส่วนลด[฿] :</th>
                      <td ><input type="text" class="form-control" name="price_dis" id="price_dis" style="font-size: 14px; text-align: right;" min="0.01" step="0.01" readonly="" value="0"></td>
                    </tr>
                    <tr>
                      <th style="width: 40%; color: #00897B;padding-top: 27px">รวมเป็นเงินสุทธิ[฿] :</th>
                      <td><input type="text" class="form-control font-weight-bold " name="price_totalNet" id="price_totalNet" style="font-size: 18px; text-align: right; color: #00796B;" min="0.01" step="0.01" readonly="" value="0">
                        <input type="hidden" name="price_totalT" id="price_totalT" >
                        <input type="hidden" name="price_totalNetT" id="price_totalNetT">
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="form-group col-md-5">
        <p class="font-weight-bold" for="inputProvince" style="text-align: left; color: #00897B; ">ข้อมูลขนส่ง</p>
        <div class="form-group col-md-12">

          <div class="form-row">
           <div class="form-group col-md-4">
            <label for="inputPay">การชำระเงิน</label>
            <span class="form-required" style="color: #CC0000">*</span>
            <select id="inputPay" name="inputPay" class="form-control">
              <?php $__currentLoopData = $dpay; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
              <option value="<?php echo e($x->idPay); ?>"><?php echo e($x->NamePay); ?></option>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
          </div>
          <div class="form-group col-md-4">
            <label>รับจากระบบ</label>
            <span class="form-required" style="color: #CC0000">*</span>
            <select id="inputSocial" name="inputSocial" class="form-control selectpicker">
              <?php $__currentLoopData = $dsocial; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
              <option data-thumbnail="<?php echo e($x->partImg); ?>" 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 col-md-4">
            <label for="inputIden">ชื่อบัญชีsocial</label>
            <input type="text" class="form-control" name="inputnamesocial" id="inputnamesocial">
          </div>
        </div>
        <div class="form-group">
          <label for="vAdd">ที่อยู่จัดส่ง</label>
          <input type="hidden" class="form-control" name="idAdd" id="idAdd" placeholder="">
          <textarea type="text" class="form-control" name="vAdd" id="vAdd" readonly=""></textarea>
        </div>

      </div>
    </div>
  </div>
  <div style="text-align: right;">
   <button type="button" id="btSm" class="btn btn-primary">บันทึกการสั่งซื้อ</button>
 </div>       
</div>
</div>


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

<!-- Modal -->
<div class="modal fade" id="ShowPdModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-xl" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <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="input-group no-border col-4 mt-2 ml-auto pr-1">
          <input type="text" value="" class="form-control"  id="myInput"  onkeyup="PdSearch()" placeholder="Search...">
          <div class="input-group-append">
            <div class="input-group-text">
              <i class="now-ui-icons ui-1_zoom-bold"></i>
            </div>
          </div>
        </div>
        <div class="table-responsive" >
          <table class="table table-sm" id="PdTable" width="100%" cellspacing="0">
            <thead>
              <tr >
                <th scope="col" style="text-align: left;">ชื่อสินค้า</th>
                <th scope="col" style="text-align: right;">ประเภทสินค้า</th>
                <th scope="col" style="text-align: right;">ราคาต้นทุน</th>
                <th scope="col" style="text-align: right;">ราคาขาย</th>
                <th scope="col" style="text-align: right;">น้ำหนัก</th>
                <th scope="col" style="text-align: center;">หน่วย นน.</th>
                <th scope="col" style="text-align: right;">จำนวนคงเหลือ</th>
                <th scope="col" style="text-align: center;">หน่วยบรรจุ</th>
              </tr>
            </thead>
            <?php
            $i = 1;
            ?>
            <tbody id="ListPdDetail">
             <?php $__currentLoopData = $showpd; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
             <tr data-toggle="collapse" data-target="#t<?php echo e($x->idPd); ?>" aria-expanded="false" aria-controls="t<?php echo e($x->idPd); ?>" onclick="deTailTranGB('<?php echo e($x->idPd); ?>','dtTran<?php echo e($x->idPd); ?>','dtsTran<?php echo e($x->idPd); ?>')">
              <td class="text-nowrap"><i class="fas fa-plus-circle" style="color: #009688"></i>  <?php echo e($x->PdName); ?></td>
              <td class="text-nowrap" style="text-align: right;"><?php echo e($x->pdTypeName); ?></td>
              <td class="text-nowrap" style="text-align: right;"><?php echo e($x->PriceCost); ?></td>
              <td class="text-nowrap" style="text-align: right;"><?php echo e($x->Price); ?></td>
              <td class="text-nowrap"style="text-align: right;"><?php echo e($x->Weight); ?></td>
              <td class="text-nowrap"style="text-align: center;"><?php echo e($x->nameWeight); ?></td>
              <td class="text-nowrap"style="text-align: right; color: #00796B; font-weight: bold;"><?php echo e(number_format($x->SumAmount),2); ?></td>
              <td class="text-nowrap"style="text-align: center;"><?php echo e($x->UnitName); ?></td>
              <td class="text-nowrap" style="text-align: center;">
                <!-- <a href="#" class="btn btn-primary btn-circle btn-sm"  data-toggle="collapse" data-target="#t<?php echo e($x->idPd); ?>" aria-expanded="false" aria-controls="t<?php echo e($x->idPd); ?>" onclick="deTailTranGB('<?php echo e($x->idPd); ?>','dtTran<?php echo e($x->idPd); ?>','dtsTran<?php echo e($x->idPd); ?>')">
                  <i class="fas fa-search"></i>
                </a> -->
        <!--     <a href="#" class="btn btn-danger btn-circle btn-sm" onClick="del(<?php echo e($x->idPd); ?>)">
              <i class="fas fa-trash"></i>
            </a>     -->           
          </td>
        </tr>
        <tr class="tranGB">
          <td colspan="10" class="text-nowrap" style="padding: 0px; width: 100%; margin-left: 10px">  
           <div  class="collapse" id="t<?php echo e($x->idPd); ?>" style="margin-left: 20px;">        
            <table class="table table-sm" style="margin-bottom: 5px;">
              <thead>
                <tr>
                  <td style="width: 5px;">[ลำดับ]</td>
                  <td style="width: 50px;text-align: left;">[เลือก]</td>
                  <td style="width: 50px;text-align: left;">[Lot no.]</td>
                  <td style="width: 10px;text-align: left;">[วันที่ผลิต]</td>
                  <td style="width: 50px;text-align: right;">[จำนวนที่ใช้ได้]</td>
                  <td style="width: 50px;text-align: right;">[จำนวนโดนจอง]</td>                  
                  <td style="width: 50px;text-align: right;">[จำนวนคงคลัง]</td>
                  <td style="width: 200px;text-align: center;">[คำอธิบายรายการ]</td>              
                </tr>
              </thead>
              <tbody class="dtTran<?php echo e($x->idPd); ?>">

              </tbody>
            </table>
          </td>
        </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
      </tbody>
    </table>
  </div>

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

<!-- Modal -->
<div class="modal fade" id="personModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">ลูกค้า</h5>
        <button type="button" data-dismiss="modal">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="input-group no-border col-8 mt-2 ml-auto pr-1">
          <input type="text" value="" class="form-control"  id="myInputNewper"  onkeyup="allSearch()" placeholder="Search...">
          <div class="input-group-append">
            <div class="input-group-text">
              <i class="dropdown-icon fe fe-search"></i>
            </div>
          </div>
        </div>
        <table class="table card-table table-sm">
          <thead>
            <tr>
              <th style="text-align: center; width: 30px;">ลำดับ</th>
              <th>ชื่อ-สกุล</th>
              <th style="text-align: center; width: 100px;">ตัวเลือก</th>
            </tr>
          </thead>
          <tbody id="persontd">

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

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


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

  $(function(){


  })

  $('#btSm').click(function(){
    row = $("#trpdlot tr").length;
    if(row == 0){
      swal({
        title: "ไม่สามารถบันทึกได้ !!!",
        text: "คุณยังไม่ได้เพิ่มสินค้า",
        icon: "info",
        button: "ตกลง",
      });

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

      return false;
    }else if(($("#inputDistrict").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",
        });
        $("#form1").submit();
      } else {
        swal("ยกเลิกการบันทึก");
      }
    });

   }
 })
  function readd() {
    $("#vAdd").val($("#inputAdd").val()+" ตำบล"+ $("#inputDistrict option:selected").text() +"อำเภอ"+ $("#inputAmphur option:selected").text() +"จังหวัด"+ $("#inputProvince option:selected").text() +""+ $("#inputposcode").val());
  }

  function show(){

    $('#ShowPdModal').modal('show');
  }

  function deTailTranGB(id,e,s){

    $.ajax({
      url:'<?php echo e(url("finepdstock")); ?>/'+id,
      type:'GET',
      dataType:'json',
      cache:false,
      success:function(ret){
        console.log(ret);

        var showpd = ret["showpdStock"];

        $("."+e).empty();
        $("."+s).empty();
        var i= 1;
        var amonuse = 0;
        for(x in showpd){
         amonuse = showpd[x]["Amount"] - showpd[x]["AmountUse"];
         strGB ='<tr style="background: #E0F2F1">'
         +'<td style="width: 3px;">->['+i+']</td>'
         +'<td style="width: 5px;text-align: left;"><a href="#" class="btn btn-success btn-circle btn-sm" onClick="addpd2chart('+showpd[x].idPdLot+',\''+showpd[x].LotNum+'\',\''+showpd[x].PdName+'\',\''+showpd[x].Price+'\',\''+showpd[x].idPd+'\')"><i class="fas fa-cart-arrow-down"></i></a></td>'
         +'<td style="width: 150px;text-align: left;">'+showpd[x]["LotNum"]+'</td>'
         +'<td style="width: 50px;text-align: left;">'+showpd[x]["datePdCer"]+'</td>'
         +'<td style="width: 50px;text-align: right; color: #00796B; font-weight: bold;">'+amonuse+'</td>'
         +'<td style="width: 50px;text-align: right; color: #E65100; font-weight: bold;">'+showpd[x]["AmountUse"]+'</td>'
         +'<td style="width: 50px;text-align: right; color: #6D4C41; font-weight: bold;">'+showpd[x]["Amount"]+'</td>'
         +'<td style="width: 200px;text-align: center;">'+showpd[x]["Note"]+'</td>'

         +'</tr>';
         $("."+e).append(strGB);
         i++;
       }

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

  function PdSearch() {
    var input, filter, tbody, tr, a, i;
    input = document.getElementById("myInput");
    filter = input.value.toUpperCase();
    tbody = document.getElementById("ListPdDetail");
    tr = tbody.getElementsByTagName("tr");
    for (i = 0; i < tr.length; i++) {
      a = tr[i].getElementsByTagName("td")[0];
      if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";

      }
    }
  }
  var rcount = 1;
  function addpd2chart(idlot,numlot,namepd,price,idPd){


    $("#trpdlot").append(''
      +'<tr>'
      +'<td scope="row" style="text-align: center;"><input type="hidden" name="idlotT[]" value="'+idlot+'"><input type="hidden" name="idPd[]" value="'+idPd+'">'
      +rcount
      +'. '
      +'</td>'
      +'<td style="text-align: left;"><input type="hidden" name="numlotT[]" value="'+numlot+'">'
      +numlot
      +'</td>'
      +'<td style="text-align: left; color: #00897B;"><input type="hidden" name="namepdT[]" value="\''+namepd+'\'">'
      +namepd
      +'</td>'
      +'<td style="text-align: right;"><input type="hidden" name="priceT[]" value="\''+price+'\'">'
      +price
      +'</td>'
      +'<td class="text-nowrap"style="text-align: right;"><input style="text-align: right; width:100px;" type="number" class="form-control form-control-sm" maxlength="9"  name="amoun[]" id="amoun" onkeyup="SumPrice(this)" value="0"></td>'
      +'<td style="text-align: right;"><input style="text-align: right; width:100px;" type="number" onkeyup="SumPrice(this)" class="form-control form-control-sm" maxlength="9"  name="inputpice[]" id="inputpice" value="'+price+'"></td>'
      +'<td class="font-weight-bold"><input class="form-control form-control-sm font-weight-bold price_mtr" type="text" name="num_mtr[]" style="text-align: right; color: #1E88E5;"  value="0" readonly=""></td>'
      +'<td style="text-align: center; color: #C2185B;">'
      +'<a onclick="deleteRow(this)"><font color="#D50000"> ลบ</font></a> <input type="hidden" name="num_mtrT[]">'
      +'</td>'
      +'</tr>'
      );

    rcount++;
    $("#ShowPdModal").modal('toggle');
  }

  function SumPrice(e){

   var tr = $(e).parent().parent();

   price_unit_mtr = tr.find('input[name="amoun[]"]').val();
   price_mtr = tr.find('input[name="inputpice[]"]').val();
   totalrow = numeral(price_mtr).value() * numeral(price_unit_mtr).value();
   tr.find('input[name="num_mtr[]"]').val(numeral(totalrow).format('0,0'));
   tr.find('input[name="num_mtrT[]"]').val(totalrow);
   totalPrice();
   totalNet();
 }

 function totalPrice(){
  var total = 0;
  $(".price_mtr").each(function( index ) {
    total += numeral($(this).val()).value();
  });
  $('#price_total').val(numeral(total).format('0,0'));
  $('#price_totalT').val(total);
}

function totalNet(){
  var totalNet = 0;
  totalNet = numeral($("#price_total").val()).value() - numeral($("#price_dis").val()).value();
  $('#price_totalNet').val(numeral(totalNet).format('0,0'));
  $('#price_totalNetT').val(totalNet);
}

function deleteRow(e){
  tag = $(e).parent().parent();
  /*  del_dnameCarplate = tag.find(".dnameCarplate").text();*/
  tag.remove();
}

$(function(){
  $("#userfide").click(function(){
    $.ajax({
      url:'<?php echo e(url("user")); ?>',
      /* data:{CompName:$("#findcompname").val()},*/
      type:'GET',
      dataType:'json',
      cache:false,
      success:function(ret){
        items = ret;
        $("#persontd").empty();
        var rows = 1;
        for(x in items){
                //str = '<tr><td >'+ rows +'</td><td style="text-align:left">'+items[x].CompName+'</td><td ><button type="button" class="btn btn-default" onclick="getCus('+x+')">เลือก</button> </td></tr> ';
                str = '<tr><td >'+ rows +'</td><td style="text-align:left padding: 0px;"><a>'+items[x].CusName+''+items[x].LastName+'</a></td><td style="padding: 0px; text-align: center;"><a class="btn btn-primary btn-sm" style="color:#FFF" onclick="getGetUser('+ret[x].idCus+',\''+ret[x].CusName+'\')">เลือก</a> </td></tr> ';
                $("#persontd").append(str);
                rows++;
              }
            },
            error:function(err){
              alert('Error');
              //console.log(err.responseText);
            }
          });
  });

});

function getGetUser(ids,sname){
  $("#username").val(sname);
  $("#idpsuser").val(ids);
  $("#personModal").modal('toggle');

  $.ajax({
    url:'<?php echo e(url("address")); ?>',
    data:{idcus:ids},
    type:'GET',
    dataType:'json',
    cache:false,
    success:function(ret){

     $("#vAdd").empty()
     sc = ret["ad"];
     $("#vAdd").val(sc[0].AddressText);
     $("#idAdd").val(sc[0].idAdd);

   },
   error:function(err){
    alert('Error');
  }
});
}

function addpromo(idpro,name,typepro,codepro,dic,detailpro,date){
 $('#price_dis').val(dic);

 totalNet();
 $('#carddic').html('<div class="card"><div class="card-header" style="background: #EC407A; color: #FFF">โปรโมชั่นสำหรับโค้ดนี้ ['+codepro+'] <button type="button" class="close"  onclick="deletePro()"><span aria-hidden="true">&times;</span></div><div class="card-body"><input type="hidden" name="idPro" value="'+idpro+'"><h5 class="card-title font-weight-bold" style="color: #880E4F"> ->>โปรโมชั่น '+name+'</h5><p class="card-text">หมายเหตุ : '+detailpro+'</p></div></div>');
 $("#ShowPMModal").modal('toggle');

}
function deletePro(){
  $( "#carddic" ).empty();
}

</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\natureplus\resources\views/sale/oldsale.blade.php ENDPATH**/ ?>