<!DOCTYPE html>
<html lang="en">


<!-- Mirrored from edumin.dexignlab.com/xhtml/add-departments.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Nov 2020 13:56:15 GMT -->
<head>
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Rizwan </title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="<?php echo base_url();?>assets/images/favicon.png">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/bootstrap-select/dist/css/bootstrap-select.min.css">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/css/style.css">
    <!-- Pick date -->
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.css">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.date.css">
     <link href="<?php echo base_url();?>assets/vendor/datatables/css/jquery.dataTables.min.css" rel="stylesheet">
    <!-- Custom Stylesheet -->
     

</head>

<body>

    <!--*******************
        Preloader start
    ********************-->
        <div id="preloader">
        <div class="sk-three-bounce">
            <div class="sk-child sk-bounce1"></div>
            <div class="sk-child sk-bounce2"></div>
            <div class="sk-child sk-bounce3"></div>
        </div>
    </div>
    <!--*******************
        Preloader end
    ********************-->

    <!--**********************************
        Main wrapper start
    ***********************************-->
    <div id="main-wrapper">

      <?php  $this->load->view('header'); ?>
        
        <!--**********************************
            Content body start
        ***********************************-->
        <div class="content-body">
            <!-- row -->
            <div class="container-fluid">
                    
                <div class="row page-titles mx-0">
                    <div class="col-sm-6 p-md-0">
                        <div class="welcome-text">
                            <h4>Boms of Material</h4>
                        </div>
                    </div>
                   
                </div>
                
                <div class="row">


                    <div class="col-12">
            
                       <?php echo form_open(base_url(''),array('class'=>"form-horizontal add_material_bom", 'id'=>"add_material_bom")); ?>
                                    
                                        <?php if($this->session->flashdata('material_success')){ ?>
                                <div class="alert alert-success solid" style='text-align:center;'><?php echo $this->session->flashdata('material_success'); ?></div>
                            <?php } ?>         
                            <input type="hidden" name='product_id' id='product_id' value="<?php echo $this->uri->segment(3); ?>"/>
                          <div class="col-xl-12 col-xxl-12 col-sm-12">
                             <div class="card">
                               
                                <div class="card-body">
                                    <div id='material_success' class='alert alert-success solid' style='display:none;'></div>
                                       <div class="row">
                                             <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                   
                                                    <input type="hidden" name="created" id="created" value="<?php echo date('Y-m-d H:i:s'); ?>" class="form-control required">
                                                </div>
                                            </div>

                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                   
                                                    <input type="hidden" value="<?php echo date('Y-m-d H:i:s'); ?>" name="modified" id="modified" class="form-control required">
                                                </div>
                                            </div>
                                          
                                            <div class="col-lg-3 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">BOM Componenet:</label>
                                                    <select  data-live-search="true" name="meterial" id="meterial">
                                                      <?php foreach ($get_materials as $get_materials) { ?>
                                                                
                                                     <option value="<?php echo $get_materials['id']; ?>"><?php echo $get_materials['name']; ?></option>

                                                        <?php } ?>
                                                  </select>
                                                 </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                 <div class="form-group">
                                                    <label class="form-label">Grade/Remarks:</label>
                                                    <input type="text"  readonly="readonly"   class="form-control grade">
                                                 </div>
                                                </div>


                                                 <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Item Code:</label>
                                                    <input type="text" readonly="readonly"  class="form-control code">
                                                 </div>
                                                </div>
                                                

                                                  <div class="col-lg-2 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Weight/Qty:</label>
                                                      <input type="text" name="weight" id="weight"  class="form-control">
                                                 </div>
                                                </div>

                                                <div class="col-lg-2 col-md-6 col-sm-12">
                                                  <div class="form-group">
                                                    <label class="form-label">Unit:</label>
                                                     <select name="unit" id="unit" class="form-control">
                                                            <option value="">Select Unit</option>
                                                            <?php foreach ($get_units as $get_units) { ?>
                                                                
                                                                 <option value="<?php echo $get_units['id']; ?>"><?php echo $get_units['names']; ?></option>

                                                            <?php } ?>
                                                           
                                                            
                                                            </select>
                                                       </div>

                                                </div>
                                        
                                       </div>
                                         <button type="submit" class="btn btn-primary">Submit <i class="icon-arrow-right14 position-right"></i></button>
                                     </div>
                                    </div>
                                    
                                </div>
                           
                               
                                
                                            
                                 <?php form_close();?>
                            </div>
                            <div class="col-xl-12 col-xxl-12 col-sm-12">
                             <div class="card">
                            <div class="card-body">
                                <?php if($this->session->flashdata('material_bom_danger')){ ?>
                                    <div class="alert alert-danger solid " style='text-align:center;'><?php echo $this->session->flashdata('material_bom_danger'); ?></div>
                                <?php } ?>
                                 <div id='material_bom_danger' class='alert alert-danger solid' style='display:none;'></div>
                                <div class="table-responsive">
                                    <table id="example5" class="display" style="min-width: 845px">
                                        <thead>
                                            <tr>
                                                <th>Bom Components</th>
                                                <th>Grade/Remarks</th>
                                                <th>Items Code</th>
                                                <th>Weight/Qty</th>
                                                <th>Unit</th>
                                                
                                            </tr>
                                        </thead>
                                        <tbody>
                                          
                                            <?php 
                                            if(!empty($get_bom_data)){
                                            foreach($get_bom_data as $get_bom_data){ ?>
                                          <tr>
                                              <td><?php echo material_name($get_bom_data['meterial']); ?></td>
                                              <td><?php echo $get_bom_data['grade']; ?></td>
                                              <td><?php echo $get_bom_data['material_code']; ?></td>
                                              <td><?php echo $get_bom_data['weight']; ?></td>
                                              <td><?php echo get_unit_name($get_bom_data['unit']); ?></td>
                                    <td><a href="javascript:void(0);" onclick="delete_data(<?php echo $get_bom_data['id']; ?>)" class="btn btn-sm btn-danger"><i class="la la-trash-o"></i></a></td>
                                          </tr>  
                                           <?php } } ?>
                                        </tbody>
                                    </table>
                                </div>
                                 </div>
                                  </div>
                            </div>
                        </div>
                    </div>





                    
                </div>
            </div>
        </div>
        <!--**********************************
            Content body end
        ***********************************-->


        <!--**********************************
            Footer start
        ***********************************-->
        
        <!--**********************************
            Footer end
        ***********************************-->

        <!--**********************************
           Support ticket button start
        ***********************************-->

        <!--**********************************
           Support ticket button end
        ***********************************-->


    </div>
    <!--**********************************
        Main wrapper end
    ***********************************-->

    <!--**********************************
        Scripts
    ***********************************-->
    <!-- Required vendors -->
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <style>
        .redborder{
            border:1px solid red;
        }
        </style>

    <script type='text/javascript'>
        
    var material = $('#add_material_bom');   
    
    material.on('submit',function(e){

        e.preventDefault();
        
        var add_material_bom = material.serialize();
         var id = $('#product_id').val();
      
            $.ajax({
                type:'POST',
                url:'<?php echo base_url('Masterlist/boms_details_add'); ?>',
                data:add_material_bom,
                dataType:'json',
                success:function(data){
                    console.log('first'+data.status);
                    if(data.status === 'true'){
                        console.log('second'+data.status);
                        $('#material_success').show().html('Bom added Successfully');
                       setTimeout(function(){location.href="<?php echo base_url('Masterlist/boms_details/'); ?>"+id} , 3000);
                    }else{
                        console.log('third'+data);          
                    }
                },
                error:function(data){console.log(data.responseText);}
            });
       // }
    });

    function delete_data(id) { 
        var id = id;
        var pro_id = $('#product_id').val();
         $.ajax({
                type:'POST',
                url:'<?php echo base_url('Masterlist/bom_delete_material/'); ?>'+id,
                data:id,
                dataType:'json',
                success:function(data){
                    console.log('first'+data.status);
                    
                        console.log('second'+data.status);
                        //debugger;
                        $('#material_bom_danger').show().html('Bom Component Deleted Successfully');
                       setTimeout(function(){location.href="<?php echo base_url('Masterlist/boms_details/'); ?>"+pro_id} , 3000);
                    
                },
                error:function(data){console.log(data.responseText);}
            });
        } 



        $("#meterial").change(function() {
    
        var id =  this.value;

        $.ajax({
                    type:'POST',
                    url:'<?php echo base_url('Masterlist/boms_details'); ?>',
                    data:{id:id},
                    dataType:'json',
                    success:function(data){
                        //console.log(data[0].material_code);
                        $('.grade').val(data[0].grade);
                        $('.code').val(data[0].material_code);
                       
                       
                    },
                    error:function(data){console.log(data.responseText);}
                });

    });


         function btnExport_monthly()
{
    
    var tab_text="<table border='2px'><tr bgcolor='#ebebeb'>";
    var textRange; var j=0;
    tab = document.getElementById('example5'); // id of table

    for(j = 0 ; j < tab.rows.length ; j++) 
    {     
        tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
        //tab_text=tab_text+"</tr>";
    }

    tab_text=tab_text+"</table>";
    tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
    tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
    tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params


    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE "); 

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))      // If Internet Explorer
    {
        txtArea2.document.open("txt/html","replace");
        txtArea2.document.write(tab_text);
        txtArea2.document.close();
        txtArea2.focus(); 
        sa=txtArea2.document.execCommand("SaveAs",true,"Generation_School_Report");
    }  
    else                 //other browser not tested on IE 11
        sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));  

    return (sa);
}
    
    </script>   

       <?php  $this->load->view('footer'); ?>
        
</body>

<!-- Mirrored from edumin.dexignlab.com/xhtml/add-departments.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Nov 2020 13:56:15 GMT -->
</html> 