ok
Direktori : /home2/selectio/www/mm-tailor-billing/themes/default/views/material_usage/ |
Current File : /home2/selectio/www/mm-tailor-billing/themes/default/views/material_usage/add.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> </div> <div class="box-body"> <div class="col-lg-12"> <?php echo form_open_multipart("material_usage/add", 'class="validation"'); ?> <div class="row"> <div class="col-md-3"> <input type="date" name="common_date" id="common_date" class="form-control" value=""> </div> <div class="col-md-3"> <select name="category" class="form-control" id="category"> <option value="">Select Category</option> <?php $c=1; foreach($categories as $cat){ ?> <option value="<?=$cat->id?>"><?=$cat->name?></option> <?php $c++; } ?> </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 class="col-md-3"> <!--<select name="user_id" class="form-control" id="user_id"> <option value="">Select User</option> <?php $f=1; foreach($user_data as $user){ ?> <option value="<?=$user->id?>"><?=$user->first_name.$user->last_name?></option> <?php $f++; } ?> </select>--> </div> </div> <br> <table style="width: 100%;border: 1px solid black;" id="pos_table"> <thead> <tr> <th style="width: 1%;">Date</th> <!--<th style="width: 10%;">User</th>--> <th style="width: 10%;">Material</th> <!--<th style="width: 10%;">Unit</th>--> <th style="width: 10%;">Units</th> <th style="width: 10%;">Quantity</th> <th style="width: 10%;">Remarks</th> <th style="width: 1%;">Action</th> </tr> </thead> <tbody id="product_tbody"> <!--<td><input type="date" name="date[]" id="date" class="form-control common_date" required="required" value="'+common_date+'"></td> <td><select name="user[]" class="form-control" id="user" required="required"> <option value="">Select User</option> <?php $f=1; foreach($user_data as $user){ ?> <option value="<?=$user->id?>"><?=$user->first_name.$user->last_name?></option> <?php $f++; } ?> <?php $u=1; foreach($uints as $uint){ ?> <option value="<?=$unit->id?>"><?=$unit->name?></option> <?php $u++; } ?> </select></td> <td><select name="material[]" class="form-control" id="material" required="required"> <option value="">Select Material</option> <?php $f=1; foreach($product_material as $products){ ?> <option value="<?=$products->id?>"><?=$products->name?></option> <?php $f++; } ?> </select></td> <td><select class="form-control" name="unit[]" id="unit" required><option value="">Select Unit</option><option value="1">KG</option><option value="2">Quantity</option></select></td> <td><input type="text" name="quantity[]" id="quantity" class="form-control" required="required" value=""></td> <td><input type="text" name="remarks[]" id="remarks" class="form-control" value=""></td> <td><span class="btn btn-warning btn-sm remove_row" id="remove_row"><i class="fa fa-times"></i></span></td>--> </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_material_usage', lang('add_material_usage'), 'class="btn btn-primary" id="add_material"'); ?> </div> </div> <?php echo form_close(); ?> </div> <div class="clearfix"></div> </div> </div> </div> </div> </section> <script> function getsubCategory(){ console.log('Get Sub Category Inside Function Working:'); var category=$('#category').val(); console.log('Category Id:'+category); $.ajax({ type: "get", url: '<?=site_url('purchases/get_sub_category');?>', data : {category:category}, dataType: "text", success: function(t) { $('#sub_category').append(t); }, error:function(err){ alert(err); } }); $('#sub_category').empty(); } </script> <script> $(document).ready(function(){ $("#add_material").prop("disabled", true); $("#user_id").change(function() { var user_id = $("#user_id").val(); console.log(user_id); $(".user").val(user_id); }); }); $(document).on('click', '.remove_row', function() { $(this).closest('.remove_tr').remove(); }); $('table#pos_table tbody').on('change', 'select.material', function() { var tr = $(this).closest('tr'); //var base_unit_selling_price = tr.find('input.hidden_base_unit_sell_price').val(); var material = $(this).find(':selected').val(); /*console.log('Selected items:'+material);*/ //tr.find('input.remark').val('xtz'); //var material=$("#material").val(); var conts='<option value="kg">kg</option><option value="pcs">pcs</option><option value="gram">gram</option>'; tr.find('.units').empty(); tr.find('.units').append(conts); $.ajax({ url:'<?=site_url('material_usage/select_unit');?>', data:{material:material}, type:'get', dataType:"text", success:function(data) { tr.find('.units').append(data); } }); tr.find('.units').empty(); }); /*function select_unit(random_id) { console.log("Random: "+random_id); var material=$("#material").val(); console.log(material); $.ajax({ url:'<?=site_url('material_usage/select_unit');?>', data:{material:material}, type:'get', dataType:"text", success:function(data) { $(".units").append(data); } }); $(".units").empty(); }*/ $("#add_table_row").click(function(){ //console.log("hjjh"); $("#add_material").prop("disabled", false); var common_date=$('#common_date').val(); var category=$('#category').val(); $.ajax({ type: "get", url: '<?=site_url('material_usage/get_category_products');?>', data : {category:category}, dataType: "text", success: function(t) { console.log('Products Name:'+t); products_list=t; console.log('Products List'+products_list); 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="material[]" class="form-control material" id="material" required="required"><option value="">Select Material</option>'+products_list+'</select></td><td><select class="form-control units" id="unit" name="unit[]"></select></td><td><input type="number" name="quantity[]" id="quantity" class="form-control" required="required" value=""></td><td><input type="text" name="remarks[]" id="remarks" class="form-control remark" value=""></td><td><span class="btn btn-danger btn-sm remove_row" id="remove_row"><i class="fa fa-times"></i></span></td></tr>'; $("#product_tbody").append(row); }, error:function(err){ alert(err); } }); /*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="material[]" class="form-control material" id="material" required="required"><option value="">Select Material</option><?php $f=1; foreach($product_material as $products){ ?><option value="<?=$products->id?>"><?=$products->name?></option><?php $f++; } ?></select></td><td><select class="form-control units" id="unit" name="unit[]"></select></td><td><input type="number" name="quantity[]" id="quantity" class="form-control" required="required" value=""></td><td><input type="text" name="remarks[]" id="remarks" class="form-control remark" value=""></td><td><span class="btn btn-danger btn-sm remove_row" id="remove_row"><i class="fa fa-times"></i></span></td></tr>'; $("#product_tbody").append(row);*/ }); /*$('#id_marca').change(function() { var selectedId = $(this).find('option:selected').val(); $('#hdn_id_marca').attr('value', selectedId); $.ajax({ url: '/admin/modelos/select_by_id_marca', data: {'hdn_id_marca': selectedId}, type: 'POST', success: function() { alert(data) } }); });*/ </script> <!--<td><select name="user[]" class="form-control user" id="user" required="required"><option value="">Select User</option><?php $f=1; foreach($user_data as $user){ ?><option value="<?=$user->id?>"><?=$user->first_name.$user->last_name?></option><?php $f++; } ?></select></td>--> <!--<td> <select class="form-control" name="unit[]" id="unit" required><option value="">Select Unit</option><?php $f=1; foreach($units as $unit){ {?> <option value="<?=$unit->id?>"><?=$unit->name?></option><?php } $f++;} ?></select></td>-->