Execute("insert into " . TABLE_ZONES_TO_GEO_ZONES . " (zone_country_id, zone_id, geo_zone_id, date_added) values ('" . (int)$zone_country_id . "', '" . (int)$zone_id . "', '" . (int)$zID . "', now())"); $new_subzone_id = $db->Insert_ID(); // zen_redirect(zen_href_link(FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'] . '&sID=' . $new_subzone_id)); zen_redirect(zen_href_link(FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list' . '&sID=' . $new_subzone_id)); break; case 'save_sub': $sID = zen_db_prepare_input($_GET['sID']); $zID = zen_db_prepare_input($_GET['zID']); $zone_country_id = zen_db_prepare_input($_POST['zone_country_id']); $zone_id = zen_db_prepare_input($_POST['zone_id']); $db->Execute("update " . TABLE_ZONES_TO_GEO_ZONES . " set geo_zone_id = '" . (int)$zID . "', zone_country_id = '" . (int)$zone_country_id . "', zone_id = " . (zen_not_null($zone_id) ? "'" . (int)$zone_id . "'" : 'null') . ", last_modified = now() where association_id = '" . (int)$sID . "'"); zen_redirect(zen_href_link(FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'] . '&sID=' . $_GET['sID'])); break; case 'deleteconfirm_sub': // demo active test if (zen_admin_demo()) { $_GET['action']= ''; $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution'); zen_redirect(zen_href_link(FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'])); } $sID = zen_db_prepare_input($_GET['sID']); $db->Execute("delete from " . TABLE_ZONES_TO_GEO_ZONES . " where association_id = '" . (int)$sID . "'"); zen_redirect(zen_href_link(FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'])); break; } } $action = (isset($_GET['action']) ? $_GET['action'] : ''); if (zen_not_null($action)) { switch ($action) { case 'insert_zone': $geo_zone_name = zen_db_prepare_input($_POST['geo_zone_name']); $geo_zone_description = zen_db_prepare_input($_POST['geo_zone_description']); $db->Execute("insert into " . TABLE_GEO_ZONES . " (geo_zone_name, geo_zone_description, date_added) values ('" . zen_db_input($geo_zone_name) . "', '" . zen_db_input($geo_zone_description) . "', now())"); $new_zone_id = $db->Insert_ID(); zen_redirect(zen_href_link(FILENAME_GEO_ZONES, 'zID=' . $new_zone_id)); break; case 'save_zone': $zID = zen_db_prepare_input($_GET['zID']); $geo_zone_name = zen_db_prepare_input($_POST['geo_zone_name']); $geo_zone_description = zen_db_prepare_input($_POST['geo_zone_description']); $db->Execute("update " . TABLE_GEO_ZONES . " set geo_zone_name = '" . zen_db_input($geo_zone_name) . "', geo_zone_description = '" . zen_db_input($geo_zone_description) . "', last_modified = now() where geo_zone_id = '" . (int)$zID . "'"); zen_redirect(zen_href_link(FILENAME_GEO_ZONES, 'zID=' . $_GET['zID'])); break; case 'deleteconfirm_zone': // demo active test if (zen_admin_demo()) { $_GET['action']= ''; $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution'); zen_redirect(zen_href_link(FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'])); } $zID = zen_db_prepare_input($_GET['zID']); $check_tax_rates = $db->Execute("select tax_zone_id from " . TABLE_TAX_RATES . " where tax_zone_id='" . $zID . "'"); if ($check_tax_rates->RecordCount() > 0) { $_GET['action']= ''; $messageStack->add_session(ERROR_TAX_RATE_EXISTS, 'caution'); } else { $db->Execute("delete from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$zID . "'"); $db->Execute("delete from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)$zID . "'"); } zen_redirect(zen_href_link(FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'])); break; } } ?> > <?php echo TITLE; ?>
' . zen_get_geo_zone_name($_GET['zone']) . ''; ?>
'' . TEXT_INFO_HEADING_NEW_SUB_ZONE . ''); $contents = array('form' => zen_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'] . '&' . (isset($_GET['sID']) ? 'sID=' . $_GET['sID'] . '&' : '') . 'saction=insert_sub')); $contents[] = array('text' => TEXT_INFO_NEW_SUB_ZONE_INTRO); $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY . '
' . zen_draw_pull_down_menu('zone_country_id', zen_get_countries(TEXT_ALL_COUNTRIES), '', 'onChange="update_zone(this.form);"')); $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_ZONE . '
' . zen_draw_pull_down_menu('zone_id', zen_prepare_country_zones_pull_down())); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_insert.gif', IMAGE_INSERT) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; case 'edit': $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_SUB_ZONE . ''); $contents = array('form' => zen_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'] . '&sID=' . $sInfo->association_id . '&saction=save_sub')); $contents[] = array('text' => TEXT_INFO_EDIT_SUB_ZONE_INTRO); $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY . '
' . zen_draw_pull_down_menu('zone_country_id', zen_get_countries(TEXT_ALL_COUNTRIES), $sInfo->zone_country_id, 'onChange="update_zone(this.form);"')); $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_ZONE . '
' . zen_draw_pull_down_menu('zone_id', zen_prepare_country_zones_pull_down($sInfo->zone_country_id), $sInfo->zone_id)); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; case 'delete': $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_SUB_ZONE . ''); $contents = array('form' => zen_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'] . '&sID=' . $sInfo->association_id . '&saction=deleteconfirm_sub')); $contents[] = array('text' => TEXT_INFO_DELETE_SUB_ZONE_INTRO); $contents[] = array('text' => '
' . $sInfo->countries_name . ''); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; default: if (isset($sInfo) && is_object($sInfo)) { $heading[] = array('text' => '' . $sInfo->countries_name . ''); $contents[] = array('align' => 'center', 'text' => '' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '' . zen_image_button('button_delete.gif', IMAGE_DELETE) . ''); $contents[] = array('text' => '
' . TEXT_INFO_DATE_ADDED . ' ' . zen_date_short($sInfo->date_added)); if (zen_not_null($sInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . zen_date_short($sInfo->last_modified)); } break; } } else { switch ($action) { case 'new_zone': $heading[] = array('text' => '' . TEXT_INFO_HEADING_NEW_ZONE . ''); $contents = array('form' => zen_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=insert_zone')); $contents[] = array('text' => TEXT_INFO_NEW_ZONE_INTRO); $contents[] = array('text' => '
' . TEXT_INFO_ZONE_NAME . '
' . zen_draw_input_field('geo_zone_name', '', zen_set_field_length(TABLE_GEO_ZONES, 'geo_zone_name'))); $contents[] = array('text' => '
' . TEXT_INFO_ZONE_DESCRIPTION . '
' . zen_draw_input_field('geo_zone_description', '', zen_set_field_length(TABLE_GEO_ZONES, 'geo_zone_description'))); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_insert.gif', IMAGE_INSERT) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; case 'edit_zone': $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_ZONE . ''); $contents = array('form' => zen_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $zInfo->geo_zone_id . '&action=save_zone')); $contents[] = array('text' => TEXT_INFO_EDIT_ZONE_INTRO); $contents[] = array('text' => '
' . TEXT_INFO_ZONE_NAME . '
' . zen_draw_input_field('geo_zone_name', $zInfo->geo_zone_name, zen_set_field_length(TABLE_GEO_ZONES, 'geo_zone_name'))); $contents[] = array('text' => '
' . TEXT_INFO_ZONE_DESCRIPTION . '
' . zen_draw_input_field('geo_zone_description', $zInfo->geo_zone_description, zen_set_field_length(TABLE_GEO_ZONES, 'geo_zone_description'))); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; case 'delete_zone': $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_ZONE . ''); $contents = array('form' => zen_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $_GET['zpage'] . '&zID=' . $zInfo->geo_zone_id . '&action=deleteconfirm_zone')); $contents[] = array('text' => TEXT_INFO_DELETE_ZONE_INTRO); $contents[] = array('text' => '
' . $zInfo->geo_zone_name . ''); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; default: if (isset($zInfo) && is_object($zInfo)) { $heading[] = array('text' => '' . $zInfo->geo_zone_name . ''); $contents[] = array('align' => 'center', 'text' => '' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '' . ' ' . zen_image_button('button_details.gif', IMAGE_DETAILS) . ''); $contents[] = array('align' => 'center', 'text' => ($zInfo->num_tax_rates > 0 ? '' . zen_image_button('button_tax_rates.gif', IMAGE_TAX_RATES) . '' : '')); $contents[] = array('text' => '
' . TEXT_INFO_NUMBER_ZONES . ' ' . $zInfo->num_zones); $contents[] = array('text' => '
' . TEXT_INFO_NUMBER_TAX_RATES . ' ' . $zInfo->num_tax_rates); $contents[] = array('text' => '
' . TEXT_INFO_DATE_ADDED . ' ' . zen_date_short($zInfo->date_added)); if (zen_not_null($zInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . zen_date_short($zInfo->last_modified)); $contents[] = array('text' => '
' . TEXT_INFO_ZONE_DESCRIPTION . '
' . $zInfo->geo_zone_description); } break; } } if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) { echo ' ' . "\n"; } ?>
Execute($zones_query_raw); $check_count=1; if ($check_page->RecordCount() > MAX_DISPLAY_SEARCH_RESULTS) { while (!$check_page->EOF) { if ($check_page->fields['association_id'] == $_GET['sID']) { break; } $check_count++; $check_page->MoveNext(); } $_GET['spage'] = round((($check_count/MAX_DISPLAY_SEARCH_RESULTS)+(fmod_round($check_count,MAX_DISPLAY_SEARCH_RESULTS) !=0 ? .5 : 0)),0); } else { $_GET['spage'] = 1; } } $rows = 0; // $zones_query_raw = "select a.association_id, a.zone_country_id, c.countries_name, a.zone_id, a.geo_zone_id, a.last_modified, a.date_added, z.zone_name from (" . TABLE_ZONES_TO_GEO_ZONES . " a left join " . TABLE_COUNTRIES . " c on a.zone_country_id = c.countries_id left join " . TABLE_ZONES . " z on a.zone_id = z.zone_id) where a.geo_zone_id = " . $_GET['zID'] . " order by association_id"; $zones_query_raw = "select a.association_id, a.zone_country_id, c.countries_name, a.zone_id, a.geo_zone_id, a.last_modified, a.date_added, z.zone_name from (" . TABLE_ZONES_TO_GEO_ZONES . " a left join " . TABLE_COUNTRIES . " c on a.zone_country_id = c.countries_id left join " . TABLE_ZONES . " z on a.zone_id = z.zone_id) where a.geo_zone_id = " . $_GET['zID'] . " order by c.countries_name, association_id"; $zones_split = new splitPageResults($_GET['spage'], MAX_DISPLAY_SEARCH_RESULTS, $zones_query_raw, $zones_query_numrows); $zones = $db->Execute($zones_query_raw); while (!$zones->EOF) { $rows++; if ((!isset($_GET['sID']) || (isset($_GET['sID']) && ($_GET['sID'] == $zones->fields['association_id']))) && !isset($sInfo) && (substr($action, 0, 3) != 'new')) { $sInfo = new objectInfo($zones->fields); } if (isset($sInfo) && is_object($sInfo) && ($zones->fields['association_id'] == $sInfo->association_id)) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?> MoveNext(); } ?>
 
fields['countries_name']) ? $zones->fields['countries_name'] : TEXT_ALL_COUNTRIES); ?> fields['zone_id']) ? $zones->fields['zone_name'] : PLEASE_SELECT); ?> fields['association_id'] == $sInfo->association_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
display_count($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['spage'], TEXT_DISPLAY_NUMBER_OF_COUNTRIES); ?> display_links($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['spage'], 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list', 'spage'); ?>
' . zen_image_button('button_back.gif', IMAGE_BACK) . ' ' . zen_image_button('button_insert.gif', IMAGE_INSERT) . ''; ?>
             
Execute($zones_query_raw); $check_count=1; if ($check_page->RecordCount() > MAX_DISPLAY_SEARCH_RESULTS) { while (!$check_page->EOF) { if ($check_page->fields['geo_zone_id'] == $_GET['zID']) { break; } $check_count++; $check_page->MoveNext(); } $_GET['zpage'] = round((($check_count/MAX_DISPLAY_SEARCH_RESULTS)+(fmod_round($check_count,MAX_DISPLAY_SEARCH_RESULTS) !=0 ? .5 : 0)),0); } else { $_GET['zpage'] = 1; } } $zones_query_raw = "select geo_zone_id, geo_zone_name, geo_zone_description, last_modified, date_added from " . TABLE_GEO_ZONES . " order by geo_zone_name"; $zones_split = new splitPageResults($_GET['zpage'], MAX_DISPLAY_SEARCH_RESULTS, $zones_query_raw, $zones_query_numrows); $zones = $db->Execute($zones_query_raw); while (!$zones->EOF) { $num_zones = $db->Execute("select count(*) as num_zones from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)$zones->fields['geo_zone_id'] . "' group by geo_zone_id"); if ($num_zones->fields['num_zones'] > 0) { $zones->fields['num_zones'] = $num_zones->fields['num_zones']; } else { $zones->fields['num_zones'] = 0; } $num_tax_rates = $db->Execute("select count(*) as num_tax_rates from " . TABLE_TAX_RATES . " where tax_zone_id = '" . (int)$zones->fields['geo_zone_id'] . "' group by tax_zone_id"); if ($num_tax_rates->fields['num_tax_rates'] > 0) { $zones->fields['num_tax_rates'] = $num_tax_rates->fields['num_tax_rates']; } else { $zones->fields['num_tax_rates'] = 0; } if ((!isset($_GET['zID']) || (isset($_GET['zID']) && ($_GET['zID'] == $zones->fields['geo_zone_id']))) && !isset($zInfo) && (substr($action, 0, 3) != 'new')) { $zInfo = new objectInfo($zones->fields); } if (isset($zInfo) && is_object($zInfo) && ($zones->fields['geo_zone_id'] == $zInfo->geo_zone_id)) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?> MoveNext(); } ?>
 
fields['geo_zone_id'] . '&action=list') . '">' . zen_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . ' ' . $zones->fields['geo_zone_name']; ?> fields['geo_zone_description']; ?> fields['num_tax_rates'] && $zones->fields['num_zones']) { echo zen_image(DIR_WS_IMAGES . 'icon_status_green.gif'); } elseif ($zones->fields['num_zones']) { echo zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif'); } else { echo zen_image(DIR_WS_IMAGES . 'icon_status_red.gif'); } ?> fields['geo_zone_id'] == $zInfo->geo_zone_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
display_count($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['zpage'], TEXT_DISPLAY_NUMBER_OF_TAX_ZONES); ?> display_links($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['zpage'], '', 'zpage'); ?>
geo_zone_id . '&action=new_zone') . '">' . zen_image_button('button_insert.gif', IMAGE_INSERT) . ''; ?>
' . "\n"; $box = new box; echo $box->infoBox($heading, $contents); echo '