
<script type="text/javascript">
	$(document).ready(function(){
		
		$("#checkall").click(function(){
			if(this.checked){
				$(".check_class").attr("checked",true);					
			}else{
				$(".check_class").attr("checked",false);					
			}
		});
		
		//$.tablesorter.defaults.sortList = [[1,0]];
/*		$(".tablesorter").tablesorter({
			headers: {
				0: { sorter: false },
				1: { sorter: false },
				4: { sorter: false },
				5: { sorter: false }
			}
		});
*/		
		//$(".tablesorter").tablesorterpackager({container: $("#packager")}); 
		
	});
	
function change_status(package_id,status){

	showLoader(1);

	$.ajax({
	  url: "packagelist.php",
	  data: 'act=change_status&package_id='+package_id+'&status='+status,
	  success: function(msg){
			showLoader(0);
		  	$(".info").html(msg);
		  	$("#status_msg").show();
		  	$("#status_msg").html(msg);
		  	
		  	if(status==0){
			  	$("#td_status_"+package_id).html("<a href=\"javascript:void(0)\" onclick=\"change_status('"+package_id+"','1')\" ><img src=\"images/publish.gif\" alt=\"Publish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}else{
			  	$("#td_status_"+package_id).html("<a href=\"javascript:void(0)\" onclick=\"change_status('"+package_id+"','0')\" ><img src=\"images/unpublish.gif\" alt=\"Unpublish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}
	  }
	});
}

function validate_all(){
	if($("#select_action").val()==''){
		$("#msg_select_action").html('Please Select action');
		$("#select_action").addClass('jquery_err');
		$("#select_action").focus();
		return false;
	}else{
		$("#msg_select_action").html('');
		$("#select_action").removeClass('jquery_err');
	}	

	if($(".check_class:checked").length == 0){
		$("#msg_select_action").html('Please Select atleast one checkbox');
		return false;
	}else{
		$("#msg_select_action").html('');
	}	
}

function changeOrder(package_id,package_order,position)
{
	location.href ="packagelist.php?act=order&package_id="+package_id+"&package_order="+package_order+"&position="+position;
}

</script>


<div id="content" class="box">

	<h1>packages &raquo; package List</h1>

	<?php if(isset($successMsg) && $successMsg!=''){ ?>
		<p class="msg done"><?php echo $successMsg; ?></p>
	<?php } ?>
	
	<?php if(isset($failedMsg) && $failedMsg!=''){ ?>
		<p class="msg error"><?php echo $failedMsg; ?></p>
	<?php } ?>

	<p id="status_msg" class="msg info" style="display:none">&nbsp;</p>
	
	<div class="loading_image" style="display:none"><img src="images/loading.gif" > </div>

    <form id="select_all_frm" name="select_all_frm" method="post" action="" onsubmit="return validate_all();">

		<table class="tablesorter" width="100%"> <!-- Sort this TABLE -->
			<thead>
				<tr>
					<th width="3%" style="text-align:center"><input type="checkbox" id="checkall" name="checkall" > </th>
				  <th width="6%">Order</th>
				  <th width="17%">Name</th>
				  <th width="36%">Short Description</th>
				  <th width="14%">Slug</th>
				  <th width="9%" style="text-align:center">Status</th>
				  <th width="15%" style="text-align:center">Action</th>
			  </tr>
			</thead>
			<tfoot>
				<tr class="bg">
				    <td colspan="9" class="arrow-01" style="border-right:0px none">
							<select name="action_val" id="action_val" class="input-text">
							    
								<?php if($DELETE_ACCESS && $EDIT_ACCESS){ ?>
								    <option value="">Select Action</option>
								    <option value="delete_all">Delete selected</option>
								    <option value="activate_all">Activate selected</option>
								    <option value="inactivate_all">Inactivate selected</option>
								    
								<?php }else if($DELETE_ACCESS){ ?>
								    <option value="">Select Action</option>
								    <option value="delete_all">Delete selected</option>
								    
								<?php } else if ($EDIT_ACCESS){ ?>
								    <option value="activate_all">Activate selected</option>
								    <option value="inactivate_all">Inactivate selected</option>
								
								<?php } ?>
							</select>&nbsp;
							<input type="submit" value="OK" id="submit" name="submit" />&nbsp;
							<span id="msg_select_action" class="message">&nbsp;</span>					</td>
					
<!--				    <td colspan="3" class="arrow-01" style="border-left:0px none" >
						<div id="packager" class="packager">
							<img src="images/first.png" class="first"/>
							<img src="images/prev.png" class="prev"/>
							<input type="text" disabled="disabled" class="packagedisplay"/>
							<img src="images/next.png" class="next"/>
							<img src="images/last.png" class="last"/>
							<select class="packagesize">
								<option selected="selected" value="20">20</option>
								<option value="50">50</option>
								<option  value="100">100</option>
								<option  value="150">150</option>
							</select>
						</div>
					</td>-->
				</tr>
			</tfoot>
			<tbody>
				
				<?php if($packagesDetails && count($packagesDetails) > 0 ){ $caOrder =1; 
						foreach ($packagesDetails as $packages){  ?>
						<tr>
							<td class="t-center ">
								<input type="checkbox" name="check[]" id="check[]" value="<?php echo $packages->package_id; ?>" class="check_class" />							</td>
							<td><?php echo $caOrder; ?>							</td>
							<td>
								<?php if($EDIT_ACCESS){ ?>	
									<a href="addpackage.php?act=edit&package_id=<?php echo $packages->package_id; ?>" class="edit"><?php echo $packages->package_title;  ?></a>
								<?php }else{ ?>	
									<?php echo $packages->package_title;  ?>
								<?php } ?>							</td>
							<td><?php echo $packages->package_short_desc;  ?></td>
							<td><?php echo $packages->package_slug;  ?></td>
							
							<td style="text-align:center" id="td_status_<?php echo $packages->package_id ?>">
								<?php if($EDIT_ACCESS){ ?>	
									<?php if($packages->package_status=='1'){?><a href="javascript:void(0)" onclick="change_status('<?php echo $packages->package_id ?>','1')" ><img src="images/publish.gif" alt="Publish" width="14" height="15" border="0" /></a> <?php }else{?><a href="javascript:void(0)" onclick="change_status('<?php echo $packages->package_id ?>','0')" ><img src="images/unpublish.gif" alt="Publish" width="14" height="15" border="0" /></a><?php }?>	
								<?php }else{ ?>
									<?php if($packages->package_status=='1'){?><img src="images/publish.gif" alt="Publish" width="14" height="15" border="0" /><?php }else{?><img src="images/unpublish.gif" alt="Publish" width="14" height="15" border="0" /><?php }?>	
								<?php } ?>							</td>
							<td class="t-center">
									<?php if($EDIT_ACCESS){ ?>	
										<a href="addpackage.php?act=edit&package_id=<?php echo $packages->package_id; ?>" class="edit"><img src="images/edit.png" alt="Edit" border="0" title="Edit Record" /></a> 
									<?php } ?>	
										<a onclick="javascript:if(confirm('Are you sure to delete ? ')){location.href='packagelist.php?act=delete&package_id=<?php echo $packages->package_id; ?>'}"><img src="images/delete.gif" alt="Delete"  border="0" title="Delete Record" /></a>							</td>
						</tr>
						
				<?php $caOrder++; } }else { ?>
						<tr>
							<td colspan="7" align="center">No Record Found</td>
						</tr>
				<?php } ?>
			</tbody>
		</table>
		
  </form>

</div> <!-- /content -->