function showSalesHistory($id) { $thestatus = "(invoices.type =\""; switch ($this->view) { case "Orders/Invoices": $thestatus .= "Order\" or invoices.type=\"Invoice\")"; $searchdate = "orderdate"; break; case "Invoices": $thestatus .= "Invoice\")"; $searchdate = "invoicedate"; break; case "Orders": $thestatus .= "Order\")"; $searchdate = "orderdate"; break; } $mysqlfromdate = sqlDateFromString($_POST["fromdate"]); $mysqltodate = sqlDateFromString($_POST["todate"]); $querystatement = "\n\t\t\tSELECT\n\t\t\t\t`invoices`.`id`,\n\t\t\t\t`invoices`.`orderdate`,\n\t\t\t\t`invoices`.`invoicedate`,\n\t\t\t\tIF(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) AS `client`,\n\t\t\t\t`lineitems`.`quantity` AS `qty`,\n\t\t\t\t`lineitems`.`unitprice`*`lineitems`.`quantity` AS `extended`,\n\t\t\t\t`lineitems`.`unitprice` AS `price`,\n\t\t\t\t`lineitems`.`unitcost` AS `cost`,\n\t\t\t\t`lineitems`.`unitcost`*`lineitems`.`quantity` AS extendedcost\n\t\t\tFROM\n\t\t\t\t((products INNER JOIN lineitems on products.uuid=lineitems.productid)\n\t\t\t\t\tINNER JOIN `invoices` ON lineitems.invoiceid=invoices.id)\n\t\t\t\t\t\tINNER JOIN `clients` on `invoices`.`clientid`=`clients`.`uuid`\n\t\t\tWHERE\n\t\t\t\t`products`.`id`=" . $id . "\n\t\t\t\tAND\n\t\t\t\t`invoices`." . $searchdate . ">=\"" . $mysqlfromdate . "\"\n\t\t\t\tAND\n\t\t\t\t`invoices`." . $searchdate . "<=\"" . $mysqltodate . "\"\n\t\t\t\tAND\n\t\t\t\t" . $thestatus . "\n\t\t\tORDER BY\n\t\t\t\t`invoices`.`invoicedate`,\n\t\t\t\t`invoices`.`orderdate`\n\t\t"; $thequery = $this->db->query($querystatement); $thequery ? $numrows = $this->db->numRows($thequery) : ($numrows = 0); ?> <table border="0" cellpadding="3" cellspacing="0"> <tr> <th align="center" nowrap="nowrap" >ID</th> <th align="center" nowrap="nowrap" >Order Date</th> <th align="center" nowrap="nowrap" >Invc. Date</th> <th nowrap="nowrap" width="100%" align="left">Client</th> <th align="center" nowrap="nowrap" >Qty.</th> <th align="right" nowrap="nowrap" >Unit Cost</th> <th align="right" nowrap="nowrap" >Cost Ext.</th> <th align="right" nowrap="nowrap" >Unit Price</th> <th align="right" nowrap="nowrap">Price Ext.</th> </tr> <?php $totalextended = 0; $totalcostextended = 0; $totalquantity = 0; $avgprice = 0; $avgcost = 0; while ($therecord = $this->db->fetchArray($thequery)) { $avgcost += $therecord["cost"]; $avgprice += $therecord["price"]; $totalquantity += $therecord["qty"]; $totalextended += $therecord["extended"]; $totalcostextended += $therecord["extendedcost"]; ?> <tr> <td align="center" nowrap="nowrap"><?php echo $therecord["id"]; ?> </td> <td align="center" nowrap="nowrap"><?php echo $therecord["orderdate"] ? formatFromSQLDate($therecord["orderdate"]) : " "; ?> </td> <td align="center" nowrap="nowrap"><?php echo $therecord["invoicedate"] ? formatFromSQLDate($therecord["invoicedate"]) : " "; ?> </td> <td nowrap="nowrap"><?php echo $therecord["client"]; ?> </td> <td align="center" nowrap="nowrap"><?php echo number_format($therecord["qty"], 2); ?> </td> <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["cost"]); ?> </td> <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["extendedcost"]); ?> </td> <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["price"]); ?> </td> <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["extended"]); ?> </td> </tr> <?php } ?> <tr> <td align="center" class="grandtotals"> </td> <td align="center" class="grandtotals"> </td> <td class="grandtotals"> </td> <td class="grandtotals"> </td> <td align="center" class="grandtotals"><?php echo number_format($totalquantity, 2); ?> </td> <td align="right" nowrap="nowrap"class="grandtotals">avg. = <?php $numrows ? $avgcost = $avgcost / $numrows : ($avgcost = 0); echo numberToCurrency($avgcost); ?> </td> <td align="right" class="grandtotals"><?php echo numberToCurrency($totalcostextended); ?> </td> <td align="right" nowrap="nowrap" class="grandtotals">avg. = <?php $numrows ? $avgprice = $avgprice / $numrows : ($avgprice = 0); echo numberToCurrency($avgprice); ?> </td> <td align="right" class="grandtotals"><?php echo numberToCurrency($totalextended); ?> </td> </tr> </table> <?php }
function display($clientInfo) { $invoiceEditFile = getAddEditFile($this->db, "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883"); $noteEditFile = getAddEditFile($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1"); $clientEditFile = getAddEditFile($this->db, "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"); ?> <div class="bodyline" id="theDetails"> <div id="rightSideDiv"> <fieldset> <legend>sales</legend> <ul class="recordCommands"> <li class="firstToolbarItem"><a href="#" class="newRecord" onclick="addEditRecord('new','invoice','<?php echo getAddEditFile($this->db, "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883", "add"); ?> ')" title="new sales order"><span>new</span></a></li> <li><a href="#" id="invoiceedit" class="editRecordDisabled" onclick="addEditRecord('edit','invoice','<?php echo $invoiceEditFile; ?> ')" title="edit"><span>edit</span></a></li> </ul> <div class="recordContainers"> <div id="salesTable" class="smallQueryTableHolder"> <?php if (!count($clientInfo["invoices"])) { ?> <div class="small"><em>no records</em></div> <?php } else { ?> <table border="0" cellpadding="0" cellspacing="0" class="smallQueryTable"> <tr> <th align="left">ID</th> <th align="left">Type</th> <th align="left">Date</th> <th align="right" width="100%">Total</th> </tr> <?php foreach ($clientInfo["invoices"] as $invoicerecord) { if ($invoicerecord["type"] == "VOID") { $invoicerecord["totalti"] = "-----"; } ?> <tr onclick="selectEdit(this,<?php echo $invoicerecord["id"]; ?> ,'invoice')" ondblclick="selectedInvoice=<?php echo $invoicerecord["id"]; ?> ;addEditRecord('edit','invoice','<?php echo $invoiceEditFile; ?> ')"> <td><?php echo $invoicerecord["id"]; ?> </td> <td><?php echo $invoicerecord["type"]; ?> </td> <td nowrap="nowrap"><?php echo formatFromSQLDate($invoicerecord["thedate"]); ?> </td> <td align="right"><?php echo numberToCurrency($invoicerecord["totalti"]); ?> </td> </tr> <?php } ?> </table><?php } ?> </div> </div> </fieldset> <fieldset> <legend>notes</legend> <ul class="recordCommands"> <li class="firstToolbarItem"><a href="#" title="new note" class="newRecord" onclick="addEditRecord('new','note','<?php echo getAddEditFile($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1", "add"); ?> ')"><span>new</span></a></li> <li><a href="#" title="edit" id="noteedit" class="editRecordDisabled" onclick="addEditRecord('edit','note','<?php echo $noteEditFile; ?> ')"><span>edit</span></a></li> </ul> <div class="recordContainers"> <div id="notesTable" class="smallQueryTableHolder"> <?php if (!count($clientInfo["notes"])) { ?> <div class="small"><em>no records</em></div> <?php } else { ?> <table border="0" cellpadding="0" cellspacing="0" class="smallQueryTable"> <tr> <th align="left">type</th> <th align="left">category</th> <th align="left" width="100%">title</th> <th align="center">done</th> </tr> <?php foreach ($clientInfo["notes"] as $noterecord) { if (strlen($noterecord["subject"]) > 17) { $noterecord["subject"] = substr($noterecord["subject"], 0, 17) . "..."; } if (strlen($noterecord["category"]) > 17) { $noterecord["category"] = substr($noterecord["category"], 0, 17) . "..."; } ?> <tr onclick="selectEdit(this,<?php echo $noterecord["id"]; ?> ,'note')" ondblclick="selectedNote=<?php echo $noterecord["id"]; ?> ;addEditRecord('edit','note','<?php echo $noteEditFile; ?> ')"> <td><?php echo $noterecord["type"]; ?> </td> <td><?php echo $noterecord["category"]; ?> </td> <td><?php echo $noterecord["subject"]; ?> </td> <td align="center"><?php echo booleanFormat($noterecord["completed"]); ?> </td> </tr> <?php } ?> </table><?php } ?> </div> </div> </fieldset> </div> <div id="leftSideDiv"> <fieldset id="crTile" class="fs<?php echo $clientInfo["type"]; ?> "> <h1> <input type="hidden" id="theid" value="<?php echo $clientInfo["id"]; ?> " /> <input type="hidden" id="theuuid" value="<?php echo $clientInfo["uuid"]; ?> " /> <?php if ($clientInfo["company"]) { echo htmlQuotes($clientInfo["company"]); } else { echo htmlQuotes($clientInfo["firstname"] . " " . $clientInfo["lastname"]); } ?> <button id="viewClientButton" type="button" title="view client" class="graphicButtons buttonInfo" onclick="addEditRecord('edit','client','<?php echo $clientEditFile; ?> ')"><span>view client</span></button></h1> <?php if ($clientInfo["company"] && $clientInfo["firstname"] && $clientInfo["lastname"]) { ?> <p id="crName"><?php echo htmlQuotes($clientInfo["firstname"]); ?> <?php echo htmlQuotes($clientInfo["lastname"]); ?> </p><?php } //endif ?> <?php $location = ""; $location .= htmlQuotes($clientInfo["address1"]); if ($clientInfo["address2"]) { $location .= "<br />" . htmlQuotes($clientInfo["address2"]); } if ($clientInfo["city"] || $clientInfo["state"] || $clientInfo["postalcode"]) { $location .= "<br/>" . htmlQuotes($clientInfo["city"]); if ($clientInfo["city"] && $clientInfo["state"]) { $location .= ", "; } $location .= htmlQuotes($clientInfo["state"]); $location .= " " . htmlQuotes($clientInfo["postalcode"]); } //endif if ($clientInfo["country"]) { $location .= "<br />" . htmlQuotes($clientInfo["country"]); } if ($location == "") { $location = "unspecified location"; } ?> <p id="crLocation"><?php echo $location; ?> </p> </fieldset> <fieldset> <legend>Contact</legend> <?php if ($clientInfo["workphone"] || $clientInfo["homephone"] || $clientInfo["mobilephone"] || $clientInfo["otherphone"] || $clientInfo["fax"]) { ?> <p class="RDNames">phone</p> <div class="fauxP RDData"> <ul> <?php if ($clientInfo["workphone"]) { ?> <li><?php echo $clientInfo["workphone"]; ?> (w)</li> <?php } ?> <?php if ($clientInfo["homephone"]) { ?> <li><?php echo $clientInfo["homephone"]; ?> (h)</li> <?php } ?> <?php if ($clientInfo["mobilephone"]) { ?> <li><?php echo $clientInfo["mobilephone"]; ?> (m)</li> <?php } ?> <?php if ($clientInfo["otherphone"]) { ?> <li><?php echo $clientInfo["otherphone"]; ?> (o)</li> <?php } ?> <?php if ($clientInfo["fax"]) { ?> <li><?php echo $clientInfo["fax"]; ?> (fax)</li> <?php } ?> </ul> </div> <?php } ?> <?php if ($clientInfo["email"]) { ?> <p class="RDNames">e-mail</p> <p class="RDData"> <button type="button" class="graphicButtons buttonEmail" onclick="document.location='mailto:<?php echo $clientInfo["email"]; ?> '"><span>send email</span></button> <a href="mailto:<?php echo $clientInfo["email"]; ?> "><?php echo htmlQuotes($clientInfo["email"]); ?> </a> </p> <?php } ?> <?php if ($clientInfo["webaddress"]) { ?> <p class="RDNames">web site</p> <p class="RDData"> <button type="button" class="graphicButtons buttonWWW" onclick="window.open('<?php echo $clientInfo["webaddress"]; ?> ')"><span>visit site</span></button> <a href="<?php echo $clientInfo["webaddress"]; ?> " target="_blank"><?php echo htmlQuotes($clientInfo["webaddress"]); ?> </a> </p> <?php } ?> </fieldset> <fieldset> <legend>Details</legend> <?php if ($clientInfo["becameclient"]) { ?> <p class="RDNames">became client</p> <p class="RDData"> <?php echo formatVariable($clientInfo["becameclient"], "date"); ?> </p> <?php } ?> <?php if ($clientInfo["category"]) { ?> <p class="RDNames">category</p> <p class="RDData"> <?php echo htmlQuotes($clientInfo["category"]); ?> </p> <?php } ?> <?php if ($clientInfo["leadsource"]) { ?> <p class="RDNames">lead source</p> <p class="RDData"> <?php echo htmlQuotes($clientInfo["leadsource"]); ?> </p> <?php } ?> <?php if ($clientInfo["salesmanagerid"]) { global $phpbms; ?> <p class="RDNames">sales person</p> <p class="RDData"> <?php echo htmlQuotes($phpbms->getUserName($clientInfo["salesmanagerid"])); ?> </p> <?php } ?> </fieldset> <?php if ($clientInfo["comments"]) { ?> <fieldset> <legend>memo</legend> <p> <?php echo htmlQuotes($clientInfo["comments"]); ?> </p> </fieldset> <?php } ?> </div> <p id="theclear"> </p> </div> <?php }
function display() { if ($this->displayLabel) { $this->showLabel(); } if (!is_numeric($this->value)) { $this->value = 0; } $this->value = htmlQuotes(numberToCurrency($this->value)); if (!isset($this->_attributes["onchange"])) { $this->_attributes["onchange"] = ""; } $this->_attributes["onchange"] = "validateCurrency(this);" . $this->_attributes["onchange"]; if (!isset($this->_attributes["class"])) { $this->_attributes["class"] = ""; } else { $this->_attributes["class"] = " " . $this->_attributes["class"]; } $this->_attributes["class"] = "currency" . $this->_attributes["class"]; ?> <input name="<?php echo $this->name; ?> " id="<?php echo $this->id; ?> " type="text" value="<?php echo $this->value; ?> " <?php $this->displayAttributes(); ?> /><?php }
<p> <strong>Orders</strong> (<?php echo $stats["Order"]["total"]; ?> )<br/> total: <?php echo numberToCurrency($stats["Order"]["sum"]); ?> </p> <p> <strong>Invoices</strong> (<?php echo $stats["Invoice"]["total"]; ?> )<br /> total: <?php echo numberToCurrency($stats["Invoice"]["sum"]); ?> </p> </fieldset> </div> <div id="nameDiv"> <fieldset> <legend>name</legend> <p class="big"> <?php $theform->showField("name"); ?> </p> </fieldset>
function showLineItems($invoiceid, $indent) { $querystatement = "\n\t\t\tSELECT\n\t\t\t\t`products`.`partnumber`,\n\t\t\t\t`products`.`partname`,\n\t\t\t\t`quantity`,\n\t\t\t\t`lineitems`.`unitprice`,\n\t\t\t\t`quantity`*`lineitems`.`unitprice` AS `extended`\n\t\t\tFROM\n\t\t\t\t(`lineitems` LEFT JOIN `products` ON `lineitems`.`productid`=`products`.`uuid`)\n\t\t\tWHERE\n\t\t\t\t`lineitems`.`invoiceid`='" . $invoiceid . "'"; $queryresult = $this->db->query($querystatement); if ($this->db->numRows($queryresult)) { ?> <tr><td class="invoices" style="padding-left:<?php echo $indent + 2; ?> px;"> <table border="0" cellspacing="0" cellpadding="0" id="lineitems"> <tr> <th width="65%" align="left">product</th> <th width="24%" align="right" nowrap="nowrap">price</th> <th width="12%" align="right" nowrap="nowrap">qty.</th> <th width="24%" align="right" nowrap="nowrap">ext.</th> </tr> <?php while ($therecord = $this->db->fetchArray($queryresult)) { ?> <tr> <td><?php echo $therecord["partnumber"]; ?> <?php echo $therecord["partname"]; ?> </td> <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["unitprice"]); ?> </td> <td align="right" nowrap="nowrap"><?php echo formatVariable($therecord["quantity"], "real"); ?> </td> <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["extended"]); ?> </td> </tr> <?php } // endwhile ?> </table></td> <?php for ($i = 1; $i < count($this->selectcolumns); $i++) { echo "<td> </td>"; } ?> </tr><?php } // endif }
function generateSingleClientHistory($clientUUID) { $theStatus = "(invoices.type = '"; switch ($this->view) { case "Orders and Invoices": $theStatus .= "Order' OR invoices.type ='Invoice')"; $searchDate = "orderdate"; break; case "Invoices": $theStatus .= "Invoice')"; $searchDate = "invoicedate"; break; case "Orders": $theStatus .= "Order')"; $searchDate = "orderdate"; break; } //endswitch $mysqlFromDate = sqlDateFromString($this->fromDate); $mysqlToDate = sqlDateFromString($this->toDate); $querystatement = "\n SELECT\n invoices.id,\n if(invoices.type = 'Invoice', invoices.invoicedate, invoices.orderdate) AS thedate,\n invoices.type,\n products.partname AS partname,\n products.partnumber AS partnumber,\n lineitems.quantity AS qty,\n lineitems.unitprice*lineitems.quantity AS extended,\n lineitems.unitprice AS price\n FROM\n ((`clients` INNER JOIN `invoices` ON `clients`.`uuid`=`invoices`.`clientid`)\n INNER JOIN `lineitems` ON `invoices`.`id`=`lineitems`.`invoiceid`)\n INNER JOIN `products` ON `lineitems`.`productid`=`products`.`uuid`\n WHERE\n `clients`.`uuid`='" . $clientUUID . "'\n AND " . $theStatus . "\n HAVING\n thedate >= '" . $mysqlFromDate . "'\n AND thedate <= '" . $mysqlToDate . "'\n ORDER BY\n thedate,\n invoices.id"; $queryresult = $this->db->query($querystatement); ob_start(); ?> <table border="0" cellpadding="0" cellspacing="0"> <thead> <tr> <th align="left" colspan="3">invoice</th> <th align="left" colspan="3">product</th> <th align="left" nowrap="nowrap" colspan="2" class="lastHeader">line item</th> </tr> <tr> <th align="center" nowrap="nowrap">id</th> <th align="left" nowrap="nowrap" >type</th> <th align="left" nowrap="nowrap" >date</th> <th align="left" nowrap="nowrap" >part #</th> <th width="100%" nowrap="nowrap" align="left">name</th> <th align="right" nowrap="nowrap" >price</th> <th align="right" nowrap="nowrap" >qty.</th> <th align="right" nowrap="nowrap" class="lastHeader">ext.</th> </tr> </thead> <tbody> <?php $totalextended = 0; while ($therecord = $this->db->fetchArray($queryresult)) { $totalextended += $therecord["extended"]; ?> <tr> <td align="left" nowrap="nowrap"><?php echo $therecord["id"] ? $therecord["id"] : " "; ?> </td> <td align="left" nowrap="nowrap"><?php echo $therecord["type"] ? formatVariable($therecord["type"]) : " "; ?> </td> <td align="left" nowrap="nowrap"><?php echo $therecord["thedate"] ? formatFromSQLDate($therecord["thedate"]) : " "; ?> </td> <td nowrap="nowrap"><?php echo formatVariable($therecord["partnumber"]); ?> </td> <td nowrap="nowrap"><?php echo formatVariable($therecord["partname"]); ?> </td> <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["price"]); ?> </td> <td align="right" nowrap="nowrap"><?php echo $therecord["qty"]; ?> </td> <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["extended"]); ?> </td> </tr> <?php } //endwhile ?> <tr class="grandTotals"> <td colspan="7" align="right">total</td> <td align="right"><?php echo numberToCurrency($totalextended); ?> </td> </tr> </tbody> </table><?php $output = ob_get_contents(); ob_end_clean(); return $output; }
</tr> <tr> <td colspan="4" class="invoiceTotalLabels" id="totalSpacer"><div> </div></td> </tr> <tr> <td colspan="2" class="invoiceTotalLabels vTabs" id="vTab4"><div>payment</div></td> <td class="totalItems"><input name="amountpaid" id="amountpaid" type="text" value="<?php echo numberToCurrency($therecord["amountpaid"]); ?> " size="12" maxlength="15" onchange="calculatePaidDue();" class="important fieldCurrency fieldTotal" /></td> <td class="totalItems"><button id="payinfull" type="button" onclick="payInFull()" class="graphicButtons buttonCheck" title="Pay in full"><span>pay in full</span></button></td> </tr> <tr id="lastTotalsTr"> <td colspan="2" class="invoiceTotalLabels" nowrap="nowrap"><div>amount due</div></td> <td class="totalItems"><input id="amountdue" name="amountdue" type="text" value="<?php echo numberToCurrency($therecord["amountdue"]); ?> " size="12" maxlength="15" onchange="calculatePaidDue();" class="important fieldCurrency fieldTotal" /></td> <td class="totalItems"> </td> </tr> </tbody> </table> </fieldset> <fieldset id="fsInstructions"> <legend>instructions</legend> <p> <label for="specialinstructions">special instructions</label> <span class="notes"><em>(will not print on invoice)</em></span><br /> <textarea id="specialinstructions" name="specialinstructions" cols="45" rows="3"><?php echo $therecord["specialinstructions"];
function showLineItems($where, $indent) { $querystatement = "\n\t\t\tSELECT\n\t\t\t\t`lineitems`.`invoiceid`,\n\t\t\t\tIF(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) AS `thename`,\n\t\t\t\t`invoices`.`invoicedate`,\n\t\t\t\t`invoices`.`orderdate`,\n\t\t\t\t`lineitems`.`id`,\n\t\t\t\t`products`.`partnumber`,\n\t\t\t\t`products`.`partname`,\n\t\t\t\t`quantity`,\n\t\t\t\t`lineitems`.`unitprice`,\n\t\t\t\t`quantity`*`lineitems`.`unitprice` AS `extended`\n\t\t\tFROM " . $this->selecttable . $this->whereClause . $where . " GROUP BY lineitems.id\n\t\t"; $queryresult = $this->db->query($querystatement); if ($this->db->numRows($queryresult)) { ?> <tr><td class="invoices" style="padding-left:<?php echo $indent + 2; ?> px;"> <table border="0" cellspacing="0" cellpadding="0" id="lineitems"> <tr> <th align="left">id</th> <th align="left">date</th> <th width="20%" align="left" >client</th> <th width="60%" align="left">product</th> <th width="9%" align="right" nowrap="nowrap">price</th> <th width="8%" align="right" nowrap="nowrap">qty.</th> <th width="7%" align="right" nowrap="nowrap">ext.</th> </tr> <?php while ($therecord = $this->db->fetchArray($queryresult)) { ?> <tr> <td nowrap="nowrap"><?php echo $therecord["invoiceid"]; ?> </td> <td nowrap="nowrap"><?php if ($therecord["invoicedate"]) { echo formatFromSQLDate($therecord["invoicedate"]); } else { echo "<strong>" . formatFromSQLDate($therecord["orderdate"]) . "</strong>"; } ?> </td> <td><?php echo $therecord["thename"]; ?> </td> <td width="60%" nowrap="nowrap"><?php echo $therecord["partnumber"]; ?> <?php echo $therecord["partname"]; ?> </td> <td width="9%" align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["unitprice"]); ?> </td> <td width="8%" align="center" nowrap="nowrap"><?php echo formatVariable($therecord["quantity"], "real"); ?> </td> <td width="7%" align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["extended"]); ?> </td> </tr> <?php } // endwhile ?> </table></td> <?php for ($i = 1; $i < count($this->selectcolumns); $i++) { echo "<td> </td>"; } ?> </tr><?php } // endif }
?> </td> <td align="right" nowrap="nowrap" >avg. = <?php $numrows ? $avgcost = $avgcost / $numrows : ($avgcost = 0); echo numberToCurrency($avgcost); ?> </td> <td align="right" ><?php echo numberToCurrency($totalcostextended); ?> </td> <td align="right" nowrap="nowrap" >avg. = <?php $numrows ? $avgprice = $avgprice / $numrows : ($avgprice = 0); echo numberToCurrency($avgprice); ?> </td> <td align="right" ><?php echo numberToCurrency($totalextended); ?> </td> </tr> </tfoot> <?php echo $tbody; ?> </table></div></form> </div> <?php include "footer.php"; } //end if
function formatVariable($value, $format = NULL) { switch ($format) { case "real": $value = number_format($value, 2); break; case "currency": $value = htmlQuotes(numberToCurrency($value)); break; case "boolean": $value = booleanFormat($value); break; case "date": $value = formatFromSQLDate($value); break; case "time": $value = formatFromSQLTime($value); break; case "datetime": $value = formatFromSQLDatetime($value); break; case "filelink": $value = "<button class=\"graphicButtons buttonDownload\" type=\"button\" onclick=\"document.location='" . APP_PATH . "servefile.php?i=" . $value . "'\"><span>download</span></button>"; //$value="<a href=\"".APP_PATH."servefile.php?i=".$value."\" style=\"display:block;\"><img src=\"".APP_PATH."common/stylesheet/".STYLESHEET."/image/button-download.png\" align=\"middle\" alt=\"view\" width=\"16\" height=\"16\" border=\"0\" /></a>"; break; case "invoice": if ($value > 0 and $value != 9999999) { $value = "<a href=\"" . APP_PATH . "modules/bms/invoices_addedit.php?id={$value}\">{$value}</a>"; } break; case "client": $value = "<a href=\"" . APP_PATH . "modules/bms/clients_addedit.php?id={$value}\">{$value}</a>"; break; case "noencoding": $value = $value; break; case "bbcode": $value = htmlQuotes($value); // This list needs to be expanded $bbcodelist["[b]"] = "<strong>"; $bbcodelist["[/b]"] = "</strong>"; $bbcodelist["[br]"] = "<br />"; $bbcodelist["[space]"] = " "; foreach ($bbcodelist as $bbcode => $translation) { $value = str_replace($bbcode, $translation, $value); } break; default: $value = htmlQuotes($value); } return $value; }
function getDiscount($uuid) { $therecord["name"] = ""; $therecord["value"] = 0; if ($uuid) { $uuid = mysql_real_escape_string($uuid); $querystatement = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`name`,\n\t\t\t\t\t\t`type`,\n\t\t\t\t\t\t`value`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`discounts`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`uuid`='" . $uuid . "'\n\t\t\t\t"; $queryresult = $this->db->query($querystatement); $therecord = $this->db->fetchArray($queryresult); if ($therecord["type"] != "amount") { $therecord["value"] .= "%"; $therecord["name"] .= ": " . $therecord["value"]; } else { $therecord["name"] .= ": " . numberToCurrency($therecord["value"]); } } $therecord["name"] = htmlQuotes($therecord["name"]); return $therecord; }