Advertisement
Guest User

index.blade.php

a guest
Dec 12th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.23 KB | None | 0 0
  1. <!-- TEMP LOCAL STYLE -->
  2. <style type="text/css">
  3.     .box {
  4.         width: 100%;
  5.     }
  6.     .form-control:focus {
  7.         border-color: #5a47fb !important;
  8.    }
  9.     .select2-container *:focus {
  10.         border : 1px solid #5a47fb;
  11.    }
  12.     span.select2.select2-container {
  13.         width: 100% !important;
  14.     }
  15.     button.btn.btn-default:focus {
  16.         color: #5a47fb !important;
  17.        border : 1px solid #5a47fb;
  18.    }
  19.     button.btn-keyboard:focus {
  20.         box-shadow : 0px 0px 5px 0px black;
  21.     }
  22.     tr.showDetail {
  23.         background: radial-gradient(black, transparent);
  24.     }
  25.     em {
  26.         background: #b4bdce;
  27.        padding: 3px 0px;
  28.     }
  29.     #search{
  30.        margin-bottom: 15px;
  31.     }
  32.     span.select2.select2-container {
  33.         /*width: 200px !important;*/
  34.     }
  35.     tr.tr-hovered:hover {
  36.         background: #ffc8c8 !important;
  37.    }
  38.     tr.tr-hovered:hover + tr.tr-hovered {
  39.         background: #fff !important;
  40.    }
  41.     form#stockCardShow {
  42.        width: 100%;
  43.     }
  44. </style>
  45.    
  46. <div class="row col-md-12">
  47.     <form action="" id="stockCardShow" method="GET">
  48.  
  49.         <div class="box-header with-border">
  50.  
  51.         </div>
  52.  
  53.         <input type="hidden" name="status" id="status">
  54.  
  55.  
  56.         <div class="box-body">
  57.             <div class="row" style="margin-top: 10px; margin-bottom: 5px">
  58.                 <div class="col-md-12">
  59.  
  60.                     <div class="row form-group">
  61.                         <div class="col-sm-2 text-right">
  62.                             <label for="warehouse_id">Warehouse</label>
  63.                         </div>
  64.                         <div class="col-sm-4">
  65.                             <select class="form-control" name="warehouse_id" id="warehouse_id">
  66.                                 <option value="">-- Select Warehouse --</option>
  67.                                 @foreach($data->warehouses as $warehouse)
  68.                                     <option {{$data->filter->warehouse_id == $warehouse->id ? 'selected' : ''}} value="{{$warehouse->id}}">{{$warehouse->warehouse_name}}</option>
  69.                                 @endforeach
  70.                             </select>
  71.                         </div>
  72.                                                
  73.                         <div class="col-sm-2 text-right">
  74.                             <label>Item</label>
  75.                         </div>
  76.                         <div class="col-sm-4">
  77.                             <select class="form-control item_id" name="item_id" id="item_id" required>
  78.                                 <option value="">-- Select Item --</option>
  79.                                 @if($data->selected_item)
  80.                                     <option value="{{$data->selected_item->id}}" selected>{{$data->selected_item->text}}</option>
  81.                                 @endif
  82.                             </select>
  83.                         </div>
  84.                     </div>
  85.  
  86.                     <div class="form-group row">
  87.                         <div class="col-sm-2 text-right">
  88.                             <label for="note">From date</label>
  89.                         </div>
  90.                         <div class="col-sm-4">
  91.                             <div class="input-group-prepend">
  92.                                 <div class="input-group-text">
  93.                                     <i class="typcn typcn-calendar-outline tx-24 lh--9 op-6"></i>
  94.                                 </div>
  95.                                 <input type="text" id="from_date" name="from_date" class="form-control fc-datepicker" required="required" value="{{$data->filter->from_date}}" placeholder="dd/mm/yyyy" autocomplete="off">
  96.                             </div>
  97.                         </div>
  98.                        
  99.                         <div class="col-sm-2 text-right">
  100.                             <label for="note">To date</label>
  101.                         </div>
  102.                         <div class="col-sm-4">
  103.                             <div class="input-group-prepend">
  104.                                 <div class="input-group-text">
  105.                                     <i class="typcn typcn-calendar-outline tx-24 lh--9 op-6"></i>
  106.                                 </div>
  107.                                 <input type="text" id="to_date" name="to_date" class="form-control fc-datepicker" required="required" value="{{$data->filter->to_date}}" placeholder="dd/mm/yyyy" autocomplete="off">
  108.                             </div>
  109.                         </div>
  110.  
  111.                     </div>
  112.  
  113.                 </div>
  114.             </div>
  115.         </div>
  116.  
  117.         <hr>
  118.         <button type="button" value="show" class="showBtn btn btn-info pull-right btn-keyboard m-2">Show</button>
  119.         <button type="button" onclick="resetFilter()" class="btn btn-danger pull-right btn-keyboard m-2">Reset</button>
  120.         <div class="clearfix"></div>
  121.  
  122.     </form>
  123.    
  124. </div>
  125.  
  126. <div class="box-body" id="data">        
  127. </div>
  128.  
  129.  
  130. <script>
  131. var urlOriginAdmin = '/admin/products/stock-card-data/';
  132.  
  133. $(document).ready(function(e) {
  134.     window.loca
  135.  
  136.     $('.fc-datepicker').datepicker({
  137.         showOtherMonths: true,
  138.         selectOtherMonths: true,
  139.         dateFormat: 'dd/mm/yy'
  140.     });
  141.  
  142.     $('.showBtn').click(function(e){
  143.         e.preventDefault();
  144.         var status = $(this).val();
  145.         $('#status').val(status);
  146.         $('#stockCardShow').submit();
  147.     });
  148.  
  149.     $('#stockCardShow').submit(function(e) {
  150.         e.preventDefault();
  151.         formData = $(this).serializeArray();
  152.         $.ajax({
  153.             dataType: 'json',
  154.             method : $(this).attr('method'),
  155.             url : urlOriginAdmin+ 'getData',
  156.             data : formData,
  157.             success : function(response){
  158.                 if(response.validator)
  159.                 {  
  160.                     message = "";
  161.                     $.each(response.validator,function(k,v){
  162.                         $.each(v,function(k1,v1){
  163.                             message+=v1+'<br>';
  164.                         });
  165.                     });
  166.  
  167.                     toastr["error"](message);
  168.                 }
  169.                 else {
  170.                     loadData(response);
  171.                 }
  172.             }
  173.         })
  174.     })
  175.  
  176.     initSelect();
  177. })
  178.  
  179. function initSelect() {
  180.     $('#warehouse_id').select2({
  181.         placeholder: 'Wareouse',
  182.     }).change(function(e){
  183.         $('#item_id').val(null).trigger("change");
  184.     });
  185.  
  186.     $('#item_id').select2({
  187.         placeholder: 'Item',
  188.         ajax: {
  189.             dataType: 'json',
  190.             url: urlOriginAdmin+'getDataItemsSelect2',
  191.             delay: 10,
  192.             data: function(params) {
  193.                 return {
  194.                     term: params.term,
  195.                     warehouse_id: $('#warehouse_id').val(),                  
  196.                 }
  197.             },
  198.             processResults: function (data) {
  199.                 return {
  200.                     results: $.map(data, function (obj) {
  201.                         return {
  202.                             id: obj.id,
  203.                             text: obj.text,
  204.                         };
  205.                     })
  206.                 };
  207.             },
  208.         }
  209.     })
  210. }
  211.  
  212. function resetFilter() {
  213.     window.history.pushState(null, null, window.location.pathname);
  214.     $('.form-group').find('input,textarea').val('');
  215.     $('.form-group').find('select').val('').trigger('change');
  216.     $('#status').val('show');
  217.     $('#data').html('');
  218.     // $('#stockCardShow').submit();
  219. }
  220.  
  221. function loadData(data) {
  222.     $('#data').html(data.map(warehouse => (`
  223.         <hr>
  224.         <h4 class="px-3 pb-2 pt-3">${warehouse.warehouse_name}</h4>
  225.  
  226.             ${warehouse.item.map(item => (`
  227.                 <div class="card px-3 m-2" style="width:98.5%">
  228.                     <div class="card-body">
  229.                         <h6 class="card-title">${item.items.item_name}</h6>
  230.                         <div class="table-responsive">
  231.                             <table class="table mg-b-0">
  232.                                 <thead>
  233.                                     <tr>
  234.                                         <th>Date</th>
  235.                                         <th>Code</th>
  236.                                         <th>No Ref</th>
  237.                                         <th class="text-right">In</th>
  238.                                         <th class="text-right">Out</th>
  239.                                         <th class="text-right">Balance</th>
  240.                                     </tr>
  241.                                 </thead>
  242.                                 <tbody>
  243.                                     ${item.operation.map(op => (`
  244.                                         <tr>
  245.                                             <td>${op.created_at}</td>
  246.                                             <td>${op.operation_code}</td>
  247.                                             <td>${op.doc_ref}</td>
  248.                                             <td class="text-right tx-success">
  249.                                                 ${op.type == 'in' ? `+${op.qty}`: ''}
  250.                                             </td>
  251.                                             <td class="text-right tx-danger">
  252.                                                 ${op.type == 'out' ? `+${op.qty}`: ''}
  253.                                             </td>
  254.                                             <td class="text-right">${op.balance}</td>
  255.                                         </tr>
  256.                                     `)).join('')}
  257.                                 </tbody>
  258.                                 <tfoot>
  259.                                     <tr>
  260.                                         <td colspan="3"><strong>Total</strong></td>
  261.                                         <td class="text-right"><strong>${item.total_in}</strong></td>
  262.                                         <td class="text-right"><strong>${item.total_out}</strong></td>
  263.                                         <td class="text-right"><strong>${item.final_balance}</strong></td>
  264.                                     </tr>
  265.                                 </tfoot>
  266.                             </table>
  267.                         </div>
  268.                     </div>
  269.                 </div>
  270.             `)).join('')}
  271.         <br>`)).join(''));
  272. }
  273. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement