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

    r612 r693  
    3838*/ 
    3939 
    40         if(!isset($_SESSION["userinfo"])){ 
     40if(!class_exists("phpbmsReport")) 
     41    include("../../../report/report_class.php"); 
    4142 
    42                 session_cache_limiter('private'); 
     43class tabledefSQLExport extends phpbmsReport{ 
    4344 
    44                 require("../../../include/session.php"); 
     45    function tabledefSQLExport($db, $reportUUID, $tabledefUUID){ 
    4546 
    46         }//end if 
     47        parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 
     48 
     49    }//end method 
    4750 
    4851 
    49         if(!class_exists("phpbmsReport")) 
    50                 include("report/report_class.php"); 
     52    function generate(){ 
    5153 
    52         class tabledefSQLExport extends phpbmsReport{ 
     54            $this->reportOutput .= $this->_addTableInfo("tablecolumns"); 
     55            $this->reportOutput .= $this->_addTableInfo("tablefindoptions"); 
     56            $this->reportOutput .= $this->_addTableInfo("tablegroupings"); 
     57            $this->reportOutput .= $this->_addTableInfo("tableoptions"); 
     58            $this->reportOutput .= $this->_addTableInfo("tablesearchablefields"); 
    5359 
    54                 var $reportOutput = ""; 
    55  
    56                 function sqlExport($db){ 
    57  
    58                         parent::phpbmsReport($db); 
    59  
    60                 }//end method 
     60    }//end method 
    6161 
    6262 
    63                 function generate(){ 
     63    function _addTableInfo($tablename){ 
    6464 
    65                         $this->reportOutput .= $this->_addTableInfo("tablecolumns"); 
    66                         $this->reportOutput .= $this->_addTableInfo("tablefindoptions"); 
    67                         $this->reportOutput .= $this->_addTableInfo("tablegroupings"); 
    68                         $this->reportOutput .= $this->_addTableInfo("tableoptions"); 
    69                         $this->reportOutput .= $this->_addTableInfo("tablesearchablefields"); 
     65        $querystatement = " 
     66            SELECT 
     67                    `uuid` 
     68            FROM 
     69                    `tabledefs` 
     70            WHERE 
     71                    ".$this->whereClause; 
    7072 
    71                 }//end method 
     73        $queryresult = $this->db->query($querystatement); 
     74 
     75        $whereclause = ""; 
     76 
     77        while($therecord = $this->db->fetchArray($queryresult)) 
     78            $whereclause .= " OR `tabledefid` = '".mysql_real_escape_string($therecord["uuid"])."'"; 
     79 
     80        $whereclause = substr($whereclause, 4); 
     81 
     82        $output =       "/* Begin ".$tablename." */\n". 
     83                        "/* ====================================================================== */\n"; 
     84 
     85        $querystatement = " 
     86                SELECT 
     87                        * 
     88                FROM 
     89                        `".$tablename."` 
     90                WHERE 
     91                        ".$whereclause." 
     92                ORDER BY 
     93                        ".$tablename.".tabledefid"; 
     94 
     95        $queryresult = $this->db->query($querystatement); 
     96 
     97        $num_fields = $this->db->numFields($queryresult); 
     98 
     99        $statementstart = "INSERT INTO `".$tablename."` ("; 
     100 
     101        for($i=0; $i<$num_fields ;$i++){ 
     102 
     103            $fieldname = $this->db->fieldName($queryresult,$i); 
     104 
     105            if($fieldname != "id") 
     106                $statementstart .= "`".$fieldname."`, "; 
     107 
     108        }//endfor 
     109 
     110        $statementstart = substr($statementstart,0,strlen($statementstart)-2).") VALUES ("; 
     111 
     112        while($therecord = $this->db->fetchArray($queryresult)){ 
     113 
     114            $insertstatement = $statementstart; 
     115 
     116            foreach($therecord as $name => $field){ 
     117 
     118                if($field === NULL) 
     119                    $addfield = "NULL, "; 
     120                else 
     121                    $addfield = "'".mysql_real_escape_string($field)."', "; 
     122 
     123                if($name != "id") 
     124                    $insertstatement .= $addfield; 
     125 
     126            }//endforeach 
     127 
     128            $insertstatement = substr($insertstatement,0,strlen($insertstatement)-2).");\n"; 
     129 
     130            $output .= $insertstatement; 
     131 
     132        }//endwhile 
    72133 
    73134 
    74                 function _addTableInfo($tablename){ 
     135        $output .=      "/* ====================================================================== */\n". 
     136                        "/* END ".$tablename." - record count: ".$this->db->numRows($queryresult)."*/\n\n"; 
    75137 
    76                         $querystatement = " 
    77                                 SELECT 
    78                                         `uuid` 
    79                                 FROM 
    80                                         `tabledefs` 
    81                                 WHERE 
    82                                         ".$this->whereclause." 
    83                                 "; 
     138        return $output; 
    84139 
    85                         $queryresult = $this->db->query($querystatement); 
    86  
    87                         $whereclause = ""; 
    88                         while($therecord = $this->db->fetchArray($queryresult)){ 
    89  
    90                                 $whereclause .= " OR `tabledefid` = '".mysql_real_escape_string($therecord["uuid"])."'"; 
    91  
    92                         }//end while 
    93  
    94                         $whereclause = substr($whereclause, 4); 
    95  
    96                         $output =       "/* Begin ".$tablename." */\n". 
    97                                                 "/* ====================================================================== */\n"; 
    98  
    99                         $querystatement = " 
    100                                 SELECT 
    101                                         * 
    102                                 FROM 
    103                                         `".$tablename."` 
    104                                 WHERE 
    105                                         ".$whereclause." 
    106                                 ORDER BY 
    107                                         ".$tablename.".tabledefid"; 
    108  
    109                         $queryresult = $this->db->query($querystatement); 
    110  
    111                         $num_fields = $this->db->numFields($queryresult); 
    112  
    113                         $statementstart = "INSERT INTO `".$tablename."` ("; 
    114  
    115                         for($i=0; $i<$num_fields ;$i++){ 
    116  
    117                                 $fieldname = $this->db->fieldName($queryresult,$i); 
    118  
    119                                 if($fieldname != "id") 
    120                                         $statementstart .= "`".$fieldname."`, "; 
    121  
    122                         }//endfor 
    123  
    124                         $statementstart = substr($statementstart,0,strlen($statementstart)-2).") VALUES ("; 
    125  
    126                         while($therecord = $this->db->fetchArray($queryresult)){ 
    127  
    128                                 $insertstatement = $statementstart; 
    129  
    130                                 foreach($therecord as $name => $field){ 
    131  
    132                                         if($field === NULL) 
    133                                                 $addfield = "NULL, "; 
    134                                         else 
    135                                                 $addfield = "'".mysql_real_escape_string($field)."', "; 
    136  
    137                                         if($name != "id") 
    138                                                 $insertstatement .= $addfield; 
    139  
    140                                 }//endforeach 
    141  
    142                                 $insertstatement = substr($insertstatement,0,strlen($insertstatement)-2).");\n"; 
    143  
    144                                 $output .= $insertstatement; 
    145  
    146                         }//endwhile 
     140    }//end method 
    147141 
    148142 
    149                         $output .=      "/* ====================================================================== */\n". 
    150                                                 "/* END ".$tablename." - record count: ".$this->db->numRows($queryresult)."*/\n\n"; 
     143    function show(){ 
    151144 
    152                         return $output; 
     145        header("Content-type: text/plain"); 
     146        header('Content-Disposition: attachment; filename="tableInfoSQL.sql"'); 
    153147 
    154                 }//end method 
     148        echo $this->reportOutput; 
     149 
     150    }//end method 
    155151 
    156152 
    157                 function show(){ 
     153}//end class 
    158154 
    159                         header("Content-type: text/plain"); 
    160                         header('Content-Disposition: attachment; filename="tableInfoSQL.sql"'); 
     155/** 
     156 * PROCESSING 
     157 * ============================================================================= 
     158 */ 
     159if(!isset($noOutput)){ 
    161160 
    162                         echo $this->reportOutput; 
     161    session_cache_limiter('private'); 
    163162 
    164                 }//end method 
     163    require_once("../../../include/session.php"); 
    165164 
     165    checkForReportArguments(); 
    166166 
    167         }//end class 
     167    $report = new tabledefSQLExport($db, $_GET["rid"],$_GET["tid"]); 
     168    $report->setupFromPrintScreen(); 
     169    $report->generate(); 
     170    $report->show(); 
    168171 
    169         //PROCESSING 
    170         //======================================================================== 
     172}//end if 
    171173 
    172         if(!isset($noOutput)){ 
    173  
    174                 $report = new tabledefSQLExport($db); 
    175                 $report->setupFromPrintScreen(); 
    176                 $report->generate(); 
    177                 $report->show(); 
    178  
    179         }//end if 
     174/** 
     175 * When adding a new report record, the add/edit needs to know what the class 
     176 * name is so that it can instantiate it, and grab it's default settings. 
     177 */ 
     178if(isset($addingReportRecord)) 
     179    $reportClass ="tabledefSQLExport"; 
    180180?> 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.