| Current Path : /var/www/html/mmishra/istore/ |
| Current File : /var/www/html/mmishra/istore/class.indent.php |
<?php
Class iIndent {
var $indentNo;
var $dateIndent;
var $purpose;
var $location;
var $employee;
var $account;
var $recommendation;
var $category;
var $subCategory;
var $item;
var $itemAdd;
var $qtyDemand;
var $unit;
var $qtyOut;
var $approxCost;
public function __construct() {
$this->tbl = 't_tenders';
if (!$this->dateIndent) $this->dateIndent = date('Y-m-d');
if (!$this->dateSubmission) $this->dateSubmission = date('Y-m-d', strtotime("+15 days"));
if (!$this->timeSubmission || $this->timeSubmission = '00:00:00') $this->timeSubmission = '15:30:00';
if (!$this->dateOpening) $this->dateOpening = date('Y-m-d', strtotime("+15 days"));
if (!$this->timeOpening || $this->timeOpening = '00:00:00') $this->timeOpening = '15:30:00';
if (!$this->dateCancellation) $this->dateCancellation = date('Y-m-d');
if (!$this->dateClosing) $this->dateClosing = date('Y-m-d');
if (!$this->dateOrder) $this->dateOrder = date('Y-m-d');
if (!$this->dateExtension) $this->dateExtension = date('Y-m-d');
if (!$this->dateCorrigendum) $this->dateCorrigendum = date('Y-m-d');
if (!$this->dateQuotation) $this->dateQuotation = date('Y-m-d');
if (!$this->status) $this->status = 'Pending';
}
function saveIndent() {
if (mysql_num_rows(mysql_query("select * from indents where indent_no=$this->indentNo"))) {
//update existing indent
mysql_query("update indents set date_indent='$this->dateIndent',purpose='$this->purpose',
location='$this->location',employee='$this->employee',account='$this->account',
recommendation='$this->recommendation',dated=now()
where indent_no=$this->indentNo");
} else {
//insert new indent
mysql_query("insert into indents(date_indent,purpose,location,employee,account,recommendation,
status,dated)
values('$this->dateIndent','$this->purpose','$this->location','$this->employee',
'$this->account','$this->recommendation','$this->status',now())");
$this->indentNo = mysql_insert_id();
}
if (!$this->id && $this->itemAdd) {
//store new item in the item master
mysql_query("insert into $st_items(code,description,subcategory,category,dated)
values('$tis->code','New item added from indent form',$this->subCategory,$this->category,
now())");
$this->id = mysql_insert_id();
}
//item entry
if (mysql_num_rows(mysql_query("select * from indent_items where id=$this->id"))) {
//update existing items of indent
mysql_query("update indent_items set item=$this->item,qty_demand=$this->qtyDemand,
qty_out=$this->qtyOut,unit='$this->unit',approx_cost=$this->approxCost,dated=now()
where id=$thios->id");
} else if ($this->item) {
//insert new items of indent
mysql_query("insert into indent_items(indent_no,item,qty_demand,qty_out,unit,approx_cost,dated)
values($this->indentNo,$this->item,$this->qtyDemand,$this->qtyOut,'$this->unit',
$this->approxCost,now())");
}
}
function deleteIndent() {
if ($this->id) {
//delete item record
mysql_query("delete from indent_items where id=$this->id");
$this->id = 0;
} else {
//delete items first and then delete indent
mysql_query("delete from indent_items where indent_no=$this->indentNo");
mysql_query("delete from indents where indent_no=$this->indentNo");
$this->indentNo = 0;
}
}
function reviveIndent() {
mysql_query("update indents set status='Pending' where indent_no=$this->indentNo");
}
function cancelIndent() {
mysql_query("delete from indent_items where id=$this->id");
}
function getIndent() {
$rs = mysql_query("select * from indents where indent_no=$this->indentNo");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$this->dateIndent = $o->date_indent;
$this->purpose = $o->purpose;
$this->location = $o->location;
$this->employee = $o->employee;
$this->account = $o->account;
$this->recommendation = $o->recommendation;
$this->status = $o->status;
}
}
}
class iItem {
public function saveItem() {
}
public function deleteItem() {
}
public function getCategory() {
$rs = mysql_query("select * from st_items where id=(select item from indent_items where id=$id)");
while ($o = mysql_fetch_object($rs)) {
$item = $o->id;
$category = $o->category;
$subcategory = $o->subcategory;
}
}
public function getSubcategory() {
$rs = mysql_query("select * from st_items where id=(select item from indent_items where id=$id)");
while ($o = mysql_fetch_object($rs)) {
$item = $o->id;
$category = $o->category;
$subcategory = $o->subcategory;
}
}
}
echo "<center>
<table width='50%'><tr><th>".($indentno ? "[ <a href='?pg=$pg'>New</a> ] " : '')."
Indent No. <input type='text' name='indent_no' size='10' value='$indentno'>
<input type='submit' name='submit' value='FIND'> Status: $status ".
($status == 'Cancelled' ? "[ <a href='?pg=$pg&revive=1&indent_no=$indentno'>Revive</a> ]" : '').
"</th></tr></table>";
echo "<table width='80%' border='1' style='border-collapse: collapse'>
<tr><td>Purpose</td><td><input type='text' name='purpose' size='50' value='$purpose'>
Location <select name='location'>";
foreach ($locations as $lc) {
echo "<option value='$lc'".($lc == $o->location ? ' selected' : '').">$lc</option>";
}
echo "</select></td>
<td width='10%'>Indent Date</td><td>";
$myCalendar = new tc_calendar("date_indent", true, false);
$myCalendar->setIcon("images/iconCalendar.gif");
$myCalendar->setDate(date('d', strtotime($dateindent)), date('m', strtotime($dateindent)), date('Y', strtotime($dateindent)));
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(2016, 2020);
$myCalendar->setAlignment('left', 'bottom');
$myCalendar->writeScript();
echo "</td></tr>
<tr><td width='10%'>Employee</td><td width='60%'>".employee_list($employee)."
Account <select name='account'>";
foreach ($accounts as $ac) {
echo "<option value='$ac'".($ac == $o->account ? ' selected' : '').">$ac</option>";
}
echo "</select></td>
</td>
<td>Recommendation</td><td><input type='text' name='recommendation' size='30' value='$recommendation'></td></tr>";
if ($indentno) {
//item list
echo "<table width='90%' border='1' style='border-collapse: collapse'>
<tr><th>No.</th><th nowrap>Indent Item</th><th>Qty Demand</th><th>Qty Issued</th><th>Approx Cost</th></tr>";
//add new item
if (!$id && $status == 'Pending') {
echo "<tr><td>New</td>
<td><select name='category' onchange=\"javascript: document.location.href='?pg=$pg&indent_no=$indentno&category='+this.value\">
<option value=''></option>";
$rs = mysql_query("select * from st_category order by code");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $category) echo " selected";
//echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
echo ">$o->code</option>";
}
echo "</select>
<select name='subcategory' onchange=\"javascript: document.location.href='?pg=$pg&indent_no=$indentno&category=$category&subcategory='+this.value\">
<option value=''></option>";
$rs = mysql_query("select * from st_subcategory where category=$category order by code");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $subcategory) echo " selected";
//echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
echo ">$o->code</option>";
}
echo "</select>
<select name='item'>
<option value=''></option>";
$rs = mysql_query("select * from st_items where category=$category and subcategory=$subcategory order by code");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $item) echo " selected";
//echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
echo ">$o->code ($o->description)</option>";
}
echo "</select></td>
<td><input type='text' name='qty_demand' size='5' value='1'>
<select name='unit'>";
foreach ($units as $qu) {
echo "<option value='$qu'".($qu == $o->unit ? ' selected' : '').">$qu</option>";
}
echo "</select></td>
<td><input type='text' name='qty_out' size='5' value='0'> *</td>
<td><input type='text' name='approx_cost' size='10' value='0.00'></td></tr>
<tr><th>Add</th><td><input type='text' name='itemadd' value='' size='50'></td>
<td colspan='3'>Select category, subcategory above and type new item here if it is not listed above.</td></tr>";
} else if ($status == 'Pending'){
echo "<tr><td>New</td><td colspan='4'><a href='?pg=$pg&indent_no=$indentno&id='>item</a></td></tr>";
}
$sr = mysql_query("select * from indent_items where indent_no=$indentno order by item");
while ($q = mysql_fetch_object($sr)) {
$j++;
echo "<tr>";
if ($id == $q->id) {
echo "<td>$j</td>
<td><select name='category' onchange=\"javascript: document.location.href='?pg=$pg&indent_no=$indentno&category='+this.value\">
<option value=''></option>";
$rs = mysql_query("select * from st_category order by code");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $category) echo " selected";
//echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
echo ">$o->code</option>";
}
echo "</select>
<select name='subcategory' onchange=\"javascript: document.location.href='?pg=$pg&indent_no=$indentno&category=$category&subcategory='+this.value\">
<option value=''></option>";
$rs = mysql_query("select * from st_subcategory where category=$category order by code");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $subcategory) echo " selected";
//echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
echo ">$o->code</option>";
}
echo "</select>
<select name='item'>
<option value=''></option>";
$rs = mysql_query("select * from st_items where category=$category and subcategory=$subcategory order by code");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $item) echo " selected";
//echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
echo ">$o->code ($o->description)</option>";
}
echo "</select>
<input type='hidden' name='id' value='$q->id'></td>
<td><input type='text' name='qty_demand' size='5' value='$q->qty_demand'>
<select name='unit'>";
foreach ($units as $qu) {
echo "<option value='$qu'".($qu == $q->unit ? ' selected' : '').">$qu</option>";
}
echo "</select></td>
<td><input type='text' name='qty_out' size='5' value='$q->qty_out'></td>
<td><input type='text' name='approx_cost' size='10' value='$q->approx_cost'></td>";
} else {
echo "<td><a href='?pg=$pg&indent_no=$indentno&id=$q->id'>$j</a></td><td>".item_detail($q->item)."</td>
<td>$q->qty_demand $q->unit</td><td>$q->qty_out".(!$q->qty_out ? " [ <a href='?pg=$pg&indent_no=$indentno&id=$q->id&cancel=1'>X</a> ]" : '')."
</td><td>$q->approx_cost</td>";
}
echo "</tr>";
}
}
if ($status == 'Pending') {
echo "<tr><th colspan='4'><input type='submit' name='submit' value='SAVE'></th>";
if ($indentno) echo "<th><input type='submit' name='submit' value='DELETE'></th>";
}
?>
</tr>
</table>
* qtuantity issued prior to approval at the time of indent receipt (to meet the urgency).
</center>