<!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>Product</h4>
                        </div>
                    </div>
                    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
                       <button type="button" class="btn btn-rounded btn-success" onclick="btnExport_monthly();"><span class="btn-icon-left text-success"><i class="fa fa-download color-success"></i>
                                    </span>Download</button>
                    </div>
                </div>
				
				<div class="row">

                    
                    <div class="col-12">
                        <div class="card">
                            <div class="card-header">
                               <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bd-example-modal-lg">Add Product</button>
                                    <div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
                                        <div class="modal-dialog modal-lg">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                  
                                                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">
                                          <?php echo form_open(base_url(''),array('class'=>"form-horizontal add_products", 'id'=>"add_products")); ?>   

                      <?php if($this->session->flashdata('product_success')){ ?>
                            <div class="alert alert-success solid" style='text-align:center;'><?php echo $this->session->flashdata('product_success'); ?></div>
                        <?php } ?>           

                         <div class="col-xl-12 col-xxl-12 col-sm-12">
                            <div class="card">
                                <div class="card-header">
                                    <h5 class="card-title">Add Products</h5>
                                </div>
                                <div class="card-body">
                                    <div id='product_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-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Product Type</label>
                                                    <select name="product_type" id="product_type" required class="form-control" tabindex="-98">
                                                        <option value="">Select Product Type</option>
                                                        <?php foreach ($get_pro_type as $get_pro_type) { ?>
                                                            <option value="<?php echo $get_pro_type['id']; ?>"><?php echo $get_pro_type['name']; ?></option>

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

                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Product Code</label>
                                            <input type="text" name="pro_code" readonly="readonly" id="pro_code" placeholder="Product Code" class="form-control">
                                                </div>
                                            </div>

                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Ref No</label>
                                            <input type="text" name="ref_no"  id="ref_no" placeholder="Product Ref No#"  value="RA/" class="form-control">
                                                </div>
                                            </div>
                                           
                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Description</label>
                                                        <input type="text" name="name" required id="name" placeholder="Product Name" class="form-control">
                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Product Weight</label>
                                                        <input type="text" name="weight" required id="weight" placeholder="Product Weight" class="form-control">
                                                </div>
                                            </div>

                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Appearance</label>
                                                        <input type="text" name="apperence"  required id="apperence" placeholder="Appearance" class="form-control">
                                                </div>
                                            </div>

                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Engrave</label>
                                                        <input type="text"  name="engrave" id="engrave" placeholder="Engrave" class="form-control">
                                                </div>
                                            </div>
                                            

                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Color Code</label>
                                                        <input type="text"  name="color_code" id="color_code" placeholder="Color Code" class="form-control">
                                                </div>
                                            </div>
                                            
                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Color Ratio</label>
                                                        <input type="text"  name="color_ratio" id="color_ratio" placeholder="Color Ratio" class="form-control">
                                                </div>
                                            </div>

                                            <div class="col-lg-6 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Remarks</label>
                                                        <input type="text"  name="remarks" id="remarks" placeholder="Remarks" class="form-control">
                                                </div>
                                            </div>
                                            <input type="hidden" name="user_id" id="user_id" value="<?php echo $this->session->userdata('id');?>">
                                        </div>
                                   
                                </div>
                            </div>
                        </div>



                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                <button type="submit" id="dis_submit" class="btn btn-primary">Submit <i class="icon-arrow-right14 position-right"></i></button>
                            </div>
                        </div>
                    </div>
                </div>
                                     <?php form_close();?>
                            </div>
                            <div class="card-body">
                                <?php if($this->session->flashdata('product_danger')){ ?>
                                    <div class="alert alert-danger solid " style='text-align:center;'><?php echo $this->session->flashdata('product_danger'); ?></div>
                                <?php } ?>
                                 <div id='product_danger' class='alert alert-danger solid' style='display:none;width: 30%;'></div>
                                <div class="table-responsive">
                                    <table id="example5" class="display" style="min-width: 1200px">
                                        <thead>
                                            <tr>
                                                <th>Product Description</th>
                                                <th>Code</th>
                                                <th>Prodyct Type</th>
                                                <th>Weight</th>
                                                <th>Appearance</th>
                                               
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                             <?php
                                                if(!empty($get_products)){
                                                    
                                             foreach($get_products as $get_products){ ?>
                                             <?php if($get_products['name']!="") {?>
                                            <tr>
                                                <td><?php echo $get_products['name']; ?></td>

                                                <td><strong><?php echo $get_products['pro_code']; ?></strong></td>

                                                <?php if($get_products['product_type']==1) {?>
                                                <td><span class="badge badge-success"><?php echo get_product_type($get_products['product_type']); ?></span></td>
                                            <?php }else if($get_products['product_type']==2) {?>

                                                <td><span class="badge badge-secondary"><?php echo get_product_type($get_products['product_type']); ?></span></td>
                                            <?php }else if($get_products['product_type']==3) { ?>
                                                 <td><span class="badge badge-warning"><?php echo get_product_type($get_products['product_type']); ?></span></td>
                                             <?php } else if($get_products['product_type']==4) { ?>
                                                 <td><span class="badge badge-danger"><?php echo get_product_type($get_products['product_type']); ?></span></td>
                                            <?PHP } else if($get_products['product_type']==5) { ?>
                                                 <td><span class="badge badge-primary"><?php echo get_product_type($get_products['product_type']); ?></span></td>
                                            <?PHP } ?>
                                               <td><?php echo $get_products['weight']; ?></td>
                                               <td>(<?php echo $get_products['apperence']; ?>)</td>
                                            
                                                 
                                                 <td>
                                                    <a href="<?php echo base_url('Masterlist/edit_get_products/'.$get_products['id']); ?>" class="btn btn-sm btn-primary"><i class="la la-pencil"></i></a>
                                                    <a href="javascript:void(0);" onclick="delete_data(<?php echo $get_products['id']; ?>)" class="btn btn-sm btn-danger"><i class="la la-trash-o"></i></a>
                                                    
                                                     <button type="button" class="badge badge-warning" data-toggle="modal" data-target=".bd-example-modal-lg1" onclick="get_data('<?php  echo $get_products['id']; ?>')">View</button>

                                                     <a href="<?php echo base_url('Masterlist/add_products_mold/'.$get_products['id']); ?>" class="badge badge-"  ><i class="la la-pencil"></i>Set Mould</a>
                                                        <?php /*if($get_products['qc_status']==0){*/ ?>
                                                     
                                               
                                                </td>                                            
                                            </tr>
                                           <?php } } }?>
                                        </tbody>
                                    </table>
                                </div>


                            </div>
                        </div>
                    </div>





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


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

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

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


    </div>

                <div class="modal fade bd-example-modal-lg1" tabindex="-1" role="dialog" aria-hidden="true">
                                        <div class="modal-dialog modal-lg">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                  
                                                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">
                                              
                                            <div class="col-xl-12 col-xxl-12 col-sm-12">
                                                <div class="card">
                                                    <div class="card-header">
                                                 <h5 class="card-title">Product Details</h5>
                                                    </div>
                                                   
                                                   <div class="card-body" id="products_details">
                                              
                                                    </div>
                                                </div>
                                            </div>



                                                </div>
                                                <div class="modal-footer">
                              
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                                                  
                                                </div>
                                            </div>
                                        </div>
                                    </div>
            
                                  </div>
    <!--**********************************
        Main wrapper end
    ***********************************-->

    <!--**********************************
        Scripts
    ***********************************-->
	<!-- Required vendors -->
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
       

    <script type='text/javascript'>

        

         $("#product_type").change(function() {

                
    
                var id = $('#product_type').val();

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

    });
        
    var products = $('#add_products');   
    
    products.on('submit',function(e){

$("#dis_submit").attr('disabled', true);
        e.preventDefault();
        
        var add_products = products.serialize();
        
      
            $.ajax({
                type:'POST',
                url:'<?php echo base_url('Masterlist/products'); ?>',
                data:add_products,
                dataType:'json',
                success:function(data){
                    console.log('first'+data.status);
                    if(data.status === 'true'){
                        console.log('second'+data.status);
                        $('#product_success').show().html('Product added Successfully').hide(3000);
                       setTimeout(function(){location.href="<?php echo base_url('Masterlist/products'); ?>"} , 3000);
                    }else{
                        console.log('third'+data);          
                    }
                },
                error:function(data){console.log(data.responseText);}
            });
       // }
    });

    function delete_data(id) { 
        var id = id;
        if (confirm('Are you sure you want to Delete.?')) {
  
         $.ajax({
                type:'POST',
                url:'<?php echo base_url('Masterlist/delete_product/'); ?>'+id,
                data:id,
                dataType:'json',
                success:function(data){
                    console.log('first'+data.status);
                    
                        console.log('second'+data.status);
                        //debugger;
                        $('#product_danger').show().html('Product Deleted Successfully');
                       setTimeout(function(){location.href="<?php echo base_url('Masterlist/products'); ?>"} , 3000);
                    
                },
                error:function(data){console.log(data.responseText);}
            });
        } 
    }

        
         function get_data(id) { 
              var id =  id;
              //alert(id);

              $.ajax({
                        type:'POST',
                        url:'<?php echo base_url('Masterlist/view_products_details'); ?>',
                        data:{id:id},
                        dataType:'json',
                        success:function(data){
                            //console.log('first'+data.status);
                            //if(data.status === 'true'){
                             $('#products_details').show().html(data.html);
                               //$('#bom_details').show(data);
                           /* }else{
                                //console.log('third'+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>