Beispiel #1
0
 /**
  * Process D0 SDIF records from the Queue
  *
  * @return int number of records processed
  */
 function ProcessQueueD0Records()
 {
     //  Processing D0 records is trickier than B1 or C1
     //  records because each D0 record is associated with
     //  a C1 record prior to it and D0 and C1 records are
     //  associated with the B1 record.
     $this->setQuery(sprintf('SELECT sdifrecord FROM %s WHERE recordtype="B1"', FT_SDIFQUEUE_TABLE));
     $this->runSelectQuery(true);
     $rslt = $this->getQueryResult();
     $rsltscnt = $this->getQueryCount();
     $b1_record = new SwimMeet();
     $b1_record->setSDIFRecord($rslt["sdifrecord"]);
     $b1_record->ParseRecord();
     $swimmeetid = $b1_record->GetSwimMeetIdByName();
     //  Need D0 record to add or update the swim meet BUT
     //  need to select the C1 records as well to ensure that
     //  D0 records are associated with the proper team.
     $this->setQuery(sprintf('SELECT recordtype, sdifrecord, linenumber
         FROM %s WHERE recordtype="D0" OR recordtype="C1" ORDER BY
         linenumber', FT_SDIFQUEUE_TABLE));
     $this->runSelectQuery(true);
     $swimmer = new Swimmer();
     $c1_record = new SwimTeam();
     $d0_record = new SwimResult();
     $rslts = $this->getQueryResults();
     $rsltscnt = $this->getQueryCount();
     //  Process each C1 and D0 record in the file.
     foreach ($rslts as $rslt) {
         //  Look for C1 records to set swim team
         if ($rslt['recordtype'] == 'C1') {
             $c1_record->setSDIFRecord($rslt["sdifrecord"]);
             $c1_record->ParseRecord();
             $swimteamid = $c1_record->GetSwimTeamIdByName();
             //  Need to select swim team id based on C1 record
         } else {
             $d0_record->setSDIFRecord($rslt["sdifrecord"]);
             $d0_record->ParseRecord();
             $d0_record->setSwimMeetId($swimmeetid['swimmeetid']);
             $d0_record->setSwimTeamId($swimteamid['swimteamid']);
             //  Does the swimmer exist?  If not, the swimmer
             //  record needs to be created.  The USS ID can be
             //  used to determine uniqueness BUT there is a chance
             //  that more than one swimmer id could be returned.
             $swimmer->setUSSNew($d0_record->getUSSNew());
             $swimmer->setSwimTeamId($d0_record->getSwimTeamId());
             if ($swimmer->SwimmerExistsByUSSNewAndSwimTeamId()) {
                 $swimmerid = $swimmer->GetSwimmerIdByUSSNewAndSwimTeamId();
             } else {
                 //print '<h1>' . basename(__FILE__) . '::' . __LINE__ . '</h1>' ;
                 $swimmer->setSwimTeamId($d0_record->getSwimTeamId());
                 $swimmer->setBirthDate($d0_record->getBirthDate(true), true);
                 $name = $d0_record->getSwimmerName();
                 list($last, $first, $middle) = explode(',', $name . ',,', 3);
                 if ($first == ',') {
                     $first = '';
                 }
                 if ($middle == ',') {
                     $middle = '';
                 }
                 $swimmer->setSwimmerLastName($last);
                 $swimmer->setSwimmerFirstName($first);
                 $swimmer->setSwimmerMiddleName($middle);
                 $swimmer->setUSS($d0_record->getUSS());
                 $swimmer->setUSSNew($d0_record->getUSSNew());
                 $swimmer->setGender($d0_record->getGender());
                 $swimmer->AddSwimmer();
                 $swimmerid = $swimmer->getSwimmerId();
                 if ($swimmerid == null) {
                     $this->add_status_message(sprintf('Unable to add swimmer "%s" from line %d to the database, result record skipped.', $d0_record->getSwimmerName(), $rslt['linenumber']), FT_WARNING);
                 }
             }
             //  The Swimmer Id may be in an array so need to extract it if it is.
             if (is_array($swimmerid)) {
                 $swimmerid = $swimmerid['swimmerid'];
             }
             //  Try and add the result
             if ($swimmerid != null) {
                 $d0_record->setSwimmerId($swimmerid);
                 if (!$d0_record->ResultExistsByMeetTeamAndSwimmer()) {
                     $d0_record->AddResult();
                 } else {
                     $this->add_status_message(sprintf('Result for "%s" from line %d is already stored in the database, ignored.', $d0_record->getSwimmerName(), $rslt['linenumber']), FT_WARNING);
                 }
             }
         }
     }
     //return $this->getAffectedRows() ;
     return $rsltscnt;
 }
Beispiel #2
0
 /**
  * Construct a summary of the active season.
  *
  */
 function BuildInfoTable($resultid = null)
 {
     //  Alternate the row colors
     $this->set_alt_color_flag(true);
     $result = new SwimResult();
     if (is_null($resultid)) {
         $resultid = $this->getResultId();
     }
     if (!is_null($resultid) || $result->ResultExistsById($resultid)) {
         $result->LoadResultById($resultid);
         $this->add_row(html_b("Swim Meet Id"), $result->getSwimmeetid());
         $this->add_row(html_b("Swim Team Id"), $result->getSwimteamid());
         $this->add_row(html_b("Swimmer Id"), $result->getSwimmerid());
         $this->add_row(html_b("Organization"), SDIFCodeTables::GetOrgCode($result->getOrgCode()));
         $this->add_row(html_b("Swimmer Name"), $result->getSwimmerName());
         $this->add_row(html_b("USS"), $result->getUSS());
         $this->add_row(html_b("USS (new)"), $result->getUSSNew());
         $this->add_row(html_b("USS (old)"), $result->getUSSOld());
         $this->add_row(html_b("Attached"), SDIFCodeTables::GetAttachedCode($result->getAttachCode()));
         $this->add_row(html_b("Citizen"), SDIFCOdeTables::GetCitizenCode($result->getCitizenCode()));
         $this->add_row(html_b("Birth Date"), $result->getBirthDate(true));
         $this->add_row(html_b("Age or Class"), $result->getAgeOrClass());
         $this->add_row(html_b("Gender"), SDIFCodeTables::GetGenderCode($result->getGender()));
         $this->add_row(html_b("Event Gender"), SDIFCodeTables::GetEventGenderCode($result->getEventGender()));
         $this->add_row(html_b("Event Distance"), $result->getEventDistance());
         $this->add_row(html_b("Stroke Code"), SDIFCodeTables::GetStrokeCode($result->getStrokeCode()));
         $this->add_row(html_b("Event Number"), $result->getEventNumber());
         $this->add_row(html_b("Event Age Code"), $result->getEventAgeCode());
         $this->add_row(html_b("Swim Date"), $result->getSwimDate(true));
         $this->add_row(html_b("Seed Time"), $result->getSeedTime());
         $this->add_row(html_b("Seed Course"), SDIFCodeTables::GetCourseCode($result->getSeedCourseCode()));
         $this->add_row(html_b("Prelim Time"), $result->getPrelimTime());
         $this->add_row(html_b("Prelim Course"), SDIFCodeTables::GetCourseCode($result->getPrelimCourseCode()));
         $this->add_row(html_b("Swim Off Time"), $result->getSwimOffTime());
         $this->add_row(html_b("Swim Off Course"), SDIFCodeTables::GetCourseCode($result->getSwimOffCourseCode()));
         $this->add_row(html_b("Finals Time"), $result->getFinalsTime());
         $this->add_row(html_b("Finals Course"), SDIFCodeTables::GetCourseCode($result->getFinalsCourseCode()));
         $this->add_row(html_b("Prelim Heat Number"), $result->getPrelimHeatNumber());
         $this->add_row(html_b("Prelim Lane Number"), $result->getPrelimLaneNumber());
         $this->add_row(html_b("Finals Heat Number"), $result->getFinalsHeatNumber());
         $this->add_row(html_b("Finals Lane Number"), $result->getFinalsLaneNumber());
         $this->add_row(html_b("Prelim Place Ranking"), $result->getPrelimPlaceRanking());
         $this->add_row(html_b("Finals Place Ranking"), $result->getFinalsPlaceRanking());
         $this->add_row(html_b("Finals Points"), $result->getFinalsPoints());
         $this->add_row(html_b("Event Time Class Code"), $result->getEventTimeClassCode());
         $this->add_row(html_b("Swimmer Flight Status"), $result->getSwimmerFlightStatus());
     } else {
         $this->add_row("No swim result details available.");
     }
 }