create.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. @extends('layouts.master')
  2. @section('content')
  3. <div class="content">
  4. <div class="row">
  5. <form action="{{ url('invoice/save') }}" enctype="multipart/form-data" method="POST" role="form">
  6. <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
  7. @if (count($errors) > 0)
  8. <div class="alert alert-danger">
  9. <ul>
  10. @foreach ($errors->all() as $error)
  11. <li>{{ $error }}</li>
  12. @endforeach
  13. </ul>
  14. </div>
  15. @endif
  16. </div>
  17. <div class="col-xs-5 col-sm-5 col-md-5 col-lg-5">
  18. <div class="panel panel-default">
  19. <div class="panel-heading">
  20. <h3 class="panel-title">Invoice</h3>
  21. </div>
  22. <div class="panel-body">
  23. {{ csrf_field() }}
  24. <div class="form-group">
  25. <label for="code">Invoice Id</label>
  26. <input type="text" class="form-control" id="code" name="code" disabled required value="{{ $code }}">
  27. <input type="hidden" name="invoice_code" value="{{ $code }}">
  28. </div>
  29. <div class="form-group">
  30. <label for="exampleInputEmail1">Client</label>
  31. <select class="form-control" name="client" placeholder="Client">
  32. <option>Select A Client</option>
  33. @foreach($client_list as $client)
  34. <option value="{{ $client->id }}">{{ $client->name }}</option>
  35. @endforeach
  36. </select>
  37. </div>
  38. <!-- <div class="form-group">
  39. <label for="client">Client</label>
  40. <select name="client" id="client" class="form-control" required>
  41. <option value="">Select Client</option>
  42. @if($companies)
  43. @foreach($companies as $row)
  44. <option value="{{ $row->id }}">{{ $row->company }}</option>
  45. @endforeach
  46. @endif
  47. </select>
  48. </div> -->
  49. <div class="form-group">
  50. <label for="po_no">PO No</label>
  51. <input type='text' name="po_no" id="po_no" class="form-control" placeholder="PO No">
  52. </div>
  53. <div class="form-group">
  54. <label for="invoice_date">Invoice Date</label>
  55. <input type='text' name="invoice_date" id="invoice_date" class="form-control dt" placeholder="Invoice Date">
  56. </div>
  57. <div class="form-group">
  58. <label for="due_date">Due Date</label>
  59. <input type='text' name="due_date" id="due_date" class="form-control dt" placeholder="Due Date">
  60. </div>
  61. <div class="form-group">
  62. <label for="note">Note</label>
  63. <textarea name="note" id="note" class="form-control" placeholder="Write a short note..."></textarea>
  64. </div>
  65. <div class="form-group">
  66. <label for="currency">Currency</label>
  67. <select name="currency" id="currency" class="form-control">
  68. <option value="BDT">BDT</option>
  69. <option value="USD">USD</option>
  70. </select>
  71. </div>
  72. <div class="form-group">
  73. <label for="attachment">Attachment</label>
  74. <input type='file' name="attachment" id="attachment" class="form-control">
  75. </div>
  76. <div class="clearfix"></div>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="col-xs-7 col-sm-7 col-md-7 col-lg-7">
  81. <div class="panel panel-default">
  82. <div class="panel-heading">
  83. <h3 class="panel-title">Invoice Items</h3>
  84. </div>
  85. <div class="panel-body">
  86. <table class="table table-bordered tbl-items">
  87. <thead>
  88. <tr>
  89. <th>Service/Product</th>
  90. <th>Particular</th>
  91. <th>Payable Amount</th>
  92. <th>Paid Amount</th>
  93. </tr>
  94. </thead>
  95. <tbody>
  96. <tr>
  97. <td>
  98. <select name="service[]" id="service" class='form-control'>
  99. <option value="">Select Service</option>
  100. @if($services)
  101. @foreach($services as $row)
  102. <option value="{{ $row->id }}">{{ $row->name }}</option>
  103. @endforeach
  104. @endif
  105. </select>
  106. </td>
  107. <td>
  108. <input type="text" name="particular[]" class="particular form-control" placeholder="Particulars">
  109. </td>
  110. <td>
  111. <input type='number' name="payable_amount[]" step='.1' min="0" value="0" max='1000000000000' class='form-control payable_amount'>
  112. </td>
  113. <td>
  114. <input type='number' name="paid_amount[]" min="0" step='.1' value="0" max='1000000000000' class='form-control paid_amount'>
  115. </td>
  116. </tr>
  117. </tbody>
  118. <tfoot>
  119. <tr>
  120. <td colspan="2">
  121. </td>
  122. <td>
  123. <label for="tax">Tax (%)</label><br>
  124. <input type='number' min='0' max='100' step='.1' value='0' name="tax" id="tax" class="form-control">
  125. </td>
  126. <td>
  127. <label for="vat">VAT (%)</label><br>
  128. <input type='number' min='0' max='100' step='.1' value='0' name="vat" id="vat" class="form-control">
  129. </td>
  130. </tr>
  131. <tr>
  132. <th colspan="2">Total</th>
  133. <th class='text-right ttl-payable'>0</th>
  134. <th class='text-right ttl-paid'>0</th>
  135. </tr>
  136. </tfoot>
  137. </table>
  138. <button type='button' id='btn_new_item' class='btn btn-xs' title='Add New Invoice Item'><i class="fa fa-plus"></i></button>
  139. <button type='button' id='btn_remove_item' class='btn btn-xs' title='Rremove Last Invoice Item'><i class="fa fa-minus"></i></button>
  140. </div>
  141. <div class="panel-footer">
  142. <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Create</button>
  143. <a href="{{ url('invoice') }}" class="btn btn-default">
  144. <i class="fa fa-times"></i>Cancel</a>
  145. </div>
  146. </div>
  147. </div>
  148. </form>
  149. </div>
  150. </div>
  151. @stop
  152. @section('script')
  153. <script type="text/javascript">
  154. $(document).ready(function() {
  155. $('#btn_new_item').click(function(){
  156. var newFrm=$('.tbl-items tbody tr:last').clone();
  157. newFrm.find('input[type="text"]').val('');
  158. newFrm.find('input[type="number"]').val(0);
  159. newFrm.find('textarea').val('');
  160. newFrm.find('select').val('');
  161. $('.tbl-items tbody tr:last').after(newFrm);
  162. });
  163. $('#btn_remove_item').click(function(){
  164. var trCount=$('.tbl-items tbody tr').length;
  165. if(trCount>1){
  166. var conf=confirm('Are you sure to remove ??');
  167. if(conf){
  168. var newFrm=$('.tbl-items tbody tr:last').remove();
  169. }
  170. }
  171. });
  172. $('.dt').datepicker({
  173. dateFormat:'yy-mm-dd',
  174. changeMonth:true,
  175. changeYear:true
  176. });
  177. $('.table').on('change','.payable_amount',function(){
  178. var ttlPayable=getTotalPayable();
  179. $('.ttl-payable').text(ttlPayable);
  180. });
  181. $('.table').on('change','.paid_amount',function(){
  182. var ttlPaid=getTotalPaid();
  183. $('.ttl-paid').text(ttlPaid);
  184. });
  185. $('#tax').change(function(){
  186. var tax=Number($(this).val());
  187. var ttlPayable=getTotalPayable();
  188. if(typeof tax!='undefined' || tax!=0){
  189. ttlPayable=ttlPayable+((ttlPayable*tax)/100);
  190. }
  191. $('.ttl-payable').text(ttlPayable);
  192. });
  193. $('#vat').change(function(){
  194. var vat=Number($(this).val());
  195. var ttlPayable=getTotalPayable();
  196. if(typeof vat!='undefined' || vat!=0){
  197. ttlPayable=ttlPayable+((ttlPayable*vat)/100);
  198. }
  199. $('.ttl-payable').text(ttlPayable);
  200. });
  201. });
  202. function getTotalPayable()
  203. {
  204. var ttl=0;
  205. $('.payable_amount').each(function(index, el) {
  206. var amnt=$(this).val();
  207. amnt=Number(amnt);
  208. if(typeof amnt!='undefined'){
  209. ttl+=amnt;
  210. }
  211. });
  212. return ttl;
  213. }
  214. function getTotalPaid()
  215. {
  216. var ttl=0;
  217. $('.paid_amount').each(function(index, el) {
  218. var amnt=$(this).val();
  219. amnt=Number(amnt);
  220. if(typeof amnt!='undefined'){
  221. ttl+=amnt;
  222. }
  223. });
  224. return ttl;
  225. }
  226. </script>
  227. @stop