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/report/general_sql.php

    r578 r693  
    3737 +-------------------------------------------------------------------------+ 
    3838*/ 
     39if(!class_exists("phpbmsReport")) 
     40    include("report_class.php"); 
    3941 
    40         if(!class_exists("phpbmsReport")) 
    41                 include("report_class.php"); 
     42/** 
     43 * Handles creation of SQL insert records 
     44 * 
     45 * This class handles the file creation of SQL Insert records that 
     46 * correspond to the table definition main table that intializes a print of this 
     47 * report 
     48 */ 
     49class sqlExport extends phpbmsReport{ 
    4250 
    43         class sqlExport extends phpbmsReport{ 
     51    /** 
     52     * $maintable 
     53     * @var string the SQL name of the main table to print. 
     54     */ 
     55    var $maintable = ""; 
    4456 
    45                 var $maintable = ""; 
    46                 var $reportOutput = ""; 
    47                 var $tabledefuuid; 
     57    /** 
     58     * function generalTablePrint 
     59     * 
     60     * Initialization function 
     61     * 
     62     * @param object $db database object 
     63     * @param string $reportUUID UUID of report record 
     64     * @param string $tabledefUUID UUID of table definition intializing print 
     65     */ 
     66    function sqlExport($db, $reportUUID, $tabledefUUID){ 
    4867 
    49                 function sqlExport($db, $tabledefuuid){ 
     68        parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 
    5069 
    51                         $this->tabledefuuid = mysql_real_escape_string($tabledefuuid); 
     70        $therecord = $this->getTableDefInfo(); 
    5271 
    53                         parent::phpbmsReport($db); 
     72        $this->maintable = $therecord["maintable"]; 
    5473 
    55                         $querystatement = " 
    56                                 SELECT 
    57                                         maintable 
    58                                 FROM 
    59                                         tabledefs 
    60                                 WHERE 
    61                                         uuid = '".$this->tabledefuuid."'"; 
    62  
    63                         $queryresult = $db->query($querystatement); 
    64                         $therecord=$db->fetchArray($queryresult); 
    65  
    66                         $this->maintable = $therecord["maintable"]; 
    67  
    68                 }//end method 
     74    }//end function init 
    6975 
    7076 
    71                 function generate(){ 
     77    /** 
     78     * function generate 
     79     * 
     80     * Generates the SQL Insert statements for each record 
     81     */ 
     82    function generate(){ 
    7283 
    73                         $querystatement = " 
    74                                 SELECT 
    75                                         * 
    76                                 FROM 
    77                                         ".$this->maintable; 
     84        $querystatement = " 
     85            SELECT 
     86                * 
     87            FROM 
     88                ".$this->maintable; 
    7889 
    79                         $querystatement = $this->assembleSQL($querystatement); 
     90        $querystatement = $this->assembleSQL($querystatement); 
    8091 
    81                         $queryresult = $this->db->query($querystatement); 
     92        $queryresult = $this->db->query($querystatement); 
    8293 
    83                         $num_fields = $this->db->numFields($queryresult); 
     94        $num_fields = $this->db->numFields($queryresult); 
    8495 
    85                         $statementstart = "INSERT INTO `".$this->maintable."` ("; 
     96        $statementstart = "INSERT INTO `".$this->maintable."` ("; 
    8697 
    87                         for($i=0; $i<$num_fields ;$i++) 
    88                                 $statementstart .= "`".$this->db->fieldName($queryresult,$i)."`, "; 
     98        for($i=0; $i<$num_fields ;$i++) 
     99             $statementstart .= "`".$this->db->fieldName($queryresult,$i)."`, "; 
    89100 
    90                         $statementstart = substr($statementstart,0,strlen($statementstart)-2).") VALUES ("; 
     101        $statementstart = substr($statementstart,0,strlen($statementstart)-2).") VALUES ("; 
    91102 
    92                         while($therecord = $this->db->fetchArray($queryresult)){ 
     103        while($therecord = $this->db->fetchArray($queryresult)){ 
    93104 
    94                                 $insertstatement = $statementstart; 
     105            $insertstatement = $statementstart; 
    95106 
    96                                 foreach($therecord as $name => $field){ 
     107            foreach($therecord as $name => $field){ 
    97108 
    98                                         if($field === NULL) 
    99                                                 $addfield = "NULL, "; 
    100                                         else 
    101                                                 $addfield = "'".mysql_real_escape_string($field)."', "; 
     109                if($field === NULL) 
     110                     $addfield = "NULL, "; 
     111                else 
     112                     $addfield = "'".mysql_real_escape_string($field)."', "; 
    102113 
    103                                         //this is in temp for intallation exporting 
    104                                         if(hasRights("Admin")){ 
     114                //this is in temp for intallation exporting 
     115                if(hasRights("Admin")){ 
    105116 
    106                                                 switch($name){ 
     117                    switch($name){ 
    107118 
    108                                                         case "createdby": 
    109                                                         case "modifiedby": 
    110                                                                 $addfield = "1, "; 
    111                                                                 break; 
     119                        case "createdby": 
     120                        case "modifiedby": 
     121                            $addfield = "1, "; 
     122                            break; 
    112123 
    113                                                         case "creationdate": 
    114                                                         case "modifieddate": 
    115                                                                 $addfield = "NOW(), "; 
    116                                                                 break; 
     124                        case "creationdate": 
     125                        case "modifieddate": 
     126                            $addfield = "NOW(), "; 
     127                            break; 
    117128 
    118                                                 }//end switch 
     129                    }//end switch 
    119130 
    120                                         }//endif 
     131                }//endif 
    121132 
    122                                         $insertstatement .= $addfield; 
     133                $insertstatement .= $addfield; 
    123134 
    124                                 }//endforeach 
     135            }//endforeach 
    125136 
    126                                 $insertstatement = substr($insertstatement,0,strlen($insertstatement)-2).");\n"; 
     137            $insertstatement = substr($insertstatement,0,strlen($insertstatement)-2).");\n"; 
    127138 
    128                                 $this->reportOutput .= $insertstatement; 
     139            $this->reportOutput .= $insertstatement; 
    129140 
    130                         }//endwhile 
     141        }//endwhile 
    131142 
    132                 }//end method 
     143    }//end function generate 
     144 
     145    /** 
     146     * function show 
     147     * 
     148     * outputs the report to a .sql file 
     149     */ 
     150    function show(){ 
     151 
     152        if(!isset($this->settings["filename"])) 
     153           $this->settings["filename"] = $this->maintable."-export.sql"; 
     154 
     155        header("Content-type: text/plain"); 
     156        header('Content-Disposition: attachment; filename="'.$this->settings["filename"].'"'); 
     157 
     158        echo $this->reportOutput; 
     159 
     160    }//end function show 
     161 
     162}//end class sqlExport 
    133163 
    134164 
    135                 function show(){ 
     165/** 
     166 * PROCESSING 
     167 * ============================================================================= 
     168 */ 
     169if(!isset($noOutput)){ 
    136170 
    137                         header("Content-type: text/plain"); 
    138                         header('Content-Disposition: attachment; filename="export.sql"'); 
     171    session_cache_limiter('private'); 
    139172 
    140                         echo $this->reportOutput; 
     173    require_once("../include/session.php"); 
    141174 
    142                 }//end method 
     175    checkForReportArguments(); 
    143176 
     177    $report = new sqlExport($db, $_GET["rid"],$_GET["tid"]); 
     178    $report->setupFromPrintScreen(); 
     179    $report->generate(); 
     180    $report->show(); 
    144181 
    145         }//end class 
     182}//end if 
    146183 
    147         //PROCESSING 
    148         //======================================================================== 
     184/** 
     185 * When adding a new report record, the add/edit needs to know what the class 
     186 * name is so that it can instantiate it, and grab it's default settings. 
     187 */ 
     188if(isset($addingReportRecord)) 
     189    $reportClass ="pdfLabels"; 
    149190 
    150         if(!isset($noOutput)){ 
    151  
    152                 session_cache_limiter('private'); 
    153  
    154                 require("../include/session.php"); 
    155                 if(!isset($_GET["tid"])) 
    156                         $error = new appError(200,"URL variable missing: tid"); 
    157  
    158                 $report = new sqlExport($db, $_GET["tid"]); 
    159                 $report->setupFromPrintScreen(); 
    160                 $report->generate(); 
    161                 $report->show(); 
    162  
    163         }//end if 
    164191?> 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.