<!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><?php 
                              $so_get_pro = so_get_pro($this->uri->segment('3'));
                              if(!empty($so_get_pro)){
                              echo product_name($so_get_pro);
                              echo  " : ";
                              echo get_in_balance($so_get_pro)-get_out_balance($so_get_pro); 
                             }
                             ?></h4>

                        </div>
                    </div>


                    
                </div>


				
				<div class="row">

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

                          

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


                    <div class="col-12">

                        <div class="card">
                            <button id="so_id" name="so_id"  onclick="production_plan_status('<?php  echo $this->uri->segment('3'); ?>')" class="badge badge-success">Finish Production</button>
                         
                            
                            <div class="card-body">
                               <div class="table-responsive">
                                    <table id="example5" class="display" style="min-width: 845px; font-size: 12px;" >
                                        <thead>
                                            <tr>
                                                <th>Code</th>
                                                <th>Items</th>
                                                <th>In Stock</th>
                                                 <th>Bom Required</th>
                                                  
                                                  <th>Production Qty</th>

                                                  <th>Status</th>
                                                  <th>Status</th>
                                                    <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php 

                                            if(!empty($get_semi_data))
                                            {

                                             
                                            foreach ($get_semi_data as $value) {
                                               //$condition = requisition_type($value['material_id']);
                                           // if($condition==1)
                                            //{   

                                               $printed_product = get_child_pro_type($value['product_id']);
                                              

                                              if($printed_product==1){

                                            ?>
                                            <tr>
                                                <td><strong><?php echo product_code($value['product_id']); ?></strong></td>
                                                <td><strong><?php echo product_name($value['product_id']); ?></strong></td>
                                                <td><?php $total_in_stock =  get_in_balance($value['product_id'])-get_out_balance($value['product_id']);  ?>
                                                    
                                                    <?php echo $total_in_stock; ?>
                                                </td>
                                                <td><?php echo $value['quantity']; ?></td>
                                                

                                                <?php
                                                 $condi =   $total_in_stock-$value['quantity']; 
                                                  if($value['quantity']  > $condi){ ?>
                                                    <td style="color:red;font-weight: bold;"><?php echo abs($total_in_stock-$value['quantity']); ?></td>

                                                <?php
                                                  }else{ ?>

                                                    <td style="color:green;font-weight: bold;"><?php echo $total_in_stock-$value['quantity']; ?></td>
                                                  <?php

                                                   }

                                                ?>


                                                <td>
                                                    
                                                    <?php


                                                     $product = product_name($value['product_id']);

                                                     $so_id = $value['so_id'];

                                                     
                                                      $check_status = check_production_status($so_id,$product); ?>
                                                      
                                                     <?php if($check_status !=""){ 

                                                      echo " &check;"; 

                                                       }else{ 

                                                       echo "&#x2718;";

                                                       }   ?>

                                                </td>
                                                
                                                <td>
                                                    <?php   //$status = check_status_machine($value['product_id']); ?>

                                                   <?php 
                                                   		$status = check_status_machine($value['product_id'],$value['so_id']);
                                                       
                                                        ?>

                                                    <?php if($status == 1){ ?>
                                                       <span class="badge badge-danger"> Closed</span>
                                                    <?php }else{ ?>
                                                        <span class="badge badge-success">Active</span>
                                                    <?php } ?>

                                                </td>
                                                
                                                
                                                <td> <a href="<?php $so_id = check_so_for_bom($value['so_id']); echo base_url('Requisition/view_Data_production_plan/'.$so_id);?>/<?php echo $value['product_id']; ?>" class="badge badge-primary">Add Production</a>
                                                    

                                                </td>

                                              

                                            </tr>
                                            <?php } } } ?>
                                        </tbody>
                                    </table>
                                </div>


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





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


          
                                    
	<!-- 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'>

    </script>   

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

<script type="text/javascript">


    

    
     function production_plan_status(id) { 
          var id =  id;
          var so_id = id; 

           if (confirm('Are you sure you want to Add Production.?')) {
  
         
     $.ajax({
                type:'POST',
                url:'<?php  echo base_url('Requisition/add_so_po_status'); ?>',
                data:{so_id:so_id},
                dataType:'json',
                success:function(data){
                    //console.log('first'+data.status);
                    if(data.status === 'true'){
                         console.log(data);
                    $('#add_add_plan_success').show().html('Plan added Successfully');
                    setTimeout(function(){location.href="<?php echo base_url('Requisition/production_plan'); ?>"} , 3000);
                 }else if(data.status === 'false'){


                     $('#warning').show().html('No Production Added..!');

                 }
                       //$('#bom_details').show(data);
                   
                },
                error:function(data){console.log(data.responseText);}
            });
            }
        } 

</script>

<!-- 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>