Changeset 693
- Timestamp:
- 12/31/09 13:36:45 (2 years ago)
- Location:
- trunk/phpbms
- Files:
-
- 14 added
- 17 removed
- 37 modified
-
common/javascript/common.js (modified) (1 diff)
-
common/stylesheet/mozilla/pages/base/reports.css (added)
-
common/stylesheet/mozilla/pages/bms/clienthistoryreport.css (added)
-
common/stylesheet/mozilla/pages/reports.css (deleted)
-
fpdf/filters (added)
-
fpdf/filters/FilterASCII85.php (added)
-
fpdf/filters/FilterASCII85_FPDI.php (added)
-
fpdf/filters/FilterLZW.php (added)
-
fpdf/filters/FilterLZW_FPDI.php (added)
-
fpdf/font/makefont/makefont.php (modified) (22 diffs)
-
fpdf/fpdf.css (modified) (1 diff)
-
fpdf/fpdf.php (modified) (63 diffs)
-
fpdf/fpdi.php (added)
-
fpdf/fpdi_pdf_parser.php (added)
-
fpdf/mem_image.php (deleted)
-
fpdf/pdf_context.php (added)
-
fpdf/pdf_parser.php (added)
-
fpdf/tpl_and_memimage.php (added)
-
include/common_functions.php (modified) (17 diffs)
-
install/createtables.sql (modified) (1 diff)
-
install/reports.sql (modified) (1 diff)
-
install/updatev0.98.sql (modified) (2 diffs)
-
modules/base/include/reports.php (modified) (1 diff)
-
modules/base/javascript/reports.js (added)
-
modules/base/report/notes_summary.php (deleted)
-
modules/base/report/tabledefs_sqlexport.php (modified) (1 diff)
-
modules/base/reports_addedit.php (modified) (6 diffs)
-
modules/bms/clients_purchasehistory.php (modified) (5 diffs)
-
modules/bms/install/install.php (modified) (1 diff)
-
modules/bms/install/reports.sql (modified) (1 diff)
-
modules/bms/install/reportsettings.sql (added)
-
modules/bms/install/updatev0.98.sql (modified) (2 diffs)
-
modules/bms/products_saleshistory.php (modified) (3 diffs)
-
modules/bms/report/aritems_clientstatement.php (modified) (8 diffs)
-
modules/bms/report/aritems_summary.php (modified) (5 diffs)
-
modules/bms/report/clients_folderlabels.php (deleted)
-
modules/bms/report/clients_mailinglabels.php (deleted)
-
modules/bms/report/clients_notesummary.php (deleted)
-
modules/bms/report/clients_purchasehistory.php (modified) (2 diffs)
-
modules/bms/report/clients_shippinglabels.php (deleted)
-
modules/bms/report/incoming_cashflow.php (modified) (10 diffs)
-
modules/bms/report/invoices_pdfinvoice.php (modified) (1 diff)
-
modules/bms/report/invoices_pdfpackinglist.php (modified) (1 diff)
-
modules/bms/report/invoices_pdfquote.php (modified) (1 diff)
-
modules/bms/report/invoices_pdfworkorder.php (modified) (1 diff)
-
modules/bms/report/invoices_pdf_class.php (modified) (1 diff)
-
modules/bms/report/invoices_shippinglabels.php (deleted)
-
modules/bms/report/invoices_totals.php (modified) (7 diffs)
-
modules/bms/report/invoices_totals_acctmngers.php (deleted)
-
modules/bms/report/invoices_totals_amtwinv.php (deleted)
-
modules/bms/report/invoices_totals_amtwinvlineitems.php (deleted)
-
modules/bms/report/invoices_totals_leadsource.php (deleted)
-
modules/bms/report/invoices_totals_shippingmethod.php (deleted)
-
modules/bms/report/invoices_totals_tax.php (deleted)
-
modules/bms/report/lineitems_totals.php (modified) (6 diffs)
-
modules/bms/report/lineitems_totals_leadsource.php (deleted)
-
modules/bms/report/lineitems_totals_productcategories.php (deleted)
-
modules/bms/report/lineitems_totals_products.php (deleted)
-
modules/bms/report/products_saleshistory.php (modified) (3 diffs)
-
modules/bms/report/receipts_pdf.php (modified) (1 diff)
-
modules/bms/report/receipts_pttotals.php (modified) (3 diffs)
-
print.php (modified) (1 diff)
-
report/general_export.php (modified) (1 diff)
-
report/general_labels.php (modified) (2 diffs)
-
report/general_sql.php (modified) (1 diff)
-
report/general_tableprint.php (modified) (1 diff)
-
report/pdfreport_class.php (modified) (1 diff)
-
report/report_class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/common/javascript/common.js
r635 r693 129 129 alert(error); 130 130 131 } //end method - reportError131 },//end method - reportError 132 132 133 133 -
trunk/phpbms/fpdf/font/makefont/makefont.php
r667 r693 2 2 /******************************************************************************* 3 3 * Utility to generate font definition files * 4 * Version: 1.13 * 5 * Date: 2004-12-31 * 4 * * 5 * Version: 1.14 * 6 * Date: 2008-08-03 * 7 * Author: Olivier PLATHEY * 6 8 *******************************************************************************/ 7 9 … … 12 14 $a=file($file); 13 15 if(empty($a)) 14 die('< B>Error:</B> encoding not found: '.$enc);16 die('<b>Error:</b> encoding not found: '.$enc); 15 17 $cc2gn=array(); 16 18 foreach($a as $l) 17 19 { 18 if($l {0}=='!')20 if($l[0]=='!') 19 21 { 20 22 $e=preg_split('/[ \\t]+/',rtrim($l)); … … 32 34 } 33 35 34 function ReadAFM($file, &$map)36 function ReadAFM($file, &$map) 35 37 { 36 38 //Read a font metric file … … 115 117 if(!isset($widths['.notdef'])) 116 118 $widths['.notdef']=600; 117 if(!isset($widths['Delta']) andisset($widths['increment']))119 if(!isset($widths['Delta']) && isset($widths['increment'])) 118 120 $widths['Delta']=$widths['increment']; 119 121 //Order widths according to map … … 122 124 if(!isset($widths[$map[$i]])) 123 125 { 124 echo '< B>Warning:</B> character '.$map[$i].' is missing<br />';126 echo '<b>Warning:</b> character '.$map[$i].' is missing<br>'; 125 127 $widths[$i]=$widths['.notdef']; 126 128 } … … 133 135 } 134 136 135 function MakeFontDescriptor($fm, $symbolic)137 function MakeFontDescriptor($fm, $symbolic) 136 138 { 137 139 //Ascent … … 151 153 //Flags 152 154 $flags=0; 153 if(isset($fm['IsFixedPitch']) and$fm['IsFixedPitch'])155 if(isset($fm['IsFixedPitch']) && $fm['IsFixedPitch']) 154 156 $flags+=1<<0; 155 157 if($symbolic) … … 157 159 if(!$symbolic) 158 160 $flags+=1<<5; 159 if(isset($fm['ItalicAngle']) and$fm['ItalicAngle']!=0)161 if(isset($fm['ItalicAngle']) && $fm['ItalicAngle']!=0) 160 162 $flags+=1<<6; 161 163 $fd.=",'Flags'=>".$flags; … … 164 166 $fbb=$fm['FontBBox']; 165 167 else 166 $fbb=array(0,$des -100,1000,$asc+100);168 $fbb=array(0,$desc-100,1000,$asc+100); 167 169 $fd.=",'FontBBox'=>'[".$fbb[0].' '.$fbb[1].' '.$fbb[2].' '.$fbb[3]."]'"; 168 170 //ItalicAngle … … 172 174 if(isset($fm['StdVW'])) 173 175 $stemv=$fm['StdVW']; 174 elseif(isset($fm['Weight']) && preg_match('/ (bold|black)/i',$fm['Weight']))176 elseif(isset($fm['Weight']) && preg_match('/bold|black/i',$fm['Weight'])) 175 177 $stemv=120; 176 178 else … … 195 197 elseif(chr($i)=="\\") 196 198 $s.="'\\\\'"; 197 elseif($i>=32 and$i<=126)199 elseif($i>=32 && $i<=126) 198 200 $s.="'".chr($i)."'"; 199 201 else … … 228 230 } 229 231 230 function SaveToFile($file, $s,$mode='t')232 function SaveToFile($file, $s, $mode) 231 233 { 232 234 $f=fopen($file,'w'.$mode); … … 254 256 $f=fopen($file,'rb'); 255 257 if(!$f) 256 die('< B>Error:</B> Can\'t open '.$file);258 die('<b>Error:</b> Can\'t open '.$file); 257 259 //Extract number of tables 258 260 fseek($f,4,SEEK_CUR); … … 285 287 $e=($fsType & 0x08)!=0; 286 288 fclose($f); 287 if($rl and !$pp and!$e)288 echo '< B>Warning:</B> font license does not allow embedding';289 if($rl && !$pp && !$e) 290 echo '<b>Warning:</b> font license does not allow embedding'; 289 291 } 290 292 291 293 /******************************************************************************* 292 * $fontfile : chemin du fichier TTF (ou chaîne vide si pas d'incorporation)*293 * $afmfile : chemin du fichier AFM*294 * $enc : encodage (ou chaîne vide si la police est symbolique)*295 * $patch : patch optionnel pour l'encodage*296 * $type : type de la police si $fontfile est vide*294 * fontfile: path to TTF file (or empty string if not to be embedded) * 295 * afmfile: path to AFM file * 296 * enc: font encoding (or empty string for symbolic fonts) * 297 * patch: optional patch for encoding * 298 * type: font type if fontfile is empty * 297 299 *******************************************************************************/ 298 function MakeFont($fontfile, $afmfile,$enc='cp1252',$patch=array(),$type='TrueType')300 function MakeFont($fontfile, $afmfile, $enc='cp1252', $patch=array(), $type='TrueType') 299 301 { 300 302 //Generate a font definition file 301 set_magic_quotes_runtime(0); 303 if(get_magic_quotes_runtime()) 304 @set_magic_quotes_runtime(0); 302 305 ini_set('auto_detect_line_endings','1'); 303 306 if($enc) … … 310 313 $map=array(); 311 314 if(!file_exists($afmfile)) 312 die('< B>Error:</B> AFM file not found: '.$afmfile);315 die('<b>Error:</b> AFM file not found: '.$afmfile); 313 316 $fm=ReadAFM($afmfile,$map); 314 317 if($enc) … … 326 329 $type='Type1'; 327 330 else 328 die('< B>Error:</B> unrecognized font file extension: '.$ext);329 } 330 else 331 { 332 if($type!='TrueType' and$type!='Type1')333 die('< B>Error:</B> incorrect font type: '.$type);331 die('<b>Error:</b> unrecognized font file extension: '.$ext); 332 } 333 else 334 { 335 if($type!='TrueType' && $type!='Type1') 336 die('<b>Error:</b> incorrect font type: '.$type); 334 337 } 335 338 //Start generation … … 353 356 //Embedded font 354 357 if(!file_exists($fontfile)) 355 die('< B>Error:</B> font file not found: '.$fontfile);358 die('<b>Error:</b> font file not found: '.$fontfile); 356 359 if($type=='TrueType') 357 360 CheckTTF($fontfile); 358 361 $f=fopen($fontfile,'rb'); 359 362 if(!$f) 360 die('< B>Error:</B> Can\'t open '.$fontfile);363 die('<b>Error:</b> Can\'t open '.$fontfile); 361 364 $file=fread($f,filesize($fontfile)); 362 365 fclose($f); … … 364 367 { 365 368 //Find first two sections and discard third one 366 $header=(ord($file {0})==128);369 $header=(ord($file[0])==128); 367 370 if($header) 368 371 { … … 372 375 $pos=strpos($file,'eexec'); 373 376 if(!$pos) 374 die('< B>Error:</B> font file does not seem to be valid Type1');377 die('<b>Error:</b> font file does not seem to be valid Type1'); 375 378 $size1=$pos+6; 376 if($header and ord($file{$size1})==128)379 if($header && ord($file[$size1])==128) 377 380 { 378 381 //Strip second binary header … … 381 384 $pos=strpos($file,'00000000'); 382 385 if(!$pos) 383 die('< B>Error:</B> font file does not seem to be valid Type1');386 die('<b>Error:</b> font file does not seem to be valid Type1'); 384 387 $size2=$pos-$size1; 385 388 $file=substr($file,0,$size1+$size2); … … 390 393 SaveToFile($cmp,gzcompress($file),'b'); 391 394 $s.='$file=\''.$cmp."';\n"; 392 echo 'Font file compressed ('.$cmp.')<br />';395 echo 'Font file compressed ('.$cmp.')<br>'; 393 396 } 394 397 else 395 398 { 396 399 $s.='$file=\''.basename($fontfile)."';\n"; 397 echo '< B>Notice:</B> font file could not be compressed (zlib extension not available)<br />';400 echo '<b>Notice:</b> font file could not be compressed (zlib extension not available)<br>'; 398 401 } 399 402 if($type=='Type1') … … 411 414 } 412 415 $s.="?>\n"; 413 SaveToFile($basename.'.php',$s );414 echo 'Font definition file generated ('.$basename.'.php'.')<br />';416 SaveToFile($basename.'.php',$s,'t'); 417 echo 'Font definition file generated ('.$basename.'.php'.')<br>'; 415 418 } 416 419 ?> -
trunk/phpbms/fpdf/fpdf.css
r485 r693 1 BODY {font-family:times new roman,serif} 2 H2 {color:#4000A0} 3 P.demo {text-align:center; margin-top:-10px} 4 A.demo {text-decoration:none; font-weight:bold; color:#0000CC} 5 A.demo:link {text-decoration:none; font-weight:bold; color:#0000CC} 6 A.demo:hover {text-decoration:none; font-weight:bold; color:#0000FF} 7 A.demo:active {text-decoration:none; font-weight:bold; color:#0000FF} 8 .st {font-weight:bold; color:#900000} 1 body {font-family:"Times New Roman",serif} 2 h1 {font:bold 135% Arial,sans-serif; color:#4000A0; margin-bottom:0.9em} 3 h2 {font:bold 95% Arial,sans-serif; color:#900000; margin-top:1.5em; margin-bottom:1em} 4 dl.param dt {text-decoration:underline} 5 dl.param dd {margin-top:1em; margin-bottom:1em} 6 dl.param ul {margin-top:1em; margin-bottom:1em} 7 tt, code, kbd {font-family:"Courier New",Courier,monospace; font-size:82%} 8 div.source {margin-top:1.4em; margin-bottom:1.3em} 9 div.source pre {display:table; border:1px solid #24246A; width:100%; margin:0em; font-family:inherit; font-size:100%} 10 div.source code {display:block; border:1px solid #C5C5EC; background-color:#F0F5FF; padding:6px; color:#000000} 11 div.doc-source {margin-top:1.4em; margin-bottom:1.3em} 12 div.doc-source pre {display:table; width:100%; margin:0em; font-family:inherit; font-size:100%} 13 div.doc-source code {display:block; background-color:#E0E0E0; padding:4px} 9 14 .kw {color:#000080; font-weight:bold} 10 15 .str {color:#CC0000} 11 16 .cmt {color:#008000} 17 p.demo {text-align:center; margin-top:-0.9em} 18 a.demo {text-decoration:none; font-weight:bold; color:#0000CC} 19 a.demo:link {text-decoration:none; font-weight:bold; color:#0000CC} 20 a.demo:hover {text-decoration:none; font-weight:bold; color:#0000FF} 21 a.demo:active {text-decoration:none; font-weight:bold; color:#0000FF} -
trunk/phpbms/fpdf/fpdf.php
r673 r693 1 1 <?php 2 2 /******************************************************************************* 3 * Software: FPDF * 4 * Version: 1.53 * 5 * Date: 2004-12-31 * 6 * Author: Olivier PLATHEY * 7 * License: Freeware * 3 * FPDF * 8 4 * * 9 * You may use and modify this software as you wish. * 5 * Version: 1.6 * 6 * Date: 2008-08-03 * 7 * Author: Olivier PLATHEY * 10 8 *******************************************************************************/ 11 9 12 if(!class_exists('FPDF')) 13 { 14 define('FPDF_VERSION','1.53'); 10 define('FPDF_VERSION','1.6'); 15 11 16 12 class FPDF 17 13 { 18 //Private properties19 14 var $page; //current page number 20 15 var $n; //current object number … … 24 19 var $state; //current document state 25 20 var $compress; //compression flag 21 var $k; //scale factor (number of points in user unit) 26 22 var $DefOrientation; //default orientation 27 23 var $CurOrientation; //current orientation 28 var $ OrientationChanges; //array indicating orientation changes29 var $ k; //scale factor (number of points in user unit)30 var $ fwPt,$fhPt; //dimensions of page format in points31 var $ fw,$fh; //dimensions of page format in user unit32 var $wPt,$hPt; // current dimensions ofpage in points33 var $w,$h; // current dimensions ofpage in user unit24 var $PageFormats; //available page formats 25 var $DefPageFormat; //default page format 26 var $CurPageFormat; //current page format 27 var $PageSizes; //array storing non-default page sizes 28 var $wPt,$hPt; //dimensions of current page in points 29 var $w,$h; //dimensions of current page in user unit 34 30 var $lMargin; //left margin 35 31 var $tMargin; //top margin … … 37 33 var $bMargin; //page break margin 38 34 var $cMargin; //cell margin 39 var $x,$y; //current position in user unit for cell positioning40 var $lasth; //height of last cell printed35 var $x,$y; //current position in user unit 36 var $lasth; //height of last printed cell 41 37 var $LineWidth; //line width in user unit 42 38 var $CoreFonts; //array of standard font names … … 44 40 var $FontFiles; //array of font files 45 41 var $diffs; //array of encoding differences 46 var $images; //array of used images47 var $PageLinks; //array of links in pages48 var $links; //array of internal links49 42 var $FontFamily; //current font family 50 43 var $FontStyle; //current font style … … 58 51 var $ColorFlag; //indicates whether fill and text colors are different 59 52 var $ws; //word spacing 53 var $images; //array of used images 54 var $PageLinks; //array of links in pages 55 var $links; //array of internal links 60 56 var $AutoPageBreak; //automatic page breaking 61 57 var $PageBreakTrigger; //threshold used to trigger page breaks 58 var $InHeader; //flag set when processing header 62 59 var $InFooter; //flag set when processing footer 63 60 var $ZoomMode; //zoom display mode … … 76 73 * * 77 74 *******************************************************************************/ 78 function FPDF($orientation='P', $unit='mm',$format='A4')75 function FPDF($orientation='P', $unit='mm', $format='A4') 79 76 { 80 77 //Some checks … … 85 82 $this->buffer=''; 86 83 $this->pages=array(); 87 $this-> OrientationChanges=array();84 $this->PageSizes=array(); 88 85 $this->state=0; 89 86 $this->fonts=array(); … … 92 89 $this->images=array(); 93 90 $this->links=array(); 91 $this->InHeader=false; 94 92 $this->InFooter=false; 95 93 $this->lasth=0; … … 104 102 $this->ws=0; 105 103 //Standard fonts 106 $this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique',107 'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique',108 'times'=>'Times-Roman', 'timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic',109 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');104 $this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique', 105 'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique', 106 'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic', 107 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats'); 110 108 //Scale factor 111 109 if($unit=='pt') … … 120 118 $this->Error('Incorrect unit: '.$unit); 121 119 //Page format 120 $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), 121 'letter'=>array(612,792), 'legal'=>array(612,1008)); 122 122 if(is_string($format)) 123 { 124 $format=strtolower($format); 125 if($format=='a3') 126 $format=array(841.89,1190.55); 127 elseif($format=='a4') 128 $format=array(595.28,841.89); 129 elseif($format=='a5') 130 $format=array(420.94,595.28); 131 elseif($format=='letter') 132 $format=array(612,792); 133 elseif($format=='legal') 134 $format=array(612,1008); 135 else 136 $this->Error('Unknown page format: '.$format); 137 $this->fwPt=$format[0]; 138 $this->fhPt=$format[1]; 139 } 140 else 141 { 142 $this->fwPt=$format[0]*$this->k; 143 $this->fhPt=$format[1]*$this->k; 144 } 145 $this->fw=$this->fwPt/$this->k; 146 $this->fh=$this->fhPt/$this->k; 123 $format=$this->_getpageformat($format); 124 $this->DefPageFormat=$format; 125 $this->CurPageFormat=$format; 147 126 //Page orientation 148 127 $orientation=strtolower($orientation); … … 150 129 { 151 130 $this->DefOrientation='P'; 152 $this->w Pt=$this->fwPt;153 $this->h Pt=$this->fhPt;131 $this->w=$this->DefPageFormat[0]; 132 $this->h=$this->DefPageFormat[1]; 154 133 } 155 134 elseif($orientation=='l' || $orientation=='landscape') 156 135 { 157 136 $this->DefOrientation='L'; 158 $this->w Pt=$this->fhPt;159 $this->h Pt=$this->fwPt;137 $this->w=$this->DefPageFormat[1]; 138 $this->h=$this->DefPageFormat[0]; 160 139 } 161 140 else 162 141 $this->Error('Incorrect orientation: '.$orientation); 163 142 $this->CurOrientation=$this->DefOrientation; 164 $this->w =$this->wPt/$this->k;165 $this->h =$this->hPt/$this->k;143 $this->wPt=$this->w*$this->k; 144 $this->hPt=$this->h*$this->k; 166 145 //Page margins (1 cm) 167 146 $margin=28.35/$this->k; … … 181 160 } 182 161 183 function SetMargins($left, $top,$right=-1)162 function SetMargins($left, $top, $right=null) 184 163 { 185 164 //Set left, top and right margins 186 165 $this->lMargin=$left; 187 166 $this->tMargin=$top; 188 if($right== -1)167 if($right===null) 189 168 $right=$left; 190 169 $this->rMargin=$right; … … 211 190 } 212 191 213 function SetAutoPageBreak($auto, $margin=0)192 function SetAutoPageBreak($auto, $margin=0) 214 193 { 215 194 //Set auto page break mode and triggering margin … … 219 198 } 220 199 221 function SetDisplayMode($zoom, $layout='continuous')200 function SetDisplayMode($zoom, $layout='continuous') 222 201 { 223 202 //Set display mode in viewer … … 241 220 } 242 221 243 function SetTitle($title )222 function SetTitle($title, $isUTF8=false) 244 223 { 245 224 //Title of document 225 if($isUTF8) 226 $title=$this->_UTF8toUTF16($title); 246 227 $this->title=$title; 247 228 } 248 229 249 function SetSubject($subject )230 function SetSubject($subject, $isUTF8=false) 250 231 { 251 232 //Subject of document 233 if($isUTF8) 234 $subject=$this->_UTF8toUTF16($subject); 252 235 $this->subject=$subject; 253 236 } 254 237 255 function SetAuthor($author )238 function SetAuthor($author, $isUTF8=false) 256 239 { 257 240 //Author of document 241 if($isUTF8) 242 $author=$this->_UTF8toUTF16($author); 258 243 $this->author=$author; 259 244 } 260 245 261 function SetKeywords($keywords )246 function SetKeywords($keywords, $isUTF8=false) 262 247 { 263 248 //Keywords of document 249 if($isUTF8) 250 $keywords=$this->_UTF8toUTF16($keywords); 264 251 $this->keywords=$keywords; 265 252 } 266 253 267 function SetCreator($creator )254 function SetCreator($creator, $isUTF8=false) 268 255 { 269 256 //Creator of document 257 if($isUTF8) 258 $creator=$this->_UTF8toUTF16($creator); 270 259 $this->creator=$creator; 271 260 } … … 280 269 { 281 270 //Fatal error 282 die('< B>FPDF error: </B>'.$msg);271 die('<b>FPDF error:</b> '.$msg); 283 272 } 284 273 … … 306 295 } 307 296 308 function AddPage($orientation='' )297 function AddPage($orientation='', $format='') 309 298 { 310 299 //Start a new page … … 329 318 } 330 319 //Start new page 331 $this->_beginpage($orientation );320 $this->_beginpage($orientation,$format); 332 321 //Set line cap style to square 333 322 $this->_out('2 J'); 334 323 //Set line width 335 324 $this->LineWidth=$lw; 336 $this->_out(sprintf('%.2 fw',$lw*$this->k));325 $this->_out(sprintf('%.2F w',$lw*$this->k)); 337 326 //Set font 338 327 if($family) … … 348 337 $this->ColorFlag=$cf; 349 338 //Page header 339 $this->InHeader=true; 350 340 $this->Header(); 341 $this->InHeader=false; 351 342 //Restore line width 352 343 if($this->LineWidth!=$lw) 353 344 { 354 345 $this->LineWidth=$lw; 355 $this->_out(sprintf('%.2 fw',$lw*$this->k));346 $this->_out(sprintf('%.2F w',$lw*$this->k)); 356 347 } 357 348 //Restore font … … 389 380 } 390 381 391 function SetDrawColor($r, $g=-1,$b=-1)382 function SetDrawColor($r, $g=null, $b=null) 392 383 { 393 384 //Set color for all stroking operations 394 if(($r==0 && $g==0 && $b==0) || $g== -1)395 $this->DrawColor=sprintf('%.3 fG',$r/255);396 else 397 $this->DrawColor=sprintf('%.3 f %.3f %.3fRG',$r/255,$g/255,$b/255);385 if(($r==0 && $g==0 && $b==0) || $g===null) 386 $this->DrawColor=sprintf('%.3F G',$r/255); 387 else 388 $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); 398 389 if($this->page>0) 399 390 $this->_out($this->DrawColor); 400 391 } 401 392 402 function SetFillColor($r, $g=-1,$b=-1)393 function SetFillColor($r, $g=null, $b=null) 403 394 { 404 395 //Set color for all filling operations 405 if(($r==0 && $g==0 && $b==0) || $g== -1)406 $this->FillColor=sprintf('%.3 fg',$r/255);407 else 408 $this->FillColor=sprintf('%.3 f %.3f %.3frg',$r/255,$g/255,$b/255);396 if(($r==0 && $g==0 && $b==0) || $g===null) 397 $this->FillColor=sprintf('%.3F g',$r/255); 398 else 399 $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); 409 400 $this->ColorFlag=($this->FillColor!=$this->TextColor); 410 401 if($this->page>0) … … 412 403 } 413 404 414 function SetTextColor($r, $g=-1,$b=-1)405 function SetTextColor($r, $g=null, $b=null) 415 406 { 416 407 //Set color for text 417 if(($r==0 && $g==0 && $b==0) || $g== -1)418 $this->TextColor=sprintf('%.3 fg',$r/255);419 else 420 $this->TextColor=sprintf('%.3 f %.3f %.3frg',$r/255,$g/255,$b/255);408 if(($r==0 && $g==0 && $b==0) || $g===null) 409 $this->TextColor=sprintf('%.3F g',$r/255); 410 else 411 $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); 421 412 $this->ColorFlag=($this->FillColor!=$this->TextColor); 422 413 } … … 430 421 $l=strlen($s); 431 422 for($i=0;$i<$l;$i++) 432 $w+=$cw[$s {$i}];423 $w+=$cw[$s[$i]]; 433 424 return $w*$this->FontSize/1000; 434 425 } … … 439 430 $this->LineWidth=$width; 440 431 if($this->page>0) 441 $this->_out(sprintf('%.2 fw',$width*$this->k));442 } 443 444 function Line($x1, $y1,$x2,$y2)432 $this->_out(sprintf('%.2F w',$width*$this->k)); 433 } 434 435 function Line($x1, $y1, $x2, $y2) 445 436 { 446 437 //Draw a line 447 $this->_out(sprintf('%.2 f %.2f m %.2f %.2fl S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));448 } 449 450 function Rect($x, $y,$w,$h,$style='')438 $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k)); 439 } 440 441 function Rect($x, $y, $w, $h, $style='') 451 442 { 452 443 //Draw a rectangle … … 457 448 else 458 449 $op='S'; 459 $this->_out(sprintf('%.2 f %.2f %.2f %.2fre %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));460 } 461 462 function AddFont($family, $style='',$file='')450 $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); 451 } 452 453 function AddFont($family, $style='', $file='') 463 454 { 464 455 //Add a TrueType or Type1 font … … 473 464 $fontkey=$family.$style; 474 465 if(isset($this->fonts[$fontkey])) 475 $this->Error('Font already added: '.$family.' '.$style);466 return; 476 467 include($this->_getfontpath().$file); 477 468 if(!isset($name)) 478 469 $this->Error('Could not include font definition file'); 479 470 $i=count($this->fonts)+1; 480 $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$enc,'file'=>$file);471 $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file); 481 472 if($diff) 482 473 { … … 504 495 $this->FontFiles[$file]=array('length1'=>$originalsize); 505 496 else 506 $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);507 } 508 } 509 510 function SetFont($family, $style='',$size=0)497 $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); 498 } 499 } 500 501 function SetFont($family, $style='', $size=0) 511 502 { 512 503 //Select a font; size given in points … … 553 544 } 554 545 $i=count($this->fonts)+1; 555 $this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]); 546 $name=$this->CoreFonts[$fontkey]; 547 $cw=$fpdf_charwidths[$fontkey]; 548 $this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw); 556 549 } 557 550 else … … 565 558 $this->CurrentFont=&$this->fonts[$fontkey]; 566 559 if($this->page>0) 567 $this->_out(sprintf('BT /F%d %.2 fTf ET',$this->CurrentFont['i'],$this->FontSizePt));560 $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); 568 561 } 569 562 … … 576 569 $this->FontSize=$size/$this->k; 577 570 if($this->page>0) 578 $this->_out(sprintf('BT /F%d %.2 fTf ET',$this->CurrentFont['i'],$this->FontSizePt));571 $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); 579 572 } 580 573 … … 583 576 //Create a new internal link 584 577 $n=count($this->links)+1; 585 $this->links[$n]=array(0, 0);578 $this->links[$n]=array(0, 0); 586 579 return $n; 587 580 } 588 581 589 function SetLink($link, $y=0,$page=-1)582 function SetLink($link, $y=0, $page=-1) 590 583 { 591 584 //Set destination of internal link … … 594 587 if($page==-1) 595 588 $page=$this->page; 596 $this->links[$link]=array($page, $y);597 } 598 599 function Link($x, $y,$w,$h,$link)589 $this->links[$link]=array($page, $y); 590 } 591 592 function Link($x, $y, $w, $h, $link) 600 593 { 601 594 //Put a link on the page 602 $this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k,$w*$this->k,$h*$this->k,$link);603 } 604 605 function Text($x, $y,$txt)595 $this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link); 596 } 597 598 function Text($x, $y, $txt) 606 599 { 607 600 //Output a string 608 $s=sprintf('BT %.2 f %.2fTd (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));601 $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); 609 602 if($this->underline && $txt!='') 610 603 $s.=' '.$this->_dounderline($x,$y,$txt); … … 620 613 } 621 614 622 function Cell($w, $h=0,$txt='',$border="0",$ln=0,$align='',$fill=0,$link='')615 function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') 623 616 { 624 617 //Output a cell 625 618 $k=$this->k; 626 if($this->y+$h>$this->PageBreakTrigger && !$this->In Footer && $this->AcceptPageBreak())619 if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) 627 620 { 628 621 //Automatic page break … … 634 627 $this->_out('0 Tw'); 635 628 } 636 $this->AddPage($this->CurOrientation );629 $this->AddPage($this->CurOrientation,$this->CurPageFormat); 637 630 $this->x=$x; 638 631 if($ws>0) 639 632 { 640 633 $this->ws=$ws; 641 $this->_out(sprintf('%.3 fTw',$ws*$k));634 $this->_out(sprintf('%.3F Tw',$ws*$k)); 642 635 } 643 636 } … … 645 638 $w=$this->w-$this->rMargin-$this->x; 646 639 $s=''; 647 if($fill ==1|| $border==1)648 { 649 if($fill ==1)640 if($fill || $border==1) 641 { 642 if($fill) 650 643 $op=($border==1) ? 'B' : 'f'; 651 644 else 652 645 $op='S'; 653 $s=sprintf('%.2 f %.2f %.2f %.2fre %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);646 $s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); 654 647 } 655 648 if(is_string($border)) … … 658 651 $y=$this->y; 659 652 if(strpos($border,'L')!==false) 660 $s.=sprintf('%.2 f %.2f m %.2f %.2fl S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);653 $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); 661 654 if(strpos($border,'T')!==false) 662 $s.=sprintf('%.2 f %.2f m %.2f %.2fl S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);655 $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); 663 656 if(strpos($border,'R')!==false) 664 $s.=sprintf('%.2 f %.2f m %.2f %.2fl S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);657 $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); 665 658 if(strpos($border,'B')!==false) 666 $s.=sprintf('%.2 f %.2f m %.2f %.2fl S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);659 $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); 667 660 } 668 661 if($txt!=='') … … 677 670 $s.='q '.$this->TextColor.' '; 678 671 $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); 679 $s.=sprintf('BT %.2 f %.2fTd (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);672 $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); 680 673 if($this->underline) 681 674 $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); … … 699 692 } 700 693 701 function MultiCell($w, $h,$txt,$border="0",$align='J',$fill=0)694 function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) 702 695 { 703 696 //Output text with automatic or explicit line breaks … … 738 731 { 739 732 //Get next character 740 $c=$s {$i};733 $c=$s[$i]; 741 734 if($c=="\n") 742 735 { … … 784 777 { 785 778 $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; 786 $this->_out(sprintf('%.3 fTw',$this->ws*$this->k));779 $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); 787 780 } 788 781 $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); … … 812 805 } 813 806 814 function Write($h, $txt,$link='')807 function Write($h, $txt, $link='') 815 808 { 816 809 //Output text in flowing mode … … 828 821 { 829 822 //Get next character 830 $c=$s {$i};823 $c=$s[$i]; 831 824 if($c=="\n") 832 825 { … … 893 886 } 894 887 895 function Image($file,$x,$y,$w=0,$h=0,$type='',$link='') 888 function Ln($h=null) 889 { 890 //Line feed; default value is last cell height 891 $this->x=$this->lMargin; 892 if($h===null) 893 $this->y+=$this->lasth; 894 else 895 $this->y+=$h; 896 } 897 898 function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') 896 899 { 897 900 //Put an image on the page 898 901 if(!isset($this->images[$file])) 899 902 { 900 //First use of image, get info903 //First use of this image, get info 901 904 if($type=='') 902 905 { … … 907 910 } 908 911 $type=strtolower($type); 909 $mqr=get_magic_quotes_runtime(); 910 set_magic_quotes_runtime(0); 911 if($type=='jpg' || $type=='jpeg') 912 $info=$this->_parsejpg($file); 913 elseif($type=='png') 914 $info=$this->_parsepng($file); 915 else 916 { 917 //Allow for additional formats 918 $mtd='_parse'.$type; 919 if(!method_exists($this,$mtd)) 920 $this->Error('Unsupported image type: '.$type); 921 $info=$this->$mtd($file); 922 } 923 set_magic_quotes_runtime($mqr); 912 if($type=='jpeg') 913 $type='jpg'; 914 $mtd='_parse'.$type; 915 if(!method_exists($this,$mtd)) 916 $this->Error('Unsupported image type: '.$type); 917 $info=$this->$mtd($file); 924 918 $info['i']=count($this->images)+1; 925 919 $this->images[$file]=$info; … … 934 928 $h=$info['h']/$this->k; 935 929 } 936 if($w==0)930 elseif($w==0) 937 931 $w=$h*$info['w']/$info['h']; 938 if($h==0)932 elseif($h==0) 939 933 $h=$w*$info['h']/$info['w']; 940 $this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); 934 //Flowing mode 935 if($y===null) 936 { 937 if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) 938 { 939 //Automatic page break 940 $x2=$this->x; 941 $this->AddPage($this->CurOrientation,$this->CurPageFormat); 942 $this->x=$x2; 943 } 944 $y=$this->y; 945 $this->y+=$h; 946 } 947 if($x===null) 948 $x=$this->x; 949 $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); 941 950 if($link) 942 951 $this->Link($x,$y,$w,$h,$link); 943 }944 945 function Ln($h='')946 {947 //Line feed; default value is last cell height948 $this->x=$this->lMargin;949 if(is_string($h))950 $this->y+=$this->lasth;951 else952 $this->y+=$h;953 952 } 954 953 … … 984 983 } 985 984 986 function SetXY($x, $y)985 function SetXY($x, $y) 987 986 { 988 987 //Set x and y positions … … 991 990 } 992 991 993 function Output($name='', $dest='')992 function Output($name='', $dest='') 994 993 { 995 994 //Output PDF to some destination 996 //Finish document if necessary997 995 if($this->state<3) 998 996 $this->Close(); 999 //Normalize parameters1000 if(is_bool($dest))1001 $dest=$dest ? 'D' : 'F';1002 997 $dest=strtoupper($dest); 1003 998 if($dest=='') … … 1015 1010 case 'I': 1016 1011 //Send to standard output 1017 if(ob_get_ contents())1012 if(ob_get_length()) 1018 1013 $this->Error('Some data has already been output, can\'t send PDF file'); 1019 1014 if(php_sapi_name()!='cli') … … 1022 1017 header('Content-Type: application/pdf'); 1023 1018 if(headers_sent()) 1024 $this->Error('Some data has already been output to browser, can\'t send PDF file');1019 $this->Error('Some data has already been output, can\'t send PDF file'); 1025 1020 header('Content-Length: '.strlen($this->buffer)); 1026 header('Content-disposition: inline; filename="'.$name.'"'); 1021 header('Content-Disposition: inline; filename="'.$name.'"'); 1022 header('Cache-Control: private, max-age=0, must-revalidate'); 1023 header('Pragma: public'); 1024 ini_set('zlib.output_compression','0'); 1027 1025 } 1028 1026 echo $this->buffer; … … 1030 1028 case 'D': 1031 1029 //Download file 1032 if(ob_get_ contents())1030 if(ob_get_length()) 1033 1031 $this->Error('Some data has already been output, can\'t send PDF file'); 1034 if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) 1035 header('Content-Type: application/force-download'); 1036 else 1037 header('Content-Type: application/octet-stream'); 1032 header('Content-Type: application/x-download'); 1038 1033 if(headers_sent()) 1039 $this->Error('Some data has already been output to browser, can\'t send PDF file');1034 $this->Error('Some data has already been output, can\'t send PDF file'); 1040 1035 header('Content-Length: '.strlen($this->buffer)); 1041 header('Content-disposition: attachment; filename="'.$name.'"'); 1036 header('Content-Disposition: attachment; filename="'.$name.'"'); 1037 header('Cache-Control: private, max-age=0, must-revalidate'); 1038 header('Pragma: public'); 1039 ini_set('zlib.output_compression','0'); 1042 1040 echo $this->buffer; 1043 1041 break; … … 1066 1064 function _dochecks() 1067 1065 { 1068 //Check for locale-related bug 1069 if(1.1==1) 1070 $this->Error('Don\'t alter the locale before including class file'); 1071 //Check for decimal separator 1072 if(sprintf('%.1f',1.0)!='1.0') 1073 setlocale(LC_NUMERIC,'C'); 1066 //Check availability of %F 1067 if(sprintf('%.1F',1.0)!='1.0') 1068 $this->Error('This version of PHP is not supported'); 1069 //Check mbstring overloading 1070 if(ini_get('mbstring.func_overload') & 2) 1071 $this->Error('mbstring overloading must be disabled'); 1072 //Disable runtime magic quotes 1073 if(get_magic_quotes_runtime()) 1074 @set_magic_quotes_runtime(0); 1075 } 1076 1077 function _getpageformat($format) 1078 { 1079 $format=strtolower($format); 1080 if(!isset($this->PageFormats[$format])) 1081 $this->Error('Unknown page format: '.$format); 1082 $a=$this->PageFormats[$format]; 1083 return array($a[0]/$this->k, $a[1]/$this->k); 1074 1084 } 1075 1085 … … 1081 1091 } 1082 1092 1093 function _beginpage($orientation, $format) 1094 { 1095 $this->page++; 1096 $this->pages[$this->page]=''; 1097 $this->state=2; 1098 $this->x=$this->lMargin; 1099 $this->y=$this->tMargin; 1100 $this->FontFamily=''; 1101 //Check page size 1102 if($orientation=='') 1103 $orientation=$this->DefOrientation; 1104 else 1105 $orientation=strtoupper($orientation[0]); 1106 if($format=='') 1107 $format=$this->DefPageFormat; 1108 else 1109 { 1110 if(is_string($format)) 1111 $format=$this->_getpageformat($format); 1112 } 1113 if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) 1114 { 1115 //New size 1116 if($orientation=='P') 1117 { 1118 $this->w=$format[0]; 1119 $this->h=$format[1]; 1120 } 1121 else 1122 { 1123 $this->w=$format[1]; 1124 $this->h=$format[0]; 1125 } 1126 $this->wPt=$this->w*$this->k; 1127 $this->hPt=$this->h*$this->k; 1128 $this->PageBreakTrigger=$this->h-$this->bMargin; 1129 $this->CurOrientation=$orientation; 1130 $this->CurPageFormat=$format; 1131 } 1132 if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) 1133 $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); 1134 } 1135 1136 function _endpage() 1137 { 1138 $this->state=1; 1139 } 1140 1141 function _escape($s) 1142 { 1143 //Escape special characters in strings 1144 $s=str_replace('\\','\\\\',$s); 1145 $s=str_replace('(','\\(',$s); 1146 $s=str_replace(')','\\)',$s); 1147 $s=str_replace("\r",'\\r',$s); 1148 return $s; 1149 } 1150 1151 function _textstring($s) 1152 { 1153 //Format a text string 1154 return '('.$this->_escape($s).')'; 1155 } 1156 1157 function _UTF8toUTF16($s) 1158 { 1159 //Convert UTF-8 to UTF-16BE with BOM 1160 $res="\xFE\xFF"; 1161 $nb=strlen($s); 1162 $i=0; 1163 while($i<$nb) 1164 { 1165 $c1=ord($s[$i++]); 1166 if($c1>=224) 1167 { 1168 //3-byte character 1169 $c2=ord($s[$i++]); 1170 $c3=ord($s[$i++]); 1171 $res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); 1172 $res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); 1173 } 1174 elseif($c1>=192) 1175 { 1176 //2-byte character 1177 $c2=ord($s[$i++]); 1178 $res.=chr(($c1 & 0x1C)>>2); 1179 $res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); 1180 } 1181 else 1182 { 1183 //Single-byte character 1184 $res.="\0".chr($c1); 1185 } 1186 } 1187 return $res; 1188 } 1189 1190 function _dounderline($x, $y, $txt) 1191 { 1192 //Underline text 1193 $up=$this->CurrentFont['up']; 1194 $ut=$this->CurrentFont['ut']; 1195 $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); 1196 return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt); 1197 } 1198 1199 function _parsejpg($file) 1200 { 1201 //Extract info from a JPEG file 1202 $a=GetImageSize($file); 1203 if(!$a) 1204 $this->Error('Missing or incorrect image file: '.$file); 1205 if($a[2]!=2) 1206 $this->Error('Not a JPEG file: '.$file); 1207 if(!isset($a['channels']) || $a['channels']==3) 1208 $colspace='DeviceRGB'; 1209 elseif($a['channels']==4) 1210 $colspace='DeviceCMYK'; 1211 else 1212 $colspace='DeviceGray'; 1213 $bpc=isset($a['bits']) ? $a['bits'] : 8; 1214 //Read whole file 1215 $f=fopen($file,'rb'); 1216 $data=''; 1217 while(!feof($f)) 1218 $data.=fread($f,8192); 1219 fclose($f); 1220 return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); 1221 } 1222 1223 function _parsepng($file) 1224 { 1225 //Extract info from a PNG file 1226 $f=fopen($file,'rb'); 1227 if(!$f) 1228 $this->Error('Can\'t open image file: '.$file); 1229 //Check signature 1230 if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) 1231 $this->Error('Not a PNG file: '.$file); 1232 //Read header chunk 1233 $this->_readstream($f,4); 1234 if($this->_readstream($f,4)!='IHDR') 1235 $this->Error('Incorrect PNG file: '.$file); 1236 $w=$this->_readint($f); 1237 $h=$this->_readint($f); 1238 $bpc=ord($this->_readstream($f,1)); 1239 if($bpc>8) 1240 $this->Error('16-bit depth not supported: '.$file); 1241 $ct=ord($this->_readstream($f,1)); 1242 if($ct==0) 1243 $colspace='DeviceGray'; 1244 elseif($ct==2) 1245 $colspace='DeviceRGB'; 1246 elseif($ct==3) 1247 $colspace='Indexed'; 1248 else 1249 $this->Error('Alpha channel not supported: '.$file); 1250 if(ord($this->_readstream($f,1))!=0) 1251 $this->Error('Unknown compression method: '.$file); 1252 if(ord($this->_readstream($f,1))!=0) 1253 $this->Error('Unknown filter method: '.$file); 1254 if(ord($this->_readstream($f,1))!=0) 1255 $this->Error('Interlacing not supported: '.$file); 1256 $this->_readstream($f,4); 1257 $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>'; 1258 //Scan chunks looking for palette, transparency and image data 1259 $pal=''; 1260 $trns=''; 1261 $data=''; 1262 do 1263 { 1264 $n=$this->_readint($f); 1265 $type=$this->_readstream($f,4); 1266 if($type=='PLTE') 1267 { 1268 //Read palette 1269 $pal=$this->_readstream($f,$n); 1270 $this->_readstream($f,4); 1271 } 1272 elseif($type=='tRNS') 1273 { 1274 //Read transparency info 1275 $t=$this->_readstream($f,$n); 1276 if($ct==0) 1277 $trns=array(ord(substr($t,1,1))); 1278 elseif($ct==2) 1279 $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); 1280 else 1281 { 1282 $pos=strpos($t,chr(0)); 1283 if($pos!==false) 1284 $trns=array($pos); 1285 } 1286 $this->_readstream($f,4); 1287 } 1288 elseif($type=='IDAT') 1289 { 1290 //Read image data block 1291 $data.=$this->_readstream($f,$n); 1292 $this->_readstream($f,4); 1293 } 1294 elseif($type=='IEND') 1295 break; 1296 else 1297 $this->_readstream($f,$n+4); 1298 } 1299 while($n); 1300 if($colspace=='Indexed' && empty($pal)) 1301 $this->Error('Missing palette in '.$file); 1302 fclose($f); 1303 return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data); 1304 } 1305 1306 function _readstream($f, $n) 1307 { 1308 //Read n bytes from stream 1309 $res=''; 1310 while($n>0 && !feof($f)) 1311 { 1312 $s=fread($f,$n); 1313 if($s===false) 1314 $this->Error('Error while reading stream'); 1315 $n-=strlen($s); 1316 $res.=$s; 1317 } 1318 if($n>0) 1319 $this->Error('Unexpected end of stream'); 1320 return $res; 1321 } 1322 1323 function _readint($f) 1324 { 1325 //Read a 4-byte integer from stream 1326 $a=unpack('Ni',$this->_readstream($f,4)); 1327 return $a['i']; 1328 } 1329 1330 function _parsegif($file) 1331 { 1332 //Extract info from a GIF file (via PNG conversion) 1333 if(!function_exists('imagepng')) 1334 $this->Error('GD extension is required for GIF support'); 1335 if(!function_exists('imagecreatefromgif')) 1336 $this->Error('GD has no GIF read support'); 1337 $im=imagecreatefromgif($file); 1338 if(!$im) 1339 $this->Error('Missing or incorrect image file: '.$file); 1340 imageinterlace($im,0); 1341 $tmp=tempnam('.','gif'); 1342 if(!$tmp) 1343 $this->Error('Unable to create a temporary file'); 1344 if(!imagepng($im,$tmp)) 1345 $this->Error('Error while saving to temporary file'); 1346 imagedestroy($im); 1347 $info=$this->_parsepng($tmp); 1348 unlink($tmp); 1349 return $info; 1350 } 1351 1352 function _newobj() 1353 { 1354 //Begin a new object 1355 $this->n++; 1356 $this->offsets[$this->n]=strlen($this->buffer); 1357 $this->_out($this->n.' 0 obj'); 1358 } 1359 1360 function _putstream($s) 1361 { 1362 $this->_out('stream'); 1363 $this->_out($s); 1364 $this->_out('endstream'); 1365 } 1366 1367 function _out($s) 1368 { 1369 //Add a line to the document 1370 if($this->state==2) 1371 $this->pages[$this->page].=$s."\n"; 1372 else 1373 $this->buffer.=$s."\n"; 1374 } 1375 1083 1376 function _putpages() 1084 1377 { … … 1092 1385 if($this->DefOrientation=='P') 1093 1386 { 1094 $wPt=$this-> fwPt;1095 $hPt=$this-> fhPt;1096 } 1097 else 1098 { 1099 $wPt=$this-> fhPt;1100 $hPt=$this-> fwPt;1387 $wPt=$this->DefPageFormat[0]*$this->k; 1388 $hPt=$this->DefPageFormat[1]*$this->k; 1389 } 1390 else 1391 { 1392 $wPt=$this->DefPageFormat[1]*$this->k; 1393 $hPt=$this->DefPageFormat[0]*$this->k; 1101 1394 } 1102 1395 $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; … … 1107 1400 $this->_out('<</Type /Page'); 1108 1401 $this->_out('/Parent 1 0 R'); 1109 if(isset($this-> OrientationChanges[$n]))1110 $this->_out(sprintf('/MediaBox [0 0 %.2 f %.2f]',$hPt,$wPt));1402 if(isset($this->PageSizes[$n])) 1403 $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); 1111 1404 $this->_out('/Resources 2 0 R'); 1112 1405 if(isset($this->PageLinks[$n])) … … 1116 1409 foreach($this->PageLinks[$n] as $pl) 1117 1410 { 1118 $rect=sprintf('%.2 f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);1411 $rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); 1119 1412 $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; 1120 1413 if(is_string($pl[4])) … … 1123 1416 { 1124 1417 $l=$this->links[$pl[4]]; 1125 $h=isset($this-> OrientationChanges[$l[0]]) ? $wPt: $hPt;1126 $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2 fnull]>>',1+2*$l[0],$h-$l[1]*$this->k);1418 $h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; 1419 $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k); 1127 1420 } 1128 1421 } … … 1147 1440 $this->_out($kids.']'); 1148 1441 $this->_out('/Count '.$nb); 1149 $this->_out(sprintf('/MediaBox [0 0 %.2 f %.2f]',$wPt,$hPt));1442 $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt)); 1150 1443 $this->_out('>>'); 1151 1444 $this->_out('endobj'); … … 1162 1455 $this->_out('endobj'); 1163 1456 } 1164 $mqr=get_magic_quotes_runtime();1165 @set_magic_quotes_runtime(0);1166 1457 foreach($this->FontFiles as $file=>$info) 1167 1458 { … … 1179 1470 if(!$compressed && isset($info['length2'])) 1180 1471 { 1181 $header=(ord($font {0})==128);1472 $header=(ord($font[0])==128); 1182 1473 if($header) 1183 1474 { … … 1185 1476 $font=substr($font,6); 1186 1477 } 1187 if($header && ord($font {$info['length1']})==128)1478 if($header && ord($font[$info['length1']])==128) 1188 1479 { 1189 1480 //Strip second binary header … … 1201 1492 $this->_out('endobj'); 1202 1493 } 1203 @set_magic_quotes_runtime($mqr);1204 1494 foreach($this->fonts as $k=>$font) 1205 1495 { … … 1361 1651 if(!empty($this->creator)) 1362 1652 $this->_out('/Creator '.$this->_textstring($this->creator)); 1363 $this->_out('/CreationDate '.$this->_textstring('D:'. date('YmdHis')));1653 $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); 1364 1654 } 1365 1655 … … 1430 1720 $this->state=3; 1431 1721 } 1432 1433 function _beginpage($orientation)1434 {1435 $this->page++;1436 $this->pages[$this->page]='';1437 $this->state=2;1438 $this->x=$this->lMargin;1439 $this->y=$this->tMargin;1440 $this->FontFamily='';1441 //Page orientation1442 if(!$orientation)1443 $orientation=$this->DefOrientation;1444 else1445 {1446 $orientation=strtoupper($orientation{0});1447 if($orientation!=$this->DefOrientation)1448 $this->OrientationChanges[$this->page]=true;1449 }1450 if($orientation!=$this->CurOrientation)1451 {1452 //Change orientation1453 if($orientation=='P')1454 {1455 $this->wPt=$this->fwPt;1456 $this->hPt=$this->fhPt;1457 $this->w=$this->fw;1458 $this->h=$this->fh;1459 }1460 else1461 {1462 $this->wPt=$this->fhPt;1463 $this->hPt=$this->fwPt;1464 $this->w=$this->fh;1465 $this->h=$this->fw;1466 }1467 $this->PageBreakTrigger=$this->h-$this->bMargin;1468 $this->CurOrientation=$orientation;1469 }1470 }1471 1472 function _endpage()1473 {1474 //End of page contents1475 $this->state=1;1476 }1477 1478 function _newobj()1479 {1480 //Begin a new object1481 $this->n++;1482 $this->offsets[$this->n]=strlen($this->buffer);1483 $this->_out($this->n.' 0 obj');1484 }1485 1486 function _dounderline($x,$y,$txt)1487 {1488 //Underline text1489 $up=$this->CurrentFont['up'];1490 $ut=$this->CurrentFont['ut'];1491 $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');1492 return sprintf('%.2f %.2f %.2f %.2f re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);1493 }1494 1495 function _parsejpg($file)1496 {1497 //Extract info from a JPEG file1498 $a=GetImageSize($file);1499 if(!$a)1500 $this->Error('Missing or incorrect image file: '.$file);1501 if($a[2]!=2)1502 $this->Error('Not a JPEG file: '.$file);1503 if(!isset($a['channels']) || $a['channels']==3)1504 $colspace='DeviceRGB';1505 elseif($a['channels']==4)1506 $colspace='DeviceCMYK';1507 else1508 $colspace='DeviceGray';1509 $bpc=isset($a['bits']) ? $a['bits'] : 8;1510 //Read whole file1511 $f=fopen($file,'rb');1512 $data='';1513 while(!feof($f))1514 $data.=fread($f,4096);1515 fclose($f);1516 return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data);1517 }1518 1519 function _parsepng($file)1520 {1521 //Extract info from a PNG file1522 $f=fopen($file,'rb');1523 if(!$f)1524 $this->Error('Can\'t open image file: '.$file);1525 //Check signature1526 if(fread($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))1527 $this->Error('Not a PNG file: '.$file);1528 //Read header chunk1529 fread($f,4);1530 if(fread($f,4)!='IHDR')1531 $this->Error('Incorrect PNG file: '.$file);1532 $w=$this->_freadint($f);1533 $h=$this->_freadint($f);1534 $bpc=ord(fread($f,1));1535 if($bpc>8)1536 $this->Error('16-bit depth not supported: '.$file);1537 $ct=ord(fread($f,1));1538 if($ct==0)1539 $colspace='DeviceGray';1540 elseif($ct==2)1541 $colspace='DeviceRGB';1542 elseif($ct==3)1543 $colspace='Indexed';1544 else1545 $this->Error('Alpha channel not supported: '.$file);1546 if(ord(fread($f,1))!=0)1547 $this->Error('Unknown compression method: '.$file);1548 if(ord(fread($f,1))!=0)1549 $this->Error('Unknown filter method: '.$file);1550 if(ord(fread($f,1))!=0)1551 $this->Error('Interlacing not supported: '.$file);1552 fread($f,4);1553 $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';1554 //Scan chunks looking for palette, transparency and image data1555 $pal='';1556 $trns='';1557 $data='';1558 do1559 {1560 $n=$this->_freadint($f);1561 $type=fread($f,4);1562 if($type=='PLTE')1563 {1564 //Read palette1565 $pal=fread($f,$n);1566 fread($f,4);1567 }1568 elseif($type=='tRNS')1569 {1570 //Read transparency info1571 $t=fread($f,$n);1572 if($ct==0)1573 $trns=array(ord(substr($t,1,1)));1574 elseif($ct==2)1575 $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));1576 else1577 {1578 $pos=strpos($t,chr(0));1579 if($pos!==false)1580 $trns=array($pos);1581 }1582 fread($f,4);1583 }1584 elseif($type=='IDAT')1585 {1586 //Read image data block1587 $data.=fread($f,$n);1588 fread($f,4);1589 }1590 elseif($type=='IEND')1591 break;1592 else1593 fread($f,$n+4);1594 }1595 while($n);1596 if($colspace=='Indexed' && empty($pal))1597 $this->Error('Missing palette in '.$file);1598 fclose($f);1599 return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data);1600 }1601 1602 function _freadint($f)1603 {1604 //Read a 4-byte integer from file1605 $a=unpack('Ni',fread($f,4));1606 return $a['i'];1607 }1608 1609 function _textstring($s)1610 {1611 //Format a text string1612 return '('.$this->_escape($s).')';1613 }1614 1615 function _escape($s)1616 {1617 //Add \ before \, ( and )1618 return str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$s)));1619 }1620 1621 function _putstream($s)1622 {1623 $this->_out('stream');1624 $this->_out($s);1625 $this->_out('endstream');1626 }1627 1628 function _out($s)1629 {1630 //Add a line to the document1631 if($this->state==2)1632 $this->pages[$this->page].=$s."\n";1633 else1634 $this->buffer.=$s."\n";1635 }1636 1722 //End of class 1637 1723 } … … 1644 1730 } 1645 1731 1646 }1647 1732 ?> -
trunk/phpbms/include/common_functions.php
r675 r693 549 549 /** 550 550 * function makeDelimeterString 551 * 551 * 552 552 * Creates a string with the same length as $string, with a delimeter where 553 553 * the corresponding part of the string is on or within that delimeter, and … … 565 565 */ 566 566 function makeDelimeterString($string, $delimeters, $escapeCharacter = "\\"){ 567 567 568 568 if(!$escapeCharacter) 569 569 $escapeCharacter = NULL; 570 570 571 571 if(strlen($escapeCharacter) > 1) 572 572 return false; 573 573 574 574 $returnString = ""; 575 575 $stringArray = str_split($string); … … 577 577 $prevChar = ""; 578 578 foreach($stringArray as $char){ 579 579 580 580 if(!$inside){ 581 581 if(in_array($char, $delimeters) && $prevChar != $escapeCharacter){ … … 586 586 $returnString .= "0"; 587 587 }else{ 588 588 589 589 if($char == $delimeter && $prevChar != $escapeCharacter){ 590 590 $inside = false; … … 592 592 }else 593 593 $returnString .= $delimeter; 594 594 595 595 }//end if 596 596 597 597 $prevChar = $char; 598 598 599 599 }//end foreach 600 600 601 601 return $returnString; 602 602 603 603 }//end function 604 604 605 605 606 /* … … 607 608 * Returns the part of $querystatement from the general FROM to its ORDER BY or 608 609 * the end of the querystatement if no ORDER BY exists. 609 * 610 * 610 611 * @param $querystatement 611 612 * @return string The part of $querystatement from the general FROM to its 612 613 * ORDER BY. 613 614 */ 614 615 615 function getSearchFrom($querystatement) { 616 616 617 617 $modstatement = $querystatement; 618 618 $insideString = makeDelimeterString($querystatement, array("'", "\"", "`")); 619 619 $insideArray = str_split($insideString); 620 621 620 621 622 622 /** 623 623 * Check for SELECTs that are not inside quotes or tics. … … 628 628 $offset = 0; 629 629 do{ 630 630 631 631 $pos = stripos($querystatement, "select", $offset); 632 632 633 633 if($pos !== false) 634 634 if(!$insideArray[$pos]) 635 635 $selectArray[] = $pos; 636 636 $offset = $pos+1; 637 637 638 638 }while($pos !== false); 639 639 640 640 /** 641 641 * Check for FROMSs that are not inside quotes or tics. … … 646 646 $offset = 0; 647 647 do{ 648 648 649 649 $pos = stripos($querystatement, "from", $offset); 650 650 651 651 if($pos !== false) 652 652 if(!$insideArray[$pos]) 653 653 $fromArray[] = $pos; 654 654 $offset = $pos+1; 655 655 656 656 }while($pos !== false); 657 657 658 658 /** 659 659 * Check for ORDER BYs that are not inside quotes or tics. … … 664 664 $offset = 0; 665 665 do{ 666 666 667 667 $pos = stripos($querystatement, "order by", $offset); 668 668 669 669 if($pos !== false) 670 670 if(!$insideArray[$pos]) 671 671 $orderArray[] = $pos; 672 672 $offset = $pos+1; 673 673 674 674 }while($pos !== false); 675 676 675 676 677 677 /** 678 * Pair the SELECTs with their appropriate FROMs 678 * Pair the SELECTs with their appropriate FROMs 679 679 */ 680 680 $godArray = array(); … … 682 682 $j = 0; 683 683 foreach($fromArray as $fromPos){ 684 684 685 685 $closest = 0; 686 686 $index = 0; … … 690 690 $index = $i; 691 691 }//end if 692 692 693 693 unset($tempSelectArray[$index]); 694 694 $godArray[$j]["select"] = $closest; 695 695 $godArray[$j]["from"] = $fromPos; 696 696 $j++; 697 697 698 698 }//end foreach 699 700 699 700 701 701 /** 702 702 * Pair the ORDER BYs with their approriate FROMs (and thus their … … 706 706 $j = 0; 707 707 foreach($orderArray as $orderPos){ 708 708 709 709 $closest = 0; 710 710 $index = 0; … … 714 714 $index = $i; 715 715 }//end if 716 716 717 717 unset($tempFromArray[$index]); 718 718 for($k=0; $k < count($godArray); $k++) 719 719 if($godArray[$k]["from"] == $closest) 720 720 $godArray[$k]["order"] = $orderPos; 721 721 722 722 $j++; 723 723 724 724 }//end foreach 725 726 725 726 727 727 /** 728 728 * The last entry in the $godArray should be the outermost / first … … 732 732 if(!isset($godArray[$l]["order"])) 733 733 $godArray[$l]["order"] = strlen($querystatement); 734 734 735 735 if(!($godArray[$l]["order"])) 736 736 $godArray[$l]["order"] = strlen($querystatement); 737 737 738 738 return substr($querystatement, $godArray[$l]["from"], $godArray[$l]["order"] - $godArray[$l]["from"]); 739 739 740 740 }//end function 741 741 … … 1125 1125 1126 1126 /* 1127 * function cleanFilename 1127 * function cleanFilename 1128 1128 * @param $string 1129 1129 * @return string $string with only alpha-numeric characters, periods (.), … … 1132 1132 1133 1133 function cleanFilename($string) { 1134 1134 1135 1135 $pattern = "/[^\w\d\.\-\_]/"; 1136 1136 $string = preg_replace($pattern, "", $string); 1137 1137 1138 1138 return $string; 1139 1139 1140 1140 }//end function --cleanFilename-- 1141 1141 … … 1246 1246 1247 1247 1248 /** 1249 * function debug 1250 * 1251 * essentially provides a formatted var_dump with extra info for development purposes 1252 */ 1253 function debug($variable, $exit = false){ 1254 1255 echo "<pre>"; 1256 var_dump($variable); 1257 echo "</pre>"; 1258 1259 $backtrace = debug_backtrace(); 1260 1261 if(count($backtrace) > 1) 1262 array_shift($backtrace); 1263 1264 foreach($backtrace as $trace){ 1265 1266 echo "* "; 1267 1268 if(isset($trace["class"])) 1269 echo $trace["class"]."-> "; 1270 1271 if(isset($trace["function"])) 1272 echo $trace["function"]." "; 1273 1274 echo "in ".$trace["file"]." "; 1275 echo "on line ".$trace["line"]."<br />"; 1276 1277 }//endforeach 1278 1279 if($exit) 1280 exit(); 1281 1282 }//endif 1283 1248 1284 //for windows servers, we have no define time constants and nl_langinfo function 1249 1285 //in a limited fashion; some windows servers still show that the function -
trunk/phpbms/install/createtables.sql
r645 r693 124 124 ) ENGINE=INNODB; 125 125 126 CREATE TABLE `reportsettings` ( 127 `id` int(11) NOT NULL auto_increment, 128 `reportuuid` varchar(64) NOT NULL, 129 `name` varchar(64) NOT NULL default '', 130 `value` text default '', 131 `type` varchar(32) NOT NULL default 'string', 132 `required` tinyint(4) NOT NULL default '0', 133 `defaultvalue` varchar(255) NOT NULL, 134 `description` text, 135 PRIMARY KEY (`id`) 136 ) ENGINE=INNODB; 137 126 138 CREATE TABLE `reports` ( 127 139 `id` int(11) NOT NULL auto_increment, -
trunk/phpbms/install/reports.sql
r643 r693 1 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:37cee478-b57e-2d53-d951-baf3937ba9e0', 'Raw Table Print', 'report', '', '0', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'report/general_tableprint.php', 'This report will print out of every field for the table for the given records. The report is displayed inHTML format.', 1, NOW(), 1, NOW());1 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:37cee478-b57e-2d53-d951-baf3937ba9e0', 'Raw Table Print', 'report', '', '0', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'report/general_tableprint.php', 'This report will prints out of every field for the table for the given records. The report is displayed HTML format.', 1, NOW(), 1, NOW()); 2 2 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:dac75fb9-91d2-cb1e-9213-9fab6d32f4c8', 'Raw Table Export', 'export', '', '0', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'report/general_export.php', 'This report will generate a comma-delimited text file. Values are encapsulated in quotes, and the first line lists the field names.', 1, NOW(), 1, NOW()); 3 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:a6999cc3-59bb-6af3-460e-d5d791afb842', 'Note Summary', 'PDF Report', 'tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1', '50', '', 'modules/base/report/notes_summary.php', 'PDF report giving basic note information (subject,dates,content) . By default, the notes are shown in chronological order.', 1, NOW(), 1, NOW());4 3 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:2944b204-5967-348a-8679-6835f45f0d79', 'SQL Export', 'export', '', '0', 'Admin', 'report/general_sql.php', 'Generate SQL INSERT statements for records.', 1, NOW(), 1, NOW()); 5 4 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:37a299d1-d795-ad83-4b47-0778c16a381c', 'Support Tables SQL Export', 'export', 'tbld:5c9d645f-26ab-5003-b98e-89e9049f8ac3', '0', '', 'modules/base/report/tabledefs_sqlexport.php', 'Insert statements for all support table records for table definition records.', 1, NOW(), 1, NOW()); -
trunk/phpbms/install/updatev0.98.sql
r663 r693 42 42 ) ENGINE=INNODB; 43 43 --end widgets CREATE-- 44 --reportsettings CREATE-- 45 CREATE TABLE `reportsettings` ( 46 `id` int(11) NOT NULL auto_increment, 47 `reportuuid` varchar(64) NOT NULL, 48 `name` varchar(64) NOT NULL default '', 49 `value` text default '', 50 `type` varchar(32) NOT NULL default 'string', 51 `required` tinyint(4) NOT NULL default '0', 52 `defaultvalue` varchar(255) NOT NULL, 53 `description` text, 54 PRIMARY KEY (`id`) 55 ) ENGINE=INNODB; 56 --end reportsettings CREATE-- 44 57 45 58 --attachments ALTER-- … … 276 289 INSERT INTO `menu` (`uuid`, `name`, `link`, `parentid`, `displayorder`, `createdby`, `modifiedby`, `creationdate`, `modifieddate`, `roleid`) VALUES ('menu:e8401ebb-c369-304f-053d-8195988e7faf', '----', 'N/A', 'menu:f07d910f-f56d-3d24-e74f-7a3b36b2d3c8', '30', 1, 1, NOW(), NOW(), ''); 277 290 --end menu INSERT-- 278 --modules UPDATE-- 279 UPDATE `modules` SET `uuid`='mod:29873ee8-c12a-e3f6-9010-4cd24174ffd7' WHERE `id`='1'; 280 --end modules UPDATE-- 281 --reports UPDATE-- 282 UPDATE `reports` SET 283 `uuid`='rpt:37cee478-b57e-2d53-d951-baf3937ba9e0' 284 WHERE 285 `name`='Raw Table Print'; 286 UPDATE `reports` SET 287 `uuid`='rpt:dac75fb9-91d2-cb1e-9213-9fab6d32f4c8', 288 `description` = 'This report will generate a comma-delimited text file. Values are encapsulated in quotes, and the first line lists the field names.' 289 WHERE 290 `name`='Raw Table Export'; 291 UPDATE `reports` SET `uuid`='rpt:a6999cc3-59bb-6af3-460e-d5d791afb842' WHERE `name`='Note Summary'; 292 UPDATE `reports` SET `uuid`='rpt:2944b204-5967-348a-8679-6835f45f0d79' WHERE `name`='SQL Export'; 293 UPDATE `reports` SET `uuid`='rpt:37a299d1-d795-ad83-4b47-0778c16a381c' WHERE `name`='Support Tables SQL Export'; 291 --reports DELETE/INSERT-- 292 DELETE FROM `reports` WHERE `name` IN ('Raw Table Print', 'Raw Table Export', 'Note Summary', 'SQL Export', 'Support Tables SQL Export'); 293 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:37cee478-b57e-2d53-d951-baf3937ba9e0', 'Raw Table Print', 'report', '', '0', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'report/general_tableprint.php', 'This report will prints out of every field for the table for the given records. The report is displayed HTML format.', 1, NOW(), 1, NOW()); 294 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:dac75fb9-91d2-cb1e-9213-9fab6d32f4c8', 'Raw Table Export', 'export', '', '0', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'report/general_export.php', 'This report will generate a comma-delimited text file. Values are encapsulated in quotes, and the first line lists the field names.', 1, NOW(), 1, NOW()); 295 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:2944b204-5967-348a-8679-6835f45f0d79', 'SQL Export', 'export', '', '0', 'Admin', 'report/general_sql.php', 'Generate SQL INSERT statements for records.', 1, NOW(), 1, NOW()); 296 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:37a299d1-d795-ad83-4b47-0778c16a381c', 'Support Tables SQL Export', 'export', 'tbld:5c9d645f-26ab-5003-b98e-89e9049f8ac3', '0', '', 'modules/base/report/tabledefs_sqlexport.php', 'Insert statements for all support table records for table definition records.', 1, NOW(), 1, NOW()); 294 297 --end reports UPDATE-- 295 298 --scheduler INSERT-- -
trunk/phpbms/modules/base/include/reports.php
r583 r693 38 38 */ 39 39 if(class_exists("phpbmsTable")) { 40 class reports extends phpbmsTable{ 41 42 var $_availableTabledefUUIDs = NULL; 43 var $_availableRoleUUIDs = NULL; 44 45 function getDefaults(){ 46 $therecord = parent::getDefaults(); 47 48 $therecord["type"]="report"; 49 $therecord["uuid"] = uuid("reports:"); 50 51 return $therecord; 52 53 } 54 55 56 function verifyVariables($variables){ 57 58 //cannot be table default ("") 59 if(isset($variables["reportfile"])){ 60 if($variables["reportfile"] === "" || $variables["reportfile"] === NULL) 61 $this->verifyErrors[] = "The `reportfile` field must not be blank."; 62 }else 63 $this->verifyErrors[] = "The `reportfile` field must be set."; 64 65 //Table default (NULL) OK 66 if(isset($variables["type"])) 67 if($variables["type"] !== "")//don't care if it's "" 68 switch($variables["type"]){ 69 case "report": 70 case "PDF Report": 71 case "export": 72 break; 73 74 default: 75 $this->verifyErrors[] = "The `type` field is not an accepted value. It must be 'report', 'PDF Report', or 'export."; 76 break; 77 78 }//end switch 79 80 //Table Default ('') ok becuase it means report is globally available to any table 81 if(isset($variables["tabledefid"])){ 82 83 if($this->_availableTabledefUUIDs === NULL){ 84 $this->_availableTabledefUUIDs = $this->_loadUUIDList("tabledefs"); 85 //add the global option 86 $this->_availableTabledefUUIDs[] = ""; 87 }//end if 88 89 if( !in_array((string)$variables["tabledefid"], $this->_availableTabledefUUIDs) ) 90 $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable table definition uuid."; 91 92 }//end if 93 94 //Table Default ('') ok becuase it means report is globally available to any user 95 if(isset($variables["roleid"])){ 96 97 if($this->_availableRoleUUIDs === NULL){ 98 $this->_availableRoleUUIDs = $this->_loadUUIDList("roles"); 99 $this->_availableRoleUUIDs[] = ""; // for no role restrictions 100 $this->_availableRoleUUIDs[] = "Admin"; //for the Admin restriction 101 }//end if 102 103 if( !in_array((string)$variables["roleid"], $this->_availableRoleUUIDs) ) 104 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable to role id number."; 105 106 }//end if 107 108 return parent::verifyVariables($variables); 109 110 }//end method 111 112 113 function displayTables($fieldname,$selectedid){ 114 115 $querystatement="SELECT uuid, displayname FROM tabledefs ORDER BY displayname"; 116 $thequery=$this->db->query($querystatement); 117 118 echo "<select id=\"".$fieldname."\" name=\"".$fieldname."\">\n"; 119 120 echo "<option value=\"\" "; 121 if ($selectedid=="") echo "selected=\"selected\""; 122 echo " style=\"font-weight:bold\">global</option>\n"; 123 124 while($therecord=$this->db->fetchArray($thequery)){ 125 echo " <option value=\"".$therecord["uuid"]."\""; 126 if($selectedid==$therecord["uuid"]) echo " selected=\"selected\""; 127 echo ">".$therecord["displayname"]."</option>\n"; 128 } 129 130 echo "</select>\n"; 131 }//end method 132 133 }//end class 40 class reports extends phpbmsTable{ 41 42 var $_availableTabledefUUIDs = NULL; 43 var $_availableRoleUUIDs = NULL; 44 45 function getDefaults(){ 46 47 $therecord = parent::getDefaults(); 48 49 $therecord["type"] = "report"; 50 51 return $therecord; 52 53 }//end function getDefaults 54 55 56 function verifyVariables($variables){ 57 58 //cannot be table default ("") 59 if(isset($variables["reportfile"])){ 60 if($variables["reportfile"] === "" || $variables["reportfile"] === NULL) 61 $this->verifyErrors[] = "The `reportfile` field must not be blank."; 62 }else 63 $this->verifyErrors[] = "The `reportfile` field must be set."; 64 65 //Table default (NULL) OK 66 if(isset($variables["type"])) 67 if($variables["type"] !== "")//don't care if it's "" 68 switch($variables["type"]){ 69 70 case "report": 71 case "PDF Report": 72 case "export": 73 break; 74 75 default: 76 $this->verifyErrors[] = "The `type` field is not an accepted value. It must be 'report', 'PDF Report', or 'export."; 77 break; 78 79 }//end switch 80 81 //Table Default ('') ok becuase it means report is globally available to any table 82 if(isset($variables["tabledefid"])){ 83 84 if($this->_availableTabledefUUIDs === NULL){ 85 86 $this->_availableTabledefUUIDs = $this->_loadUUIDList("tabledefs"); 87 88 //add the global option 89 $this->_availableTabledefUUIDs[] = ""; 90 91 }//end if 92 93 if( !in_array((string)$variables["tabledefid"], $this->_availableTabledefUUIDs) ) 94 $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable table definition uuid."; 95 96 }//end if 97 98 //Table Default ('') ok becuase it means report is globally available to any user 99 if(isset($variables["roleid"])){ 100 101 if($this->_availableRoleUUIDs === NULL){ 102 103 $this->_availableRoleUUIDs = $this->_loadUUIDList("roles"); 104 $this->_availableRoleUUIDs[] = ""; // for no role restrictions 105 $this->_availableRoleUUIDs[] = "Admin"; //for the Admin restriction 106 107 }//end if 108 109 if( !in_array((string)$variables["roleid"], $this->_availableRoleUUIDs) ) 110 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable to role id number."; 111 112 }//end if 113 114 return parent::verifyVariables($variables); 115 116 }//end method 117 118 119 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false){ 120 121 $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid); 122 123 $reportSettings = new reportSettings($this->db, $variables["uuid"]); 124 $reportSettings->createFromDefaults($variables["reportfile"]); 125 126 return $newid; 127 128 }//end method 129 130 131 function updateRecord($variables, $modifiedby = NULL, $useUuid = false){ 132 133 parent::updateRecord($variables, $modifiedby, $useUuid); 134 135 $reportSettings = new reportSettings($this->db, $variables["uuid"]); 136 $reportSettings->save($variables["rsDelList"], $variables["rsUpdates"], $variables["rsAdds"]); 137 138 }//end method updateRecord 139 140 141 function displayTables($fieldname,$selectedid){ 142 143 $querystatement="SELECT uuid, displayname FROM tabledefs ORDER BY displayname"; 144 $thequery=$this->db->query($querystatement); 145 146 echo "<select id=\"".$fieldname."\" name=\"".$fieldname."\">\n"; 147 148 echo "<option value=\"\" "; 149 if ($selectedid=="") echo "selected=\"selected\""; 150 echo " style=\"font-weight:bold\">global</option>\n"; 151 152 while($therecord=$this->db->fetchArray($thequery)){ 153 echo " <option value=\"".$therecord["uuid"]."\""; 154 if($selectedid==$therecord["uuid"]) echo " selected=\"selected\""; 155 echo ">".$therecord["displayname"]."</option>\n"; 156 } 157 158 echo "</select>\n"; 159 160 }//end method 161 162 163 /** 164 * function displayFiles 165 * 166 * Displays a list of possible report filenames. This includes 167 * all PHP files in the main report folder, as well as in the report 168 * folder of any loaded module 169 */ 170 function displayRerportFiles(){ 171 172 $files = array(); 173 174 $curDir = getcwd(); 175 176 chdir("../.."); 177 178 /** 179 * Load core reports 180 */ 181 if(file_exists("report") && is_dir("report")){ 182 183 $thedir = @ opendir("report"); 184 185 while($entry = @ readdir($thedir)) 186 if(@ strtolower(substr($entry, -4)) == ".php") 187 $files[] = "report/".$entry; 188 189 }//endif 190 191 chdir("modules"); 192 193 /** 194 * Get loaded modules 195 */ 196 $querystatement = " 197 SELECT 198 `name` 199 FROM 200 `modules`"; 201 202 $queryresult = $this->db->query($querystatement); 203 204 while($therecord = $this->db->fetchArray($queryresult)){ 205 206 chdir($therecord["name"]); 207 208 $thedir = @ opendir("report"); 209 210 while($entry = @ readdir($thedir)) 211 if(@ strtolower(substr($entry, -4)) == ".php") 212 $files[] = "modules/".$therecord["name"]."/report/".$entry; 213 214 chdir(".."); 215 216 }//endwhile 217 218 chdir($curDir); 219 220 ?><label for="reportfile">report file</label><br /> 221 <select id="reportfile" name="reportfile"> 222 <?php foreach($files as $filename){?> 223 <option value="<?php echo $filename; ?>"><?php echo $filename; ?></option> 224 <?php }//endforeach?> 225 </select><?php 226 227 }//end function displayReportFiles 228 229 }//end class 230 231 232 233 /** 234 * handles retrieval, display and saving of report settings records 235 */ 236 class reportSettings{ 237 238 /** 239 * $db 240 * @var object the database object 241 */ 242 var $db; 243 244 /** 245 * $reportUUID 246 * @var string report UUID 247 */ 248 var $reportUUID; 249 250 /** 251 * $settingsQueryResult 252 * @var int query result reference 253 */ 254 var $settingsQueryResult; 255 256 257 /** 258 * function reportSettings 259 * 260 * Class initializer 261 * 262 * @param object $db database object 263 * @param string $reportUUID associated report's UUID 264 */ 265 function reportSettings($db, $reportUUID){ 266 267 $this->db = $db; 268 $this->reportUUID = $reportUUID; 269 270 }//end function reportSettings (init) 271 272 273 /** 274 * function get 275 * 276 * retrieves query result for all report settings asociated with report 277 */ 278 function get(){ 279 280 $querystatement = " 281 SELECT 282 `id`, 283 `name`, 284 `value`, 285 `type`, 286 `required`, 287 `description` 288 FROM 289 `reportsettings` 290 WHERE 291 `reportuuid` = '".$this->reportUUID."'"; 292 293 $this->settingsQueryResult = $this->db->query($querystatement); 294 295 }//end function get 296 297 298 /** 299 * function display 300 * 301 * Display all settings records one TR for each 302 */ 303 function display(){ 304 305 if($this->db->numRows($this->settingsQueryResult) == 0){ 306 307 ?><tr class="norecords" id="noSettings"><td colspan="5">No Settings</td></tr><?php 308 309 return; 310 311 }//endif 312 313 $row = 1; 314 315 while($therecord = $this->db->fetchArray($this->settingsQueryResult)){ 316 317 ?> 318 <tr class="qr<?php echo $row; ?> rsRows" id="rsExRow<?php echo $therecord["id"] ?>"> 319 <td align="right"> 320 <strong><?php echo formatVariable($therecord["name"]) ?></strong> 321 <input class="rsNames" id="rsName<?php echo $therecord["id"]?>" type="hidden" value="<?php echo formatVariable($therecord["name"]) ?>" /> 322 </td> 323 <td> 324 <?php if($therecord["type"] != "text") {?> 325 <input class="rsValues" id="rsValue<?php echo $therecord["id"] ?>" type="text" size="32" value="<?php echo formatVariable(addcslashes($therecord["value"],"\\\n\t\r")) ?>" /> 326 <?php } else { 327 ?> 328 <textarea class="rsValues" id="rsValue<?php echo $therecord["id"] ?>" rows="2" cols="29"><?php echo formatVariable(addcslashes($therecord["value"],"\\\n\t\r")) ?></textarea> 329 <?php 330 }?> 331 </td> 332 <td><?php echo formatVariable($therecord["type"]) ?></td> 333 <td><?php echo formatVariable($therecord["description"]) ?></td> 334 <td><?php 335 if($therecord["required"] != 1){ 336 337 ?><button type="button" id="rsDelButton<?php echo $therecord["id"]?>" class="graphicButtons buttonMinus rsDelButtons" title="Remove Setting"><span>-</span></button><?php 338 339 }//endif 340 ?></td> 341 </tr> 342 <?php 343 344 $row = ($row==1) ? 2 : 1; 345 346 }//endwhile 347 348 }//end function display 349 350 351 /** 352 * function save 353 * 354 * saves report settings changes 355 * 356 * @param string $delList JSON string of ids to be deleted 357 * @param string $updateList JSON string of updates to be made 358 * @param string $addList JSON string of name/value pairs to be added 359 */ 360 function save($delList, $updateList, $addList){ 361 362 $delList = json_decode(stripslashes($delList)); 363 if(count($delList)){ 364 365 $inClause = ""; 366 367 foreach($delList as $id){ 368 369 $inClause .= ", ".$id; 370 371 }//endforeach 372 373 $deletestatement = " 374 DELETE FROM 375 `reportsettings` 376 WHERE 377 `id` IN (".substr($inClause, 1).")"; 378 379 $this->db->query($deletestatement); 380 381 }//endif 382 383 $updateList = str_replace("\n", "\\\\n", $updateList); 384 $updateList = str_replace("\r", "", $updateList); 385 $updateList = json_decode(stripslashes($updateList)); 386 387 foreach($updateList as $updateObj){ 388 389 $updatestatement = ' 390 UPDATE 391 `reportsettings` 392 SET 393 `value` = "'.mysql_real_escape_string($updateObj->value).'" 394 WHERE 395 `id` = '.((int) $updateObj->id); 396 397 $this->db->query($updatestatement); 398 399 }//endforeach 400 401 402 $addList = str_replace("\n", "\\\\n", $addList); 403 $addList = str_replace("\r", "", $addList); 404 $addList = json_decode(stripslashes($addList)); 405 406 foreach($addList as $addObj){ 407 408 $insertstatement = ' 409 INSERT INTO 410 `reportsettings` 411 ( 412 `reportuuid`, 413 `name`, 414 `value` 415 ) VALUES ( 416 "'.$this->reportUUID.'", 417 "'.mysql_real_escape_string($addObj->name).'", 418 "'.mysql_real_escape_string($addObj->value).'" 419 )'; 420 421 $this->db->query($insertstatement); 422 423 }//endforeach 424 425 }//end function save 426 427 428 /** 429 * function createFromDefaults 430 * 431 * Creates reportsettings records for report based on defaults from the class 432 * instanciated by filename 433 * 434 * @param string $filename file name of report file to retrieve class from 435 */ 436 function createFromDefaults($filename){ 437 438 $addingReportRecord = true; 439 $noOutput = true; 440 441 include_once("report/report_class.php"); 442 443 include($filename); 444 445 if(!isset($reportClass)) 446 $error = new appError(200, "Report file is missing reportClass definition", "Report File Error"); 447 else 448 $report = new $reportClass($this->db, $this->reportUUID, "tbld:d595ef42-db9d-2233-1b9b-11dfd0db9cbb"); 449 450 $settings = $report->addingRecordDefaultSettings(); 451 452 $startInsertStatement = " 453 INSERT INTO 454 `reportsettings` 455 ( 456 `reportuuid`, 457 `name`, 458 `value`, 459 `type`, 460 `required`, 461 `defaultvalue`, 462 `description` 463 ) VALUES ( 464 '".$this->reportUUID."',"; 465 466 foreach($settings as $setting){ 467 468 $insertstatement = $startInsertStatement; 469 $insertstatement .= "'".$setting["name"]."', " ; 470 $insertstatement .= "'".$setting["defaultValue"]."', " ; 471 $insertstatement .= "'".$setting["type"]."', " ; 472 $insertstatement .= ((int) $setting["required"]).", " ; 473 $insertstatement .= "'".$setting["defaultValue"]."', " ; 474 $insertstatement .= "'".$setting["description"]."')" ; 475 476 $this->db->query($insertstatement); 477 478 }//endforeach 479 480 }//end function createFromDefaults 481 482 }//end class 483 484 }//end if 485 486 if(class_exists("searchFunctions")){ 487 488 class tabledefsSearchFunctions extends searchFunctions{ 489 490 function delete_record($useUUID = false){ 491 492 if(!$useUUID){ 493 494 $whereclause = $this->buildWhereClause(); 495 //support tables link to tabledefs using uuids not ids, so we must make sure that they are uuids. 496 $this->idsArray = getUuidArray($this->db, "tbld:d595ef42-db9d-2233-1b9b-11dfd0db9cbb", $this->idsArray); 497 498 }else 499 $whereclause = $this->buildWhereClause($this->maintable.".uuid"); 500 501 $linkedwhereclause = $this->buildWhereClause("reportuuid"); 502 503 $querystatement = "DELETE FROM reportsettings WHERE ".$linkedwhereclause.";"; 504 $queryresult = $this->db->query($querystatement); 505 506 $querystatement = "DELETE FROM reports WHERE ".$whereclause.";"; 507 $queryresult = $this->db->query($querystatement); 508 509 $message = $this->buildStatusMessage(); 510 $message.=" deleted."; 511 return $message; 512 513 }//end function delete_record 514 515 }//end class 516 134 517 }//end if 135 518 ?> -
trunk/phpbms/modules/base/report/tabledefs_sqlexport.php
r612 r693 38 38 */ 39 39 40 if(!isset($_SESSION["userinfo"])){ 40 if(!class_exists("phpbmsReport")) 41 include("../../../report/report_class.php"); 41 42 42 session_cache_limiter('private'); 43 class tabledefSQLExport extends phpbmsReport{ 43 44 44 require("../../../include/session.php"); 45 function tabledefSQLExport($db, $reportUUID, $tabledefUUID){ 45 46 46 }//end if 47 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 48 49 }//end method 47 50 48 51 49 if(!class_exists("phpbmsReport")) 50 include("report/report_class.php"); 52 function generate(){ 51 53 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"); 53 59 54 var $reportOutput = ""; 55 56 function sqlExport($db){ 57 58 parent::phpbmsReport($db); 59 60 }//end method 60 }//end method 61 61 62 62 63 function generate(){63 function _addTableInfo($tablename){ 64 64 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; 70 72 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 72 133 73 134 74 function _addTableInfo($tablename){ 135 $output .= "/* ====================================================================== */\n". 136 "/* END ".$tablename." - record count: ".$this->db->numRows($queryresult)."*/\n\n"; 75 137 76 $querystatement = " 77 SELECT 78 `uuid` 79 FROM 80 `tabledefs` 81 WHERE 82 ".$this->whereclause." 83 "; 138 return $output; 84 139 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 147 141 148 142 149 $output .= "/* ====================================================================== */\n". 150 "/* END ".$tablename." - record count: ".$this->db->numRows($queryresult)."*/\n\n"; 143 function show(){ 151 144 152 return $output; 145 header("Content-type: text/plain"); 146 header('Content-Disposition: attachment; filename="tableInfoSQL.sql"'); 153 147 154 }//end method 148 echo $this->reportOutput; 149 150 }//end method 155 151 156 152 157 function show(){ 153 }//end class 158 154 159 header("Content-type: text/plain"); 160 header('Content-Disposition: attachment; filename="tableInfoSQL.sql"'); 155 /** 156 * PROCESSING 157 * ============================================================================= 158 */ 159 if(!isset($noOutput)){ 161 160 162 echo $this->reportOutput;161 session_cache_limiter('private'); 163 162 164 }//end method 163 require_once("../../../include/session.php"); 165 164 165 checkForReportArguments(); 166 166 167 }//end class 167 $report = new tabledefSQLExport($db, $_GET["rid"],$_GET["tid"]); 168 $report->setupFromPrintScreen(); 169 $report->generate(); 170 $report->show(); 168 171 169 //PROCESSING 170 //======================================================================== 172 }//end if 171 173 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 */ 178 if(isset($addingReportRecord)) 179 $reportClass ="tabledefSQLExport"; 180 180 ?> -
trunk/phpbms/modules/base/reports_addedit.php
r574 r693 46 46 $therecord = $thetable->processAddEditPage(); 47 47 48 if($therecord["id"]){ 49 50 $reportSettings = new reportSettings($db, $therecord["uuid"]); 51 $reportSettings->get(); 52 53 }//endif 54 48 55 if(isset($therecord["phpbmsStatus"])) 49 56 $statusmessage = $therecord["phpbmsStatus"]; … … 51 58 $pageTitle="Report"; 52 59 53 $phpbms->cssIncludes[] = "pages/reports.css"; 60 $phpbms->cssIncludes[] = "pages/base/reports.css"; 61 $phpbms->jsIncludes[] = "modules/base/javascript/reports.js"; 54 62 55 63 //Form Elements 56 64 //============================================================== 57 $theform = new phpbmsForm(); 65 $theform = new phpbmsForm(NULL, "post", "record", NULL); 66 $theform->id = "record"; 58 67 59 68 $theinput = new inputField("name",$therecord["name"],NULL,true,NULL,32,64); … … 70 79 $theform->addField($theinput); 71 80 72 $theinput = new inputField("reportfile",$therecord["reportfile"],"report file",true,NULL,64,128); 73 $theform->addField($theinput); 81 if($therecord["id"]){ 82 83 $theinput = new inputField("reportfile",$therecord["reportfile"],"report file",true,NULL,64,128); 84 $theinput->setAttribute("readonly","readonly"); 85 $theinput->setAttribute("class","uneditable"); 86 87 $theform->addField($theinput); 88 89 }//endif 90 91 $theinput = new inputTextarea("description", $therecord["description"], NULL, false, 3, 48); 92 $theform->addField($theinput); 74 93 75 94 $thetable->getCustomFieldInfo(); … … 82 101 83 102 ?><div class="bodyline"> 84 <?php $theform->startForm($pageTitle)?> 85 103 <?php $theform->startForm($pageTitle) ?> 86 104 <fieldset id="fsAttributes"> 87 105 <legend>Attributes</legend> 106 107 <p><?php $theform->showField("type")?></p> 88 108 89 109 <p> 90 110 <label for="tabledefid">report table</label><br /> 91 111 <?php $thetable->displayTables("tabledefid",$therecord["tabledefid"]);?><br /> 92 <span class="notes">Note: Use the global option to associate the report with every table in the system.</span>93 112 </p> 94 113 95 114 <p> 96 115 <?php $theform->showField("displayorder"); ?><br /> 97 <span class="notes">Lower numbers are displayed first. Reports with the same order are grouped together.</span>98 116 </p> 99 117 … … 108 126 <p class="big"><?php $theform->showField("name"); ?></p> 109 127 110 <p><?php $theform->showField("type")?></p>111 112 <p><?php $theform->showField("reportfile")?></p>113 128 114 129 <p> 115 <label for="description">description</label><br /> 116 <textarea id="description" name="description" cols="61" rows="5" tabindex="35"><?php echo htmlQuotes($therecord["description"])?></textarea> 117 </p> 130 <?php 131 if($therecord["id"]) 132 $theform->showField("reportfile"); 133 else 134 $thetable->displayRerportFiles(); 135 ?> 136 </p> 137 138 <p class="big"><?php $theform->showField("description"); ?></p> 139 118 140 </fieldset> 141 142 <fieldset> 143 <legend>settings</legend> 144 <?php if(!$therecord["id"]) { 145 ?><p class="notes">Report settings are available after initial record creation.</p><?php 146 } else { 147 ?> 148 149 150 <textarea class="hiddenTextAreas" id="rsUpdates" name="rsUpdates" rows="1" cols="5"></textarea> 151 <textarea class="hiddenTextAreas" id="rsDelList" name="rsDelList" rows="1" cols="5"></textarea> 152 <textarea class="hiddenTextAreas" id="rsAdds" name="rsAdds" rows="1" cols="5"></textarea> 153 <table class="querytable simple" id="settingsTable" cellspacing="0" cellpadding="0" border="0" summary="report settings"> 154 <thead> 155 <tr> 156 <th align="right">name</th> 157 <th>value</th> 158 <th>type</th> 159 <th width="100%">description</th> 160 <th> </th> 161 </tr> 162 </thead> 163 <tbody id="rsTbody"> 164 <tr id="addNewRow"> 165 <td> 166 <input type="text" id="rsAddName"/> 167 </td> 168 <td> 169 <input type="text" id="rsAddValue" size="32"/> 170 </td> 171 <td>string</td> 172 <td>user added setting</td> 173 <td> 174 <button title="Add Setting" class="graphicButtons buttonPlus" id="rsButtonAdd" type="button"><span>+</span></button> 175 </td> 176 </tr> 177 <?php 178 $reportSettings->display(); 179 ?> 180 <tr class="queryfooter" id="rsFooterTr"> 181 <td colspan="5"> </td> 182 </tr> 183 </tbody> 184 </table> 185 <?php 186 }//endif 187 ?> 188 </fieldset> 119 189 120 190 <?php $theform->showCustomFields($db, $thetable->customFieldsQueryResult) ?> … … 124 194 <?php 125 195 $theform->showGeneralInfo($phpbms,$therecord); 126 $theform->endForm();196 $theform->endForm(); 127 197 ?> 128 198 </div> -
trunk/phpbms/modules/bms/clients_purchasehistory.php
r606 r693 52 52 if(!isset($_POST["fromdate"])) $_POST["fromdate"]=dateToString(strtotime("-1 year")); 53 53 if(!isset($_POST["todate"])) $_POST["todate"]=dateToString(mktime()); 54 if(!isset($_POST["status"])) $_POST["status"]="Orders /Invoices";54 if(!isset($_POST["status"])) $_POST["status"]="Orders and Invoices"; 55 55 if(!isset($_POST["command"])) $_POST["command"]="show"; 56 56 57 57 if($_POST["command"]=="print") { 58 58 59 $_SESSION["printing"]["whereclause"]="WHEREclients.id=".$_GET["id"];60 $_SESSION["printing"]["dataprint"]="Single Record";61 $fromClient=true; 62 require("report/clients_purchasehistory.php");59 $_SESSION["printing"]["whereclause"] = "clients.id=".$_GET["id"]; 60 $_SESSION["printing"]["dataprint"] = "Single Record"; 61 62 goURL("report/clients_purchasehistory.php?rid=".urlencode("rpt:1908b03c-cacc-f03a-6d22-21fdef123f65")."&tid=".urlencode("tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083")."&status=".urlencode($_POST["status"])."&fromdate=".urlencode($_POST["fromdate"])."&todate=".urlencode($_POST["todate"])); 63 63 64 64 } else { … … 72 72 $thestatus="(invoices.type =\""; 73 73 switch($_POST["status"]){ 74 case "Orders /Invoices":74 case "Orders and Invoices": 75 75 $thestatus.="Order\" or invoices.type=\"Invoice\")"; 76 76 break; … … 110 110 thedate, 111 111 invoices.id"; 112 112 113 113 $queryresult=$db->query($querystatement); 114 114 … … 142 142 <label for="status">type</label><br /> 143 143 <select name="status" id="status"> 144 <option value="Orders /Invoices" <?php if($_POST["status"]=="Orders/Invoices") echo "selected=\"selected\""?>>Orders/Invoices</option>144 <option value="Orders abd Invoices" <?php if($_POST["status"]=="Orders and Invoices") echo "selected=\"selected\""?>>Orders and Invoices</option> 145 145 <option value="Invoices" <?php if($_POST["status"]=="Invoices") echo "selected=\"selected\""?>>Invoices</option> 146 146 <option value="Orders" <?php if($_POST["status"]=="Orders") echo "selected=\"selected\""?>>Orders</option> … … 153 153 154 154 <p id="printP"><br /><input id="print" name="command" type="submit" value="print" class="Buttons" /></p> 155 <p id="changeTimelineP"><br /><input name="command" type="submit" value=" change timeframe/view" class="smallButtons" /></p>155 <p id="changeTimelineP"><br /><input name="command" type="submit" value="update" class="smallButtons" /></p> 156 156 </div> 157 157 </form> -
trunk/phpbms/modules/bms/install/install.php
r496 r693 47 47 "relationships", 48 48 "reports", 49 "reportsettings", 49 50 "tablecolumns", 50 51 "tabledefs", -
trunk/phpbms/modules/bms/install/reports.sql
r643 r693 1 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:bac1d6eb-b2bb-9aa0-77c0-ff7f9046ca75', 'Invoice', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', '', 'modules/bms/report/invoices_pdfinvoice.php', 'This report will generate and display an invoice in PDF format (which can be printed or saved). The PDF file will contain one page per invoice.', 1, NOW(), 1, NOW()); 2 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:a34dd4b5-6942-2b14-4a58-74345dce48de', 'Work Order', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', 'role:de7e6679-8bb2-29ee-4883-2fcd756fb120', 'modules/bms/report/invoices_pdfworkorder.php', 'This report will generate and display a work order in PDF format (which can be printed or saved). The PDF file will contain one page per work order.', 1, NOW(), 1, NOW()); 3 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:34a69580-6fbc-d04c-ed3e-f0e497a9a9b2', 'Packing List', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', '', 'modules/bms/report/invoices_pdfpackinglist.php', 'This report will generate and display an invoice packing list in PDF format (which can be printed or saved). The PDF file will contain one page per invoice packing list.', 1, NOW(), 1, NOW()); 4 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:07f58303-d6e9-a032-01ad-0097d59b3c04', 'Labels - Folder', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '50', '', 'modules/bms/report/clients_folderlabels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 5 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:030e7d95-4542-b37c-3cac-a18ff5f4b8ff', 'Labels - Mailing', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '50', '', 'modules/bms/report/clients_mailinglabels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 6 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:c4a34fa0-16b5-dd85-cf63-5c8b543bb9c3', 'Labels - Shipping', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '50', '', 'modules/bms/report/clients_shippinglabels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 7 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:a502aa38-4ae8-9aa7-2795-4a05a4814637', 'Labels - Shipping', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '60', '', 'modules/bms/report/invoices_shippinglabels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 8 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:e3ef15d4-1bf5-36a1-cc05-ee44025ad619', 'Totals - Custom', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Creater your own custom invoice totaling report, specify groupings, totals, averages and whether to display summary, invoice, and invoice detail information.', 1, NOW(), 1, NOW()); 9 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:5ec9b1fb-f3c6-26c7-f1bc-bec4ac8448fd', 'Totals - Amt. w/ Invoices', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals_amtwinv.php', 'Basic totals report. Shows invoice total, subtotal and amount due fields and displaying indidivdual invoice information.', 1, NOW(), 1, NOW()); 10 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:960ec744-4955-81d1-8170-e56251603e4b', 'Totals - Amt. w/ Invoices + Line Items', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals_amtwinvlineitems.php', 'Basic totals report. Shows invoice total, subtotal and amount due fields and displaying indidivdual invoice and line item information.', 1, NOW(), 1, NOW()); 11 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:47407854-cb7f-f1e3-bc44-1b3979eae9b0', 'Totals - Grouped by Acct. Manager', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals_acctmngers.php', 'Totals report grouping by client account manager', 1, NOW(), 1, NOW()); 12 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:05de9afc-c82c-ed66-9403-184aa3f07a1c', 'Totals - Grouped by Shipping Method', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals_shippingmethod.php', 'Totals report including shipping ammount grouped by shipping method', 1, NOW(), 1, NOW()); 13 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:60c71b67-5cf1-6d1b-6d96-a4dfe9bbd651', 'Totals - Grouped by Payment Method', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals_payment.php', 'Totals report grouped by payment method.', 1, NOW(), 1, NOW()); 14 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:7a7672ef-f11c-9a6a-5640-708c50cadd29', 'Totals - Grouped by Invoice Lead Source', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals_leadsource.php', 'Totals - Grouped by invoice lead source', 1, NOW(), 1, NOW()); 15 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:49c0907c-9253-4fcb-0717-37952dd0ef4e', 'Quote', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', 'role:de7e6679-8bb2-29ee-4883-2fcd756fb120', 'modules/bms/report/invoices_pdfquote.php', 'PDF report for quote. Does not include amount due.', 1, NOW(), 1, NOW()); 16 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:a278af28-9c34-da2e-d81b-4caa36dfa29f', 'Sales History', 'report', 'tbld:7a9e87ed-d165-c4a4-d9b9-0a4adc3c5a34', '100', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/products_saleshistory.php', 'Sales History for product including costs, average price and quantities.', 1, NOW(), 1, NOW()); 17 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:1908b03c-cacc-f03a-6d22-21fdef123f65', 'Purchase History', 'report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '10', '', 'modules/bms/report/clients_purchasehistory.php', 'Client purchase history', 1, NOW(), 1, NOW()); 18 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:858702da-1b85-3a62-c20f-6b1593140a64', 'Totals - Custom', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals.php', 'Create your own custom line item totaling report, specify groupings, totals, averages and whether to display summary, invoice, and invoice detail information.', 1, NOW(), 1, NOW()); 19 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:28cf69cb-60de-bbed-df15-ea98842b6924', 'Totals - Product Categories', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals_productcategories.php', 'Totals report grouped first by product category and then by product.', 1, NOW(), 1, NOW()); 20 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:274d3dfa-ec52-74d2-630f-0c432a6e1ea5', 'Totals - Product', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals_products.php', 'Totals report grouped by product displaying line items', 1, NOW(), 1, NOW()); 21 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:68b6258a-6902-f705-19f5-d2707bd78b35', 'Totals - Lead Source', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals_leadsource.php', 'Totals grouped by invoice lead source and product', 1, NOW(), 1, NOW()); 22 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:b552c34f-64b9-5a89-15b3-c5d717644b81', 'Client Notes Summary', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '10', '', 'modules/bms/report/clients_notesummary.php', 'Print all notes associated with the client and any notes associated with client invoices.', 1, NOW(), 1, NOW()); 23 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:aca42dbe-68c9-e966-c174-ed938e9b880a', 'Totals - Tax', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals_tax.php', 'Tax Totals', 1, NOW(), 1, NOW()); 24 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:e54cee32-b3c9-82cc-50c8-14848ece8e90', 'Receipt', 'PDF Report', 'tbld:43678406-be25-909b-c715-7e2afc7db601', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/receipts_pdf.php', 'PDF print out of receipt for processing or client records', 1, NOW(), 1, NOW()); 25 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:0df82ecf-5f05-56bd-18c3-e7cb27c0cf8a', 'Client Statements', 'PDF Report', 'tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/aritems_clientstatement.php', 'Client AR statement balances and activity.', 1, NOW(), 1, NOW()); 26 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:e25bdb7a-93be-b1d6-a292-cdec89c0c9fc', 'Summary', 'report', 'tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/aritems_summary.php', 'Items grouped and totaled by clients, with grand totals.', 1, NOW(), 1, NOW()); 27 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:916f34d8-0997-162c-4350-d93c3d283241', 'Payment Type Totals', 'report', 'tbld:43678406-be25-909b-c715-7e2afc7db601', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/receipts_pttotals.php', 'Totals grouped by payment method.', 1, NOW(), 1, NOW()); 28 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:4851c350-4343-4dc3-4b7b-74c287de011b', 'Incoming Cash Flow', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '55', 'role:8f5fb368-e7d9-5010-d8f6-b4a78adc0520', 'modules/bms/report/incoming_cashflow.php', 'This report shows total incoming monies for a time period from both posted sales orders AND posted receipts. It can be grouped by week, month, quarter and year.\r\n\r\nThis report runs is unaffected by selected records, search or sort parameters. It requires input of its own start and end dates.', 1, NOW(), 1, NOW()); 1 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('207', 'rpt:e3ef15d4-1bf5-36a1-cc05-ee44025ad619', 'Totals - Custom', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Creater your own custom invoice totaling report, specify groupings, totals, averages and whether to display summary, invoice, and invoice detail information.', 1, NOW(), 1, NOW()); 2 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('215', 'rpt:a278af28-9c34-da2e-d81b-4caa36dfa29f', 'Sales History', 'report', 'tbld:7a9e87ed-d165-c4a4-d9b9-0a4adc3c5a34', '100', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/products_saleshistory.php', 'Sales History for product including costs, average price and quantities.', 1, NOW(), 1, NOW()); 3 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('216', 'rpt:1908b03c-cacc-f03a-6d22-21fdef123f65', 'Purchase History', 'report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '10', '', 'modules/bms/report/clients_purchasehistory.php', 'Client purchase history', 1, NOW(), 1, NOW()); 4 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('217', 'rpt:858702da-1b85-3a62-c20f-6b1593140a64', 'Totals - Custom', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals.php', 'Creat your own custom line item totaling report, specify groupings, totals, averages and whether to display summary, invoice, and invoice detail information.', 1, NOW(), 1, NOW()); 5 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('224', 'rpt:0df82ecf-5f05-56bd-18c3-e7cb27c0cf8a', 'Client Statements', 'PDF Report', 'tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/aritems_clientstatement.php', 'Client AR statement balances and activity.', 1, NOW(), 1, NOW()); 6 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('225', 'rpt:e25bdb7a-93be-b1d6-a292-cdec89c0c9fc', 'Summary', 'report', 'tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/aritems_summary.php', 'Items grouped and totaled by clients, with grand totals.', 1, NOW(), 1, NOW()); 7 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('226', 'rpt:916f34d8-0997-162c-4350-d93c3d283241', 'Payment Type Totals', 'report', 'tbld:43678406-be25-909b-c715-7e2afc7db601', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/receipts_pttotals.php', 'Totals grouped by payment method.', 1, NOW(), 1, NOW()); 8 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('227', 'rpt:4851c350-4343-4dc3-4b7b-74c287de011b', 'Incoming Cash Flow', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '55', 'role:8f5fb368-e7d9-5010-d8f6-b4a78adc0520', 'modules/bms/report/incoming_cashflow.php', 'This report shows total incoming monies for a time period from both posted sales orders AND posted receipts. It can be grouped by week, month, quarter and year.\r\n\r\nThis report runs is unaffected by selected records, search or sort parameters. It requires input of its own start and end dates.', 1, NOW(), 1, NOW()); 9 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('233', 'reports:e3057c38-0f68-5d1d-a1b7-793183d951d2', 'Labels - Folder', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '50', NULL, 'report/general_labels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 10 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('234', 'rpt:1019eae2-50d4-e097-c73c-3748c2bd7840', 'Labels - Mailing', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '50', NULL, 'report/general_labels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 11 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('235', 'rpt:805fe2c4-a0d2-185a-5609-a444da07d61a', 'Labels - Shipping', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '50', NULL, 'report/general_labels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 12 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('236', 'rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f', 'Labels - Shipping', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '60', 'role:de7e6679-8bb2-29ee-4883-2fcd756fb120', 'report/general_labels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 13 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('240', 'rpt:435d3c34-0ca3-5d40-3488-e5593869c20c', 'Totals - Lead Source', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals.php', 'Totals grouped by invoice lead source and product', 1, NOW(), 1, NOW()); 14 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('241', 'rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39', 'Totals - Products', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals.php', 'Totals report grouped by product displaying line items', 1, NOW(), 1, NOW()); 15 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('242', 'rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c', 'Totals - Product Categories', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals.php', 'Totals report grouped first by product category and then by product.', 1, NOW(), 1, NOW()); 16 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('243', 'rpt:b934c506-ee84-f260-283b-9cb07050b197', 'Receipt', 'PDF Report', 'tbld:43678406-be25-909b-c715-7e2afc7db601', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/receipts_pdf.php', 'PDF print out of receipt for processing or client records', 1, NOW(), 1, NOW()); 17 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('244', 'rpt:5ff03ba4-a310-524e-f3a3-05b6cadf820a', 'Totals - Account Manager', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Totals report grouping by client account manager', 1, NOW(), 1, NOW()); 18 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('246', 'rpt:3e25c485-857d-1698-6c9b-03e3e8f4177b', 'Totals - Amount with Invoices', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Basic totals report. Shows invoice total, subtotal and amount due fields and displaying individual invoice information.', 1, NOW(), 1, NOW()); 19 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('247', 'rpt:8a9cf2d6-d5f0-54ca-1b89-8207dfa4c348', 'Totals - Amounts with Invoices and Line Items', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Basic totals report. Shows invoice total, subtotal and amount due fields and displaying individual invoice and line item information.', 1, NOW(), 1, NOW()); 20 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('248', 'rpt:3cb9ae81-0838-863e-0185-1f46224cbe00', 'Totals - Sales Order Lead Source', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Totals - Grouped by invoice lead source', 1, NOW(), 1, NOW()); 21 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('249', 'rpt:67dca680-14ba-d4e7-4926-b90c65495f48', 'Totals - Pament Methods', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Totals report grouped by payment method.', 1, NOW(), 1, NOW()); 22 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('250', 'rpt:5dc66c67-1e98-7f85-6e89-5ab5d7795140', 'Totals - Shipping Methods', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Totals report including shipping amount grouped by shipping method', 1, NOW(), 1, NOW()); 23 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('251', 'rpt:d97334ef-0139-f178-fe36-c38e151cc60e', 'Totals - Tax', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Sales order tax totals', 1, NOW(), 1, NOW()); 24 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('256', 'rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b', 'Invoice', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', NULL, 'modules/bms/report/invoices_pdfinvoice.php', 'Printable/E-Mail Ready Invoice PDF', 1, NOW(), 1, NOW()); 25 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('257', 'rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73', 'Packing List', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', NULL, 'modules/bms/report/invoices_pdfpackinglist.php', 'Packing (pick) List PDF', 1, NOW(), 1, NOW()); 26 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('258', 'rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca', 'Quote', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', NULL, 'modules/bms/report/invoices_pdfquote.php', 'Quote PDF. Does not include amount due.', 1, NOW(), 1, NOW()); 27 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('259', 'rpt:30a56a65-8673-b3c0-cd50-6546968b4d37', 'Work Order', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', 'role:de7e6679-8bb2-29ee-4883-2fcd756fb120', 'modules/bms/report/invoices_pdfworkorder.php', 'Work Order PDF', 1, NOW(), 1, NOW()); -
trunk/phpbms/modules/bms/install/updatev0.98.sql
r682 r693 336 336 INSERT INTO `relationships` (`uuid`, `tofield`, `name`, `fromfield`, `fromtableid`, `totableid`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`, `inherint`) VALUES ('rln:c003c109-b79b-eded-9acd-b251af8d92ec', 'postingsessionid', 'receipts', 'id', 'tbld:97760a4f-1c1a-a108-d05f-5fc4ec59583c', 'tbld:43678406-be25-909b-c715-7e2afc7db601', 1, NOW(), 1, NOW(), '0'); 337 337 --end relationships INSERT-- 338 --reports INSERT-- 339 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:0df82ecf-5f05-56bd-18c3-e7cb27c0cf8a', 'Client Statements', 'PDF Report', 'tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/aritems_clientstatement.php', 'Client AR statement balances and activity.', 1, NOW(), 1, NOW()); 340 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:e25bdb7a-93be-b1d6-a292-cdec89c0c9fc', 'Summary', 'report', 'tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/aritems_summary.php', 'Items grouped and totaled by clients, with grand totals.', 1, NOW(), 1, NOW()); 341 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:916f34d8-0997-162c-4350-d93c3d283241', 'Payment Type Totals', 'report', 'tbld:43678406-be25-909b-c715-7e2afc7db601', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/receipts_pttotals.php', 'Totals grouped by payment method.', 1, NOW(), 1, NOW()); 342 INSERT INTO `reports` (`uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('rpt:4851c350-4343-4dc3-4b7b-74c287de011b', 'Incoming Cash Flow', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '55', 'role:8f5fb368-e7d9-5010-d8f6-b4a78adc0520', 'modules/bms/report/incoming_cashflow.php', 'This report shows total incoming monies for a time period from both posted sales orders AND posted receipts. It can be grouped by week, month, quarter and year.\r\n\r\nThis report runs is unaffected by selected records, search or sort parameters. It requires input of its own start and end dates.', 1, NOW(), 1, NOW()); 343 --end reports INSERT-- 344 --reports UPDATE-- 345 UPDATE `reports` SET `uuid`='rpt:bac1d6eb-b2bb-9aa0-77c0-ff7f9046ca75' WHERE `name`='Invoice'; 346 UPDATE `reports` SET `uuid`='rpt:a34dd4b5-6942-2b14-4a58-74345dce48de' WHERE `name`='Work Order'; 347 UPDATE `reports` SET `uuid`='rpt:34a69580-6fbc-d04c-ed3e-f0e497a9a9b2' WHERE `name`='Packing List'; 348 UPDATE `reports` SET `uuid`='rpt:07f58303-d6e9-a032-01ad-0097d59b3c04' WHERE `name`='Labels - Folder'; 349 UPDATE `reports` SET `uuid`='rpt:030e7d95-4542-b37c-3cac-a18ff5f4b8ff' WHERE `name`='Labels - Mailing'; 350 UPDATE `reports` SET `uuid`='rpt:c4a34fa0-16b5-dd85-cf63-5c8b543bb9c3' WHERE `name`='Labels - Shipping' AND `tabledefid`='2'; 351 UPDATE `reports` SET `uuid`='rpt:a502aa38-4ae8-9aa7-2795-4a05a4814637' WHERE `name`='Labels - Shipping' AND `tabledefid`='3'; 352 UPDATE `reports` SET `uuid`='rpt:e3ef15d4-1bf5-36a1-cc05-ee44025ad619' WHERE `name`='Totals - Custom' AND `tabledefid`='3'; 353 UPDATE `reports` SET `uuid`='rpt:5ec9b1fb-f3c6-26c7-f1bc-bec4ac8448fd' WHERE `name`='Totals - Amt. w/ Invoices'; 354 UPDATE `reports` SET `uuid`='rpt:960ec744-4955-81d1-8170-e56251603e4b' WHERE `name`='Totals - Amt. w/ Invoices + Line Items'; 355 UPDATE `reports` SET `uuid`='rpt:47407854-cb7f-f1e3-bc44-1b3979eae9b0' WHERE `name`='Totals - Grouped by Acct. Manager'; 356 UPDATE `reports` SET `uuid`='rpt:05de9afc-c82c-ed66-9403-184aa3f07a1c' WHERE `name`='Totals - Grouped by Shipping Method'; 357 UPDATE `reports` SET `uuid`='rpt:60c71b67-5cf1-6d1b-6d96-a4dfe9bbd651' WHERE `name`='Totals - Grouped by Payment Method'; 358 UPDATE `reports` SET `uuid`='rpt:7a7672ef-f11c-9a6a-5640-708c50cadd29' WHERE `name`='Totals - Grouped by Invoice Lead Source'; 359 UPDATE `reports` SET `uuid`='rpt:49c0907c-9253-4fcb-0717-37952dd0ef4e' WHERE `name`='Quote'; 360 UPDATE `reports` SET `uuid`='rpt:a278af28-9c34-da2e-d81b-4caa36dfa29f' WHERE `name`='Sales History'; 361 UPDATE `reports` SET `uuid`='rpt:1908b03c-cacc-f03a-6d22-21fdef123f65' WHERE `name`='Purchase History'; 362 UPDATE `reports` SET `uuid`='rpt:858702da-1b85-3a62-c20f-6b1593140a64' WHERE `name`='Totals - Custom' AND `tabledefid`='5'; 363 UPDATE `reports` SET `uuid`='rpt:28cf69cb-60de-bbed-df15-ea98842b6924' WHERE `name`='Totals - Product Categories'; 364 UPDATE `reports` SET `uuid`='rpt:274d3dfa-ec52-74d2-630f-0c432a6e1ea5' WHERE `name`='Totals - Product'; 365 UPDATE `reports` SET `uuid`='rpt:68b6258a-6902-f705-19f5-d2707bd78b35' WHERE `name`='Totals - Lead Source'; 366 UPDATE `reports` SET `uuid`='rpt:b552c34f-64b9-5a89-15b3-c5d717644b81' WHERE `name`='Client Notes Summary'; 367 UPDATE `reports` SET `uuid`='rpt:aca42dbe-68c9-e966-c174-ed938e9b880a' WHERE `name`='Totals - Tax'; 368 UPDATE `reports` SET `uuid`='rpt:e54cee32-b3c9-82cc-50c8-14848ece8e90' WHERE `name`='Receipt'; 369 --end reports UPDATE-- 338 --reports DELETE/INSERT-- 339 DELETE FROM `reports` WHERE `name` IN ('Receipt', 'Totals - Tax', 'report', 'Client Notes Summary', 'Totals - Lead Source', 'Totals - Product', 'Totals - Product Categories', 'Totals - Custom', 'Purchase History', 'Sales History', 'Quote', 'Totals - Grouped by Invoice Lead Source', 'Totals - Grouped by Payment Method', 'Totals - Grouped by Shipping Method', 'Totals - Grouped by Acct. Manager', 'Totals - Amt. w/ Invoices + Line Items', 'Totals - Amt. w/ Invoices', 'Labels - Shipping', 'Labels - Mailing', 'Labels - Folder', 'Packing List', 'Work Order', 'Invoice') 340 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('207', 'rpt:e3ef15d4-1bf5-36a1-cc05-ee44025ad619', 'Totals - Custom', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Creater your own custom invoice totaling report, specify groupings, totals, averages and whether to display summary, invoice, and invoice detail information.', 1, NOW(), 1, NOW()); 341 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('215', 'rpt:a278af28-9c34-da2e-d81b-4caa36dfa29f', 'Sales History', 'report', 'tbld:7a9e87ed-d165-c4a4-d9b9-0a4adc3c5a34', '100', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/products_saleshistory.php', 'Sales History for product including costs, average price and quantities.', 1, NOW(), 1, NOW()); 342 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('216', 'rpt:1908b03c-cacc-f03a-6d22-21fdef123f65', 'Purchase History', 'report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '10', '', 'modules/bms/report/clients_purchasehistory.php', 'Client purchase history', 1, NOW(), 1, NOW()); 343 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('217', 'rpt:858702da-1b85-3a62-c20f-6b1593140a64', 'Totals - Custom', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals.php', 'Creat your own custom line item totaling report, specify groupings, totals, averages and whether to display summary, invoice, and invoice detail information.', 1, NOW(), 1, NOW()); 344 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('224', 'rpt:0df82ecf-5f05-56bd-18c3-e7cb27c0cf8a', 'Client Statements', 'PDF Report', 'tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/aritems_clientstatement.php', 'Client AR statement balances and activity.', 1, NOW(), 1, NOW()); 345 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('225', 'rpt:e25bdb7a-93be-b1d6-a292-cdec89c0c9fc', 'Summary', 'report', 'tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/aritems_summary.php', 'Items grouped and totaled by clients, with grand totals.', 1, NOW(), 1, NOW()); 346 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('226', 'rpt:916f34d8-0997-162c-4350-d93c3d283241', 'Payment Type Totals', 'report', 'tbld:43678406-be25-909b-c715-7e2afc7db601', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/receipts_pttotals.php', 'Totals grouped by payment method.', 1, NOW(), 1, NOW()); 347 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('227', 'rpt:4851c350-4343-4dc3-4b7b-74c287de011b', 'Incoming Cash Flow', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '55', 'role:8f5fb368-e7d9-5010-d8f6-b4a78adc0520', 'modules/bms/report/incoming_cashflow.php', 'This report shows total incoming monies for a time period from both posted sales orders AND posted receipts. It can be grouped by week, month, quarter and year.\r\n\r\nThis report runs is unaffected by selected records, search or sort parameters. It requires input of its own start and end dates.', 1, NOW(), 1, NOW()); 348 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('233', 'reports:e3057c38-0f68-5d1d-a1b7-793183d951d2', 'Labels - Folder', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '50', NULL, 'report/general_labels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 349 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('234', 'rpt:1019eae2-50d4-e097-c73c-3748c2bd7840', 'Labels - Mailing', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '50', NULL, 'report/general_labels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 350 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('235', 'rpt:805fe2c4-a0d2-185a-5609-a444da07d61a', 'Labels - Shipping', 'PDF Report', 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', '50', NULL, 'report/general_labels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 351 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('236', 'rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f', 'Labels - Shipping', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '60', 'role:de7e6679-8bb2-29ee-4883-2fcd756fb120', 'report/general_labels.php', 'Avery 5160 or compatible (3x10) Instructor Folder labels. \r\n\r\n **MAKE SURE when printing the pdf file, to TURN OFF the option \"shrink oversized pages to paper size\".**', 1, NOW(), 1, NOW()); 352 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('240', 'rpt:435d3c34-0ca3-5d40-3488-e5593869c20c', 'Totals - Lead Source', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals.php', 'Totals grouped by invoice lead source and product', 1, NOW(), 1, NOW()); 353 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('241', 'rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39', 'Totals - Products', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals.php', 'Totals report grouped by product displaying line items', 1, NOW(), 1, NOW()); 354 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('242', 'rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c', 'Totals - Product Categories', 'report', 'tbld:31423480-a9b0-f0ff-749e-b3b5e18ca93c', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/lineitems_totals.php', 'Totals report grouped first by product category and then by product.', 1, NOW(), 1, NOW()); 355 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('243', 'rpt:b934c506-ee84-f260-283b-9cb07050b197', 'Receipt', 'PDF Report', 'tbld:43678406-be25-909b-c715-7e2afc7db601', '10', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2', 'modules/bms/report/receipts_pdf.php', 'PDF print out of receipt for processing or client records', 1, NOW(), 1, NOW()); 356 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('244', 'rpt:5ff03ba4-a310-524e-f3a3-05b6cadf820a', 'Totals - Account Manager', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Totals report grouping by client account manager', 1, NOW(), 1, NOW()); 357 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('246', 'rpt:3e25c485-857d-1698-6c9b-03e3e8f4177b', 'Totals - Amount with Invoices', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Basic totals report. Shows invoice total, subtotal and amount due fields and displaying individual invoice information.', 1, NOW(), 1, NOW()); 358 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('247', 'rpt:8a9cf2d6-d5f0-54ca-1b89-8207dfa4c348', 'Totals - Amounts with Invoices and Line Items', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Basic totals report. Shows invoice total, subtotal and amount due fields and displaying individual invoice and line item information.', 1, NOW(), 1, NOW()); 359 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('248', 'rpt:3cb9ae81-0838-863e-0185-1f46224cbe00', 'Totals - Sales Order Lead Source', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Totals - Grouped by invoice lead source', 1, NOW(), 1, NOW()); 360 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('249', 'rpt:67dca680-14ba-d4e7-4926-b90c65495f48', 'Totals - Pament Methods', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Totals report grouped by payment method.', 1, NOW(), 1, NOW()); 361 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('250', 'rpt:5dc66c67-1e98-7f85-6e89-5ab5d7795140', 'Totals - Shipping Methods', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Totals report including shipping amount grouped by shipping method', 1, NOW(), 1, NOW()); 362 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('251', 'rpt:d97334ef-0139-f178-fe36-c38e151cc60e', 'Totals - Tax', 'report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '50', 'role:259ead9f-100b-55b5-508a-27e33a6216bf', 'modules/bms/report/invoices_totals.php', 'Sales order tax totals', 1, NOW(), 1, NOW()); 363 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('256', 'rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b', 'Invoice', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', NULL, 'modules/bms/report/invoices_pdfinvoice.php', 'Printable/E-Mail Ready Invoice PDF', 1, NOW(), 1, NOW()); 364 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('257', 'rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73', 'Packing List', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', NULL, 'modules/bms/report/invoices_pdfpackinglist.php', 'Packing (pick) List PDF', 1, NOW(), 1, NOW()); 365 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('258', 'rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca', 'Quote', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', NULL, 'modules/bms/report/invoices_pdfquote.php', 'Quote PDF. Does not include amount due.', 1, NOW(), 1, NOW()); 366 INSERT INTO `reports` (`id`, `uuid`, `name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('259', 'rpt:30a56a65-8673-b3c0-cd50-6546968b4d37', 'Work Order', 'PDF Report', 'tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', '100', 'role:de7e6679-8bb2-29ee-4883-2fcd756fb120', 'modules/bms/report/invoices_pdfworkorder.php', 'Work Order PDF', 1, NOW(), 1, NOW()); 367 --end reports DELETE/INSERT-- 368 --reportsettings INSERT-- 369 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','maxRows','10','int',1,'10','Number of label rows per page'); 370 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','maxColumns','3','int',1,'3','Number of label columns per page'); 371 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','startTop','0.5','real',1,'0.5','Top Margin of page'); 372 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','startLeft','0.1875','real',1,'0.1875','Left Margin of page'); 373 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','columnMargin','0.125','real',1,'0.125','Distance between columns'); 374 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','labelHeight','1','real',1,'1','Height of a single label'); 375 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','labelHeight','2.625','real',1,'2.625','Width of a single label'); 376 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','labelMarginLeft','0.0625','real',1,'0.0625','Distance from left between the start of an individual to the text being put on it'); 377 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','labelMarginTop','0.125','real',1,'0.125','Distance from top between start of an individual to the text being put on it'); 378 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','queryStatement','SELECT if(clients.lastname != \'\' || clients.lastname is not null, concat(clients.lastname, \', \', clients.firstname), \'\') as rowText1, clients.company as rowText2, concat(addresses.city, \', \', addresses.state) as rowText3 FROM ((clients INNER JOIN addresstorecord on clients.uuid = addresstorecord.recordid AND addresstorecord.tabledefid=\'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083\' AND addresstorecord.primary=1) INNER JOIN addresses ON addresstorecord.addressid = addresses.uuid)','text',1,'SELECT \"no data in first row\" AS `rowText1`, \"no data in second row\" AS `rowText2` FROM `reports`','SQL SELECT and FROM clauses defining the data to be retrieved. Each line printed should be selected as a column in the format `rowText(X)`, where (X) is the line number it will be printed on'); 379 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','rowText1Font','Arial,B,9','string',0,'Arial,B,9','Comma separated list of FPF parameters defining font settings for the label text. You can change the font on subsequent lines by adding an additional setting rowText(x)Font where (x) is the line number the font change occurs.'); 380 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:e3057c38-0f68-5d1d-a1b7-793183d951d2','rowText3Font','Arial,,8','string',0,'',NULL); 381 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','maxRows','10','int',1,'10','Number of label rows per page'); 382 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','maxColumns','3','int',1,'3','Number of label columns per page'); 383 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','startTop','0.5','real',1,'0.5','Top Margin of page'); 384 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','startLeft','0.1875','real',1,'0.1875','Left Margin of page'); 385 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','columnMargin','0.125','real',1,'0.125','Distance between columns'); 386 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','labelHeight','1','real',1,'1','Height of a single label'); 387 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','labelHeight','2.625','real',1,'2.625','Width of a single label'); 388 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','labelMarginLeft','0.0625','real',1,'0.0625','Distance from left between the start of an individual to the text being put on it'); 389 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','labelMarginTop','0.125','real',1,'0.125','Distance from top between start of an individual to the text being put on it'); 390 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','queryStatement','SELECT clients.company AS rowText1, trim(concat(clients.firstname, \' \', clients.lastname)) AS rowText2, addresses.address1 AS rowText3, addresses.address2 AS rowText4, concat(addresses.city, \', \', addresses.state, \' \', addresses.postalcode) AS rowText5, addresses.country AS rowText6 FROM ((clients INNER JOIN addresstorecord on clients.uuid = addresstorecord.recordid AND addresstorecord.tabledefid=\'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083\' AND addresstorecord.primary=1) INNER JOIN addresses ON addresstorecord.addressid = addresses.uuid)','text',1,'SELECT \"no data in first row\" AS `rowText1`, \"no data in second row\" AS `rowText2` FROM `reports`','SQL SELECT and FROM clauses defining the data to be retrieved. Each line printed should be selected as a column in the format `rowText(X)`, where (X) is the line number it will be printed on'); 391 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','rowText1Font','Arial,B,9','string',0,'Arial,B,9','Comma separated list of FPDF font parameters defining font settings for the label text. You can change the font on subsequent lines by adding an additional setting rowText(x)Font where (x) is the line number the font change occurs.'); 392 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:1019eae2-50d4-e097-c73c-3748c2bd7840','rowText3Font','Arial,,8','string',0,'',NULL); 393 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','maxRows','10','int',1,'10','Number of label rows per page'); 394 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','maxColumns','3','int',1,'3','Number of label columns per page'); 395 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','startTop','0.5','real',1,'0.5','Top Margin of page'); 396 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','startLeft','0.1875','real',1,'0.1875','Left Margin of page'); 397 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','columnMargin','0.125','real',1,'0.125','Distance between columns'); 398 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','labelHeight','1','real',1,'1','Height of a single label'); 399 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','labelHeight','2.625','real',1,'2.625','Width of a single label'); 400 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','labelMarginLeft','0.0625','real',1,'0.0625','Distance from left between the start of an individual to the text being put on it'); 401 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','labelMarginTop','0.125','real',1,'0.125','Distance from top between start of an individual to the text being put on it'); 402 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','queryStatement','SELECT clients.company AS rowText1, if(shiptoname != \'\' && shiptoname is not null, trim(shiptoname), trim(concat(clients.firstname, \' \', clients.lastname))) AS rowText2, addresses.address1 AS rowText3, addresses.address2 AS rowText4, concat(addresses.city, \', \', addresses.state, \' \', addresses.postalcode) AS rowText5, addresses.country AS rowText6 FROM ((clients INNER JOIN addresstorecord on clients.uuid = addresstorecord.recordid AND addresstorecord.tabledefid=\'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083\' AND addresstorecord.defaultshipto=1) INNER JOIN addresses ON addresstorecord.addressid = addresses.uuid)','text',1,'SELECT \"no data in first row\" AS `rowText1`, \"no data in second row\" AS `rowText2` FROM `reports`','SQL SELECT and FROM clauses defining the data to be retrieved. Each line printed should be selected as a column in the format `rowText(X)`, where (X) is the line number it will be printed on'); 403 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','rowText1Font','Arial,B,9','string',0,'Arial,B,9','Comma separated list of FPDF font parameters defining font settings for the label text. You can change the font on subsequent lines by adding an additional setting rowText(x)Font where (x) is the line number the font change occurs.'); 404 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:805fe2c4-a0d2-185a-5609-a444da07d61a','rowText3Font','Arial,,8','string',0,'',NULL); 405 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','maxRows','10','int',1,'10','Number of label rows per page'); 406 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','maxColumns','3','int',1,'3','Number of label columns per page'); 407 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','startTop','0.5','real',1,'0.5','Top Margin of page'); 408 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','startLeft','0.1875','real',1,'0.1875','Left Margin of page'); 409 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','columnMargin','0.125','real',1,'0.125','Distance between columns'); 410 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','labelHeight','1','real',1,'1','Height of a single label'); 411 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','labelHeight','2.625','real',1,'2.625','Width of a single label'); 412 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','labelMarginLeft','0.0625','real',1,'0.0625','Distance from left between the start of an individual to the text being put on it'); 413 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','labelMarginTop','0.125','real',1,'0.125','Distance from top between start of an individual to the text being put on it'); 414 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','queryStatement','SELECT clients.company AS rowText1, if(shiptosameasbilling = 0 && shiptoname != \'\' && shiptoname IS NOT NULL, shiptoname, trim(concat(clients.firstname, \' \', clients.lastname))) AS rowText2, if(shiptosameasbilling = 0, shiptoaddress1, invoices.address1) AS rowText3, if(shiptosameasbilling = 0, shiptoaddress2, invoices.address2) AS rowText4, if(shiptosameasbilling = 0, concat(shiptocity, \', \',shiptostate,\' \',shiptopostalcode), concat(invoices.city,\', \',invoices.state,\' \',invoices.postalcode)) AS rowText5, if(shiptosameasbilling = 0, shiptocountry, invoices.country) AS rowText6 FROM invoices INNER JOIN clients ON invoices.clientid=clients.uuid','text',1,'SELECT \"no data in first row\" AS `rowText1`, \"no data in second row\" AS `rowText2` FROM `reports`','SQL SELECT and FROM clauses defining the data to be retrieved. Each line printed should be selected as a column in the format `rowText(X)`, where (X) is the line number it will be printed on'); 415 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','rowText1Font','Arial,B,9','string',0,'Arial,B,9','Comma separated list of FPDF font parameters defining font settings for the label text. You can change the font on subsequent lines by adding an additional setting rowText(x)Font where (x) is the line number the font change occurs.'); 416 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:7d461e1a-1bf3-b484-6b58-bf99126ad95f','rowText3Font','Arial,,8','string',0,'',NULL); 417 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:435d3c34-0ca3-5d40-3488-e5593869c20c','reportTitle','Totals Grouped by Invoice Lead Source and Product','string',0,'Report','Report Title'); 418 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:435d3c34-0ca3-5d40-3488-e5593869c20c','column1','1','string',0,'',NULL); 419 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:435d3c34-0ca3-5d40-3488-e5593869c20c','column2','4','string',0,'',NULL); 420 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:435d3c34-0ca3-5d40-3488-e5593869c20c','column4','8','string',0,'',NULL); 421 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:435d3c34-0ca3-5d40-3488-e5593869c20c','column5','5','string',0,'',NULL); 422 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:435d3c34-0ca3-5d40-3488-e5593869c20c','group1','14','string',0,'',NULL); 423 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:435d3c34-0ca3-5d40-3488-e5593869c20c','group2','1','string',0,'',NULL); 424 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:435d3c34-0ca3-5d40-3488-e5593869c20c','showWhat','totals','string',0,'',NULL); 425 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:435d3c34-0ca3-5d40-3488-e5593869c20c','column3','9','string',0,'',NULL); 426 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39','reportTitle','Totals Grouped by Product','string',0,'Report','Report Title'); 427 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39','column1','1','string',0,'',NULL); 428 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39','column2','4','string',0,'',NULL); 429 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39','column3','9','string',0,'',NULL); 430 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39','column4','8','string',0,'',NULL); 431 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39','column5','5','string',0,'',NULL); 432 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39','group1','1','string',0,'',NULL); 433 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:157ec22d-14c2-64cc-486a-fedc9cfe7d39','showWhat','lineitems','string',0,'',NULL); 434 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c','reportTitle','Totals Grouped by Product Categories and Product','string',0,'Report','Report Title'); 435 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c','column1','1','string',0,'',NULL); 436 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c','column2','4','string',0,'',NULL); 437 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c','column3','9','string',0,'',NULL); 438 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c','column4','8','string',0,'',NULL); 439 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c','column5','5','string',0,'',NULL); 440 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c','group1','2','string',0,'',NULL); 441 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c','group2','1','string',0,'',NULL); 442 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b2402d8d-10e3-30b2-2c92-e6da9bd0093c','showWhat','totals','string',0,'',NULL); 443 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b934c506-ee84-f260-283b-9cb07050b197','reportTitle','Receipt','string',1,'Receipts','Title printed in upper right hand of report.'); 444 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5ff03ba4-a310-524e-f3a3-05b6cadf820a','reportTitle','Totals Grouped by Client Account Manager','string',0,'Report','Report Title'); 445 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5ff03ba4-a310-524e-f3a3-05b6cadf820a','showWhat','invoices','string',0,'',NULL); 446 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5ff03ba4-a310-524e-f3a3-05b6cadf820a','column1','11','string',0,'',NULL); 447 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5ff03ba4-a310-524e-f3a3-05b6cadf820a','column2','1','string',0,'',NULL); 448 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5ff03ba4-a310-524e-f3a3-05b6cadf820a','column3','3','string',0,'',NULL); 449 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5ff03ba4-a310-524e-f3a3-05b6cadf820a','group1','13','string',0,'',NULL); 450 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5ff03ba4-a310-524e-f3a3-05b6cadf820a','group2','12','string',0,'',NULL); 451 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3e25c485-857d-1698-6c9b-03e3e8f4177b','reportTitle','Subtotals, Totals, and Amount Due','string',0,'Report','Report Title'); 452 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3e25c485-857d-1698-6c9b-03e3e8f4177b','showWhat','invoices','string',0,'',NULL); 453 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3e25c485-857d-1698-6c9b-03e3e8f4177b','column1','11','string',0,'',NULL); 454 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3e25c485-857d-1698-6c9b-03e3e8f4177b','column2','1','string',0,'',NULL); 455 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3e25c485-857d-1698-6c9b-03e3e8f4177b','column3','3','string',0,'',NULL); 456 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:8a9cf2d6-d5f0-54ca-1b89-8207dfa4c348','reportTitle','Subtotals, Totals, and Amount Due','string',0,'Report','Report Title'); 457 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:8a9cf2d6-d5f0-54ca-1b89-8207dfa4c348','showWhat','lineitems','string',0,'',NULL); 458 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:8a9cf2d6-d5f0-54ca-1b89-8207dfa4c348','column1','11','string',0,'',NULL); 459 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:8a9cf2d6-d5f0-54ca-1b89-8207dfa4c348','column2','1','string',0,'',NULL); 460 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:8a9cf2d6-d5f0-54ca-1b89-8207dfa4c348','column3','3','string',0,'',NULL); 461 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3cb9ae81-0838-863e-0185-1f46224cbe00','reportTitle','Totals Grouped by Sales Order Lead Source','string',0,'Report','Report Title'); 462 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3cb9ae81-0838-863e-0185-1f46224cbe00','showWhat','invoices','string',0,'',NULL); 463 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3cb9ae81-0838-863e-0185-1f46224cbe00','column1','11','string',0,'',NULL); 464 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3cb9ae81-0838-863e-0185-1f46224cbe00','column2','1','string',0,'',NULL); 465 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3cb9ae81-0838-863e-0185-1f46224cbe00','column3','3','string',0,'',NULL); 466 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:3cb9ae81-0838-863e-0185-1f46224cbe00','group1','15','string',0,'',NULL); 467 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:67dca680-14ba-d4e7-4926-b90c65495f48','reportTitle','Totals Grouped by Payment Method','string',0,'Report','Report Title'); 468 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:67dca680-14ba-d4e7-4926-b90c65495f48','showWhat','invoices','string',0,'',NULL); 469 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:67dca680-14ba-d4e7-4926-b90c65495f48','column1','11','string',0,'',NULL); 470 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:67dca680-14ba-d4e7-4926-b90c65495f48','column2','1','string',0,'',NULL); 471 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:67dca680-14ba-d4e7-4926-b90c65495f48','column3','3','string',0,'',NULL); 472 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:67dca680-14ba-d4e7-4926-b90c65495f48','group1','16','string',0,'',NULL); 473 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5dc66c67-1e98-7f85-6e89-5ab5d7795140','reportTitle','Totals Grouped by Shipping Method','string',0,'Report','Report Title'); 474 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5dc66c67-1e98-7f85-6e89-5ab5d7795140','showWhat','invoices','string',0,'',NULL); 475 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5dc66c67-1e98-7f85-6e89-5ab5d7795140','column1','1','string',0,'',NULL); 476 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5dc66c67-1e98-7f85-6e89-5ab5d7795140','coumn2','7','string',0,'',NULL); 477 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:5dc66c67-1e98-7f85-6e89-5ab5d7795140','group1','17','string',0,'',NULL); 478 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:d97334ef-0139-f178-fe36-c38e151cc60e','reportTitle','Tax Totals','string',0,'Report','Report Title'); 479 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:d97334ef-0139-f178-fe36-c38e151cc60e','showWhat','invoices','string',0,'',NULL); 480 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:d97334ef-0139-f178-fe36-c38e151cc60e','column1','11','string',0,'',NULL); 481 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:d97334ef-0139-f178-fe36-c38e151cc60e','column2','1','string',0,'',NULL); 482 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:d97334ef-0139-f178-fe36-c38e151cc60e','column3','5','string',0,'',NULL); 483 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b','reportTitle','Invoice','string',1,'Invoice','Title printed on reports'); 484 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b','printLogo','1','bool',1,'1','Should the logo print (1 = yes, 0 = no)'); 485 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b','printCompanyInfo','1','bool',1,'1','Should the top company information print (1 = yes, 0 = no)'); 486 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b','leftTopBox','billto','string',1,'billto','Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)'); 487 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b','leftTopBoxTitle','SOLD TO','string',1,'SOLD TO','Title of Left Top Header Box'); 488 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b','rightTopBox','shipto','string',1,'shipto','Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)'); 489 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b','rightTopBoxTitle','SHIP TO','string',1,'SHIP TO','Title of Right Top Header Box'); 490 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b','templateFormatting','0','bool',1,'0','Should PDF remove lines and dark titles (1 = remove, 0 = keep)'); 491 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:44b21461-6e67-c284-0ccf-36ab1af47c9b','templateUUID','','string',0,'','Optional UUID of file record for PDF to be used as background template'); 492 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73','reportTitle','Packing List','string',1,'Packing List','Title printed on reports'); 493 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73','printLogo','1','bool',1,'1','Should the logo print (1 = yes, 0 = no)'); 494 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73','printCompanyInfo','1','bool',1,'1','Should the top company information print (1 = yes, 0 = no)'); 495 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73','leftTopBox','billto','string',1,'billto','Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)'); 496 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73','leftTopBoxTitle','SOLD TO','string',1,'SOLD TO','Title of Left Top Header Box'); 497 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73','rightTopBox','shipto','string',1,'shipto','Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)'); 498 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73','rightTopBoxTitle','SHIP TO','string',1,'SHIP TO','Title of Right Top Header Box'); 499 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73','templateFormatting','0','bool',1,'0','Should PDF remove lines and dark titles (1 = remove, 0 = keep)'); 500 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:6bdef1ac-2f74-4d20-411a-3e48531dae73','templateUUID','','string',0,'','Optional UUID of file record for PDF to be used as background template'); 501 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca','reportTitle','Quote','string',1,'Quote','Title printed on reports'); 502 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca','printLogo','1','bool',1,'1','Should the logo print (1 = yes, 0 = no)'); 503 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca','printCompanyInfo','1','bool',1,'1','Should the top company information print (1 = yes, 0 = no)'); 504 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca','leftTopBox','billto','string',1,'billto','Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)'); 505 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca','leftTopBoxTitle','SOLD TO','string',1,'SOLD TO','Title of Left Top Header Box'); 506 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca','rightTopBox','shipto','string',1,'shipto','Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)'); 507 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca','rightTopBoxTitle','SHIP TO','string',1,'SHIP TO','Title of Right Top Header Box'); 508 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca','templateFormatting','0','bool',1,'0','Should PDF remove lines and dark titles (1 = remove, 0 = keep)'); 509 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:b683e2f0-e52b-4dd4-33e1-7566616893ca','templateUUID','','string',0,'','Optional UUID of file record for PDF to be used as background template'); 510 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:30a56a65-8673-b3c0-cd50-6546968b4d37','reportTitle','Work Order','string',1,'Work Order','Title printed on reports'); 511 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:30a56a65-8673-b3c0-cd50-6546968b4d37','printLogo','1','bool',1,'1','Should the logo print (1 = yes, 0 = no)'); 512 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:30a56a65-8673-b3c0-cd50-6546968b4d37','printCompanyInfo','1','bool',1,'1','Should the top company information print (1 = yes, 0 = no)'); 513 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:30a56a65-8673-b3c0-cd50-6546968b4d37','leftTopBox','billto','string',1,'billto','Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)'); 514 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:30a56a65-8673-b3c0-cd50-6546968b4d37','leftTopBoxTitle','SOLD TO','string',1,'SOLD TO','Title of Left Top Header Box'); 515 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:30a56a65-8673-b3c0-cd50-6546968b4d37','rightTopBox','shipto','string',1,'shipto','Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)'); 516 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:30a56a65-8673-b3c0-cd50-6546968b4d37','rightTopBoxTitle','SHIP TO','string',1,'SHIP TO','Title of Right Top Header Box'); 517 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:30a56a65-8673-b3c0-cd50-6546968b4d37','templateFormatting','0','bool',1,'0','Should PDF remove lines and dark titles (1 = remove, 0 = keep)'); 518 INSERT INTO `reportsettings` (reportuuid, name, value, type, required, defaultvalue, description) VALUES ('rpt:30a56a65-8673-b3c0-cd50-6546968b4d37','templateUUID','','string',0,'','Optional UUID of file record for PDF to be used as background template'); 519 --end reportsettings INSERT-- 370 520 --role UPDATE-- 371 521 UPDATE `roles` SET `uuid`='role:3403a7e0-adb1-4d0b-3c6e-6d6bbe177d52' WHERE `id`='10'; … … 386 536 UPDATE `shippingmethods` SET `uuid`='shp:f34a3e10-e782-2675-f041-71f5c88f5aa9' WHERE `name`='FedEx Priority Overnight AM'; 387 537 UPDATE `shippingmethods` SET `uuid`='shp:e2e43816-667a-fdf3-6bec-4456bcf8bef0' WHERE `name`='FedEx Standard Overnight'; 388 UPDATE `shippingmethods` SET `uuid`='shp:0f07f7fd-0352-8df7-8294-a57e5e375808' WHERE `name`='UPS 2nd Day Air'; 538 UPDATE `shippingmethods` SET `uuid`='shp:0f07f7fd-0352-8df7-8294-a57e5e375808' WHERE `name`='UPS 2nd Day Air'; 389 539 UPDATE `shippingmethods` SET `uuid`='shp:6ef11711-7335-3e90-cf27-df5ea23c1480' WHERE `name`='UPS 3 Day Select'; 390 540 UPDATE `shippingmethods` SET `uuid`='shp:1a0c53bd-6754-7d9f-4bea-bad57628187a' WHERE `name`='UPS Ground (Com)'; -
trunk/phpbms/modules/bms/products_saleshistory.php
r606 r693 40 40 include("include/fields.php"); 41 41 42 if(!hasRights("role:259ead9f-100b-55b5-508a-27e33a6216bf")) goURL(APP_PATH."noaccess.php"); 43 44 if(!isset($_POST["fromdate"])) $_POST["fromdate"]=dateToString(strtotime("-1 year")); 45 if(!isset($_POST["todate"])) $_POST["todate"]=dateToString(mktime()); 46 if(!isset($_POST["status"])) $_POST["status"]="Orders/Invoices"; 47 if(!isset($_POST["command"])) $_POST["command"]="show"; 48 if(!isset($_POST["date_order"])) $_POST["date_order"]="DESC"; 42 if(!hasRights("role:259ead9f-100b-55b5-508a-27e33a6216bf")) 43 goURL(APP_PATH."noaccess.php"); 44 45 if(!isset($_POST["fromdate"])) 46 $_POST["fromdate"] = dateToString(strtotime("-1 year")); 47 48 if(!isset($_POST["todate"])) 49 $_POST["todate"] = dateToString(mktime()); 50 51 if(!isset($_POST["status"])) 52 $_POST["status"] = "Orders and Invoices"; 53 54 if(!isset($_POST["command"])) 55 $_POST["command"] = "show"; 56 57 if(!isset($_POST["date_order"])) 58 $_POST["date_order"] = "DESC"; 49 59 50 60 if($_POST["command"]=="print") { 51 $_SESSION["printing"]["whereclause"]="WHERE products.id=".$_GET["id"]; 52 $_SESSION["printing"]["dataprint"]="Single Record"; 53 $fromProduct=true; 54 require("report/products_saleshistory.php"); 61 62 $_SESSION["printing"]["whereclause"]="products.id=".$_GET["id"]; 63 $_SESSION["printing"]["dataprint"]="Single Record"; 64 65 goURL("report/products_saleshistory.php?rid=".urlencode("rpt:a278af28-9c34-da2e-d81b-4caa36dfa29f")."&tid=".urlencode("tbld:7a9e87ed-d165-c4a4-d9b9-0a4adc3c5a34")."&status=".urlencode($_POST["status"])."&fromdate=".urlencode($_POST["fromdate"])."&todate=".urlencode($_POST["todate"])); 66 55 67 } else { 56 $thestatus="(invoices.type =\""; 57 switch($_POST["status"]){ 58 case "Orders/Invoices": 59 $thestatus.="Order\" or invoices.type=\"Invoice\")"; 60 $searchdate="orderdate"; 61 break; 68 69 $thestatus="(invoices.type =\""; 70 switch($_POST["status"]){ 71 72 case "Orders and Invoices": 73 $thestatus.="Order\" or invoices.type=\"Invoice\")"; 74 $searchdate="orderdate"; 75 break; 76 62 77 case "Invoices": 63 $thestatus.="Invoice\")"; 64 $searchdate="invoicedate"; 65 break; 78 $thestatus.="Invoice\")"; 79 $searchdate="invoicedate"; 80 break; 81 66 82 case "Orders": 67 $thestatus.="Order\")"; 68 $searchdate="orderdate"; 69 break; 70 } 83 $thestatus.="Order\")"; 84 $searchdate="orderdate"; 85 break; 86 87 }//endswitch 71 88 $dateOrder = ($_POST['date_order'] == 'DESC') ? 'ASC' : 'DESC'; 72 89 … … 132 149 <label for="status">type</label><br /> 133 150 <select name="status" id="status"> 134 <option value="Orders /Invoices" <?php if($_POST["status"]=="Orders/Invoices") echo "selected=\"selected\""?>>Orders/Invoices</option>151 <option value="Orders and Invoices" <?php if($_POST["status"]=="Orders and Invoices") echo "selected=\"selected\""?>>Orders and Invoices</option> 135 152 <option value="Invoices" <?php if($_POST["status"]=="Invoices") echo "selected=\"selected\""?>>Invoices</option> 136 153 <option value="Orders" <?php if($_POST["status"]=="Orders") echo "selected=\"selected\""?>>Orders</option> … … 143 160 144 161 <p id="printP"><br /><input id="print" name="command" type="submit" value="print" class="Buttons" /></p> 145 <p id="changeTimelineP"><br /><input name="command" type="submit" value=" change timeframe/view" class="smallButtons" /></p>162 <p id="changeTimelineP"><br /><input name="command" type="submit" value="update" class="smallButtons" /></p> 146 163 <input name="date_order" id="date_order" type="hidden" value="<?php echo $_POST["date_order"]; ?>" /> 147 164 </div> -
trunk/phpbms/modules/bms/report/aritems_clientstatement.php
r673 r693 50 50 var $showClosed = false; 51 51 52 function aritemsClientStatements($db, $ statementDate = NULL, $showPayments = true, $showClosed = false){53 54 parent::phpbmsReport($db);52 function aritemsClientStatements($db, $reportUUID, $tabledefUUID, $statementDate = NULL, $showPayments = true, $showClosed = false){ 53 54 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 55 55 56 56 if($statementDate) … … 69 69 70 70 if($whereclause) 71 $this->where clause = $whereclause;72 73 if(!$this->where clause)74 $this->where clause = "71 $this->whereClause = $whereclause; 72 73 if(!$this->whereClause) 74 $this->whereClause = " 75 75 aritems.status = 'open' 76 76 AND aritems.posted = 1"; … … 108 108 ON clients.salesmanagerid = users.uuid"; 109 109 110 $this->sort order = 'if(clients.lastname!="",concat(clients.lastname,", ",clients.firstname,if(clients.company!="",concat(" (",clients.company,")"),"")),clients.company)';110 $this->sortOrder = 'if(clients.lastname!="",concat(clients.lastname,", ",clients.firstname,if(clients.company!="",concat(" (",clients.company,")"),"")),clients.company)'; 111 111 112 112 $querystatement = $this->assembleSQL($querystatement); … … 134 134 //uncomment the following line to help troubleshoot formatting 135 135 //$pdf->borderDebug = 1; 136 $pdf->hasComapnyHeader = true; 136 $pdf->logoInHeader = true; 137 $pdf->companyInfoInHeader = true; 137 138 $pdf->SetMargins(); 138 139 … … 608 609 if(!isset($noOutput)){ 609 610 611 //IE needs caching to be set to private in order to display PDFS 612 session_cache_limiter('private'); 613 614 //set encoding to latin1 (fpdf doesnt like utf8) 615 $sqlEncoding = "latin1"; 616 require_once("../../../include/session.php"); 617 618 checkForReportArguments(); 619 620 $report = new aritemsClientStatements($db, $_GET["rid"], $_GET["tid"]); 621 610 622 if(isset($_GET["cmd"])){ 611 623 … … 616 628 617 629 if(isset($_POST["command"])) { 618 619 session_cache_limiter('private');620 621 //set encoding to latin1 (fpdf doesnt like utf8)622 $sqlEncoding = "latin1";623 require_once("../../../include/session.php");624 625 $report = new aritemsClientStatements($db);626 630 627 631 switch($_POST["command"]){ … … 635 639 } else { 636 640 637 require_once("../../../include/session.php");638 639 $report = new aritemsClientStatements($db);640 641 641 $report->showOptions(); 642 642 … … 644 644 645 645 }//end if 646 647 /** 648 * When adding a new report record, the add/edit needs to know what the class 649 * name is so that it can instantiate it, and grab it's default settings. 650 */ 651 if(isset($addingReportRecord)) 652 $reportClass ="aritemsClientStatements"; 653 646 654 ?> -
trunk/phpbms/modules/bms/report/aritems_summary.php
r633 r693 59 59 60 60 61 function aritemsSummary($db, $ statementDate = NULL, $showPayments = "new", $showClosed = false){62 63 parent::phpbmsReport($db);61 function aritemsSummary($db, $reportUUID, $tabledefUUID, $statementDate = NULL, $showPayments = "new", $showClosed = false){ 62 63 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 64 64 65 65 if($statementDate) … … 78 78 79 79 if($whereclause) 80 $this->where clause = $whereclause;81 82 if(!$this->where clause)83 $this->where clause = "80 $this->whereClause = $whereclause; 81 82 if(!$this->whereClause) 83 $this->whereClause = " 84 84 aritems.status = 'open' 85 85 AND aritems.posted = 1"; … … 116 116 ON clients.salesmanagerid = users.uuid"; 117 117 118 $this->sort order = 'if(clients.lastname!="",concat(clients.lastname,", ",clients.firstname,if(clients.company!="",concat(" (",clients.company,")"),"")),clients.company)';118 $this->sortOrder = 'if(clients.lastname!="",concat(clients.lastname,", ",clients.firstname,if(clients.company!="",concat(" (",clients.company,")"),"")),clients.company)'; 119 119 120 120 $querystatement = $this->assembleSQL($querystatement); … … 573 573 }//endif 574 574 575 session_cache_limiter('private'); 576 //set encoding to latin1 (fpdf doesnt like utf8) 577 $sqlEncoding = "latin1"; 578 require_once("../../../include/session.php"); 579 580 checkForReportArguments(); 581 582 $report = new aritemsSummary($db, $_GET["rid"], $_GET["tid"]); 583 575 584 if(isset($_POST["command"])) { 576 577 session_cache_limiter('private');578 579 //set encoding to latin1 (fpdf doesnt like utf8)580 $sqlEncoding = "latin1";581 require_once("../../../include/session.php");582 583 $report = new aritemsSummary($db);584 585 585 586 switch($_POST["command"]){ … … 593 594 } else { 594 595 595 require_once("../../../include/session.php");596 597 $report = new aritemsSummary($db);598 599 596 $report->showOptions(); 600 597 -
trunk/phpbms/modules/bms/report/clients_purchasehistory.php
r607 r693 38 38 */ 39 39 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); 102 117 103 118 $querystatement = " 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> 129 149 <tr> 130 <th align="left" nowrap="nowrap"colspan="3">invoice</th>131 <th align="left" nowrap="nowrap"colspan="3">product</th>132 <th align="left" nowrap="nowrap" colspan="2" >line item</th>150 <th align="left" colspan="3">invoice</th> 151 <th align="left" colspan="3">product</th> 152 <th align="left" nowrap="nowrap" colspan="2" class="lastHeader">line item</th> 133 153 </tr> 134 154 <tr> … … 136 156 <th align="left" nowrap="nowrap" >type</th> 137 157 <th align="left" nowrap="nowrap" >date</th> 138 <th align="left" nowrap="nowrap" >part num.</th>158 <th align="left" nowrap="nowrap" >part #</th> 139 159 <th width="100%" nowrap="nowrap" align="left">name</th> 140 160 <th align="right" nowrap="nowrap" >price</th> 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> 215 213 216 214 <ul> 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"; -
trunk/phpbms/modules/bms/report/incoming_cashflow.php
r611 r693 38 38 */ 39 39 40 require("../../../include/session.php"); 41 42 class totalReport{ 40 if(!class_exists("phpbmsReport")) 41 require("../../../report/report_class.php"); 42 43 class totalReport extends phpbmsReport{ 43 44 44 45 var $selectcolumns; 45 46 var $tableClause = array(); 46 var $whereClause = array();47 var $whereClauses = array(); 47 48 var $group = ""; 48 49 var $showItems = false; … … 51 52 var $toDate; 52 53 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 119 76 }//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 120 143 121 144 … … 206 229 $querystatement = "(SELECT"; 207 230 $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"].")"; 209 232 $querystatement .= " UNION "; 210 233 $querystatement .= "(SELECT"; 211 234 $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"].")"; 213 236 214 237 … … 257 280 $querystatement .= $this->generateColumns("invoices").", COUNT(invoices.id) AS `thecount` "; 258 281 $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"); 260 283 $querystatement .= " GROUP BY `thegroup`)"; 261 284 $querystatement .= " UNION "; … … 263 286 $querystatement .= $this->generateColumns("receipts").", COUNT(receipts.id) AS thecount "; 264 287 $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"); 266 289 $querystatement .= " GROUP BY `thegroup`)"; 267 290 $querystatement .= " ORDER BY `thegroup`"; … … 421 444 FROM 422 445 (".$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")." 424 447 GROUP BY `theid`) 425 448 UNION … … 431 454 FROM 432 455 (".$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")." 434 457 GROUP BY `theid`) 435 458 ORDER BY `docdate`"; … … 464 487 function showReport(){ 465 488 466 $pageTitle = "Incoming Cash Flow"; 489 if(!isset($this->settings["reportTitle"])) 490 $this->settings["reportTitle"] = "Incoming Cash Flow"; 467 491 468 492 … … 477 501 <body> 478 502 <div id="toprint"> 479 <h1><span><?php echo $pageTitle?></span></h1>503 <h1><span><?php echo formatVariable($this->settings["reportTitle"]); ?></span></h1> 480 504 <h2>Dates: <?php echo $this->fromDate ?> - <?php echo $this->toDate ?></h2> 481 505 … … 582 606 }//endclass 583 607 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 */ 613 if(!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 */ 645 if(isset($addingReportRecord)) 646 $reportClass ="totalReport"; 647 648 ?> -
trunk/phpbms/modules/bms/report/invoices_pdfinvoice.php
r673 r693 38 38 */ 39 39 40 //PROCESSING 41 //============================================================================= 40 /** 41 * PROCESSING 42 * ============================================================================= 43 */ 42 44 if(!isset($noOutput)){ 43 45 44 //IE needs caching to be set to private in order to display PDFS45 session_cache_limiter('private');46 //IE needs caching to be set to private in order to display PDFS 47 session_cache_limiter('private'); 46 48 47 //set encoding to latin1 (fpdf doesnt like utf8)48 $sqlEncoding = "latin1";49 require_once("../../../include/session.php");49 //set encoding to latin1 (fpdf doesnt like utf8) 50 $sqlEncoding = "latin1"; 51 require_once("../../../include/session.php"); 50 52 51 include("modules/bms/report/invoices_pdf_class.php");53 include("modules/bms/report/invoices_pdf_class.php"); 52 54 53 $report = new invoicePDF($db, 'P', 'in', 'Letter'); 54 $report->setupFromPrintScreen(); 55 $report->generate(); 56 57 $filename = "Invoice"; 58 if($report->count === 1){ 59 60 if($report->invoicerecord["company"]) 61 $filename .= "_".$report->invoicerecord["company"]; 62 63 $filename .= "_".$report->invoicerecord["id"]; 64 65 }elseif((int)$report->count) 66 $filename .= "_Multiple"; 67 68 $filename .= ".pdf"; 69 $report->output('screen', $filename); 55 checkForReportArguments(); 56 57 $report = new invoicePDF($db, $_GET["rid"], $_GET["tid"], 'P', 'in', 'Letter'); 58 $report->setupFromPrintScreen(); 59 $report->generate(); 60 61 $filename = "Invoice"; 62 if($report->count === 1){ 63 64 if($report->invoicerecord["company"]) 65 $filename .= "_".$report->invoicerecord["company"]; 66 67 $filename .= "_".$report->invoicerecord["id"]; 68 69 }elseif((int)$report->count) 70 $filename .= "_Multiple"; 71 72 $filename .= ".pdf"; 73 74 $report->output('screen', $filename); 70 75 71 76 }//end if 72 77 78 79 /** 80 * When adding a new report record, the add/edit needs to know what the class 81 * name is so that it can instantiate it, and grab it's default settings. 82 */ 83 if(isset($addingReportRecord)){ 84 85 include("modules/bms/report/invoices_pdf_class.php"); 86 $reportClass = "invoicePDF"; 87 88 }//endif 73 89 ?> -
trunk/phpbms/modules/bms/report/invoices_pdfpackinglist.php
r673 r693 38 38 */ 39 39 40 if(!isset($_SESSION["userinfo"]["id"])){ 41 42 //IE needs caching to be set to private in order to display PDFS 43 session_cache_limiter('private'); 44 45 //set encoding to latin1 (fpdf doesnt like utf8) 46 $sqlEncoding = "latin1"; 47 require_once("../../../include/session.php"); 48 49 }//end if 50 51 if(!class_exists("invoicePDF")) 52 include("invoices_pdf_class.php"); 53 54 class packinglistPDF extends invoicePDF{ 55 56 var $title = "Packing List"; 57 var $showShipNameInShipTo = false; 58 59 function packinglistPDF($db, $orientation='P', $unit='mm', $format='Letter'){ 60 61 $this->invoicePDF($db, $orientation, $unit, $format); 62 63 }//end method 64 65 66 function initialize(){ 67 //This function will set column headings, sizes and formatting 68 69 $pdf = &$this->pdf; 70 71 $topinfo = array(); 72 $topinfo[] = new pdfColumn("Order ID", "id", 0.75); 73 $topinfo[] = new pdfColumn("Order Date", "orderdate", 1, "date"); 74 $topinfo[] = new pdfColumn("Client PO", "ponumber", 0); 75 76 $size = 0; 77 foreach($topinfo as $column) 78 $size += $column->size; 79 80 $topinfo[2]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 81 82 $this->topinfo = $topinfo; 83 84 $lineitems = array(); 85 $lineitems[] = new pdfColumn("Product / (Part Number)", "parts", 0); 86 $lineitems[] = new pdfColumn("Prepackaged", "isprepackaged", 0.75, "boolean", "C"); 87 $lineitems[] = new pdfColumn("Oversized", "isoversized", 0.75, "boolean", "C"); 88 $lineitems[] = new pdfColumn("Unit Weight", "unitweight", 0.75, "real", "R"); 89 $lineitems[] = new pdfColumn("Qty", "quantity", 0.5, "real","R"); 90 $lineitems[] = new pdfColumn("Weight Ext.", "extended", 0.75, "real", "R"); 91 92 $size = 0; 93 foreach($lineitems as $column) 94 $size += $column->size; 95 96 $lineitems[0]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 97 98 $this->lineitems = $lineitems; 99 100 $totalsinfo = array(); 101 $totalsinfo[] = new pdfColumn("Shipping Method", "shippingname", 0); 102 $totalsinfo[] = new pdfColumn("Estimated Boxes", "estimatedboxes", 1, NULL, "C"); 103 $totalsinfo[] = new pdfColumn("Total Weight", "totalweight", 1, "real", "R"); 104 $totalsinfo[] = new pdfColumn("Shipping", "shipping", 1, "currency", "R"); 105 106 $size = 0; 107 foreach($totalsinfo as $column) 108 $size += $column->size; 109 110 $totalsinfo[0]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 111 112 $this->totalsinfo = $totalsinfo; 113 114 }//end method 115 116 117 function _addNotes(){ 118 119 $pdf = &$this->pdf; 120 121 $height = 1; 122 $nextPos = $pdf->GetY() + $height + 0.125; 123 124 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 125 $pdf->setStyle("header"); 126 $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Special Instructions", 1, 2, "L", 1); 127 128 $pdf->setStyle("normal"); 129 $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); 130 $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->invoicerecord["specialinstructions"]); 131 132 $pdf->SetXY($pdf->leftmargin, $nextPos); 133 134 }//end method 135 136 137 function _getLineItems(){ 138 139 $querystatement = " 140 SELECT 141 lineitems.*, 142 lineitems.quantity*lineitems.unitweight as extended, 143 products.partname, 144 products.partnumber, 145 products.isoversized, 146 products.isprepackaged, 147 products.packagesperitem 148 FROM 149 lineitems LEFT JOIN products ON lineitems.productid = products.id 150 WHERE 151 lineitems.invoiceid =".((int) $this->invoicerecord["id"])." 152 ORDER BY 153 displayorder"; 154 155 $queryresult = $this->db->query($querystatement); 156 157 //determine estimated total boxes 158 $this->invoicerecord["estimatedboxes"] = 0; 159 while($therecord = $this->db->fetchArray($queryresult)){ 160 161 if($therecord["isprepackaged"]) 162 $this->invoicerecord["estimatedboxes"] += $therecord["quantity"]; 163 else 164 $this->invoicerecord["estimatedboxes"] += $therecord["quantity"] * $therecord["packagesperitem"]; 165 166 }//endwhile 167 168 $this->db->seek($queryresult, 0); 169 170 return $queryresult; 171 172 }//end method 173 174 function _addTotals(){ 175 176 $pdf = &$this->pdf; 177 178 $height = .5; 179 $nextPos = $pdf->GetY() + $height + 0.125; 180 181 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 182 183 $pdf->setStyle("header"); 184 foreach($this->totalsinfo as $column) 185 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 186 187 $pdf->setStyle("normal"); 188 $pdf->SetFont("Arial", "B", 10); 189 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); 190 191 foreach($this->totalsinfo as $column){ 192 193 if($column->format != "") 194 $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); 195 else 196 $value = $this->invoicerecord[$column->fieldname]; 197 198 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 199 200 }//end foreach 201 202 }//end method 203 204 }//end class 205 206 207 //PROCESSING 208 //============================================================================= 209 if(!isset($noOutput)){ 210 211 $report = new packinglistPDF($db, 'P', 'in', 'Letter'); 212 213 $report->setupFromPrintScreen(); 214 $report->generate(); 215 $filename = "Packing_List"; 216 217 if($report->count === 1){ 218 219 if($report->invoicerecord["company"]) 220 $filename .= "_".$report->invoicerecord["company"]; 221 222 $filename .= "_".$report->invoicerecord["id"]; 223 224 }elseif((int)$report->count) 225 $filename .= "_Multiple"; 226 227 $report->output('screen', $filename); 228 229 }//end if 40 if(!class_exists("invoicePDF")) 41 include("invoices_pdf_class.php"); 42 43 class packinglistPDF extends invoicePDF{ 44 45 var $showShipNameInShipTo = false; 46 47 function packinglistPDF($db, $reportUUID, $tabledefUUID, $orientation='P', $unit='mm', $format='Letter'){ 48 49 $this->invoicePDF($db, $reportUUID, $tabledefUUID, $orientation, $unit, $format); 50 51 }//end method 52 53 54 /** 55 * function checkForDefaultSettings 56 * 57 * Checks to make sure loaded report Settings exist and are correct 58 */ 59 function checkForDefaultSettings(){ 60 61 if(!isset($this->settings["reportTitle"])) 62 $this->settings["reportTitle"] = "Packing List"; 63 64 parent::checkForDefaultSettings(); 65 66 }//end function checkForDefaultSettings 67 68 69 function initialize(){ 70 //This function will set column headings, sizes and formatting 71 72 $pdf = &$this->pdf; 73 74 $topinfo = array(); 75 $topinfo[] = new pdfColumn("Order ID", "id", 0.75); 76 $topinfo[] = new pdfColumn("Order Date", "orderdate", 1, "date"); 77 $topinfo[] = new pdfColumn("Client PO", "ponumber", 0); 78 79 $size = 0; 80 foreach($topinfo as $column) 81 $size += $column->size; 82 83 $topinfo[2]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 84 85 $this->topinfo = $topinfo; 86 87 $lineitems = array(); 88 $lineitems[] = new pdfColumn("Product / (Part Number)", "parts", 0); 89 $lineitems[] = new pdfColumn("Prepackaged", "isprepackaged", 0.75, "boolean", "C"); 90 $lineitems[] = new pdfColumn("Oversized", "isoversized", 0.75, "boolean", "C"); 91 $lineitems[] = new pdfColumn("Unit Weight", "unitweight", 0.75, "real", "R"); 92 $lineitems[] = new pdfColumn("Qty", "quantity", 0.5, "real","R"); 93 $lineitems[] = new pdfColumn("Weight Ext.", "extended", 0.75, "real", "R"); 94 95 $size = 0; 96 foreach($lineitems as $column) 97 $size += $column->size; 98 99 $lineitems[0]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 100 101 $this->lineitems = $lineitems; 102 103 $totalsinfo = array(); 104 $totalsinfo[] = new pdfColumn("Shipping Method", "shippingname", 0); 105 $totalsinfo[] = new pdfColumn("Estimated Boxes", "estimatedboxes", 1, NULL, "C"); 106 $totalsinfo[] = new pdfColumn("Total Weight", "totalweight", 1, "real", "R"); 107 $totalsinfo[] = new pdfColumn("Shipping", "shipping", 1, "currency", "R"); 108 109 $size = 0; 110 foreach($totalsinfo as $column) 111 $size += $column->size; 112 113 $totalsinfo[0]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 114 115 $this->totalsinfo = $totalsinfo; 116 117 }//end method 118 119 120 function _addNotes(){ 121 122 $pdf = &$this->pdf; 123 124 $height = 1; 125 $nextPos = $pdf->GetY() + $height + 0.125; 126 127 if(!$this->settings["templateFormatting"]){ 128 129 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 130 $pdf->setStyle("header"); 131 $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Special Instructions", 1, 2, "L", 1); 132 133 }//endif 134 135 $pdf->setStyle("normal"); 136 $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); 137 $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->invoicerecord["specialinstructions"]); 138 139 $pdf->SetXY($pdf->leftmargin, $nextPos); 140 141 }//end method 142 143 144 function _getLineItems(){ 145 146 $querystatement = " 147 SELECT 148 lineitems.*, 149 lineitems.quantity*lineitems.unitweight as extended, 150 products.partname, 151 products.partnumber, 152 products.isoversized, 153 products.isprepackaged, 154 products.packagesperitem 155 FROM 156 lineitems LEFT JOIN products ON lineitems.productid = products.id 157 WHERE 158 lineitems.invoiceid =".((int) $this->invoicerecord["id"])." 159 ORDER BY 160 displayorder"; 161 162 $queryresult = $this->db->query($querystatement); 163 164 //determine estimated total boxes 165 $this->invoicerecord["estimatedboxes"] = 0; 166 while($therecord = $this->db->fetchArray($queryresult)){ 167 168 if($therecord["isprepackaged"]) 169 $this->invoicerecord["estimatedboxes"] += $therecord["quantity"]; 170 else 171 $this->invoicerecord["estimatedboxes"] += $therecord["quantity"] * $therecord["packagesperitem"]; 172 173 }//endwhile 174 175 $this->db->seek($queryresult, 0); 176 177 return $queryresult; 178 179 }//end method 180 181 182 function _addTotals(){ 183 184 $pdf = &$this->pdf; 185 186 $height = .5; 187 $nextPos = $pdf->GetY() + $height + 0.125; 188 189 if(!$this->settings["templateFormatting"]){ 190 191 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 192 193 $pdf->setStyle("header"); 194 foreach($this->totalsinfo as $column) 195 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 196 197 } else 198 $pdf->SetY($pdf->GetY() + 0.18); 199 200 $pdf->setStyle("normal"); 201 $pdf->SetFont("Arial", "B", 10); 202 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); 203 204 foreach($this->totalsinfo as $column){ 205 206 if($column->format != "") 207 $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); 208 else 209 $value = $this->invoicerecord[$column->fieldname]; 210 211 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 212 213 }//end foreach 214 215 }//end method 216 217 218 /** 219 * function addingRecordDefaultSettings 220 * 221 * Creates an array of settings associative arrays for use by the system when 222 * a new report record is added that references the file containing this class 223 * 224 * @retrun array of settings. Each setting should itself be 225 * an associative array containing the following 226 * name: name of the setting 227 * defaultvalue: default value for setting 228 * type: (string, int, real, bool) type for value of setting 229 * required: (0,1) whether the setting is required or not 230 * description: brief description for what this setting is used for. 231 */ 232 function addingRecordDefaultSettings(){ 233 234 $settings = parent::addingRecordDefaultSettings(); 235 236 for($i=0; $i< count($settings); $i++){ 237 238 switch($settings[$i]["name"]){ 239 240 case "reportTitle": 241 $settings[$i]["defaultValue"] = "Packing List"; 242 243 }//endswitch 244 245 }//end foreach 246 247 return $settings; 248 249 }//endfunction addingRecordDefaultSettings 250 251 }//end class 252 253 254 /** 255 * PROCESSING 256 * ============================================================================= 257 */ 258 if(!isset($noOutput)){ 259 260 //IE needs caching to be set to private in order to display PDFS 261 session_cache_limiter('private'); 262 263 //set encoding to latin1 (fpdf doesnt like utf8) 264 $sqlEncoding = "latin1"; 265 require_once("../../../include/session.php"); 266 267 checkForReportArguments(); 268 269 $report = new packinglistPDF($db, $_GET["rid"], $_GET["tid"], 'P', 'in', 'Letter'); 270 271 $report->setupFromPrintScreen(); 272 $report->generate(); 273 $filename = "Packing_List"; 274 275 if($report->count === 1){ 276 277 if($report->invoicerecord["company"]) 278 $filename .= "_".$report->invoicerecord["company"]; 279 280 $filename .= "_".$report->invoicerecord["id"]; 281 282 }elseif((int)$report->count) 283 $filename .= "_Multiple"; 284 285 $filename .=".pdf"; 286 287 $report->output('screen', $filename); 288 289 }//end if 290 291 292 /** 293 * When adding a new report record, the add/edit needs to know what the class 294 * name is so that it can instantiate it, and grab it's default settings. 295 */ 296 if(isset($addingReportRecord)) 297 $reportClass ="packinglistPDF"; 230 298 ?> -
trunk/phpbms/modules/bms/report/invoices_pdfquote.php
r673 r693 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 if(!isset($_SESSION["userinfo"]["id"])){40 41 //IE needs caching to be set to private in order to display PDFS42 session_cache_limiter('private');43 44 //set encoding to latin1 (fpdf doesnt like utf8)45 $sqlEncoding = "latin1";46 require_once("../../../include/session.php");47 48 }//end if49 50 39 if(!class_exists("invoicePDF")) 51 include("invoices_pdf_class.php");40 include("invoices_pdf_class.php"); 52 41 53 42 class quotePDF extends invoicePDF{ 54 43 55 var $title = "Quote"; 44 function quotePDF($db, $reportUUID, $tabledefUUID, $orientation='P', $unit='mm', $format='Letter'){ 56 45 57 function quotePDF($db, $orientation='P', $unit='mm', $format='Letter'){ 46 $this->invoicePDF($db, $reportUUID, $tabledefUUID, $orientation, $unit, $format); 58 47 59 $this->invoicePDF($db, $orientation, $unit, $format); 48 }//end method 60 49 61 }//end method62 50 63 function initialize(){ 64 parent::initialize(); 51 /** 52 * function checkForDefaultSettings 53 * 54 * Checks to make sure loaded report Settings exist and are correct 55 */ 56 function checkForDefaultSettings(){ 65 57 66 unset($this->totalsinfo[5]); 58 if(!isset($this->settings["reportTitle"])) 59 $this->settings["reportTitle"] = "Quote"; 67 60 68 }//end method 61 parent::checkForDefaultSettings(); 62 63 }//end function checkForDefaultSettings 64 65 66 function initialize(){ 67 68 parent::initialize(); 69 70 unset($this->totalsinfo[5]); 71 72 }//end method 73 74 75 /** 76 * function addingRecordDefaultSettings 77 * 78 * Creates an array of settings associative arrays for use by the system when 79 * a new report record is added that references the file containing this class 80 * 81 * @retrun array of settings. Each setting should itself be 82 * an associative array containing the following 83 * name: name of the setting 84 * defaultvalue: default value for setting 85 * type: (string, int, real, bool) type for value of setting 86 * required: (0,1) whether the setting is required or not 87 * description: brief description for what this setting is used for. 88 */ 89 function addingRecordDefaultSettings(){ 90 91 $settings = parent::addingRecordDefaultSettings(); 92 93 for($i=0; $i< count($settings); $i++){ 94 95 switch($settings[$i]["name"]){ 96 97 case "reportTitle": 98 $settings[$i]["defaultValue"] = "Quote"; 99 100 }//endswitch 101 102 }//end foreach 103 104 return $settings; 105 106 }//endfunction addingRecordDefaultSettings 69 107 70 108 }//end class 71 109 72 //PROCESSING 73 //============================================================================= 110 111 /** 112 * PROCESSING 113 * ============================================================================= 114 */ 74 115 if(!isset($noOutput)){ 75 116 76 $report = new quotePDF($db, 'P', 'in', 'Letter'); 77 $report->showShipNameInShipTo = false;117 //IE needs caching to be set to private in order to display PDFS 118 session_cache_limiter('private'); 78 119 79 $report->setupFromPrintScreen(); 80 $report->generate(); 81 82 $filename = "Quote"; 83 if($report->count === 1){ 84 85 if($report->invoicerecord["company"]) 86 $filename .= "_".$report->invoicerecord["company"]; 87 88 $filename .= "_".$report->invoicerecord["id"]; 89 90 }elseif((int)$report->count) 91 $filename .= "_Multiple"; 92 93 $filename .= ".pdf"; 94 95 $report->output('screen', $filename); 120 //set encoding to latin1 (fpdf doesnt like utf8) 121 $sqlEncoding = "latin1"; 122 require_once("../../../include/session.php"); 123 124 checkForReportArguments(); 125 126 $report = new quotePDF($db, $_GET["rid"], $_GET["tid"], 'P', 'in', 'Letter'); 127 $report->showShipNameInShipTo = false; 128 129 $report->setupFromPrintScreen(); 130 $report->generate(); 131 132 $filename = "Quote"; 133 if($report->count === 1){ 134 135 if($report->invoicerecord["company"]) 136 $filename .= "_".$report->invoicerecord["company"]; 137 138 $filename .= "_".$report->invoicerecord["id"]; 139 140 }elseif((int)$report->count) 141 $filename .= "_Multiple"; 142 143 $filename .= ".pdf"; 144 145 $report->output('screen', $filename); 96 146 97 147 }//end if 98 148 99 149 150 /** 151 * When adding a new report record, the add/edit needs to know what the class 152 * name is so that it can instantiate it, and grab it's default settings. 153 */ 154 if(isset($addingReportRecord)) 155 $reportClass ="quotePDF"; 100 156 ?> -
trunk/phpbms/modules/bms/report/invoices_pdfworkorder.php
r673 r693 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 if(!isset($_SESSION["userinfo"]["id"])){ 40 41 //IE needs caching to be set to private in order to display PDFS 42 session_cache_limiter('private'); 43 44 //set encoding to latin1 (fpdf doesnt like utf8) 45 $sqlEncoding = "latin1"; 46 require_once("../../../include/session.php"); 47 48 }//end if 49 50 if(!class_exists("invoicePDF")) 51 include("invoices_pdf_class.php"); 52 53 class workorderPDF extends invoicePDF{ 54 55 var $title = "Work Order"; 56 var $lineitemBoxHeight = 3.75; 57 58 function workorderPDF($db, $orientation='P', $unit='mm', $format='Letter'){ 59 60 $this->invoicePDF($db, $orientation, $unit, $format); 61 62 }//end method 63 64 65 function _addNotes(){ 66 67 $pdf = &$this->pdf; 68 69 $height = 1; 70 $nextPos = $pdf->GetY() + $height + 0.125; 71 72 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 73 $pdf->setStyle("header"); 74 $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Special Instructions", 1, 2, "L", 1); 75 76 $pdf->setStyle("normal"); 77 $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); 78 $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->invoicerecord["specialinstructions"]); 79 80 $pdf->SetXY($pdf->leftmargin, $nextPos); 81 82 }//end method 83 84 function _addPaymentDetails(){ 85 86 $pdf = &$this->pdf; 87 88 $columns = array(); 89 $columns[] = new pdfColumn("Payment Method", "paymentname", 0); 90 91 switch($this->invoicerecord["paymenttype"]){ 92 93 case "draft": 94 $columns[0]->size = 1.5; 95 $columns[] = new pdfColumn("Check Number", "checkno", 1); 96 $columns[] = new pdfColumn("Bank Name", "bankname", 2); 97 break; 98 99 case "charge": 100 $columns[0]->size = 1.5; 101 $columns[] = new pdfColumn("Number", "ccnumber", 1.5); 102 $columns[] = new pdfColumn("Exp.", "ccexpiration", 1); 103 $columns[] = new pdfColumn("Verification/Pin", "ccverification", 1); 104 break; 105 106 }//end switch 107 108 $size = 0; 109 foreach($columns as $column) 110 $size += $column->size; 111 112 $i = count($columns) -1; 113 114 $columns[$i]->size += $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 115 116 $height = 0.5; 117 $nextPos = $pdf->GetY() + $height + 0.125; 118 119 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 120 121 $pdf->setStyle("header"); 122 123 foreach($columns as $column) 124 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 125 126 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); 127 128 $pdf->setStyle("normal"); 129 $pdf->SetFont("Arial", "B", 10); 130 foreach($columns as $column) 131 $pdf->Cell($column->size, 0.18, $this->invoicerecord[$column->fieldname], $pdf->borderDebug, 0, $column->align); 132 133 }//end method 134 135 }//end class 136 137 138 //PROCESSING 139 //============================================================================= 39 if(!class_exists("invoicePDF")) 40 include("invoices_pdf_class.php"); 41 42 class workorderPDF extends invoicePDF{ 43 44 var $lineitemBoxHeight = 3.75; 45 46 47 function workorderPDF($db, $reportUUID, $tabledefUUID, $orientation='P', $unit='mm', $format='Letter'){ 48 49 $this->invoicePDF($db, $reportUUID, $tabledefUUID, $orientation, $unit, $format); 50 51 }//end method 52 53 54 /** 55 * function checkForDefaultSettings 56 * 57 * Checks to make sure loaded report Settings exist and are correct 58 */ 59 function checkForDefaultSettings(){ 60 61 if(!isset($this->settings["reportTitle"])) 62 $this->settings["reportTitle"] = "Work Order"; 63 64 parent::checkForDefaultSettings(); 65 66 }//end function checkForDefaultSettings 67 68 69 function _addNotes(){ 70 71 $pdf = &$this->pdf; 72 73 $height = 1; 74 $nextPos = $pdf->GetY() + $height + 0.125; 75 76 if(!$this->settings["templateFormatting"]){ 77 78 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 79 $pdf->setStyle("header"); 80 $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Special Instructions", 1, 2, "L", 1); 81 82 }else 83 $pdf->SetY($pdf->GetY() + 0.18); 84 85 $pdf->setStyle("normal"); 86 $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); 87 $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->invoicerecord["specialinstructions"]); 88 89 $pdf->SetXY($pdf->leftmargin, $nextPos); 90 91 }//end method 92 93 function _addPaymentDetails(){ 94 95 $pdf = &$this->pdf; 96 97 $columns = array(); 98 $columns[] = new pdfColumn("Payment Method", "paymentname", 0); 99 100 switch($this->invoicerecord["paymenttype"]){ 101 102 case "draft": 103 $columns[0]->size = 1.5; 104 $columns[] = new pdfColumn("Check Number", "checkno", 1); 105 $columns[] = new pdfColumn("Bank Name", "bankname", 2); 106 break; 107 108 case "charge": 109 $columns[0]->size = 1.5; 110 $columns[] = new pdfColumn("Number", "ccnumber", 1.5); 111 $columns[] = new pdfColumn("Exp.", "ccexpiration", 1); 112 $columns[] = new pdfColumn("Verification/Pin", "ccverification", 1); 113 break; 114 115 }//end switch 116 117 $size = 0; 118 foreach($columns as $column) 119 $size += $column->size; 120 121 $i = count($columns) -1; 122 123 $columns[$i]->size += $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 124 125 $height = 0.5; 126 $nextPos = $pdf->GetY() + $height + 0.125; 127 128 if(!$this->settings["templateFormatting"]){ 129 130 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 131 132 $pdf->setStyle("header"); 133 134 foreach($columns as $column) 135 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 136 137 }//endif 138 139 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); 140 141 $pdf->setStyle("normal"); 142 $pdf->SetFont("Arial", "B", 10); 143 foreach($columns as $column) 144 $pdf->Cell($column->size, 0.18, $this->invoicerecord[$column->fieldname], $pdf->borderDebug, 0, $column->align); 145 146 }//end method 147 148 /** 149 * function addingRecordDefaultSettings 150 * 151 * Creates an array of settings associative arrays for use by the system when 152 * a new report record is added that references the file containing this class 153 * 154 * @retrun array of settings. Each setting should itself be 155 * an associative array containing the following 156 * name: name of the setting 157 * defaultvalue: default value for setting 158 * type: (string, int, real, bool) type for value of setting 159 * required: (0,1) whether the setting is required or not 160 * description: brief description for what this setting is used for. 161 */ 162 function addingRecordDefaultSettings(){ 163 164 $settings = parent::addingRecordDefaultSettings(); 165 166 for($i=0; $i< count($settings); $i++){ 167 168 switch($settings[$i]["name"]){ 169 170 case "reportTitle": 171 $settings[$i]["defaultValue"] = "Work Order"; 172 173 }//endswitch 174 175 }//end foreach 176 177 return $settings; 178 179 }//endfunction addingRecordDefaultSettings 180 181 }//end class 182 183 184 /** 185 * PROCESSING 186 * ============================================================================= 187 */ 140 188 if(!isset($noOutput)){ 141 189 142 $report = new workorderPDF($db, 'P', 'in', 'Letter'); 143 144 $report->setupFromPrintScreen(); 145 $report->generate(); 146 $filename = 'Work_Order'; 147 if($report->count === 1){ 148 149 if($report->invoicerecord["company"]) 150 $filename .= "_".$report->invoicerecord["company"]; 151 152 $filename .= "_".$report->invoicerecord["id"]; 153 154 }elseif((int)$report->count) 155 $filename .= "_Multiple"; 156 157 $filename .= ".pdf"; 158 $report->output('screen', $filename); 190 //IE needs caching to be set to private in order to display PDFS 191 session_cache_limiter('private'); 192 193 //set encoding to latin1 (fpdf doesnt like utf8) 194 $sqlEncoding = "latin1"; 195 require_once("../../../include/session.php"); 196 197 checkForReportArguments(); 198 199 $report = new workorderPDF($db, $_GET["rid"], $_GET["tid"], 'P', 'in', 'Letter'); 200 201 $report->setupFromPrintScreen(); 202 $report->generate(); 203 204 $filename = 'Work_Order'; 205 206 if($report->count === 1){ 207 208 if($report->invoicerecord["company"]) 209 $filename .= "_".$report->invoicerecord["company"]; 210 211 $filename .= "_".$report->invoicerecord["id"]; 212 213 }elseif((int)$report->count) 214 $filename .= "_Multiple"; 215 216 $filename .= ".pdf"; 217 218 $report->output('screen', $filename); 159 219 160 220 }//end if 161 221 222 /** 223 * When adding a new report record, the add/edit needs to know what the class 224 * name is so that it can instantiate it, and grab it's default settings. 225 */ 226 if(isset($addingReportRecord)) 227 $reportClass ="workorderPDF"; 162 228 ?> -
trunk/phpbms/modules/bms/report/invoices_pdf_class.php
r673 r693 38 38 */ 39 39 40 if(!class_exists("phpbmsReport")) 41 include("report/report_class.php"); 42 43 class invoicePDF extends phpbmsReport{ 44 45 var $title = "Invoice"; 46 var $showShipNameInShipTo = true; 47 var $lineitemBoxHeight = 4.25; 48 49 /** 50 * $count 51 * @var int The number of invoice records being displayed 52 */ 53 var $count; 54 55 function invoicePDF($db, $orientation='P', $unit='mm', $format='Letter'){ 56 57 $this->db = $db; 58 59 if(!class_exists("phpbmsPDFReport")) 60 include("report/pdfreport_class.php"); 61 62 $this->pdf = new phpbmsPDFReport($db, $orientation, $unit, $format); 63 64 $this->initialize(); 65 66 }//end method 67 68 69 function initialize(){ 70 //This function will set column headings, sizes and formatting 71 72 $pdf = &$this->pdf; 73 74 $topinfo = array(); 75 $topinfo[] = new pdfColumn("Order ID", "id", 0.75); 76 $topinfo[] = new pdfColumn("Order Date", "orderdate", 1, "date"); 77 $topinfo[] = new pdfColumn("Client PO", "ponumber", 1); 78 $topinfo[] = new pdfColumn("Processed By", "processedby", 0); 79 $topinfo[] = new pdfColumn("Payment Method", "paymentname",2); 80 81 $size = 0; 82 foreach($topinfo as $column) 83 $size += $column->size; 84 85 $topinfo[3]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 86 87 $this->topinfo = $topinfo; 88 89 90 $lineitems = array(); 91 $lineitems[] = new pdfColumn("Product / (Part Number)", "parts", 0); 92 $lineitems[] = new pdfColumn("Tax", "taxable", 0.5, "boolean", "C"); 93 $lineitems[] = new pdfColumn("Unit Price", "unitprice", 0.75, "currency", "R"); 94 $lineitems[] = new pdfColumn("Qty", "quantity", 0.5, "real","R"); 95 $lineitems[] = new pdfColumn("Extended", "extended", 0.75, "currency", "R"); 96 97 $size = 0; 98 foreach($lineitems as $column) 99 $size += $column->size; 100 101 $lineitems[0]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 102 103 $this->lineitems = $lineitems; 104 105 $totalsinfo = array(); 106 $totalsinfo[] = new pdfColumn("Discount", "discountamount", 1, "currency", "R"); 107 $totalsinfo[] = new pdfColumn("Subtotal", "totaltni", 0, "currency", "R"); 108 $totalsinfo[] = new pdfColumn("Tax", "tax", 1, "currency", "R"); 109 $totalsinfo[] = new pdfColumn("Shipping", "shipping", 1, "currency", "R"); 110 $totalsinfo[] = new pdfColumn("Total", "totalti", 1, "currency", "R"); 111 $totalsinfo[] = new pdfColumn("Due", "amountdue", 1, "currency", "R"); 112 113 $this->totalsinfo = $totalsinfo; 114 115 }//end method 116 117 118 function generate($whereclause = NULL, $sortorder = "invoices.id"){ 119 120 $pdf = &$this->pdf; 121 122 if($whereclause) 123 $this->whereclause = $whereclause; 124 elseif(!$this->whereclause) 125 $this->whereclause = "invoices.id = -400"; 126 127 if($sortorder) 128 $this->sortorder = $sortorder; 129 elseif(!$this->sortorder) 130 $this->sortorder = "invoices.id"; 131 132 $paymentFields = ""; 133 if(ENCRYPT_PAYMENT_FIELDS){ 134 135 $paymentFields = " 136 ".$this->db->decrypt("`ccnumber`")." AS `ccnumber`, 137 ".$this->db->decrypt("`ccverification`")." AS `ccverification`, 138 ".$this->db->decrypt("`ccexpiration`")." AS `ccexpiration`, 139 ".$this->db->decrypt("`routingnumber`")." AS `routingnumber`, 140 ".$this->db->decrypt("`accountnumber`")." AS `accountnumber`, 141 "; 142 143 }//end if 144 145 $querystatement = " 146 SELECT 147 invoices.*, 148 ".$paymentFields." 149 150 invoices.totalti - invoices.amountpaid AS amountdue, 151 152 clients.firstname, 153 clients.lastname, 154 clients.company, 155 clients.homephone, 156 clients.workphone, 157 clients.email, 158 159 shippingmethods.name AS shippingname, 160 161 paymentmethods.name AS paymentname, 162 paymentmethods.type AS paymenttype, 163 164 tax.name as taxname, 165 166 users.firstname AS processorfirst, 167 users.lastname AS processorlast 168 169 FROM 170 invoices INNER JOIN clients ON invoices.clientid = clients.uuid 171 INNER JOIN users ON invoices.modifiedby = users.id 172 LEFT JOIN shippingmethods ON invoices.shippingmethodid = shippingmethods.uuid 173 LEFT JOIN paymentmethods ON invoices.paymentmethodid = paymentmethods.uuid 174 LEFT JOIN tax ON invoices.taxareaid = tax.uuid"; 175 176 $querystatement = $this->assembleSQL($querystatement); 177 $queryresult = $this->db->query($querystatement); 178 179 $this->count = $this->db->numRows($queryresult); 180 if($this->count == 0){ 181 182 $this->_showNoRecords(); 183 exit; 184 185 }//end if 186 187 188 $pdf->hasComapnyHeader = true; 189 $pdf->SetMargins(); 190 191 //iterate through each invoice record 192 while($invoicerecord = $this->db->fetchArray($queryresult)){ 193 194 $this->page = 0; 195 196 $this->invoicerecord = $invoicerecord; 197 198 //adds top info 199 $top = $this->_addPage(); 200 201 $this->_addLineItems($top); 202 203 $pdf->SetXY($pdf->leftmargin, $top["y"] + $this->lineitemBoxHeight + 0.125); 204 205 //Print any special/instructions and stuff 206 $this->_addNotes(); 207 208 //totals 209 $this->_addTotals(); 210 211 //payment details 212 $this->_addPaymentDetails(); 213 214 }//end while; 215 216 217 }//end method 218 219 220 function _addPage(){ 221 222 $pdf = &$this->pdf; 223 224 225 $pdf->AddPage(); 226 $this->page++; 227 228 $nextY = $pdf->getY(); 229 230 //TITLE 231 $title = "Statement"; 232 $titleWidth=2.375; 233 $titleHeight=.25; 234 $pdf->setStyle("title"); 235 $pdf->SetXY(-1*($titleWidth+$pdf->rightmargin), $pdf->topmargin); 236 $pdf->Cell($titleWidth, $titleHeight,$this->title, $pdf->borderDebug,1,"R"); 237 238 $startY = $pdf->GetY() + 0.75; 239 240 //page number? 241 $pdf->setStyle("normal"); 242 $pageNoWidth = 1; 243 $pdf->SetFontSize(8); 244 $pdf->SetXY(-1*($pageNoWidth + $pdf->rightmargin), $pdf->topmargin + $titleHeight + 0.25); 245 $pdf->Cell($pageNoWidth, 0.17, "page: ".$this->page, $pdf->borderDebug,1,"R"); 246 247 248 //SOLD TO 249 $boxHeight = 1.75; 250 $boxWidth = ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin)/2 -0.0625; 251 252 $pdf->setLineWidth(0.02); 253 $pdf->Rect($pdf->leftmargin, $startY, $boxWidth, $boxHeight); 254 $pdf->setLineWidth(0.01); 255 256 $pdf->setStyle("header"); 257 $pdf->setY($startY); 258 $pdf->Cell($boxWidth, 0.17, "SOLD TO", $pdf->borderDebug, 2, "L", 1); 259 $pdf->setStyle("normal"); 260 261 //Company Name 262 $companyDisplay = ""; 263 if($this->invoicerecord["company"]){ 264 $companyDisplay .= $this->invoicerecord["company"]; 265 if($this->invoicerecord["firstname"]) 266 $companyDisplay .= " (".$this->invoicerecord["firstname"]." ".$this->invoicerecord["lastname"].")"; 267 } else 268 $companyDisplay .= $this->invoicerecord["firstname"]." ".$this->invoicerecord["lastname"]; 269 270 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 271 $pdf->SetFont("Arial", "B", 10); 272 $pdf->Cell($boxWidth - 0.125, 0.17, $companyDisplay, $pdf->borderDebug, 2, "L"); 273 274 $billto = $this->_setBillTo(); 275 $pdf->SetFont("Arial", "", 10); 276 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 277 $pdf->MultiCell($boxWidth - 0.125,.17,$billto, $pdf->borderDebug); 278 279 //SHIP TO 280 $pdf->setLineWidth(0.02); 281 $pdf->Rect($pdf->leftmargin + $boxWidth + 0.125, $startY, $boxWidth, $boxHeight); 282 $pdf->setLineWidth(0.01); 283 284 $pdf->setStyle("header"); 285 $pdf->setXY($pdf->leftmargin + $boxWidth + 0.125, $startY); 286 $pdf->Cell($boxWidth, 0.17, "SHIP TO", $pdf->borderDebug, 2, "L", 1); 287 $pdf->setStyle("normal"); 288 289 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 290 $pdf->SetFont("Arial", "B", 10); 291 292 $shipDisplay = (!$this->invoicerecord["shiptosameasbilling"] && $this->invoicerecord["shiptoname"])? $this->invoicerecord["shiptoname"] :$companyDisplay; 293 $pdf->Cell($boxWidth - 0.125, 0.17, $shipDisplay, $pdf->borderDebug, 2, "L"); 294 295 $shipto = $this->_setShipTo(); 296 $pdf->SetFont("Arial", "", 10); 297 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 298 $pdf->MultiCell($boxWidth - 0.125,.17, $shipto, $pdf->borderDebug); 299 300 $pdf->setXY($pdf->leftmargin, $startY + $boxHeight + 0.125); 301 302 $this->_topInvoiceInfo(); 303 304 //line item headings 305 $pdf->setStyle("header"); 306 $pdf->SetLineWidth(0.02); 307 308 $coords["x"] = $pdf->GetX(); 309 $coords["y"] = $pdf->GetY(); 310 311 foreach($this->lineitems as $column) 312 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 313 314 return $coords; 315 316 }//end method 317 318 319 function _setBillTo(){ 320 321 $billto = $this->invoicerecord["address1"]; 322 323 if($this->invoicerecord["address2"]) 324 $billto .= "\n".$this->invoicerecord["address2"]; 325 326 $billto .="\n".$this->invoicerecord["city"].", ".$this->invoicerecord["state"]." ".$this->invoicerecord["postalcode"]; 327 328 if($this->invoicerecord["country"]) 329 $billto .=" ".$this->invoicerecord["country"]; 330 331 $phoneemail = ""; 332 if($this->invoicerecord["workphone"] || $this->invoicerecord["homephone"]){ 333 334 if($this->invoicerecord["workphone"]) 335 $phoneemail = $this->invoicerecord["workphone"]." (W)"; 336 else 337 $phoneemail = $this->invoicerecord["homephone"]." (H)"; 338 339 $phoneemail.="\n"; 340 341 }//end if 342 343 if($this->invoicerecord["email"]) 344 $phoneemail .= $this->invoicerecord["email"]; 345 346 if($phoneemail) 347 $billto .= "\n\n".$phoneemail; 348 349 return $billto; 350 351 }//end method 352 353 354 function _setShipTo(){ 355 356 $added = ($this->invoicerecord["shiptosameasbilling"])? "" : "shipto"; 357 358 $shipto = ""; 359 360 $shipto .= $this->invoicerecord[$added."address1"]; 361 362 if($this->invoicerecord[$added."address2"]) 363 $shipto .= "\n".$this->invoicerecord[$added."address2"]; 364 365 $shipto .="\n".$this->invoicerecord[$added."city"].", ".$this->invoicerecord[$added."state"]." ".$this->invoicerecord[$added."postalcode"]; 366 367 if($this->invoicerecord[$added."country"]) 368 $shipto .=" ".$this->invoicerecord[$added."country"]; 369 370 if($this->showShipNameInShipTo) 371 if($this->invoicerecord["shippingname"]) 372 $shipto .="\n\nShipping Method:\n".$this->invoicerecord["shippingname"]; 373 374 return $shipto; 375 376 }//end method 377 378 379 function _topInvoiceInfo(){ 380 381 $pdf = &$this->pdf; 382 383 $pdf->setStyle("header"); 384 $pdf->SetLineWidth(0.02); 385 386 foreach($this->topinfo as $column) 387 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 388 389 $pdf->Rect($pdf->leftmargin, $pdf->GetY(), ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin), 0.39); 390 391 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + .2); 392 393 394 $this->invoicerecord["processedby"] = $this->invoicerecord["processorfirst"]." ".$this->invoicerecord["processorlast"]; 395 $pdf->setStyle("normal"); 396 397 foreach($this->topinfo as $column){ 398 399 if($column->format != "") 400 $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); 401 else 402 $value = $this->invoicerecord[$column->fieldname]; 403 404 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 405 406 }//end foreach 407 408 $pdf->SetY($pdf->GetY() + 0.18 + 0.125); 409 410 }//end method 411 412 413 function _addLineItems($coords){ 414 415 $pdf = &$this->pdf; 416 417 $lineitemresult = $this->_getLineItems(); 418 419 $pdf->setStyle("normal"); 420 421 $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); 422 423 while($line = $this->db->fetchArray($lineitemresult)){ 424 425 426 if($line["partname"] || $line["partnumber"] || $line["extended"]){ 427 428 if($pdf->GetY() + 0.17*3 > $coords["y"] + $this->lineitemBoxHeight){ 429 430 $pdf->SetLineWidth(0.02); 431 $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); 432 $pdf->SetLineWidth(0.01); 433 434 $this->_addPage(); 435 436 $pdf->setStyle("normal"); 437 438 $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); 439 440 }//end if 441 442 foreach($this->lineitems as $column){ 443 444 $ln = 0; 445 446 447 switch($column->fieldname){ 448 449 case "parts": 450 $pdf->SetFont("Arial", "B", 8); 451 $pdf->Write(0.17, $line["partname"]); 452 $pdf->setStyle("normal"); 453 $pdf->SetX($pdf->leftmargin + $column->size); 454 break; 455 456 default: 457 if($column->format != "") 458 $value = formatVariable($line[$column->fieldname], $column->format); 459 else 460 $value = $line[$column->fieldname]; 461 462 if($value == "·") 463 $value = " "; 464 if($column->fieldname == $this->lineitems[count($this->lineitems)-1]->fieldname) 465 $ln = 2; 466 467 $pdf->Cell($column->size, 0.17, $value, $pdf->borderDebug, $ln, $column->align); 468 break; 469 470 }//end switch 471 472 }//end foreach 473 474 $pdf->SetX($pdf->leftmargin); 475 $pdf->Write(0.17, "(".$line["partnumber"].")"); 476 $pdf->Ln(); 477 478 }//endif 479 480 if($line["memo"]){ 481 482 $pdf->SetX($pdf->leftmargin + 0.0625); 483 $pdf->SetFont("Arial", "I", 8); 484 $pdf->MultiCell($this->lineitems[0]->size - 0.0625, 0.16, $line["memo"], $pdf->borderDebug); 485 $pdf->setStyle("normal"); 486 487 }//end if 488 489 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); 490 $pdf->SetLineWidth(0.01); 491 $pdf->SetDrawColor(180,180,180); 492 $pdf->Line($pdf->leftmargin, $pdf->GetY(), $pdf->paperwidth - $pdf->rightmargin, $pdf->GetY()); 493 $pdf->SetDrawColor(0,0,0); 494 $pdf->SetLineWidth(0.02); 495 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); 496 497 }//end while 498 499 $pdf->SetLineWidth(0.02); 500 $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); 501 502 }//end method 503 504 505 function _getLineItems(){ 506 507 $querystatement = " 508 SELECT 509 lineitems.*, 510 lineitems.quantity * lineitems.unitprice AS extended, 511 products.partname, 512 products.partnumber 513 FROM 514 lineitems LEFT JOIN products ON lineitems.productid = products.uuid 515 WHERE 516 lineitems.invoiceid ='".((int) $this->invoicerecord["id"])."' 517 ORDER BY 518 displayorder"; 519 520 $queryresult = $this->db->query($querystatement); 521 522 return $queryresult; 523 524 }//end method 525 526 527 function _addNotes(){ 528 529 $pdf = &$this->pdf; 530 531 $height = 1; 532 $nextPos = $pdf->GetY() + $height + 0.125; 533 534 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 535 $pdf->setStyle("header"); 536 $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Notes/Instructions", 1, 2, "L", 1); 537 538 $pdf->setStyle("normal"); 539 $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); 540 $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->invoicerecord["printedinstructions"]); 541 542 $pdf->SetXY($pdf->leftmargin, $nextPos); 543 544 }//end method 545 546 547 function _addTotals(){ 548 549 $pdf = &$this->pdf; 550 551 $size = 0; 552 foreach($this->totalsinfo as $column) 553 switch($column->fieldname){ 554 case "shipping": 555 case "discountamount": 556 if($this->invoicerecord[$column->fieldname]) 557 $size += $column->size; 558 break; 559 default: 560 $size += $column->size; 561 }//endswitch 562 $this->totalsinfo[1]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 563 564 $height = .5; 565 $nextPos = $pdf->GetY() + $height + 0.125; 566 567 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 568 569 $pdf->setStyle("header"); 570 foreach($this->totalsinfo as $column) 571 switch($column->fieldname){ 572 case "shipping": 573 case "discountamount": 574 if($this->invoicerecord[$column->fieldname]) 575 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 576 break; 577 default: 578 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 579 }//endswitch 580 581 $pdf->setStyle("normal"); 582 $pdf->SetFont("Arial", "B", 10); 583 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); 584 585 foreach($this->totalsinfo as $column){ 586 587 if($column->format != "") 588 $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); 589 else 590 $value = $this->invoicerecord[$column->fieldname]; 591 592 switch($column->fieldname){ 593 case "shipping": 594 case "discountamount": 595 if($this->invoicerecord[$column->fieldname]) 596 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 597 break; 598 default: 599 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 600 }//endswitch 601 }//end foreach 602 $this->totalsinfo[1]->size = 0; 603 604 $pdf->SetXY($pdf->leftmargin, $nextPos); 605 606 }//end method 607 608 609 function _addPaymentDetails(){ 610 }//end method 611 612 613 function output($destination = "screen" , $userinfo = NULL){ 614 615 switch($destination){ 616 617 case "screen": 618 $userinfo = cleanFilename((string)$userinfo); 619 $this->pdf->Output($userinfo, 'D'); 620 break; 621 622 case "email": 623 624 if(!$userinfo) 625 $userinfo = $_SESSION["userinfo"]; 626 627 if(!$userinfo["email"] || !$this->invoicerecord["email"]) 628 return false; 629 630 $pdf = $this->pdf->Output(NULL, "S"); 631 632 $to = $this->invoicerecord["email"]; 633 $from = $userinfo["email"]; 634 $subject = "Your ".$this->title." from ".COMPANY_NAME; 635 $message = "Attached is your ".$this->title." from ".COMPANY_NAME."\n\n" . 636 "The attachment requires Adobe Acrobat Reader to view. \n If you do not " . 637 "have Acrobat Reader, you can download it at http://www.adobe.com \n\n" . 638 COMPANY_NAME."\n". 639 COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; 640 641 $headers = "From: $from"; 642 643 $semi_rand = md5( time() ); 644 $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 645 646 $headers .= "\nMIME-Version: 1.0\n" . 647 "Content-Type: multipart/mixed;\n" . 648 " boundary=\"{$mime_boundary}\""; 649 650 $message = "This is a multi-part message in MIME format.\n\n" . 651 "--{$mime_boundary}\n" . 652 "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 653 "Content-Transfer-Encoding: 7bit\n\n" . 654 $message . "\n\n"; 655 656 $pdf = chunk_split( base64_encode( $pdf ) ); 657 658 $message .= "--{$mime_boundary}\n" . 659 "Content-Type: {application/pdf};\n" . 660 " name=\"".$this->title.$this->invoicerecord["id"].".pdf\"\n" . 661 "Content-Disposition: attachment;\n" . 662 " filename=\"".$this->title.$this->invoicerecord["id"].".pdf\"\n" . 663 "Content-Transfer-Encoding: base64\n\n" . 664 $pdf . "\n\n" . 665 "--{$mime_boundary}--\n"; 666 667 return @ mail($to, $subject, $message, $headers); 668 669 break; 670 671 }//endswitch 672 673 }//end method 674 675 }//end class 40 if(!class_exists("phpbmsReport")) 41 include("../../../report/report_class.php"); 42 43 class invoicePDF extends phpbmsReport{ 44 45 var $showShipNameInShipTo = true; 46 var $lineitemBoxHeight = 4.25; 47 var $templateUUID = NULL; 48 49 /** 50 * $count 51 * @var int The number of invoice records being displayed 52 */ 53 var $count; 54 55 56 function invoicePDF($db, $reportUUID, $tabledefUUID, $orientation='P', $unit='mm', $format='Letter'){ 57 58 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 59 60 if(!class_exists("phpbmsPDFReport")) 61 include("report/pdfreport_class.php"); 62 63 $this->pdf = new phpbmsPDFReport($db, $orientation, $unit, $format); 64 65 $this->checkForDefaultSettings(); 66 $this->initialize(); 67 68 }//end method 69 70 71 /** 72 * function checkForDefaultSettings 73 * 74 * Checks to make sure loaded report Settings exist and are correct 75 */ 76 function checkForDefaultSettings(){ 77 78 if(!isset($this->settings["reportTitle"])) 79 $this->settings["reportTitle"] = "Invoice"; 80 81 if(!isset($this->settings["printLogo"])) 82 $this->settings["printLogo"] = 1; 83 84 if(!isset($this->settings["printCompanyInfo"])) 85 $this->settings["printCompanyInfo"] = 1; 86 87 if(!isset($this->settings["leftTopBox"])) 88 $this->settings["leftTopBox"] = "billto"; 89 90 if(!isset($this->settings["leftTopBoxTitle"])) 91 $this->settings["leftTopBoxTitle"] = "SOLD TO"; 92 93 if(!isset($this->settings["rightTopBox"])) 94 $this->settings["rightTopBox"] = "shipto"; 95 96 if(!isset($this->settings["rightTopBoxTitle"])) 97 $this->settings["rightTopBoxTitle"] = "SHIP TO"; 98 99 if(!isset($this->settings["templateFormatting"])) 100 $this->settings["templateFormatting"] = 0; 101 102 if(!isset($this->settings["templateUUID"])) 103 $this->settings["templateUUID"] = ""; 104 105 }//end function checkForDefaultSettings 106 107 108 function initialize(){ 109 //This function will set column headings, sizes and formatting 110 111 $pdf = &$this->pdf; 112 113 $topinfo = array(); 114 $topinfo[] = new pdfColumn("Order ID", "id", 0.75); 115 $topinfo[] = new pdfColumn("Order Date", "orderdate", 1, "date"); 116 $topinfo[] = new pdfColumn("Client PO", "ponumber", 1); 117 $topinfo[] = new pdfColumn("Processed By", "processedby", 0); 118 $topinfo[] = new pdfColumn("Payment Method", "paymentname",2); 119 120 $size = 0; 121 foreach($topinfo as $column) 122 $size += $column->size; 123 124 $topinfo[3]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 125 126 $this->topinfo = $topinfo; 127 128 129 $lineitems = array(); 130 $lineitems[] = new pdfColumn("Product / (Part Number)", "parts", 0); 131 $lineitems[] = new pdfColumn("Tax", "taxable", 0.5, "boolean", "C"); 132 $lineitems[] = new pdfColumn("Unit Price", "unitprice", 0.75, "currency", "R"); 133 $lineitems[] = new pdfColumn("Qty", "quantity", 0.5, "real","R"); 134 $lineitems[] = new pdfColumn("Extended", "extended", 0.75, "currency", "R"); 135 136 $size = 0; 137 foreach($lineitems as $column) 138 $size += $column->size; 139 140 $lineitems[0]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 141 142 $this->lineitems = $lineitems; 143 144 $totalsinfo = array(); 145 $totalsinfo[] = new pdfColumn("Discount", "discountamount", 1, "currency", "R"); 146 $totalsinfo[] = new pdfColumn("Subtotal", "totaltni", 0, "currency", "R"); 147 $totalsinfo[] = new pdfColumn("Tax", "tax", 1, "currency", "R"); 148 $totalsinfo[] = new pdfColumn("Shipping", "shipping", 1, "currency", "R"); 149 $totalsinfo[] = new pdfColumn("Total", "totalti", 1, "currency", "R"); 150 $totalsinfo[] = new pdfColumn("Due", "amountdue", 1, "currency", "R"); 151 152 $this->totalsinfo = $totalsinfo; 153 154 }//end method 155 156 157 function generate($whereclause = NULL, $sortorder = "invoices.id"){ 158 159 $pdf = &$this->pdf; 160 161 if($whereclause) 162 $this->whereClause = $whereclause; 163 elseif(!$this->whereClause) 164 $this->whereClause = "invoices.id = -400"; 165 166 if($sortorder) 167 $this->sortOrder = $sortorder; 168 elseif(!$this->sortOrder) 169 $this->sortOrder = "invoices.id"; 170 171 $paymentFields = ""; 172 if(ENCRYPT_PAYMENT_FIELDS){ 173 174 $paymentFields = " 175 ".$this->db->decrypt("`ccnumber`")." AS `ccnumber`, 176 ".$this->db->decrypt("`ccverification`")." AS `ccverification`, 177 ".$this->db->decrypt("`ccexpiration`")." AS `ccexpiration`, 178 ".$this->db->decrypt("`routingnumber`")." AS `routingnumber`, 179 ".$this->db->decrypt("`accountnumber`")." AS `accountnumber`, 180 "; 181 182 }//end if 183 184 $querystatement = " 185 SELECT 186 invoices.*, 187 ".$paymentFields." 188 189 invoices.totalti - invoices.amountpaid AS amountdue, 190 191 clients.firstname, 192 clients.lastname, 193 clients.company, 194 clients.homephone, 195 clients.workphone, 196 clients.email, 197 198 shippingmethods.name AS shippingname, 199 200 paymentmethods.name AS paymentname, 201 paymentmethods.type AS paymenttype, 202 203 tax.name as taxname, 204 205 users.firstname AS processorfirst, 206 users.lastname AS processorlast 207 208 FROM 209 invoices INNER JOIN clients ON invoices.clientid = clients.uuid 210 INNER JOIN users ON invoices.modifiedby = users.id 211 LEFT JOIN shippingmethods ON invoices.shippingmethodid = shippingmethods.uuid 212 LEFT JOIN paymentmethods ON invoices.paymentmethodid = paymentmethods.uuid 213 LEFT JOIN tax ON invoices.taxareaid = tax.uuid"; 214 215 $querystatement = $this->assembleSQL($querystatement); 216 217 $queryresult = $this->db->query($querystatement); 218 219 $this->count = $this->db->numRows($queryresult); 220 if($this->count == 0){ 221 222 $this->showNoRecords(); 223 exit; 224 225 }//end if 226 227 $pdf->logoInHeader = $this->settings["printLogo"]; 228 $pdf->companyInfoInHeader = $this->settings["printCompanyInfo"]; 229 230 $pdf->SetMargins(); 231 232 //iterate through each invoice record 233 while($invoicerecord = $this->db->fetchArray($queryresult)){ 234 235 $this->page = 0; 236 237 $this->invoicerecord = $invoicerecord; 238 239 //adds top info 240 $top = $this->_addPage(); 241 242 $this->_addLineItems($top); 243 244 $pdf->SetXY($pdf->leftmargin, $top["y"] + $this->lineitemBoxHeight + 0.125); 245 246 //Print any special/instructions and stuff 247 $this->_addNotes(); 248 249 //totals 250 $this->_addTotals(); 251 252 //payment details 253 $this->_addPaymentDetails(); 254 255 }//end while; 256 257 258 }//end method 259 260 261 function _addPage(){ 262 263 $pdf = &$this->pdf; 264 265 $pdf->AddPage(); 266 267 if($this->settings["templateUUID"]){ 268 269 if(!isset($GLOBALS["pdfDoc"])){ 270 271 $querystatement = " 272 SELECT 273 `file` 274 FROM 275 `files` 276 WHERE 277 `uuid` = '".$this->settings["templateUUID"]."'"; 278 279 $queryresult = $this->db->query($querystatement); 280 281 $therecord = $this->db->fetchArray($queryresult); 282 283 $GLOBALS["pdfDoc"] = $therecord["file"]; 284 $pdf->setSourceFile("global://pdfDoc"); 285 $this->tplIdx = $pdf->importPage(1); 286 287 }//endif 288 289 $pdf->useTemplate($this->tplIdx); 290 291 }//endif 292 293 294 $this->page++; 295 296 $nextY = $pdf->getY(); 297 298 //TITLE 299 $title = "Statement"; 300 $titleWidth=2.375; 301 $titleHeight=.25; 302 $pdf->setStyle("title"); 303 $pdf->SetXY(-1*($titleWidth+$pdf->rightmargin), $pdf->topmargin); 304 $pdf->Cell($titleWidth, $titleHeight, $this->settings["reportTitle"], $pdf->borderDebug,1,"R"); 305 306 $startY = $pdf->GetY() + 0.75; 307 308 //page number? 309 $pdf->setStyle("normal"); 310 $pageNoWidth = 1; 311 $pdf->SetFontSize(8); 312 $pdf->SetXY(-1*($pageNoWidth + $pdf->rightmargin), $pdf->topmargin + $titleHeight + 0.25); 313 $pdf->Cell($pageNoWidth, 0.17, "page: ".$this->page, $pdf->borderDebug,1,"R"); 314 315 $boxHeight = 1.75; 316 $boxWidth = ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin)/2 -0.0625; 317 318 //Left Top Box 319 $this->_addTopBox($this->settings["leftTopBox"], $this->settings["leftTopBoxTitle"], $pdf->leftmargin, $startY, $boxWidth, $boxHeight); 320 321 //Right Top Box 322 $this->_addTopBox($this->settings["rightTopBox"], $this->settings["rightTopBoxTitle"], $pdf->leftmargin + $boxWidth + 0.125, $startY, $boxWidth, $boxHeight); 323 324 $pdf->setXY($pdf->leftmargin, $startY + $boxHeight + 0.125); 325 326 $this->_topInvoiceInfo(); 327 328 329 $coords["x"] = $pdf->GetX(); 330 $coords["y"] = $pdf->GetY(); 331 332 if(!$this->settings["templateFormatting"]){ 333 334 //line item headings 335 $pdf->setStyle("header"); 336 $pdf->SetLineWidth(0.02); 337 338 foreach($this->lineitems as $column) 339 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 340 341 }//endif 342 343 return $coords; 344 345 }//end method 346 347 348 function _addTopBox($areaToPrint, $title, $x, $y, $boxWidth, $boxHeight){ 349 350 if($areaToPrint != "noshow"){ 351 352 $pdf = &$this->pdf; 353 354 if(!$this->settings["templateFormatting"]){ 355 356 $pdf->setLineWidth(0.02); 357 $pdf->Rect($x, $y, $boxWidth, $boxHeight); 358 $pdf->setLineWidth(0.01); 359 360 $pdf->setStyle("header"); 361 $pdf->setXY($x, $y); 362 $pdf->Cell($boxWidth, 0.17, $title, $pdf->borderDebug, 2, "L", 1); 363 $pdf->setStyle("normal"); 364 365 } else 366 $pdf->SetXY($x ,$y + 0.17); 367 368 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 369 370 switch($areaToPrint){ 371 372 case "billto": 373 374 $companyDisplay = ""; 375 if($this->invoicerecord["company"]){ 376 377 $companyDisplay .= $this->invoicerecord["company"]; 378 if($this->invoicerecord["firstname"]) 379 $companyDisplay .= " (".$this->invoicerecord["firstname"]." ".$this->invoicerecord["lastname"].")"; 380 381 } else 382 $companyDisplay .= $this->invoicerecord["firstname"]." ".$this->invoicerecord["lastname"]; 383 384 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 385 $pdf->SetFont("Arial", "B", 10); 386 $pdf->Cell($boxWidth - 0.125, 0.17, $companyDisplay, $pdf->borderDebug, 2, "L"); 387 388 $billto = $this->_setBillTo(); 389 $pdf->SetFont("Arial", "", 10); 390 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 391 $pdf->MultiCell($boxWidth - 0.125,.17,$billto, $pdf->borderDebug); 392 break; 393 394 case "shipto": 395 396 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 397 $pdf->SetFont("Arial", "B", 10); 398 399 $shipDisplay = (!$this->invoicerecord["shiptosameasbilling"] && $this->invoicerecord["shiptoname"])? $this->invoicerecord["shiptoname"] :$companyDisplay; 400 $pdf->Cell($boxWidth - 0.125, 0.17, $shipDisplay, $pdf->borderDebug, 2, "L"); 401 402 $shipto = $this->_setShipTo(); 403 $pdf->SetFont("Arial", "", 10); 404 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 405 $pdf->MultiCell($boxWidth - 0.125,.17, $shipto, $pdf->borderDebug); 406 break; 407 408 case "companyinfo": 409 410 $cname = COMPANY_NAME; 411 $caddress = COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; 412 413 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 414 $pdf->SetFont("Arial","B",10); 415 $pdf->Cell($boxWidth - 0.125, 0.17, $cname, $pdf->borderDebug, 2, "L"); 416 417 //and last, company address 418 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 419 $pdf->SetFont("Arial", "", 10); 420 $pdf->MultiCell($boxWidth - 0.125,.17 , $caddress, $pdf->borderDebug); 421 break; 422 423 case "invoiceinfo": 424 425 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 426 $pdf->SetFont("Arial","B",14); 427 $pdf->Cell($boxWidth - 0.125, 0.25, $this->invoicerecord["id"], $pdf->borderDebug, 2, "R"); 428 429 430 $details = "payment method\n".$this->invoicerecord["paymentname"]; 431 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.125); 432 $pdf->SetFont("Arial", "", 8); 433 $pdf->MultiCell($boxWidth - 0.125,.17, $details, $pdf->borderDebug, "R"); 434 435 break; 436 437 }//endswitch 438 439 }//endif 440 441 }//end function _addTopBox 442 443 444 function _setBillTo(){ 445 446 $billto = $this->invoicerecord["address1"]; 447 448 if($this->invoicerecord["address2"]) 449 $billto .= "\n".$this->invoicerecord["address2"]; 450 451 $billto .="\n".$this->invoicerecord["city"].", ".$this->invoicerecord["state"]." ".$this->invoicerecord["postalcode"]; 452 453 if($this->invoicerecord["country"]) 454 $billto .=" ".$this->invoicerecord["country"]; 455 456 $phoneemail = ""; 457 if($this->invoicerecord["workphone"] || $this->invoicerecord["homephone"]){ 458 459 if($this->invoicerecord["workphone"]) 460 $phoneemail = $this->invoicerecord["workphone"]." (W)"; 461 else 462 $phoneemail = $this->invoicerecord["homephone"]." (H)"; 463 464 $phoneemail.="\n"; 465 466 }//end if 467 468 if($this->invoicerecord["email"]) 469 $phoneemail .= $this->invoicerecord["email"]; 470 471 if($phoneemail) 472 $billto .= "\n\n".$phoneemail; 473 474 return $billto; 475 476 }//end method 477 478 479 function _setShipTo(){ 480 481 $added = ($this->invoicerecord["shiptosameasbilling"])? "" : "shipto"; 482 483 $shipto = ""; 484 485 $shipto .= $this->invoicerecord[$added."address1"]; 486 487 if($this->invoicerecord[$added."address2"]) 488 $shipto .= "\n".$this->invoicerecord[$added."address2"]; 489 490 $shipto .="\n".$this->invoicerecord[$added."city"].", ".$this->invoicerecord[$added."state"]." ".$this->invoicerecord[$added."postalcode"]; 491 492 if($this->invoicerecord[$added."country"]) 493 $shipto .=" ".$this->invoicerecord[$added."country"]; 494 495 if($this->showShipNameInShipTo) 496 if($this->invoicerecord["shippingname"]) 497 $shipto .="\n\nShipping Method:\n".$this->invoicerecord["shippingname"]; 498 499 return $shipto; 500 501 }//end method 502 503 504 function _topInvoiceInfo(){ 505 506 $pdf = &$this->pdf; 507 508 if(!$this->settings["templateFormatting"]){ 509 510 $pdf->setStyle("header"); 511 $pdf->SetLineWidth(0.02); 512 513 foreach($this->topinfo as $column) 514 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 515 516 $pdf->Rect($pdf->leftmargin, $pdf->GetY(), ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin), 0.39); 517 518 }//endif 519 520 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + .2); 521 522 523 $this->invoicerecord["processedby"] = $this->invoicerecord["processorfirst"]." ".$this->invoicerecord["processorlast"]; 524 $pdf->setStyle("normal"); 525 526 foreach($this->topinfo as $column){ 527 528 if($column->format != "") 529 $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); 530 else 531 $value = $this->invoicerecord[$column->fieldname]; 532 533 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 534 535 }//end foreach 536 537 $pdf->SetY($pdf->GetY() + 0.18 + 0.125); 538 539 }//end method 540 541 542 function _addLineItems($coords){ 543 544 $pdf = &$this->pdf; 545 546 $lineitemresult = $this->_getLineItems(); 547 548 $pdf->setStyle("normal"); 549 550 $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); 551 552 while($line = $this->db->fetchArray($lineitemresult)){ 553 554 555 if($line["partname"] || $line["partnumber"] || $line["extended"]){ 556 557 if($pdf->GetY() + 0.17*3 > $coords["y"] + $this->lineitemBoxHeight){ 558 559 if(!$this->settings["templateFormatting"]){ 560 561 $pdf->SetLineWidth(0.02); 562 $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); 563 $pdf->SetLineWidth(0.01); 564 565 }//endif 566 567 $this->_addPage(); 568 569 $pdf->setStyle("normal"); 570 571 $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); 572 573 }//end if 574 575 foreach($this->lineitems as $column){ 576 577 $ln = 0; 578 579 580 switch($column->fieldname){ 581 582 case "parts": 583 $pdf->SetFont("Arial", "B", 8); 584 $pdf->Write(0.17, $line["partname"]); 585 $pdf->setStyle("normal"); 586 $pdf->SetX($pdf->leftmargin + $column->size); 587 break; 588 589 default: 590 if($column->format != "") 591 $value = formatVariable($line[$column->fieldname], $column->format); 592 else 593 $value = $line[$column->fieldname]; 594 595 if($value == "·") 596 $value = " "; 597 if($column->fieldname == $this->lineitems[count($this->lineitems)-1]->fieldname) 598 $ln = 2; 599 600 $pdf->Cell($column->size, 0.17, $value, $pdf->borderDebug, $ln, $column->align); 601 break; 602 603 }//end switch 604 605 }//end foreach 606 607 $pdf->SetX($pdf->leftmargin); 608 $pdf->Write(0.17, "(".$line["partnumber"].")"); 609 $pdf->Ln(); 610 611 }//endif 612 613 if($line["memo"]){ 614 615 $pdf->SetX($pdf->leftmargin + 0.0625); 616 $pdf->SetFont("Arial", "I", 8); 617 $pdf->MultiCell($this->lineitems[0]->size - 0.0625, 0.16, $line["memo"], $pdf->borderDebug); 618 $pdf->setStyle("normal"); 619 620 }//end if 621 622 if(!$this->settings["templateFormatting"]){ 623 624 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); 625 $pdf->SetLineWidth(0.01); 626 $pdf->SetDrawColor(180,180,180); 627 $pdf->Line($pdf->leftmargin, $pdf->GetY(), $pdf->paperwidth - $pdf->rightmargin, $pdf->GetY()); 628 $pdf->SetDrawColor(0,0,0); 629 $pdf->SetLineWidth(0.02); 630 631 }//endif 632 633 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); 634 635 }//end while 636 637 if(!$this->settings["templateFormatting"]){ 638 639 $pdf->SetLineWidth(0.02); 640 $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); 641 $pdf->SetLineWidth(0.01); 642 643 }//endif 644 645 }//end method 646 647 648 function _getLineItems(){ 649 650 $querystatement = " 651 SELECT 652 lineitems.*, 653 lineitems.quantity * lineitems.unitprice AS extended, 654 products.partname, 655 products.partnumber 656 FROM 657 lineitems LEFT JOIN products ON lineitems.productid = products.uuid 658 WHERE 659 lineitems.invoiceid ='".((int) $this->invoicerecord["id"])."' 660 ORDER BY 661 displayorder"; 662 663 $queryresult = $this->db->query($querystatement); 664 665 return $queryresult; 666 667 }//end method 668 669 670 function _addNotes(){ 671 672 $pdf = &$this->pdf; 673 674 $height = 1; 675 $nextPos = $pdf->GetY() + $height + 0.125; 676 677 if(!$this->settings["templateFormatting"]){ 678 679 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 680 $pdf->setStyle("header"); 681 $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Notes/Instructions", 1, 2, "L", 1); 682 $pdf->setStyle("normal"); 683 684 } else 685 $pdf->SetY($pdf->GetY() + 0.18); 686 687 $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); 688 $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->invoicerecord["printedinstructions"]); 689 690 $pdf->SetXY($pdf->leftmargin, $nextPos); 691 692 }//end method 693 694 695 function _addTotals(){ 696 697 $pdf = &$this->pdf; 698 699 $size = 0; 700 foreach($this->totalsinfo as $column) 701 switch($column->fieldname){ 702 case "shipping": 703 case "discountamount": 704 if($this->invoicerecord[$column->fieldname]) 705 $size += $column->size; 706 break; 707 default: 708 $size += $column->size; 709 }//endswitch 710 $this->totalsinfo[1]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 711 712 $height = .5; 713 $nextPos = $pdf->GetY() + $height + 0.125; 714 715 if(!$this->settings["templateFormatting"]){ 716 717 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 718 719 $pdf->setStyle("header"); 720 foreach($this->totalsinfo as $column) 721 switch($column->fieldname){ 722 723 case "shipping": 724 case "discountamount": 725 if($this->invoicerecord[$column->fieldname]) 726 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 727 break; 728 729 default: 730 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 731 732 }//endswitch 733 734 }//endif 735 736 $pdf->setStyle("normal"); 737 $pdf->SetFont("Arial", "B", 10); 738 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); 739 740 foreach($this->totalsinfo as $column){ 741 742 if($column->format != "") 743 $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); 744 else 745 $value = $this->invoicerecord[$column->fieldname]; 746 747 switch($column->fieldname){ 748 case "shipping": 749 case "discountamount": 750 if($this->invoicerecord[$column->fieldname]) 751 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 752 break; 753 default: 754 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 755 }//endswitch 756 }//end foreach 757 $this->totalsinfo[1]->size = 0; 758 759 $pdf->SetXY($pdf->leftmargin, $nextPos); 760 761 }//end method 762 763 764 function _addPaymentDetails(){ 765 }//end method 766 767 768 function output($destination = "screen" , $userinfo = NULL){ 769 770 switch($destination){ 771 772 case "screen": 773 $userinfo = cleanFilename((string)$userinfo); 774 $this->pdf->Output($userinfo, 'D'); 775 break; 776 777 case "email": 778 779 if(!$userinfo) 780 $userinfo = $_SESSION["userinfo"]; 781 782 if(!$userinfo["email"] || !$this->invoicerecord["email"]) 783 return false; 784 785 $pdf = $this->pdf->Output(NULL, "S"); 786 787 $to = $this->invoicerecord["email"]; 788 $from = $userinfo["email"]; 789 $subject = "Your ".$this->title." from ".COMPANY_NAME; 790 $message = "Attached is your ".$this->title." from ".COMPANY_NAME."\n\n" . 791 "The attachment requires Adobe Acrobat Reader to view. \n If you do not " . 792 "have Acrobat Reader, you can download it at http://www.adobe.com \n\n" . 793 COMPANY_NAME."\n". 794 COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; 795 796 $headers = "From: $from"; 797 798 $semi_rand = md5( time() ); 799 $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 800 801 $headers .= "\nMIME-Version: 1.0\n" . 802 "Content-Type: multipart/mixed;\n" . 803 " boundary=\"{$mime_boundary}\""; 804 805 $message = "This is a multi-part message in MIME format.\n\n" . 806 "--{$mime_boundary}\n" . 807 "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 808 "Content-Transfer-Encoding: 7bit\n\n" . 809 $message . "\n\n"; 810 811 $pdf = chunk_split( base64_encode( $pdf ) ); 812 813 $message .= "--{$mime_boundary}\n" . 814 "Content-Type: {application/pdf};\n" . 815 " name=\"".$this->title.$this->invoicerecord["id"].".pdf\"\n" . 816 "Content-Disposition: attachment;\n" . 817 " filename=\"".$this->title.$this->invoicerecord["id"].".pdf\"\n" . 818 "Content-Transfer-Encoding: base64\n\n" . 819 $pdf . "\n\n" . 820 "--{$mime_boundary}--\n"; 821 822 return @ mail($to, $subject, $message, $headers); 823 824 break; 825 826 }//endswitch 827 828 }//end method 829 830 831 /** 832 * function addingRecordDefaultSettings 833 * 834 * Creates an array of settings associative arrays for use by the system when 835 * a new report record is added that references the file containing this class 836 * 837 * @retrun array of settings. Each setting should itself be 838 * an associative array containing the following 839 * name: name of the setting 840 * defaultvalue: default value for setting 841 * type: (string, int, real, bool) type for value of setting 842 * required: (0,1) whether the setting is required or not 843 * description: brief description for what this setting is used for. 844 */ 845 function addingRecordDefaultSettings(){ 846 847 $settings[] = array( 848 "name"=>"reportTitle", 849 "defaultValue"=>"Invoice", 850 "type"=>"string", 851 "required"=>1, 852 "description"=>"Title printed on reports" 853 ); 854 855 $settings[] = array( 856 "name"=>"printLogo", 857 "defaultValue"=>1, 858 "type"=>"bool", 859 "required"=>1, 860 "description"=>"Should the logo print (1 = yes, 0 = no)" 861 ); 862 863 $settings[] = array( 864 "name"=>"printCompanyInfo", 865 "defaultValue"=>1, 866 "type"=>"bool", 867 "required"=>1, 868 "description"=>"Should the top company information print (1 = yes, 0 = no)" 869 ); 870 871 $settings[] = array( 872 "name"=>"leftTopBox", 873 "defaultValue"=>"billto", 874 "type"=>"string", 875 "required"=>1, 876 "description"=>"Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)" 877 ); 878 879 $settings[] = array( 880 "name"=>"leftTopBoxTitle", 881 "defaultValue"=>"SOLD TO", 882 "type"=>"string", 883 "required"=>1, 884 "description"=>"Title of Left Top Header Box" 885 ); 886 887 $settings[] = array( 888 "name"=>"rightTopBox", 889 "defaultValue"=>"shipto", 890 "type"=>"string", 891 "required"=>1, 892 "description"=>"Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)" 893 ); 894 895 $settings[] = array( 896 "name"=>"rightTopBoxTitle", 897 "defaultValue"=>"SHIP TO", 898 "type"=>"string", 899 "required"=>1, 900 "description"=>"Title of Right Top Header Box" 901 ); 902 903 $settings[] = array( 904 "name"=>"templateFormatting", 905 "defaultValue"=>"0", 906 "type"=>"bool", 907 "required"=>1, 908 "description"=>"Should PDF remove lines and dark titles (1 = remove, 0 = keep)" 909 ); 910 911 $settings[] = array( 912 "name"=>"templateUUID", 913 "defaultValue"=>"", 914 "type"=>"string", 915 "required"=>0, 916 "description"=>"Optional UUID of file record for PDF to be used as background template" 917 ); 918 919 return $settings; 920 921 }//endfunction addingRecordDefaultSettings 922 923 }//end class 676 924 677 925 -
trunk/phpbms/modules/bms/report/invoices_totals.php
r611 r693 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 40 require("../../../include/session.php"); 41 42 class totalReport{ 43 44 var $selectcolumns; 45 var $selecttable; 46 var $whereclause=""; 47 var $group=""; 48 var $showinvoices=false; 49 var $showlineitems=false; 50 var $padamount=20; 51 52 function totalReport($db,$variables = NULL){ 53 $this->db = $db; 54 55 // first we define the available groups 56 $this->addGroup("Invoice Date - Year","YEAR(invoices.invoicedate)"); //0 57 $this->addGroup("Invoice Date - Quarter","QUARTER(invoices.invoicedate)"); //1 58 $this->addGroup("Invoice Date - Month","MONTH(invoices.invoicedate)"); //2 59 $this->addGroup("Invoice Date","invoices.invoicedate","date"); //3 60 61 $this->addGroup("Order Date - Year","YEAR(invoices.orderdate)"); //4 62 $this->addGroup("Order Date - Quarter","QUARTER(invoices.orderdate)");//5 63 $this->addGroup("Order Date - Month","MONTH(invoices.orderdate)");//6 64 $this->addGroup("Order Date","invoices.orderdate","date");//7 65 66 $this->addGroup("Required Date - Year","YEAR(invoices.requireddate)");//8 67 $this->addGroup("Required Date - Quarter","QUARTER(invoices.requireddate)");//9 68 $this->addGroup("Required Date - Month","MONTH(invoices.requireddate)");//10 69 $this->addGroup("Required Date","invoices.requireddate","date");//11 70 71 $this->addGroup("Client","if(clients.lastname!='',concat(clients.lastname,', ',clients.firstname,if(clients.company!='',concat(' (',clients.company,')'),'')),clients.company)");//12 72 73 $this->addGroup("Client Sales Person","concat(salesPerson.firstname,' ',salesPerson.lastname)",NULL, "LEFT JOIN users AS salesPerson ON clients.salesmanagerid = salesPerson.uuid");//13 74 75 $this->addGroup("Client Lead Source","clients.leadsource");//14 76 77 $this->addGroup("Invoice Lead Source","invoices.leadsource");//15 78 79 $this->addGroup("Payment Method","paymentmethods.name");//16 80 81 $this->addGroup("Shipping Method","shippingmethods.name");//17 82 $this->addGroup("Invoice Shipping Country","invoices.shiptocountry");//18 83 $this->addGroup("Invoice Shipping State / Province","invoices.shiptostate");//19 84 $this->addGroup("Invoice Shipping Postal Code","invoices.shiptopostalcode");//20 85 $this->addGroup("Invoice Shipping City","invoices.shiptocity");//21 86 87 $this->addGroup("Web Order","invoices.weborder","boolean");//22 88 89 $this->addGroup("Invoice billing Country","invoices.country");//23 90 $this->addGroup("Invoice Billing State / Province","invoices.state");//24 91 $this->addGroup("Invoice Billing Postal Code","invoices.postalcode");//25 92 $this->addGroup("Invoice Billing City","invoices.city");//26 93 94 95 //next we do the columns 96 $this->addColumn("Record Count","count(invoices.id)");//0 97 $this->addColumn("Invoice Total","sum(invoices.totalti)","currency");//1 98 $this->addColumn("Average Invoice Total","avg(invoices.totalti)","currency");//2 99 100 $this->addColumn("Subtotal","sum(invoices.totaltni)","currency");//3 101 $this->addColumn("Average Subtotal","avg(invoices.totaltni)","currency");//4 102 103 $this->addColumn("Tax","sum(invoices.tax)","currency");//5 104 $this->addColumn("Average Tax","avg(invoices.tax)","currency");//6 105 106 $this->addColumn("Shipping","sum(invoices.shipping)","currency");//7 107 $this->addColumn("Average Shipping","avg(invoices.shipping)","currency");//8 108 109 $this->addColumn("Amount Paid","sum(invoices.amountpaid)","currency");//9 110 $this->addColumn("Average Amount Paid","avg(invoices.amountpaid)","currency");//10 111 112 $this->addColumn("Amount Due","sum(invoices.totalti - invoices.amountpaid)","currency");//11 113 $this->addColumn("Average Amount Due","avg(invoices.totalti - invoices.amountpaid)","currency");//12 114 115 $this->addColumn("Cost","sum(invoices.totalcost)","currency");//13 116 $this->addColumn("Average Cost","avg(invoices.totalcost)","currency");//14 117 118 $this->addColumn("Total Weight","sum(invoices.totalweight)","real");//15 119 $this->addColumn("Average Total Weight","avg(invoices.totalweight)","real");//16 120 121 122 if($variables){ 123 $tempArray = explode("::", $variables["columns"]); 124 125 foreach($tempArray as $id) 126 $this->selectcolumns[] = $this->columns[$id]; 127 $this->selectcolumns = array_reverse($this->selectcolumns); 128 129 $this->selecttable="((`invoices` INNER JOIN `clients` ON `invoices`.`clientid`=`clients`.`uuid`) LEFT JOIN `shippingmethods` ON `shippingmethods`.`uuid` = `invoices`.`shippingmethodid`) LEFT JOIN `paymentmethods` ON `paymentmethods`.`id`=`invoices`.`paymentmethodid`"; 130 131 if($variables["groupings"] !== ""){ 132 $this->group = explode("::",$variables["groupings"]); 133 $this->group = array_reverse($this->group); 134 } else 135 $this->group = array(); 136 137 foreach($this->group as $grp){ 138 if($this->groupings[$grp]["table"]) 139 $this->selecttable="(".$this->selecttable." ".$this->groupings[$grp]["table"].")"; 140 } 141 142 $this->whereclause=$_SESSION["printing"]["whereclause"]; 143 if($this->whereclause=="") $this->whereclause="WHERE invoices.id!=-1"; 144 145 switch($variables["showwhat"]){ 146 case "invoices": 147 $this->showinvoices = true; 148 $this->showlineitems = false; 149 break; 150 151 case "lineitems": 152 $this->showinvoices = true; 153 $this->showlineitems = true; 154 break; 155 156 default: 157 $this->showinvoices = false; 158 $this->showlineitems = false; 159 }// endswitch 160 161 if($this->whereclause!="") $this->whereclause=" WHERE (".substr($this->whereclause,6).") "; 162 }// endif 39 if(!class_exists("phpbmsReport")) 40 include("../../../report/report_class.php"); 41 42 class totalReport extends phpbmsReport{ 43 44 var $selectcolumns; 45 var $selecttable; 46 var $group = ""; 47 var $showinvoices = false; 48 var $showlineitems = false; 49 var $padamount = 20; 50 var $title = "Totals"; 51 52 function totalReport($db, $reportUUID, $tabledefUUID, $variables = NULL){ 53 54 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 55 56 // first we define the available groups 57 $this->addGroup("Invoice Date - Year","YEAR(invoices.invoicedate)"); //0 58 $this->addGroup("Invoice Date - Quarter","QUARTER(invoices.invoicedate)"); //1 59 $this->addGroup("Invoice Date - Month","MONTH(invoices.invoicedate)"); //2 60 $this->addGroup("Invoice Date","invoices.invoicedate","date"); //3 61 62 $this->addGroup("Order Date - Year","YEAR(invoices.orderdate)"); //4 63 $this->addGroup("Order Date - Quarter","QUARTER(invoices.orderdate)");//5 64 $this->addGroup("Order Date - Month","MONTH(invoices.orderdate)");//6 65 $this->addGroup("Order Date","invoices.orderdate","date");//7 66 67 $this->addGroup("Required Date - Year","YEAR(invoices.requireddate)");//8 68 $this->addGroup("Required Date - Quarter","QUARTER(invoices.requireddate)");//9 69 $this->addGroup("Required Date - Month","MONTH(invoices.requireddate)");//10 70 $this->addGroup("Required Date","invoices.requireddate","date");//11 71 72 $this->addGroup("Client","if(clients.lastname!='',concat(clients.lastname,', ',clients.firstname,if(clients.company!='',concat(' (',clients.company,')'),'')),clients.company)");//12 73 74 $this->addGroup("Client Sales Person","concat(salesPerson.firstname,' ',salesPerson.lastname)",NULL, "LEFT JOIN users AS salesPerson ON clients.salesmanagerid = salesPerson.uuid");//13 75 76 $this->addGroup("Client Lead Source","clients.leadsource");//14 77 78 $this->addGroup("Invoice Lead Source","invoices.leadsource");//15 79 80 $this->addGroup("Payment Method","paymentmethods.name");//16 81 82 $this->addGroup("Shipping Method","shippingmethods.name");//17 83 $this->addGroup("Invoice Shipping Country","invoices.shiptocountry");//18 84 $this->addGroup("Invoice Shipping State / Province","invoices.shiptostate");//19 85 $this->addGroup("Invoice Shipping Postal Code","invoices.shiptopostalcode");//20 86 $this->addGroup("Invoice Shipping City","invoices.shiptocity");//21 87 88 $this->addGroup("Web Order","invoices.weborder","boolean");//22 89 90 $this->addGroup("Invoice billing Country","invoices.country");//23 91 $this->addGroup("Invoice Billing State / Province","invoices.state");//24 92 $this->addGroup("Invoice Billing Postal Code","invoices.postalcode");//25 93 $this->addGroup("Invoice Billing City","invoices.city");//26 94 95 96 //next we do the columns 97 $this->addColumn("Record Count","count(invoices.id)");//0 98 $this->addColumn("Invoice Total","sum(invoices.totalti)","currency");//1 99 $this->addColumn("Average Invoice Total","avg(invoices.totalti)","currency");//2 100 101 $this->addColumn("Subtotal","sum(invoices.totaltni)","currency");//3 102 $this->addColumn("Average Subtotal","avg(invoices.totaltni)","currency");//4 103 104 $this->addColumn("Tax","sum(invoices.tax)","currency");//5 105 $this->addColumn("Average Tax","avg(invoices.tax)","currency");//6 106 107 $this->addColumn("Shipping","sum(invoices.shipping)","currency");//7 108 $this->addColumn("Average Shipping","avg(invoices.shipping)","currency");//8 109 110 $this->addColumn("Amount Paid","sum(invoices.amountpaid)","currency");//9 111 $this->addColumn("Average Amount Paid","avg(invoices.amountpaid)","currency");//10 112 113 $this->addColumn("Amount Due","sum(invoices.totalti - invoices.amountpaid)","currency");//11 114 $this->addColumn("Average Amount Due","avg(invoices.totalti - invoices.amountpaid)","currency");//12 115 116 $this->addColumn("Cost","sum(invoices.totalcost)","currency");//13 117 $this->addColumn("Average Cost","avg(invoices.totalcost)","currency");//14 118 119 $this->addColumn("Total Weight","sum(invoices.totalweight)","real");//15 120 $this->addColumn("Average Total Weight","avg(invoices.totalweight)","real");//16 121 122 $this->selecttable="((`invoices` INNER JOIN `clients` ON `invoices`.`clientid`=`clients`.`uuid`) 123 LEFT JOIN `shippingmethods` ON `shippingmethods`.`uuid` = `invoices`.`shippingmethodid`) 124 LEFT JOIN `paymentmethods` ON `paymentmethods`.`id`=`invoices`.`paymentmethodid`"; 125 163 126 }//end method 164 127 165 128 129 function processFromPost($variables){ 130 131 $tempArray = explode("::", $variables["columns"]); 132 133 foreach($tempArray as $id) 134 $this->selectcolumns[] = $this->columns[$id]; 135 136 $this->selectcolumns = array_reverse($this->selectcolumns); 137 138 if($variables["groupings"] !== ""){ 139 140 $this->group = explode("::",$variables["groupings"]); 141 $this->group = array_reverse($this->group); 142 143 } else 144 $this->group = array(); 145 146 foreach($this->group as $grp) 147 if($this->groupings[$grp]["table"]) 148 $this->selecttable="(".$this->selecttable." ".$this->groupings[$grp]["table"].")"; 149 150 switch($variables["showwhat"]){ 151 152 case "invoices": 153 $this->showinvoices = true; 154 $this->showlineitems = false; 155 break; 156 157 case "lineitems": 158 $this->showinvoices = true; 159 $this->showlineitems = true; 160 break; 161 162 default: 163 $this->showinvoices = false; 164 $this->showlineitems = false; 165 166 }// endswitch 167 168 if($variables["reporttitle"]) 169 $this->title = $variables["reporttitle"]; 170 171 }//end function processFromPost 172 173 174 function processFromSettings(){ 175 176 foreach($this->settings as $key=>$value) 177 if(strpos($key, "column") === 0) 178 $this->selectcolumns[substr($key,6)-1] = $this->columns[$value]; 179 180 ksort($this->selectcolumns); 181 $this->selectcolumns = array_reverse($this->selectcolumns); 182 183 $this->group = array(); 184 185 foreach($this->settings as $key=>$value) 186 if(strpos($key, "group") === 0) 187 $this->group[substr($key,5)-1] = $value; 188 189 ksort($this->group); 190 $this->group = array_reverse($this->group); 191 192 foreach($this->group as $grp) 193 if($this->groupings[$grp]["table"]) 194 $this->selecttable="(".$this->selecttable." ".$this->groupings[$grp]["table"].")"; 195 196 197 if(isset($this->settings["showWhat"])) 198 $showWhat = $this->settings["showWhat"]; 199 else 200 $showWhat = ""; 201 202 switch($showWhat){ 203 204 case "invoices": 205 $this->showinvoices = true; 206 $this->showlineitems = false; 207 break; 208 209 case "lineitems": 210 $this->showinvoices = true; 211 $this->showlineitems = true; 212 break; 213 214 default: 215 $this->showinvoices = false; 216 $this->showlineitems = false; 217 218 }// endswitch 219 220 if(isset($this->settings["reportTitle"])) 221 $this->title = $this->settings["reportTitle"]; 222 223 }//end function processFromSettings 224 225 166 226 function addGroup($name, $field, $format = NULL, $tableAddition = NULL){ 167 $temp = array(); 168 $temp["name"] = $name; 169 $temp["field"] = $field; 170 $temp["format"] = $format; 171 $temp["table"] = $tableAddition; 172 173 $this->groupings[] = $temp; 227 228 $temp = array(); 229 $temp["name"] = $name; 230 $temp["field"] = $field; 231 $temp["format"] = $format; 232 $temp["table"] = $tableAddition; 233 234 $this->groupings[] = $temp; 235 174 236 }//end method 175 237 176 238 177 239 function addColumn($name, $field, $format = NULL){ 178 $temp = array(); 179 $temp["name"] = $name; 180 $temp["field"] = $field; 181 $temp["format"] = $format; 182 183 $this->columns[] = $temp; 240 241 $temp = array(); 242 $temp["name"] = $name; 243 $temp["field"] = $field; 244 $temp["format"] = $format; 245 246 $this->columns[] = $temp; 247 184 248 }//end method 185 249 186 250 187 251 function showReportTable(){ 252 188 253 ?><table border="0" cellspacing="0" cellpadding="0"> 189 254 <tr> … … 207 272 $querystatement.=$thecolumn["field"]." AS `".$thecolumn["name"]."`,"; 208 273 $querystatement.=" count(invoices.id) as thecount "; 209 $querystatement.=" FROM ".$this->selecttable.$this->where clause;274 $querystatement.=" FROM ".$this->selecttable.$this->whereClause; 210 275 $queryresult=$this->db->query($querystatement); 211 276 … … 236 301 $querystatement.=$thecolumn["field"]." AS `".$thecolumn["name"]."`,"; 237 302 $querystatement .= $this->groupings[$groupby]["field"]." AS thegroup, count(invoices.id) as thecount "; 238 $querystatement .= " FROM ".$this->selecttable.$this->where clause.$where." GROUP BY ".$this->groupings[$groupby]["field"];303 $querystatement .= " FROM ".$this->selecttable.$this->whereClause.$where." GROUP BY ".$this->groupings[$groupby]["field"]; 239 304 $queryresult=$this->db->query($querystatement); 240 305 … … 288 353 $querystatement.=" invoices.id as theid, if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) as thename, 289 354 invoices.orderdate,invoices.invoicedate"; 290 $querystatement.=" FROM ".$this->selecttable.$this->where clause.$where." GROUP BY invoices.id";355 $querystatement.=" FROM ".$this->selecttable.$this->whereClause.$where." GROUP BY invoices.id"; 291 356 $queryresult=$this->db->query($querystatement); 292 357 … … 370 435 function showReport(){ 371 436 372 if($_POST["reporttitle"]) 373 $pageTitle = $_POST["reporttitle"]; 374 else 375 $pageTitle = "Invoice Totals"; 376 437 if(!$this->whereClause) 438 $this->whereClause = "invoices.id!=-1"; 439 440 $this->whereClause = " WHERE ".$this->whereClause; 441 442 $pageTitle = $this->title; 377 443 378 444 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> … … 427 493 <div class="bodyline"> 428 494 <h1>Invoice Total Options</h1> 429 <form id="GroupForm" action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" name="GroupForm">495 <form id="GroupForm" action="<?php echo str_replace("&", "&", $_SERVER["REQUEST_URI"]) ?>" method="post" name="GroupForm"> 430 496 431 497 <fieldset> … … 495 561 }//end method 496 562 497 }//endclass 498 499 // Processing =================================================================================================================== 500 if(!isset($dontProcess)){ 501 if(isset($_POST["columns"])){ 502 $myreport= new totalReport($db,$_POST); 503 $myreport->showReport(); 504 } else { 505 $myreport = new totalReport($db); 506 $myreport->showSelectScreen(); 507 } 508 }?> 563 }//end class totalReport 564 565 566 /** 567 * PROCESSING 568 * ============================================================================= 569 */ 570 if(!isset($noOutput)){ 571 572 require("../../../include/session.php"); 573 574 checkForReportArguments(); 575 576 $report = new totalReport($db, $_GET["rid"], $_GET["tid"]); 577 578 if(isset($_POST["columns"])){ 579 580 $report->setupFromPrintScreen(); 581 $report->processFromPost($_POST); 582 $report->showReport(); 583 584 } elseif(isset($report->settings["column1"])){ 585 586 $report->setupFromPrintScreen(); 587 $report->processFromSettings(); 588 $report->showReport(); 589 590 } else { 591 592 $report->showSelectScreen(); 593 594 }//endif 595 596 }//endif 597 598 /** 599 * When adding a new report record, the add/edit needs to know what the class 600 * name is so that it can instantiate it, and grab it's default settings. 601 */ 602 if(isset($addingReportRecord)) 603 $reportClass ="totalReport"; 604 605 ?> -
trunk/phpbms/modules/bms/report/lineitems_totals.php
r611 r693 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 40 require("../../../include/session.php");41 42 class totalReport {39 if(!class_exists("phpbmsReport")) 40 include("../../../report/report_class.php"); 41 42 class totalReport extends phpbmsReport{ 43 43 44 44 var $selectcolumns; 45 45 var $selecttable; 46 var $whereclause=""; 47 var $group=""; 48 var $showinvoices=false; 49 var $showlineitems=false; 50 var $padamount=20; 51 52 function totalReport($db,$variables = NULL){ 53 $this->db = $db; 54 55 // first we define the available groups 56 $this->addGroup("Invoice ID","invoices.id"); //0 57 $this->addGroup("Product","concat(products.partnumber,' - ',products.partname)"); //1 58 $this->addGroup("Product Category","concat(productcategories.id,' - ',productcategories.name)",NULL,"INNER JOIN productcategories ON products.categoryid=productcategories.uuid"); //2 59 60 $this->addGroup("Invoice Date - Year","YEAR(invoices.invoicedate)"); //3 61 $this->addGroup("Invoice Date - Quarter","QUARTER(invoices.invoicedate)"); //4 62 $this->addGroup("Invoice Date - Month","MONTH(invoices.invoicedate)"); //5 63 $this->addGroup("Invoice Date","invoices.invoicedate","date"); //6 64 65 $this->addGroup("Order Date - Year","YEAR(invoices.orderdate)"); //7 66 $this->addGroup("Order Date - Quarter","QUARTER(invoices.orderdate)");//8 67 $this->addGroup("Order Date - Month","MONTH(invoices.orderdate)");//9 68 $this->addGroup("Order Date","invoices.orderdate","date");//10 69 70 $this->addGroup("Client","if(clients.lastname!='',concat(clients.lastname,', ',clients.firstname,if(clients.company!='',concat(' (',clients.company,')'),'')),clients.company)");//11 71 72 $this->addGroup("Client Sales Person","concat(salesPerson.firstname,' ',salesPerson.lastname)",NULL, "LEFT JOIN users AS salesPerson ON clients.salesmanagerid = salesPerson.id");//12 73 74 $this->addGroup("Client Lead Source","clients.leadsource");//13 75 76 $this->addGroup("Invoice Lead Source","invoices.leadsource");//14 77 78 $this->addGroup("Payment Method","paymentmethods.name");//15 79 80 $this->addGroup("Shipping Method","shippingmethods.name");//16 81 $this->addGroup("Invoice Shipping Country","invoices.shiptocountry");//17 82 $this->addGroup("Invoice Shipping State / Province","invoices.shiptostate");//18 83 $this->addGroup("Invoice Shipping Postal Code","invoices.shiptopostalcode");//19 84 $this->addGroup("Invoice Shipping City","invoices.shiptocity");//20 85 86 $this->addGroup("Web Order","invoices.weborder","boolean");//21 87 88 $this->addGroup("Invoice billing Country","invoices.country");//22 89 $this->addGroup("Invoice Billing State / Province","invoices.state");//23 90 $this->addGroup("Invoice Billing Postal Code","invoices.postalcode");//24 91 $this->addGroup("Invoice Billing City","invoices.city");//25 92 93 //next we do the columns 94 $this->addColumn("Record Count","count(lineitems.id)");//0 95 $this->addColumn("Extended Price","sum(lineitems.unitprice*lineitems.quantity)","currency");//1 96 $this->addColumn("Average Extended Price","avg(lineitems.unitprice*lineitems.quantity)","currency");//2 97 $this->addColumn("Unit Price","sum(lineitems.unitprice)","currency");//3 98 $this->addColumn("Average Unit Price","avg(lineitems.unitprice)","currency");//4 99 $this->addColumn("Quantity","sum(lineitems.quantity)","real");//5 100 $this->addColumn("Average Quantity","avg(lineitems.quantity)","real");//6 101 $this->addColumn("Unit Cost","sum(lineitems.unitcost)","currency");//7 102 $this->addColumn("Average Unit Cost","avg(lineitems.unitcost)","currency");//8 103 $this->addColumn("Extended Cost","sum(lineitems.unitcost*lineitems.quantity)","currency");//9 104 $this->addColumn("Average Extended Cost","avg(lineitems.unitcost*lineitems.quantity)","currency");//10 105 $this->addColumn("Unit Weight","sum(lineitems.unitweight)","real");//11 106 $this->addColumn("Average Unit Weight","avg(lineitems.unitweight)","real");//12 107 $this->addColumn("Extended Unit Weight","sum(lineitems.unitweight*lineitems.quantity)","real");//13 108 $this->addColumn("Extended Average Unit Weight","avg(lineitems.unitweight*lineitems.quantity)","real");//14 109 110 111 if($variables){ 112 $tempArray = explode("::", $variables["columns"]); 113 114 foreach($tempArray as $id) 115 $this->selectcolumns[] = $this->columns[$id]; 116 $this->selectcolumns = array_reverse($this->selectcolumns); 117 118 //change 119 $this->selecttable="(((((lineitems LEFT JOIN products ON lineitems.productid=products.uuid) 120 INNER JOIN invoices ON lineitems.invoiceid=invoices.id) 121 INNER JOIN clients ON invoices.clientid=clients.uuid) 122 LEFT JOIN shippingmethods ON shippingmethods.uuid=invoices.shippingmethodid) 123 LEFT JOIN paymentmethods ON paymentmethods.uuid=invoices.paymentmethodid) 124 "; 125 126 if($variables["groupings"] !== ""){ 127 $this->group = explode("::",$variables["groupings"]); 128 $this->group = array_reverse($this->group); 129 } else 130 $this->group = array(); 131 132 foreach($this->group as $grp){ 133 if($this->groupings[$grp]["table"]) 134 $this->selecttable="(".$this->selecttable." ".$this->groupings[$grp]["table"].")"; 135 } 136 137 $this->whereclause=$_SESSION["printing"]["whereclause"]; 138 if($this->whereclause=="") $this->whereclause="WHERE invoices.id!=-1"; 139 140 switch($variables["showwhat"]){ 141 case "invoices": 142 $this->showinvoices = true; 143 $this->showlineitems = false; 144 break; 145 146 case "lineitems": 147 $this->showinvoices = true; 148 $this->showlineitems = true; 149 break; 150 151 default: 152 $this->showinvoices = false; 153 $this->showlineitems = false; 154 }// endswitch 155 156 if($this->whereclause!="") $this->whereclause=" WHERE (".substr($this->whereclause,6).") "; 157 }// endif 46 var $group = ""; 47 var $showinvoices = false; 48 var $showlineitems = false; 49 var $padamount = 20; 50 var $title = "Totals"; 51 52 function totalReport($db, $reportUUID, $tabledefUUID, $variables = NULL){ 53 54 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 55 56 // first we define the available groups 57 $this->addGroup("Invoice ID","invoices.id"); //0 58 $this->addGroup("Product","concat(products.partnumber,' - ',products.partname)"); //1 59 $this->addGroup("Product Category","concat(productcategories.id,' - ',productcategories.name)",NULL,"INNER JOIN productcategories ON products.categoryid=productcategories.uuid"); //2 60 61 $this->addGroup("Invoice Date - Year","YEAR(invoices.invoicedate)"); //3 62 $this->addGroup("Invoice Date - Quarter","QUARTER(invoices.invoicedate)"); //4 63 $this->addGroup("Invoice Date - Month","MONTH(invoices.invoicedate)"); //5 64 $this->addGroup("Invoice Date","invoices.invoicedate","date"); //6 65 66 $this->addGroup("Order Date - Year","YEAR(invoices.orderdate)"); //7 67 $this->addGroup("Order Date - Quarter","QUARTER(invoices.orderdate)");//8 68 $this->addGroup("Order Date - Month","MONTH(invoices.orderdate)");//9 69 $this->addGroup("Order Date","invoices.orderdate","date");//10 70 71 $this->addGroup("Client","if(clients.lastname!='',concat(clients.lastname,', ',clients.firstname,if(clients.company!='',concat(' (',clients.company,')'),'')),clients.company)");//11 72 73 $this->addGroup("Client Sales Person","concat(salesPerson.firstname,' ',salesPerson.lastname)",NULL, "LEFT JOIN users AS salesPerson ON clients.salesmanagerid = salesPerson.id");//12 74 75 $this->addGroup("Client Lead Source","clients.leadsource");//13 76 77 $this->addGroup("Invoice Lead Source","invoices.leadsource");//14 78 79 $this->addGroup("Payment Method","paymentmethods.name");//15 80 81 $this->addGroup("Shipping Method","shippingmethods.name");//16 82 $this->addGroup("Invoice Shipping Country","invoices.shiptocountry");//17 83 $this->addGroup("Invoice Shipping State / Province","invoices.shiptostate");//18 84 $this->addGroup("Invoice Shipping Postal Code","invoices.shiptopostalcode");//19 85 $this->addGroup("Invoice Shipping City","invoices.shiptocity");//20 86 87 $this->addGroup("Web Order","invoices.weborder","boolean");//21 88 89 $this->addGroup("Invoice billing Country","invoices.country");//22 90 $this->addGroup("Invoice Billing State / Province","invoices.state");//23 91 $this->addGroup("Invoice Billing Postal Code","invoices.postalcode");//24 92 $this->addGroup("Invoice Billing City","invoices.city");//25 93 94 //next we do the columns 95 $this->addColumn("Record Count","count(lineitems.id)");//0 96 $this->addColumn("Extended Price","sum(lineitems.unitprice*lineitems.quantity)","currency");//1 97 $this->addColumn("Average Extended Price","avg(lineitems.unitprice*lineitems.quantity)","currency");//2 98 $this->addColumn("Unit Price","sum(lineitems.unitprice)","currency");//3 99 $this->addColumn("Average Unit Price","avg(lineitems.unitprice)","currency");//4 100 $this->addColumn("Quantity","sum(lineitems.quantity)","real");//5 101 $this->addColumn("Average Quantity","avg(lineitems.quantity)","real");//6 102 $this->addColumn("Unit Cost","sum(lineitems.unitcost)","currency");//7 103 $this->addColumn("Average Unit Cost","avg(lineitems.unitcost)","currency");//8 104 $this->addColumn("Extended Cost","sum(lineitems.unitcost*lineitems.quantity)","currency");//9 105 $this->addColumn("Average Extended Cost","avg(lineitems.unitcost*lineitems.quantity)","currency");//10 106 $this->addColumn("Unit Weight","sum(lineitems.unitweight)","real");//11 107 $this->addColumn("Average Unit Weight","avg(lineitems.unitweight)","real");//12 108 $this->addColumn("Extended Unit Weight","sum(lineitems.unitweight*lineitems.quantity)","real");//13 109 $this->addColumn("Extended Average Unit Weight","avg(lineitems.unitweight*lineitems.quantity)","real");//14 110 111 //change 112 $this->selecttable="(((((lineitems LEFT JOIN products ON lineitems.productid=products.uuid) 113 INNER JOIN invoices ON lineitems.invoiceid=invoices.id) 114 INNER JOIN clients ON invoices.clientid=clients.uuid) 115 LEFT JOIN shippingmethods ON shippingmethods.uuid=invoices.shippingmethodid) 116 LEFT JOIN paymentmethods ON paymentmethods.uuid=invoices.paymentmethodid) 117 "; 118 119 }//end function totalReport 120 121 122 function processFromPost($variables){ 123 124 $tempArray = explode("::", $variables["columns"]); 125 126 foreach($tempArray as $id) 127 $this->selectcolumns[] = $this->columns[$id]; 128 129 $this->selectcolumns = array_reverse($this->selectcolumns); 130 131 if($variables["groupings"] !== ""){ 132 133 $this->group = explode("::",$variables["groupings"]); 134 $this->group = array_reverse($this->group); 135 136 } else 137 $this->group = array(); 138 139 foreach($this->group as $grp) 140 if($this->groupings[$grp]["table"]) 141 $this->selecttable="(".$this->selecttable." ".$this->groupings[$grp]["table"].")"; 142 143 switch($variables["showwhat"]){ 144 145 case "invoices": 146 $this->showinvoices = true; 147 $this->showlineitems = false; 148 break; 149 150 case "lineitems": 151 $this->showinvoices = true; 152 $this->showlineitems = true; 153 break; 154 155 default: 156 $this->showinvoices = false; 157 $this->showlineitems = false; 158 159 }// endswitch 160 161 if($variables["reporttitle"]) 162 $this->title = $variables["reporttitle"]; 163 164 }//end function processFromPost 165 166 167 function processFromSettings(){ 168 169 foreach($this->settings as $key=>$value) 170 if(strpos($key, "column") === 0) 171 $this->selectcolumns[substr($key,6)-1] = $this->columns[$value]; 172 173 ksort($this->selectcolumns); 174 $this->selectcolumns = array_reverse($this->selectcolumns); 175 176 $this->group = array(); 177 178 foreach($this->settings as $key=>$value) 179 if(strpos($key, "group") === 0) 180 $this->group[substr($key,5)-1] = $value; 181 182 ksort($this->group); 183 $this->group = array_reverse($this->group); 184 185 foreach($this->group as $grp) 186 if($this->groupings[$grp]["table"]) 187 $this->selecttable="(".$this->selecttable." ".$this->groupings[$grp]["table"].")"; 188 189 190 if(isset($this->settings["showWhat"])) 191 $showWhat = $this->settings["showWhat"]; 192 else 193 $showWhat = ""; 194 195 switch($showWhat){ 196 197 case "invoices": 198 $this->showinvoices = true; 199 $this->showlineitems = false; 200 break; 201 202 case "lineitems": 203 $this->showinvoices = true; 204 $this->showlineitems = true; 205 break; 206 207 default: 208 $this->showinvoices = false; 209 $this->showlineitems = false; 210 211 }// endswitch 212 213 if(isset($this->settings["reportTitle"])) 214 $this->title = $this->settings["reportTitle"]; 215 216 }//end function processFromSettings 217 218 219 function addGroup($name, $field, $format = NULL, $tableAddition = NULL){ 220 221 $temp = array(); 222 $temp["name"] = $name; 223 $temp["field"] = $field; 224 $temp["format"] = $format; 225 $temp["table"] = $tableAddition; 226 227 $this->groupings[] = $temp; 228 158 229 }//end method 159 230 160 231 161 function addGroup($name, $field, $format = NULL, $tableAddition = NULL){ 162 $temp = array(); 163 $temp["name"] = $name; 164 $temp["field"] = $field; 165 $temp["format"] = $format; 166 $temp["table"] = $tableAddition; 167 168 $this->groupings[] = $temp; 232 function addColumn($name, $field, $format = NULL){ 233 234 $temp = array(); 235 $temp["name"] = $name; 236 $temp["field"] = $field; 237 $temp["format"] = $format; 238 239 $this->columns[] = $temp; 240 169 241 }//end method 170 242 171 243 172 function addColumn($name, $field, $format = NULL){173 $temp = array();174 $temp["name"] = $name;175 $temp["field"] = $field;176 $temp["format"] = $format;177 178 $this->columns[] = $temp;179 }//end method180 181 182 244 function showReportTable(){ 183 ?><table border="0" cellspacing="0" cellpadding="0"> 184 <tr> 185 <th> </th> 186 <?php 187 foreach($this->selectcolumns as $thecolumn){ 188 ?><th align="right"><?php echo $thecolumn["name"]?></th><?php 189 }//end foreach 190 ?> 191 </tr> 192 <?php $this->showGroup($this->group,"",10);?> 193 <?php $this->showGrandTotals();?> 194 </table> 195 <?php 196 } 245 246 ?><table border="0" cellspacing="0" cellpadding="0"> 247 <tr> 248 <th> </th> 249 <?php 250 foreach($this->selectcolumns as $thecolumn){ 251 ?><th align="right"><?php echo $thecolumn["name"]?></th><?php 252 }//end foreach 253 ?> 254 </tr> 255 <?php $this->showGroup($this->group,"",10);?> 256 <?php $this->showGrandTotals();?> 257 </table> 258 <?php 259 260 }//end function showReportTable(); 261 197 262 198 263 function showGrandTotals(){ 199 264 200 $querystatement="SELECT "; 201 foreach($this->selectcolumns as $thecolumn) 202 $querystatement.=$thecolumn["field"]." AS `".$thecolumn["name"]."`,"; 203 $querystatement.=" count(lineitems.id) as thecount "; 204 $querystatement.=" FROM ".$this->selecttable.$this->whereclause; 205 $queryresult=$this->db->query($querystatement); 206 207 $therecord=$this->db->fetchArray($queryresult); 208 ?> 209 <tr> 210 <td class="grandtotals" align="right">Totals: (<?php echo $therecord["thecount"]?>)</td> 211 <?php 212 foreach($this->selectcolumns as $thecolumn){ 213 ?><td align="right" class="grandtotals"><?php echo formatVariable($therecord[$thecolumn["name"]],$thecolumn["format"])?></td><?php 214 }//end foreach 215 ?> 216 </tr> 217 <?php 218 } 265 $querystatement="SELECT "; 266 foreach($this->selectcolumns as $thecolumn) 267 $querystatement.=$thecolumn["field"]." AS `".$thecolumn["name"]."`,"; 268 $querystatement.=" count(lineitems.id) as thecount "; 269 $querystatement.=" FROM ".$this->selecttable.$this->whereClause; 270 $queryresult=$this->db->query($querystatement); 271 272 $therecord=$this->db->fetchArray($queryresult); 273 ?> 274 <tr> 275 <td class="grandtotals" align="right">Totals: (<?php echo $therecord["thecount"]?>)</td> 276 <?php 277 foreach($this->selectcolumns as $thecolumn){ 278 ?><td align="right" class="grandtotals"><?php echo formatVariable($therecord[$thecolumn["name"]],$thecolumn["format"])?></td><?php 279 }//end foreach 280 ?> 281 </tr> 282 <?php 283 284 }//end function showGrandTotals 285 219 286 220 287 function showGroup($group,$where,$indent){ … … 231 298 $querystatement.=$thecolumn["field"]." AS `".$thecolumn["name"]."`,"; 232 299 $querystatement .= $this->groupings[$groupby]["field"]." AS thegroup, count(lineitems.id) as thecount "; 233 $querystatement .= " FROM ".$this->selecttable.$this->where clause.$where." GROUP BY ".$this->groupings[$groupby]["field"];300 $querystatement .= " FROM ".$this->selecttable.$this->whereClause.$where." GROUP BY ".$this->groupings[$groupby]["field"]; 234 301 $queryresult=$this->db->query($querystatement); 235 302 … … 290 357 `lineitems`.`unitprice`, 291 358 `quantity`*`lineitems`.`unitprice` AS `extended` 292 FROM ".$this->selecttable.$this->where clause.$where." GROUP BY lineitems.id359 FROM ".$this->selecttable.$this->whereClause.$where." GROUP BY lineitems.id 293 360 "; 294 361 … … 337 404 function showReport(){ 338 405 339 if($_POST["reporttitle"]) 340 $pageTitle = $_POST["reporttitle"]; 341 else 342 $pageTitle = "Line Item Totals"; 343 406 if(!$this->whereClause) 407 $this->whereClause = "invoices.id!=-1"; 408 409 $this->whereClause = " WHERE ".$this->whereClause; 410 411 $pageTitle = $this->title; 344 412 345 413 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> … … 394 462 <div class="bodyline"> 395 463 <h1>Line Items Total Options</h1> 396 <form id="GroupForm" action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" name="GroupForm">464 <form id="GroupForm" action="<?php echo str_replace("&", "&", $_SERVER["REQUEST_URI"]) ?>" method="post" name="GroupForm"> 397 465 398 466 <fieldset> … … 465 533 466 534 467 // Processing =================================================================================================================== 468 if(!isset($dontProcess)){ 469 if(isset($_POST["columns"])){ 470 $myreport= new totalReport($db,$_POST); 471 $myreport->showReport(); 472 } else { 473 $myreport = new totalReport($db); 474 $myreport->showSelectScreen(); 475 } 476 }?> 535 /** 536 * PROCESSING 537 * ============================================================================= 538 */ 539 if(!isset($noOutput)){ 540 541 require("../../../include/session.php"); 542 543 checkForReportArguments(); 544 545 $report = new totalReport($db, $_GET["rid"], $_GET["tid"]); 546 547 if(isset($_POST["columns"])){ 548 549 $report->setupFromPrintScreen(); 550 $report->processFromPost($_POST); 551 $report->showReport(); 552 553 } elseif(isset($report->settings["column1"])){ 554 555 $report->setupFromPrintScreen(); 556 $report->processFromSettings(); 557 $report->showReport(); 558 559 } else { 560 561 $report->showSelectScreen(); 562 563 }//endif 564 565 }//endif 566 567 /** 568 * When adding a new report record, the add/edit needs to know what the class 569 * name is so that it can instantiate it, and grab it's default settings. 570 */ 571 if(isset($addingReportRecord)) 572 $reportClass ="totalReport"; 573 574 ?> -
trunk/phpbms/modules/bms/report/products_saleshistory.php
r611 r693 38 38 */ 39 39 40 if(!isset($fromProduct)) { 41 require_once("../../../include/session.php"); 42 } 43 44 class salesHistoryReport{ 40 if(!class_exists("phpbmsReport")) 41 include("../../../report/report_class.php"); 42 43 class salesHistoryReport extends phpbmsReport{ 44 45 var $fromDate; 46 var $toDate; 47 var $view; 48 var $productQueryresult; 49 var $dataPrint; 50 51 function salesHistoryReport($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 products.partnumber "; 73 74 if(!$this->whereClause) 75 $this->whereClause = "products.id!=-1"; 76 77 $this->whereClause = " WHERE (".$this->whereClause.") "; 78 79 $querystatement = " 80 SELECT 81 products.uuid, 82 products.partnumber, 83 products.partname 84 FROM 85 products 86 ".$this->whereClause.$this->sortOrder; 87 88 $this->productQueryresult = $this->db->query($querystatement); 89 90 }//end function initialize 91 92 93 function generateSingleHistory($productUUID){ 94 95 $theStatus = "(invoices.type = '"; 96 97 switch($this->view){ 98 99 case "Orders and Invoices": 100 $theStatus .= "Order' OR invoices.type ='Invoice')"; 101 $searchDate = "orderdate"; 102 break; 103 104 case "Invoices": 105 $theStatus .= "Invoice')"; 106 $searchDate = "invoicedate"; 107 break; 108 109 case "Orders": 110 $theStatus .= "Order')"; 111 $searchDate = "orderdate"; 112 break; 113 114 }//endswitch 115 116 $mysqlFromDate = sqlDateFromString($this->fromDate); 117 $mysqlToDate = sqlDateFromString($this->toDate); 118 119 $querystatement = " 120 SELECT 121 `invoices`.`id`, 122 `invoices`.`orderdate`, 123 `invoices`.`invoicedate`, 124 IF(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) AS `client`, 125 `lineitems`.`quantity` AS `qty`, 126 `lineitems`.`unitprice`*`lineitems`.`quantity` AS `extended`, 127 `lineitems`.`unitprice` AS `price`, 128 `lineitems`.`unitcost` AS `cost`, 129 `lineitems`.`unitcost`*`lineitems`.`quantity` AS extendedcost 130 FROM 131 ((products INNER JOIN lineitems on products.uuid=lineitems.productid) 132 INNER JOIN `invoices` ON lineitems.invoiceid=invoices.id) 133 INNER JOIN `clients` on `invoices`.`clientid`=`clients`.`uuid` 134 WHERE 135 `products`.`uuid`='".$productUUID."' 136 AND 137 `invoices`.".$searchDate.">='".$mysqlFromDate."' 138 AND 139 `invoices`.".$searchDate."<='".$mysqlToDate."' 140 AND 141 ".$theStatus." 142 ORDER BY 143 `invoices`.`invoicedate`, 144 `invoices`.`orderdate` 145 "; 146 147 $queryresult = $this->db->query($querystatement); 148 149 ob_start(); 150 151 ?> 152 <table border="0" cellpadding="3" cellspacing="0"> 153 <thead> 154 <tr> 155 <th align="center" nowrap="nowrap" >ID</th> 156 <th align="center" nowrap="nowrap" >Order Date</th> 157 <th align="center" nowrap="nowrap" >Invoice. Date</th> 158 <th nowrap="nowrap" width="100%" align="left">Client</th> 159 <th align="center" nowrap="nowrap" >Qty.</th> 160 <th align="right" nowrap="nowrap" >Unit Cost</th> 161 <th align="right" nowrap="nowrap" >Cost Ext.</th> 162 <th align="right" nowrap="nowrap" >Unit Price</th> 163 <th align="right" nowrap="nowrap">Price Ext.</th> 164 </tr> 165 </thead> 166 <?php 167 168 $totalextended = 0; 169 $totalcostextended = 0; 170 $totalquantity = 0; 171 $avgprice = 0; 172 $avgcost = 0; 173 174 $numrows = $this->db->numRows($queryresult); 175 176 while ($therecord = $this->db->fetchArray($queryresult)){ 177 178 $avgcost += $therecord["cost"]; 179 $avgprice += $therecord["price"]; 180 $totalquantity += $therecord["qty"]; 181 $totalextended += $therecord["extended"]; 182 $totalcostextended += $therecord["extendedcost"]; 183 ?> 184 <tr> 185 <td align="center" nowrap="nowrap"><?php echo $therecord["id"]?></td> 186 <td align="center" nowrap="nowrap"><?php echo $therecord["orderdate"]?formatFromSQLDate($therecord["orderdate"]):" " ?></td> 187 <td align="center" nowrap="nowrap"><?php echo $therecord["invoicedate"]?formatFromSQLDate($therecord["invoicedate"]):" " ?></td> 188 <td nowrap="nowrap"><?php echo $therecord["client"]?></td> 189 <td align="center" nowrap="nowrap"><?php echo number_format($therecord["qty"],2)?></td> 190 <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["cost"])?></td> 191 <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["extendedcost"])?></td> 192 <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["price"])?></td> 193 <td align="right" nowrap="nowrap"><?php echo numberToCurrency($therecord["extended"])?></td> 194 </tr> 195 <?php }//endwhile ?> 196 <tr> 197 <td align="center" class="grandtotals"> </td> 198 <td align="center" class="grandtotals"> </td> 199 <td class="grandtotals"> </td> 200 <td class="grandtotals"> </td> 201 <td align="center" class="grandtotals"><?php echo number_format($totalquantity,2)?></td> 202 <td align="right" nowrap="nowrap"class="grandtotals">avg. = <?php $numrows?$avgcost=$avgcost/$numrows:$avgcost=0; echo numberToCurrency($avgcost)?></td> 203 <td align="right" class="grandtotals"><?php echo numberToCurrency($totalcostextended)?></td> 204 <td align="right" nowrap="nowrap" class="grandtotals">avg. = <?php $numrows?$avgprice=$avgprice/$numrows:$avgprice=0; echo numberToCurrency($avgprice)?></td> 205 <td align="right" class="grandtotals"><?php echo numberToCurrency($totalextended)?></td> 206 </tr> 207 </table> 208 <?php 209 210 $output = ob_get_contents(); 211 ob_end_clean(); 212 213 return $output; 214 215 }//end function generateSingleHistory 216 217 218 219 function generate(){ 220 221 222 ob_start(); 223 ?> 224 225 <h1>Product Sales History</h1> 226 227 <ul> 228 <li> 229 source:<br /> 230 <?php echo formatVariable($this->dataPrint); ?> 231 </li> 232 <li> 233 date generated:<br /> 234 <?php echo dateToString(mktime())." ".timeToString(mktime()); ?> 235 </li> 236 <li> 237 view:<br /> 238 <?php echo $this->view; ?> 239 </li> 240 <li> 241 from:<br /> 242 <?php echo $this->fromDate; ?> 243 </li> 244 <li> 245 to:<br /> 246 <?php echo $this->toDate; ?> 247 </li> 248 </ul> 249 250 <?php 251 252 $this->reportOutput = ob_get_contents(); 253 ob_end_clean(); 254 255 while($therecord = $this->db->fetchArray($this->productQueryresult)){ 256 257 $this->reportOutput .= '<h2>'.$therecord["partnumber"].'<br />'.$therecord["partname"].'</h2>'; 258 259 $this->reportOutput .= $this->generateSingleHistory($therecord["uuid"]); 260 261 }//endwhile 262 263 }//end function generate 264 265 266 function output(){ 267 268 global $phpbms; 269 $db = &$this->db; 270 271 $phpbms->cssIncludes[] = "reports.css"; 272 $phpbms->cssIncludes[] = "pages/bms/clienthistoryreport.css"; 273 274 $phpbms->showMenu = false; 275 $phpbms->showFooter = false; 276 277 include("header.php"); 278 279 echo $this->reportOutput; 280 281 include("footer.php"); 282 283 }//end function output 284 285 286 function displayOptions(){ 287 288 global $phpbms; 289 $db = &$this->db; 290 291 require("include/fields.php"); 292 293 $pageTitle = "Product Sales History"; 294 $phpbms->cssIncludes[] = "pages/historyreports.css"; 295 $phpbms->showMenu = false; 296 297 //Form Elements 298 //============================================================== 299 $theform = new phpbmsForm(); 300 301 $thedate = dateToString( mktime(0,0,0,date("m"),1),"SQL" ); 302 $theinput = new inputDatePicker("fromdate", $thedate, "from",true); 303 $theform->addField($theinput); 304 305 $thedate = dateToString( mktime(0,0,0,date("m")+1,0,date("Y")), "SQL" ); 306 $theinput = new inputDatePicker("todate", $thedate, "to",true); 307 $theform->addField($theinput); 308 309 $theform->jsMerge(); 310 //============================================================== 311 //End Form Elements 312 313 include("header.php"); 314 ?> 315 <form action="<?php echo str_replace("&", "&", $_SERVER["REQUEST_URI"]); ?>" method="post" name="totals" onsubmit="return validateForm(this)"> 316 317 <div class="bodyline" id="reportOptions"> 318 319 <h1 id="topTitle"><span>Product Sales History Options</span></h1> 320 321 <fieldset> 322 <legend>time frame</legend> 323 324 <p id="fromP"><?php $theform->showField("fromdate");?></p> 325 326 <p><?php $theform->showField("todate");?></p> 327 </fieldset> 328 329 <p> 330 <label for="status">include products from...<br /></label> 331 <select id="status" name="status"> 332 <option value="Orders and Invoices" selected="selected">Orders and Invoices</option> 333 <option value="Invoices">Invoices</option> 334 <option value="Orders">Orders</option> 335 </select> 336 </p> 337 338 <div align="right"> 339 <input name="command" type="submit" class="Buttons" id="print" value="print" /> 340 <input name="cancel" type="button" class="Buttons" id="cancel" value="cancel" onclick="window.close();" /> 341 </div> 342 </div> 343 </form> 344 345 <?php 346 include("footer.php"); 347 348 }//end function displayOptions 349 350 }//end class salesHistoryReport 351 352 353 /** 354 * PROCESSING 355 * ============================================================================= 356 */ 357 if(!isset($noOutput)){ 358 359 //IE needs caching to be set to private in order to display PDFS 360 session_cache_limiter('private'); 361 362 require_once("../../../include/session.php"); 363 364 checkForReportArguments(); 365 366 $report = new salesHistoryReport($db, $_GET["rid"], $_GET["tid"]); 367 368 if(!isset($_POST["command"]) && !isset($_GET["status"])) 369 $report->displayOptions(); 370 else{ 371 372 if(isset($_GET["status"])){ 373 374 $_POST["status"] = $_GET["status"]; 375 $_POST["fromdate"] = $_GET["fromdate"]; 376 $_POST["todate"] = $_GET["todate"]; 377 378 }//endif 379 380 //need to set post variables here 381 382 $report->setupFromPrintScreen(); 383 $report->initialize($_POST); 384 $report->generate(); 385 $report->output(); 386 387 }//endif 388 389 390 }//end if 391 392 /** 393 * When adding a new report record, the add/edit needs to know what the class 394 * name is so that it can instantiate it, and grab it's default settings. 395 */ 396 if(isset($addingReportRecord)) 397 $reportClass ="salesHistoryReport"; 398 399 400 401 402 403 404 405 406 407 class s_salesHistoryReport{ 45 408 46 409 var $whereclause=""; … … 187 550 188 551 function showReport(){ 189 552 190 553 ?> 191 554 <head> … … 261 624 }//end method 262 625 }//end class 263 264 if(isset($_POST["command"])){265 $myreport= new salesHistoryReport();266 $myreport->initialize($_POST,$db);267 268 $myreport->showReport();269 } else {270 271 require("include/fields.php");272 273 $pageTitle = "Product Sales History";274 $phpbms->cssIncludes[] = "pages/historyreports.css";275 $phpbms->showMenu = false;276 277 //Form Elements278 //==============================================================279 $theform = new phpbmsForm();280 281 282 $thedate = dateToString( mktime(0,0,0,date("m"),1),"SQL" );283 $theinput = new inputDatePicker("fromdate", $thedate, "from",true);284 $theform->addField($theinput);285 286 $thedate = dateToString( mktime(0,0,0,date("m")+1,0,date("Y")), "SQL" );287 $theinput = new inputDatePicker("todate", $thedate, "to",true);288 $theform->addField($theinput);289 290 $theform->jsMerge();291 //==============================================================292 //End Form Elements293 294 include("header.php");295 626 ?> 296 <form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" name="totals" onsubmit="return validateForm(this)">297 <div class="bodyline" id="reportOptions">298 <h1 id="topTitle"><span>Product Sales History Options</span></h1>299 <fieldset>300 <legend>time frame</legend>301 302 <p id="fromP"><?php $theform->showField("fromdate");?></p>303 304 <p><?php $theform->showField("todate");?></p>305 </fieldset>306 307 <p>308 <label for="status">include line items from...<br /></label>309 <select id="status" name="status">310 <option value="Orders/Invoices" selected="selected">Orders/Invoices</option>311 <option value="Invoices">Invoices</option>312 <option value="Orders">Orders</option>313 </select>314 </p>315 316 <div align="right">317 <input name="command" type="submit" class="Buttons" id="print" value="print" />318 <input name="cancel" type="button" class="Buttons" id="cancel" value="cancel" onclick="window.close();" />319 </div>320 </div>321 </form>322 <?php323 include("footer.php");324 }?> -
trunk/phpbms/modules/bms/report/receipts_pdf.php
r673 r693 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 40 if(!isset($_SESSION["userinfo"])){ 41 42 //set encoding to latin1 (fpdf doesnt like utf8) 43 $sqlEncoding = "latin1"; 44 require_once("../../../include/session.php"); 45 46 } 47 48 if(!class_exists("phpbmsReport")) 49 include("report/report_class.php"); 50 51 class receiptPDF extends phpbmsReport{ 52 53 var $title = "Receipt"; 54 var $lineitemBoxHeight = 4.25; 55 /** 56 * $count 57 * @var int The number of invoice records being displayed 58 */ 59 var $count; 60 61 function receiptPDF($db, $orientation='P', $unit='mm', $format='Letter'){ 62 63 $this->db = $db; 64 65 if(!class_exists("phpbmsPDFReport")) 66 include("report/pdfreport_class.php"); 67 68 $this->pdf = new phpbmsPDFReport($db, $orientation, $unit, $format); 69 70 $this->initialize(); 71 72 }//end method 73 74 75 function initialize(){ 76 //This function will set column headings, sizes and formatting 77 78 $pdf = &$this->pdf; 79 80 $topinfo = array(); 81 $topinfo[] = new pdfColumn("ID", "id", 0.75); 82 $topinfo[] = new pdfColumn("Date", "receiptdate", 1, "date"); 83 $topinfo[] = new pdfColumn("Processed By", "processedby", 0); 84 85 $size = 0; 86 foreach($topinfo as $column) 87 $size += $column->size; 88 89 $topinfo[2]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 90 91 $this->topinfo = $topinfo; 92 93 94 $lineitems = array(); 95 $lineitems[] = new pdfColumn("Doc Ref", "relatedid", 0.5); 96 $lineitems[] = new pdfColumn("Type", "type", 0.75); 97 $lineitems[] = new pdfColumn("Doc Date", "itemdate", 0.75, "date"); 98 $lineitems[] = new pdfColumn("Due Date", "duedate", 0.75, "date"); 99 100 $lineitems[] = new pdfColumn("Doc Amount", "amount", 0, "currency", "R"); 101 $lineitems[] = new pdfColumn("Applied", "applied", 0.75, "currency", "R"); 102 $lineitems[] = new pdfColumn("Discount", "discount", 0.75, "currency", "R"); 103 $lineitems[] = new pdfColumn("Tax Adj", "taxadjustment", 0.75, "currency", "R"); 104 105 $size = 0; 106 foreach($lineitems as $column) 107 $size += $column->size; 108 109 $lineitems[4]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 110 111 $this->lineitems = $lineitems; 112 113 $totalsinfo = array(); 114 $totalsinfo[] = new pdfColumn("Distribution Remaining", "remaining", 0, "currency", "R"); 115 $totalsinfo[] = new pdfColumn("Receipt Total", "amount", 0, "currency", "R"); 116 117 $this->totalsinfo = $totalsinfo; 118 119 }//end method 120 121 122 function generate($whereclause = NULL, $sortorder = "receipts.id"){ 123 124 $pdf = &$this->pdf; 125 126 if($whereclause) 127 $this->whereclause = $whereclause; 128 elseif(!$this->whereclause) 129 $this->whereclause = "receipts.id = -400"; 130 131 if($sortorder) 132 $this->sortorder = $sortorder; 133 elseif(!$this->sortorder) 134 $this->sortorder = "receipts.id"; 135 136 $paymentFields = ""; 137 if(ENCRYPT_PAYMENT_FIELDS){ 138 139 $paymentFields = " 140 ".$this->db->decrypt("`ccnumber`")." AS `ccnumber`, 141 ".$this->db->decrypt("`ccverification`")." AS `ccverification`, 142 ".$this->db->decrypt("`ccexpiration`")." AS `ccexpiration`, 143 ".$this->db->decrypt("`routingnumber`")." AS `routingnumber`, 144 ".$this->db->decrypt("`accountnumber`")." AS `accountnumber`, 145 "; 146 147 }//end if 148 149 $querystatement = " 150 SELECT 151 receipts.*, 152 ".$paymentFields." 153 154 clients.firstname, 155 clients.lastname, 156 clients.company, 157 addresses.address1, 158 addresses.address2, 159 addresses.city, 160 addresses.state, 161 addresses.postalcode, 162 addresses.country, 163 clients.homephone, 164 clients.workphone, 165 clients.email, 166 167 paymentmethods.name AS paymentname, 168 paymentmethods.type AS paymenttype, 169 170 users.firstname AS processorfirst, 171 users.lastname AS processorlast 172 173 FROM 174 receipts INNER JOIN clients ON receipts.clientid = clients.uuid 175 INNER JOIN users ON receipts.modifiedby = users.id INNER JOIN 176 addresstorecord ON addresstorecord.tabledefid = 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083' AND addresstorecord.primary = 1 177 AND addresstorecord.recordid = clients.uuid INNER JOIN addresses 178 ON addresstorecord.addressid = addresses.uuid 179 LEFT JOIN paymentmethods ON receipts.paymentmethodid = paymentmethods.uuid"; 180 181 $querystatement = $this->assembleSQL($querystatement); 182 $queryresult = $this->db->query($querystatement); 183 184 185 $this->count = $this->db->numRows($queryresult); 186 if($this->count == 0){ 187 188 $this->_showNoRecords(); 189 exit; 190 191 }//end if 192 193 $pdf->hasComapnyHeader = true; 194 $pdf->SetMargins(); 195 196 //iterate through each invoice record 197 while($receiptrecord = $this->db->fetchArray($queryresult)){ 198 199 $querystatement = " 200 SELECT 201 SUM(applied) AS thesum 202 FROM 203 receiptitems 204 WHERE 205 receiptid ='".$receiptrecord["uuid"]."' 206 "; 207 208 $sumresult = $this->db->query($querystatement); 209 $sumrecord = $this->db->fetchArray($sumresult); 210 211 $receiptrecord["remaining"] = $receiptrecord["amount"] - $sumrecord["thesum"]; 212 213 $this->page = 0; 214 215 $this->receiptrecord = $receiptrecord; 216 217 //adds top info 218 $top = $this->_addPage(); 219 220 $this->_addLineItems($top); 221 222 $pdf->SetXY($pdf->leftmargin, $top["y"] + $this->lineitemBoxHeight + 0.125); 223 224 //totals 225 $this->_addTotals(); 226 227 //Print any special/instructions and stuff 228 $this->_addNotes(); 229 230 }//end while; 231 232 233 }//end method 234 235 236 function _addPage(){ 237 238 $pdf = &$this->pdf; 239 240 $pdf->AddPage(); 241 $this->page++; 242 243 $nextY = $pdf->getY(); 244 245 //TITLE 246 $titleWidth=2.375; 247 $titleHeight=.25; 248 $pdf->setStyle("title"); 249 $pdf->SetXY(-1*($titleWidth+$pdf->rightmargin), $pdf->topmargin); 250 $pdf->Cell($titleWidth, $titleHeight,$this->title, $pdf->borderDebug,1,"R"); 251 252 //CLIENT 253 $startY = $pdf->GetY() + 0.75; 254 255 $boxHeight = 1.75; 256 $boxWidth = ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin)/2 -0.0625; 257 258 $pdf->setLineWidth(0.02); 259 $pdf->Rect($pdf->leftmargin, $startY, $boxWidth, $boxHeight); 260 $pdf->setLineWidth(0.01); 261 262 $pdf->setStyle("header"); 263 $pdf->setY($startY); 264 $pdf->Cell($boxWidth, 0.17, "CLIENT", $pdf->borderDebug, 2, "L", 1); 265 $pdf->setStyle("normal"); 266 267 //Company Name 268 $companyDisplay = ""; 269 if($this->receiptrecord["company"]){ 270 $companyDisplay .= $this->receiptrecord["company"]; 271 if($this->receiptrecord["firstname"]) 272 $companyDisplay .= " (".$this->receiptrecord["firstname"]." ".$this->receiptrecord["lastname"].")"; 273 } else 274 $companyDisplay .= $this->receiptrecord["firstname"]." ".$this->receiptrecord["lastname"]; 275 276 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 277 $pdf->SetFont("Arial", "B", 10); 278 $pdf->Cell($boxWidth - 0.125, 0.17, $companyDisplay, $pdf->borderDebug, 2, "L"); 279 280 $client = $this->_setClientInfo(); 281 282 $pdf->SetFont("Arial", "", 10); 283 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 284 $pdf->MultiCell($boxWidth - 0.125,.17,$client, $pdf->borderDebug); 285 286 //PAYMENT 287 $pdf->setLineWidth(0.02); 288 $pdf->Rect($pdf->leftmargin + $boxWidth + 0.125, $startY, $boxWidth, $boxHeight); 289 $pdf->setLineWidth(0.01); 290 291 $pdf->setStyle("header"); 292 $pdf->setXY($pdf->leftmargin + $boxWidth + 0.125, $startY); 293 $pdf->Cell($boxWidth, 0.17, "PAYMENT", $pdf->borderDebug, 2, "L", 1); 294 $pdf->setStyle("normal"); 295 296 if(!$this->receiptrecord["paymentname"]) 297 $this->receiptrecord["paymentname"] = "Other"; 298 299 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 300 $pdf->SetFont("Arial", "B", 10); 301 $pdf->Cell($boxWidth - 0.125, 0.17, $this->receiptrecord["paymentname"], $pdf->borderDebug, 2, "L"); 302 303 304 $paymentInfo = $this->_getPaymentInfo(); 305 $pdf->SetFont("Arial", "", 10); 306 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 307 $pdf->MultiCell($boxWidth - 0.125,.17, $paymentInfo, $pdf->borderDebug); 308 309 $pdf->setXY($pdf->leftmargin, $startY + $boxHeight + 0.125); 310 311 $this->_addTopInfo(); 312 313 //line item headings 314 $pdf->setStyle("header"); 315 $pdf->SetLineWidth(0.02); 316 317 $coords["x"] = $pdf->GetX(); 318 $coords["y"] = $pdf->GetY(); 319 320 foreach($this->lineitems as $column) 321 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 322 323 324 return $coords; 325 326 }//end method 327 328 329 function _setClientInfo(){ 330 331 $client = $this->receiptrecord["address1"]; 332 333 if($this->receiptrecord["address2"]) 334 $client .= "\n".$this->receiptrecord["address2"]; 335 336 $client .="\n".$this->receiptrecord["city"].", ".$this->receiptrecord["state"]." ".$this->receiptrecord["postalcode"]; 337 338 if($this->receiptrecord["country"]) 339 $client .=" ".$this->receiptrecord["country"]; 340 341 $phoneemail = ""; 342 if($this->receiptrecord["workphone"] || $this->receiptrecord["homephone"]){ 343 344 if($this->receiptrecord["workphone"]) 345 $phoneemail = $this->receiptrecord["workphone"]." (W)"; 346 else 347 $phoneemail = $this->receiptrecord["homephone"]." (H)"; 348 349 $phoneemail.="\n"; 350 351 }//end if 352 353 if($this->receiptrecord["email"]) 354 $phoneemail .= $this->receiptrecord["email"]; 355 356 if($phoneemail) 357 $client .= "\n\n".$phoneemail; 358 359 return $client; 360 361 }//end method 362 363 364 function _getPaymentInfo(){ 365 366 $info = ""; 367 368 switch($this->receiptrecord["paymenttype"]){ 369 370 case "charge": 371 372 $info .= $this->receiptrecord["ccnumber"]; 373 $info .= "\n Expires: ".$this->receiptrecord["ccexpiration"]; 374 if($this->receiptrecord["ccverification"]) 375 $info .= "\n Verification/Pin: ".$this->receiptrecord["ccverification"]; 376 break; 377 378 case "draft": 379 380 $info .= $this->receiptrecord["bankname"]; 381 $info .= "\n Check No: ".$this->receiptrecord["checkno"]; 382 383 if($this->receiptrecord["accountnumber"] || $this->receiptrecord["routingnumber"]) 384 $info .= "\n"; 385 386 if($this->receiptrecord["accountnumber"]) 387 $info .="\n".$this->receiptrecord["accountnumber"]; 388 389 if($this->receiptrecord["routingnumber"]) 390 $info .="\n".$this->receiptrecord["routingnumber"]; 391 392 break; 393 394 default: 395 396 if(!$this->receiptrecord["paymentmethodid"]) 397 $info .= $this->receiptrecord["paymentother"]; 398 399 }//endswitch 400 401 if($this->receiptrecord["transactionid"]) 402 $info .= "\nTransaction ID: ".$this->receiptrecord["transactionid"]; 403 404 return $info; 405 406 }//end method 407 408 409 function _addTopInfo(){ 410 411 $pdf = &$this->pdf; 412 413 $pdf->setStyle("header"); 414 $pdf->SetLineWidth(0.02); 415 416 foreach($this->topinfo as $column) 417 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 418 419 $pdf->Rect($pdf->leftmargin, $pdf->GetY(), ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin), 0.39); 420 421 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + .2); 422 423 424 $this->receiptrecord["processedby"] = $this->receiptrecord["processorfirst"]." ".$this->receiptrecord["processorlast"]; 425 $pdf->setStyle("normal"); 426 427 foreach($this->topinfo as $column){ 428 429 if($column->format != "") 430 $value = formatVariable($this->receiptrecord[$column->fieldname], $column->format); 431 else 432 $value = $this->receiptrecord[$column->fieldname]; 433 434 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 435 436 }//end foreach 437 438 $pdf->SetY($pdf->GetY() + 0.18 + 0.125); 439 440 }//end method 441 442 443 function _addLineItems($coords){ 444 445 $pdf = &$this->pdf; 446 447 $lineitemresult = $this->_getLineItems(); 448 449 $pdf->setStyle("normal"); 450 451 $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); 452 453 while($line = $this->db->fetchArray($lineitemresult)){ 454 455 if($pdf->GetY() + 0.17*3 > $coords["y"] + $this->lineitemBoxHeight){ 456 457 $pdf->SetLineWidth(0.02); 458 $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); 459 $pdf->SetLineWidth(0.01); 460 461 $this->_addPage(); 462 463 }//end if 464 465 if($line["type"] == "invoice"){ 466 467 $tempDate = stringToDate($line["itemdate"], "SQL"); 468 $line["duedate"] = dateToString( strtotime(TERM1_DAYS." days", $tempDate), "SQL" ); 469 470 } else 471 $line["duedate"] = ""; 472 473 if($line["type"] == "deposit" && $line["relatedid"] == $this->receiptrecord["id"]){ 474 $line["relatedid"] = ""; 475 $line["amount"] = 0; 476 $line["aritemid"] = 0; 477 } 478 479 if($this->receiptrecord["posted"]) 480 $line["docdue"] = $line["amount"] - $line["paid"]; 481 elseif($line["relatedid"]) 482 $line["docdue"] = $line["amount"] - $line["paid"] - $line["applied"] - $line["discount"] - $line["taxadjustment"]; 483 else 484 $line["docDue"] = 0; 485 486 487 foreach($this->lineitems as $column){ 488 489 $ln = 0; 490 491 492 switch($column->fieldname){ 493 494 case "parts": 495 $pdf->SetFont("Arial", "B", 8); 496 $pdf->Write(0.17, $line["partname"]); 497 $pdf->setStyle("normal"); 498 $pdf->SetX($pdf->leftmargin + $column->size); 499 break; 500 501 default: 502 if($column->format != "") 503 $value = formatVariable($line[$column->fieldname], $column->format); 504 else 505 $value = $line[$column->fieldname]; 506 507 if($value == "·") 508 $value = " "; 509 510 if($column->fieldname == $this->lineitems[count($this->lineitems)-1]->fieldname) 511 $ln = 2; 512 513 $pdf->Cell($column->size, 0.17, $value, $pdf->borderDebug, $ln, $column->align); 514 break; 515 516 }//end switch 517 518 }//end foreach 519 520 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); 521 $pdf->SetLineWidth(0.01); 522 $pdf->SetDrawColor(180,180,180); 523 $pdf->Line($pdf->leftmargin, $pdf->GetY(), $pdf->paperwidth - $pdf->rightmargin, $pdf->GetY()); 524 $pdf->SetDrawColor(0,0,0); 525 $pdf->SetLineWidth(0.02); 526 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); 527 528 }//end while 529 530 $pdf->SetLineWidth(0.02); 531 $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); 532 533 }//end method 534 535 536 function _getLineItems(){ 537 538 $querystatement = " 539 SELECT 540 receiptitems.aritemid, 541 receiptitems.applied, 542 receiptitems.discount, 543 receiptitems.taxadjustment, 544 aritems.type, 545 IF(`invoices`.`id`,`invoices`.`id`,`receipts`.`id`) AS `relatedid`, 546 aritems.itemdate, 547 aritems.amount, 548 aritems.paid 549 FROM 550 ((receiptitems INNER JOIN aritems ON receiptitems.aritemid = aritems.uuid)LEFT JOIN `invoices` ON `aritems`.`relatedid` = `invoices`.`uuid`) LEFT JOIN `receipts` ON `aritems`.`relatedid` = `receipts`.`uuid` 551 WHERE 552 receiptitems.receiptid = '".mysql_real_escape_string($this->receiptrecord["uuid"])."' 553 ORDER BY 554 aritems.type, 555 aritems.itemdate"; 556 557 return $this->db->query($querystatement); 558 559 }//end method 560 561 562 function _addNotes(){ 563 564 $pdf = &$this->pdf; 565 566 $height = 1; 567 $nextPos = $pdf->GetY() + $height + 0.125; 568 569 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 570 $pdf->setStyle("header"); 571 $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Notes", 1, 2, "L", 1); 572 573 $pdf->setStyle("normal"); 574 $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); 575 $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->receiptrecord["memo"]); 576 577 $pdf->SetXY($pdf->leftmargin, $nextPos); 578 579 }//end method 580 581 582 function _addTotals(){ 583 584 $pdf = &$this->pdf; 585 586 $size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin; 587 588 $tempTotalsinfo = $this->totalsinfo; 589 590 if($this->receiptrecord["remaining"]){ 591 592 $this->totalsinfo[1]->size = 1; 593 $size -= 1; 594 595 } else 596 array_shift($this->totalsinfo); 597 598 $this->totalsinfo[0]->size = $size; 599 600 $height = .5; 601 $nextPos = $pdf->GetY() + $height + 0.125; 602 603 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 604 605 $pdf->setStyle("header"); 606 607 foreach($this->totalsinfo as $column) 608 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 609 610 $pdf->setStyle("normal"); 611 $pdf->SetFont("Arial", "B", 10); 612 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); 613 614 foreach($this->totalsinfo as $column){ 615 616 if($column->format != "") 617 $value = formatVariable($this->receiptrecord[$column->fieldname], $column->format); 618 else 619 $value = $this->receiptrecord[$column->fieldname]; 620 621 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 622 623 }//end foreach 624 625 if(isset($this->totalsinfo[1])) 626 $this->totalsinfo[1]->size = 0; 627 628 $pdf->SetXY($pdf->leftmargin, $nextPos); 629 630 $this->totalsinfo = $tempTotalsinfo; 631 632 }//end method 633 634 635 636 function output($destination = "screen" , $userinfo = NULL){ 637 638 switch($destination){ 639 640 case "screen": 641 $userinfo = cleanFilename((string)$userinfo); 642 $this->pdf->Output($userinfo, 'D'); 643 break; 644 645 case "email": 646 647 if(!$userinfo) 648 $userinfo = $_SESSION["userinfo"]; 649 650 if(!$userinfo["email"] || !$this->receiptrecord["email"]) 651 return false; 652 653 $pdf = $this->pdf->Output(NULL, "S"); 654 655 $to = $this->receiptrecord["email"]; 656 $from = $userinfo["email"]; 657 $subject = "Your ".$this->title." from ".COMPANY_NAME; 658 $message = "Attached is your ".$this->title." from ".COMPANY_NAME."\n\n" . 659 "The attachment requires Adobe Acrobat Reader to view. \n If you do not " . 660 "have Acrobat Reader, you can download it at http://www.adobe.com \n\n" . 661 COMPANY_NAME."\n". 662 COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; 663 664 $headers = "From: $from"; 665 666 $semi_rand = md5( time() ); 667 $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 668 669 $headers .= "\nMIME-Version: 1.0\n" . 670 "Content-Type: multipart/mixed;\n" . 671 " boundary=\"{$mime_boundary}\""; 672 673 $message = "This is a multi-part message in MIME format.\n\n" . 674 "--{$mime_boundary}\n" . 675 "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 676 "Content-Transfer-Encoding: 7bit\n\n" . 677 $message . "\n\n"; 678 679 $pdf = chunk_split( base64_encode( $pdf ) ); 680 681 $message .= "--{$mime_boundary}\n" . 682 "Content-Type: {application/pdf};\n" . 683 " name=\"".$this->title.$this->receiptrecord["id"]."\"\n" . 684 "Content-Disposition: attachment;\n" . 685 " filename=\"".$this->title.$this->receiptrecord["id"].".pdf\"\n" . 686 "Content-Transfer-Encoding: base64\n\n" . 687 $pdf . "\n\n" . 688 "--{$mime_boundary}--\n"; 689 690 return @ mail($to, $subject, $message, $headers); 691 692 break; 693 694 }//endswitch 695 696 }//end method 697 698 }//end class 699 700 701 //PROCESSING 702 //============================================================================= 39 if(!class_exists("phpbmsReport")) 40 include("../../../report/report_class.php"); 41 42 class receiptPDF extends phpbmsReport{ 43 44 var $lineitemBoxHeight = 4.25; 45 46 /** 47 * $count 48 * @var int The number of invoice records being displayed 49 */ 50 var $count; 51 52 53 function receiptPDF($db, $reportUUID, $tabledefUUID, $orientation='P', $unit='mm', $format='Letter'){ 54 55 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 56 57 if(!class_exists("phpbmsPDFReport")) 58 include("report/pdfreport_class.php"); 59 60 $this->pdf = new phpbmsPDFReport($db, $orientation, $unit, $format); 61 62 $this->checkForDefaultSettings(); 63 64 $this->initialize(); 65 66 $this->pdf->borderDebug = $this->settings["borderDebug"]; 67 68 }//end method 69 70 71 /** 72 * function checkForDefaultSettings 73 * 74 * Checks to make sure loaded report Settings exist and are correct 75 */ 76 function checkForDefaultSettings(){ 77 78 if(!isset($this->settings["reportTitle"])) 79 $this->settings["reportTitle"] = "Receipt"; 80 81 if(!isset($this->settings["borderDebug"])) 82 $this->settings["borderDebug"] = 0; 83 84 }//end function checkForDefaultSettings 85 86 87 /** 88 * function initialize 89 * 90 * This function sets column headings sizes, and formatting 91 */ 92 function initialize(){ 93 94 $pdf = &$this->pdf; 95 96 $topinfo = array(); 97 $topinfo[] = new pdfColumn("ID", "id", 0.75); 98 $topinfo[] = new pdfColumn("Date", "receiptdate", 1, "date"); 99 $topinfo[] = new pdfColumn("Processed By", "processedby", 0); 100 101 $size = 0; 102 foreach($topinfo as $column) 103 $size += $column->size; 104 105 $topinfo[2]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 106 107 $this->topinfo = $topinfo; 108 109 110 $lineitems = array(); 111 $lineitems[] = new pdfColumn("Doc Ref", "relatedid", 0.5); 112 $lineitems[] = new pdfColumn("Type", "type", 0.75); 113 $lineitems[] = new pdfColumn("Doc Date", "itemdate", 0.75, "date"); 114 $lineitems[] = new pdfColumn("Due Date", "duedate", 0.75, "date"); 115 116 $lineitems[] = new pdfColumn("Doc Amount", "amount", 0, "currency", "R"); 117 $lineitems[] = new pdfColumn("Applied", "applied", 0.75, "currency", "R"); 118 $lineitems[] = new pdfColumn("Discount", "discount", 0.75, "currency", "R"); 119 $lineitems[] = new pdfColumn("Tax Adj", "taxadjustment", 0.75, "currency", "R"); 120 121 $size = 0; 122 foreach($lineitems as $column) 123 $size += $column->size; 124 125 $lineitems[4]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; 126 127 $this->lineitems = $lineitems; 128 129 $totalsinfo = array(); 130 $totalsinfo[] = new pdfColumn("Distribution Remaining", "remaining", 0, "currency", "R"); 131 $totalsinfo[] = new pdfColumn("Receipt Total", "amount", 0, "currency", "R"); 132 133 $this->totalsinfo = $totalsinfo; 134 135 }//end method 136 137 138 function generate($whereclause = NULL, $sortorder = "receipts.id"){ 139 140 $pdf = &$this->pdf; 141 142 if($whereclause) 143 $this->whereClause= $whereclause; 144 elseif(!$this->whereClause) 145 $this->whereClause = "receipts.id = -400"; 146 147 if($sortorder) 148 $this->sortOrder = $sortorder; 149 elseif(!$this->sortOrder) 150 $this->sortOrder = "receipts.id"; 151 152 $paymentFields = ""; 153 if(ENCRYPT_PAYMENT_FIELDS){ 154 155 $paymentFields = " 156 ".$this->db->decrypt("`ccnumber`")." AS `ccnumber`, 157 ".$this->db->decrypt("`ccverification`")." AS `ccverification`, 158 ".$this->db->decrypt("`ccexpiration`")." AS `ccexpiration`, 159 ".$this->db->decrypt("`routingnumber`")." AS `routingnumber`, 160 ".$this->db->decrypt("`accountnumber`")." AS `accountnumber`, 161 "; 162 163 }//end if 164 165 $querystatement = " 166 SELECT 167 receipts.*, 168 ".$paymentFields." 169 170 clients.firstname, 171 clients.lastname, 172 clients.company, 173 addresses.address1, 174 addresses.address2, 175 addresses.city, 176 addresses.state, 177 addresses.postalcode, 178 addresses.country, 179 clients.homephone, 180 clients.workphone, 181 clients.email, 182 183 paymentmethods.name AS paymentname, 184 paymentmethods.type AS paymenttype, 185 186 users.firstname AS processorfirst, 187 users.lastname AS processorlast 188 189 FROM 190 receipts INNER JOIN clients ON receipts.clientid = clients.uuid 191 INNER JOIN users ON receipts.modifiedby = users.id INNER JOIN 192 addresstorecord ON addresstorecord.tabledefid = 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083' AND addresstorecord.primary = 1 193 AND addresstorecord.recordid = clients.uuid INNER JOIN addresses 194 ON addresstorecord.addressid = addresses.uuid 195 LEFT JOIN paymentmethods ON receipts.paymentmethodid = paymentmethods.uuid"; 196 197 $querystatement = $this->assembleSQL($querystatement); 198 $queryresult = $this->db->query($querystatement); 199 200 201 $this->count = $this->db->numRows($queryresult); 202 if($this->count == 0){ 203 204 $this->showNoRecords(); 205 exit; 206 207 }//end if 208 209 $pdf->logoInHeader = true; 210 $pdf->companyInfoInHeader = true; 211 $pdf->SetMargins(); 212 213 //iterate through each invoice record 214 while($receiptrecord = $this->db->fetchArray($queryresult)){ 215 216 $querystatement = " 217 SELECT 218 SUM(applied) AS thesum 219 FROM 220 receiptitems 221 WHERE 222 receiptid ='".$receiptrecord["uuid"]."' 223 "; 224 225 $sumresult = $this->db->query($querystatement); 226 $sumrecord = $this->db->fetchArray($sumresult); 227 228 $receiptrecord["remaining"] = $receiptrecord["amount"] - $sumrecord["thesum"]; 229 230 $this->page = 0; 231 232 $this->receiptrecord = $receiptrecord; 233 234 //adds top info 235 $top = $this->_addPage(); 236 237 $this->_addLineItems($top); 238 239 $pdf->SetXY($pdf->leftmargin, $top["y"] + $this->lineitemBoxHeight + 0.125); 240 241 //totals 242 $this->_addTotals(); 243 244 //Print any special/instructions and stuff 245 $this->_addNotes(); 246 247 $this->receiptrecord = $receiptrecord; 248 249 }//end while; 250 251 252 }//end method 253 254 255 function _addPage(){ 256 257 $pdf = &$this->pdf; 258 259 $pdf->AddPage(); 260 $this->page++; 261 262 $nextY = $pdf->getY(); 263 264 //TITLE 265 $titleWidth=2.375; 266 $titleHeight=.25; 267 $pdf->setStyle("title"); 268 $pdf->SetXY(-1*($titleWidth+$pdf->rightmargin), $pdf->topmargin); 269 $pdf->Cell($titleWidth, $titleHeight, $this->settings["reportTitle"], $pdf->borderDebug,1,"R"); 270 271 //CLIENT 272 $startY = $pdf->GetY() + 0.75; 273 274 $boxHeight = 1.75; 275 $boxWidth = ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin)/2 -0.0625; 276 277 $pdf->setLineWidth(0.02); 278 $pdf->Rect($pdf->leftmargin, $startY, $boxWidth, $boxHeight); 279 $pdf->setLineWidth(0.01); 280 281 $pdf->setStyle("header"); 282 $pdf->setY($startY); 283 $pdf->Cell($boxWidth, 0.17, "CLIENT", $pdf->borderDebug, 2, "L", 1); 284 $pdf->setStyle("normal"); 285 286 //Company Name 287 $companyDisplay = ""; 288 if($this->receiptrecord["company"]){ 289 $companyDisplay .= $this->receiptrecord["company"]; 290 if($this->receiptrecord["firstname"]) 291 $companyDisplay .= " (".$this->receiptrecord["firstname"]." ".$this->receiptrecord["lastname"].")"; 292 } else 293 $companyDisplay .= $this->receiptrecord["firstname"]." ".$this->receiptrecord["lastname"]; 294 295 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 296 $pdf->SetFont("Arial", "B", 10); 297 $pdf->Cell($boxWidth - 0.125, 0.17, $companyDisplay, $pdf->borderDebug, 2, "L"); 298 299 $client = $this->_setClientInfo(); 300 301 $pdf->SetFont("Arial", "", 10); 302 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 303 $pdf->MultiCell($boxWidth - 0.125,.17,$client, $pdf->borderDebug); 304 305 //PAYMENT 306 $pdf->setLineWidth(0.02); 307 $pdf->Rect($pdf->leftmargin + $boxWidth + 0.125, $startY, $boxWidth, $boxHeight); 308 $pdf->setLineWidth(0.01); 309 310 $pdf->setStyle("header"); 311 $pdf->setXY($pdf->leftmargin + $boxWidth + 0.125, $startY); 312 $pdf->Cell($boxWidth, 0.17, "PAYMENT", $pdf->borderDebug, 2, "L", 1); 313 $pdf->setStyle("normal"); 314 315 if(!$this->receiptrecord["paymentname"]) 316 $this->receiptrecord["paymentname"] = "Other"; 317 318 $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); 319 $pdf->SetFont("Arial", "B", 10); 320 $pdf->Cell($boxWidth - 0.125, 0.17, $this->receiptrecord["paymentname"], $pdf->borderDebug, 2, "L"); 321 322 323 $paymentInfo = $this->_getPaymentInfo(); 324 $pdf->SetFont("Arial", "", 10); 325 $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); 326 $pdf->MultiCell($boxWidth - 0.125,.17, $paymentInfo, $pdf->borderDebug); 327 328 $pdf->setXY($pdf->leftmargin, $startY + $boxHeight + 0.125); 329 330 $this->_addTopInfo(); 331 332 //line item headings 333 $pdf->setStyle("header"); 334 $pdf->SetLineWidth(0.02); 335 336 $coords["x"] = $pdf->GetX(); 337 $coords["y"] = $pdf->GetY(); 338 339 foreach($this->lineitems as $column) 340 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 341 342 343 return $coords; 344 345 }//end method 346 347 348 function _setClientInfo(){ 349 350 $client = $this->receiptrecord["address1"]; 351 352 if($this->receiptrecord["address2"]) 353 $client .= "\n".$this->receiptrecord["address2"]; 354 355 $client .="\n".$this->receiptrecord["city"].", ".$this->receiptrecord["state"]." ".$this->receiptrecord["postalcode"]; 356 357 if($this->receiptrecord["country"]) 358 $client .=" ".$this->receiptrecord["country"]; 359 360 $phoneemail = ""; 361 if($this->receiptrecord["workphone"] || $this->receiptrecord["homephone"]){ 362 363 if($this->receiptrecord["workphone"]) 364 $phoneemail = $this->receiptrecord["workphone"]." (W)"; 365 else 366 $phoneemail = $this->receiptrecord["homephone"]." (H)"; 367 368 $phoneemail.="\n"; 369 370 }//end if 371 372 if($this->receiptrecord["email"]) 373 $phoneemail .= $this->receiptrecord["email"]; 374 375 if($phoneemail) 376 $client .= "\n\n".$phoneemail; 377 378 return $client; 379 380 }//end method 381 382 383 function _getPaymentInfo(){ 384 385 $info = ""; 386 387 switch($this->receiptrecord["paymenttype"]){ 388 389 case "charge": 390 391 $info .= $this->receiptrecord["ccnumber"]; 392 $info .= "\n Expires: ".$this->receiptrecord["ccexpiration"]; 393 if($this->receiptrecord["ccverification"]) 394 $info .= "\n Verification/Pin: ".$this->receiptrecord["ccverification"]; 395 break; 396 397 case "draft": 398 399 $info .= $this->receiptrecord["bankname"]; 400 $info .= "\n Check No: ".$this->receiptrecord["checkno"]; 401 402 if($this->receiptrecord["accountnumber"] || $this->receiptrecord["routingnumber"]) 403 $info .= "\n"; 404 405 if($this->receiptrecord["accountnumber"]) 406 $info .="\n".$this->receiptrecord["accountnumber"]; 407 408 if($this->receiptrecord["routingnumber"]) 409 $info .="\n".$this->receiptrecord["routingnumber"]; 410 411 break; 412 413 default: 414 415 if(!$this->receiptrecord["paymentmethodid"]) 416 $info .= $this->receiptrecord["paymentother"]; 417 418 }//endswitch 419 420 if($this->receiptrecord["transactionid"]) 421 $info .= "\nTransaction ID: ".$this->receiptrecord["transactionid"]; 422 423 return $info; 424 425 }//end method 426 427 428 function _addTopInfo(){ 429 430 $pdf = &$this->pdf; 431 432 $pdf->setStyle("header"); 433 $pdf->SetLineWidth(0.02); 434 435 foreach($this->topinfo as $column) 436 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 437 438 $pdf->Rect($pdf->leftmargin, $pdf->GetY(), ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin), 0.39); 439 440 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + .2); 441 442 443 $this->receiptrecord["processedby"] = $this->receiptrecord["processorfirst"]." ".$this->receiptrecord["processorlast"]; 444 $pdf->setStyle("normal"); 445 446 foreach($this->topinfo as $column){ 447 448 if($column->format != "") 449 $value = formatVariable($this->receiptrecord[$column->fieldname], $column->format); 450 else 451 $value = $this->receiptrecord[$column->fieldname]; 452 453 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 454 455 }//end foreach 456 457 $pdf->SetY($pdf->GetY() + 0.18 + 0.125); 458 459 }//end method 460 461 462 function _addLineItems($coords){ 463 464 $pdf = &$this->pdf; 465 466 $lineitemresult = $this->_getLineItems(); 467 468 $pdf->setStyle("normal"); 469 470 $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); 471 472 while($line = $this->db->fetchArray($lineitemresult)){ 473 474 if($pdf->GetY() + 0.17*3 > $coords["y"] + $this->lineitemBoxHeight){ 475 476 $pdf->SetLineWidth(0.02); 477 $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); 478 $pdf->SetLineWidth(0.01); 479 480 $this->_addPage(); 481 482 }//end if 483 484 if($line["type"] == "invoice"){ 485 486 $tempDate = stringToDate($line["itemdate"], "SQL"); 487 $line["duedate"] = dateToString( strtotime(TERM1_DAYS." days", $tempDate), "SQL" ); 488 489 } else 490 $line["duedate"] = ""; 491 492 if($line["type"] == "deposit" && $line["relatedid"] == $this->receiptrecord["id"]){ 493 $line["relatedid"] = ""; 494 $line["amount"] = 0; 495 $line["aritemid"] = 0; 496 } 497 498 if($this->receiptrecord["posted"]) 499 $line["docdue"] = $line["amount"] - $line["paid"]; 500 elseif($line["relatedid"]) 501 $line["docdue"] = $line["amount"] - $line["paid"] - $line["applied"] - $line["discount"] - $line["taxadjustment"]; 502 else 503 $line["docDue"] = 0; 504 505 506 foreach($this->lineitems as $column){ 507 508 $ln = 0; 509 510 511 switch($column->fieldname){ 512 513 case "parts": 514 $pdf->SetFont("Arial", "B", 8); 515 $pdf->Write(0.17, $line["partname"]); 516 $pdf->setStyle("normal"); 517 $pdf->SetX($pdf->leftmargin + $column->size); 518 break; 519 520 default: 521 if($column->format != "") 522 $value = formatVariable($line[$column->fieldname], $column->format); 523 else 524 $value = $line[$column->fieldname]; 525 526 if($value == "·") 527 $value = " "; 528 529 if($column->fieldname == $this->lineitems[count($this->lineitems)-1]->fieldname) 530 $ln = 2; 531 532 $pdf->Cell($column->size, 0.17, $value, $pdf->borderDebug, $ln, $column->align); 533 break; 534 535 }//end switch 536 537 }//end foreach 538 539 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); 540 $pdf->SetLineWidth(0.01); 541 $pdf->SetDrawColor(180,180,180); 542 $pdf->Line($pdf->leftmargin, $pdf->GetY(), $pdf->paperwidth - $pdf->rightmargin, $pdf->GetY()); 543 $pdf->SetDrawColor(0,0,0); 544 $pdf->SetLineWidth(0.02); 545 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); 546 547 }//end while 548 549 $pdf->SetLineWidth(0.02); 550 $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); 551 552 }//end method 553 554 555 function _getLineItems(){ 556 557 $querystatement = " 558 SELECT 559 receiptitems.aritemid, 560 receiptitems.applied, 561 receiptitems.discount, 562 receiptitems.taxadjustment, 563 aritems.type, 564 IF(`invoices`.`id`,`invoices`.`id`,`receipts`.`id`) AS `relatedid`, 565 aritems.itemdate, 566 aritems.amount, 567 aritems.paid 568 FROM 569 ((receiptitems INNER JOIN aritems ON receiptitems.aritemid = aritems.uuid)LEFT JOIN `invoices` ON `aritems`.`relatedid` = `invoices`.`uuid`) LEFT JOIN `receipts` ON `aritems`.`relatedid` = `receipts`.`uuid` 570 WHERE 571 receiptitems.receiptid = '".mysql_real_escape_string($this->receiptrecord["uuid"])."' 572 ORDER BY 573 aritems.type, 574 aritems.itemdate"; 575 576 return $this->db->query($querystatement); 577 578 }//end method 579 580 581 function _addNotes(){ 582 583 $pdf = &$this->pdf; 584 585 $height = 1; 586 $nextPos = $pdf->GetY() + $height + 0.125; 587 588 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 589 $pdf->setStyle("header"); 590 $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Notes", 1, 2, "L", 1); 591 592 $pdf->setStyle("normal"); 593 $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); 594 $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->receiptrecord["memo"]); 595 596 $pdf->SetXY($pdf->leftmargin, $nextPos); 597 598 }//end method 599 600 601 function _addTotals(){ 602 603 $pdf = &$this->pdf; 604 605 $size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin; 606 607 $tempTotalsinfo = $this->totalsinfo; 608 609 if($this->receiptrecord["remaining"]){ 610 611 $this->totalsinfo[1]->size = 1; 612 $size -= 1; 613 614 } else 615 array_shift($this->totalsinfo); 616 617 $this->totalsinfo[0]->size = $size; 618 619 $height = .5; 620 $nextPos = $pdf->GetY() + $height + 0.125; 621 622 $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); 623 624 $pdf->setStyle("header"); 625 626 foreach($this->totalsinfo as $column) 627 $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); 628 629 $pdf->setStyle("normal"); 630 $pdf->SetFont("Arial", "B", 10); 631 $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); 632 633 foreach($this->totalsinfo as $column){ 634 635 if($column->format != "") 636 $value = formatVariable($this->receiptrecord[$column->fieldname], $column->format); 637 else 638 $value = $this->receiptrecord[$column->fieldname]; 639 640 $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); 641 642 }//end foreach 643 644 if(isset($this->totalsinfo[1])) 645 $this->totalsinfo[1]->size = 0; 646 647 $pdf->SetXY($pdf->leftmargin, $nextPos); 648 649 $this->totalsinfo = $tempTotalsinfo; 650 651 }//end method 652 653 654 655 function output($destination = "screen" , $userinfo = NULL){ 656 657 switch($destination){ 658 659 case "screen": 660 $userinfo = cleanFilename((string)$userinfo); 661 $this->pdf->Output($userinfo, 'D'); 662 break; 663 664 case "email": 665 666 if(!$userinfo) 667 $userinfo = $_SESSION["userinfo"]; 668 669 if(!$userinfo["email"] || !$this->receiptrecord["email"]) 670 return false; 671 672 $pdf = $this->pdf->Output(NULL, "S"); 673 674 $to = $this->receiptrecord["email"]; 675 $from = $userinfo["email"]; 676 $subject = "Your ".$this->settings["reportTitle"]." from ".COMPANY_NAME; 677 $message = "Attached is your ".$this->settings["reportTitle"]." from ".COMPANY_NAME."\n\n" . 678 "The attachment requires Adobe Acrobat Reader to view. \n If you do not " . 679 "have Acrobat Reader, you can download it at http://www.adobe.com \n\n" . 680 COMPANY_NAME."\n". 681 COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; 682 683 $headers = "From: $from"; 684 685 $semi_rand = md5( time() ); 686 $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 687 688 $headers .= "\nMIME-Version: 1.0\n" . 689 "Content-Type: multipart/mixed;\n" . 690 " boundary=\"{$mime_boundary}\""; 691 692 $message = "This is a multi-part message in MIME format.\n\n" . 693 "--{$mime_boundary}\n" . 694 "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 695 "Content-Transfer-Encoding: 7bit\n\n" . 696 $message . "\n\n"; 697 698 $pdf = chunk_split( base64_encode( $pdf ) ); 699 700 $message .= "--{$mime_boundary}\n" . 701 "Content-Type: {application/pdf};\n" . 702 " name=\"".$this->settings["reportTitle"].$this->receiptrecord["id"]."\"\n" . 703 "Content-Disposition: attachment;\n" . 704 " filename=\"".$this->settings["reportTitle"].$this->receiptrecord["id"].".pdf\"\n" . 705 "Content-Transfer-Encoding: base64\n\n" . 706 $pdf . "\n\n" . 707 "--{$mime_boundary}--\n"; 708 709 return @ mail($to, $subject, $message, $headers); 710 711 break; 712 713 }//endswitch 714 715 }//end method 716 717 /** 718 * function addingRecordDefaultSettings 719 * 720 * Creates an array of settings associative arrays for use by the system when 721 * a new report record is added that references the file containing this class 722 * 723 * @retrun array of settings. Each setting should itself be 724 * an associative array containing the following 725 * name: name of the setting 726 * defaultvalue: default value for setting 727 * type: (string, int, real, bool) type for value of setting 728 * required: (0,1) whether the setting is required or not 729 * description: brief description for what this setting is used for. 730 */ 731 function addingRecordDefaultSettings(){ 732 733 $settings[] = array( 734 "name"=>"reportTitle", 735 "defaultValue"=>"Receipt", 736 "type"=>"string", 737 "required"=>1, 738 "description"=>"Title printed in upper right hand of report." 739 ); 740 741 return $settings; 742 743 }//endfunction addingRecordDefaultSettings 744 745 }//end class 746 747 748 /** 749 * PROCESSING 750 * ============================================================================= 751 */ 703 752 if(!isset($noOutput)){ 704 753 705 //IE needs caching to be set to private in order to display PDFS 706 session_cache_limiter('private'); 707 708 709 710 $report = new receiptPDF($db, 'P', 'in', 'Letter'); 711 $report->setupFromPrintScreen(); 712 $report->generate(); 713 714 $filename = 'Receipts_'; 715 if($report->count === 1){ 716 717 if($report->invoicerecord["company"]) 718 $filename .= "_".$report->invoicerecord["company"]; 719 720 $filename .= "_".$report->invoicerecord["id"]; 721 722 }elseif((int)$report->count) 723 $filename .= "_Multiple"; 724 725 $filename .= ".pdf"; 726 $report->output('screen', $filename); 754 //IE needs caching to be set to private in order to display PDFS 755 session_cache_limiter('private'); 756 757 //set encoding to latin1 (fpdf doesnt like utf8) 758 $sqlEncoding = "latin1"; 759 require_once("../../../include/session.php"); 760 761 checkForReportArguments(); 762 763 $report = new receiptPDF($db, $_GET["rid"], $_GET["tid"], 'P', 'in', 'Letter'); 764 $report->setupFromPrintScreen(); 765 $report->generate(); 766 767 $filename = 'Receipts'; 768 769 if($report->count === 1){ 770 771 if($report->receiptrecord["company"]) 772 $filename .= "_".$report->receiptrecord["company"]; 773 else 774 $filename .= "_".$report->receiptrecord["firstname"]."_".$report->receiptrecord["lastname"]; 775 776 $filename .= "_".$report->receiptrecord["id"]; 777 778 }elseif((int)$report->count) 779 $filename .= "_MultiClient"; 780 781 $filename .= ".pdf"; 782 $report->output('screen', $filename); 727 783 728 784 }//end if 729 785 786 /** 787 * When adding a new report record, the add/edit needs to know what the class 788 * name is so that it can instantiate it, and grab it's default settings. 789 */ 790 if(isset($addingReportRecord)) 791 $reportClass ="receiptPDF"; 730 792 ?> -
trunk/phpbms/modules/bms/report/receipts_pttotals.php
r611 r693 39 39 40 40 if(!class_exists("phpbmsReport")) 41 include("../../../report/report_class.php");41 include("../../../report/report_class.php"); 42 42 43 43 class receiptsPTTotals extends phpbmsReport{ 44 44 45 function receiptsPTTotals($db ){46 47 parent::phpbmsReport($db);45 function receiptsPTTotals($db, $reportUUID, $tabledefUUID){ 46 47 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 48 48 49 49 }//end method … … 67 67 LEFT JOIN paymentmethods ON receipts.paymentmethodid = paymentmethods.uuid)"; 68 68 69 if($this->sort order)70 $this->sort order= "paymentmethods.id DESC, ".$this->sortorder;69 if($this->sortOrder) 70 $this->sortOrder= "paymentmethods.id DESC, ".$this->sortorder; 71 71 else 72 $this->sort order= "paymentmethods.id DESC, receipts.receiptdate";72 $this->sortOrder= "paymentmethods.id DESC, receipts.receiptdate"; 73 73 74 74 $querystatement = $this->assembleSQL($querystatement); … … 216 216 }//end method 217 217 218 }//end method 219 220 221 //PROCESSING 222 //======================================================================== 223 224 if(!isset($noOutput)){ 225 226 session_cache_limiter('private'); 227 228 require("../../../include/session.php"); 229 230 $report = new receiptsPTTotals($db); 231 $report->setupFromPrintScreen(); 232 $report->generate(); 233 $report->show(); 234 235 }//end if 236 218 }//end class 219 220 221 /** 222 * PROCESSING 223 * ============================================================================= 224 */ 225 if(!isset($noOutput)){ 226 227 session_cache_limiter('private'); 228 229 require("../../../include/session.php"); 230 231 checkForReportArguments(); 232 233 $report = new receiptsPTTotals($db, $_GET["rid"], $_GET["tid"]); 234 $report->setupFromPrintScreen(); 235 $report->generate(); 236 $report->show(); 237 238 }//end if 239 240 /** 241 * When adding a new report record, the add/edit needs to know what the class 242 * name is so that it can instantiate it, and grab it's default settings. 243 */ 244 if(isset($addingReportRecord)) 245 $reportClass ="generalExport"; 237 246 ?> -
trunk/phpbms/print.php
r643 r693 100 100 101 101 if(isset($_POST["choosereport"])){ 102 102 103 $tablePrinter->openwindows=""; 104 103 105 for($i=0;$i<count($_POST["choosereport"]);$i++){ 106 104 107 if($_POST["choosereport"][$i]){ 105 $querystatement="SELECT reportfile,type from reports where id=".$_POST["choosereport"][$i].";"; 106 $queryresult=$db->query($querystatement); 107 if(!$queryresult) $error = new appError(100,"Could not Retrieve Report Information"); 108 $reportrecord=$db->fetchArray($queryresult); 108 109 $querystatement = " 110 SELECT 111 `uuid`, 112 `reportfile`, 113 `type` 114 FROM 115 `reports` 116 WHERE 117 id = ".$_POST["choosereport"][$i]; 118 119 $queryresult = $db->query($querystatement); 120 121 if(!$queryresult) 122 $error = new appError(100,"Could not Retrieve Report Information"); 123 124 $reportrecord = $db->fetchArray($queryresult); 125 109 126 $fakeExtForIE=""; 110 if($reportrecord["type"]=="PDF Report") 111 $fakeExtForIE="&ext=.pdf"; 112 $dateTimeStamp="&ts=".mktime(); // make the url unique to avoid using browser cache 127 128 if($reportrecord["type"] == "PDF Report") 129 $fakeExtForIE = "' + String.fromCharCode(38) + ' &ext=.pdf"; 130 131 // make the url unique to avoid using browser cache 132 $dateTimeStamp = "' + String.fromCharCode(38) + 'ts=".mktime(); 133 113 134 //javascript open each report in new window 114 $tablePrinter->openwindows.="window.open('".APP_PATH.$reportrecord["reportfile"]."?tid=".urlencode($tablePrinter->tableid).$dateTimeStamp.$fakeExtForIE."','print".$i."');\n"; 115 } 116 } 117 } 135 $tablePrinter->openwindows .= "window.open('".APP_PATH.$reportrecord["reportfile"]."?rid=".urlencode($reportrecord["uuid"])."' + String.fromCharCode(38) + 'tid=".urlencode($tablePrinter->tableid).$dateTimeStamp.$fakeExtForIE."','print".$i."');\n"; 136 137 }//endif 138 139 }//endfor 140 141 }//endif 142 118 143 break; 119 144 } -
trunk/phpbms/report/general_export.php
r580 r693 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 if(!class_exists("phpbmsReport")) 40 include("report_class.php"); 41 42 class generalExport extends phpbmsReport { 43 44 var $maintable = ""; 45 var $resultOutput = ""; 46 var $tabledefuuid; 47 48 function generalExport($db, $tabledefuuid){ 49 50 $this->tabledefuuid = mysql_real_escape_string($tabledefuuid); 51 52 parent::phpbmsReport($db); 53 54 $querystatement = " 55 SELECT 56 maintable 57 FROM 58 tabledefs 59 WHERE 60 uuid = '".$this->tabledefuuid."'"; 61 62 $queryresult = $db->query($querystatement); 63 $therecord=$db->fetchArray($queryresult); 64 65 $this->maintable = $therecord["maintable"]; 66 67 }//end method 68 69 70 function generate(){ 71 72 $querystatement = " 73 SELECT 74 * 75 FROM 76 ".$this->maintable; 77 78 $querystatement = $this->assembleSQL($querystatement); 79 80 $queryresult = $this->db->query($querystatement); 81 82 $num_fields = $this->db->numFields($queryresult); 83 84 for($i=0;$i<$num_fields;$i++) 85 $this->reportOutput .= ",".$this->db->fieldName($queryresult, $i); 86 87 $this->reportOutput = substr($this->reportOutput, 1)."\n"; 88 89 while($therecord = $this->db->fetchArray($queryresult)){ 90 91 $line = ""; 92 93 foreach($therecord as $value) 94 $line .= ',"'.mysql_real_escape_string($value).'"'; 95 96 $line = substr($line, 1)."\n"; 97 98 $this->reportOutput .= $line; 99 100 }//endwhile 101 102 $this->reportOutput = substr($this->reportOutput, 0, strlen($this->reportOutput)-1); 103 104 }//end method 105 106 107 function show(){ 108 109 header("Content-type: text/plain"); 110 header('Content-Disposition: attachment; filename="export.txt"'); 111 112 echo $this->reportOutput; 113 114 }//end method 115 116 }//end class 117 118 119 //PROCESSING 120 //======================================================================== 121 122 if(!isset($noOutput)){ 123 124 session_cache_limiter('private'); 125 126 require("../include/session.php"); 127 if(!isset($_GET["tid"])) 128 $error = new appError(200,"URL variable missing: tid"); 129 130 $report = new generalExport($db, $_GET["tid"]); 131 $report->setupFromPrintScreen(); 132 $report->generate(); 133 $report->show(); 134 135 }//end if 136 39 if(!class_exists("phpbmsReport")) 40 include("report_class.php"); 41 42 /** 43 * Basic CSV output report 44 * 45 * This class implements a report used for creating a CSV file through reporting 46 */ 47 class generalExport extends phpbmsReport { 48 49 /** 50 * $maintable 51 * @var string the SQL name of the main table to print. 52 */ 53 var $maintable = ""; 54 55 56 /** 57 * function generalExport 58 * 59 * Initialization function 60 * 61 * @param object $db database object 62 * @param string $reportUUID UUID of report record 63 * @param string $tabledefUUID UUID of table definition intializing print 64 */ 65 function generalExport($db, $reportUUID, $tabledefUUID){ 66 67 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 68 69 $this->checkForDefaultSettings(); 70 71 $therecord = $this->getTableDefInfo(); 72 73 $this->maintable = $therecord["maintable"]; 74 75 }//end function init 76 77 78 /** 79 * function checkForDefaultSettings 80 * 81 * Checks to make sure loaded report Settings exist and are correct 82 */ 83 function checkForDefaultSettings(){ 84 85 if(!isset($this->settings["showHeader"])) 86 $this->settings["showHeader"] = 1; 87 88 if(!isset($this->settings["fieldDelimiter"])) 89 $this->settings["fieldDelimiter"] = ","; 90 91 if(!isset($this->settings["recordDelimiter"])) 92 $this->settings["recordDelimiter"] = "\n"; 93 94 if(!isset($this->settings["fieldEncapsulation"])) 95 $this->settings["fieldEncapsulation"] = "\""; 96 97 }//end function checkForDefaultSettings 98 99 100 /** 101 * function generate 102 * 103 * Creates body of the file. 104 */ 105 function generate(){ 106 107 $fromFields = "*"; 108 109 $columns = array(); 110 foreach($this->settings as $key=>$value){ 111 112 if(strpos($key, "column") === 0){ 113 114 $pos = substr($key,6)-1; 115 $columns[$pos]["field"] = $value; 116 117 if(isset($this->settings["titleColumn".($pos + 1)])) 118 $columns[$pos]["title"] = $this->settings["titleColumn".($pos +1)]; 119 else 120 $columns[$pos]["title"] = ""; 121 122 }//endif 123 124 }//endforeach 125 126 if(count($columns)){ 127 128 ksort($columns); 129 130 $fromFields = ""; 131 foreach($columns as $column){ 132 133 $fromFields .= ", ".$column["field"]; 134 if($column["title"]) 135 $fromFields .= " AS `".$column["title"]."`"; 136 137 $fromFields.="\n"; 138 139 }//endforeach 140 141 $fromFields = substr($fromFields, 1); 142 143 }//endif 144 145 if(isset($this->settings["fromTable"])) 146 $querytable = $this->settings["fromTable"]; 147 else 148 $querytable = $this->maintable; 149 150 $querystatement = " 151 SELECT 152 ".$fromFields." 153 FROM 154 ".$querytable; 155 156 $querystatement = $this->assembleSQL($querystatement); 157 158 $queryresult = $this->db->query($querystatement); 159 160 $num_fields = $this->db->numFields($queryresult); 161 162 /** 163 * generating column names. First row is just field names 164 */ 165 if($this->settings["showHeader"]) 166 for($i=0;$i<$num_fields;$i++) 167 $this->reportOutput .= $this->settings["fieldDelimiter"].$this->db->fieldName($queryresult, $i); 168 169 $this->reportOutput = substr($this->reportOutput, strlen($this->settings["fieldDelimiter"])).$this->settings["recordDelimiter"]; 170 171 /** 172 * Looping through retrieved records. 173 */ 174 while($therecord = $this->db->fetchArray($queryresult)){ 175 176 $line = ""; 177 178 foreach($therecord as $value) 179 $line .= $this->settings["fieldDelimiter"].$this->settings["fieldEncapsulation"].mysql_real_escape_string($value).$this->settings["fieldEncapsulation"]; 180 181 $line = substr($line, strlen($this->settings["fieldDelimiter"])).$this->settings["recordDelimiter"]; 182 183 $this->reportOutput .= $line; 184 185 }//endwhile 186 187 /** 188 * removing last \n 189 */ 190 $this->reportOutput = substr($this->reportOutput, 0, strlen($this->reportOutput) - strlen($this->settings["recordDelimiter"])); 191 192 }//end function generate 193 194 195 /** 196 * function show 197 * 198 * Outputing generated data 199 */ 200 function show(){ 201 202 if(!isset($this->settings["filename"])) 203 $this->settings["filename"] = $this->maintable."-export.txt"; 204 echo "<pre>"; 205 //header("Content-type: text/plain"); 206 //header('Content-Disposition: attachment; filename="'.$this->settings["filename"].'"'); 207 208 echo $this->reportOutput; 209 210 }//end function show 211 212 }//end class 213 214 215 /** 216 * PROCESSING 217 * ============================================================================= 218 */ 219 if(!isset($noOutput)){ 220 221 session_cache_limiter('private'); 222 223 require_once("../include/session.php"); 224 225 checkForReportArguments(); 226 227 $report = new generalExport($db, $_GET["rid"],$_GET["tid"]); 228 $report->setupFromPrintScreen(); 229 $report->generate(); 230 $report->show(); 231 232 }//end if 233 234 /** 235 * When adding a new report record, the add/edit needs to know what the class 236 * name is so that it can instantiate it, and grab it's default settings. 237 */ 238 if(isset($addingReportRecord)) 239 $reportClass ="generalExport"; 137 240 ?> -
trunk/phpbms/report/general_labels.php
r673 r693 38 38 */ 39 39 40 //set mysql encoding to latin1 (fpdf doesn't like utf) 41 $db->setEncoding("latin1"); 42 43 // The label report requires the following variables to be set before creating the PDF 44 //maxrows 45 //maxcolumns 46 //columnmargin 47 //labelheight 48 //labelwidth 49 //top_start 50 //left_start 51 //border debug 52 //reportquerystatement 53 if(!isset($border_debug)) $border_debug=0; 54 55 //Also, it requires the definition of the function printLabel($pdf,$therecord,$thex,$they,$border_debug) which prints the actual 56 //contectens of the label 57 58 if(isset($_POST["command"])) { 59 60 if(!is_numeric($_POST["skiplabels"])) $_POST["skiplabels"]=0; 61 if ($_POST["skiplabels"]>$maxrows*$maxcolumns) $_POST["skiplabels"]=0; 62 63 64 65 //Generate the invoice Query 66 $reportquerystatement.=$_SESSION["printing"]["whereclause"].$sortorder; 67 $thequery=$db->query($reportquerystatement); 68 if(!$thequery) die("No records, or invalid SQL statement:<br />".$reportquerystatement); 69 //=================================================================================================== 70 // Generating PDF File. 71 //=================================================================================================== 72 73 //define the documents and margins 74 $pdf=new FPDF("P","in","Letter"); 75 $pdf->Open(); 76 $pdf->SetMargins(0,0); 77 78 $pdf->AddPage(); 79 80 $thex=$leftstart; 81 $they=$topstart; 82 $rowcount=1; 83 $totalcount=1; 84 $column=1; 85 //this first while skips records 86 87 while($totalcount<=$_POST["skiplabels"]){ 88 if($rowcount>$maxrows) { 89 $column++; 90 $they=$topstart; 91 $thex+=$labelwidth+$columnmargin; 92 $rowcount=1; 93 } 94 $they+=$labelheight; 95 $rowcount++; 96 $totalcount++; 97 } 98 99 $thisCount = $db->numRows($thequery); 100 while($therecord=$db->fetchArray($thequery)) { 101 102 if($rowcount>$maxrows) { 103 $column++; 104 $they=$topstart; 105 $thex+=$labelwidth+$columnmargin; 106 $rowcount=1; 107 } 108 if($column>$maxcolumns){ 109 $pdf->AddPage(); 110 $thex=$leftstart; 111 $they=$topstart; 112 $rowcount=1; 113 $column=1; 114 } 115 $pdf=printLabel($pdf,$therecord,$thex,$they,$border_debug); 116 117 $they+=$labelheight; 118 $rowcount++; 119 120 $company = $therecord["company"]; 121 122 }// end fetch_array while loop 123 124 if($thisCount === 1){ 125 if($company) 126 $filename .= "_".$company; 127 }elseif((int)$thisCount) 128 $filename .= "_Multiple"; 129 130 131 $filename = cleanFilename($filename); 132 $filename .= ".pdf"; 133 $pdf->Output($filename, 'D'); 134 exit(); 135 } else { 40 if(!class_exists("phpbmsReport")) 41 include("report_class.php"); 42 43 /** 44 * Handles Label Printing 45 */ 46 class pdfLabels extends phpbmsReport{ 47 48 /** 49 * $maintable 50 * @var string the SQL name of the main table to print. 51 */ 52 var $maintable = ""; 53 54 /** 55 * $skipLabels 56 * @var int number of lables to skip before printing. 57 */ 58 var $skipLabels = 0; 59 60 61 /** 62 * function pdfLabels 63 * 64 * initialization function 65 */ 66 function pdfLabels($db, $reportUUID, $tabledefUUID){ 67 68 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 69 70 $therecord = $this->getTableDefInfo(); 71 72 $this->maintable = $therecord["maintable"]; 73 74 $this->checkForDefaultSettings(); 75 76 }//end function init 77 78 79 /** 80 * function checkForDefaultSettings 81 * 82 * Checks to make sure loaded report Settings exist and are correct 83 */ 84 function checkForDefaultSettings(){ 85 86 if(!isset($this->settings["maxRows"])) 87 $this->settings["maxRows"] = 10; 88 89 if(!isset($this->settings["maxColumns"])) 90 $this->settings["maxColumns"] = 3; 91 92 if(!isset($this->settings["columnMargin"])) 93 $this->settings["columnMargin"] = 1/8; 94 95 if(!isset($this->settings["labelHeight"])) 96 $this->settings["labelHeight"] = 1; 97 98 if(!isset($this->settings["labelWidth"])) 99 $this->settings["labelWidth"] = 2 + (5/8); 100 101 if(!isset($this->settings["startTop"])) 102 $this->settings["startTop"] = 1/2; 103 104 if(!isset($this->settings["startLeft"])) 105 $this->settings["startLeft"] = 3/16; 106 107 if(!isset($this->settings["borderDebug"])) 108 $this->settings["borderDebug"] = 0; 109 110 if(!isset($this->settings["queryStatement"])) 111 $this->settings["queryStatement"] = 'SELECT "no data in first row" AS `rowText1`, "no data in second row" AS `rowText2` FROM `'.$this->maintable.'`'; 112 113 if(!isset($this->settings["defaultSortOrder"])) 114 $this->settings["defaultSortOrder"] = ''; 115 116 if(!isset($this->settings["fileName"])) 117 $this->settings["fileName"] = $this->maintable.'-labels.pdf'; 118 119 if(!isset($this->settings["labelMarginTop"])) 120 $this->settings["labelMarginTop"] = 1/8; 121 122 if(!isset($this->settings["labelMarginLeft"])) 123 $this->settings["labelMarginLeft"] = 1/16; 124 125 if(!isset($this->settings["rowText1Font"])) 126 $this->settings["rowText1Font"] = "Arial,B,9"; 127 128 }//end function checkForDefaultSettings 129 130 131 /** 132 * function siplaySkipLabels 133 * 134 * Displays dialog so that people can skip labels when printing 135 */ 136 function displaySkipLabels(){ 137 138 global $phpbms; 136 139 137 140 $pageTitle = "Label Options"; … … 140 143 include("header.php"); 141 144 145 ?> 146 <form action="<?php echo str_replace("&", "&", $_SERVER["REQUEST_URI"])?>" method="post" name="print_form"> 147 <div class="bodyline" id="reportOptions"> 148 149 <h1 id="topTitle"><span>Label Options</span></h1> 150 151 <p> 152 <label for="skipLabels">skip first labels</label><br /> 153 <input name="skipLabels" id="skipLabels" value="0" size="3" maxlength="3" /> 154 </p> 155 <p align="right"> 156 <input name="command" type="submit" class="Buttons" id="print" value="print" /> 157 <input name="cancel" type="button" class="Buttons" id="cancel" value="cancel" onclick="window.close();" /> 158 </p> 159 160 </div> 161 </form> 162 <?php 163 164 include("footer.php"); 165 166 }//end function displaySkipLabels 167 168 169 /** 170 * function generate 171 * 172 * Generates the PDF report 173 */ 174 function generate(){ 175 176 if($this->skipLabels >= $this->settings["maxRows"] * $this->settings["maxColumns"]) 177 $this->skipLabels = 0; 178 179 if($this->settings["defaultSortOrder"] && !$this->sortOrder) 180 $this->sortOrder = $this->settings["defaultSortOrder"]; 181 182 $querystatement = $this->assembleSQL($this->settings["queryStatement"]); 183 184 $queryresult = $this->db->query($querystatement); 185 186 if(!class_exists("phpbmsPDFReport")) 187 include("pdfreport_class.php"); 188 189 $pdf = new phpbmsPDFReport($this->db, "P", "in"); 190 191 $pdf->Open(); 192 $pdf->SetMargins(0,0); 193 194 $pdf->AddPage(); 195 196 $thex = $this->settings["startLeft"]; 197 $they = $this->settings["startTop"]; 198 $rowcount = 1; 199 $totalcount = 1; 200 $column = 1; 201 $textRows = 0; 202 203 /** 204 * skipping labels 205 */ 206 while($totalcount <= $this->skipLabels){ 207 208 if($rowcount > $this->settings["maxRows"]){ 209 210 $column++; 211 $they = $this->settings["startTop"]; 212 $thex += $this->settings["labelWidth"] + $this->settings["columnMargin"]; 213 $rowcount = 1; 214 215 }//endif 216 217 $they += $this->settings["labelHeight"]; 218 $rowcount++; 219 $totalcount++; 220 221 }//endwhile 222 223 $thisCount = $this->db->numRows($queryresult); 224 225 while($therecord = $this->db->fetchArray($queryresult)){ 226 227 //initialize amount of text rows 228 if(!$textRows){ 229 230 $textRows = 0; 231 232 foreach($therecord as $key=>$value) 233 if(strpos($key, "rowText") === 0) 234 $textRows++; 235 236 }//endif 237 238 if($rowcount > $this->settings["maxRows"]){ 239 240 $column++; 241 $they = $this->settings["startTop"]; 242 $thex += $this->settings["labelWidth"] + $this->settings["columnMargin"]; 243 $rowcount = 1; 244 245 }//endif 246 247 if($column > $this->settings["maxColumns"]){ 248 249 $pdf->AddPage(); 250 $thex = $this->settings["startLeft"]; 251 $they = $this->settings["startTop"]; 252 $rowcount = 1; 253 $column = 1; 254 255 }//endif 256 257 $pdf = $this->printLabel($pdf, $therecord, $thex, $they, $textRows); 258 259 $they += $this->settings["labelHeight"]; 260 $rowcount++; 261 262 263 }//endwhile $therecord 264 265 $this->reportOutput = $pdf; 266 267 }//end function generate 268 269 270 /** 271 * function printLabel 272 * 273 * generates the contents on an individual label, and adds them to the PDF 274 * 275 * @param object $pdf the PDF object 276 * @param array $therecord the data record 277 * @param int $thex x corrdinate of current PDF 278 * @param int $they y coordinate of current PDF 279 * @param int $textRows number of text rows that will be printed 280 * 281 * @return object returns the modified PDF object 282 */ 283 function printLabel($pdf, $therecord, $thex, $they, $textRows){ 284 285 $pdf->SetXY($thex + $this->settings["labelMarginLeft"], $they + $this->settings["labelMarginTop"]); 286 287 288 $textHeight = 0.135; 289 290 for($i=1; $i<= $textRows; $i++){ 291 292 if(isset($this->settings["rowText".$i."Font"])) 293 $pdf = $this->setFont($pdf, $this->settings["rowText".$i."Font"]); 294 295 if(isset($this->settings["rowText".$i."Height"])) 296 $textHeight = $this->settings["rowText".$i."Height"]; 297 298 if($therecord["rowText".$i]) 299 $pdf->Cell($this->settings["labelWidth"] - $this->settings["labelMarginLeft"], $textHeight, $therecord["rowText".$i], $this->settings["borderDebug"], 2, "L"); 300 301 //$pdf->SetX($thex + $this->settings["labelMarginLeft"]); 302 303 }//endfor 304 305 return $pdf; 306 307 }//end function printLabel 308 309 310 /** 311 * function setFont 312 * 313 * Sets the current PDF font stle based on the passed setting 314 * 315 * @param object $pdf PDF object 316 * @param string $setting comma separated list of FPDF font paramaters 317 * 318 * @return object PDF object with font set appropriately 319 */ 320 function setFont($pdf, $setting){ 321 322 $settings = explode(",", $setting); 323 324 if(!isset($settings[1])) 325 $settings[1] = ""; 326 327 if(!isset($settings[2])) 328 $settings[2] =""; 329 330 $pdf->SetFont($settings[0], $settings[1], $settings[2]); 331 332 return $pdf; 333 334 }//end function setfont 335 336 337 /** 338 * function output 339 * 340 * sends the generated PDF through the browser 341 */ 342 function output(){ 343 344 $filename = cleanFilename($this->settings["fileName"]); 345 $this->reportOutput->Output($filename, "D"); 346 347 }//end function output 348 349 350 /** 351 * function addingRecordDefaultSettings 352 * 353 * Creates an array of settings associative arrays for use by the system when 354 * a new report record is added that references the file containing this class 355 * 356 * @retrun array of settings. Each setting should itself be 357 * an associative array containing the following 358 * name: name of the setting 359 * defaultvalue: default value for setting 360 * type: (string, int, real, bool) type for value of setting 361 * required: (0,1) whether the setting is required or not 362 * description: brief description for what this setting is used for. 363 */ 364 function addingRecordDefaultSettings(){ 365 366 $settings[] = array( 367 "name"=>"maxRows", 368 "defaultValue"=>10, 369 "type"=>"int", 370 "required"=>1, 371 "description"=>"Number of label rows per page" 372 ); 373 374 $settings[] = array( 375 "name"=>"maxColumns", 376 "defaultValue"=>3, 377 "type"=>"int", 378 "required"=>1, 379 "description"=>"Number of label columns per page" 380 ); 381 382 $settings[] = array( 383 "name"=>"startTop", 384 "defaultValue"=>1/2, 385 "type"=>"real", 386 "required"=>1, 387 "description"=>"Top Margin of page" 388 ); 389 390 $settings[] = array( 391 "name"=>"startLeft", 392 "defaultValue"=>3/16, 393 "type"=>"real", 394 "required"=>1, 395 "description"=>"Left Margin of page" 396 ); 397 398 $settings[] = array( 399 "name"=>"columnMargin", 400 "defaultValue"=>1/8, 401 "type"=>"real", 402 "required"=>1, 403 "description"=>"Distance between columns" 404 ); 405 406 $settings[] = array( 407 "name"=>"labelHeight", 408 "defaultValue"=>1, 409 "type"=>"real", 410 "required"=>1, 411 "description"=>"Height of a single label" 412 ); 413 414 $settings[] = array( 415 "name"=>"labelHeight", 416 "defaultValue"=>2 + 5/8, 417 "type"=>"real", 418 "required"=>1, 419 "description"=>"Width of a single label" 420 ); 421 422 $settings[] = array( 423 "name"=>"labelMarginLeft", 424 "defaultValue"=>1/16, 425 "type"=>"real", 426 "required"=>1, 427 "description"=>"Distance from left between the start of an individual to the text being put on it" 428 ); 429 430 $settings[] = array( 431 "name"=>"labelMarginTop", 432 "defaultValue"=>1/8, 433 "type"=>"real", 434 "required"=>1, 435 "description"=>"Distance from top between start of an individual to the text being put on it" 436 ); 437 438 $settings[] = array( 439 "name"=>"queryStatement", 440 "defaultValue"=>'SELECT "no data in first row" AS `rowText1`, "no data in second row" AS `rowText2` FROM `'.$this->maintable.'`', 441 "type"=>"text", 442 "required"=>1, 443 "description"=>"SQL SELECT and FROM clauses defining the data to be retrieved. Each line printed should be selected as a column in the format `rowText(X)`, where (X) is the line number it will be printed on" 444 ); 445 446 $settings[] = array( 447 "name"=>"rowText1Font", 448 "defaultValue"=>"Arial,B,9", 449 "type"=>"string", 450 "required"=>0, 451 "description"=>"Comma separated list of FPDF font parameters defining font settings for the label text. You can change the font on subsequent lines by adding an additional setting rowText(x)Font where (x) is the line number the font change occurs." 452 ); 453 454 return $settings; 455 456 }//endfunction addingRecordDefaultSettings 457 458 }//end class pdfLabels 459 460 461 /** 462 * PROCESSING 463 * ============================================================================= 464 */ 465 if(!isset($noOutput)){ 466 467 //IE needs caching to be set to private in order to display PDFS 468 session_cache_limiter('private'); 469 470 //set encoding to latin1 (fpdf doesnt like utf8) 471 $sqlEncoding = "latin1"; 472 require_once("../include/session.php"); 473 474 checkForReportArguments(); 475 476 $report = new pdfLabels($db, $_GET["rid"], $_GET["tid"]); 477 478 if(!isset($_POST["skipLabels"])) 479 $report->displaySkipLabels(); 480 else{ 481 482 $report->skipLabels = (int) $_POST["skipLabels"]; 483 484 $report->setupFromPrintScreen(); 485 $report->generate(); 486 $report->output(); 487 488 }//endif 489 490 491 }//end if 492 493 /** 494 * When adding a new report record, the add/edit needs to know what the class 495 * name is so that it can instantiate it, and grab it's default settings. 496 */ 497 if(isset($addingReportRecord)) 498 $reportClass ="pdfLabels"; 499 142 500 ?> 143 144 <form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" name="print_form">145 <div class="bodyline" id="reportOptions">146 <h1 id="topTitle"><span>Label Options</span></h1>147 148 <p>149 skip first labels<br />150 <input name="skiplabels" value="0" size="3" maxlength="3" />151 </p>152 <p align="right">153 <input name="command" type="submit" class="Buttons" id="print" value="print" />154 <input name="cancel" type="button" class="Buttons" id="cancel" value="cancel" onclick="window.close();" />155 </p>156 </div>157 </form>158 <?php include("footer.php"); }//end if ?> -
trunk/phpbms/report/general_sql.php
r578 r693 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 if(!class_exists("phpbmsReport")) 40 include("report_class.php"); 39 41 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 */ 49 class sqlExport extends phpbmsReport{ 42 50 43 class sqlExport extends phpbmsReport{ 51 /** 52 * $maintable 53 * @var string the SQL name of the main table to print. 54 */ 55 var $maintable = ""; 44 56 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){ 48 67 49 function sqlExport($db, $tabledefuuid){ 68 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 50 69 51 $this->tabledefuuid = mysql_real_escape_string($tabledefuuid);70 $therecord = $this->getTableDefInfo(); 52 71 53 parent::phpbmsReport($db);72 $this->maintable = $therecord["maintable"]; 54 73 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 69 75 70 76 71 function generate(){ 77 /** 78 * function generate 79 * 80 * Generates the SQL Insert statements for each record 81 */ 82 function generate(){ 72 83 73 $querystatement = "74 SELECT75 *76 FROM77 ".$this->maintable;84 $querystatement = " 85 SELECT 86 * 87 FROM 88 ".$this->maintable; 78 89 79 $querystatement = $this->assembleSQL($querystatement);90 $querystatement = $this->assembleSQL($querystatement); 80 91 81 $queryresult = $this->db->query($querystatement);92 $queryresult = $this->db->query($querystatement); 82 93 83 $num_fields = $this->db->numFields($queryresult);94 $num_fields = $this->db->numFields($queryresult); 84 95 85 $statementstart = "INSERT INTO `".$this->maintable."` (";96 $statementstart = "INSERT INTO `".$this->maintable."` ("; 86 97 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)."`, "; 89 100 90 $statementstart = substr($statementstart,0,strlen($statementstart)-2).") VALUES (";101 $statementstart = substr($statementstart,0,strlen($statementstart)-2).") VALUES ("; 91 102 92 while($therecord = $this->db->fetchArray($queryresult)){103 while($therecord = $this->db->fetchArray($queryresult)){ 93 104 94 $insertstatement = $statementstart;105 $insertstatement = $statementstart; 95 106 96 foreach($therecord as $name => $field){107 foreach($therecord as $name => $field){ 97 108 98 if($field === NULL)99 $addfield = "NULL, ";100 else101 $addfield = "'".mysql_real_escape_string($field)."', ";109 if($field === NULL) 110 $addfield = "NULL, "; 111 else 112 $addfield = "'".mysql_real_escape_string($field)."', "; 102 113 103 //this is in temp for intallation exporting104 if(hasRights("Admin")){114 //this is in temp for intallation exporting 115 if(hasRights("Admin")){ 105 116 106 switch($name){117 switch($name){ 107 118 108 case "createdby":109 case "modifiedby":110 $addfield = "1, ";111 break;119 case "createdby": 120 case "modifiedby": 121 $addfield = "1, "; 122 break; 112 123 113 case "creationdate":114 case "modifieddate":115 $addfield = "NOW(), ";116 break;124 case "creationdate": 125 case "modifieddate": 126 $addfield = "NOW(), "; 127 break; 117 128 118 }//end switch129 }//end switch 119 130 120 }//endif131 }//endif 121 132 122 $insertstatement .= $addfield;133 $insertstatement .= $addfield; 123 134 124 }//endforeach135 }//endforeach 125 136 126 $insertstatement = substr($insertstatement,0,strlen($insertstatement)-2).");\n";137 $insertstatement = substr($insertstatement,0,strlen($insertstatement)-2).");\n"; 127 138 128 $this->reportOutput .= $insertstatement;139 $this->reportOutput .= $insertstatement; 129 140 130 }//endwhile141 }//endwhile 131 142 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 133 163 134 164 135 function show(){ 165 /** 166 * PROCESSING 167 * ============================================================================= 168 */ 169 if(!isset($noOutput)){ 136 170 137 header("Content-type: text/plain"); 138 header('Content-Disposition: attachment; filename="export.sql"'); 171 session_cache_limiter('private'); 139 172 140 echo $this->reportOutput;173 require_once("../include/session.php"); 141 174 142 }//end method 175 checkForReportArguments(); 143 176 177 $report = new sqlExport($db, $_GET["rid"],$_GET["tid"]); 178 $report->setupFromPrintScreen(); 179 $report->generate(); 180 $report->show(); 144 181 145 }//end class 182 }//end if 146 183 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 */ 188 if(isset($addingReportRecord)) 189 $reportClass ="pdfLabels"; 149 190 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 if164 191 ?> -
trunk/phpbms/report/general_tableprint.php
r580 r693 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 if(!class_exists("phpbmsReport")) 40 include("report_class.php"); 41 42 class generalTablePrint extends phpbmsReport { 43 44 var $maintable = ""; 45 var $resultOutput = ""; 46 var $tabledefuuid; 47 48 function generalTablePrint($db, $tabledefuuid){ 49 50 $this->tabledefuuid = mysql_real_escape_string($tabledefuuid); 51 52 parent::phpbmsReport($db); 53 54 $querystatement = " 55 SELECT 56 maintable, displayname 57 FROM 58 tabledefs 59 WHERE 60 uuid = '".$this->tabledefuuid."'"; 61 62 $queryresult = $db->query($querystatement); 63 $therecord=$db->fetchArray($queryresult); 64 65 $this->maintable = $therecord["maintable"]; 66 $this->displayname = $therecord["displayname"]; 67 68 }//end method 69 70 71 function generate(){ 72 73 $querystatement = " 74 SELECT 75 * 76 FROM 77 ".$this->maintable; 78 79 $querystatement = $this->assembleSQL($querystatement); 80 81 $queryresult = $this->db->query($querystatement); 82 83 $num_fields = $this->db->numFields($queryresult); 84 85 ob_start(); 86 87 ?> 88 <div id="container"> 89 <h1><?php echo formatVariable($this->displayname)?></h1> 90 <table id="results"> 91 <thead> 92 <tr> 93 <?php 94 95 for($i=0;$i<$num_fields;$i++){ 96 97 ?> 98 <th <?php if($i == $num_fields-1) echo 'id="lastHeader"' ?>><?php echo $this->db->fieldName($queryresult, $i); ?></th> 99 100 <?php 101 102 }//end for 103 104 ?> 105 </tr> 106 </thead> 107 108 <tbody> 109 <?php 110 111 while($therecord = $this->db->fetchArray($queryresult)){ 112 113 ?><tr><?php 114 115 foreach($therecord as $value){ 116 117 ?><td><?php echo formatVariable($value)?></td><?php 118 119 }//end foreach 120 121 ?></tr><?php 122 123 }//endwhile 124 125 ?> 126 </tbody> 127 128 </table> 129 </div> 130 <?php 131 132 $this->reportOutput = ob_get_contents(); 133 ob_end_clean(); 134 135 }//end method 136 137 138 function show(){ 139 140 global $phpbms; 141 $db = &$this->db; 142 143 $phpbms->cssIncludes[] = "reports.css"; 144 $phpbms->cssIncludes[] = "pages/generaltableprint.css"; 145 146 $phpbms->showMenu = false; 147 $phpbms->showFooter = false; 148 149 include("header.php"); 150 151 echo $this->reportOutput; 152 153 include("footer.php"); 154 155 }//end method 156 157 }//end class 158 159 160 //PROCESSING 161 //======================================================================== 162 163 if(!isset($noOutput)){ 164 165 session_cache_limiter('private'); 166 167 require("../include/session.php"); 168 if(!isset($_GET["tid"])) 169 $error = new appError(200,"URL variable missing: tid"); 170 171 $report = new generalTablePrint($db, $_GET["tid"]); 172 $report->setupFromPrintScreen(); 173 $report->generate(); 174 $report->show(); 175 176 }//end if 39 40 if(!class_exists("phpbmsReport")) 41 include("report_class.php"); 42 43 /** 44 * Record Reporting in HTML table format 45 * 46 * This class implements a report used for printing out general table information 47 * in HTML table format 48 */ 49 class generalTablePrint extends phpbmsReport { 50 51 /** 52 * $maintable 53 * @var string the SQL name of the main table to print. 54 */ 55 var $maintable = ""; 56 57 /** 58 * $displayname 59 * @var string display name of table definition 60 */ 61 var $displayname = ""; 62 63 64 /** 65 * function generalTablePrint 66 * 67 * Initialization function 68 * 69 * @param object $db database object 70 * @param string $reportUUID UUID of report record 71 * @param string $tabledefUUID UUID of table definition intializing print 72 */ 73 function generalTablePrint($db, $reportUUID, $tabledefUUID){ 74 75 parent::phpbmsReport($db, $reportUUID, $tabledefUUID); 76 77 $therecord = $this->getTableDefInfo(); 78 79 $this->maintable = $therecord["maintable"]; 80 $this->displayname = $therecord["displayname"]; 81 82 }//end function init 83 84 85 /** 86 * function generate 87 * 88 * Creates the main part of the report (table) 89 */ 90 function generate(){ 91 92 $fromFields = "*"; 93 94 $columns = array(); 95 foreach($this->settings as $key=>$value){ 96 97 if(strpos($key, "column") === 0){ 98 99 $pos = substr($key,6)-1; 100 $columns[$pos]["field"] = $value; 101 102 if(isset($this->settings["titleColumn".($pos + 1)])) 103 $columns[$pos]["title"] = $this->settings["titleColumn".($pos +1)]; 104 else 105 $columns[$pos]["title"] = ""; 106 107 }//endif 108 109 }//endforeach 110 111 if(count($columns)){ 112 113 ksort($columns); 114 $columns = array_reverse($columns); 115 116 $fromFields = ""; 117 foreach($columns as $column){ 118 119 $fromFields .= ", ".$column["field"]; 120 if($column["title"]) 121 $fromFields .= " AS `".$column["title"]."`"; 122 123 $fromFields.="\n"; 124 125 }//endforeach 126 127 $fromFields = substr($fromFields, 1); 128 129 }//endif 130 131 if(isset($this->settings["fromTable"])) 132 $querytable = $this->settings["fromTable"]; 133 else 134 $querytable = $this->maintable; 135 136 $querystatement = " 137 SELECT 138 ".$fromFields." 139 FROM 140 ".$querytable; 141 142 $querystatement = $this->assembleSQL($querystatement); 143 144 $queryresult = $this->db->query($querystatement); 145 146 $num_fields = $this->db->numFields($queryresult); 147 148 149 if(!isset($this->settings["reportTitle"])) 150 $this->settings["reportTitle"] = $this->displayname; 151 152 ob_start(); 153 154 ?> 155 <div id="container"> 156 <h1><?php echo formatVariable($this->settings["reportTitle"])?></h1> 157 <table id="results"> 158 <thead> 159 <tr> 160 <?php 161 162 for($i=0;$i<$num_fields;$i++){ 163 164 ?> 165 <th <?php if($i == $num_fields-1) echo 'id="lastHeader"' ?>><?php echo $this->db->fieldName($queryresult, $i); ?></th> 166 <?php 167 168 }//end for 169 170 ?> 171 </tr> 172 </thead> 173 174 <tbody> 175 <?php 176 177 while($therecord = $this->db->fetchArray($queryresult)){ 178 179 ?><tr><?php 180 181 foreach($therecord as $value){ 182 183 ?><td><?php echo formatVariable($value)?></td><?php 184 185 }//end foreach 186 187 ?></tr><?php 188 189 }//endwhile 190 191 ?> 192 </tbody> 193 </table> 194 </div> 195 <?php 196 197 $this->reportOutput = ob_get_contents(); 198 ob_end_clean(); 199 200 }//end function generate 201 202 203 /** 204 * function show 205 * 206 * outputs HTML report 207 */ 208 function show(){ 209 210 global $phpbms; 211 $db = &$this->db; 212 213 $phpbms->cssIncludes[] = "reports.css"; 214 $phpbms->cssIncludes[] = "pages/generaltableprint.css"; 215 216 $phpbms->showMenu = false; 217 $phpbms->showFooter = false; 218 219 include("header.php"); 220 221 echo $this->reportOutput; 222 223 include("footer.php"); 224 225 }//end method 226 227 }//end class 228 229 230 /** 231 * PROCESSING 232 * ============================================================================= 233 */ 234 if(!isset($noOutput)){ 235 236 session_cache_limiter('private'); 237 238 require_once("../include/session.php"); 239 240 checkForReportArguments(); 241 242 $report = new generalTablePrint($db, $_GET["rid"], $_GET["tid"]); 243 $report->setupFromPrintScreen(); 244 $report->generate(); 245 $report->show(); 246 247 }//end if 248 249 /** 250 * When adding a new report record, the add/edit needs to know what the class 251 * name is so that it can instantiate it, and grab it's default settings. 252 */ 253 if(isset($addingReportRecord)) 254 $reportClass ="generalTablePrint"; 177 255 178 256 ?> -
trunk/phpbms/report/pdfreport_class.php
r672 r693 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 class pdfColumn{ 40 41 var $title; 42 var $fieldname; 43 var $size = 1; 44 var $format; 45 var $align = "L"; 46 47 function pdfColumn($title, $fieldname, $size = 1, $format = "", $align = "L"){ 48 49 $this->title = $title; 50 $this->fieldname = $fieldname; 51 $this->size = ((real) $size); 52 $this->format = $format; 53 $this->align = $align; 54 55 }//end method 56 57 }//end class 58 59 class pdfColor{ 60 61 var $r = 0; 62 var $g = 0; 63 var $b = 0; 64 65 function pdfColor($r = 0,$g = 0,$b = 0){ 66 67 $this->r = $r; 68 $this->g = $g; 69 $this->b = $b; 70 71 }//end method 72 73 }//end class 74 75 76 class pdfFont { 77 78 var $family = "Arial"; 79 var $style = ""; 80 var $size = 8; 81 82 function pdfFont($family = "Arial", $style ="", $size = 8){ 83 84 $this->family = $family; 85 $this->style = $style; 86 $this->size = $size; 87 88 }//end method 89 90 }//end class 91 92 93 class pdfStyle{ 94 95 var $font = NULL; 96 var $textColor = NULL; 97 var $backgroundColor = NULL; 98 99 function pdfStyle($font = NULL, $textColor = NULL, $backgroundColor = NULL){ 100 101 if($font) $this->font = $font; 102 if($textColor) $this->textColor = $textColor; 103 if($backgroundColor) $this->backgroundColor = $backgroundColor; 104 105 }//end method 106 107 }//end class 108 109 110 if(!class_exists("MEM_IMAGE")){ 111 112 include("fpdf/fpdf.php"); 113 include("fpdf/mem_image.php"); 114 115 }//end if 116 117 class phpbmsPDFReport extends MEM_IMAGE { 118 119 var $borderDebug = 0; 120 121 var $leftmargin = 0.5; 122 var $rightmargin = 0.5; 123 var $topmargin = 0.75; 124 var $paperwidth = 8.5; 125 var $paperlength = 11; 126 127 var $hasComapnyHeader = false; 128 var $companyImageWidth = 1; 129 130 var $styles = array(); 131 132 133 function phpbmsPDFReport($db, $orientation='P', $unit='mm', $format='Letter'){ 134 135 $this->db = $db; 136 137 parent::MEM_IMAGE($orientation, $unit, $format); 138 139 $this->initStyles(); 140 $this->SetLineWidth(0.01); 141 142 }//end method 143 144 145 function initStyles(){ 146 147 //here we set the standard styles 148 149 // NORMAL 150 $font = new pdfFont("Arial", "", 8); 151 $style = new pdfStyle($font); 152 153 $this->styles["normal"] = $style; 154 155 156 // TITLES 157 $font = new pdfFont("Arial", "B", 16); 158 $style = new pdfStyle($font); 159 160 $this->styles["title"] = $style; 161 162 163 // HEADER 164 $font = new pdfFont("Arial", "B", 8); 165 $bgC = new pdfColor(0,0,0); 166 $txtC = new pdfColor(255,255,255); 167 $style = new pdfStyle($font, $txtC, $bgC); 168 169 $this->styles["header"] = $style; 170 171 }//end method 172 173 174 function defineStyle($name, $pdfStyleObj){ 175 176 if(get_class($pdfStyleObj) != "pdfStyle") 177 $error = new appError(1400,"defineStyle Method needs pdfStyle object as parameter 2","PDF Error",true,true,false); 178 179 $this->styles[$name] = $pdfStyleObj; 180 181 }//end if 182 183 184 function setStyle($name){ 185 186 if(!isset($this->styles[$name])) 187 $name = "normal"; 188 189 $newStyle = $this->styles[$name]; 190 191 if(isset($newStyle->font)) 192 $this->SetFont($newStyle->font->family, $newStyle->font->style, $newStyle->font->size); 193 else 194 $this->SetFont("Arial", "", 8); 195 196 if(isset($newStyle->textColor)) 197 $this->SetTextColor($newStyle->textColor->r, $newStyle->textColor->g, $newStyle->textColor->b); 198 else 199 $this->SetTextColor(0,0,0); 200 201 if(isset($newStyle->backgroundColor)) 202 $this->SetFillColor($newStyle->backgroundColor->r, $newStyle->backgroundColor->g, $newStyle->backgroundColor->b); 203 else 204 $this->SetFillColor(255,255,255); 205 206 }//end if 207 208 209 function SetMargins(){ 210 211 parent::SetMargins($this->leftmargin, $this->topmargin, $this->rightmargin); 212 213 }//end method 214 215 216 function Header(){ 217 if($this->hasComapnyHeader){ 218 219 $cname = COMPANY_NAME; 220 $caddress = COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; 221 222 $querystatement = " 223 SELECT 224 `file`, 225 UPPER(`type`) AS `type` 226 FROM 227 files 228 WHERE 229 id=1"; 230 231 $pictureresult = $this->db->query($querystatement); 232 233 $thepicture = $this->db->fetchArray($pictureresult); 234 235 if($thepicture["type"]=="IMAGE/JPEG"){ 236 237 global $image; 238 $image = $thepicture["file"]; 239 $this->Image('var://image', $this->leftmargin,$this->topmargin, $this->companyImageWidth, 0, "JPEG"); 240 241 } elseif($thepicture["type"]=="IMAGE/PNG") 242 $this->MemImage($thepicture["file"], $this->leftmargin, $this->topmargin, $this->companyImageWidth); 243 244 //company name 245 $this->SetXY($this->companyImageWidth + $this->leftmargin, $this->topmargin); 246 $this->SetFont("Times","B",12); 247 $this->Cell(4, 0.25, $cname, $this->borderDebug, 2, "L"); 248 249 //and last, company address 250 $this->SetFont("Times","",8); 251 $this->MultiCell(4, .125 , $caddress, $this->borderDebug); 252 253 }//end if 254 255 }//end method 256 257 }//end class 39 class pdfColumn{ 40 41 var $title; 42 var $fieldname; 43 var $size = 1; 44 var $format; 45 var $align = "L"; 46 47 function pdfColumn($title, $fieldname, $size = 1, $format = "", $align = "L"){ 48 49 $this->title = $title; 50 $this->fieldname = $fieldname; 51 $this->size = ((real) $size); 52 $this->format = $format; 53 $this->align = $align; 54 55 }//end method 56 57 }//end class 58 59 60 class pdfColor{ 61 62 var $r = 0; 63 var $g = 0; 64 var $b = 0; 65 66 function pdfColor($r = 0,$g = 0,$b = 0){ 67 68 $this->r = $r; 69 $this->g = $g; 70 $this->b = $b; 71 72 }//end method 73 74 }//end class 75 76 77 class pdfFont { 78 79 var $family = "Arial"; 80 var $style = ""; 81 var $size = 8; 82 83 function pdfFont($family = "Arial", $style ="", $size = 8){ 84 85 $this->family = $family; 86 $this->style = $style; 87 $this->size = $size; 88 89 }//end method 90 91 }//end class 92 93 94 class pdfStyle{ 95 96 var $font = NULL; 97 var $textColor = NULL; 98 var $backgroundColor = NULL; 99 100 function pdfStyle($font = NULL, $textColor = NULL, $backgroundColor = NULL){ 101 102 if($font) $this->font = $font; 103 if($textColor) $this->textColor = $textColor; 104 if($backgroundColor) $this->backgroundColor = $backgroundColor; 105 106 }//end method 107 108 }//end class 109 110 111 if(!class_exists("FPDI")){ 112 113 require_once("fpdf/fpdf.php"); 114 require_once("fpdf/tpl_and_memimage.php"); 115 require_once("fpdf/fpdi.php"); 116 require_once('fpdf/fpdi_pdf_parser.php'); 117 118 }//end if 119 120 121 class phpbmsPDFReport extends FPDI { 122 123 var $borderDebug = 0; 124 125 var $leftmargin = 0.5; 126 var $rightmargin = 0.5; 127 var $topmargin = 0.75; 128 var $paperwidth = 8.5; 129 var $paperlength = 11; 130 131 var $logoInHeader = false; 132 var $companyInfoInHeader = false; 133 134 var $companyImageWidth = 1; 135 136 var $styles = array(); 137 138 139 function phpbmsPDFReport($db, $orientation='P', $unit='mm', $format='Letter'){ 140 141 $this->db = $db; 142 143 parent::FPDF_TPL($orientation, $unit, $format); 144 145 $this->initStyles(); 146 $this->SetLineWidth(0.01); 147 148 }//end method 149 150 151 function initStyles(){ 152 153 //here we set the standard styles 154 155 // NORMAL 156 $font = new pdfFont("Arial", "", 8); 157 $style = new pdfStyle($font); 158 159 $this->styles["normal"] = $style; 160 161 162 // TITLES 163 $font = new pdfFont("Arial", "B", 16); 164 $style = new pdfStyle($font); 165 166 $this->styles["title"] = $style; 167 168 169 // HEADER 170 $font = new pdfFont("Arial", "B", 8); 171 $bgC = new pdfColor(0,0,0); 172 $txtC = new pdfColor(255,255,255); 173 $style = new pdfStyle($font, $txtC, $bgC); 174 175 $this->styles["header"] = $style; 176 177 }//end method 178 179 180 function defineStyle($name, $pdfStyleObj){ 181 182 if(get_class($pdfStyleObj) != "pdfStyle") 183 $error = new appError(1400,"defineStyle Method needs pdfStyle object as parameter 2","PDF Error",true,true,false); 184 185 $this->styles[$name] = $pdfStyleObj; 186 187 }//end if 188 189 190 function setStyle($name){ 191 192 if(!isset($this->styles[$name])) 193 $name = "normal"; 194 195 $newStyle = $this->styles[$name]; 196 197 if(isset($newStyle->font)) 198 $this->SetFont($newStyle->font->family, $newStyle->font->style, $newStyle->font->size); 199 else 200 $this->SetFont("Arial", "", 8); 201 202 if(isset($newStyle->textColor)) 203 $this->SetTextColor($newStyle->textColor->r, $newStyle->textColor->g, $newStyle->textColor->b); 204 else 205 $this->SetTextColor(0,0,0); 206 207 if(isset($newStyle->backgroundColor)) 208 $this->SetFillColor($newStyle->backgroundColor->r, $newStyle->backgroundColor->g, $newStyle->backgroundColor->b); 209 else 210 $this->SetFillColor(255,255,255); 211 212 }//end if 213 214 215 function SetMargins(){ 216 217 parent::SetMargins($this->leftmargin, $this->topmargin, $this->rightmargin); 218 219 }//end method 220 221 222 function Header(){ 223 224 if($this->logoInHeader){ 225 226 $querystatement = " 227 SELECT 228 `file`, 229 UPPER(`type`) AS `type` 230 FROM 231 files 232 WHERE 233 id=1"; 234 235 $pictureresult = $this->db->query($querystatement); 236 237 $thepicture = $this->db->fetchArray($pictureresult); 238 239 if($thepicture["type"]=="IMAGE/JPEG"){ 240 241 global $image; 242 $image = $thepicture["file"]; 243 $this->Image('var://image', $this->leftmargin,$this->topmargin, $this->companyImageWidth, 0, "JPEG"); 244 245 } elseif($thepicture["type"]=="IMAGE/PNG") 246 $this->MemImage($thepicture["file"], $this->leftmargin, $this->topmargin, $this->companyImageWidth); 247 248 }//end if 249 250 if($this->companyInfoInHeader){ 251 252 $cname = COMPANY_NAME; 253 $caddress = COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; 254 255 //company name 256 $width = $this->leftmargin; 257 if($this->logoInHeader) 258 $width += $this->companyImageWidth; 259 260 $this->SetXY($width, $this->topmargin); 261 $this->SetFont("Times","B",12); 262 $this->Cell(4, 0.25, $cname, $this->borderDebug, 2, "L"); 263 264 //and last, company address 265 $this->SetFont("Times","",8); 266 $this->MultiCell(4, .125 , $caddress, $this->borderDebug); 267 268 }//end if 269 270 }//end method 271 272 }//end class 258 273 259 274 ?> -
trunk/phpbms/report/report_class.php
r441 r693 38 38 */ 39 39 40 class phpbmsReport{ 41 42 var $db; 43 var $whereclause =""; 44 var $sortorder = ""; 45 var $reportOutput = ""; 46 var $groupBy = ""; 47 48 function phpBMSReport($db){ 49 50 $this->db = $db; 51 52 }//end method 53 54 55 function setupFromPrintScreen(){ 56 57 if(isset($_SESSION["printing"]["sortorder"])) 58 $this->sortorder = $_SESSION["printing"]["sortorder"]; 59 60 if(isset($_SESSION["printing"]["whereclause"])){ 61 62 if(strpos($_SESSION["printing"]["whereclause"],"WHERE") === 0) 63 $this->whereclause = substr($this->whereclause, 5); 64 65 $this->whereclause = $_SESSION["printing"]["whereclause"]; 66 67 }//endif 68 69 //backwards compatibility 70 if(strpos($this->whereclause, "where ") === 0) 71 $this->whereclause = substr($this->whereclause, 6); 72 73 }//end method 74 75 76 function assembleSQL($querystatement){ 77 78 if($this->whereclause) 79 $querystatement .= " 80 WHERE 81 ".$this->whereclause; 82 83 if($this->groupBy) 84 $querystatement .= " 85 GROUP BY 86 ".$this->groupBy; 87 88 if($this->sortorder) 89 $querystatement .= " 90 ORDER BY 91 ".$this->sortorder; 92 93 return $querystatement; 94 95 }//end method 96 97 function _showNoRecords(){ 98 99 ?> 100 <h1 id="noRecord">No Records</h1> 101 <p>No valid records for this report.</p> 102 <?php 103 104 }//end method --_showNoRecords-- 105 106 }//end class 107 40 /** 41 * Basic reporting class 42 * 43 * The phpbmsReport class handles basic processing of reports and report type 44 * functions. It is designed to be extended by a specifc report. It provides 45 * functions for retrieving the where clause, sort order and group by fields 46 * as well as retrieving report settings 47 * @author Brian Rieb <brieb@kreotek.com> 48 */ 49 class phpbmsReport{ 50 51 /** 52 * $db 53 * @var object the database object 54 */ 55 var $db; 56 57 /** 58 * $whereClasue 59 * @var string whereclause used to filter results 60 */ 61 var $whereClause = ""; 62 63 /** 64 * $sortOrder 65 * @var string sortorder for results 66 */ 67 var $sortOrder = ""; 68 69 /** 70 * $groupBy 71 * @var string sort order for result SQL 72 */ 73 var $groupBy = ""; 74 75 /** 76 * $reportOutput 77 * @var string output generated by report 78 */ 79 var $reportOutput = ""; 80 81 /** 82 * $settings 83 * @var array array of report settings 84 */ 85 var $settings = array(); 86 87 /** 88 * $reportUUID; 89 * @var string UUID of report record 90 */ 91 var $reportUUID = ""; 92 93 /** 94 * $tabledefUUID 95 * @var string UUID of table definition that initiated report 96 */ 97 var $tabledefUUID = ""; 98 99 100 /** 101 * function phpbmsReport 102 * 103 * Initialization Function 104 * 105 * @param object $db database object 106 * @param string $reportUUID UUID of report record 107 * @param string $tabledefUUID UUID of table definition that initiated report 108 */ 109 function phpBMSReport($db, $reportUUID, $tabledefUUID){ 110 111 $this->db = $db; 112 113 $this->reportUUID = mysql_real_escape_string($reportUUID); 114 115 $this->tabledefUUID = mysql_real_escape_string($tabledefUUID); 116 117 if($reportUUID) 118 $this->retrieveReportSettings(); 119 120 }//end function init 121 122 123 /** 124 * function retrieveReportSettings() 125 * 126 * Retrieves settings for specific report from database and stores them in 127 * settings array. 128 */ 129 function retrieveReportSettings(){ 130 131 $querystatement = " 132 SELECT 133 `name`, 134 `value`, 135 `type` 136 FROM 137 reportsettings 138 WHERE 139 reportuuid = '".$this->reportUUID."'"; 140 141 $queryresult = $this->db->query($querystatement); 142 143 while($therecord = $this->db->fetchArray($queryresult)){ 144 145 switch($therecord["type"]){ 146 147 case "int": 148 $therecord["value"] = (int) $therecord["value"]; 149 break; 150 151 case "bool": 152 $therecord["value"] = (bool) $therecord["value"]; 153 break; 154 155 case "real": 156 $therecord["value"] = (real) $therecord["value"]; 157 break; 158 159 }//endswitch 160 161 $this->settings[$therecord["name"]] = $therecord["value"]; 162 163 }//endwhile 164 165 }//end function retrieveReportSettings 166 167 /** 168 * function setupFromPrintScreen 169 * 170 * Retrieves session information pertaining to printing as set by the print 171 * screen. 172 */ 173 function setupFromPrintScreen(){ 174 175 if(isset($_SESSION["printing"]["sortorder"])) 176 $this->sortOrder = $_SESSION["printing"]["sortorder"]; 177 178 if(isset($_SESSION["printing"]["whereclause"])){ 179 180 if(strpos($_SESSION["printing"]["whereclause"],"WHERE") === 0) 181 $this->whereClause = substr($this->whereClause, 5); 182 183 $this->whereClause = $_SESSION["printing"]["whereclause"]; 184 185 }//endif 186 187 //backwards compatibility 188 if(strpos($this->whereClause, "where ") === 0) 189 $this->whereClause = substr($this->whereClause, 6); 190 191 }//end function setupFromPrintScreen 192 193 /** 194 * function getTableDefInfo 195 * 196 * Retrieves pertinent table definition information 197 * @return array table definition record information 198 */ 199 function getTableDefInfo(){ 200 201 $querystatement = " 202 SELECT 203 * 204 FROM 205 tabledefs 206 WHERE 207 uuid = '".$this->tabledefUUID."'"; 208 209 $queryresult = $this->db->query($querystatement); 210 211 return $this->db->fetchArray($queryresult); 212 213 }//end function getTableDefInfo 214 215 /** 216 * function assembleSQL 217 * 218 * assembles record query 219 * 220 * @param string $querystatement SELECT and FROM clauses of SQL statement 221 * 222 * @return string Retruns full SQL statement 223 */ 224 function assembleSQL($querystatement){ 225 226 if($this->whereClause) 227 $querystatement .= " 228 WHERE 229 ".$this->whereClause; 230 231 if($this->groupBy) 232 $querystatement .= " 233 GROUP BY 234 ".$this->groupBy; 235 236 if($this->sortOrder) 237 $querystatement .= " 238 ORDER BY 239 ".$this->sortOrder; 240 return $querystatement; 241 242 }//end function assembleSQL 243 244 245 /** 246 * function showNoRecords 247 * 248 * Outputs simple no records error 249 */ 250 function showNoRecords(){ 251 252 ?> 253 <h1 id="noRecord">No Records</h1> 254 <p>No valid records for this report.</p> 255 <?php 256 257 }//end function showNoRecords 258 259 260 /** 261 * function addingRecordDefaultSettings 262 * 263 * Creates an array of settings associative arrays for use by the system when 264 * a new report record is added that references the file containing this class 265 * 266 * @retrun array of settings. Each setting should itself be 267 * an associative array containing the following 268 * name: name of the setting 269 * defaultvalue: default value for setting 270 * type: (string, text, int, real, bool) type for value of setting 271 * required: (0,1) whether the setting is required or not 272 * description: brief description for what this setting is used for. 273 */ 274 function addingRecordDefaultSettings(){ 275 276 $settings[] = array( 277 "name"=>"reportTitle", 278 "defaultValue"=>"Report", 279 "type"=>"string", 280 "required"=>0, 281 "description"=>"Report Title" 282 ); 283 284 return $settings; 285 286 }//endfunction addingRecordDefaultSettings 287 288 }//end class 289 290 /** 291 * function checkForReportArguments 292 * 293 * used before class instatiation to make sure POST arguments are set correctly 294 */ 295 function checkForReportArguments(){ 296 297 if(!isset($_GET["tid"])) 298 $error = new appError(200,"URL variable missing: tid"); 299 300 if(!isset($_GET["rid"])) 301 $error = new appError(200,"URL variable missing: rid"); 302 303 }//end function checkForReportArguments 108 304 ?>