| Current Path : /var/www/html/mmishra/irp/pcstore/ |
| Current File : /var/www/html/mmishra/irp/pcstore/object_class.php |
<?php
global $rid;
$rid = $_REQUEST["row_id"];
class category {
var $rid;
var $tbl;
var $con;
var $row_id;
var $name;
var $item_type;
var $stock_quantity;
var $issued_quantity;
var $scrap_quantity;
var $total_cost;
function category($rid,$tbl,$con){
$this->rid = $rid;
$this->tbl = $tbl;
$this->con = $con;
}
function get_data_from_form(){
$this->row_id = $_REQUEST["row_id"];
$this->name = $_REQUEST["name"];
$this->item_type = $_REQUEST["item_type"];
}
function insert_update_table(){
if (mysql_num_rows(mysql_query("select * from $this->tbl where row_id=$this->rid", $this->con))){
mysql_query("update $this->tbl set name='$this->name',item_type='$this->item_type' where row_id=$this->rid", $this->con);
}else{
mysql_query("insert into $this->tbl(name,item_type) values('$this->name','$this->item_type')", $this->con);
}
}
function delete_from_table(){
mysql_query("delete from $this->tbl where row_id=$this->rid", $this->con);
}
function show_form(){
$status_array = array('asset','consumable');
echo "<table width='80%'>";
echo "<tr><th>ID</th><th>Name</th><th>Type</th><th>Stock Qty</th><th>Issued Qty</th><th>Scrap Qty</th></tr>";
if ($this->rid == 0){
echo "<tr><td>New</td>";
echo "<td><input type='text' name='name' size='40'></td>";
echo "<td><select name='item_type'>";
foreach ($status_array as $s){
echo "<option value='$s'>$s</option>";
}
echo "</select></td>";
echo "<td colspan='6'><input type='submit' name='submit' value='SAVE'></td></tr>";
}else{
echo "<tr><td colspan='6'><a href='" . $_SERVER["SCRIPT_NAME"] . "?row_id=0'>New category</a> <div align='right'>(<a href='query/what_where.php?category_code=$this->rid'>Item under category ID $this->rid</a>)</div></td></tr>";
}
$rs = mysql_query("select * from $this->tbl order by name", $this->con);
if(!$rs) error_message(sql_error());
while ($o = mysql_fetch_object($rs)){
$this->row_id = $o->row_id;
$this->name = $o->name;
$this->item_type = $o->item_type;
$this->stock_quantity = $o->stock_quantity;
$this->issued_quantity = $o->issued_quantity;
$this->scrap_quantity = $o->scrap_quantity;
$this->total_cost = $o->total_cost;
if ($this->stock_quantity == "") $this->stock_quantity = 0;
if ($this->issued_quantity == "") $this->issued_quantity = 0;
if ($this->scrap_quantity == "") $this->scrap_quantity = 0;
if ($this->total_cost == "") $this->total_cost = 0;
if ($this->rid == $this->row_id){
echo "<tr id='orange_box'><th>$this->rid<input type='hidden' name='row_id' value='$this->rid'></th>";
echo "<td><input type='text' name='name' value='$this->name' size='40'></td>";
echo "<td><select name='item_type'>";
foreach ($status_array as $s){
echo "<option value='$s'";
if ($this->item_type == $s) echo " selected";
echo ">$s</option>";
}
echo "</select></td>";
echo "<td colspan='3' nowrap><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"] . "?row_id=$this->row_id'>$this->name</a></td><td>$this->item_type</td><td align='center'>$this->stock_quantity</td><td align='center'>$this->issued_quantity</td><td align='center'>$this->scrap_quantity</td></tr>\n";
}
}
echo "</table>";
}
}
class supplier {
var $rid;
var $tbl;
var $con;
var $row_id;
var $supplier_code;
var $firm_name;
var $phone_no;
var $email;
var $status;
function supplier($rid,$tbl,$con){
$this->rid = $rid;
$this->tbl = $tbl;
$this->con = $con;
}
function get_data_from_form(){
$this->row_id = $_REQUEST["row_id"];
$this->supplier_code = $_REQUEST["supplier_code"];
$this->firm_name = $_REQUEST["firm_name"];
$this->phone_no = $_REQUEST["phone_no"];
$this->email = $_REQUEST["email"];
$this->status = $_REQUEST["status"];
}
function insert_update_table(){
if (mysql_num_rows(mysql_query("select * from $this->tbl where row_id=$this->rid", $this->con))){
mysql_query("update $this->tbl set supplier_code='$this->supplier_code', firm_name='$this->firm_name', phone_no='$this->phone_no', email='$this->email', status='$this->status' where row_id=$this->rid", $this->con);
}else{
mysql_query("insert into $this->tbl(supplier_code,firm_name,phone_no,email,status) values('$this->supplier_code', '$this->firm_name', '$this->phone_no', '$this->email', '$this->status')", $this->con);
}
}
function delete_from_table(){
mysql_query("delete from $this->tbl where row_id=$this->rid", $this->con);
}
function show_form(){
$status_array = array('online', 'offline');
echo "<table width='80%'>";
echo "<tr><th>ID</th><th>Supplier Code</th><th>Firm Name</th><th>Phone No.</th><th>Email</th><th>Status</th></tr>";
if ($this->rid == 0){
echo "<tr><td>New</td>";
echo "<td><input type='text' name='supplier_code' size='10'></td>";
echo "<td><input type='text' name='firm_name' size='30'></td>";
echo "<td><input type='text' name='phone_no' size='15'></td>";
echo "<td><input type='text' name='email' size='20'></td>";
echo "<td><select name='status'>";
foreach ($status_array as $s){
echo "<option value='$s'";
echo ">$s</option>";
}
echo "</select></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"] . "?row_id=0'>New supplier</a> <div align='right'>(<a href='query/list_item.php?row_id=$this->rid'>Till date supply of supplier ID $this->rid</a>)</div></td></tr>";
}
$rs = mysql_query("select * from $this->tbl order by supplier_code", $this->con);
if(!$rs) error_message(sql_error());
while ($o = mysql_fetch_object($rs)){
$this->row_id = $o->row_id;
$this->supplier_code = $o->supplier_code;
$this->firm_name = $o->firm_name;
$this->phone_no = $o->phone_no;
$this->email = $o->email;
$this->status = $o->status;
if ($this->rid == $this->row_id){
echo "<tr id='orange-box'><th>$this->rid<input type='hidden' name='row_id' value='$this->rid'></th>";
echo "<td><input type='text' name='supplier_code' value='$this->supplier_code' size='10'></td>";
echo "<td><input type='text' name='firm_name' value='$this->firm_name' size='30'></td>";
echo "<td><input type='text' name='phone_no' value='$this->phone_no' size='15'></td>";
echo "<td><input type='text' name='email' value='$this->email' size='20'></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></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"] . "?row_id=$this->row_id'>$this->supplier_code</a></td><td>$this->firm_name</td><td>$this->phone_no</td><td>$this->email</td><td>$this->status</td></tr>";
}
}
echo "</table>";
}
}
class ugroup {
var $rid;
var $tbl;
var $con;
var $row_id;
var $name;
var $strength;
var $status;
function ugroup($rid,$tbl,$con){
$this->rid = $rid;
$this->tbl = $tbl;
$this->con = $con;
}
function get_data_from_form(){
$this->row_id = $_REQUEST["row_id"];
$this->name = $_REQUEST["name"];
$this->strength = $_REQUEST["strength"];
$this->status = $_REQUEST["status"];
}
function insert_update_table(){
$rs = mysql_query("select count(row_id) as no from $customer_master where group_code=$this->rid", $this->con);
if (mysql_num_rows($rs)){
$o = mysql_fetch_object($rs);
$this->strength = $o->no;
}
if (mysql_num_rows(mysql_query("select * from $this->tbl where row_id=$this->rid", $this->con))){
mysql_query("update $this->tbl set name='$this->name',strength=$this->strength,status='$this->status' where row_id=$this->rid", $this->con);
}else{
mysql_query("insert into $this->tbl(name,strength,status) values('$this->name',$this->strength,'$this->status')", $this->con);
}
}
function delete_from_table(){
mysql_query("delete from $this->tbl where row_id=$this->rid", $this->con);
}
function show_form(){
$status_array = array('online','offline');
echo "<table width='80%'>";
echo "<tr><th width='10%'>ID</th><th width='60%'>Name</th><th width='10%'>Strength</th><th width='20%'>Status</th></tr>";
if ($this->rid == 0){
echo "<tr><td>New</td>";
echo "<td><input type='text' name='name' size='40'></td>";
echo "<td><input type='text' name='strength' size='10'></td>";
echo "<td><select name='status'>";
foreach ($status_array as $s){
echo "<option value='$s'>$s</option>";
}
echo "</select></td></tr>";
echo "<tr><td colspan='4' align='center'><input type='submit' name='submit' value='SAVE'></td></tr>";
}else{
echo "<tr><td colspan='4'><a href='" . $_SERVER["SCRIPT_NAME"] . "?row_id=0'>New group</a> <div align='right'>(<a href='entry/master_user.php?group_code=$this->rid&row_id=0'>Add user to group ID $this->rid</a>)</div></td></tr>";
}
$rs = mysql_query("select * from $this->tbl order by name", $this->con);
if(!$rs) error_message(sql_error());
while ($o = mysql_fetch_object($rs)){
$this->row_id = $o->row_id;
$this->name = $o->name;
$this->strength = $o->strength;
$this->status = $o->status;
if ($this->rid == $this->row_id){
echo "<tr id='orange_box'><th>$this->rid<input type='hidden' name='row_id' value='$this->row_id'></th>";
echo "<td><input type='text' name='name' value='$this->name' size='40'></td>";
echo "<td><input type='text' name='strength' value='$this->strength' 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></tr>";
echo "<tr><td colspan='4' 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"] . "?row_id=$this->row_id'>$this->name</a></td><td>$this->strength</td><td>$this->status</td></tr>";
}
}
echo "</table>";
}
}
class user {
var $rid;
var $tbl;
var $con;
var $row_id;
var $name;
var $group_code;
var $category;
var $phone_no;
var $email;
var $status;
function user($rid,$tbl,$con){
$this->rid = $rid;
$this->tbl = $tbl;
$this->con = $con;
}
function get_data_from_form(){
$this->row_id = $_REQUEST["row_id"];
$this->name = $_REQUEST["name"];
$this->group_code = $_REQUEST["group_code"];
$this->category = $_REQUEST["category"];
$this->phone_no = $_REQUEST["phone_no"];
$this->email = $_REQUEST["email"];
$this->status = $_REQUEST["status"];
}
function insert_update_table(){
if (mysql_num_rows(mysql_query("select * from $this->tbl where row_id=$this->rid", $this->con))){
mysql_query("update $this->tbl set name='$this->name',group_code=$this->group_code,category='$this->category',phone_no='$this->phone_no',email='$this->email',status='$this->status' where row_id=$this->rid", $this->con);
}else{
mysql_query("insert into $this->tbl(name,group_code,category,phone_no,email,status) values('$this->name',$this->group_code,'$this->category','$this->phone_no','$this->email','$this->status')",$this->con);
}
}
function delete_from_table(){
mysql_query("delete from $this->tbl where row_id=$this->rid", $this->con);
}
function show_form(){
$status_array = array('online', 'offline');
$rs = mysql_query("select * from $customer_group where status='online' order by name", $this->con);
if(!$rs) error_message(sql_error());
echo "Select <select name='group_code' onchange=\"javascript:document.location.href='" . $_SERVER["SCRIPT_NAME"] . "?group_code=' + this.value\"><option value=''>User Group</option>";
while ($o = mysql_fetch_object($rs)){
$group_code_id = $o->row_id;
$name = $o->name;
echo "<option value='$group_code_id'";
if ($group_code_id == $this->group_code) echo " selected";
echo ">$name</option>";
}
echo "</select> <a href='entry/master_group.php?row_id=0'>New group</a><br>";
echo "<table width='80%'>";
echo "<tr><th>ID</th><th>Name</th><th>Category</th><th>Phone No.</th><th>Email</th><th>Status</th></tr>";
if ($this->rid == 0){
echo "<tr><td>New</td>";
echo "<td><input type='text' name='name' size='20'></td>";
echo "<td><input type='text' name='category' size='10'></td>";
echo "<td><input type='text' name='phone_no' size='15'></td>";
echo "<td><input type='text' name='email' size='20'></td>";
echo "<td><select name='status'>";
foreach ($status_array as $s){
echo "<option value='$s'>$s</option>";
}
echo "</select></td></tr>";
echo "<tr><td colspan='5' align='center'><input type='submit' name='submit' value='SAVE'></td></tr>";
}else{
echo "<tr><td colspan='5'><a href='" . $_SERVER["SCRIPT_NAME"] . "?group_code=$this->group_code&row_id=0'>New user</a> <div align='right'>(<a href='query/user_dues.php?group_code=$this->group_code&user_code=$this->rid&row_id=$this->rid'>Dues on user ID $this->rid</a>)</div></td></tr>";
}
$rs = mysql_query("select * from $this->tbl where group_code=$this->group_code order by name", $this->con);
if(!$rs) error_message(sql_error());
while ($q = mysql_fetch_object($rs)){
$this->row_id = $q->row_id;
$this->name = $q->name;
$this->category = $q->category;
$this->group_code = $q->group_code;
$this->phone_no = $q->phone_no;
$this->email = $q->email;
$this->status = $q->status;
if ($this->rid == $this->row_id){
echo "<tr><th>$this->rid<input type='hidden' name='row_id' value='$this->rid'></th>";
echo "<td><input type='text' name='name' value='$this->name' size='20'></td>";
echo "<td><input type='text' name='category' value='$this->category' size='20'></td>";
echo "<td><input type='text' name='phone_no' value='$this->phone_no' size='15'></td>";
echo "<td><input type='text' name='email' value='$this->email' size='20'></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></tr>";
echo "<tr><td colspan='5' 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"] . "?group_code=$this->group_code&row_id=$this->row_id'>$this->name</a></td><td>$this->category</td><td>$this->phone_no</td><td>$this->email</td><td>$this->status</td></tr>";
}
}
echo "</table>";
}
}
class series {
var $rid;
var $tbl;
var $con;
var $row_id;
var $name;
var $status;
var $stock_quantity;
var $issued_quantity;
var $scrap_quantity;
function series($rid,$tbl,$con){
$this->rid = $rid;
$this->tbl = $tbl;
$this->con = $con;
}
function get_data_from_form(){
$this->row_id = $_REQUEST["row_id"];
$this->name = $_REQUEST["name"];
$this->status = $_REQUEST["status"];
}
function insert_update_table(){
if (mysql_num_rows(mysql_query("select * from $this->tbl where row_id=$this->rid", $this->con))){
mysql_query("update $this->tbl set name='$this->name',status='$this->status' where row_id=$this->rid", $this->con);
}else{
mysql_query("insert into $this->tbl(name,status) values('$this->name','$this->status')", $this->con);
}
}
function delete_from_table(){
mysql_query("delete from $this->tbl where row_id=$this->rid", $this->con);
}
function show_form(){
$status_array = array('online','offline');
echo "<table width='80%'>";
echo "<tr><th width='10%'>ID</th><th width='40%'>Name</th><th width='20%'>Status</th><th width='10%'>Stock<br>Quantity</th><th width='10%'>Issued<br>Quantity</th><th width='10%'>Scrap<br>Quantity</th></tr>";
if ($this->rid == 0){
echo "<tr><td>New</td>";
echo "<td><input type='text' name='name' size='40'></td>";
echo "<td><select name='status'>";
foreach ($status_array as $s){
echo "<option value='$s'>$s</option>";
}
echo "</select></td></tr>";
echo "<tr><td colspan='3' align='center'><input type='submit' name='submit' value='SAVE'></td></tr>";
}else{
echo "<tr><td colspan='6'><a href='" . $_SERVER["SCRIPT_NAME"] . "?row_id=0'>New series</a> <div align='right'>(<a href='entry/stock_computer.php?series_code=$this->rid&row_id=0'>Add computer to series ID $this->rid</a>)</div></td></tr>";
}
$rs = mysql_query("select * from $this->tbl order by name", $this->con);
if(!$rs) error_message(sql_error());
while ($o = mysql_fetch_object($rs)){
$this->row_id = $o->row_id;
$this->name = $o->name;
$this->status = $o->status;
$this->stock_quantity = $o->stock_quantity;
$this->issued_quantity = $o->issued_quantity;
$this->scrap_quantity = $o->scrap_quantity;
if ($this->rid == $this->row_id){
echo "<tr id='orange_box'><th>$this->rid<input type='hidden' name='row_id' value='$this->rid'></th>";
echo "<td><input type='text' name='name' value='$this->name' size='40'></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><td>$this->stock_quantity</td><td>$this->issued_quantity</td><td>$this->scrap_quantity</td></tr>";
echo "<tr><td colspan='3' 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"] . "?row_id=$this->row_id'>$this->name</a></td><td>$this->status</td><td>$this->stock_quantity</td><td>$this->issued_quantity</td><td>$this->scrap_quantity</td></tr>";
}
}
echo "</table>";
}
}
class computer {
var $rid;
var $tbl;
var $con;
var $row_id;
var $pc_code;
var $series_code;
var $description;
var $fabrication_year;
var $status;
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->fabrication_year = $_REQUEST["fabrication_year"];
if ($fabrication_year == "") $fabrication_year = date("Y");
$this->status = $_REQUEST["status"];
}
function insert_update_table(){
if (mysql_num_rows(mysql_query("select * from $this->tbl where row_id=$this->rid", $this->con))){
mysql_query("update $this->tbl set pc_code='$this->pc_code',series_code=$this->series_code,description='$this->description',fabrication_year=$this->fabrication_year,status='$this->status' where row_id=$this->rid", $this->con);
}else{
mysql_query("insert into $this->tbl(pc_code,series_code,description,fabrication_year,status) values('$this->pc_code',$this->series_code,'$this->description',$this->fabrication_year,'$this->status')", $this->con);
}
}
function delete_from_table(){
mysql_query("delete from $this->tbl where row_id=$this->rid", $this->con);
}
function show_form(){
$status_array = array('new', 'old', 'issued','scrap');
$rs = mysql_query("select * from $product_series 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>Fabrication Year</th><th>Status</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='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></tr>";
echo "<tr><td colspan='5' align='center'><input type='submit' name='submit' value='SAVE'></td></tr>";
}else{
echo "<tr><td colspan='5'><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->fabrication_year = $o->fabrication_year;
$this->status = $o->status;
$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='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></tr>";
echo "<tr><td colspan='5' 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>$this->fabrication_year</td><td>$this->status</td></tr>";
}
}
echo "</table>";
echo "<font color='red' size='+1'>Total: $i</font>";
}
function show_list(){
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 $product_master where 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>";
}
}
class parts {
var $rid;
var $tbl;
var $con;
var $row_id;
var $item_code;
var $parts_code;
var $status;
var $remark;
function parts($rid,$tbl,$con){
$this->rid = $rid;
$this->tbl = $tbl;
$this->con = $con;
}
function get_data_from_form(){
$this->row_id = $_REQUEST["row_id"];
$this->item_code = $_REQUEST["item_code"];
$this->parts_code = $_REQUEST["parts_code"];
$this->remark = $_REQUEST["remark"];
$this->status = $_REQUEST["status"];
}
function insert_update_table(){
if (mysql_num_rows(mysql_query("select * from $this->tbl where row_id=$this->rid", $this->con))){
mysql_query("update $this->tbl set item_code=$this->item_code,parts_code='$this->parts_code',remark='$this->remark',status='$this->status' where row_id=$this->rid", $this->con);
}else{
mysql_query("insert into $this->tbl(item_code,parts_code,remark,status) values($this->item_code,'$this->parts_code','$this->remark','$this->status')", $this->con);
}
//update stock_quantity in item_master table
if ($this->status == "new" or $this->status == "old"){
mysql_query("update $parts_receipt set stock_quantity=stock_quantity + 1 where row_id=$this->item_code", $this->con);
}else if ($this->status == "scrap"){
mysql_query("update $parts_receipt set scrap_quantity=scrap_quantity + 1 where row_id=$this->item_code", $this->con);
}
}
function delete_from_table(){
mysql_query("delete from $this->tbl where row_id=$this->rid", $this->con);
//update stock_quantity in item_master table
if ($this->status == "new" or $this->status == "old"){
mysql_query("update $parts_receipt set stock_quantity=stock_quantity - 1 where row_id=$this->item_code", $this->con);
}else if ($this->status == "scrap"){
mysql_query("update $parts_receipt set scrap_quantity=scrap_quantity - 1 where row_id=$this->item_code", $this->con);
}
}
function show_form(){
$status_array = array('new', 'old', 'issued', 'missing', 'reserved', 'scrap');
echo "<table width='60%' align='left'><tr><th>ID</th><th>Parts Code</th><th>Status</th><th>Remark</th></tr>";
if ($this->rid == 0){
$this->parts_code = time();
echo "<tr><td>New</td>";
echo "<td><input type='text' name='parts_code' value='$this->parts_code' size='15'></td>";
echo "<td><select name='status'>";
foreach ($status_array as $s){
echo "<option value='$s'";
if ($s == $status) echo " selected";
echo ">$s</option>";
}
echo "</select></td>";
echo "<td><input type='text' name='remark' value='$this->remark' size='20'></td></tr>";
echo "<tr><td colspan='4' align='center'><input type='submit' name='submit' value='SAVE'></td></tr>";
}else{
echo "<tr><td colspan='3'><a href='" . $_SERVER["SCRIPT_NAME"]. "?item_code=$this->item_code'>New parts</a></td></tr>";
}
$rs = mysql_query("select * from $this->tbl where item_code=$this->item_code order by parts_code", $this->con);
if(!$rs) echo sql_error();
while ($o = mysql_fetch_object($rs)){
$i++;
$this->row_id = $o->row_id;
$this->parts_code = $o->parts_code;
$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<input type='hidden' name='row_id' value='$this->rid'></th>";
echo "<td><input type='text' name='parts_code' value='$this->parts_code' size='15'></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='20'></td><tr>";
echo "<tr><td colspan='4' 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"]. "?item_code=$this->item_code&row_id=$this->row_id#$j'>$this->parts_code</a></td><td>$this->status</td><td>$this->remark</td></tr>";
}
}
echo "<tr><td colspan='4'>Total: $i Parts<br>";
$rs = mysql_query("select m.pc_code as issued_to from $product_master m left join $product_configuration c on m.row_id=c.pc_code where c.parts_code=$this->rid", $this->con);
if (!mysql_num_rows($rs)){
$rs = mysql_query("select m.name as issued_to from $customer_master m left join $parts_issued i on m.row_id=i.user_code where i.parts_code=$this->rid", $this->con);
}
$o = mysql_fetch_object($rs);
$issued_to = $o->issued_to;
echo " <b id='orange_box'>Issued To: $issued_to</b></td></tr></table>";
echo "Duplicate Parts Code";
echo "<table width='40%'><tr><th>ID</th><th>Parts Code</th><th>Status</th><th>Remark</th></tr>";
$rs = mysql_query("select * from $parts_master where item_code=$this->item_code order by parts_code", $this->con);
if(!$rs) echo sql_error();
while ($o = mysql_fetch_object($rs)){
$this->row_id = $o->row_id;
$this->parts_code = $o->parts_code;
$this->status = $o->status;
$this->remark = $o->remark;
$j = $this->row_id - 1;
echo "<tr><td><a href='" . $_SERVER["SCRIPT_NAME"]. "?item_code=$this->item_code&row_id=$this->row_id#$j'>$this->row_id</a></td><td><a href='query/search_parts.php?parts_code=$this->parts_code' target='_blank'>$this->parts_code</a></td><td>$this->status</td><td>$this->remark</td></tr>";
}
echo "</table>";
}
}
class item {
var $rid;
var $tbl;
var $con;
var $row_id;
var $supplier_code;
var $category_code;
var $description;
var $model_make;
var $unit_price;
var $receive_date;
var $warranty_date;
var $shelf_no;
var $remark;
function item($rid,$tbl,$con){
$this->rid = $rid;
$this->tbl = $tbl;
$this->con = $con;
}
function get_data_from_form(){
$this->row_id = $_REQUEST["row_id"];
$this->supplier_code = $_REQUEST["supplier_code"];
$this->category_code = $_REQUEST["category_code"];
$this->description = $_REQUEST["description"];
$this->model_make = $_REQUEST["model_make"];
if ($this->model_make == "") $this->model_make = "iiita";
$this->unit_price = $_REQUEST["unit_price"];
$this->receive_date = $_REQUEST["receive_date"];
if ($this->receive_date == "") $this->receive_date = date("Y-m-d");
$this->warranty_date = $_REQUEST["warranty_date"];
$this->shelf_no = $_REQUEST["shelf_no"];
$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))){
mysql_query("update $this->tbl set description='$this->description',model_make='$this->model_make',unit_price=$this->unit_price,warranty_date='$this->warranty_date',shelf_no='$this->shelf_no',receive_date='$this->receive_date',remark='$this->remark' where row_id=$this->rid", $this->con);
}else{
mysql_query("insert into $this->tbl(description,category_code,model_make,unit_price,receive_date,warranty_date,shelf_no,supplier_code,remark) values('$this->description', $this->category_code, '$this->model_make', $this->unit_price, '$this->receive_date', '$this->warranty_date', '$this->shelf_no', $this->supplier_code, '$this->remark')", $this->con);
}
}
function delete_from_table(){
mysql_query("delete from $this->tbl where row_id=$this->rid", $this->con);
}
function show_form(){
echo "Select Supplier <select name='supplier_code'>";
$rs = mysql_query("select row_id,firm_name from $supplier_master order by firm_name", $this->con);
while ($o = mysql_fetch_object($rs)){
$this->row_id = $o->row_id;
$name = $o->firm_name;
echo "<option value='$this->row_id'";
if ($this->supplier_code == $this->row_id) echo " selected";
echo ">$name</option>";
}
echo "</select> ";
//if (!$this->supplier_code) exit;
echo "Select <select name='category_code'><option value=''>Item Category</option>";
$rs = mysql_query("select row_id,name,stock_quantity from $parts_category order by name", $this->con);
while ($o = mysql_fetch_object($rs)){
$this->row_id = $o->row_id;
$name = $o->name;
$qty = $o->stock_quantity;
echo "<option value='$this->row_id'";
if ($this->category_code == $this->row_id) echo " selected";
echo ">$name</option>";
}
echo "</select> ";
echo "<input type='submit' name='submit' value='FIND'><p>";
if ($this->category_code != ""){
$rs = mysql_query("select * from $this->tbl where supplier_code=$this->supplier_code and category_code=$this->category_code order by receive_date", $this->con);
echo "<table><tr><td><b>Item Entry</b></td><th><b>Code: $this->row_id</b><input type='hidden' name='row_id' value='$this->rid'></th></tr>";
echo "<tr valign='top'><td>Select Receive Date<br>";
echo "<select name='row_id1' size='10' onchange=\"javascript:document.location.href='" . $_SERVER["SCRIPT_NAME"] . "?supplier_code=$this->supplier_code&category_code=$this->category_code&row_id=' + this.value\">";
echo "<option value=''>Add New</option>";
while ($o = mysql_fetch_object($rs)){
$i++;
$this->row_id = $o->row_id;
$receive_date1 = $o->receive_date;
echo "<option value='$this->row_id'";
if ($this->rid == $this->row_id){
$flag = "TRUE";
echo " selected";
$this->description = $o->description;
$this->model_make = $o->model_make;
$this->unit_price = $o->unit_price;
$this->receive_date = $o->receive_date;
$this->warranty_date = $o->warranty_date;
$qty1 = $o->stock_quantity;
$qty2 = $o->issued_quantity;
$qty3 = $o->scrap_quantity;
$this->shelf_no = $o->shelf_no;
$remark = $o->remark;
}
echo ">$receive_date1</option>";
}
echo "</select><br>Total: $i Supply</td><td><table>";
echo "<tr valign='top'><td>Description</td><td><input type='text' name='description' value='$this->description' size='40'></td></tr>";
echo "<tr><td>Model, Make</td><td><input type='text' name='model_make' value='$this->model_make' size='40'></td></tr>";
echo "<tr><td>Unit Price</td><td><input type='text' name='unit_price' value='$this->unit_price' size='10'></td>";
if (($qty1+$qty2+qty3) > 0 ){
echo "<td rowspan='4'><table id='orange_box'><tr><td nowrap><font color='red'>Stock Quantity:<br>Issued Quantity:<br>Scrap Quantity:</font></td><td align='right' nowrap><font color='green'>$qty1<br>$qty2<br>$qty3</font></td></tr></table></td>";
}
echo "</tr>";
echo "<tr><td>Receive Date</td><td><input type='text' name='receive_date' value='$this->receive_date' size='10'> (default current date)</td></tr>";
echo "<tr><td>Warranty Date</td><td><input type='text' name='warranty_date' value='$this->warranty_date' size='10'></td></tr>";
echo "<tr><td>Shelf No.</td><td><input type='text' name='shelf_no' value='$this->shelf_no' size='10'></td></tr>";
echo "<tr><td valign='top'>Remark</td><td><input type='text' name='remark' value='$this->remark' size='40'></td></tr>";
echo "<tr><td></td><td><input type='submit' name='submit' value='SAVE'>";
//if ($flag == "TRUE") echo " <input type='submit' name='submit' value='DELETE'>";
echo "</td></tr></table></td></tr></table>";
if ($flag == "TRUE") echo "<iframe src='entry/master_parts.php?item_code=$this->rid' align='center' width='95%' height='300' id='orange_box'></iframe>";
}
}
}
?>