From 81ff5fce83ec33a90240f7f7757a389939d48b95 Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Fri, 28 Oct 2005 05:22:54 +0000 Subject: [PATCH] use squad ordering from phpgacl in the team roster --- .../patient_file/summary/demographics_full.php | 2 +- interface/reports/players_report.php | 51 +++++++++++++++------- library/acl.inc | 6 ++- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/interface/patient_file/summary/demographics_full.php b/interface/patient_file/summary/demographics_full.php index 96762f232..788c54062 100644 --- a/interface/patient_file/summary/demographics_full.php +++ b/interface/patient_file/summary/demographics_full.php @@ -319,7 +319,7 @@ function checkNum () { foreach ($squads as $key => $value) { echo " \n"; + echo ">" . $value[3] . "\n"; } } ?> diff --git a/interface/reports/players_report.php b/interface/reports/players_report.php index 19d52688b..62365be62 100644 --- a/interface/reports/players_report.php +++ b/interface/reports/players_report.php @@ -13,12 +13,7 @@ include_once("$srcdir/patient.inc"); include_once("$srcdir/acl.inc"); - // $squads = array( - // 'None', - // 'Senior', - // 'Academy', - // 'Ladies' - // ); + $squads = acl_get_squads(); $fitnesses = array( 'Full Play', @@ -32,8 +27,30 @@ $alertmsg = ''; // not used yet but maybe later - $query = "SELECT * FROM patient_data ORDER BY squad, lname, fname"; + $query = "SELECT pid, squad, fitness, lname, fname FROM " . + "patient_data"; // ORDER BY squad, lname, fname $res = sqlStatement($query); + + // Sort the patients in squad priority order. + function patient_compare($a, $b) { + global $squads; + if ($squads[$a['squad']][3] == $squads[$b['squad']][3]) { + if ($a['lname'] == $b['lname']) { + return ($a['fname'] < $b['fname']) ? -1 : 1; + } + return ($a['lname'] < $b['lname']) ? -1 : 1; + } + // The squads are different so compare their order attributes, + // or unassigned squads sort last. + if (! $squads[$a['squad']][3]) return 1; + if (! $squads[$b['squad']][3]) return -1; + return ($squads[$a['squad']][2] < $squads[$b['squad']][2]) ? -1 : 1; + } + $ordres = array(); + if ($res) { + while ($row = sqlFetchArray($res)) $ordres[] = $row; + usort($ordres, "patient_compare"); + } ?> @@ -100,13 +117,17 @@ -   +     @@ -130,9 +151,9 @@ diff --git a/library/acl.inc b/library/acl.inc index ea16a9a7c..85f62ec33 100644 --- a/library/acl.inc +++ b/library/acl.inc @@ -93,7 +93,8 @@ return 0; } - // Return an array of squad ACO names and descriptive names. + // Return an array keyed on squad ACO names. Each value is an + // array (section_value, value, order_value, name, hidden). // This is only applicable for sports team use. // function acl_get_squads() { @@ -106,7 +107,8 @@ $arr = array(); foreach ($arr1[$section] as $value) { $odata = $gacl->get_object_data($gacl->get_object_id($section, $value, 'ACO'), 'ACO'); - $arr[$value] = $odata[0][3]; + // $arr[$value] = $odata[0][3]; + $arr[$value] = $odata[0]; } return $arr; } -- 2.11.4.GIT