<!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">
                <button type="submit" class="btn btn-warning" onclick="goBack()">Go Back <i class="icon-arrow-right14 position-right"></i></button> 
                    <br/><br/>
                     <input type="hidden" name='product_id' id='product_id' value="<?php echo $this->uri->segment(3); ?>"/>

                 <input type="hidden" name='main_product' id='main_product' value="<?php echo $this->uri->segment(4); ?>"/>
                <div class="row page-titles mx-0">
                    <div class="col-sm-6 p-md-0">
                        <div class="welcome-text">
                            <h4>Boms: <?php echo product_name($this->uri->segment(3)); ?></h4>
                           
                            <div class="form-group">
                                <label class="form-label"></label>
                                <select  data-live-search="true" name="select" id="select">
                                      <option value="">Select Option</option>
                                  <option value="1">Material</option>
                                  <option value="2">Product</option>
                                
                              </select>
                             </div>
                          
                        </div>

                    </div>
                   
                </div>

                
        <div class="row">
            <div class="col-12">
                    <span id="show_form"></span>
            </div>
                            <div class="col-12">

                                 <div class="col-xl-12 col-lg-12 col-xxl-12 col-md-12">
                        <div class="card profile-tab">
                            <div class="card-header">
                                <h4 class="card-title">Bom</h4>
                            </div>
                            <div class="card-body custom-tab-1">
                                
                                <div class="tab-content">
                                    <div id="my-posts" class="tab-pane fade active show">
                                        <div class="table-responsive">
                                             <table id="example5" class="display" style="min-width: 845px">
                                                <thead>
                                                    <tr>
                                                        <th scope="col">Bom Component</th>
                                                        <th scope="col">Product Type</th>
                                                        <th scope="col">Grade/Remark</th>
                                                        <th scope="col">Items Code</th>
                                                        <th scope="col">Weight</th>
                                                        <th scope="col">Unit</th>
                                                        <th scope="col">Action</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                     
                                                    <?php 
                                                    if(!empty($get_bom_data_child))
                                                        {
                                                    foreach ($get_bom_data_child as $get_bom_data_child) { ?>
                                                        
                                                        <tr>
                                                        <td><?php echo product_name($get_bom_data_child['child_product']); ?></td>
                                                        
                                                            <?php if($get_bom_data_child['product_type']==1) {?>
                                                                <td><span class="badge badge-success"><?php echo get_product_type($get_bom_data_child['product_type']); ?></span></td>
                                                            <?php }else if($get_bom_data_child['product_type']==2) {?>

                                                                <td><span class="badge badge-secondary"><?php echo get_product_type($get_bom_data_child['product_type']); ?></span></td>
                                                            <?php }else if($get_bom_data_child['product_type']==3) { ?>
                                                                 <td><span class="badge badge-warning"><?php echo get_product_type($get_bom_data_child['product_type']); ?></span></td>
                                                             <?php } else if($get_bom_data_child['product_type']==4) { ?>
                                                                 <td><span class="badge badge-danger"><?php echo get_product_type($get_bom_data_child['product_type']); ?></span></td>
                                                            <?PHP } else if($get_bom_data_child['product_type']==5) { ?>
                                                                 <td><span class="badge badge-primary"><?php echo get_product_type($get_bom_data_child['product_type']); ?></span></td>
                                                            <?PHP } ?>
                                                        
                                                        <td><?php echo $get_bom_data_child['remarks']; ?></td>
                                                        <td><?php echo $get_bom_data_child['pro_code']; ?></td>
                                                        <td><?php echo $get_bom_data_child['weight']; ?></td>
                                                        <td><?php echo get_unit_name($get_bom_data_child['unit']); ?></td>

                                                         <td><a href="javascript:void(0);" onclick="delete_data_product(<?php echo $get_bom_data_child['bom_id']; ?>)" class="btn btn-sm btn-danger"><i class="la la-trash-o"></i></a></td> 
                                                    </tr>
                                                    

                                                    <?php 
                                                        }
                                                    }

                                                     ?>
                                                    <?php 
                                                if(!empty($get_bom_data_materials_pro))
                                                {
                                                foreach ($get_bom_data_materials_pro as $get_bom_data_materials_pro) { ?>
                                                    <tr>
                                                        <td><?php echo $get_bom_data_materials_pro['name']; ?></td>
                                                        <?php if($get_bom_data_materials_pro['type'] == 1){ ?>
                                                        <td><span class="badge badge-rounded badge-success"><?php echo get_material_type($get_bom_data_materials_pro['type']); ?></span></td>

                                                        <?php }else if($get_bom_data_materials_pro['type'] == 2){ ?>
                                                            <td><span class="badge badge-rounded badge-warning"><?php echo get_material_type($get_bom_data_materials_pro['type']); ?></span></td>

                                                        <?php }else if($get_bom_data_materials_pro['type'] == 3){?>

                                                            <td><span class="badge badge-rounded badge-primary"><?php echo get_material_type($get_bom_data_materials_pro['type']); }?></span></td>

                                                        <td><?php echo $get_bom_data_materials_pro['grade']; ?></td>
                                                        
                                                        <td><?php echo $get_bom_data_materials_pro['material_code']; ?></td>
                                                        <td><?php echo $get_bom_data_materials_pro['weight']; ?></td>
                                                        <td><?php echo get_unit_name($get_bom_data_materials_pro['bom_unit']); ?></td>
                                                        <td><a href="javascript:void(0);" onclick="delete_data_material(<?php echo $get_bom_data_materials_pro['boms_materials_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>

                   
                </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="<?php echo base_url();?>assets/js/jjquery.min.js"></script>
        <style>
        .redborder{
            border:1px solid red;
        }
        </style>

    <script type='text/javascript'>
         function goBack() {
          window.history.back();
        }


    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_materials/'); ?>"+pro_id} , 3000);
                    
                },
                error:function(data){console.log(data.responseText);}
            });
        } 

         function delete_data_material(id) { 
        var id = id;

        if (confirm('Are you sure you want to Delete.?')) {
  

         var pro_id = $('#product_id').val();
         var main_product = $('#main_product').val();
        //alert(pro_id);
        
         $.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);
                        //
                        $('#material_bom_danger').show().html('Bom Component Deleted Successfully');
                       setTimeout(function(){location.href="<?php echo base_url('Masterlist/boms_details/'); ?>"+pro_id+"/"+main_product} , 2000);
                    
                },
                error:function(data){console.log(data.responseText);}
            });

         } else {
  
            }
        } 

        

        function delete_data_product(id) { 
        var id = id;
        if (confirm('Are you sure you want to Delete.?')) {
  

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

         } else {
  
            }
        } 


        $("#select").change(function() {
    
        var id =  this.value;
        
        var segment = $('#product_id').val();
        var main_product = $('#main_product').val();
        $.ajax({
                    type:'POST',
                    url:'<?php echo base_url('Masterlist/view_design_pro_mat'); ?>',
                    data:{id:id,segment:segment,main_product:main_product},
                    dataType:'json',
                    success:function(data){
                        //console.log(data[0].material_code);
                        //$('.grade').val(data[0].grade);
                        //$('.code').val(data[0].material_code);
                       $('#show_form').show().html(data.html);
                        
                        //$("#show_form").append(data);
                       
                    },
                    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> 