<?php 

/***************************************************************************
 *   copyright            : (C) 2013 PCRepairTracker.com
 *   email                : info@pcrepairtracker.com
 *   This program is a copyrighted work.
 *   Please see the license.txt file for details
 *
 ***************************************************************************/


require("header.php"); 

?>



<table style="width:100%;border-collapse:collapse;border: 1px #777777 solid;margin:0px;"><tr><td valign=top colspan=5 bgcolor=#eeeeee>
<h2><?php echo pcrtlang("Order Planning"); ?>&nbsp;</h2><br><br>
<?php echo pcrtlang("Qty"); ?>. &nbsp;&nbsp;<?php echo pcrtlang("Items Desc"); ?>:</td></tr><tr bgcolor=#eeeeee><td colspan=5 valign=top>
<form action=shoplist.php?func=add_item method=post>
<input type=text size=2 name=qty class=textbox value=1><input type=text size=30 name=itemdesc class=textbox>
<select name=status>
<?php
require("deps.php");

if ($gomodal == 1) {
$therel = "rel=facebox";
} else {
$therel = "";
}


reset($shopliststatus);
foreach($shopliststatus as $thestatus => $thestatus2) {
echo "<option value=\"$thestatus\">$thestatus</option>";
}
                                                                                                                                               
echo "</select><input type=submit value=\"".pcrtlang("Add")."\" class=button></form></td></tr>";

$rs_findpc = "SELECT * FROM shoplist ORDER BY itemstatus DESC,itemdesc ASC";
$rs_result = mysqli_query($rs_connect, $rs_findpc);
        
$oldstatus = "";                                                                                                                                       
                                                                                                                                               
while($rs_result_q = mysqli_fetch_object($rs_result)) {
$shopid = "$rs_result_q->shopid";
$qty = "$rs_result_q->qty";
$itemdesc2 = "$rs_result_q->itemdesc";
$status = "$rs_result_q->itemstatus";
$byuser = "$rs_result_q->byuser";
$stockid = "$rs_result_q->stockid";

reset($shopliststatus);
$thecol = $shopliststatus["$status"];

if ($oldstatus != $status) {
echo "<tr><td colspan=5 bgcolor=#eeeeee>&nbsp;</td></tr>";
echo "<tr bgcolor=#$thecol><td colspan=5>$status</td></tr>";
} 

echo "\n<tr bgcolor=#$thecol><td><a href=shoplist.php?func=edititemq&dir=up&shopid=$shopid class=\"linkbuttontiny linkbuttongray radiusleft\"><i class=\"fa fa-chevron-up\"></i></a>";

if ($qty > 1) {
echo "<a href=shoplist.php?func=edititemq&dir=down&shopid=$shopid class=\"linkbuttontiny linkbuttongray radiusright\"><i class=\"fa fa-chevron-down\"></i></a>";
}

$itemdesc = htmlspecialchars($itemdesc2);

echo "</td><td><form action=shoplist.php?func=edititem method=post><input type=hidden value=$shopid name=shopid><input type=text size=2 name=qty class=textbox value=$qty><input type=text size=35 name=itemdesc class=textboxw value=\"$itemdesc\">";

if ($byuser != "") {
echo " <span class=\"sizemesmaller italme\">".pcrtlang("by")." $byuser</span>";
}

echo "</td><td valign=center>"; 
echo "\n<select name=status onchange='this.form.submit()'><option value=\"$status\">$status</option>";
reset($shopliststatus);
foreach($shopliststatus as $thestatus => $thestatus2) {
echo "<option value=\"$thestatus\">$thestatus</option>\n";
$oldstatus = $status;
}


echo "</select> </td><td><input type=submit value=\"&laquo;".pcrtlang("edit")."\" class=button></form>";

if ($stockid != 0) {
echo "&nbsp;&nbsp;<a href=\"stock.php?func=restock_item&stockid=$stockid&stockqty=$qty\" class=imagelink $therel><img src=\"images/restock.png\" align=absmiddle></a>";
}

echo "</td><td> &nbsp;&nbsp;&nbsp;&nbsp;<a href=shoplist.php?func=remove_item&item_id=$shopid class=\"linkbuttonsmall linkbuttonred radiusall\"><i class=\"fa fa-trash fa-lg\"></i></a></td></tr>";
                                                                                                                                               
}
                                                                                                                                               
                                                                                                                                               
                                                                                                                                               
?>
                                                                                                                                               
</table>
                                                                                                                                               





<?php 


require("footer.php"); 
?>
