| Current Path : /var/www/html/mmishra/iws8/html/pcstore/backupxxxxxxx/ |
| Current File : /var/www/html/mmishra/iws8/html/pcstore/backupxxxxxxx/entry_parts_loan.php |
<?php
$tbl = $parts_issued;
echo "<b>Parts Loan</b> (To <b>online</b> customers only)<p>";
$submit = $_REQUEST["submit"];
$row_id = $_REQUEST["row_id"];
$group_code = $_REQUEST["group_code"];
$user_code = $_REQUEST["user_code"];
$showall = $_REQUEST["showall"];
if (!$showall) $showall = 0;
$category_code = $_REQUEST["category_code"];
$parts_code = $_REQUEST["parts_code"];
$rs = mysql_query("select item_code from $parts_master where row_id=$parts_code");
$o = mysql_fetch_object($rs);
if ($o){
$item_code = $o->item_code;
$rs = mysql_query("select category_code from $parts_receipt where row_id=$item_code");
$q = mysql_fetch_object($rs);
$category_code = $q->category_code;
}
$issue_date = $_REQUEST["issue_date"];
if ($issue_date == "") $issue_date = date("Y-m-d");
$issue_for = $_REQUEST["issue_for"];
$destination = $_REQUEST["destination"];
if ($destination == "") $destination="lab";
$due_date = $_REQUEST["due_date"];
if ($due_date == "") $due_date = date("Y-m-d");
$return_date = date("Y-m-d");
$status = $_REQUEST["status"];
$remark = $_REQUEST["remark"];
$flag = "FALSE";
switch ($submit){
case "ISSUE":
//issue & reduce stock status
$sql = "insert into $tbl(parts_code,user_code,issue_date,issue_for,destination,due_date,remark) values($parts_code,$user_code,'$issue_date','$issue_for','$destination','$due_date','$remark')";
$rs = mysql_query($sql);
if ($rs){
access_log($sql);
//change status in stock master
$sql = "update $parts_master set status='issued' where row_id=$parts_code";
mysql_query($sql);
$sql = "update $parts_receipt set stock_quantity=stock_quantity-1,issued_quantity=issued_quantity+1 where row_id=$item_code";
mysql_query($sql);
$sql = "update $parts_category set stock_quantity=stock_quantity-1,issued_quantity=issued_quantity+1 where row_id=$category_code";
mysql_query($sql);
//access_log($sql);
}
break;
case "RETURN":
$sql = "insert into $parts_used(parts_code,user_code,issue_date,return_date,remark) values($parts_code,$user_code,'$issue_date','$return_date','$remark')";
$rs = mysql_query($sql);
if ($rs){
access_log($sql);
//change status in stock master
$sql = "update $parts_master set status='$status' where row_id=$parts_code";
mysql_query($sql);
access_log($sql);
//delete issue record from parts_issued table
$sql = "delete from $tbl where row_id=$row_id";
mysql_query($sql);
if ($status == 'old'){
mysql_query("update $parts_receipt set stock_quantity=stock_quantity+1,issued_quantity=issued_quantity-1 where row_id=$item_code");
mysql_query("update $parts_category set stock_quantity=stock_quantity+1,issued_quantity=issued_quantity-1 where row_id=$category_code");
}else{
mysql_query("update $parts_receipt set scrap_quantity=scrap_quantity+1,issued_quantity=issued_quantity-1 where row_id=$item_code");
mysql_query("update $parts_category set scrap_quantity=scrap_quantity+1,issued_quantity=issued_quantity-1 where row_id=$category_code");
}
//access_log($sql);
}
break;
case "FIND":
break;
}
$sql = "select row_id,name,strength from $customer_group where status='online' order by name";
$rs = mysql_query($sql);
echo "Select <select name='group_code' onchange=\"javascript:document.location.href='inner.php?conf=$conf&showall=$showall&group_code=' + this.value\">";
echo "<option value=''>Customer Group</option>";
while ($qd = mysql_fetch_array($rs)){
$row_id1 = $qd["row_id"];
$name = $qd["name"];
echo "<option value='$row_id1'";
if ($row_id1 == $group_code) echo " selected";
echo ">$name</option>";
}
echo "</select> ";
if (!$group_code) exit;
$sql = "select row_id,name,email from $customer_master where group_code=$group_code ";
if ($showall == 0) $sql .= " and status='online' ";
$sql .= "order by name";
$rs = mysql_query($sql);
echo " Select <select name='user_code'onchange=\"javascript:document.location.href='inner.php?conf=$conf&showall=$showall&group_code=$group_code&user_code=' + this.value\">";
echo "<option value=''>User Name</option>";
while ($o = mysql_fetch_object($rs)){
$row_id1 = $o->row_id;
$name = $o->name;
$email = $o->email;
echo "<option value='$row_id1'";
if ($row_id1 == $user_code) echo " selected";
echo ">$name ($email)</option>";
}
echo "</select> ";
echo "(<input type='checkbox' name='showall' value='1' ";
if ($showall == "1"){
echo "checked ";
echo "onclick=\"document.location.href='inner.php?conf=$conf&group_code=$group_code&user_code=$user_code&showall=0'\">";
}else{
echo "onclick=\"document.location.href='inner.php?conf=$conf&group_code=$group_code&user_code=$user_code&showall=1'\">";
}echo "Show all) by defaults online members are listed here<p>";
if ($user_code == "") exit;
echo "<b>Available Parts</b> ";
$sql = "select row_id,name,stock_quantity as qty from $parts_category where stock_quantity > 0 order by name";
$rs = mysql_query($sql);
echo "<select name='category_code' onchange=\"javascript:document.location.href='inner.php?conf=$conf&group_code=$group_code&user_code=$user_code&category_code=' + this.value\">";
echo "<option value=''>Select Category</option>";
while ($qd = mysql_fetch_array($rs)){
$row_id1 = $qd["row_id"];
$name = $qd["name"];
$qty = $qd["qty"];
echo "<option value='$row_id1'";
if ($row_id1 == $category_code) echo " selected";
echo ">$name ($qty)</option>";
}
echo "</select> To issue select parts to get list of stoked peices<br>";
if ($category_code != ""){
$sql = "select pm.row_id, pm.parts_code, pm.item_code, pm.status, im.description, im.model_make, im.unit_price, im.receive_date, im.warranty_date from $parts_master pm left join parts_receipt im on pm.item_code=im.row_id where im.category_code=$category_code and pm.status in ('new', 'old') order by pm.parts_code";
$rs = mysql_query($sql);
if(!$rs) echo sql_error();
if (mysql_num_rows($rs)){
echo "<table width='100%'>";
echo "<tr><th nowrap>Parts Code</th><th nowrap>Description</th><th nowrap>Unit Price</th><th nowrap>Receive Date</th><th nowrap>Warranty Date</th><th nowrap>Remark</th></tr>";
while ($qd = mysql_fetch_array($rs)){
$i++;
$row_id1 = $qd["row_id"];
$parts_code1 = $qd["parts_code"];
$description = $qd["description"];
$model_make = $qd["model_make"];
$unit_price = $qd["unit_price"];
$receive_date = $qd["receive_date"];
$warranty_date = $qd["warranty_date"];
$remark = $qd["remark"];
$j = $row_id1 - 1;
if ($i % 2) echo "<tr id='row1'>"; else echo "<tr id='row2'>";
echo "<td><a name='$j'></a><input type='radio' name='parts_code' value='$row_id1' onclick=\"javascript:document.location.href='inner.php?conf=$conf&group_code=$group_code&user_code=$user_code&category_code=$category_code&parts_code=$row_id1#$j'\"";
if ($row_id1 == $parts_code){
echo " checked";
$flag = "TRUE";
echo "> <b>$parts_code1</b>";
}else{
echo "> $parts_code1";
}
echo "</td><td>$description ($model_make)</td><td align='right'>Rs. $unit_price</td><td align='center'>$receive_date</td><td align='center'>$warranty_date</td><td>$remark</td></tr>";
if ($flag == "TRUE"){
echo "<tr><td id='orange_box' colspan='6' align='center'><b>Issue ?</b> ";
echo "Purpose <select name='issue_for'><option value='self'>self use</option><option value='project'>project use</option><option value='others'>others use</option></select> ";
echo "Location <input type='text' name='destination' value='$destination' size='20' maxlength='20'> ";
echo "Due Date <input type='text' name='due_date' value='$due_date' size='10' maxlength='10'> ";
echo "Remark <input type'text' name='remark' value='$remark' size='30' maxlength='255'> ";
echo "<input type='submit' name='submit' value='ISSUE'></td></tr>";
$flag = "FALSE";
}
}
echo "</table>Select Parts Code to issue";
}
}
$i = 0; $flag = "FALSE";
//show user account
echo "<p><b>Dues on Customer</b> ";
$sql = "select pi.*, pm.item_code from parts_issued pi, parts_master pm where pi.parts_code=pm.row_id and pi.user_code=$user_code order by pi.issue_date desc";
$rs = mysql_query($sql);
if(!$rs) echo sql_error();
if (mysql_num_rows($rs)){
echo " <a href='inner.php?conf=report_form_parts_issue&user_code=$user_code'>Print Report on Issued Items</a><br>";
echo "<table width='100%'><tr><th nowrap>Parts Code</th><th nowrap>Description</th><th nowrap>Issue Date</th><th nowrap>Due Date</th><th>Issue For</th><th>Remark</th></tr>";
while($qd = mysql_fetch_array($rs)){
$i++;
$row_id1 = $qd["row_id"];
$parts_code1 = $qd["parts_code"];
$parts = parts($parts_code1);
$item_code1 = $qd["item_code"];
$item = item($item_code1);
$issue_date = $qd["issue_date"];
$issue_for = $qd["issue_for"];
$destination = $qd["destination"];
$due_date = $qd["due_date"];
if ($due_date > date("Y-m-d")) $overdue = "TRUE";
$remark = $qd["remark"];
$j = $row_id1 - 1;
if ($i % 2) echo "<tr id='row1'>"; else echo "<tr id='row2'>";
echo "<td><a name='$j'></a><input type='radio' name='parts_code' value='$parts_code1' onclick=\"javascript:document.location.href='inner.php?conf=$conf&group_code=$group_code&user_code=$user_code&category_code=$category_code&parts_code=$parts_code1#$j'\"";
if ($parts_code1 == $parts_code){
echo " checked";
$flag = "TRUE";
echo "> <b>$parts</n>";
}else{
echo "> $parts";
}
echo "</td><td>$item</td><td align='center'>$issue_date</td><td align='center'>$due_date</td><td>$issue_for ($destination)</td><td>$remark</td></tr>";
if ($flag == "TRUE"){
echo "<tr><td id='orange_box' colspan='6' align='center' ><b>Return ?</b> ";
echo "Status <select name='status'><option value='old'>working</option><option value='missing'>missing</option><option value='scrap'>scrap</option></select> ";
echo "Dated <input type='hidden' name='issue_date' value='$issue_date'><input type='text' name='return_date' value='$return_date' size='10'> ";
echo "Remark <input type='text' name='remark' value='$remark' size='30'> ";
echo "<input type='submit' name='submit' value='RETURN'><input type='hidden' name='row_id' value='$row_id1'></td></tr>";
$flag = "FALSE";
}
}
echo "</table>Select Parts Code to return";
}else{ echo "<dir>None</dir>";}
//show user history
echo "<p><b>Returned by Customer</b>";
$sql = "select u.*, m.item_code from $parts_used u left join $parts_master m on u.parts_code=m.row_id where u.user_code=$user_code";
$rs = mysql_query($sql);
if (!$rs) echo mysql_error();
if (mysql_num_rows($rs)){
echo "<table width='98%'><tr><th nowrap>Parts Code</th><th nowrap>Description</th><th nowrap>Issue Date</th><th nowrap>Return Date</th><th>Remark</th></tr>";
while ($qd = mysql_fetch_array($rs)){
$parts_code1 = $qd["parts_code"];
$parts_detail = parts($parts_code1);
$item_code1 = $qd["item_code"];
$item_detail = item($item_code1);
$issue_date = $qd["issue_date"];
$return_date = $qd["return_date"];
$remark = $qd["remark"];
echo "<tr><td>$parts_detail</td><td>$item_detail</td><td align='center'>$issue_date</td><td align='center'>$return_date</td><td>$remark</td></tr>";
}
echo "</table>";
}else{ echo "<dir>None</dir>";}
?>