<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
      <div class="main my-0">
        <div class="row mt-3 mx-0">
          <div class="col-md-9">
            <h3>Manage <?php echo ucfirst($mgmtname);?></h3>
          </div>
        </div>
        
        <div class="container_fluid mt-2 px-3">
		<form name="frmsearch" method="get" action="account/<?php echo $mgmtname;?>/admin">
         <table class="webforms sttbl bg-light my-0 table-responsive-sm">
          <tr>
           <td class="pr-0" width="20%"><input type="text" name="search" size="20" value="<?php echo $this->input->get("search");?>" placeholder="search by name"></td>
           <td>
           	<button class="btn btn-dark pt-0 pb-1 px-2">Go</button>
           </td>
          </tr>
         </table>
       </form>
         <?php
			if($this->session->flashdata("message")!="" && $this->session->flashdata("alerttype")!="")
			{
         ?>
         <div class="text-center my-4">
			 <span class="alert <?php echo $this->session->flashdata("alerttype");?>"><?php echo $this->session->flashdata("message");?></span>
         </div>
         <?php
			}
         ?>
         
         <table class="table mt-2 table-responsive-sm">
		 <form name="frmlisting" id="frmlisting" action="<?php echo base_url()."account/".$mgmtname;?>" method="post" onsubmit=" return checkboxvalidate();">
                <thead>
                	<tr>
                    	<th width="5%">SRNo.</th>                   	
           
                    
                    	<th width="35%">Name</th>
                    	<th width="15%">Purchase</th>
                    	<th width="10%">Stock</th>
       
                    	<th width="10%">Posted On</th>
                        <th width="10%" class="text-center">Status</th>
                        <th width="10%" class="text-center">Action</th>
                    </tr>
                    </thead>
                    <tbody>
					<?php
					if(is_array($results) && count(array_filter($results))>0)
					{
						$rowindex = 0;
						foreach($results as $row)
						{
							$rowindex++;
	

					?>
                    <tr>
                    	<td class="text-center"><?php echo $rowindex;?>.</td>                    	
                    	              
                    	         
                    	<td><?php echo $row->fld_name;?></td>               
						<td><a href="account/purchase?warehouseid=<?php echo $row->fld_id;?>">View Purchase</a></td>              
						<td><a href="account/stockstatus?warehouseid=<?php echo encodeValue($row->fld_id);?>">View Stock</a></td>                                     
                    	<td><?php echo date("d-M-Y", strtotime($row->fld_datetime));?></td>
                        <td align="center">
							<?php
							if($row->fld_status == "active")
							{
							?>
							<a id="chstatus_<?php echo $row->fld_id;?>" style="cursor:pointer" class="text-success" onclick="changestatus('<?php echo base_url() ?>','<?php echo $row->fld_id; ?>', '<?php echo $mgmtname;?>')"><i class="fa fa-check fa-lg" aria-hidden="true"></i></a>
							<input type="hidden" id="status_<?php echo $row->fld_id;?>" value="active" />
							<?php
							}
							else
							{
							?>
							<a id="chstatus_<?php echo $row->fld_id;?>" style="cursor:pointer" class="text-danger" onclick="changestatus('<?php echo base_url() ?>','<?php echo $row->fld_id; ?>', '<?php echo $mgmtname;?>')"><i class="fa fa-times fa-lg" aria-hidden="true"></i></a>
							<input type="hidden" id="status_<?php echo $row->fld_id;?>" value="inactive" />
							<?php
							}
							?>
                        </td>
                        <td align="center">
							<a href="account/<?php echo $mgmtname;?>/manage/<?php echo encodeValue($row->fld_id);?>" class="text-success" title="Edit"><span class="fa fa-edit fa-lg"></span></a><span class="ml-2"></span></a>
							
							<!--<a href="account/delcomm/<?php echo $mgmtname;?>/<?php echo encodeValue($row->fld_id);?>" onclick="if(!confirm('This will delete the info. permanently!\nAre you sure?')) return false;" class="text-danger" title="Delete"><span class="fa fa-trash-o fa-lg"></span></a>//-->
						</td>
                    </tr>
                    <?php
						}
							
					}
					else
					{
                    ?>
                    <tr><td colspan="8" style="text-align:center">Record not found!</td></tr>
                    <?php
					}
                    ?>
                    
                    
                    </tbody>
                </table>
                 
	         <div class="clearfix"></div>
          
        </div>
        <div id="paginate" class="row">
			<?php echo $this->ajax_pagination->create_links(); ?>
        </div>
            
        </div>

