Location: PHPKode > projects > EZphotopress > ezphotopress-1.0.0/admin/categories/manageCategories.php
<h3><?=$typeObject==OBJECT_ENABLE?MANAGECATEGORIES_TITLE:MANAGEDISABLECATEGORIES_TITLE?></h3>
<br>
<br>
<h3 onClick="expandcontent('sc1')" style="cursor:pointer; margin-left: auto; margin-right: auto;"><?=MANAGECATEGORIES_ADVANCED_SEARCH?></h3>
<div id="sc1" class="switchcontent" style="text-align: center; margin-left: auto; margin-right: auto;">
<form action="home.php?id=cate&action=manage&type=<?=$typeObject?>" method="post">
	<table style="margin-left: auto; margin-right: auto; text-align: left; width: 700px;" border="0" cellpadding="2" cellspacing="2">
		<tr>
			<td class="td_left">
				<?=MANAGECATEGORIES_ADVANCED_SEARCH_1?>
			</td>
			<td class="td_right">
				<input type="text" name="value" class="form">
			</td>
			<td class="td_right">
				<?=MANAGECATEGORIES_ADVANCED_SEARCH_2?>
			</td>
		</tr>
		<tr>
			<td class="td_left">
				<?=MANAGECATEGORIES_ADVANCED_SEARCH_3?>
			</td>
			<td class="td_center">
				<select name="order">
					<option value="name"><?=MANAGECATEGORIES_ADVANCED_SEARCH_4?></option>
				</select>
			</td>
			<td class="td_right">
				
			</td>
		</tr>
		<tr>
			<td class="td_left">
				<?=MANAGECATEGORIES_ADVANCED_SEARCH_5?>
			</td>
			<td class="td_center">
				<select name="maxr" class="form">
					<option value="10">10</option>
					<option value="20">20</option>
					<option value="30">30</option>
					<option value="40">40</option>
					<option value="50">50</option>
				</select>
			</td>
		</tr>
		
		<tr>
			<td colspan="3" rowspan="1" style="text-align: center;">
				<input type="submit" name="submit" value="<?=MANAGECATEGORIES_ADVANCED_SEARCH_FORM_SUBMIT?>" />
				&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="reset" name="reset" value="<?=MANAGECATEGORIES_ADVANCED_SEARCH_FORM_RESET?>" />
			</td>
		</tr>
	</table>
</form>
<br>
<br>
<h3 onClick="closeComponent('sc1')" style="cursor:pointer; margin-left: auto; margin-right: auto;"><?=MANAGECATEGORIES_ADVANCED_SEARCH_CLOSE?></h3>
</div>
<br>
<?php
//set value for deleted options
$isDeleted = $typeObject==OBJECT_ENABLE?0:1;
if (isset($_POST['submit']) && $_POST['submit'] == MANAGECATEGORIES_ADVANCED_SEARCH_FORM_SUBMIT) {
	//get all parameter
	$value = $_POST['value']; //value to search
	$order = $_POST['order']; // order result by
	$maxr = $_POST['maxr']; //max result per page
	
	$query = "select * from ".TABPREFIX."categories where id > 0 and deleted = ".$isDeleted;

	if (isset($value) && $value != "") {
		$query .= " and lower(name) like '%".strtolower($value)."%'";
	}

	$query .= " order by name";
	
	//query to count object for pagination
	$sqlCount = "select count(id) as total from ".TABPREFIX."categories where id > 0 and deleted = ".$isDeleted;

	if (isset($value) && $value != "") {
		$sqlCount .= " and lower(name) like '%".strtolower($value)."%'";
	}
} else {
	$query = "select * from ".TABPREFIX."categories where deleted = ".$isDeleted." order by name";
	$maxr = 10;
	
	//query to count object for pagination
	$sqlCount = "select count(id) as total from ".TABPREFIX."categories where deleted = ".$isDeleted;
}

//count the items
$queryCount = $db->query($sqlCount);
$resultCount = $queryCount->fetch();

if (@$resultCount['total'] > 0) {

//number of items per page
$npp = @$_GET['npp'];
$maxr = (isset($npp) && $npp != "") ? $npp : $maxr;

// start pager class
$pager = new Pager($db,$maxr);

// page number
$pager->PageNumber=@$_GET[PageNumber];

// sql query 
$pager->sql_query($query);

// Previous Page Link
if($pager->PreviousPage()) {
	echo " <a href='home.php?id=cate&action=manage&npp=".$maxr."&PageNumber=".$pager->PreviousPage()."'>Previous</a>";
}
	
// print page link number
foreach($pager->PageLink() as $key=>$value) {
	if($pager->PageNumber()==$key) {		
		echo "<b>".$key."</b>";	
	} else {
		echo " <a href='home.php?id=cate&action=manage&npp=".$maxr."&PageNumber=".$key."'>".$key."</a>";		
	}
}
	
// Next Page Link
if($pager->NextPage()) {
	echo " <a href='home.php?id=cate&action=manage&npp=".$maxr."&PageNumber=".$pager->NextPage()."'>Next</a>";	
}

?>
<br>
<table style="margin-left: auto; margin-right: auto; text-align: left; width: 600px;" border="0" cellpadding="2" cellspacing="2">			
	<tr>
		<td class="td_right">
			<?=MANAGECATEGORIES_TABLE_NAME?>
		</td>
		<td class="td_right">
			
		</td>
	</tr>
	<?php
	echo"<hr>";
	// print records
	foreach($pager->mysql_fetch() as $row) {
		extract($row);
		?>
		<tr>
			<td class="td_right">
				<?php echo $name; ?>
			</td>
			<td>
				<?php 
				if ($isDeleted == 0) { // object enable
					$msg = MANAGECATEGORIES_QUESTION_DISABLE; 
					?>
					<!-- modify -->
					<a href="home.php?id=cate&action=modify&catid=<?php echo $id; ?>" class="error"><img src="images/modify.png" alt="<?=MANAGECATEGORIES_TOOLTIP_MODIFY?>" title="<?=MANAGECATEGORIES_TOOLTIP_MODIFY?>"></a>
					&nbsp;
					<!-- disable -->
					<a href="home.php?id=cate&action=enable&enable=off&catid=<?php echo $id; ?>" class="error" onclick="return confirm('<?php echo $msg; ?>')"><img src="images/unpublished.png" alt="<?=MANAGECATEGORIES_TOOLTIP_DISABLE?>" title="<?=MANAGECATEGORIES_TOOLTIP_DISABLE?>"></a>
					<?php 	
				} else {
					$msg = MANAGEDISABLECATEGORIES_QUESTION_ENABLE;
					$msgDelete = MANAGEDISABLECATEGORIES_QUESTION_DELETE; 
					?>
					<!-- delete -->
					<a href="home.php?id=cate&action=delete&catid=<?php echo $id; ?>" class="error" onclick="return confirm('<?php echo $msgDelete; ?>')"><img src="images/delete.png" alt="<?=MANAGEDISABLECATEGORIES_TOOLTIP_DELETE?>" title="<?=MANAGEDISABLECATEGORIES_TOOLTIP_DELETE?>"></a>
					&nbsp;
					<!-- enable -->
					<a href="home.php?id=cate&action=enable&enable=on&catid=<?php echo $id; ?>" class="error" onclick="return confirm('<?php echo $msg; ?>')"><img src="images/published.png" alt="<?=MANAGEDISABLECATEGORIES_TOOLTIP_ENABLE?>" title="<?=MANAGEDISABLECATEGORIES_TOOLTIP_ENABLE?>"></a>
					<?php 	
				}
				?>
				
			</td>
		</tr>
		<?php
	}
	?>
</table>
<?php
} else {
	?>
	<p class="ok">
		<?=MANAGECATEGORIES_NO_FOUND?>
	</p>	
	<?php 
}

?>
Return current item: EZphotopress