Changeset View
Changeset View
Standalone View
Standalone View
modules/in-commerce/units/taxes/taxes_tag_processor.php
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
break; | break; | ||||
case 'has_states': | case 'has_states': | ||||
/** @var kCountryStatesHelper $cs_helper */ | /** @var kCountryStatesHelper $cs_helper */ | ||||
$cs_helper = $this->Application->recallObject('CountryStatesHelper'); | $cs_helper = $this->Application->recallObject('CountryStatesHelper'); | ||||
$has_states = $cs_helper->getCountriesWithStates(); | $has_states = $cs_helper->getCountriesWithStates(); | ||||
if ($selected_country_id && !array_key_exists($selected_country_id, $has_states)) { | if ($selected_country_id && !array_key_exists($selected_country_id, $has_states)) { | ||||
Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace: Expected 1 spaces before "if" closing bracket; 0 found | |||||
Expected 1 spaces after "if" opening bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace: Expected 1 spaces after "if" opening bracket; 0 found | |||||
list ($selected_country_id, ) = each($has_states); | $selected_country_id = key($has_states); | ||||
$this->Application->SetVar('CountrySelector', $selected_country_id); | $this->Application->SetVar('CountrySelector', $selected_country_id); | ||||
} | } | ||||
// preselect country from 1st found state | // preselect country from 1st found state | ||||
if (!$selected_country_id) { | if (!$selected_country_id) { | ||||
$sql = 'SELECT cs.StateCountryId | $sql = 'SELECT cs.StateCountryId | ||||
FROM ' . $table_name . ' cs | FROM ' . $table_name . ' cs | ||||
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . ' | LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . ' | ||||
WHERE (cs.Type = ' . DESTINATION_TYPE_STATE . ') AND (zd.TaxZoneId = ' . $object->GetID() . ')'; | WHERE (cs.Type = ' . DESTINATION_TYPE_STATE . ') AND (zd.TaxZoneId = ' . $object->GetID() . ')'; | ||||
$selected_country_id = $this->Conn->GetOne($sql); | $selected_country_id = $this->Conn->GetOne($sql); | ||||
if ($selected_country_id) { | if ($selected_country_id) { | ||||
$this->Application->SetVar('CountrySelector', $selected_country_id); | $this->Application->SetVar('CountrySelector', $selected_country_id); | ||||
} | } | ||||
else { | else { | ||||
list ($selected_country_id, ) = each($has_states); | $selected_country_id = key($has_states); | ||||
$this->Application->SetVar('CountrySelector', $selected_country_id); | $this->Application->SetVar('CountrySelector', $selected_country_id); | ||||
} | } | ||||
} | } | ||||
// gets only countries with states | // gets only countries with states | ||||
$sql = 'SELECT ' . $name_field . ', ' . $id_field . ' | $sql = 'SELECT ' . $name_field . ', ' . $id_field . ' | ||||
FROM ' . $table_name . ' | FROM ' . $table_name . ' | ||||
WHERE Type = ' . DESTINATION_TYPE_COUNTRY . ' AND ' . $id_field . ' IN (' . implode(',', array_keys($has_states)) . ') | WHERE Type = ' . DESTINATION_TYPE_COUNTRY . ' AND ' . $id_field . ' IN (' . implode(',', array_keys($has_states)) . ') | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | |||||
if ($object->IsTempTable()) { | if ($object->IsTempTable()) { | ||||
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $this->Prefix); | $table_name = $this->Application->GetTempName($table_name, 'prefix:' . $this->Prefix); | ||||
} | } | ||||
} | } | ||||
return $table_name; | return $table_name; | ||||
} | } | ||||
} | } | ||||
No newline at end of file |
Expected 1 spaces before "if" closing bracket; 0 found