Guest User

Untitled

a guest
Jan 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. $columns[] = ['label'=>'Servicio Logistico','name'=>'Servicio_Logistico','type'=>'number','required'=>true];
  2. $columns[] = ['label'=>'Diferencia Giro','name'=>'Diferencia_Giro','type'=>'number','required'=>true];
  3. $columns[] = ['label'=>'Anticipo','name'=>'Anticipo','type'=>'number','required'=>true];
  4. $columns[] = ['label'=>'Sub Total','name'=>'Sub_Total','type'=>'number','formula'=>"([Servicio_Logistico]) + ([Diferencia_Giro]) - [Anticipo]","readonly"=>true,'required'=>true];
  5.  
  6. @if($col['formula'])
  7. <?php
  8. $formula = $col['formula'];
  9. $formula_function_name ='formula'.str_slug($name.$col['name'],'');
  10. $script_onchange = "";
  11. foreach($form['columns'] as $c) {
  12. if(strpos($formula, "[".$c['name']."]")!==false) {
  13. $script_onchange .= "
  14. $('#$name$c[name]').change(function() {
  15. $formula_function_name();
  16. });
  17. ";
  18. }
  19. $formula = str_replace("[".$c['name']."]","$('#".$name.$c['name']."').val()",$formula);
  20. }
  21. ?>
  22. @push('bottom')
  23. <script type="text/javascript">
  24. function {{ $formula_function_name }}() {
  25. var v = {!! $formula !!};
  26. $('#{{$name_column}}').val(v);
  27. }
  28. $(function() {
  29. {!! $script_onchange !!}
  30. })
  31. </script>
  32. @endpush
  33. @endif
Add Comment
Please, Sign In to add comment