- Replace reports_acpresentation with a report from the report generator.

- Implementing a function call option to parse column data in the report
  generator as it comes out of the database.
This commit is contained in:
dave 2007-12-25 05:13:42 +00:00
parent a912b7df99
commit f3f2747118
6 changed files with 78 additions and 175 deletions

View File

@ -248,11 +248,6 @@ foreach($report_stock as $n=>$v) {
'desc' => 'Award List for Award Ceremony Program creation',
'custom_url' => 'admin/reports_program_awards.php?type=csv',
'creator' => 'The Grant Brothers');
$x++;
$report_custom[$x] = array('id' => $x, 'name' => 'Custom -- Award Winners (CSV)',
'desc' => 'Award Winners',
'custom_url' => 'admin/reports_acpresentation.php?type=csv',
'creator' => 'The Grant Brothers');
function report_save_field($report, $type, $loc)
{
@ -698,6 +693,11 @@ foreach($report_stock as $n=>$v) {
$f = $d['field'];
if(is_array($fields[$f]['value_map'])) {
$v = $fields[$f]['value_map'][$i["C$o"]];
} else if(is_callable($fields[$f]['exec_function'])) {
$v = call_user_func_array($fields[$f]['exec_function'], array($i["C$o"]));
// } else if(isset($fields[$f]['exec_code'])) {
// Somethign like this, how do we pass $i["C$o"] in?
// $v = exec($fields[$f]['exec_code']);
} else {
$v = $i["C$o"];
}

View File

@ -1,166 +0,0 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
require("../lpdf.php");
require("../lcsv.php");
$type=$_GET['type'];
if(!$type) $type="csv";
if($type=="csv")
{
$rep=new lcsv(i18n("Awards Ceremony Presentation"));
}
$q=mysql_query("SELECT
award_awards.id,
award_awards.name,
award_awards.presenter,
award_awards.order AS awards_order,
award_types.type
FROM
award_awards,
award_types
WHERE
award_awards.year='".$config['FAIRYEAR']."'
AND award_types.year='".$config['FAIRYEAR']."'
AND award_awards.award_types_id=award_types.id
AND award_awards.excludefromac='0'
ORDER BY awards_order");
echo mysql_error();
$table=array();
// $table['header']=array(i18n("Timeslot"),i18n("Judging Team"));
$table['widths']=array( 1,1,1,1,1,1,1,1);
$table['dataalign']=array("left","left","left","left","left","left","left","left");
if(mysql_num_rows($q))
{
while($r=mysql_fetch_object($q))
{
$award=$r->name;
$pq=mysql_query("SELECT
award_prizes.prize,
award_prizes.number,
award_prizes.id,
award_prizes.cash,
award_prizes.scholarship,
winners.projects_id,
projects.projectnumber,
projects.title,
projects.registrations_id AS reg_id,
projectcategories.category,
projectdivisions.division
FROM
award_prizes
LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id
LEFT JOIN projects ON projects.id=winners.projects_id
LEFT JOIN projectcategories ON projects.projectcategories_id=projectcategories.id
LEFT JOIN projectdivisions ON projects.projectdivisions_id=projectdivisions.id
WHERE
award_awards_id='$r->id'
AND award_prizes.year='".$config['FAIRYEAR']."'
AND award_prizes.excludefromac='0'
AND projectcategories.year='".$config['FAIRYEAR']."'
AND projectdivisions.year='".$config['FAIRYEAR']."'
ORDER BY
projectcategories.id,projectdivisions.id,
`order`");
echo mysql_error();
$prevprizeid=-1;
while($pr=mysql_fetch_object($pq))
{
if($prevprizeid!=$pr->id)
{
$prizetext=$pr->prize;
if($pr->cash || $pr->scholarship)
{
$prizetext.=" (";
if($pr->cash && $pr->scholarship)
$prizetext.="\$$pr->cash cash / \$$pr->scholarship scholarship";
else if($pr->cash)
$prizetext.= "\$$pr->cash cash";
else if($pr->scholarship)
$prizetext.= "\$$pr->scholarship scholarship";
$prizetext.= ")";
}
$prevprizeid=$pr->id;
}
if($pr->projectnumber)
{
$sq=mysql_query("SELECT students.firstname,
students.lastname,
students.schools_id,
schools.school,
schools.board,
schools.district,
schools.postalcode,
schools.city
FROM
students,
schools
WHERE
students.registrations_id='$pr->reg_id'
AND students.schools_id=schools.id
");
$students=" Students: ";
$studnum=0;
$student1="";
$student2="";
while($studentinfo=mysql_fetch_object($sq))
{
if($studnum==0) $student1="$studentinfo->firstname $studentinfo->lastname";
if($studnum==1) $student2="$studentinfo->firstname $studentinfo->lastname";
if($studnum>0) $students.=", ";
$studnum++;
//we will assume that they are coming from the same school, so lets just grab the last students school
//and use it.
$school=$studentinfo->school;
$schoolboard=$studentinfo->board;
$schooldistrict=$studentinfo->district;
$schoolpostalcode=$studentinfo->postalcode;
$schoolcity=$studentinfo->city;
}
}
else
{
}
/*
$table['data'][]=array(i18n("Division"),$proj->division);
$table['data'][]=array(i18n("Category"),$proj->category);
$table['data'][]=array(i18n("Prize"),$prizetext);
$table['data'][]=array(i18n("Proj #"),$pr->projectnumber);
$table['data'][]=array(i18n("Project Title"),$pr->title);
$table['data'][]=array(i18n("Name 1"),$student1);
$table['data'][]=array(i18n("Name 2"),$student2);
$table['data'][]=array(i18n("School"),$school->school);
*/
$table['data'][]=array($pr->division,
i18n($pr->division,array(),array(),"fr"),
"$pr->category / ".i18n($pr->category,array(),array(),"fr"),
$award,
$prizetext,
$pr->projectnumber,
$pr->title,
$student1,
$student2,
$school,
$schoolcity,
$schoolboard,
$schoolpostalcode
);
}
}
}
$rep->addTable($table);
$rep->output();
?>

View File

@ -163,7 +163,7 @@ while($catr=mysql_fetch_object($catq))
echo i18n("Award Ceremony Script").": ";
echo "<a href=\"reports_acscript.php?type=csv\">CSV</a> &nbsp; ";
echo "<br />";
echo "<a href=\"reports_acpresentation.php?type=csv\">Award Winners CSV</a> &nbsp; ";
echo "<a href=\"reports_gen.php?sid=42\">Award Winners CSV</a> &nbsp; ";
echo "<br />";
send_footer();

View File

@ -21,6 +21,11 @@
Boston, MA 02111-1307, USA.
*/
function report_students_i18n_fr($text)
{
return i18n($text, array(), array(), 'fr');
}
$report_students_fields = array(
'pn' => array(
'name' => 'Project Number',
@ -55,7 +60,14 @@ $report_students_fields = array(
'table_sort'=> 'students.lastname' ),
'partner' => array(
'name' => 'Student -- Partner Name',
'name' => 'Student -- Partner Name (last, first)',
'header' => 'Partner',
'width' => 1.5,
'table' => "CONCAT(students2.lastname, ', ', students2.firstname)",
'components' => array('partner') ),
'partnerfl' => array(
'name' => 'Student -- Partner Name (first last)',
'header' => 'Partner',
'width' => 1.5,
'table' => "CONCAT(students2.lastname, ', ', students2.firstname)",
@ -126,6 +138,13 @@ $report_students_fields = array(
'width' => 3.0,
'table' => 'projectdivisions.division' ),
'fr_division' => array(
'name' => 'Project -- Division (French)',
'header' => i18n('Division', array(), array(), 'fr'),
'width' => 3.0,
'table' => 'projectdivisions.division',
'exec_function' => 'report_students_i18n_fr'),
'div' => array(
'name' => 'Project -- Division Short Form' ,
'header' => 'Div',
@ -139,6 +158,14 @@ $report_students_fields = array(
'table_sort' => 'projectcategories.id',
'table' => 'projectcategories.category' ),
'fr_category' => array(
'name' => 'Project -- Category (French)',
'header' => i18n('Category', array(), array(), 'fr'),
'width' => 1,
'table_sort' => 'projectcategories.id',
'table' => 'projectcategories.category',
'exec_function' => 'report_students_i18n_fr'),
'categorydivision' => array(
'name' => 'Project -- Category and Division',
'header' => 'Category/Division',
@ -292,7 +319,14 @@ $report_students_fields = array(
'width' => 4,
'table' => 'award_awards.name',
'components' => array('awards')),
'award_excludefromac' => array(
'name' => 'Award -- Exclude from Award Ceremony (Yes/No)',
'header' => 'Exclude',
'width' => .5,
'table' => "award_awards.excludefromac",
'value_map' => array ('no' => 'No', 'yes' => 'Yes')),
'order' => array(
'name' => 'Award -- Order',
'header' => 'Award Order',

View File

@ -1 +1 @@
90
91

35
db/db.update.91.sql Normal file
View File

@ -0,0 +1,35 @@
INSERT INTO `reports` (`id`, `system_report_id`, `name`, `desc`, `creator`, `type`) VALUES
('', '42', 'Winners -- Award Ceremony Presentation Data', 'A CSV dump of all the winners and their prizes. Useful for importing into an award ceremony presentation, or a document.', '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', 'csv', 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', 'fullpage', 0, 0, 0, 0, 0, '', ''),
('', LAST_INSERT_ID(), 'col', 0, 'division', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 1, 'fr_division', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 2, 'category', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 3, 'fr_category', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 4, 'award_name', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 5, 'award_prize_name', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 6, 'award_prize_cash', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 7, 'award_prize_scholarship', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 8, 'award_prize_value', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 9, 'pn', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 10, 'title', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 11, 'namefl', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 12, 'partnerfl', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 13, 'school', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 14, 'school_city', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 15, 'school_province', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 16, 'school_board', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'col', 17, 'school_postal', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'sort', 0, 'order', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'distinct', 0, 'pn', '', 0, 0, 0, 0, 1, '', ' '),
('', LAST_INSERT_ID(), 'filter', 0, 'award_excludefromac', 'no', 0, 0, 0, 0, 1, '', ' ');
SELECT @id:=id FROM reports WHERE system_report_id='42';
UPDATE reports_committee SET reports_id=@id WHERE reports_id='-9';