Changeset 413
- Timestamp:
- 06/18/08 16:32:34
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/phpbms/modules/bms/products_saleshistory.php
r412 r413 46 46 if(!isset($_POST["status"])) $_POST["status"]="Orders/Invoices"; 47 47 if(!isset($_POST["command"])) $_POST["command"]="show"; 48 if(!isset($_POST["date_order"])) $_POST["date_order"]=" desc";48 if(!isset($_POST["date_order"])) $_POST["date_order"]="DESC"; 49 49 50 50 if($_POST["command"]=="print") { … … 69 69 break; 70 70 } 71 $date_order_reverse = $_POST['date_order'] == 'desc' ? 'asc' : 'desc';71 $dateOrder = ($_POST['date_order'] == 'DESC') ? 'ASC' : 'DESC'; 72 72 73 73 $mysqlfromdate=sqlDateFromString($_POST["fromdate"]); 74 74 $mysqltodate=sqlDateFromString($_POST["todate"]); 75 75 76 $refquery="select partname from products where id=". $_GET["id"];76 $refquery="select partname from products where id=".((int)$_GET["id"]); 77 77 $refquery=$db->query($refquery); 78 78 $refrecord=$db->fetchArray($refquery); 79 79 80 $querystatement="SELECT invoices.id as id, 81 if(invoices.type=\"Invoice\",invoices.invoicedate,invoices.orderdate) as thedate, 82 if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) as client, 83 lineitems.quantity as qty, 84 lineitems.unitprice*lineitems.quantity as extended, 85 lineitems.unitprice as price, lineitems.unitcost as cost, 86 lineitems.unitcost*lineitems.quantity as extendedcost 87 FROM((products inner join lineitems on products.id=lineitems.productid) 88 inner join invoices on lineitems.invoiceid=invoices.id) 89 inner join clients on invoices.clientid=clients.id 90 WHERE products.id=".$_GET["id"]." 91 AND ".$thestatus." 92 HAVING thedate >=\"".$mysqlfromdate."\" 93 and thedate <=\"".$mysqltodate."\" ORDER BY thedate " .$_POST["date_order"]; 80 $querystatement=" 81 SELECT 82 invoices.id AS id, 83 IF(invoices.type=\"Invoice\",invoices.invoicedate,invoices.orderdate) AS thedate, 84 CONCAT(\"<strong>\",IF(clients.lastname!=\"\",CONCAT(clients.lastname,\", \",clients.firstname,IF(clients.company!=\"\",CONCAT(\" (\",clients.company,\")\"),\"\")),clients.company),\"</strong>\") AS client, 85 lineitems.quantity AS qty, 86 lineitems.unitprice*lineitems.quantity AS extended, 87 lineitems.unitprice AS price, 88 lineitems.unitcost AS cost, 89 lineitems.unitcost*lineitems.quantity AS extendedcost 90 FROM 91 ((products INNER JOIN lineitems ON products.id=lineitems.productid) 92 INNER JOIN invoices ON lineitems.invoiceid=invoices.id) 93 INNER JOIN clients ON invoices.clientid=clients.id 94 WHERE 95 products.id=".((int)$_GET["id"])." 96 AND ".$thestatus." 97 HAVING 98 thedate >=\"".$mysqlfromdate."\" 99 AND thedate <=\"".$mysqltodate."\" 100 ORDER BY 101 thedate " .$dateOrder; 94 102 $queryresult=$db->query($querystatement); 95 103 … … 143 151 <th align="center" nowrap="nowrap" class="queryheader" colspan="2">ID</th> 144 152 <th align="center" nowrap="nowrap" class="queryheader"> 145 <a onclick="javascript:document.getElementById('date_order').value='<?php echo $date_order_reverse; ?>'; document.record.submit();">OrderDate</a>153 <a href="#" onclick="javascript:document.getElementById('date_order').value='<?php echo $dateOrder; ?>'; document.record.submit(); return false;">Date</a> 146 154 </th> 147 155 <th nowrap="nowrap" class="queryheader" width="100%" align="left">Client</th> … … 169 177 <tr class="row<?php echo $row?>"> 170 178 <td> 171 <button type="button" class="invisibleButtons" onclick="location.href='<?php echo getAddEditFile($db,3) ?>?id=<?php echo $therecord["id"]?> '"><img src="<?php echo APP_PATH ?>common/stylesheet/<?php echo STYLESHEET ?>/image/button-edit.png" align="middle" alt="edit" width="16" height="16" border="0" /></button>179 <button type="button" class="invisibleButtons" onclick="location.href='<?php echo getAddEditFile($db,3) ?>?id=<?php echo $therecord["id"]?>&backurl=<?php echo urlencode($_SERVER["REQUEST_URI"]); ?>'"><img src="<?php echo APP_PATH ?>common/stylesheet/<?php echo STYLESHEET ?>/image/button-edit.png" align="middle" alt="edit" width="16" height="16" border="0" /></button> 172 180 </td> 173 181 <td align="center" nowrap="nowrap"><?php echo $therecord["id"]?></td> … … 181 189 </tr> 182 190 <?php } if(!$db->numRows($queryresult)) {?> 183 <tr ><td colspan="9" align="center" style="padding:0px;"><div class="norecords">No Sales Data for Given Timeframe</div></td></tr>184 <?php } ?>191 <tr class="norecords"><td colspan="9">No Sales Data for Given Timeframe</td></tr> 192 <?php }else{?> 185 193 <tr> 186 194 <td align="center" class="queryfooter"> </td> 187 195 <td align="center" class="queryfooter"> </td> 188 <td class="queryfooter"> </td> 196 <td align="center" class="queryfooter"> </td> 197 <td align="center" class="queryfooter"> </td> 189 198 <td align="center" class="queryfooter"><?php echo number_format($totalquantity,2)?></td> 190 199 <td align="right" nowrap="nowrap" class="queryfooter">avg. = <?php $numrows?$avgcost=$avgcost/$numrows:$avgcost=0; echo numberToCurrency($avgcost)?></td> … … 193 202 <td align="right" class="queryfooter"><?php echo numberToCurrency($totalextended)?></td> 194 203 </tr> 204 <?php }//end if --numrows-- ?> 195 205 </table></div></form> 196 206 </div>