| 40 | | if(!isset($fromClient)) { |
| 41 | | require_once("../../../include/session.php"); |
| 42 | | } |
| 43 | | |
| 44 | | class purchaseHistoryReport{ |
| 45 | | |
| 46 | | var $whereclause=""; |
| 47 | | var $sortorder=" ORDER BY IF(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) "; |
| 48 | | var $fromdate; |
| 49 | | var $todate; |
| 50 | | var $view; |
| 51 | | |
| 52 | | var $clientQuery; |
| 53 | | |
| 54 | | function initialize($variables,$db){ |
| 55 | | |
| 56 | | $this->db = $db; |
| 57 | | $this->fromdate=$variables["fromdate"]; |
| 58 | | $this->todate=$variables["todate"]; |
| 59 | | $this->view=$variables["status"]; |
| 60 | | |
| 61 | | $this->whereclause=$_SESSION["printing"]["whereclause"]; |
| 62 | | if(isset($_SESSION["printing"]["sortorder"])) |
| 63 | | if ($_SESSION["printing"]["sortorder"]) |
| 64 | | $this->sortorder=$_SESSION["printing"]["sortorder"]; |
| 65 | | |
| 66 | | if($this->whereclause=="") $this->whereclause="WHERE clients.id!=-1"; |
| 67 | | $this->whereclause=" WHERE (".substr($this->whereclause,6).") "; |
| 68 | | |
| 69 | | $querystatement = " |
| 70 | | SELECT |
| 71 | | `clients`.`id`, |
| 72 | | IF(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) as thename |
| 73 | | FROM |
| 74 | | `clients` ".$this->whereclause.$this->sortorder; |
| 75 | | |
| 76 | | $queryresult=$this->db->query($querystatement); |
| 77 | | |
| 78 | | $this->clientQuery=$queryresult; |
| 79 | | } |
| 80 | | |
| 81 | | |
| 82 | | function showPurchaseHistory($id){ |
| 83 | | |
| 84 | | $thestatus="(invoices.type =\""; |
| 85 | | switch($this->view){ |
| 86 | | case "Orders/Invoices": |
| 87 | | $thestatus.="Order\" or invoices.type=\"Invoice\")"; |
| 88 | | $searchdate="orderdate"; |
| 89 | | break; |
| 90 | | case "Invoices": |
| 91 | | $thestatus.="Invoice\")"; |
| 92 | | $searchdate="invoicedate"; |
| 93 | | break; |
| 94 | | case "Orders": |
| 95 | | $thestatus.="Order\")"; |
| 96 | | $searchdate="orderdate"; |
| 97 | | break; |
| 98 | | } |
| 99 | | |
| 100 | | $mysqlfromdate=sqlDateFromString($_POST["fromdate"]); |
| 101 | | $mysqltodate=sqlDateFromString($_POST["todate"]); |
| | 40 | if(!class_exists("phpbmsReport")) |
| | 41 | include("../../../report/report_class.php"); |
| | 42 | |
| | 43 | class purchaseHistoryReport extends phpbmsReport{ |
| | 44 | |
| | 45 | var $fromDate; |
| | 46 | var $toDate; |
| | 47 | var $view; |
| | 48 | var $clientQueryresult; |
| | 49 | var $dataPrint; |
| | 50 | |
| | 51 | function purchaseHistoryReport($db, $reportUUID, $tabledefUUID){ |
| | 52 | |
| | 53 | parent::phpbmsReport($db, $reportUUID, $tabledefUUID); |
| | 54 | |
| | 55 | //$this->checkForDefaultSettings(); |
| | 56 | |
| | 57 | }//end function init |
| | 58 | |
| | 59 | |
| | 60 | function initialize($variables){ |
| | 61 | |
| | 62 | if(!isset($variables["fromdate"]) || !isset($variables["todate"]) || !isset($variables["status"])) |
| | 63 | $error = new appError(300, "Missing Passed Parameters"); |
| | 64 | |
| | 65 | $this->fromDate = $variables["fromdate"]; |
| | 66 | $this->toDate = $variables["todate"]; |
| | 67 | $this->view = $variables["status"]; |
| | 68 | |
| | 69 | $this->dataPrint = $_SESSION["printing"]["dataprint"]; |
| | 70 | |
| | 71 | if(!$this->sortOrder) |
| | 72 | $this->sortOrder = " ORDER BY clients.company, clients.firstname, clients.lastname"; |
| | 73 | |
| | 74 | if(!$this->whereClause) |
| | 75 | $this->whereClause = "clients.id!=-1"; |
| | 76 | |
| | 77 | $this->whereClause = " WHERE (".$this->whereClause.") "; |
| | 78 | |
| | 79 | $querystatement = " |
| | 80 | SELECT |
| | 81 | `clients`.`uuid`, |
| | 82 | IF(clients.company != '', CONCAT(clients.company,IF(clients.lastname != '' OR clients.firstname != '', CONCAT(' (',if(clients.lastname != '', clients.lastname, '{blank}'),', ',if(clients.firstname != '', clients.firstname, '{blank}'),')'), '')), IF(clients.lastname != '' OR clients.firstname != '', CONCAT(if(clients.lastname != '', clients.lastname, '{blank}'),', ',if(clients.firstname != '', clients.firstname, '{blank}')), '')) AS thename |
| | 83 | FROM |
| | 84 | `clients` |
| | 85 | ".$this->whereClause.$this->sortOrder; |
| | 86 | |
| | 87 | $this->clientQueryresult = $this->db->query($querystatement); |
| | 88 | |
| | 89 | }//end function initialize |
| | 90 | |
| | 91 | |
| | 92 | function generateSingleClientHistory($clientUUID){ |
| | 93 | |
| | 94 | $theStatus = "(invoices.type = '"; |
| | 95 | |
| | 96 | switch($this->view){ |
| | 97 | |
| | 98 | case "Orders and Invoices": |
| | 99 | $theStatus .= "Order' OR invoices.type ='Invoice')"; |
| | 100 | $searchDate = "orderdate"; |
| | 101 | break; |
| | 102 | |
| | 103 | case "Invoices": |
| | 104 | $theStatus .= "Invoice')"; |
| | 105 | $searchDate = "invoicedate"; |
| | 106 | break; |
| | 107 | |
| | 108 | case "Orders": |
| | 109 | $theStatus .= "Order')"; |
| | 110 | $searchDate = "orderdate"; |
| | 111 | break; |
| | 112 | |
| | 113 | }//endswitch |
| | 114 | |
| | 115 | $mysqlFromDate = sqlDateFromString($this->fromDate); |
| | 116 | $mysqlToDate = sqlDateFromString($this->toDate); |
| 104 | | SELECT |
| 105 | | invoices.id, |
| 106 | | if(invoices.type=\"Invoice\",invoices.invoicedate,invoices.orderdate) as thedate, |
| 107 | | if(invoices.type=\"Invoice\",invoices.invoicedate,invoices.orderdate) as formateddate, |
| 108 | | invoices.type, |
| 109 | | products.partname as partname, |
| 110 | | products.partnumber as partnumber, |
| 111 | | lineitems.quantity as qty, |
| 112 | | lineitems.unitprice*lineitems.quantity as extended, |
| 113 | | lineitems.unitprice as price |
| 114 | | FROM |
| 115 | | ((`clients` INNER JOIN `invoices` ON `clients`.`uuid`=`invoices`.`clientid`) |
| 116 | | INNER JOIN `lineitems` ON `invoices`.`id`=`lineitems`.`invoiceid`) |
| 117 | | INNER JOIN `products` ON `lineitems`.`productid`=`products`.`uuid` |
| 118 | | WHERE `clients`.`id`='".$id."' |
| 119 | | AND ".$thestatus." |
| 120 | | HAVING |
| 121 | | thedate >=\"".$mysqlfromdate."\" |
| 122 | | and thedate <=\"".$mysqltodate."\" |
| 123 | | ORDER BY thedate,invoices.id;"; |
| 124 | | $thequery=$this->db->query($querystatement); |
| 125 | | |
| 126 | | $thequery? $numrows=$this->db->numRows($thequery): $numrows=0; |
| 127 | | ?> |
| 128 | | <table border="0" cellpadding="0" cellspacing="0" > |
| | 119 | SELECT |
| | 120 | invoices.id, |
| | 121 | if(invoices.type = 'Invoice', invoices.invoicedate, invoices.orderdate) AS thedate, |
| | 122 | invoices.type, |
| | 123 | products.partname AS partname, |
| | 124 | products.partnumber AS partnumber, |
| | 125 | lineitems.quantity AS qty, |
| | 126 | lineitems.unitprice*lineitems.quantity AS extended, |
| | 127 | lineitems.unitprice AS price |
| | 128 | FROM |
| | 129 | ((`clients` INNER JOIN `invoices` ON `clients`.`uuid`=`invoices`.`clientid`) |
| | 130 | INNER JOIN `lineitems` ON `invoices`.`id`=`lineitems`.`invoiceid`) |
| | 131 | INNER JOIN `products` ON `lineitems`.`productid`=`products`.`uuid` |
| | 132 | WHERE |
| | 133 | `clients`.`uuid`='".$clientUUID."' |
| | 134 | AND ".$theStatus." |
| | 135 | HAVING |
| | 136 | thedate >= '".$mysqlFromDate."' |
| | 137 | AND thedate <= '".$mysqlToDate."' |
| | 138 | ORDER BY |
| | 139 | thedate, |
| | 140 | invoices.id"; |
| | 141 | |
| | 142 | $queryresult = $this->db->query($querystatement); |
| | 143 | |
| | 144 | ob_start(); |
| | 145 | |
| | 146 | ?> |
| | 147 | <table border="0" cellpadding="0" cellspacing="0"> |
| | 148 | <thead> |
| 141 | | <th align="center" nowrap="nowrap" >qty.</th> |
| 142 | | <th align="right" nowrap="nowrap" >ext.</th> |
| 143 | | </tr> |
| 144 | | <?php |
| 145 | | $totalextended=0; |
| 146 | | while ($therecord=$this->db->fetchArray($thequery)){ |
| 147 | | $totalextended=$totalextended+$therecord["extended"]; |
| 148 | | ?> |
| 149 | | <tr> |
| 150 | | <td align="left" nowrap="nowrap"><?php echo $therecord["id"]?$therecord["id"]:" " ?></td> |
| 151 | | <td align="left" nowrap="nowrap"><?php echo $therecord["type"]?$therecord["type"]:" " ?></td> |
| 152 | | <td align="left" nowrap="nowrap"><?php echo $therecord["formateddate"]?$therecord["formateddate"]:" " ?></td> |
| 153 | | <td nowrap="nowrap"><?php echo $therecord["partnumber"]?></td> |
| 154 | | <td nowrap="nowrap"><?php echo $therecord["partname"]?></td> |
| 155 | | <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["price"])?></td> |
| 156 | | <td align="center" nowrap="nowrap"><?php echo $therecord["qty"]?></td> |
| 157 | | <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["extended"])?></td> |
| 158 | | </tr> |
| 159 | | <?php }//end while ?> |
| 160 | | <tr> |
| 161 | | <td align="center" class="grandtotals"> </td> |
| 162 | | <td align="center" class="grandtotals"> </td> |
| 163 | | <td align="center" class="grandtotals"> </td> |
| 164 | | <td class="grandtotals"> </td> |
| 165 | | <td class="grandtotals"> </td> |
| 166 | | <td align="right" class="grandtotals"> </td> |
| 167 | | <td align="center" class="grandtotals"> </td> |
| 168 | | <td align="right" class="grandtotals"><?php echo numberToCurrency($totalextended)?></td> |
| 169 | | </tr> |
| 170 | | </table> <?php |
| 171 | | }//end fucntion showSalesHistory($id) |
| 172 | | |
| 173 | | function showReport(){ |
| 174 | | ?> |
| 175 | | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 176 | | <html> |
| 177 | | <head> |
| 178 | | <title>Client Purchase History</title> |
| 179 | | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 180 | | <style type="text/css"> |
| 181 | | <!-- |
| 182 | | BODY,TH,TD,H1,H2,h3{ |
| 183 | | font-size : 11px; |
| 184 | | font-family : sans-serif; |
| 185 | | color : Black; |
| 186 | | } |
| 187 | | H1,H2, LI{ |
| 188 | | font-size:18px; |
| 189 | | border-bottom:4px solid black; |
| 190 | | margin:0px; |
| 191 | | } |
| 192 | | H2, LI{ font-size:11px; border-bottom-width:2px; margin-bottom:10px;} |
| 193 | | H3{ font-size:14px; margin-bottom:2px;} |
| 194 | | div {padding:5px;} |
| 195 | | |
| 196 | | UL{margin:0;padding:0;} |
| 197 | | LI{float:left;display:inline;padding-left:10px;} |
| 198 | | |
| 199 | | TABLE{border:3px solid black;border-bottom-width:1px;border-right-width:1px;} |
| 200 | | TH, TD{ padding:2px; border-right:1px solid black;border-bottom:1px solid black;} |
| 201 | | TH { |
| 202 | | background-color:#EEEEEE; |
| 203 | | font-size:12px; |
| 204 | | font-weight: bold; |
| 205 | | border-bottom-width:3px; |
| 206 | | } |
| 207 | | |
| 208 | | .grandtotals{font-size:12px; border-top:3px double black; font-weight:bold; padding-top:8px;padding-bottom:8px; background-color:#EEEEEE;} |
| 209 | | |
| 210 | | --> |
| 211 | | </style> |
| 212 | | </head> |
| 213 | | <body> |
| 214 | | <h1>Client Purchase History</h1> |
| | 161 | <th align="right" nowrap="nowrap" >qty.</th> |
| | 162 | <th align="right" nowrap="nowrap" class="lastHeader">ext.</th> |
| | 163 | </tr> |
| | 164 | </thead> |
| | 165 | <tbody> |
| | 166 | <?php |
| | 167 | |
| | 168 | $totalextended = 0; |
| | 169 | |
| | 170 | while($therecord = $this->db->fetchArray($queryresult)){ |
| | 171 | |
| | 172 | $totalextended += $therecord["extended"]; |
| | 173 | |
| | 174 | ?> |
| | 175 | <tr> |
| | 176 | <td align="left" nowrap="nowrap"><?php echo $therecord["id"]?$therecord["id"]:" " ?></td> |
| | 177 | <td align="left" nowrap="nowrap"><?php echo $therecord["type"]?formatVariable($therecord["type"]):" " ?></td> |
| | 178 | <td align="left" nowrap="nowrap"><?php echo $therecord["thedate"]?formatFromSQLDate($therecord["thedate"]):" " ?></td> |
| | 179 | <td nowrap="nowrap"><?php echo formatVariable($therecord["partnumber"]) ?></td> |
| | 180 | <td nowrap="nowrap"><?php echo formatVariable($therecord["partname"]) ?></td> |
| | 181 | <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["price"])?></td> |
| | 182 | <td align="right" nowrap="nowrap"><?php echo $therecord["qty"]?></td> |
| | 183 | <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["extended"])?></td> |
| | 184 | </tr> |
| | 185 | <?php |
| | 186 | |
| | 187 | }//endwhile |
| | 188 | ?> |
| | 189 | <tr class="grandTotals"> |
| | 190 | <td colspan="7" align="right">total</td> |
| | 191 | <td align="right"><?php echo numberToCurrency($totalextended)?></td> |
| | 192 | </tr> |
| | 193 | |
| | 194 | </tbody> |
| | 195 | </table><?php |
| | 196 | |
| | 197 | $output = ob_get_contents(); |
| | 198 | ob_end_clean(); |
| | 199 | |
| | 200 | return $output; |
| | 201 | |
| | 202 | }//end function generateSingleClientHistory |
| | 203 | |
| | 204 | |
| | 205 | |
| | 206 | function generate(){ |
| | 207 | |
| | 208 | |
| | 209 | ob_start(); |
| | 210 | ?> |
| | 211 | |
| | 212 | <h1>Client Purchase History</h1> |
| 217 | | <li> |
| 218 | | <strong> |
| 219 | | source:<br /> |
| 220 | | <?php echo $_SESSION["printing"]["dataprint"]?> |
| 221 | | </strong> |
| 222 | | </li> |
| 223 | | <li> |
| 224 | | <strong> |
| 225 | | date generated:<br /> |
| 226 | | <?php echo dateToString(mktime())." ".timeToString(mktime());?> |
| 227 | | </strong> |
| 228 | | </li> |
| 229 | | <li style="padding-left:30px;padding-right:20px;"> |
| 230 | | <strong> |
| 231 | | view:<br /> |
| 232 | | <?php echo $this->view?> |
| 233 | | </strong> |
| 234 | | </li> |
| 235 | | <li> |
| 236 | | <strong> |
| 237 | | from:<br /> |
| 238 | | <?php echo $this->fromdate?> |
| 239 | | </strong> |
| 240 | | </li> |
| 241 | | <li> |
| 242 | | <strong> |
| 243 | | to:<br /> |
| 244 | | <?php echo $this->todate?> |
| 245 | | </strong> |
| 246 | | </li> |
| 247 | | </ul><br /><br /> |
| 248 | | |
| 249 | | <?php while($therecord=$this->db->fetchArray($this->clientQuery)){?> |
| 250 | | <h3><?php echo $therecord["thename"]?></h3> |
| 251 | | <?php $this->showPurchaseHistory($therecord["id"]);}//end while?> |
| 252 | | </body> |
| 253 | | </html> |
| 254 | | <?php |
| 255 | | } |
| 256 | | }//end class |
| 257 | | |
| 258 | | if(isset($_POST["command"])){ |
| 259 | | $myreport= new purchaseHistoryReport(); |
| 260 | | $myreport->initialize($_POST,$db); |
| 261 | | |
| 262 | | $myreport->showReport(); |
| 263 | | } else { |
| 264 | | require("include/fields.php"); |
| 265 | | |
| 266 | | $pageTitle = "Client Purchase History"; |
| 267 | | $phpbms->cssIncludes[] = "pages/historyreports.css"; |
| 268 | | $phpbms->showMenu = false; |
| 269 | | |
| 270 | | //Form Elements |
| 271 | | //============================================================== |
| 272 | | $theform = new phpbmsForm(); |
| 273 | | |
| 274 | | |
| 275 | | $thedate = dateToString( mktime(0,0,0,date("m"),1),"SQL" ); |
| 276 | | $theinput = new inputDatePicker("fromdate", $thedate, "from",true); |
| 277 | | $theform->addField($theinput); |
| 278 | | |
| 279 | | $thedate = dateToString( mktime(0,0,0,date("m")+1,0,date("Y")), "SQL" ); |
| 280 | | $theinput = new inputDatePicker("todate", $thedate, "to",true); |
| 281 | | $theform->addField($theinput); |
| 282 | | |
| 283 | | $theform->jsMerge(); |
| 284 | | //============================================================== |
| 285 | | //End Form Elements |
| 286 | | |
| 287 | | include("header.php"); |
| 288 | | ?> |
| 289 | | <form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" name="totals" onsubmit="return validateForm(this)"> |
| 290 | | <div class="bodyline" id="reportOptions"> |
| 291 | | <h1 id="topTitle"><span>Product Sales History Options</span></h1> |
| 292 | | <fieldset> |
| 293 | | <legend>time frame</legend> |
| 294 | | |
| 295 | | <p id="fromP"><?php $theform->showField("fromdate");?></p> |
| 296 | | |
| 297 | | <p><?php $theform->showField("todate");?></p> |
| 298 | | </fieldset> |
| 299 | | |
| 300 | | <p> |
| 301 | | <label for="status">include products from...<br /></label> |
| 302 | | <select id="status" name="status"> |
| 303 | | <option value="Orders/Invoices" selected="selected">Orders/Invoices</option> |
| 304 | | <option value="Invoices">Invoices</option> |
| 305 | | <option value="Orders">Orders</option> |
| 306 | | </select> |
| 307 | | </p> |
| 308 | | |
| 309 | | <div align="right"> |
| 310 | | <input name="command" type="submit" class="Buttons" id="print" value="print" /> |
| 311 | | <input name="cancel" type="button" class="Buttons" id="cancel" value="cancel" onclick="window.close();" /> |
| 312 | | </div> |
| 313 | | </div> |
| 314 | | </form> |
| 315 | | <?php |
| 316 | | include("footer.php"); |
| 317 | | }?> |
| | 215 | <li> |
| | 216 | source:<br /> |
| | 217 | <?php echo formatVariable($this->dataPrint); ?> |
| | 218 | </li> |
| | 219 | <li> |
| | 220 | date generated:<br /> |
| | 221 | <?php echo dateToString(mktime())." ".timeToString(mktime()); ?> |
| | 222 | </li> |
| | 223 | <li> |
| | 224 | view:<br /> |
| | 225 | <?php echo $this->view; ?> |
| | 226 | </li> |
| | 227 | <li> |
| | 228 | from:<br /> |
| | 229 | <?php echo $this->fromDate; ?> |
| | 230 | </li> |
| | 231 | <li> |
| | 232 | to:<br /> |
| | 233 | <?php echo $this->toDate; ?> |
| | 234 | </li> |
| | 235 | </ul> |
| | 236 | |
| | 237 | <?php |
| | 238 | |
| | 239 | $this->reportOutput = ob_get_contents(); |
| | 240 | ob_end_clean(); |
| | 241 | |
| | 242 | while($therecord = $this->db->fetchArray($this->clientQueryresult)){ |
| | 243 | |
| | 244 | $this->reportOutput .= '<h2>'.$therecord["thename"].'</h2>'; |
| | 245 | |
| | 246 | $this->reportOutput .= $this->generateSingleClientHistory($therecord["uuid"]); |
| | 247 | |
| | 248 | }//endwhile |
| | 249 | |
| | 250 | }//end function generate |
| | 251 | |
| | 252 | |
| | 253 | function output(){ |
| | 254 | |
| | 255 | global $phpbms; |
| | 256 | $db = &$this->db; |
| | 257 | |
| | 258 | $phpbms->cssIncludes[] = "reports.css"; |
| | 259 | $phpbms->cssIncludes[] = "pages/bms/clienthistoryreport.css"; |
| | 260 | |
| | 261 | $phpbms->showMenu = false; |
| | 262 | $phpbms->showFooter = false; |
| | 263 | |
| | 264 | include("header.php"); |
| | 265 | |
| | 266 | echo $this->reportOutput; |
| | 267 | |
| | 268 | include("footer.php"); |
| | 269 | |
| | 270 | }//end function output |
| | 271 | |
| | 272 | |
| | 273 | function displayOptions(){ |
| | 274 | |
| | 275 | global $phpbms; |
| | 276 | $db = &$this->db; |
| | 277 | |
| | 278 | require("include/fields.php"); |
| | 279 | |
| | 280 | $pageTitle = "Client Purchase History"; |
| | 281 | $phpbms->cssIncludes[] = "pages/historyreports.css"; |
| | 282 | $phpbms->showMenu = false; |
| | 283 | |
| | 284 | //Form Elements |
| | 285 | //============================================================== |
| | 286 | $theform = new phpbmsForm(); |
| | 287 | |
| | 288 | $thedate = dateToString( mktime(0,0,0,date("m"),1),"SQL" ); |
| | 289 | $theinput = new inputDatePicker("fromdate", $thedate, "from",true); |
| | 290 | $theform->addField($theinput); |
| | 291 | |
| | 292 | $thedate = dateToString( mktime(0,0,0,date("m")+1,0,date("Y")), "SQL" ); |
| | 293 | $theinput = new inputDatePicker("todate", $thedate, "to",true); |
| | 294 | $theform->addField($theinput); |
| | 295 | |
| | 296 | $theform->jsMerge(); |
| | 297 | //============================================================== |
| | 298 | //End Form Elements |
| | 299 | |
| | 300 | include("header.php"); |
| | 301 | ?> |
| | 302 | <form action="<?php echo str_replace("&", "&", $_SERVER["REQUEST_URI"]); ?>" method="post" name="totals" onsubmit="return validateForm(this)"> |
| | 303 | |
| | 304 | <div class="bodyline" id="reportOptions"> |
| | 305 | |
| | 306 | <h1 id="topTitle"><span>Client Purchase History Options</span></h1> |
| | 307 | |
| | 308 | <fieldset> |
| | 309 | <legend>time frame</legend> |
| | 310 | |
| | 311 | <p id="fromP"><?php $theform->showField("fromdate");?></p> |
| | 312 | |
| | 313 | <p><?php $theform->showField("todate");?></p> |
| | 314 | </fieldset> |
| | 315 | |
| | 316 | <p> |
| | 317 | <label for="status">include products from...<br /></label> |
| | 318 | <select id="status" name="status"> |
| | 319 | <option value="Orders and Invoices" selected="selected">Orders and Invoices</option> |
| | 320 | <option value="Invoices">Invoices</option> |
| | 321 | <option value="Orders">Orders</option> |
| | 322 | </select> |
| | 323 | </p> |
| | 324 | |
| | 325 | <div align="right"> |
| | 326 | <input name="command" type="submit" class="Buttons" id="print" value="print" /> |
| | 327 | <input name="cancel" type="button" class="Buttons" id="cancel" value="cancel" onclick="window.close();" /> |
| | 328 | </div> |
| | 329 | </div> |
| | 330 | </form> |
| | 331 | |
| | 332 | <?php |
| | 333 | include("footer.php"); |
| | 334 | |
| | 335 | }//end function displayOptions |
| | 336 | |
| | 337 | }//end class purchaseHistoryReport |
| | 338 | |
| | 339 | |
| | 340 | /** |
| | 341 | * PROCESSING |
| | 342 | * ============================================================================= |
| | 343 | */ |
| | 344 | if(!isset($noOutput)){ |
| | 345 | |
| | 346 | //IE needs caching to be set to private in order to display PDFS |
| | 347 | session_cache_limiter('private'); |
| | 348 | |
| | 349 | require_once("../../../include/session.php"); |
| | 350 | |
| | 351 | checkForReportArguments(); |
| | 352 | |
| | 353 | $report = new purchaseHistoryReport($db, $_GET["rid"], $_GET["tid"]); |
| | 354 | |
| | 355 | if(!isset($_POST["command"]) && !isset($_GET["status"])) |
| | 356 | $report->displayOptions(); |
| | 357 | else{ |
| | 358 | |
| | 359 | if(isset($_GET["status"])){ |
| | 360 | |
| | 361 | $_POST["status"] = $_GET["status"]; |
| | 362 | $_POST["fromdate"] = $_GET["fromdate"]; |
| | 363 | $_POST["todate"] = $_GET["todate"]; |
| | 364 | |
| | 365 | }//endif |
| | 366 | |
| | 367 | //need to set post variables here |
| | 368 | |
| | 369 | $report->setupFromPrintScreen(); |
| | 370 | $report->initialize($_POST); |
| | 371 | $report->generate(); |
| | 372 | $report->output(); |
| | 373 | |
| | 374 | }//endif |
| | 375 | |
| | 376 | |
| | 377 | }//end if |
| | 378 | |
| | 379 | /** |
| | 380 | * When adding a new report record, the add/edit needs to know what the class |
| | 381 | * name is so that it can instantiate it, and grab it's default settings. |
| | 382 | */ |
| | 383 | if(isset($addingReportRecord)) |
| | 384 | $reportClass ="purchaseHistoryReport"; |