phpBMS

Show
Ignore:
Timestamp:
12/31/09 13:36:45 (2 years ago)
Author:
brieb
Message:
  • Introduced administratively changeable settings to indvidual reports
  • Modified all reports to work with new settings system
  • Altered invoice and line item total reports to accept parameters from reportsettings: You can now bypass the grouping/column dialog by providing the infrmation administratively
  • Altered all sales order PDF reports to accept parameters from reportsettings: You can now administratively change certain aspects of the print outs, including what parts of the top of the report to show, and what to title the report
  • Altered label reports to accept parameters from reportsettings: printed data as well

as label measurements and layout are now defined by administratively

  • Altered export and tableprint reports to accept parameters from reportsettings: You can specify individual columns and from table instead of just the defaults (all fields, main table only)
  • Added var_dump-esque 'debug' function for development purposes to common functions
  • Integrated FPDI functionality with sales order PDF reports: It is now possible to use a PDF saved in the files table as a background template for your invoices (e.g. watermarks)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/bms/report/incoming_cashflow.php

    r611 r693  
    3838*/ 
    3939 
    40 require("../../../include/session.php"); 
    41  
    42 class totalReport{ 
     40if(!class_exists("phpbmsReport")) 
     41    require("../../../report/report_class.php"); 
     42 
     43class totalReport extends phpbmsReport{ 
    4344 
    4445        var $selectcolumns; 
    4546        var $tableClause = array(); 
    46         var $whereClause = array(); 
     47        var $whereClauses = array(); 
    4748        var $group = ""; 
    4849        var $showItems = false; 
     
    5152        var $toDate; 
    5253 
    53         function totalReport($db,$variables = NULL){ 
    54                 $this->db = $db; 
    55  
    56                 // first we define the available groups 
    57                 $this->addGroup("Year","YEAR(docdate)"); //0 
    58                 $this->addGroup("Quarter","QUARTER(docdate)"); //1 
    59                 $this->addGroup("Month","DATE_FORMAT(docdate, '%m - %b')"); //2 
    60                 $this->addGroup("Week","WEEK(docdate)"); //3 
    61                 $this->addGroup("Payment Method","paymentmethods.name"); //4 
    62                 $this->addGroup("Document Type","doctype"); //5 
    63  
    64  
    65                 //next we do the columns 
    66                 $this->addColumn("Record Count","COUNT(id)");//0 
    67                 $this->addColumn("Total","SUM(doctotal)","currency");//1 
    68  
    69  
    70                 if($variables){ 
    71  
    72                         $this->selectcolumns = $this->columns; 
    73  
    74                         $this->fromDate = $variables["fromdate"]; 
    75                         $this->toDate = $variables["todate"]; 
    76  
    77                         $this->tableClause["invoices"] = "(invoices INNER JOIN paymentmethods ON invoices.paymentmethodid = paymentmethods.uuid)"; 
    78                         $this->tableClause["receipts"] = "(receipts INNER JOIN paymentmethods ON receipts.paymentmethodid = paymentmethods.uuid)"; 
    79  
    80                         if($variables["groupings"] !== ""){ 
    81  
    82                                 $this->group = explode("::",$variables["groupings"]); 
    83                                 $this->group = array_reverse($this->group); 
    84  
    85                         } else 
    86                                 $this->group = array(); 
    87  
    88                         foreach($this->group as $grp){ 
    89  
    90                                 if($this->groupings[$grp]["table"]){ 
    91  
    92                                         foreach($this->tableClause as $key => $value); 
    93                                             $this->tableClause[$key]="(".$this->tableClause[$key]." ".$this->groupings[$grp]["table"].")"; 
    94  
    95                                 }//endif 
    96  
    97                         }//endforeach 
    98  
    99 //                      $this->whereclause = $_SESSION["printing"]["whereclause"]; 
    100 //                      if($this->whereclause=="") $this->whereclause="WHERE invoices.id!=-1"; 
    101                         $this->whereClause["invoices"] = " 
    102                             WHERE 
    103                                 (invoices.type = 'Invoice' 
    104                                 AND paymentmethods.type != 'receivable' 
    105                                 AND invoicedate >= '".sqlDateFromString($variables["fromdate"])."' 
    106                                 AND invoicedate <= '".sqlDateFromString($variables["todate"])."') 
    107                             "; 
    108  
    109                         $this->whereClause["receipts"] = " 
    110                             WHERE 
    111                                 (receipts.posted = 1 
    112                                 AND receiptdate >= '".sqlDateFromString($variables["fromdate"])."' 
    113                                 AND receiptdate <= '".sqlDateFromString($variables["todate"])."') 
    114                             "; 
    115  
    116                         $this->showItems = isset($variables["showitems"]); 
    117  
    118                 }// endif 
     54 
     55        function totalReport($db, $reportUUID, $tabledefUUID){ 
     56 
     57            $this->db = $db; 
     58 
     59            parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 
     60 
     61            // first we define the available groups 
     62            $this->addGroup("Year","YEAR(docdate)"); //0 
     63            $this->addGroup("Quarter","QUARTER(docdate)"); //1 
     64            $this->addGroup("Month","DATE_FORMAT(docdate, '%m - %b')"); //2 
     65            $this->addGroup("Week","WEEK(docdate)"); //3 
     66            $this->addGroup("Payment Method","paymentmethods.name"); //4 
     67            $this->addGroup("Document Type","doctype"); //5 
     68 
     69            //next we do the columns 
     70            $this->addColumn("Record Count","COUNT(id)");//0 
     71            $this->addColumn("Total","SUM(doctotal)","currency");//1 
     72 
     73            $this->tableClause["invoices"] = "(invoices INNER JOIN paymentmethods ON invoices.paymentmethodid = paymentmethods.uuid)"; 
     74            $this->tableClause["receipts"] = "(receipts INNER JOIN paymentmethods ON receipts.paymentmethodid = paymentmethods.uuid)"; 
     75 
    11976        }//end method 
     77 
     78 
     79        function processFromPost($variables){ 
     80 
     81            $this->selectcolumns = $this->columns; 
     82 
     83            $this->fromDate = $variables["fromdate"]; 
     84            $this->toDate = $variables["todate"]; 
     85 
     86            if($variables["groupings"] !== ""){ 
     87 
     88                $this->group = explode("::",$variables["groupings"]); 
     89                $this->group = array_reverse($this->group); 
     90 
     91            } else 
     92                $this->group = array(); 
     93 
     94            foreach($this->group as $grp){ 
     95 
     96                if($this->groupings[$grp]["table"]){ 
     97 
     98                    foreach($this->tableClause as $key => $value); 
     99                        $this->tableClause[$key] = "(".$this->tableClause[$key]." ".$this->groupings[$grp]["table"].")"; 
     100 
     101                }//endif 
     102 
     103            }//endforeach 
     104 
     105            $this->whereClauses["invoices"] = " 
     106                WHERE 
     107                    (invoices.type = 'Invoice' 
     108                    AND paymentmethods.type != 'receivable' 
     109                    AND invoicedate >= '".sqlDateFromString($variables["fromdate"])."' 
     110                    AND invoicedate <= '".sqlDateFromString($variables["todate"])."') 
     111                "; 
     112 
     113            $this->whereClauses["receipts"] = " 
     114                WHERE 
     115                    (receipts.posted = 1 
     116                    AND receiptdate >= '".sqlDateFromString($variables["fromdate"])."' 
     117                    AND receiptdate <= '".sqlDateFromString($variables["todate"])."') 
     118                "; 
     119 
     120            $this->showItems = isset($variables["showitems"]); 
     121 
     122        }//end function processFromPost 
     123 
     124 
     125        function processFromSettings(){ 
     126 
     127            $variables["fromdate"] = $this->settings["fromDate"]; 
     128            $variables["todate"] = $this->settings["toDate"]; 
     129 
     130            $variables["groupings"] = ""; 
     131            foreach($this->settings as $key=>$value) 
     132                if(strpos($key, "group") === 0) 
     133                    $variables["groupings"] .= "::".$value; 
     134 
     135            if($variables["groupings"]) 
     136                $variables["groupings"] = substr($variables["groupings"], 2); 
     137 
     138            $variables["showitems"] = isset($this->settings["showItems"]); 
     139 
     140            $this->processFromPost($variables); 
     141 
     142        }//end function processFromSettings 
    120143 
    121144 
     
    206229                $querystatement = "(SELECT"; 
    207230                $querystatement .= $this->generateColumns("invoices").", COUNT(invoices.id) AS thecount "; 
    208                 $querystatement .= "FROM ".$this->tableClause["invoices"]." ".$this->whereClause["invoices"].")"; 
     231                $querystatement .= "FROM ".$this->tableClause["invoices"]." ".$this->whereClauses["invoices"].")"; 
    209232                $querystatement .= " UNION "; 
    210233                $querystatement .= "(SELECT"; 
    211234                $querystatement .= $this->generateColumns("receipts").", COUNT(receipts.id) AS thecount "; 
    212                 $querystatement .= "FROM ".$this->tableClause["receipts"]." ".$this->whereClause["receipts"].")"; 
     235                $querystatement .= "FROM ".$this->tableClause["receipts"]." ".$this->whereClauses["receipts"].")"; 
    213236 
    214237 
     
    257280                        $querystatement .= $this->generateColumns("invoices").", COUNT(invoices.id) AS `thecount` "; 
    258281                        $querystatement .= ", ".$this->typeSubstitute($this->groupings[$groupby]["field"], "invoices")." AS `thegroup`"; 
    259                         $querystatement .= "FROM ".$this->tableClause["invoices"]." ".$this->whereClause["invoices"].$this->typeSubstitute($where, "invoices"); 
     282                        $querystatement .= "FROM ".$this->tableClause["invoices"]." ".$this->whereClauses["invoices"].$this->typeSubstitute($where, "invoices"); 
    260283                        $querystatement .= " GROUP BY `thegroup`)"; 
    261284                        $querystatement .= " UNION "; 
     
    263286                        $querystatement .= $this->generateColumns("receipts").", COUNT(receipts.id) AS thecount "; 
    264287                        $querystatement .= ", ".$this->typeSubstitute($this->groupings[$groupby]["field"], "receipts")." AS `thegroup`"; 
    265                         $querystatement .= "FROM ".$this->tableClause["receipts"]." ".$this->whereClause["receipts"].$this->typeSubstitute($where, "receipts"); 
     288                        $querystatement .= "FROM ".$this->tableClause["receipts"]." ".$this->whereClauses["receipts"].$this->typeSubstitute($where, "receipts"); 
    266289                        $querystatement .= " GROUP BY `thegroup`)"; 
    267290                        $querystatement .= " ORDER BY `thegroup`"; 
     
    421444                    FROM 
    422445                        (".$this->tableClause["invoices"].") INNER JOIN clients ON invoices.clientid = clients.uuid 
    423                         ".$this->whereClause["invoices"].$this->typeSubstitute($where, "invoices")." 
     446                        ".$this->whereClauses["invoices"].$this->typeSubstitute($where, "invoices")." 
    424447                    GROUP BY `theid`) 
    425448                    UNION 
     
    431454                    FROM 
    432455                        (".$this->tableClause["receipts"].") INNER JOIN clients ON receipts.clientid = clients.uuid 
    433                         ".$this->whereClause["receipts"].$this->typeSubstitute($where, "receipts")." 
     456                        ".$this->whereClauses["receipts"].$this->typeSubstitute($where, "receipts")." 
    434457                    GROUP BY `theid`) 
    435458                    ORDER BY `docdate`"; 
     
    464487        function showReport(){ 
    465488 
    466             $pageTitle = "Incoming Cash Flow"; 
     489            if(!isset($this->settings["reportTitle"])) 
     490                $this->settings["reportTitle"] = "Incoming Cash Flow"; 
    467491 
    468492 
     
    477501<body> 
    478502        <div id="toprint"> 
    479                 <h1><span><?php echo $pageTitle?></span></h1> 
     503                <h1><span><?php echo formatVariable($this->settings["reportTitle"]); ?></span></h1> 
    480504                <h2>Dates: <?php echo $this->fromDate ?> - <?php echo $this->toDate ?></h2> 
    481505 
     
    582606}//endclass 
    583607 
    584 // Processing =================================================================================================================== 
    585 if(!isset($dontProcess)){ 
    586         if(isset($_POST["fromdate"])){ 
    587                 $myreport= new totalReport($db,$_POST); 
    588                 $myreport->showReport(); 
    589         } else { 
    590                 $myreport = new totalReport($db); 
    591                 $myreport->showSelectScreen(); 
    592         } 
    593 }?> 
     608 
     609/** 
     610 * PROCESSING 
     611 * ============================================================================= 
     612 */ 
     613if(!isset($noOutput)){ 
     614 
     615    //IE needs caching to be set to private in order to display PDFS 
     616    session_cache_limiter('private'); 
     617 
     618    //set encoding to latin1 (fpdf doesnt like utf8) 
     619    $sqlEncoding = "latin1"; 
     620    require_once("../../../include/session.php"); 
     621 
     622    checkForReportArguments(); 
     623 
     624    $report = new totalReport($db, $_GET["rid"], $_GET["tid"]); 
     625 
     626    if(isset($_POST["fromdate"])){ 
     627 
     628        $report->processFromPost($_POST); 
     629        $report->showReport(); 
     630 
     631    } elseif(isset($report->settings["fromdate"]) && isset($report->settings["todate"]) && isset($report->settings["groupings"])){ 
     632 
     633        $report->processFromSettings(); 
     634        $report->showReport(); 
     635 
     636    }else 
     637        $report->showSelectScreen(); 
     638 
     639}//end if 
     640 
     641/** 
     642 * When adding a new report record, the add/edit needs to know what the class 
     643 * name is so that it can instantiate it, and grab it's default settings. 
     644 */ 
     645if(isset($addingReportRecord)) 
     646    $reportClass ="totalReport"; 
     647 
     648?> 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.