<?php
include "chkuser.php";
include "includefilemng.php";

$perpage=10;
$serchstr='';
$searchsql='';


$ORDER_BY=" ORDER BY id DESC ";
$WHERE_CLOUSE=" ";
		
		// end urlstr 
		function del_real($delid)
		{
		
		$pdel="delete from franchise where id='$delid'";
		$rdel=mysql_query($pdel);
		$errormsg = "Record deleted";
		}
		if (isset($_POST['delete']))
		{
		$del_all=$_POST['chk'];
		
		$j= 0;
		for($i=0;$i<count($del_all);$i++)
		{
		if(is_numeric($del_all[$i]))
		{
		$orderid = $del_all[$i];
		del_real($orderid);
		
		
		$j = $j +1;
		}
		}
		$rmsg = $j ." records deleted";
		}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Control Panel </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="ssi.css" rel="stylesheet" type="text/css">
<script src="includenp/functions.js"></script>
<script language="javascript">
<!--

//-->
function openSWIN()
{
popwin = open("",'NewWin','height=500,width=500,toolbars=no,menubar=no,scrollbars=yes') 
}				
function openIWIN()
{
popwin = open("",'NewWin','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=632,height=370,left = 362,top = 234') 
}				
</script>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center">
  <tr>
    <td width="1%"  bgcolor="#C9C9C9"></td>
	<td width="98%"><?php include_once "top.php";?></td>
	<td width="1%"  bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
   <td width="1%"  bgcolor="#C9C9C9"></td>
    <td width="98%"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="centertable">
      <tr>
        <td><table width="94%"  border="0" align="center" cellpadding="0" cellspacing="0">

          <tr>
            <td height="40" class="bigblackTxt" style="padding-left:20px;"> <a href="franchise_add.php" class="normalLink">Add</a> :: <a href="view_franchise.php" class="normalLink">Manage</a> :: <a href="franchise_settings.php" class="normalLink">Settings</a></td>
          </tr>
          <tr>
            <td width="100%"><?php 

		  if(isset($errormsg))
		  	{
				echo display_error_msg($errormsg);
		   	}
			?>            </td>
          </tr>
          <tr>
            <td><table width="100%"  border="0" cellpadding="2" cellspacing="0">
                <tr>
                  <td width="100%" align="center"><?php 
			$sqln="SELECT * FROM franchise";			
			$resultn = mysql_query($sqln); 
			$numrows = $row = mysql_num_rows($resultn);
     			if($numrows > 0 )
				{
				?>
                      <form action="<?php echo $_SERVER['PHP_SELF'];?>?<?php echo $serchstr;?>" method="post"  name="form1" ID="form1">
                        <TABLE class=table cellSpacing=3 cellPadding=3 width="100%" align=center border=0>
                          <TR valign="top" class="thbg">
                            <TH height="20" align="center" class="bluebold">Delete</TH>
                            <TH width="10%" align="center"  class="bluebold">Edit</TH>
                            <TH width="10%" align="center"  class="bluebold">Details</TH>
                            <TH width="18%" align="center"  class="bluebold">Franchise Name</TH>
                            <TH width="19%" align="center"  class="bluebold">Name</TH>
                            <TH width="15%" align="center"  class="bluebold">Email Address</TH>
                            <TH width="19%" align="center"  class="bluebold">Address</TH>
                          </TR>
                          <?php	
			if(!isset($_GET['page'])){$_GET['page']=1;} 
			if (!isset($recordstart)) {$recordstart=1;}
			
			$recordstart = ($_GET['page']-1)*$perpage; 
			
		 	 if(isset($_GET['page']))
			 {
		     $itk = ($_GET['page']* $perpage) - $perpage + 1;
		 	 }
			 	
			 /*$sql = "SELECT
			 * from products";*/
			 
			 $sql="SELECT * FROM franchise ".$WHERE_CLOUSE.$ORDER_BY." LIMIT $recordstart,$perpage";
			 $result = mysql_query($sql); 
			 while($row = mysql_fetch_array($result))
			 {								
			 extract($row); 					 
			 ?>
                          <TR valign="top" class="trbg">
                            <TD width="9%" align=center><input name="chk[]" type="checkbox" id="chk[]" value="<?php  echo $id;?>" size="4">                            </TD>
                            <TD align="center" class="normalTxt"><a href="franchise_add.php?fid=<?php echo $id;?>"><img src="panelimages/b_edit.png" alt="" border="0"></a></TD>
                            <TD align="center" class="normalTxt"><a href="franchise_details.php?fid=<?php echo $id;?>"><img src="panelimages/pinfo.gif" alt="" border="0"></a>
                              </TD>
                            <TD align="center" class="normalTxt"><?php echo $franname;?></TD>
                            <TD align="center" class="normalTxt"><?php echo $fname;?>  <?php echo $lname;?></TD>
                            <TD align="center" class="normalTxt"><?php echo $email;?></TD>
                            <TD align="center" class="normalTxt"><?php echo $address;?></TD>
                          </TR>
                          <?php
				}
				
				?>
                          <TR valign="top" class="trbg">
                            <TD align=center><a href="JavaScript:checkAll(document.form1)" class="normalLink">Check All</a> </TD>
                            <TD align=center><a href="JavaScript:uncheckAll(document.form1)" class="normalLink">Unckeck All</a> </TD>
                            <td colspan="2"><span class="normalTxt">
                              <input name="delete" type="submit"  onClick="return docheck()" class="hbutton" id="delete" value="DELETE SELECTED">
                            </span></td>
                            <td>&nbsp;</td>
                            <TD align="left" class="normalTxt">&nbsp;</TD>
                            <TD align="left" class="normalTxt">&nbsp;</TD>
                          </TR>
                        </TABLE>
                      </form>
                    <?php 
				$query=$sqln;
				$result = mysql_query($query); 
				$totalreturned = mysql_num_rows($result); 
				$pagecount = ceil($totalreturned/$perpage);     
				$recordstart = ($_GET['page']-1)*$perpage; 
				echo page_records($_GET['page'],$pagecount,$recordstart,$perpage,$serchstr); 
				?>
                      <?php
				}
				else
				{
				?>                      
                       
                        <META HTTP-EQUIV=REFRESH CONTENT="0;URL=franchise_add.php">
                        					 
                    <?php
				}
				?></td>
                </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    <td width="1%"  bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
    <td  bgcolor="#C9C9C9" width="1%"></td>
	<td><?php include_once "footer.php";?></td>
	<td width="1%"  bgcolor="#C9C9C9"></td>
  </tr>
</table>
</body>
</html>
