<?php 
$PageSecurity = 11;
$title = _('Print Size Master');
include('includes/SQL_CommonFunctions.inc');
if($_REQUEST['id']!='' && $_REQUEST['action']=='delete')
{
	$delete_sql="Delete from printsize_master where id='".$_REQUEST['id']."'";
	$delete_res=DB_query($delete_sql,$db);
	prnMsg( _('Record Deleted Successfully!'),'success');
	echo "<script>location.href='index.php?route=printsize_master&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
if($_REQUEST['Submit'] != '')
{
	$sql="INSERT INTO printsize_master(id,size) VALUES('','".$_POST['size']."')";
	$result=DB_query($sql,$db);
	prnMsg( _('Record Inserted Successfully!'),'success');
	echo "<script>location.href='index.php?route=printsize_master&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
if($_GET['id']!='' && $_GET['action']=='edit' && !isset($_REQUEST['Update']))
{
	$get_sql=DB_query("Select * from printsize_master where id='".$_GET['id']."'",$db);
	$get_row=DB_fetch_array($get_sql);
	
	$_REQUEST['size']=$get_row['size'];
}
if($_REQUEST['Update'] != '' && $_REQUEST['row_id']!='')
{
$update_sql="Update printsize_master SET size='".$_POST['size']."' where id='".$_REQUEST['row_id']."' ";
$update_res=DB_query($update_sql,$db);
prnMsg( _('Record Updated Successfully!'),'success');
echo "<script>location.href='index.php?route=printsize_master&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
?>
<h1 align="center"><strong>Print Size Master</strong></h1>
<form action="" method="post">
<table width="40%" border="0" cellspacing="1" cellpadding="2" align="center">
  <tr>
    <th><strong>PRINT SIZE</strong></th>
    <td>
      <input name="size" type="text" id="size" value="<?php echo $_REQUEST['size'];?>" size="30">    </td>
</table>
<p align="center">
<?php if($_GET['action']=='edit'){?>
<input type="submit" value="Update" name="Update">
<input type="hidden" name="row_id" value="<?php echo $_GET['id'];?>" id="row_id">
<?php } else {?>
<input type="submit" value="Submit" name="Submit">
<?php }?>
</p>
</form>
<br>	
<br>
<?php 
$size_sql=DB_query("Select * from printsize_master",$db);
?>
<table width="50%" border="0" cellspacing="1" cellpadding="2" align="center">
<tr>
<th><strong>SIZE</strong></th>
<th colspan="2"><strong>ACTION</strong></th>
</tr>
<?php
if(DB_num_rows($size_sql)>0){
while($size_row=DB_fetch_array($size_sql))
{ 
?>
<tr>
<td><?php echo stripslashes($size_row['size']);?></td>
<td><a href="index.php?route=printsize_master&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $size_row['id'];?>&action=edit">Edit</a></td>
<td><a href="index.php?route=printsize_master&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $size_row['id'];?>&action=delete" onClick="return confirm('Are you sure you want to delete this record?')">Delete</a></td>
</tr>
<?php } }
else
{?>
<tr>
<td colspan="2"><h3 align="center"><strong><font color="#FF0000">NO RECORD FOUND!</font></strong></h3></td>
</tr>
<?php 
}?>
</table>
<?php 
include('includes/footer.inc');
?>