diff --git a/admin/reports.inc.php b/admin/reports.inc.php index 557727b..5c145e0 100644 --- a/admin/reports.inc.php +++ b/admin/reports.inc.php @@ -33,6 +33,7 @@ require_once('../lpdf.php'); require_once('../lcsv.php'); + require_once('../tcpdf.inc.php'); $filter_ops = array( 0 => '=', 1 => '<=', @@ -48,7 +49,7 @@ $report_options = array(); $report_options['type'] = array('desc' => 'Report Format', - 'values' => array('pdf'=>'PDF', 'csv'=>'CSV', 'label'=>'Label') + 'values' => array('pdf'=>'PDF', 'csv'=>'CSV', 'label'=>'Label', 'tcpdf_label'=>'TCPDF Label') ); $report_options['group_new_page'] = array('desc' => 'Start each new grouping on a new page', 'values' => array('no'=>'No', 'yes'=>'Yes') @@ -105,6 +106,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 9.5, 'y_spacing' => 0, 'rows' => 1, + 'page_format' => 'LETTER', + 'page_orientation' => 'P', ); $report_stock['fullpage_landscape'] = array('name' => 'Letter 8.5 x 11 Landscape (3/4" margin)', @@ -116,6 +119,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 7, 'y_spacing' => 0, 'rows' => 1, + 'page_format' => 'LETTER', + 'page_orientation' => 'L', ); $report_stock['fullpage_full'] = array('name' => 'Letter 8.5 x 11 (no margin)', @@ -127,6 +132,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 11, 'y_spacing' => 0, 'rows' => 1, + 'page_format' => 'LETTER', + 'page_orientation' => 'P', ); $report_stock['fullpage_landscape_full'] = array('name' => 'Letter 8.5 x 11 Landscape (no margin)', @@ -138,6 +145,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 8.5, 'y_spacing' => 0, 'rows' => 1, + 'page_format' => 'LETTER', + 'page_orientation' => 'L', ); $report_stock['5161'] = array('name' => 'Avery 5161/5261/5961/8161, G&T 99189 (1"x4")', @@ -150,6 +159,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'y_spacing' => 0.00, 'y_padding' => 0.05, 'rows' => 10, + 'page_format' => 'LETTER', + 'page_orientation' => 'P', ); $report_stock['5162'] = array('name' => 'Avery 5162/5262/5962/8162/8462, G&T 99190 (1 1/3"x4")', @@ -162,6 +173,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'y_spacing' => 0.00, 'y_padding' => 0.30, 'rows' => 7, + 'page_format' => 'LETTER', + 'page_orientation' => 'P', ); $report_stock['5163'] = array('name' => 'Avery 5163/5263/5963/8163/8463, G&T 99181 (2"x4")', 'page_width' => 8.5, @@ -172,6 +185,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 2, 'y_spacing' => 0.00, 'rows' => 5, + 'page_format' => 'LETTER', + 'page_orientation' => 'P', ); /* This is combined with 5161 @@ -196,6 +211,9 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 3 + 1/3, 'y_spacing' => 0, 'rows' => 3, + 'page_format' => 'LETTER', /* tcpdf format */ + 'page_orientation' => 'P', /* tcpdf orientation */ + ); $report_stock['nametag'] = array('name' => 'Cards 4"x3"', 'page_width' => 8.5, @@ -206,6 +224,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 3, 'y_spacing' => 0, 'rows' => 3, + 'page_format' => 'LETTER', + 'page_orientation' => 'P', ); $report_stock['letter_4up'] = array('name' => 'Fullpage, 4up', @@ -217,6 +237,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 5, 'y_spacing' => 0.25, 'rows' => 2, + 'page_format' => 'LETTER', + 'page_orientation' => 'P', ); $report_stock['ledger'] = array('name' => 'Ledger/Tabloid 11 x 17', @@ -228,6 +250,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 17, 'y_spacing' => 0, 'rows' => 1, + 'page_format' => 'LETTER', + 'page_orientation' => 'P', ); $report_stock['ledger_landscape'] = array('name' => 'Ledger/Tabloid 11 x 17 Landscape', @@ -239,6 +263,8 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ 'label_height' => 11, 'y_spacing' => 0, 'rows' => 1, + 'page_format' => 'LETTER', + 'page_orientation' => 'P', ); @@ -322,24 +348,30 @@ foreach($report_stock as $n=>$v) { $x = 0; foreach($report[$type] as $k=>$v) { if($type == 'option') { - /* field, value, x, y, w, h, lines, face, align */ - $vals = "'$k','$v','0','0','0','0','0','',''"; + /* field, value, x, y, w, h, lines, face, align, valign, fn, fs, fsize, overflow */ + $vals = "'$k','$v','0','0','0','0','0','','','','','','0','truncate'"; } else { if($v['lines'] == 0) $v['lines'] =1; + $fs = is_array($v['fontstyle']) ? implode(',',$v['fontstyle']) : ''; $opts = "{$v['align']} {$v['valign']}"; $vals = "'{$v['field']}','{$v['value']}', '{$v['x']}','{$v['y']}','{$v['w']}', '{$v['h']}','{$v['lines']}','{$v['face']}', - '$opts'"; + '$opts','{$v['valign']}', + '{$v['fontname']}','$fs','{$v['fontsize']}', + '{$v['on_overflow']}'"; } if($q != '') $q .= ','; $q .= "({$report['id']}, '$type','$x',$vals)"; $x++; } + mysql_query("INSERT INTO reports_items(`reports_id`,`type`,`ord`, `field`,`value`,`x`, `y`, `w`, `h`, - `lines`, `face`, `align`) + `lines`, `face`, `align`,`valign`, + `fontname`,`fontstyle`,`fontsize`,`on_overflow`) VALUES $q;"); + echo mysql_error(); } @@ -404,8 +436,11 @@ foreach($report_stock as $n=>$v) { } /* Pull out all the data */ $val = array(); - $col_fields = array('field', 'x', 'y', 'w', 'h', 'lines', 'face', 'align', 'value'); + $col_fields = array('field', 'x', 'y', 'w', 'h', 'lines', 'face', 'align', 'valign', 'value', 'fontname','fontsize','on_overflow'); foreach($col_fields as $lf) $val[$lf] = $a[$lf]; + $val['fontstyle'] = explode(',', $a['fontstyle']); + /* valign, fontname, fontsize,fontstyle are unused, except in tcpdf reports + (i.e. nothign has changed, only adding on */ if($val['lines'] == 0) $val['lines'] = 1; $opts = explode(" ", $val['align']); @@ -422,6 +457,7 @@ foreach($report_stock as $n=>$v) { break; } } +//`int_r($report); return $report; } @@ -448,9 +484,7 @@ foreach($report_stock as $n=>$v) { } - -/* - print("
"); +/* print(""); print_r($_POST); print_r($report); print(""); @@ -577,6 +611,20 @@ foreach($report_stock as $n=>$v) { if($report['option']['allow_multiline'] == 'yes') $table['option']['allow_multiline'] = true; break; + case 'tcpdf_label': + $label_stock = $report_stock[$report['option']['stock']]; + $show_box = ($report['option']['label_box'] == 'yes') ? true : false; + $show_fair = ($report['option']['label_fairname'] == 'yes') ? true : false; + $show_logo = ($report['option']['label_logo'] == 'yes') ? true : false; + + $rep=new pdf($report['name'], $label_stock['page_format'], $label_stock['page_orientation']); + $rep->setup_for_labels($show_box, $show_fair, $show_logo, + $label_stock['label_width'] * 25.4, $label_stock['label_height'] * 25.4, + $label_stock['x_spacing'] * 25.4, $label_stock['y_spacing'] * 25.4, + $label_stock['rows'], $label_stock['cols']); + $gen_mode = 'tcpdf_label'; + break; + default: echo "Invalid type [{$report['option']['type']}]"; exit; @@ -737,6 +785,8 @@ foreach($report_stock as $n=>$v) { $n_groups = count($report['group']); $last_group_data = array(); +// echo "";print_r($rep); + while($i = mysql_fetch_assoc($r)) { if($n_groups > 0) { @@ -789,7 +839,10 @@ foreach($report_stock as $n=>$v) { $show_fair = ($report['option']['label_fairname'] == 'yes') ? true : false; $show_logo = ($report['option']['label_logo'] == 'yes') ? true : false; $rep->newLabel($show_box, $show_fair, $show_logo); + } else if($gen_mode == 'tcpdf_label') { + $rep->label_new(); } + foreach($report['col'] as $o=>$d) { $f = $d['field']; if(is_array($fields[$f]['value_map'])) { @@ -826,6 +879,23 @@ foreach($report_stock as $n=>$v) { $d['h'], $lh, $v, $opt); } + } else if($gen_mode == 'tcpdf_label') { + /* Setup additional options */ + $show_box = ($report['option']['field_box'] == 'yes') ? true : false; + +// echo ""; print_r($d); + + if($f == 'static_box') { + $rep->label_rect($d['x'], $d['y'], $d['w'], $d['h']); + } else { + if($f == 'static_text') $v = $d['value']; + + $rep->label_text($d['x'], $d['y'], $d['w'], $d['h'], + $v, $show_box, $d['align'], $d['valign'], + $d['fontname'],$d['fontstyle'],$d['fontsize'], + $d['on_overflow']); + } + } if($fields[$f]['total'] == true) @@ -836,6 +906,8 @@ foreach($report_stock as $n=>$v) { if(count($table['data'])) { $rep->addTable($table); } + + $rep->output(); } diff --git a/admin/reports_editor.php b/admin/reports_editor.php index 0b8f8ea..a1eacf1 100644 --- a/admin/reports_editor.php +++ b/admin/reports_editor.php @@ -36,6 +36,7 @@ require_once('reports_fairs.inc.php'); require_once('reports_fundraising.inc.php'); require_once('reports.inc.php'); + require_once('../tcpdf.inc.php'); $fields = array(); $locs = array('X' => 'x', 'Y' => 'y', 'W' => 'w', 'H' => 'h', 'Lines' => 'lines'); @@ -89,7 +90,7 @@ exit; } } else if($l == 'valign') { - $aligns = array('vtop', 'vbottom', 'vcenter'); + $aligns = array('vtop', 'vbottom', 'vcenter', 'top','middle','bottom'); if(!in_array($v, $aligns)) { echo "Invalid valignment $v"; exit; @@ -186,10 +187,14 @@ function reportReload() var canvasWidth=0; var canvasHeight=0; var canvasObjectIndex=0; +var labelWidth=0; +var labelHeight=0; -function initCanvas(w,h) { +function initCanvas(w,h,lw,lh) { canvasWidth=w; canvasHeight=h; + labelWidth=lw; + labelHeight=lh; } function createData(x,y,w,h,l,face,align,valign,value) { @@ -235,10 +240,55 @@ function createData(x,y,w,h,l,face,align,valign,value) { canvas.appendChild(newdiv); + canvasObjectIndex++; +} + +function createDataTCPDF(x,y,w,h,align,valign,fontname,fontstyle,fontsize,value) { + + var canvas=document.getElementById('layoutcanvas'); + var newdiv=document.createElement('div'); + + var dx = Math.round(x * canvasWidth / labelWidth); + var dy = Math.round(y * canvasHeight / labelHeight); + var dw = Math.round(w * canvasWidth / labelWidth); + var dh = Math.round(h * canvasHeight / labelHeight); + + + var fontheight=(fontsize * 25.4 / 72) * canvasHeight / labelHeight; + var l = Math.floor(h/fontheight); + if(fontheight == 0) fontheight=10; + if(l==0) l=1; + +// alert(dh + ", fh="+fontheight); + + newdiv.setAttribute('id','o_'+canvasObjectIndex); + newdiv.style.display="table-cell"; + newdiv.style.position="absolute"; + newdiv.style.width=dw+"px"; + newdiv.style.height=dh+"px"; + newdiv.style.left=dx+"px"; + newdiv.style.top=dy+"px"; + newdiv.style.textAlign=align; + newdiv.style.verticalAlign=valign; + newdiv.style.padding="0 0 0 0"; + newdiv.style.margin="0 0 0 0"; +// newdiv.style.vertical-align=valign; + newdiv.style.border="1px solid blue"; + newdiv.style.fontSize=fontheight+"px"; + newdiv.style.lineHeight=fontheight+"px"; + newdiv.style.fontFamily=fontname; + newdiv.style.fontSizeAdjust=0.65; + + var maxlength=Math.floor(dw/(fontheight*0.7))*l; + if(value.length>maxlength) value=value.substring(0,maxlength); + + newdiv.innerHTML=value; + + canvas.appendChild(newdiv); canvasObjectIndex++; - } + @@ -394,6 +444,8 @@ function createData(x,y,w,h,l,face,align,valign,value) { echo ""; echo "\n"; +$doCanvasSample = false; +$doCanvasSampletcpdf = false; $l_w=$report_stock[$report['option']['stock']]['label_width']; $l_h=$report_stock[$report['option']['stock']]['label_height']; if($l_w && $l_h && $report['option']['type']=="label") { @@ -405,31 +457,69 @@ function createData(x,y,w,h,l,face,align,valign,value) { $canvasheight=round($canvaswidth*$ratio); echo ""; echo "\n"; - echo "\n"; + echo "\n"; } + if($l_w && $l_h && $report['option']['type']=="tcpdf_label") { + echo "Label Data Locations - TCPDF
"; + + $l_w *= 25.4; + $l_h *= 25.4; + $doCanvasSampletcpdf=true; + $ratio=$l_h/$l_w; + $canvaswidth=600; + $canvasheight=round($canvaswidth*$ratio); + echo ""; + echo "\n"; + echo "\n"; + } + + echo "
Loc ".($o+1).": | "; echo "";
$script="";
foreach($locs as $k=>$v) {
+ if($k=='Lines' && $report['option']['type'] != 'label') continue;
echo "$k=";
$script.="{$d[$v]},";
}
- echo 'Face=';
- selector("col[$x][face]", array('' => '', 'bold' => 'Bold'), $d['face']);
+
+ if($report['option']['type'] == 'label') {
+ echo 'Face=';
+ selector("col[$x][face]", array('' => '', 'bold' => 'Bold'), $d['face']);
+ }
echo 'Align';
selector("col[$x][align]", array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'),
$d['align']);
echo 'vAlign';
- selector("col[$x][valign]", array('vcenter' => 'Center', 'vtop' => 'Top', 'vbottom' => 'Bottom'),
- $d['valign']);
+ if($report['option']['type'] == 'label') {
+ selector("col[$x][valign]", array('vcenter' => 'Center', 'vtop' => 'Top', 'vbottom' => 'Bottom'),
+ $d['valign']);
+ } else {
+ selector("col[$x][valign]", array('middle' => 'Middle', 'top' => 'Top', 'bottom' => 'Bottom'),
+ $d['valign']);
+
+ echo 'Font=';
+ selector("col[$x][fontname]", $fontlist, $d['fontname']);
+ selector("col[$x][fontstyle]", array('' => '', 'bold' => 'Bold'), $d['fontstyle']);
+ echo "";
+ echo 'pt ';
+ echo 'OnOverflow=';
+ selector("col[$x][on_overflow]", array('tuncate'=>'Truncate','...'=>'Add ...', 'scale'=>'Scale'), $d['on_overflow']);
+ }
+
if($f == 'static_text') {
echo " Text="; } else { @@ -437,6 +527,8 @@ function createData(x,y,w,h,l,face,align,valign,value) { } if($doCanvasSample) echo "\n"; + if($doCanvasSampletcpdf) + echo "\n"; $x++; } @@ -444,16 +536,32 @@ function createData(x,y,w,h,l,face,align,valign,value) { echo " |
Loc ".($x+1).": | "; echo ""; foreach($locs as $k=>$v) { + if($k=='Lines' && $report['option']['type'] != 'label') continue; echo "$k="; } - echo 'Face='; - selector("col[$x][face]", array('' => '', 'bold' => 'Bold'), ''); + if($report['option']['type'] == 'label') { + echo 'Face='; + selector("col[$x][face]", array('' => '', 'bold' => 'Bold'), ''); + } + echo 'Align'; selector("col[$x][align]", array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'), 'center'); echo 'vAlign'; - selector("col[$x][valign]", array('vcenter' => 'Center', 'vtop' => 'Top', 'vbottom' => 'Bottom'), - 'top'); + if($report['option']['type'] == 'label') { + selector("col[$x][valign]", array('vcenter' => 'Center', 'vtop' => 'Top', 'vbottom' => 'Bottom'), + 'top'); + } else { + selector("col[$x][valign]", array('middle' => 'Middle', 'top' => 'Top', 'bottom' => 'Bottom'), 'middle'); + + echo 'Font='; + selector("col[$x][fontname]", $fontlist, ''); + selector("col[$x][fontstyle]", array('' => '', 'bold' => 'Bold'), ''); + echo ""; + echo 'pt '; + echo 'OnOverflow='; + selector("col[$x][on_overflow]", array('Truncate'=>'truncate','Add ...'=>'...', 'Scale'=>'scale'),''); + } echo ""; echo " |