Advertisement
pushbear

create.blade.php

Nov 18th, 2018
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 19.67 KB | None | 0 0
  1. <div class="container-fluid pt-2 pb-2 pl-4 pr-4">
  2.     @if ($errors->any())
  3.           <div class="alert alert-danger">
  4.               <ul>
  5.                   <li>Please complete the required fields below!</li>
  6.               </ul>
  7.           </div>
  8.       @endif    
  9.  
  10.       {!!Form::open(array('route'=>'insert','id'=>'frmsave','method'=>'post'))!!}
  11.         @csrf
  12.       <div class="row">
  13.         <div class="col-md-4 order-md-2 mb-4">
  14.           <h4 class="d-flex justify-content-between align-items-center mb-3">
  15.             <span class="text-muted">Order Total</span>
  16.           </h4>
  17.           <ul class="list-group mb-3">
  18.              <!-- Discount Total
  19.            <li class="list-group-item d-flex justify-content-between">
  20.              <label for="orderTotal">Discount</label>
  21.              <span>
  22.              <div class="input-group col-9 float-right nopadding">
  23.                  <div class="input-group-prepend">
  24.                    <span class="input-group-text"><b>RM</b></span>
  25.                  </div>
  26.                   <input type="text" class="form-control" id="dicountTotal" name="discountTotal" value="" readonly="readonly" jAutoCalc="SUM({orderDis[]})">
  27.                </div>
  28.              </span>
  29.            </li>
  30.          -->
  31.             <li class="list-group-item d-flex justify-content-between">
  32.               <label for="orderTotal">Total</label>
  33.               <span>
  34.               <div class="input-group col-9 float-right nopadding">
  35.                   <div class="input-group-prepend">
  36.                     <span class="input-group-text"><b>RM</b></span>
  37.                   </div>
  38.                    <input type="text" class="form-control" id="orderTotal" name="orderTotal" value="" readonly="readonly" jAutoCalc="SUM({orderPerAmount[]})">
  39.                 </div>
  40.               </span>
  41.             </li>
  42.           </ul>
  43.  
  44.             <hr class="mb-4">
  45.             {!!Form::submit('Save',array('class'=>'btn btn-success btn-lg btn-block','id'=>'btnsave'))!!}
  46.         </div>
  47.  
  48.         <div class="col-md-8 order-md-1">
  49.           <h4 class="mb-3">New Order</h4>
  50.  
  51.           <div class="row">
  52.               <div class="col-md-12 mb-12">
  53.                 <label for="orderId">Order No.</label>
  54.                 <input type="text" class="form-control is-valid" id="orderId" name="orderId" value="<?php use App\Http\Controllers\Order\OrderController;
  55. echo OrderController::generateOrderNR(); ?>" readonly="readonly">
  56.               </div>
  57.             </div>
  58.  
  59.             <div class="row">
  60.               <div class="col-md-12 mb-12 mt-2">
  61.                 <label for="customerId">Customer</label>
  62.                 <select class="custom-select" name="customerId" id="customerId">
  63.                   <option></option>
  64.                   @foreach($customers as $customer)
  65.                   <option value="{{$customer['customerId']}}" {{(old('customerId')==$customer->customerId)? 'selected':''}}>{{$customer['customerName']}}</option>
  66.                   @endforeach
  67.                 </select>
  68.                 @if ($errors->has('customerId'))
  69.                    <div class="text-danger">
  70.                     <small>{{ $errors->first('customerId') }}</small>
  71.                   </div>
  72.                @endif
  73.               </div>
  74.             </div>
  75.  
  76.             <div class="row">
  77.               <div class="col-md-12 mb-12 mt-2">
  78.                 <label for="orderStatusId">Status</label>
  79.                 <select  class="custom-select" name="orderStatusId" id="orderStatusId">
  80.                   <option></option>
  81.                   @foreach($order_statuses as $order_status)
  82.                   <option value="{{$order_status['orderStatusId']}}" {{(old('orderStatusId')==$order_status->orderStatusId)? 'selected':''}}>{{$order_status['orderStatusName']}}</option>
  83.                   @endforeach
  84.                 </select>
  85.                 @if ($errors->has('orderStatusId'))
  86.                    <div class="text-danger">
  87.                     <small>{{ $errors->first('orderStatusId') }}</small>
  88.                   </div>
  89.                @endif
  90.               </div>
  91.             </div>
  92.  
  93.             <!-- This will show up when status order changed to "Paid" -->
  94.             <div class="row">
  95.               <div class="col-md-12 mb-12 mt-2">
  96.                 <label for="paymentMethodId">Payment Method</label>
  97.                 <select  class="custom-select" name="paymentMethodId" id="paymentMethodId">
  98.                   <option></option>
  99.                   @foreach($payment_methods as $payment_method)
  100.                   <option value="{{$payment_method['paymentMethodId']}}" {{(old('paymentMethodId')==$payment_method->paymentMethodId)? 'selected':''}}>{{$payment_method['paymentMethodName']}}</option>
  101.                   @endforeach
  102.                 </select>
  103.                 @if ($errors->has('paymentMethodId'))
  104.                    <div class="text-danger">
  105.                     <small>{{ $errors->first('paymentMethodId') }}</small>
  106.                   </div>
  107.                @endif
  108.               </div>
  109.             </div>
  110.  
  111.             <div class="row">
  112.               <div class="col-md-12 mb-3 mt-2">
  113.                     <label for="tbl-products">Product</label>
  114.  
  115.                     <div id="newRow">
  116.  
  117.             @if(Form::old('productSku'))
  118.                 @foreach(old('productSku') as $key => $val)
  119.                     <table id="tbl-products" name="line_items" class="table table-bordered tbl-products">
  120.                     <thead>
  121.                       <th colspan="5" class="rowCount"></th>
  122.                       <th>Available Stock</th>
  123.                     </thead>
  124.                     <tbody>
  125.                         <td colspan="5">
  126.                           <select  id="productSku" name="productSku[]" class="productSku custom-select">
  127.                             <option></option>
  128.                             @foreach($products as $product)
  129.                             <option value="{{$product['productSku']}}" {{(old('productSku.'.$key)==$product->productSku)? 'selected':''}}>{{$product['productName']}}</option>
  130.                             @endforeach
  131.                             </select>
  132.                             @if ($errors->has('productSku.'.$key))
  133.                                <div class="text-danger">
  134.                                 <small>{{ $errors->first('productSku.'.$key) }}</small>
  135.                               </div>
  136.                            @endif
  137.                         </td>
  138.                         <td>
  139.                           <input disabled id="productQty" type="text" class="form-control" name="productQty[]" value="" readonly="readonly">
  140.                         </td>
  141.                         <td align="center">
  142.                           <a href="#" class="btn btn-danger remove" id="remove"><em class="fa fa-trash"></em></a>
  143.                       </td>
  144.                       </tbody>
  145.                     <thead>
  146.                       <th>Quantity</th>
  147.                       <th colspan="2">UOM</th>
  148.                       <th>Price (per)</th>
  149.                       <th>Discount (%)</th>
  150.                       <th>Amount</th>
  151.                     </thead>
  152.                     <tbody>
  153.                       <td>
  154.                           <input type="text" class="form-control" id="orderQty" name="orderQty[]" value="{{ old('orderQty.'.$key) }}">
  155.                            @if ($errors->has('orderQty.'.$key))
  156.                                <div class="text-danger">
  157.                                 <small>{{ $errors->first('orderQty.'.$key) }}</small>
  158.                               </div>
  159.                            @endif
  160.                         </td>
  161.                         <td colspan="2">
  162.                           <select  class="custom-select" name="uomId" id="uomId" name="uomId[]">
  163.                             <option></option>
  164.                             <option value="1" {{(old('uomId.'.$key))? 'selected':''}}>Test</option>
  165.                           </select>
  166.                           @if ($errors->has('uomId.'.$key))
  167.                                <div class="text-danger">
  168.                                 <small>{{ $errors->first('uomId.'.$key) }}</small>
  169.                               </div>
  170.                            @endif
  171.                         </td>
  172.                         <td>
  173.                           <input  type="text" class="form-control" id="orderPrice" name="orderPrice[]" value="{{ old('orderPrice.'.$key) }}">
  174.                            @if ($errors->has('orderPrice.'.$key))
  175.                                <div class="text-danger">
  176.                                 <small>{{ $errors->first('orderPrice.'.$key) }}</small>
  177.                               </div>
  178.                            @endif
  179.                         </td>
  180.                         <td>
  181.                           <input type="text" class="form-control" id="orderDis" name="orderDis[]" placeholder="0.00" value="{{ old('orderDis.'.$key) }}">
  182.                            @if ($errors->has('orderDis.'.$key))
  183.                                <div class="text-danger">
  184.                                 <small>{{ $errors->first('orderDis.'.$key) }}</small>
  185.                               </div>
  186.                            @endif
  187.                         </td>
  188.                         <td>
  189.                           <input type="text" class="form-control" id="orderPerAmount" name="orderPerAmount[]" readonly="readonly" jAutoCalc="{#orderQty} * {#orderPrice} - {#orderQty} * {#orderPrice} * {#orderDis} / 100">
  190.                         </td>
  191.                     </tbody>
  192.                   </table>
  193.                 @endforeach
  194.                 @else
  195.                     <table id="tbl-products" name="line_items" class="table table-bordered tbl-products">
  196.                     <thead>
  197.                       <th colspan="5" class="rowCount"></th>
  198.                       <th>Available Stock</th>
  199.                     </thead>
  200.                     <tbody>
  201.                         <td colspan="5">
  202.                           <select  id="productSku" name="productSku[]" class="productSku custom-select">
  203.                             <option></option>
  204.                             @foreach($products as $product)
  205.                             <option value="{{$product['productSku']}}">{{$product['productName']}}</option>
  206.                             @endforeach
  207.                             </select>
  208.                             @if ($errors->has('productSku.0'))
  209.                                <div class="text-danger">
  210.                                 <small>{{ $errors->first('productSku.0') }}</small>
  211.                               </div>
  212.                            @endif
  213.                         </td>
  214.                         <td>
  215.                           <input  disabled id="productQty" type="text" class="form-control" name="productQty[]" value="" readonly="readonly">
  216.                         </td>
  217.                         <td align="center">
  218.                           <a href="#" class="btn btn-danger remove" id="remove"><em class="fa fa-trash"></em></a>
  219.                       </td>
  220.                       </tbody>
  221.                     <thead>
  222.                       <th>Quantity</th>
  223.                       <th colspan="2">UOM</th>
  224.                       <th>Price (per)</th>
  225.                       <th>Discount (%)</th>
  226.                       <th>Amount</th>
  227.                     </thead>
  228.                     <tbody>
  229.                       <td>
  230.                           <input  type="text" class="form-control" id="orderQty" name="orderQty[]">
  231.                            @if ($errors->has('orderQty.0'))
  232.                                <div class="text-danger">
  233.                                 <small>{{ $errors->first('orderQty.0') }}</small>
  234.                               </div>
  235.                            @endif
  236.                         </td>
  237.                         <td colspan="2">
  238.                           <select  class="custom-select" name="uomId" id="uomId" name="uomId[]">
  239.                             <option></option>
  240.                             <option value="1">Test</option>
  241.                           </select>
  242.                         </td>
  243.                         <td>
  244.                           <input  type="text" class="form-control" id="orderPrice" name="orderPrice[]">
  245.                            @if ($errors->has('orderPrice.0'))
  246.                                <div class="text-danger">
  247.                                 <small>{{ $errors->first('orderPrice.0') }}</small>
  248.                               </div>
  249.                            @endif
  250.                         </td>
  251.                         <td>
  252.                           <input type="text" class="form-control" id="orderDis" name="orderDis[]" placeholder="0.00" value="0.00">
  253.                         </td>
  254.                         <td>
  255.                           <input type="text" class="form-control" id="orderPerAmount" name="orderPerAmount[]" readonly="readonly" jAutoCalc="{#orderQty} * {#orderPrice} - {#orderQty} * {#orderPrice} * {#orderDis} / 100">
  256.                         </td>
  257.                     </tbody>
  258.                   </table>
  259.                 @endif
  260.                 </div>
  261.                   <a href="#" class="btn btn-success addRow" id="addRow"><em class="fa fa-plus"></em> Add New Product</a>
  262.               </div>
  263.             </div>
  264.             </div>
  265.           {!!Form::hidden('_token',csrf_token())!!}
  266.         {!!Form::close()!!}
  267.         </div>
  268.       </div>
  269.  
  270.  
  271. <script>
  272.   $(document).ready(function() {
  273.  
  274.     function chosenJs() { // Interactive dropdown select run here...
  275.     $('select').chosen({
  276.         allow_single_deselect: true
  277.       });
  278.     }
  279.     chosenJs(); // Init the function
  280.  
  281.     function autoCalcSetup() { // Calculation code run here...
  282.         $('form[id=frmsave]').jAutoCalc('destroy');
  283.          $('form[id=frmsave] table[name=line_items]').jAutoCalc({
  284.             keyEventsFire: true,
  285.             decimalPlaces: 2,
  286.             emptyAsZero: true
  287.           });
  288.             $('form[id=frmsave]').jAutoCalc({
  289.                 decimalPlaces: 2,
  290.                 emptyAsZero: true
  291.               });
  292.             $('form[id=frmsave]').jAutoCalc({
  293.                 decimalPlaces: 2,
  294.                 emptyAsZero: true
  295.               });
  296.          }
  297.     autoCalcSetup(); // Init the function
  298.  
  299.     function calculateOrderRows() { // Row order calculation code run here...
  300.     $(".rowCount").each(function (i){
  301.           var index = i + 1;
  302.            $(this).text("Product - " + index++);
  303.         });
  304.     }
  305.     calculateOrderRows(); // Init the function
  306.  
  307.     $('#newRow #productSku').each(function(){ // This function generates value from preselected data in select dropdown
  308.         var tr = $(this).parent().parent().parent();
  309.         var id = tr.find('#productSku').val();
  310.         var dataId = {'id':id};
  311.         $.ajax({
  312.           type : 'GET',
  313.           url : '{{ url("find_qty") }}',
  314.           dataType : 'json',
  315.           data : dataId,
  316.           success:function(data){
  317.             console.log(data);
  318.             tr.find('#productQty').val(data.productQty);
  319.           }
  320.         });
  321.       });
  322.  
  323.     $('#newRow').delegate('#productSku','change',function(){ // This function generates value from selected data in select dropdown
  324.         var tr = $(this).parent().parent().parent();
  325.         var id = tr.find('#productSku').val();
  326.         var dataId = {'id':id};
  327.         $.ajax({
  328.           type : 'GET',
  329.           url : '{{ url("find_qty") }}',
  330.           dataType : 'json',
  331.           data : dataId,
  332.           success:function(data){
  333.             console.log(data);
  334.             tr.find('#productQty').val(data.productQty);
  335.           }
  336.         });
  337.       });
  338.  
  339.       $('#newRow').on('click','.remove',function(){ // Function for remove button
  340.         var i=$('#newRow table').length;
  341.         if(i==1)
  342.         {
  343.           alert('You cannot remove the last one!');
  344.         } else {
  345.         $(this).closest('#newRow table').remove();
  346.         autoCalcSetup(); // Init calculation code on looping field
  347.         calculateOrderRows(); // Init row order calculation on looping field      
  348.       }
  349.       });
  350.  
  351.       $('.addRow').on('click',function() // Add Row function on products input
  352.       {
  353.       var tr = '<table id="tbl-products" name="line_items" class="table table-bordered tbl-products">'+
  354.                     '<thead>'+
  355.                       '<th colspan="5" class="rowCount"></th>'+
  356.                       '<th>Available Stock</th>'+
  357.                     '</thead>'+
  358.                     '<tbody>'+
  359.                         '<td colspan="5">'+
  360.                           '<select  id="productSku" name="productSku[]" class="custom-select">'+
  361.                             '<option></option>'+
  362.                             '@foreach($products as $product)'+
  363.                             '<option value="{{$product['productSku']}}">{{$product['productName']}}</option>'+
  364.                             '@endforeach'+
  365.                             '</select>'+
  366.                         '</td>'+
  367.                         '<td>'+
  368.                           '<input disabled id="productQty" type="text" class="form-control" name="productQty[]" value="" readonly="readonly">'+
  369.                         '</td>'+
  370.                         '<td align="center">'+
  371.                           '<a href="#" class="btn btn-danger remove" id="remove"><em class="fa fa-trash"></em></a>'+
  372.                       '</td>'+
  373.                       '</tbody>'+
  374.                     '<thead>'+
  375.                       '<th>Quantity</th>'+
  376.                       '<th colspan="2">UOM</th>'+
  377.                       '<th>Price (per)</th>'+
  378.                       '<th>Discount (%)</th>'+
  379.                       '<th>Amount</th>'+
  380.                     '</thead>'+
  381.                     '<tbody>'+
  382.                       '<td>'+
  383.                           '<input  type="text" class="form-control" id="orderQty" name="orderQty[]">'+
  384.                            '@if ($errors->has('orderQty'))'+
  385.                               '<p class="error">{{ $errors->first('orderQty') }}</p>'+
  386.                           '@endif'+
  387.                         '</td>'+
  388.                         '<td colspan="2">'+
  389.                           '<select  class="custom-select" name="uomId" id="uomId">'+
  390.                             '<option></option>'+
  391.                             '<option value="1">Test</option>'+
  392.                           '</select>'+
  393.                         '</td>'+
  394.                         '<td>'+
  395.                           '<input  type="text" class="form-control" id="orderPrice" name="orderPrice[]">'+
  396.                            '@if ($errors->has('orderPrice'))'+
  397.                               '<p class="error">{{ $errors->first('orderPrice') }}</p>'+
  398.                           '@endif'+
  399.                         '</td>'+
  400.                         '<td>'+
  401.                           '<input type="text" class="form-control" id="orderDis" name="orderDis[]" placeholder="0.00" value="0.00">'+
  402.                            '@if ($errors->has('orderDis'))'+
  403.                               '<p class="error">{{ $errors->first('orderDis') }}</p>'+
  404.                           '@endif'+
  405.                         '</td>'+
  406.                         '<td>'+
  407.                           '<input type="text" class="form-control" id="orderPerAmount" name="orderPerAmount[]" readonly="readonly" jAutoCalc="{#orderQty} * {#orderPrice} - {#orderQty} * {#orderPrice} * {#orderDis} / 100">'+
  408.                         '</td>'+
  409.                     '</tbody>'+
  410.                   '</table>';
  411.                   $('#newRow').append(tr);
  412.                   calculateOrderRows(); // Init row order calculation on looping field
  413.                   autoCalcSetup(); // Init calculation code on looping field
  414.                   chosenJs(); // Init interactive dropdown select on looping field
  415.               });
  416.             });
  417.  
  418. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement