forked from science-ation/science-ation
- Fix drawing label boxes around text items
- Add the ability to draw a static label box (without text) - Add "self nominated award" 1 through 5 to the student reports - Add a new report demonstrating how to use the above (this is of the format Sudbury sent us).
This commit is contained in:
parent
735e5e0999
commit
58df28ba9a
@ -193,6 +193,17 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */
|
|||||||
'rows' => 3,
|
'rows' => 3,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$report_stock['nametag'] = array('name' => 'Fullpage, 4up',
|
||||||
|
'page_width' => 8.5,
|
||||||
|
'page_height' => 11,
|
||||||
|
'label_width' => 4,
|
||||||
|
'x_spacing' => 0.25,
|
||||||
|
'cols' => 2,
|
||||||
|
'label_height' => 5,
|
||||||
|
'y_spacing' => 0.25,
|
||||||
|
'rows' => 2,
|
||||||
|
);
|
||||||
|
|
||||||
$report_options['stock'] = array('desc' => "Paper Type",
|
$report_options['stock'] = array('desc' => "Paper Type",
|
||||||
'values' => array() );
|
'values' => array() );
|
||||||
|
|
||||||
@ -712,7 +723,15 @@ foreach($report_stock as $n=>$v) {
|
|||||||
if($d['face'] == 'bold') $opt[] = 'bold';
|
if($d['face'] == 'bold') $opt[] = 'bold';
|
||||||
$opt[] = $d['align'];
|
$opt[] = $d['align'];
|
||||||
$opt[] = $d['valign'];
|
$opt[] = $d['valign'];
|
||||||
|
if($report['option']['label_box'] == 'yes')
|
||||||
|
$opt[] = 'label_box';
|
||||||
|
|
||||||
|
|
||||||
|
/* Special column, draw a box */
|
||||||
|
if($f == 'static_box') {
|
||||||
|
$rep->addLabelBox($d['x'], $d['y'], $d['w'],
|
||||||
|
$d['h']);
|
||||||
|
} else {
|
||||||
/* Special column, override result with static text */
|
/* Special column, override result with static text */
|
||||||
if($f == 'static_text') $v = $d['value'];
|
if($f == 'static_text') $v = $d['value'];
|
||||||
|
|
||||||
@ -721,6 +740,7 @@ foreach($report_stock as $n=>$v) {
|
|||||||
$d['h'], $lh,
|
$d['h'], $lh,
|
||||||
$v, $opt);
|
$v, $opt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($fields[$f]['total'] == true)
|
if($fields[$f]['total'] == true)
|
||||||
$table['total'] += $v;
|
$table['total'] += $v;
|
||||||
|
@ -35,6 +35,43 @@ function reports_students_numstudents(&$report, $text)
|
|||||||
return mysql_num_rows($q);
|
return mysql_num_rows($q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reports_students_award_selfnom_num(&$report, $text, $n)
|
||||||
|
{
|
||||||
|
$year = $report['year'];
|
||||||
|
$q = mysql_query("SELECT award_awards.name FROM
|
||||||
|
projects
|
||||||
|
LEFT JOIN project_specialawards_link ON project_specialawards_link.projects_id=projects.id
|
||||||
|
LEFT JOIN award_awards ON award_awards.id=project_specialawards_link.award_awards_id
|
||||||
|
WHERE projects.id='$text'
|
||||||
|
AND projects.year='$year'
|
||||||
|
AND project_specialawards_link.year='$year'
|
||||||
|
LIMIT $n,$n");
|
||||||
|
echo mysql_error();
|
||||||
|
$i = mysql_fetch_assoc($q);
|
||||||
|
return $i['name'];
|
||||||
|
}
|
||||||
|
function reports_students_award_selfnom_1(&$report, $text)
|
||||||
|
{
|
||||||
|
return reports_students_award_selfnom_num(&$report, $text, 1);
|
||||||
|
}
|
||||||
|
function reports_students_award_selfnom_2(&$report, $text)
|
||||||
|
{
|
||||||
|
return reports_students_award_selfnom_num(&$report, $text, 2);
|
||||||
|
}
|
||||||
|
function reports_students_award_selfnom_3(&$report, $text)
|
||||||
|
{
|
||||||
|
return reports_students_award_selfnom_num(&$report, $text, 3);
|
||||||
|
}
|
||||||
|
function reports_students_award_selfnom_4(&$report, $text)
|
||||||
|
{
|
||||||
|
return reports_students_award_selfnom_num(&$report, $text, 4);
|
||||||
|
}
|
||||||
|
function reports_students_award_selfnom_5(&$report, $text)
|
||||||
|
{
|
||||||
|
return reports_students_award_selfnom_num(&$report, $text, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$report_students_fields = array(
|
$report_students_fields = array(
|
||||||
'pn' => array(
|
'pn' => array(
|
||||||
'name' => 'Project Number',
|
'name' => 'Project Number',
|
||||||
@ -432,6 +469,46 @@ $report_students_fields = array(
|
|||||||
'table_sort' => 'award_awards.name',
|
'table_sort' => 'award_awards.name',
|
||||||
'components' => array('awards_nominations')),
|
'components' => array('awards_nominations')),
|
||||||
|
|
||||||
|
'nom_awards_name_1' => array(
|
||||||
|
'name' => 'Award Nominations -- Self-Nominated Special Award 1',
|
||||||
|
'header' => 'Award Name',
|
||||||
|
'width' => 3,
|
||||||
|
'table' => 'projects.id',
|
||||||
|
'table_sort' => 'projects.id',
|
||||||
|
'exec_function' => 'reports_students_award_selfnom_1'),
|
||||||
|
|
||||||
|
'nom_awards_name_2' => array(
|
||||||
|
'name' => 'Award Nominations -- Self-Nominated Special Award 2',
|
||||||
|
'header' => 'Award Name',
|
||||||
|
'width' => 3,
|
||||||
|
'table' => 'projects.id',
|
||||||
|
'table_sort' => 'projects.id',
|
||||||
|
'exec_function' => 'reports_students_award_selfnom_2'),
|
||||||
|
|
||||||
|
'nom_awards_name_3' => array(
|
||||||
|
'name' => 'Award Nominations -- Self-Nominated Special Award 3',
|
||||||
|
'header' => 'Award Name',
|
||||||
|
'width' => 3,
|
||||||
|
'table' => 'projects.id',
|
||||||
|
'table_sort' => 'projects.id',
|
||||||
|
'exec_function' => 'reports_students_award_selfnom_3'),
|
||||||
|
|
||||||
|
'nom_awards_name_4' => array(
|
||||||
|
'name' => 'Award Nominations -- Self-Nominated Special Award 4',
|
||||||
|
'header' => 'Award Name',
|
||||||
|
'width' => 3,
|
||||||
|
'table' => 'projects.id',
|
||||||
|
'table_sort' => 'projects.id',
|
||||||
|
'exec_function' => 'reports_students_award_selfnom_4'),
|
||||||
|
|
||||||
|
'nom_awards_name_5' => array(
|
||||||
|
'name' => 'Award Nominations -- Self-Nominated Special Award 5',
|
||||||
|
'header' => 'Award Name',
|
||||||
|
'width' => 3,
|
||||||
|
'table' => 'projects.id',
|
||||||
|
'table_sort' => 'projects.id',
|
||||||
|
'exec_function' => 'reports_students_award_selfnom_5'),
|
||||||
|
|
||||||
'req_elec' => array(
|
'req_elec' => array(
|
||||||
'name' => 'If the project requires electricity',
|
'name' => 'If the project requires electricity',
|
||||||
'header' => 'Elec',
|
'header' => 'Elec',
|
||||||
@ -507,7 +584,13 @@ $report_students_fields = array(
|
|||||||
'table' => "'".mysql_escape_string($config['fairname'])."'"),
|
'table' => "'".mysql_escape_string($config['fairname'])."'"),
|
||||||
|
|
||||||
'static_text' => array (
|
'static_text' => array (
|
||||||
'name' => 'Static Text (useful for labels)',
|
'name' => 'Label -- Static Text',
|
||||||
|
'header' => '',
|
||||||
|
'width' => 0.1,
|
||||||
|
'table' => "CONCAT(' ')"),
|
||||||
|
|
||||||
|
'static_box' => array (
|
||||||
|
'name' => 'Label -- Static Box',
|
||||||
'header' => '',
|
'header' => '',
|
||||||
'width' => 0.1,
|
'width' => 0.1,
|
||||||
'table' => "CONCAT(' ')"),
|
'table' => "CONCAT(' ')"),
|
||||||
|
@ -1 +1 @@
|
|||||||
98
|
99
|
||||||
|
32
db/db.update.99.sql
Normal file
32
db/db.update.99.sql
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
INSERT INTO `reports` (`id`, `system_report_id`, `name`, `desc`, `creator`, `type`) VALUES
|
||||||
|
('', '44', 'Labels -- Table Labels (with special award nominations)', 'Labels for each project. This report includes the first 5 projects the students have self-nominated for. There are boxes for judges to initial too. We realize that each fair may have a different number of projects. This reports serves as an example of how to create a report with boxes.', 'The Grant Brothers', 'student');
|
||||||
|
INSERT INTO `reports_items` (`id`, `reports_id`, `type`, `ord`, `field`, `value`, `x`, `y`, `w`, `h`, `lines`, `face`, `align`) VALUES
|
||||||
|
('', LAST_INSERT_ID(), 'option', 0, 'type', 'label', 0, 0, 0, 0, 0, '', ''),
|
||||||
|
('', LAST_INSERT_ID(), 'option', 1, 'group_new_page', 'no', 0, 0, 0, 0, 0, '', ''),
|
||||||
|
('', LAST_INSERT_ID(), 'option', 2, 'allow_multiline', 'no', 0, 0, 0, 0, 0, '', ''),
|
||||||
|
('', LAST_INSERT_ID(), 'option', 3, 'label_box', 'no', 0, 0, 0, 0, 0, '', ''),
|
||||||
|
('', LAST_INSERT_ID(), 'option', 4, 'label_fairname', 'no', 0, 0, 0, 0, 0, '', ''),
|
||||||
|
('', LAST_INSERT_ID(), 'option', 5, 'label_logo', 'no', 0, 0, 0, 0, 0, '', ''),
|
||||||
|
('', LAST_INSERT_ID(), 'option', 6, 'stock', 'nametag', 0, 0, 0, 0, 0, '', ''),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 0, 'pn', '', 5, 5, 30, 5, 1, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 1, 'nom_awards_name_1', '', 5, 45, 50, 10, 3, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 2, 'nom_awards_name_2', '', 5, 56, 50, 10, 3, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 3, 'nom_awards_name_3', '', 5, 67, 50, 10, 3, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 4, 'nom_awards_name_4', '', 5, 78, 50, 10, 3, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 5, 'nom_awards_name_5', '', 5, 89, 50, 10, 3, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 6, 'static_text', 'Judge 1', 5, 22, 30, 4, 1, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 7, 'static_text', 'Judge 2', 5, 34, 30, 4, 1, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 8, 'static_text', 'Safety Check', 42, 6, 12, 6, 2, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 9, 'static_text', 'Judges: Please initial box when judging of project is complete', 70, 23, 28, 12, 4, '', 'left vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 10, 'static_box', '', 0, 0, 100, 100, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 11, 'static_box', '', 55, 5, 40, 8, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 12, 'static_box', '', 22, 20, 40, 8, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 13, 'static_box', '', 22, 32, 40, 8, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 14, 'static_box', '', 55, 46, 40, 8, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 15, 'static_box', '', 55, 57, 40, 8, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 16, 'static_box', '', 55, 68, 40, 8, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 17, 'static_box', '', 55, 79, 40, 8, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 18, 'static_box', '', 55, 90, 40, 8, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'col', 19, 'static_box', '', 0, 15, 100, 27, 1, '', 'center vcenter'),
|
||||||
|
('', LAST_INSERT_ID(), 'sort', 0, 'pn', '', 0, 0, 0, 0, 1, '', ' '),
|
||||||
|
('', LAST_INSERT_ID(), 'distinct', 0, 'pn', '', 0, 0, 0, 0, 1, '', ' ');
|
19
lpdf.php
19
lpdf.php
@ -341,7 +341,7 @@ class lpdf
|
|||||||
if(in_array('vtop', $options)) $valign = 'top';
|
if(in_array('vtop', $options)) $valign = 'top';
|
||||||
if(in_array('vcenter', $options)) $valign = 'center';
|
if(in_array('vcenter', $options)) $valign = 'center';
|
||||||
if(in_array('vbottom', $options)) $valign = 'bottom';
|
if(in_array('vbottom', $options)) $valign = 'bottom';
|
||||||
if(in_array('boxtext', $options)) $boxtext = true;
|
if(in_array('label_box', $options)) $boxtext = true;
|
||||||
|
|
||||||
|
|
||||||
/* Find the correct font size for the lineheight */
|
/* Find the correct font size for the lineheight */
|
||||||
@ -414,6 +414,23 @@ class lpdf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addLabelBox($xp,$yp,$wp,$hp)
|
||||||
|
{
|
||||||
|
$xpos = ($xp * $this->label_width) /100;
|
||||||
|
$ypos = ($yp * $this->label_effective_height) / 100;
|
||||||
|
|
||||||
|
$desired_width = ($this->label_width * $wp) / 100;
|
||||||
|
$desired_height = ($this->label_effective_height * $hp) / 100;
|
||||||
|
|
||||||
|
pdf_rect($this->pdf,
|
||||||
|
$this->loc($this->label_current_xpos + $xpos),
|
||||||
|
$this->loc($this->label_current_ypos - ($ypos + $desired_height)),
|
||||||
|
$this->loc($desired_width),
|
||||||
|
$this->loc($desired_height));
|
||||||
|
pdf_stroke($this->pdf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function newLabel($show_box=false, $show_fairname=false, $show_logo=false)
|
function newLabel($show_box=false, $show_fairname=false, $show_logo=false)
|
||||||
{
|
{
|
||||||
if($this->current_label_index==$this->labels_per_page)
|
if($this->current_label_index==$this->labels_per_page)
|
||||||
|
Loading…
Reference in New Issue
Block a user