- Avoid a divde by zero in label generation

- Never allow the number of lines for text data to be zero in the first place.
This commit is contained in:
dave 2007-12-22 20:49:33 +00:00
parent 801e70cb0c
commit edf26caf1e
2 changed files with 6 additions and 3 deletions

View File

@ -281,6 +281,7 @@ foreach($report_stock as $n=>$v) {
/* field, value, x, y, w, h, lines, face, align */
$vals = "'$k','$v','0','0','0','0','0','',''";
} else {
if($v['lines'] == 0) $v['lines'] =1;
$opts = "{$v['align']} {$v['valign']}";
$vals = "'{$v['field']}','{$v['value']}',
'{$v['x']}','{$v['y']}','{$v['w']}',
@ -707,9 +708,9 @@ foreach($report_stock as $n=>$v) {
/* Special column, override result with static text */
if($f == 'static_text') $v = $d['value'];
$lh = ($d['lines'] == 0) ? 0 : $d['h']/$d['lines'];
$rep->addLabelText2($d['x'], $d['y'], $d['w'],
$d['h'], $d['h']/$d['lines'],
$d['h'], $lh,
$v, $opt);
}
}

View File

@ -141,6 +141,7 @@ function reportChange()
$v = stripslashes($v);
} else if(in_array($l, $floatloc)) {
$v = floatval($v);
if($l == 'lines' && $v==0) $v=1;
} else if($l == 'face') {
$v = ($v == 'bold') ? 'bold' : '';
} else if($l == 'align') {
@ -155,7 +156,7 @@ function reportChange()
echo "Invalid valignment $v";
exit;
}
}
}
$a[$l] = $v;
}
if(trim($a['field']) == '') continue;
@ -271,6 +272,7 @@ function reportChange()
$vw = intval($v['w']);
$vh = intval($v['h']);
$vlines = intval($v['lines']);
if($vlines == 0) $vlines = 1;
$face = $v['face'];
$align = $v['align']. ' ' . $v['valign'];
$value=mysql_escape_string(stripslashes($v['value']));