Changeset 12186
- Timestamp:
- 09/12/07 22:01:38 (1 year ago)
- Files:
-
- trunk/midcom/fi.mik.lentopaikkakisa/exec (added)
- trunk/midcom/fi.mik.lentopaikkakisa/exec/recalculate_scores.php (added)
- trunk/midcom/fi.mik.lentopaikkakisa/handler/download.php (modified) (4 diffs)
- trunk/midcom/fi.mik.lentopaikkakisa/handler/score.php (modified) (1 diff)
- trunk/midcom/fi.mik.lentopaikkakisa/viewer.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/fi.mik.lentopaikkakisa/handler/download.php
r3414 r12186 28 28 $_MIDCOM->header("Content-type: text/xml; charset=UTF-8"); 29 29 30 $qb = fi_mik_ lentopaikkakisa_report_dba::new_query_builder();30 $qb = fi_mik_flight_dba::new_query_builder(); 31 31 $qb->add_order('created', 'DESC'); 32 32 $this->_request_data['all'] = $qb->execute(); … … 37 37 function _show_xml($handler_id, &$data) 38 38 { 39 $_MIDCOM->load_library('midcom.helper.xml'); 39 40 echo "<reports>\n"; 40 41 $mapper = new midcom_helper_xml_objectmapper(); … … 50 51 $_MIDCOM->auth->require_valid_user(); 51 52 $_MIDCOM->skip_page_style = true; 52 $_MIDCOM->header('Content-Type: text/plain;charset=UTF-8'); 53 $_MIDCOM->cache->content->content_type('application/csv'); 54 $_MIDCOM->header('Content-Type: application/csv;charset=UTF-8'); 53 55 54 $qb = fi_mik_ lentopaikkakisa_report_dba::new_query_builder();56 $qb = fi_mik_flight_dba::new_query_builder(); 55 57 $qb->add_order('created', 'DESC'); 56 58 $this->_request_data['all'] = $qb->execute(); … … 61 63 function _show_csv($handler_id, &$data) 62 64 { 65 $pilots = array(); 66 $organizations = array(); 67 $aircraft = array(); 68 echo "date,firstname,lastname,username,operator,aircraft,origin,destination,score_origin,score_destination\n"; 63 69 foreach ($this->_request_data['all'] as $report) 64 70 { 65 71 // FIXME: Use DM2 CSV output system 66 echo date('Y-m-d', $report->date).",{$report->organization},{$report->aerodrome},{$report->plane},".str_replace(',','.',$report->score).",{$report->sendername}\n"; 72 if (!isset($pilots[$report->pilot])) 73 { 74 $pilots[$report->pilot] = new midcom_db_person($report->pilot); 75 } 76 if (!isset($organizations[$report->operator])) 77 { 78 $organizations[$report->operator] = new midcom_db_group($report->operator); 79 } 80 if (!isset($aircraft[$report->aircraft])) 81 { 82 $aircraft[$report->aircraft] = new org_openpsa_calendar_resource_dba($report->aircraft); 83 } 84 echo date('Y-m-d', $report->end).",{$pilots[$report->pilot]->firstname},{$pilots[$report->pilot]->lastname},{$pilots[$report->pilot]->username},{$organizations[$report->operator]->official},{$aircraft[$report->aircraft]->title},{$report->origin},{$report->destination},".str_replace(',','.',$report->scoreorigin).",".str_replace(',','.',$report->scoredestination)."\n"; 67 85 } 68 86 } trunk/midcom/fi.mik.lentopaikkakisa/handler/score.php
r5578 r12186 55 55 { 56 56 $owner = new $report_class($score->parentguid); 57 $data['scores'][ $owner->$report_label] =$score->value;58 $data['total'] += $score->value;57 $data['scores']["{$owner->$report_label} ({$score->parentguid}"] = (int) $score->value; 58 $data['total'] += (int) $score->value; 59 59 } 60 61 arsort($data['scores']); 60 62 return true; 61 63 } trunk/midcom/fi.mik.lentopaikkakisa/viewer.php
r5572 r12186 48 48 'fixed_args' => Array('score', 'pilot'), 49 49 ); 50 51 // Match /flights.xml 52 $this->_request_switch['xml'] = Array 53 ( 54 'handler' => Array('fi_mik_lentopaikkakisa_handler_download', 'xml'), 55 'fixed_args' => Array('flights.xml'), 56 ); 57 58 // Match /flights.csv 59 $this->_request_switch['csv'] = Array 60 ( 61 'handler' => Array('fi_mik_lentopaikkakisa_handler_download', 'csv'), 62 'fixed_args' => Array('flights.csv'), 63 ); 50 64 } 51 65
