184 lines
6.7 KiB
PHP
184 lines
6.7 KiB
PHP
<?php
|
|
include('pop_up_top.php');
|
|
$TABLENAME='unit_master';
|
|
$this_script='unit_master.php';
|
|
$acn=$_REQUEST['acn'];
|
|
?>
|
|
<?php
|
|
if(isset($acn) && $acn=='delete')
|
|
{
|
|
if($unit_id)
|
|
mysqli_query($conn,"DELETE FROM $TABLENAME WHERE unit_id ='".$unit_id."'");
|
|
}
|
|
if(isset($hid) && $hid=='1')
|
|
{
|
|
$query_main=" SET unit_name='".addslashes($unit_name)."',unit_remarks='".addslashes($unit_remarks)."', modified_by='".$_SESSION['user_id']."'";
|
|
$query_prefix='';
|
|
$query_suffix="";
|
|
$query_additional="";
|
|
if($frmacn=="Update")
|
|
{
|
|
$query_prefix='UPDATE ';
|
|
$query_suffix=" WHERE unit_id='".$unit_id."'";
|
|
$query_additional="";
|
|
$msg="Category Updated Successfully";
|
|
}
|
|
elseif($frmacn=="Add")
|
|
{
|
|
$query_prefix='INSERT INTO ';
|
|
$query_suffix="";
|
|
$query_additional="";
|
|
$msg="Category Added Successfully";
|
|
}
|
|
$sql=$query_prefix.$TABLENAME.$query_main.$query_additional.$query_suffix;
|
|
|
|
$res=@mysqli_query($conn,$sql);
|
|
|
|
if(!$res){
|
|
$msg='Error adding/updating Category. Please make sure category does not already exist.';
|
|
}
|
|
//echo "<script>location.replace('$this_script?msg=$msg')</script>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<tr>
|
|
<td height="350" valign="top" style="padding:10px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
<tr>
|
|
<td><fieldset class="bdr1" >
|
|
|
|
|
|
<center>
|
|
|
|
<?php if($acn=='add' || $acn=='update'|| $acn=='view') { ?>
|
|
<?php
|
|
if($acn=='update'|| $acn=='view')
|
|
{
|
|
$sql=@mysqli_query($conn,"SELECT * FROM $TABLENAME WHERE unit_id='".$unit_id."'");
|
|
$row=@mysqli_fetch_array($sql);
|
|
extract($row);
|
|
}
|
|
?>
|
|
<form name="f1" method="post" action="#" onsubmit="return validateForm();">
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="bdr_table">
|
|
<tr>
|
|
<td colspan="2" align="center" class="bg2">
|
|
<span class="txt">
|
|
<?php
|
|
if($msg)
|
|
echo $msg;
|
|
?>
|
|
</span></td>
|
|
</tr>
|
|
<tr>
|
|
<!-- <td width="50%" align="right" class="bg3">Unit Name:</td> -->
|
|
|
|
<td width="50%" align="left" class="bdr_td"><input placeholder="UNIT NAME" type="text" class="textbox1" name="unit_name" size="45" value="<?php echo stripslashes($unit_name)?>"></td>
|
|
</tr>
|
|
<tr>
|
|
<!--<td width="50%" align="right" class="bg3">Remarks:</td>-->
|
|
<td width="50%" align="left" class="bdr_td"><textarea placeholder="REMARK" name="unit_remarks" cols="30" rows="6"><?php echo stripslashes($unit_remarks )?></textarea></td>
|
|
</tr>
|
|
<tr>
|
|
<td width="50%" align="right" class="bg3">
|
|
<input type="hidden" name="unit_id" value="<?php echo $unit_id?>">
|
|
<input type="hidden" name="hid" value="1">
|
|
</td>
|
|
</tr><tr>
|
|
<td width="50%" align="left" class="bdr_td">
|
|
<?php if($acn=='update') { ?>
|
|
<input type="submit" name="frmacn" value="Update" class="submitbutton" style="background-color:#CCFF33;">
|
|
<?php } else if($acn=='add') { ?>
|
|
<input type="submit" name="frmacn" value="Add" class="submitbutton" style="background-color:#CCFF33;">
|
|
<?php } ?>
|
|
<input type="button" onClick="window.close();"value="Close" class="submitbutton" style="background-color:#FF5C33;">
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
</form>
|
|
|
|
<?php } else echo "<script>location.href='unit_list.php'</script>"; { ?>
|
|
<form name="f1" method="post" action="<?php echo $this_script?>">
|
|
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="bdr_table">
|
|
<tr class="bg2">
|
|
<td colspan="6" align="center"><font color="maroon"><?php echo $msg?></font></td>
|
|
</tr>
|
|
<tr class="bg2">
|
|
<td align="left" ><strong>S.No.</strong></td>
|
|
<td align="center"><strong>Unit Name</strong></td>
|
|
<td align="center"><strong>Remarks</strong></td>
|
|
<td align="center"><strong>View</strong></td>
|
|
<td align="center"><strong>Edit</strong></td>
|
|
<td align="center"><strong>Delete</strong></td>
|
|
</tr>
|
|
<?php
|
|
$sql="SELECT * FROM $TABLENAME ORDER BY unit_id";
|
|
$result = mysqli_query($conn,$sql);
|
|
$num_rows=@mysqli_num_rows($result);
|
|
$page=new Page();
|
|
$page->set_page_data($this_script,$num_rows,$records_per_page=100000,$scroll_num=0,$show_prev_next=true,$show_scroll_prev_next=true,$show_first_last=true);
|
|
$page->set_qry_string("");
|
|
$page_order_result=@mysqli_query($conn,$page->get_limit_query($sql));
|
|
$num=@mysqli_num_rows($page_order_result);
|
|
if($num>0)
|
|
{
|
|
$pageon=$_GET['page'];
|
|
$pageon=($pageon)*100000;
|
|
$count=$pageon+1;
|
|
while($row=@mysqli_fetch_array($page_order_result))
|
|
{
|
|
extract($row);
|
|
?>
|
|
<tr class="bdr_td">
|
|
<td align="left" class="bdr_td"><?php echo $count?></td>
|
|
<td align="center" class="bdr_td"> <?php echo stripslashes($unit_name)?></td>
|
|
<td align="center" class="bdr_td"> <?php echo stripslashes($unit_remarks)?></td>
|
|
<td align="center" class="bdr_td"> <a href="javascript:void(0);" onclick="javascript:sendpage('<?php echo $this_script?>?acn=view&unit_id=<?php echo $unit_id?>');"><img src='images/view.jpg' border="0" /></a></td>
|
|
<td align="center" class="bdr_td"> <a href="javascript:void(0);" onclick="javascript:sendpage('<?php echo $this_script?>?acn=update&unit_id=<?php echo $unit_id?>');"><img src='images/edit.png' border="0" /></a></td>
|
|
<td align="center" class="bdr_td"> <a href="javascript:void(0);" onclick="javascript:deleterecord('<?php echo $this_script?>?acn=delete&unit_id=<?php echo $unit_id?>');"><img src='images/drop.png' border="0" /></a></td>
|
|
</tr>
|
|
<?php
|
|
$count++;
|
|
} ?>
|
|
<tr class='bg2'><td colspan='6'><div style="margin-right:10px; ">Page <?php echo "<br>".$page->get_page_nav();?></div></td></tr>
|
|
<?php }
|
|
else
|
|
{
|
|
echo "<tr><td align='center' colspan='6' class='bdr_td'><strong>No Record Found</strong></td></tr>";
|
|
}
|
|
?>
|
|
|
|
<tr><td colspan="6" align="right">
|
|
<span>
|
|
<a href="pdf_unit_master.php" target="_blank">Print</a>
|
|
</span>
|
|
<input type="button" onclick="window.location.href='unit_master.php?acn=add'" value="Add New" class="submitbutton" style="background-color:#CCFF33;"></td></tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
<?php } ?>
|
|
</center>
|
|
</fieldset>
|
|
</td>
|
|
</tr>
|
|
</table></td>
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
var fieldArray = new Array(
|
|
new Array('unit_name'), new Array('Please enter unit name.'));
|
|
|
|
function validateForm(){
|
|
|
|
return checkform('f1',fieldArray);
|
|
}
|
|
</script>
|