<?php

		$DraftCount = '';
		$ReqNo = '';
		if(!empty($Status))
{
    foreach ($Status as $St)
    {
		$DraftCount = $St->cnt;
		$ReqNo = $St->ReqNo;
	}
	//echo $ReqNo;
}?>
	
<script>
  

 function DeleteRow(rowid)
{
	    
		 id = rowid;		 
		 
	    var answer = confirm(" Do you want to delete the Requisition?")
		if (answer) 
		{ 	
	      				
			 $.ajax({ 
			data:{id:id},
			type:"POST",
			url:"<?php echo base_url() ?>requisitionform/DeleteReqNo", 
			success:function(data) {
			if(data)
			{
				$('#content').loader('hide'); 
				alert(data);
								
				 location.reload();	
				
			
			}
			else
			{
				alert("Error");	
			}			
		
		}}); 
			}
		}
       	

</script>
 <style>
span.highlight {
    background-color: yellow;
}
</style>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        <CENTER>Siddharth Industries Requisition Listing</CENTER>
       
      </h1>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-xs-12 text-right">
                <div class="form-group">
				   <?php if($DraftCount == 0)
				   {					   ?>
				   <a class="btn btn-primary" onclick="Test()" href="<?php echo base_url(); ?>RequisitionForm">Raise New Requisition</a><?php   }?>
					
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
              <div class="box">
                <div class="box-header">
                    <CENTER><h3 class="box-title"></h3></CENTER>
                    <div class="box-tools">

                        </form>
                    </div>
                </div><!-- /.box-header -->
				<?php if($DraftCount > 0 ) {?><p>
<span class="highlight">The Requisition No <b><?php echo $ReqNo;?></b> is in Draft status.</span>  Please act on the requisition.<span class="highlight">Then only you can raise New Requisition. </span>
				</p> <?php } ?>
               
                  <table id="Requisition"  class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
                   <thead style="background-color:#ddf">
				    <tr>
                      <th>Requisition No</th>
					  <th>Requisition Type</th> 
					  <th>Tot No.OfLineItem </th>
					  <th>Po CreatedLineItem</th>
					  <th>Partical PoCreatedLineItem</th>
					  <th>NewLine Item</th>					   
					  <th>Status</th>
					  <th>Requisted Date</th>					  
					  <th>Action</th>						 						                       
                 
						  </tr>
                </thead>	




                	 <?php
                    if(!empty($TotNoOfLine))
                    {
                        foreach($TotNoOfLine as $record)
                        { //print_r($record);
                    ?>
                    <tr>
					<td><?php echo $record->ReqNo ?></td>                     
					<td><?php echo $record->ReqType ?></td> 
                    <td><?php echo $record->TotalNoofLineItems ?></td> 
                     <td><?php echo $record->PolineItems ?></td> 
                      <td><?php echo $record->PartilallyLineItems ?></td> 
                     <td> <?php echo $record->newLineItem ?></td> 


					<td><?php echo $record->StatusName ?></td>                     
					<td><?php $Pdt =	new DateTime($record->CreatedDate );
							$PODate =  $Pdt->format('Y-m-d');
					echo $PODate 
					?></td>                     
					<td>   <a  	 data-toggle="tooltip"  href="<?php echo base_url().'EditRequisition?ReqNo='.$record->ReqNo.'&ReqType='.$record->ReqType; ?>"><i class="fa fa-pencil" data-toggle="tooltip" title="<?php echo $record->ReqNo; ?>  -  Click here to view Requisition details"></i>&nbsp;&nbsp;&nbsp;</a> <a data-toggle="tooltip"  onclick="DeleteRow('<?php echo $record->ReqNo; ?>' )"   ><span class="glyphicon glyphicon-trash" title="<?php echo $record->ReqNo; ?>  -  Click here to Delete Requisition details"></span></a> </td>            
                    </tr>
					
                 <?php
                        }
                    }
                    ?>
                  </table>
                  
              
                </div>
				</div>
				</div>
				</section>
				</div>
	<script>
	$(function () {
  
    $('#Requisition').DataTable({
      "paging": true,
      "lengthChange": true,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": true
	   
    }); 
  });
	</script>
	