ok
Direktori : /home2/selectio/www/mm-tailor-billing/themes/default/views/expenses/ |
Current File : /home2/selectio/www/mm-tailor-billing/themes/default/views/expenses/add_expense.php |
<?php (defined('BASEPATH')) OR exit('No direct script access allowed'); ?> <section class="content"> <div class="row"> <div class="col-xs-12"> <div class="box box-primary"> <div class="box-header"> <h3 class="box-title"><?= lang('enter_info'); ?></h3> <a href="../mmcategories/sub_add" class="btn btn-info btn-sm pull-right" style="margin-right: 5px;">Add Categories</a> </div> <div class="box-body"> <?= form_open_multipart("expenses/add_expense"); ?> <div class="row"> <div class="col-md-3"> <input type="date" name="common_date" id="common_date" class="form-control" required="required" value=""> </div> <div class="col-md-3"> <select name="category" id="category" class="form-control select2"> <option value="">Select Accounts</option> <?php $f=1; foreach($expense_category as $category){ ?> <option value="<?=$category->id?>"><?=$category->name?></option> <?php $f++; } ?> </select> </div> <div class="col-md-3"> <span class="btn btn-warning btn-xs" id="add_table_row"><i class="fa fa-plus"></i> Add Row</span> </div> <div class="col-md-3"> </div> </div> <br> <input type="hidden" name="attachment[]" class="form-control" id="attachment"> <input type="hidden" name="reference[]" id="reference" class="form-control tip" value=""> <table style="width: 100%;border: 1px solid black;"> <thead> <tr> <th style="width: 15%;">Date</th> <th style="width: 30%;">Category</th> <th style="width: 20%;">Amount</th> <th style="width: 30%;">Short Notes</th> <th style="width: 5%;">Actions</th> </tr> </thead> <tbody id="product_tbody"> </tbody> </table> <style> table{ border: 1px solid black; } td,tr,th{ border: 1px solid black; text-align: center; } th{ padding: 5px; } </style> <br> <div class="col-md-6"> <div class="form-group"> <?php echo form_submit('add_expense', lang('add_expense'), 'class="btn btn-primary"'); ?> </div> </div> <div class="col-md-6" style="text-align: right;padding-bottom: 25px;padding-top: 20px;"> <div style="font-size: 35px;font-weight: 600;"><span style="background: aquamarine; padding: 5px 35px 5px 35px; border-radius: 12px; box-shadow: 2px 2px; border: 1px solid darkgray;">Grand Total: <span id="grand_total" style="color: #ff0303; font-size: 35px; font-weight: 900;"></span></span></div> </div> <!--<input type="text" id="grand_total" class="form-control" value="" style="color: darkblue; font-size: 28px; font-weight: 900;" readonly />--> </div> <?php echo form_close(); ?> <div class="clearfix"></div> </div> </div> </div> </section> <script src="<?= $assets ?>plugins/bootstrap-datetimepicker/js/moment.min.js" type="text/javascript"></script> <script src="<?= $assets ?>plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $('.datetimepicker').datetimepicker({ format: 'YYYY-MM-DD HH:mm' }); }); </script> <script> $(document).on('click', '.remove_row', function() { $(this).closest('.remove_tr').remove(); grand_total(); }); $("#add_table_row").click(function(){ var common_date=$('#common_date').val(); var category=$('#category').val(); console.log('Category Id:'+category); var sub_cat=''; $.ajax({ type: "get", url: '<?=site_url('expenses/get_sub_category');?>', data : {category:category}, dataType: "text", success: function(t) { console.log('Sub Category Name:'+t); sub_cat=t; console.log('sub_category'+sub_cat); var row='<tr class="remove_tr"><td><input type="date" name="date[]" id="date" class="form-control common_date" required="required" value="'+common_date+'"></td><td><select name="sub_category[]" id="sub_category" class="form-control sub_category select2">'+sub_cat+'</select></td><td><input type="text" name="amount[]" id="amount" value="" class="pa form-control kb-pad amount" required="required"/></td><td><input name="note[]" class="form-control" id="note" value=""></td><td><span class="btn btn-warning btn-sm remove_row" id="remove_row"><i class="fa fa-times"></i></span></td></tr>'; $("#product_tbody").append(row); $('.select2').select2(); }, error:function(err){ alert(err); } }); $("body").on("keyup",".amount",function(){ grand_total(); }); }); function grand_total(){ var tot=0; $(".amount").each(function(){ tot+=Number($(this).val()); }); console.log("Total: "+tot); $("#grand_total").text(tot); } </script>