/** * 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; }
/** * Construct a summary of the active season. * */ function BuildInfoTable($swimteamid = null) { // Alternate the row colors $this->set_alt_color_flag(true); $team = new SwimTeam(); if (is_null($swimteamid)) { $swimteamid = $this->getSwimTeamId(); } if (!is_null($swimteamid) || $team->SwimTeamExistsById($swimteamid)) { $team->LoadSwimTeamById($swimteamid); $this->add_row(html_b("Organization"), SDIFCodeTables::GetOrgCode($team->getOrgCode())); $this->add_row(html_b("Team Code"), $team->getTeamCode()); $this->add_row(html_b("Team Name"), $team->getTeamName()); $this->add_row(html_b("Team Name Abbreviation"), $team->getTeamNameAbrv()); $this->add_row(html_b("Team Addresss 1"), $team->getTeamAddress1()); $this->add_row(html_b("Team Addresss 2"), $team->getTeamAddress2()); $this->add_row(html_b("City"), $team->getTeamCity()); $this->add_row(html_b("State"), $team->getTeamState()); $this->add_row(html_b("Postal Code"), $team->getTeamPostalCode()); $this->add_row(html_b("Country"), SDIFCodeTables::GetCountryCode($team->getTeamCountryCode())); $this->add_row(html_b("Region"), SDIFCodeTables::GetRegionCode($team->getRegionCode())); $this->add_row(html_b("Team Code 5th Character"), $team->getTeamCode5()); } else { $this->add_row("No swim team details available."); } }
/** * Construct a summary of the active season. * */ function BuildInfoTable($swimmerid = null) { include_once 'swimteams.class.php'; // Alternate the row colors $this->set_alt_color_flag(true); $swimmer = new Swimmer(); if (is_null($swimmerid)) { $swimmerid = $this->getSwimmerId(); } if (!is_null($swimmerid) || $swimmer->SwimmerExistsById($swimmerid)) { $swimmer->LoadSwimmerById($swimmerid); $swimteam = new SwimTeam(); $swimteam->LoadSwimTeamById($swimmer->getSwimTeamId()); $this->add_row(html_b("Team Name"), $swimteam->getTeamName()); $this->add_row(html_b("Last Name"), $swimmer->getSwimmerLastName()); $this->add_row(html_b("First Name"), $swimmer->getSwimmerFirstName()); $this->add_row(html_b("Middle Name"), $swimmer->getSwimmerMiddleName()); $this->add_row(html_b("Birth Date"), $swimmer->getBirthDate(true)); $this->add_row(html_b("USS"), $swimmer->getUSS()); $this->add_row(html_b("USS (calculated)"), $swimmer->getUSSNew()); $this->add_row(html_b("Gender"), SDIFCodeTables::GetGenderCode($swimmer->getGender())); } else { $this->add_row("No swim swimmer details available."); } }
/** * Get the array of opponent swim club key and value pairs * * @return mixed - array of opponent swim club key value pairs */ function SwimTeamSelections() { // Swim Club options and labels, seed "None" as an // option as some meet types don't have an opponent. $s = array(ucfirst(FT_NONE) => FT_NULL_ID); $swimteam = new SwimTeam(); $swimteamIds = $swimteam->getAllSwimTeamIds(); // Make sure we have swim clubs to build a list of! if ($swimteamIds != null) { foreach ($swimteamIds as $swimteamId) { $swimteam->LoadSwimTeamById($swimteamId['swimteamid']); $team = $swimteam->getTeamName(); $s[$team] = $swimteam->getSwimTeamId(); } } return $s; }
/** * This method is called ONLY after ALL validation has * passed. This is the method that allows you to * do something with the data, say insert/update records * in the DB. */ function form_action() { $success = true; $swimteam = new SwimTeam(); $swimteam->PurgeSwimTeams(); $this->set_action_message(html_div(sprintf('ft-%s-msg', $swimteam->getAffectedRows() == 0 ? 'warning' : 'note'), sprintf('%d record%s purged from Swim Teams database.', $swimteam->getAffectedRows(), $swimteam->getAffectedRows() == 1 ? '' : 's'))); unset($swimteam); return $success; }