/*Copyright (c) 2009, Dan "Ducky" Little & GeoMOOSE.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ include('config.php'); require('fpdf/fpdf.php'); # Turn off the warning reporting # error_reporting(E_ERROR | E_PARSE); # Get the query id from which we are going to get the files $query_id = $_REQUEST['queryid']; # format for the labels $output = $_REQUEST['output']; if(!isset($output)) { $output = 'html'; } # get some config $tempDirectory = $CONFIGURATION['temp']; # get some layout information $maxRows = $CONFIGURATION['label_rows']; $maxColumns = $CONFIGURATION['label_columns']; # This will load the line template into an Array $labelLines = (int)$CONFIGURATION['label_lines']; $lineTemplate = array(); for($i = 1; $i <= $labelLines; $i++) { array_push($lineTemplate, $CONFIGURATION['label_line_'.$i]); } # open the dbase file with all the record information $dbase = dbase_open($tempDirectory.'/'.$query_id.'.dbf', 0); # put the labels into a larger array $numRecords = dbase_numrecords($dbase); $allAddresses = array(); for($i = 1; $i <= $numRecords; $i++) { $rec = dbase_get_record_with_names($dbase, $i); $address = array(); for($line = 0; $line < $labelLines; $line++) { $address[$line] = $lineTemplate[$line]; foreach($rec as $k=>$v) { $address[$line] = str_replace('%'.$k.'%', trim($v), $address[$line]); } $address[$line] = trim($address[$line]); } array_push($allAddresses, $address); } dbase_close($dbase); # So I wrote this to just test the functionality. It seems to work pretty well. if($output == 'html') { print "
"; $i = 0; $column = 0; $row = 0; while($i < $numRecords) { if($row == 0 and $column == 0) { print "";
for($line = 0; $line < $labelLines; $line++) {
print $allAddresses[$i][$line]." "; } print " | ";
$i++;
$column++;
if($column >= $maxColumns) {
print "