| Current Path : /var/www/html/mmishra/iws8/html/pcstore/backupxxxxxxx/ |
| Current File : /var/www/html/mmishra/iws8/html/pcstore/backupxxxxxxx/entry_productxxx.php |
<?php
include "../page_header.inc";
$tbl = $product_master;
echo "<b>Computer Entry</b><br>";
//include "item.php";
$myproduct = new product($rid, $tbl, $con);
$myproduct->get_data_from_form();
switch ($_REQUEST["submit"]){
case "SAVE":
$myproduct->insert_update_table();
break;
case "DELETE":
$myproduct->delete_from_table();
break;
}
$myproduct->show_form();
include "../page_footer.inc";
exit;
class computer {
var $rid;
var $tbl;
var $con;
var $row_id;
var $pc_code;
var $series_code;
var $description;
var $cost;
var $fabrication_year;
var $status;
var $remark;
function computer($rid,$tbl,$con){
$this->rid = $rid;
$this->tbl = $tbl;
$this->con = $con;
}
function get_data_from_form(){
$this->row_id = $_REQUEST['row_id'];
$this->pc_code = $_REQUEST['pc_code'];
$this->series_code = $_REQUEST['series_code'];
$this->description = $_REQUEST['description'];
$this->cost = $_REQUEST['cost'];
$this->fabrication_year = $_REQUEST['fabrication_year'];
if ($fabrication_year == "") $fabrication_year = date('Y');
$this->status = $_REQUEST['status'];
$this->remark = $_REQUEST['remark'];
}
function insert_update_table(){
if (mysql_num_rows(mysql_query("select * from $this->tbl where row_id=$this->rid", $this->con))){
$sql = "update $this->tbl set pc_code='$this->pc_code',series_code=$this->series_code,description='$this->description',cost=$this->cost,fabrication_year=$this->fabrication_year,status='$this->status',remark='$this->remark' where row_id=$this->rid";
}else{
$sql = "insert into $this->tbl(pc_code,series_code,description,cost,fabrication_year,status,remark) values('$this->pc_code',$this->series_code,'$this->description',$this->cost,$this->fabrication_year,'$this->status','$this->remark')";
}
//echo $sql;
mysql_query($sql, $this->con);
access_log($sql, $this->con);
}
function delete_from_table(){
$sql = "delete from $this->tbl where row_id=$this->rid";
mysql_query($sql, $this->con);
access_log($sql, $this->con);
}
function show_form(){
$status_array = array('new', 'old', 'issued','scrap');
$rs = mysql_query("select * from series_master order by name", $this->con);
if(!$rs) error_message(sql_error());
echo "Select Series <select name='series_code' onchange=\"javascript:document.location.href='" . $_SERVER["SCRIPT_NAME"] . "?series_code=' + this.value\"><option value=''>Add New</option>";
while ($o = mysql_fetch_object($rs)){
$series_code_id = $o->row_id;
$name = $o->name;
$stock_qty = $o->stock_quantity;
$issued_qty = $o->issued_quantity;
$scrap_qty = $o->scrap_quantity;
echo "<option value='$series_code_id'";
if ($this->series_code == $series_code_id) echo " selected";
echo ">$name ($stock_qty, $issued_qty, $scap_qty)</option>";
}
echo "</select> <a href='entry/master_series.php?row_id=0'>New series</a><br>";
echo "<table>";
echo "<tr><th>ID</th><th>PC Code</th><th>Description</th><th>Cost</th><th>Fabrication Year</th><th>Status</th><th>Remark</th></tr>";
if ($this->rid == 0){
echo "<tr><td>New</td>";
echo "<td><input type='text' name='pc_code' value='$this->pc_code' size='20'></td>";
echo "<td><input type='text' name='description' value='$this->description' size='20'></td>";
echo "<td><input type='text' name='cost' value='$this->cost' size='10'</td>";
echo "<td><input type='text' name='fabrication_year' value='$this->fabrication_year' size='10'></td>";
echo "<td><select name='status'>";
foreach ($status_array as $s){
echo "<option value='$s'>$s</option>";
}
echo "</select></td>";
echo "<td><input type='text' name='remark' value='$this->remark' size='30'></td></tr>";
echo "<tr><td colspan='6' align='center'><input type='submit' name='submit' value='SAVE'></td></tr>";
}else{
echo "<tr><td colspan='6'><a href='" . $_SERVER["SCRIPT_NAME"] . "?series_code=$this->series_code&description=$this->description'>New computer</a> <div align='right'>(<a href='report/form_computer_issue.php?pc_code=$this->pc_code'>Configuration of Computer ID $this->rid</a>)</div></td></tr>";
}
$rs = mysql_query("select * from $this->tbl where series_code=$this->series_code order by pc_code", $this->con);
if(!$rs) error_message(sql_error());
while ($o = mysql_fetch_object($rs)){
$i++;
$this->row_id = $o->row_id;
$this->pc_code = $o->pc_code;
$this->description = $o->description;
$this->cost = $o->cost;
$this->fabrication_year = $o->fabrication_year;
$this->status = $o->status;
$this->remark = $o->remark;
$j = $this->row_id - 1;
if ($this->rid == $this->row_id){
echo "<tr><th><a name='$j'></a>$this->rid</a><input type='hidden' name='row_id' value='$this->rid'></th>";
echo "<td><input type='text' name='pc_code' value='$this->pc_code' size='20'></td>";
echo "<td><input type='text' name='description' value='$this->description' size='20'></td>";
echo "<td><input type='text' name='cost' value='$this->cost' size='10'></td>";
echo "<td><input type='text' name='fabrication_year' value='$this->fabrication_year' size='10'></td>";
echo "<td><select name='status'>";
foreach ($status_array as $s){
echo "<option value='$s'";
if ($s == $this->status) echo " selected";
echo ">$s</option>";
}
echo "</select></td>";
echo "<td><input type='text' name='remark' value='$this->remark' size='30'></td></tr>";
echo "<tr><td colspan='6' align='center'><input type='submit' name='submit' value='SAVE'> <input type='submit' name='submit' value='DELETE'></td></tr>";
}else{
echo "<tr><td>$this->row_id</td><td><a href='" . $_SERVER["SCRIPT_NAME"] . "?series_code=$this->series_code&row_id=$this->row_id#$j'>$this->pc_code</a></td><td>$this->description</td><td align='right'>$this->cost</td><td align='center'>$this->fabrication_year</td><td>$this->status</td><td>$this->remark</td></tr>";
}
}
echo "</table>";
echo "<font color='red' size='+1'>Total: $i</font>";
}
function show_list($pc_code){
//$pc_code = $_REQUEST["pc_code"];
echo "Enter PC Code <input type='text' name='pc_code' value='$pc_code' size='15'> ";
echo "<input type='submit' name='submit' value='SEARCH'>";
echo "<table width='100%'><tr><th width='10%'>ID</th><th width='25%'>PC Code</th><th width='35%'>Description</th><th width='15%'>Fab.Year</th><th width='15%'>Status</th></tr>";
$sql1 = "select row_id,series_code,pc_code,description,fabrication_year,status from pc_master where ";
if ($pc_code) $sql1 .= "pc_code='$pc_code' and ";
$sql1 .= "status in('old', 'new') order by series_code, pc_code";
$rs1 = mysql_query($sql1, $this->con);
if(!$rs1) echo sql_error();
while ($o = mysql_fetch_object($rs1)){
$i++; $j++;
$this->row_id = $o->row_id;
$this->pc_code = $o->pc_code;
$this->description = $o->description;
$this->fabrication_year = $o->fabrication_year;
$this->status = $o->status;
if ($this->series_code != $o->series_code){
$this->series_code = $o->series_code;
$series = series($this->series_code,$this->con);
echo "<tr><td colspan='5'><font size='+1' color='red'>$series</td></tr>";
$i = 1;
}
if ($i % 2) echo "<tr id='row1' valign='top'>"; else echo "<tr id='row2' valign='top'>";
echo "<td>$this->row_id</td><td><a href='report/form_computer_issue.php?pc_code=$this->row_id'>$this->pc_code</a></td><td>$this->description</td><td>$this->fabrication_year</td><td> $this->status</td></tr>";
}
echo "</table>";
echo "<font color='red' size='+1'>Total: $j</font>";
}
}
?>