本文整理汇总了PHP中Location::regionsToHash方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::regionsToHash方法的具体用法?PHP Location::regionsToHash怎么用?PHP Location::regionsToHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location::regionsToHash方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
public function editAction()
{
if (!$this->hasACL('edit_employee')) {
$this->doNoAccessError();
}
$db = $this->dbfunc();
$status = ValidationContainer::instance();
$params = $this->getAllParams();
$id = $params['id'];
#// restricted access?? only show partners by organizers that we have the ACL to view
#$org_allowed_ids = allowed_org_access_full_list($this);
#if ($org_allowed_ids && $this->view->mode != 'add') { // doesnt have acl 'training_organizer_option_all'
# $validID = $db->fetchCol("SELECT partner.id FROM partner WHERE partner.id = $id AND partner.organizer_option_id in ($org_allowed_ids)"); // check for both
# if(empty($validID))
# $this->doNoAccessError ();
#}
if ($this->getRequest()->isPost()) {
//validate then save
$params['location_id'] = regionFiltersGetLastID('', $params);
$params['dob'] = $this->_date_to_sql($params['dob']);
$params['agreement_end_date'] = $this->_date_to_sql($params['agreement_end_date']);
$params['transition_date'] = $this->_date_to_sql($params['transition_date']);
$params['transition_complete_date'] = $this->_date_to_sql($params['transition_complete_date']);
$params['site_id'] = $params['facilityInput'];
$params['option_nationality_id'] = $params['lookup_nationalities_id'];
$params['facility_type_option_id'] = $params['employee_site_type_option_id'];
$status->checkRequired($this, 'first_name', t('Frist Name'));
$status->checkRequired($this, 'last_name', t('Last Name'));
$status->checkRequired($this, 'last_name', t('Name'));
$status->checkRequired($this, 'dob', t('Name'));
if ($this->setting('display_employee_nationality')) {
$status->checkRequired($this, 'lookup_nationalities_id', t('Employee Nationality'));
}
$status->checkRequired($this, 'employee_qualification_option_id', t('Staff Cadre'));
if ($this->setting('display_employee_salary')) {
$status->checkRequired($this, 'salary', t('Salary'));
}
if ($this->setting('display_employee_benefits')) {
$status->checkRequired($this, 'benefits', t('Benefits'));
}
if ($this->setting('display_employee_additional_expenses')) {
$status->checkRequired($this, 'additional_expenses', t('Additional Expenses'));
}
if ($this->setting('display_employee_stipend')) {
$status->checkRequired($this, 'stipend', t('Stipend'));
}
if ($this->setting('display_employee_partner')) {
$status->checkRequired($this, 'partner_id', t('Partner'));
}
if ($this->setting('display_employee_sub_partner')) {
$status->checkRequired($this, 'subpartner_id', t('Sub Partner'));
}
if ($this->setting('display_employee_intended_transition')) {
$status->checkRequired($this, 'employee_transition_option_id', t('Intended Transition'));
}
if ($this->setting('display_employee_base') && !$params['employee_base_option_id'] || !$this->setting('display_employee_base')) {
// either one is OK, javascript disables regions if base is on & has a value choice
$status->checkRequired($this, 'province_id', t('Region A (Province)'));
}
if ($this->setting('display_employee_base')) {
$status->checkRequired($this, 'employee_base_option_id', t('Employee Based at'));
}
if (!$status->hasError()) {
$id = $this->_findOrCreateSaveGeneric('employee', $params);
if (!$id) {
$status->setStatusMessage(t('That person could not be saved.'));
} else {
# converted to optionlist, link table not needed TODO. marking for removal.
#MultiOptionList::updateOptions ( 'employee_to_role', 'employee_role_option', 'employee_id', $id, 'employee_role_option_id', $params['employee_role_option_id'] );
$status->setStatusMessage(t('The person was saved.'));
$this->_redirect("employee/edit/id/{$id}");
}
} else {
$status->setStatusMessage(t('That person could not be saved.'));
}
}
if ($id && !$status->hasError()) {
// read data from db
$sql = 'SELECT * FROM employee WHERE employee.id = ' . $id;
$row = $db->fetchRow($sql);
if ($row) {
$params = $row;
} else {
$status->setStatusMessage(t('Error finding that record in the database.'));
}
$region_ids = Location::getCityInfo($params['location_id'], $this->setting('num_location_tiers'));
$region_ids = Location::regionsToHash($region_ids);
$params = array_merge($params, $region_ids);
#$params['roles'] = $db->fetchCol("SELECT employee_role_option_id FROM employee_to_role WHERE employee_id = $id");
}
// assign form drop downs
$params['dob'] = formhelperdate($params['dob']);
$params['agreement_end_date'] = formhelperdate($params['agreement_end_date']);
$params['transition_date'] = formhelperdate($params['transition_date']);
$params['transition_complete_date'] = formhelperdate($params['transition_complete_date']);
$params['courses'] = $this->getCourses($id);
$params['lookup_nationalities_id'] = $params['option_nationality_id'];
$params['employee_site_type_option_id'] = $params['facility_type_option_id'];
$this->viewAssignEscaped('employee', $params);
$validCHWids = $db->fetchCol("select id from employee_qualification_option qual\r\n\t\t\t\t\t\t\t\t\t\tinner join (select id as success from employee_qualification_option where qualification_phrase in ('Community Based Worker','Community Health Worker','NC02 -Community health workers')) parentIDs\r\n\t\t\t\t\t\t\t\t\t\ton (parentIDs.success = qual.id)");
//.........这里部分代码省略.........
示例2: doAddEditView
//.........这里部分代码省略.........
if ($validateOnly) {
$this->sendData($status);
} else {
$this->view->assign('status', $status);
}
}
if ($this->setting('display_mod_skillsmart')) {
if ($person_id) {
$rows = $db->fetchAll('SELECT `facstring` FROM `facs` INNER JOIN `facility` ON `facs`.`facility` = `facility`.`id` WHERE `facility`.`is_deleted`=0 AND `facs`.`person`=' . $person_id . ' AND `facs`.`Active`=\'Y\' ORDER BY `facs`.`sno` ASC;');
$Fcs = "";
foreach ($rows as $rw) {
$Fcs = $Fcs . $rw['facstring'] . '$';
}
$Fcs = trim($Fcs, '$');
$this->view->assign('Fcs', $Fcs);
$rows = $db->fetchAll('SELECT `id`, `chk`, `yr`, `transstring` FROM `trans` WHERE `person`=' . $person_id . ' AND `Active`=\'Y\' ORDER BY sno ASC;');
$Trs = array();
$cok = 0;
for ($cok = 1; $cok <= 20; $cok++) {
$Trs[$cok] = NULL;
}
foreach ($rows as $rw) {
$Trs[$rw['id']] = $rw;
}
$this->view->assign('Trs', $Trs);
}
}
//view it
$facilityObj = new Facility();
$facilityrow = $facilityObj->findOrCreate($personrow->facility_id);
$personArray['facility'] = $facilityrow->toArray();
//facility location
$region_ids = Location::getCityInfo($facilityrow->location_id, $this->setting('num_location_tiers'));
$region_ids = Location::regionsToHash($region_ids, 'person_facility');
$personArray = array_merge($personArray, $region_ids);
//audit history
$creatorObj = new User();
$updaterObj = new User();
$creatorrow = $creatorObj->findOrCreate($personrow->created_by);
$personArray['creator'] = addslashes($creatorrow->first_name . ' ' . $creatorrow->last_name);
$updaterrow = $updaterObj->findOrCreate($personrow->modified_by);
$personArray['updater'] = addslashes($updaterrow->first_name . ' ' . $updaterrow->last_name);
$personArray['birthdate-year'] = '';
$personArray['birthdate-month'] = '';
$personArray['birthdate-day'] = '';
//split birthdate fields
if ($person_id and $personrow->birthdate) {
$parts = explode(' ', $personrow->birthdate);
$parts = explode('-', $parts[0]);
$personArray['birthdate-year'] = $parts[0];
$personArray['birthdate-month'] = $parts[1];
$personArray['birthdate-day'] = $parts[2];
}
//custom fields
if ($person_id) {
$personArray['custom1'] = ITechTable::getCustomValue('person_custom_1_option', 'custom1_phrase', $personArray['person_custom_1_option_id']);
$personArray['custom2'] = ITechTable::getCustomValue('person_custom_2_option', 'custom2_phrase', $personArray['person_custom_2_option_id']);
}
//qualifications
$qualificationsArray = OptionList::suggestionListHierarchical('person_qualification_option', 'qualification_phrase', false, false, array('0 AS is_default', 'child.is_default'));
$personQualificationId = $personArray['primary_qualification_option_id'];
// get parent qualification id, if user has sub qualification selected
$personArray['primary_qualification_option_id_parent'] = $personQualificationId;
foreach ($qualificationsArray as $k => $qualArray) {
if ($qualArray['parent_phrase'] == 'unknown') {
unset($qualificationsArray[$k]);
示例3: editAction
public function editAction()
{
if (!$this->hasACL('edit_employee')) {
$this->doNoAccessError();
}
$db = $this->dbfunc();
$status = ValidationContainer::instance();
$params = $this->getAllParams();
$id = $params['id'];
#// restricted access?? only show partners by organizers that we have the ACL to view // - removed 5/1/13, they dont want this, its used by site-rollup (datashare), and user-restrict by org.
#$org_allowed_ids = allowed_org_access_full_list($this); // doesnt have acl 'training_organizer_option_all'
#$site_orgs = allowed_organizer_in_this_site($this); // for sites to host multiple training organizers on one domain
#$siteOrgsClause = $site_orgs ? " AND partner.organizer_option_id IN ($site_orgs)" : "";
#if ($org_allowed_ids && $this->view->mode != 'add') {
# $validID = $db->fetchCol("SELECT partner.id FROM partner WHERE partner.id = $id AND partner.organizer_option_id in ($org_allowed_ids) $siteOrgsClause");
# if(empty($validID))
# $this->doNoAccessError ();
#
#}
if ($this->getRequest()->isPost()) {
//validate then save
$status->checkRequired($this, 'partner', t('Partner'));
if ($this->setting('display_partner_type')) {
$status->checkRequired($this, 'partner_type_option_id', t('Type of Partner'));
}
$status->checkRequired($this, 'address1', t('Address 1'));
$status->checkRequired($this, 'address2', t('Address 2'));
$status->checkRequired($this, 'province_id', t('Region A (Province)'));
$status->checkRequired($this, 'phone', t('Phone'));
$status->checkRequired($this, 'fax', t('Fax'));
if ($this->setting('display_employee_funder')) {
$status->checkRequired($this, 'partner_funder_option_id[]', t('Funder'));
}
#$status->checkRequired ( $this, 'funding_end_date[]', t ( 'Funding End Date' ) );
#if ($this->setting('display_employee_intended_transition'))
# $status->checkRequired ( $this, 'employee_transition_option_id', t ( 'Intended Transition' ) );
if ($this->setting('display_employee_agreement_end_date')) {
$status->checkRequired($this, 'agreement_end_date', t('Agreement End Date'));
}
if ($this->setting('display_employee_importance')) {
$status->checkRequired($this, 'partner_importance_option_id', t('Importance'));
}
#$status->checkRequired ( $this, 'comments', t ( 'Partner Comments' ) );
#$status->checkRequired ( $this, 'subpartner_id[]', t ( 'Sub Partner' ) );
$params['funding_end_date'] = $this->_array_me($params['funding_end_date']);
foreach ($params['funding_end_date'] as $i => $value) {
$params['funding_end_date'][$i] = $this->_date_to_sql($value);
}
$params['transition_confirmed'] = $params['transition_confirmed'] == 'on' ? 1 : 0;
$params['agreement_end_date'] = $this->_date_to_sql($params['agreement_end_date']);
$params['subpartner_id'] = $this->_array_me($params['subpartner_id']);
foreach ($params['subpartner_id'] as $i => $value) {
// strip empty values (it breaks MultiOptionList apparently)
if (empty($value)) {
unset($params['subpartner_id'][$i]);
}
}
//location save stuff
$params['location_id'] = regionFiltersGetLastID(null, $params);
// formprefix, criteria
if ($params['city']) {
$params['location_id'] = Location::insertIfNotFound($params['city'], $params['location_id'], $this->setting('num_location_tiers'));
}
if (!$status->hasError()) {
$id = $this->_findOrCreateSaveGeneric('partner', $params);
if (!$id) {
$status->setStatusMessage(t('That partner could not be saved.'));
} else {
MultiOptionList::updateOptions('partner_to_funder', 'partner_funder_option', 'partner_id', $id, 'partner_funder_option_id', $params['partner_funder_option_id'], 'funder_end_date', $params['funding_end_date']);
$db->query("DELETE FROM partner_to_subpartner WHERE partner_id = {$id}");
// updateOptions is not clearing the old options, I dont know why... todo
MultiOptionList::updateOptions('partner_to_subpartner', 'partner', 'partner_id', $id, 'subpartner_id', $params['subpartner_id']);
$status->setStatusMessage(t('The partner was saved.'));
$this->_redirect("partner/edit/id/{$id}");
}
}
}
if ($id) {
// read data from db
#// restricted access?? only show partners by organizers that we have the ACL to view
#$org_allowed_ids = allowed_org_access_full_list($this); // doesnt have acl 'training_organizer_option_all'
#$orgWhere = ($org_allowed_ids) ? " AND partner.organizer_option_id in ($org_allowed_ids) " : "";
#// restricted access?? only show organizers that belong to this site if its a multi org site
#$site_orgs = allowed_organizer_in_this_site($this); // for sites to host multiple training organizers on one domain
#$allowedWhereClause .= $site_orgs ? " AND partner.organizer_option_id in ($site_orgs) " : "";
// continue reading data
$sql = 'SELECT * FROM partner WHERE id = ' . $id . space . $orgWhere;
$row = $db->fetchRow($sql);
if (!$row) {
$status->setStatusMessage(t('Error finding that record in the database.'));
} else {
$params = $row;
// reassign form data
$region_ids = Location::getCityInfo($params['location_id'], $this->setting('num_location_tiers'));
$params['city'] = $region_ids[0];
$region_ids = Location::regionsToHash($region_ids);
$params = array_merge($params, $region_ids);
//get linked table data from option tables
$sql = "SELECT partner_funder_option_id,funder_end_date FROM partner_to_funder WHERE partner_id = {$id}";
$params['funder'] = $db->fetchAll($sql);
//.........这里部分代码省略.........
示例4: viewlocationAction
function viewlocationAction()
{
if (!$this->hasACL('edit_course')) {
$this->view->assign('viewonly', 'disabled="disabled"');
}
require_once 'models/table/TrainingLocation.php';
$this->view->assign('id', $this->_getParam('id'));
if ($this->_getParam('id')) {
require_once 'views/helpers/DropDown.php';
$rowLocation = TrainingLocation::selectLocation($this->_getParam('id'))->toArray();
//locations
$this->viewAssignEscaped('locations', Location::getAll());
$region_ids = Location::getCityInfo($rowLocation['location_id'], $this->setting('num_location_tiers'));
$rowLocation['city_name'] = $region_ids[0];
$region_ids = Location::regionsToHash($region_ids);
$rowLocation = array_merge($rowLocation, $region_ids);
$this->viewAssignEscaped('rowLocation', $rowLocation);
//see if it is referenced anywhere
$this->view->assign('okToDelete', !TrainingLocation::isReferenced($this->_getParam('id')));
}
// location drop-down
$locations = TrainingLocation::selectAllLocations($this->setting('num_location_tiers'));
$this->viewAssignEscaped('tlocations', $locations);
}