| 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"; |