<?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 Items for Merge</h3>
          </div>
          <div class="col-md-3 text-right">
            <a href="account/products/mergeitem" class="btn btn-success">Add Item For Merging</a>
          </div>
        </div>
        
        <div class="container_fluid mt-2 px-3">

         <?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%">Serial</th>                    	
                    	<th width="25%">From Item</th>
                    	<th width="25%">To Item</th>
                    	<th width="15%">Created On</th>
                    	<th width="15%">Executed On</th>                    	
                        <th width="15%" class="text-center">Action</th>
                    </tr>
                    </thead>
                    <tbody>
					<?php
					if(is_array($results) && count(array_filter($results))>0)
					{
						$arrrights = getuserrights();
						$rowindex = 0;
						if($this->uri->segment("4")!="") $rowindex = ($this->uri->segment("4") - 1) * $this->perPage;
						foreach($results as $row)
						{
							$rowindex++;
							$executedon = "";
							if($row->fld_updatedon!="") $executedon = date("d-M-Y H:i:s", strtotime($row->fld_updatedon));
							
					?>
                    <tr>
                    	<td class="text-center"><?php echo $rowindex;?>.</td>                    	
                    	<td><?php echo $row->fromproductname . " (" . $row->fld_fromproductid . ")";?></td>              
                    	<td><?php echo $row->toproductname . " (" . $row->fld_toproductid . ")";?></td>               
                    	<td><?php echo date("d-M-Y H:i:s", strtotime($row->fld_datetime));?></td>              
                    	<td><?php echo $executedon;?></td>              
                        <td align="center">
						<?php
							if($row->fld_executed=="yes")
							{
								echo "Executed";
							}
							else
							{
						?>
							<a href="account/products/executemerge/<?php echo encodeValue($row->fld_id);?>" onclick="if(!confirm('This will execute the item merge process!\nAre you sure?')) return false;" title="Execute Merge" class="btn btn-primary"><strong>Execute Merge</strong></a>
						<?php
							}
						?>
						</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>

