';
$ret .= $hidden;
}
return $ret;
}
*/
function ShowCountries($param){
$param = $this->prepareTagParams($param);
$param['name'] = $param['block'];
$destination = &$this->Application->recallObject('dst');
$zone = &$this->Application->recallObject('z');
$selected_country = Array(); // this prevents 241 warnings to me raised :D
switch ($param['show']){
case 'current':
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=1
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND zd.ShippingZoneId='.$zone->GetDBField('ZoneID').'
ORDER BY Translation
';
break;
case 'available':
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=1
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND zd.ShippingZoneId IS NULL
ORDER BY Translation
';
break;
case 'all':
$selected_country = $this->Application->GetVar('CountrySelector');
if (!$selected_country){
// get 1st available country ID
$selected_country = $this->Conn->GetOne('SELECT StdDestId FROM '.$destination->TableName.'
WHERE ShippingZoneId='.$zone->GetDBField('ZoneID'));
if ($selected_country){
$this->Application->SetVar('CountrySelector', $selected_country);
}
}
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=1
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
ORDER BY Translation
';
break;
case 'has_states':
$has_states = $this->Conn->GetCol('SELECT DISTINCT DestParentId FROM '.TABLE_PREFIX.'StdDestinations sd
WHERE sd.DestType=2');
$selected_country = $this->Application->GetVar('CountrySelector');
if ($selected_country && !in_array($selected_country, $has_states)){
$selected_country = $has_states[0];
$this->Application->SetVar('CountrySelector', $selected_country);
}
if (!$selected_country){
// get 1st available country ID
$selected_country = $this->Conn->GetOne('SELECT DestParentId FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
WHERE sd.DestType=2
AND zd.ShippingZoneId='.$zone->GetDBField('ZoneID'));
if ($selected_country){
$this->Application->SetVar('CountrySelector', $selected_country);
}
else {
$selected_country = $has_states[0];
$this->Application->SetVar('CountrySelector', $selected_country);
}
}
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=1
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND DestId IN ('.implode(',', $has_states).')
ORDER BY Translation
';
break;
}
$countries = $this->Conn->Query($sql);
$o = '';
foreach($countries as $key => $country) {
$param['id'] = $country['DestId'];
$param['destination_title'] = $this->Application->Phrase($country['DestName']);
if ($selected_country && $selected_country == $param['id']){
$param['selected'] = ' selected="selected"';
}
else {
$param['selected']='';
}
$o .= $this->Application->ParseBlock($param);
}
return $o;
}
function ShowStates($param){
$param = $this->prepareTagParams($param);
$param['name'] = $param['block'];
$destination = &$this->Application->recallObject('dst');
$zone = &$this->Application->recallObject('z');
switch ($param['show']){
case 'current':
$sql = 'SELECT * FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=2
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND sd.DestParentId='.$this->Application->GetVar('CountrySelector').'
AND zd.ShippingZoneId='.$zone->GetDBField('ZoneID').'
ORDER BY Translation
';
break;
case 'available':
$sql = 'SELECT * FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=2
AND zd.ShippingZoneId IS NULL
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND sd.DestParentId='.$this->Application->GetVar('CountrySelector').'
ORDER BY Translation
';
break;
case 'all':
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=2
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND sd.DestParentId='.$this->Application->GetVar('CountrySelector').'
ORDER BY Translations
';
break;
}
$states = $this->Conn->Query($sql);
$o = '';
foreach($states as $key => $state) {
$param['id'] = $state['DestId'];
$param['destination_title'] = $this->Application->Phrase($state['DestName']);
$o .= $this->Application->ParseBlock($param);
}
return $o;
}
function ShowZips($param){
$param = $this->prepareTagParams($param);
$param['name'] = $param['block'];
$destination = &$this->Application->recallObject('dst');
$zone = &$this->Application->recallObject('z');
$country_selector = $this->Application->GetVar('CountrySelector');
if (!$country_selector){
$country_selector=0;
}
switch ($param['show']){
case 'current':
$sql = 'SELECT * FROM '.$destination->TableName.'
WHERE NOT(DestValue IS NULL)
AND DestValue<>""
AND ShippingZoneID='.$zone->GetDBField('ZoneID').'
ORDER BY DestValue
';
break;
case 'available':
$selected_zips = $this->Conn->GetCol('SELECT DestValue FROM '.$destination->TableName.'
WHERE NOT(DestValue IS NULL)
AND DestValue<>""
AND ShippingZoneID='.$zone->GetDBField('ZoneID').'
ORDER BY DestValue
');
$sql = 'SELECT DISTINCT(DestValue) FROM '.$this->Application->getUnitOption('dst', 'TableName').'
WHERE NOT(DestValue IS NULL)
AND ShippingZoneID!='.$zone->GetDBField('ZoneID').'
AND DestValue NOT IN ("'.implode('", "', $selected_zips).'")
AND DestValue<>"" AND StdDestId='.$country_selector.'
ORDER BY DestValue
';
break;
case 'all':
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
WHERE sd.DestType=3 AND sd.DestParentId='.$country_selector.'
ORDER BY DestValue
';
break;
}
$zips = $this->Conn->Query($sql);
$o = '';
foreach($zips as $key => $zip) {
$param['id'] = $zip['DestId'].'|'.$zip['DestValue'];
$param['destination_title'] = $zip['DestValue'];
$o .= $this->Application->ParseBlock($param);
}
return $o;
}
}