<?php
/**
 @licence GPL 2005-2009  The osCSS developers - osCSS Open Source E-commerce
  @package oscss-2 <www http://www.oscss.org>
  @version Rc-3
  @date  07/04/10, 22:11
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
   @encode UTF-8
*/
?>
<!-- body //-->

<?php if($action=='list') { ?>
<h3><?php echo HEADING_TITLE; ?></h3>
<h4><?php echo HEADING_TITLE_COUNTRY_ZONE; ?></h4>
  <div class="button_nav">
    <?php echo '<a  class="button" href="' . tep_href_link(FILENAME_COUNTRIES, tep_get_all_get_params(array('page_admin')) . 'saction=new') . '">' . tep_image(DIR_WS_ICONS . 'icon_add_new.png',IMAGE_INSERT) . IMAGE_NEW_ZONE . '</a>'; ?>
    <?php echo '<a  class="button" href="' . tep_href_link(FILENAME_COUNTRIES, tep_get_all_get_params(array('rID','action','saction'))) . '">' .  IMAGE_BACK . '</a>'; ?>
  </div>

<div class="box_left">
  <table width="100%" class="dataTable">
    <thead>
      <tr>
        <th><?php echo TABLE_HEADING_COUNTRY_NAME.tep_link_sort_by(FILENAME_COUNTRIES,'c.countries_name'); ?></th>
        <th><?php echo TABLE_HEADING_ZONE_NAME.tep_link_sort_by(FILENAME_COUNTRIES,'z.zone_name'); ?></th>
        <th class="tcenter"><?php echo TABLE_HEADING_ZONE_CODE.tep_link_sort_by(FILENAME_COUNTRIES,'z.zone_code'); ?></th>
        <th class="tright" style="width:100px"><?php echo TABLE_HEADING_ACTION; ?></th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <td><?php echo $zones_split->display_count($zones_query_numrows, MAX_DISPLAY_ROW_BY_PAGE, $page, TEXT_DISPLAY_NUMBER_OF_ZONES); ?></td>
        <td><?php echo row_by_page(FILENAME_COUNTRIES, $row_bypage_array,  $row_by_page, "fleft"); ?></td>
        <td colspan="2"><?php echo $zones_split->display_links($zones_query_numrows, MAX_DISPLAY_ROW_BY_PAGE, MAX_DISPLAY_PAGE_LINKS, $page,tep_get_all_get_params(array('page', 'oID'))); ?></td>
      </tr>
    </tfoot>
    <tbody>
      <?php foreach($list_z as $zones) { ?>
        <tr class="view parent dataTableRow <?php if(( $rID ==$zones['zone_id'])) echo 'Selected' ?>" >
          <td><?php echo $zones['countries_name']; ?></td>
          <td><?php echo $zones['zone_name']; ?></td>
          <td class="tcenter"><?php echo $zones['zone_code']; ?></td>
          <td>
            <span class="view fils fleft">
              <?php  echo '<a class="buttonimg" href="' . tep_href_link(FILENAME_COUNTRIES, tep_get_all_get_params(array('page','rID')) .'rID=' . $zones['zone_id']. '&amp;saction=edit') . '">' .  tep_image(DIR_WS_ICONS . 'icon_edit.png',IMAGE_EDIT ) . '</a> <a  class="buttonimg" href="' . tep_href_link(FILENAME_COUNTRIES, tep_get_all_get_params(array('page','rID')). 'rID=' . $zones['zone_id'] . '&amp;saction=delete') . '">' . tep_image(DIR_WS_ICONS . 'icon_delete.png',IMAGE_DELETE ) . '</a>';
            ?>
            </span>
            <span class="fright">
              <?php if (isset($cInfo) && is_object($cInfo) && ($zones['zone_id'] == $cInfo->zone_id) ) { echo tep_image(DIR_WS_ICONS . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_COUNTRIES,tep_get_all_get_params(array('page','rID')). 'rID=' . $zones['zone_id']) . '">' . tep_image(DIR_WS_ICONS . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>
            </span>
          </td>
        </tr>
      <?php } ?>
    </tbody>
  </table>
</div>

<?php } else { ?>
<h3><?php echo HEADING_TITLE; ?></h3>
<h4><?php echo HEADING_TITLE_COUNTRY; ?></h4>
  <div class="button_nav">
    <?php echo '<a class="button" href="' . tep_href_link(FILENAME_COUNTRIES,tep_get_all_get_params(array('page_admin')). 'action=new') . '">' . tep_image(DIR_WS_ICONS.'icon_add_new.png' , IMAGE_NEW_COUNTRY) . IMAGE_NEW_COUNTRY . '</a>'; ?>
  </div>
<div class="box_uniq">
  <div class="box_left">
    <table width="100%" class="dataTable">
      <thead>
        <tr>
            <th><?php echo TABLE_HEADING_COUNTRY_NAME.tep_link_sort_by(FILENAME_COUNTRIES,'countries_name'); ?></th>
            <th><?php echo TABLE_HEADING_COUNTRY_LOCALNAME.tep_link_sort_by(FILENAME_COUNTRIES,'countries_localname' );  ?></th>
            <th style="width:40px"><?php echo TABLE_HEADING_COUNTRY_CODE_2.tep_link_sort_by(FILENAME_COUNTRIES,'countries_iso_code_2'); ?></th>
            <th style="width:40px"><?php echo TABLE_HEADING_COUNTRY_CODE_3.tep_link_sort_by(FILENAME_COUNTRIES,'countries_iso_code_3'); ?></th>
            <th><?php echo TABLE_HEADING_COUNTRY_VISIBLE.tep_link_sort_by(FILENAME_COUNTRIES,'country_visible');  ?></th>
            <th class="tright" style="width:100px"><?php echo TABLE_HEADING_ACTION; ?></th>
        </tr>
      </thead>
      <tfoot>
        <tr>
          <td colspan="1"><?php echo $countries_split->display_count($countries_query_numrows, MAX_DISPLAY_ROW_BY_PAGE, $page, TEXT_DISPLAY_NUMBER_OF_COUNTRIES); ?></td>
          <td colspan="3"><?php echo row_by_page(FILENAME_COUNTRIES, $row_bypage_array,  $row_by_page, "fleft"); ?></td>
          <td colspan="2"><?php echo $countries_split->display_links($countries_query_numrows, MAX_DISPLAY_ROW_BY_PAGE, MAX_DISPLAY_PAGE_LINKS,$page, tep_get_all_get_params(array('page_admin','page','cID'))); ?></td>
        </tr>
      </tfoot>
      <tbody>
        <?php foreach($list_c as $countries) { ?>
          <tr class="view parent dataTableRow <?php if(isset($cID) && $cID==$countries['countries_id']) echo 'Selected' ?>">
              <td class="tleft"><?php echo $countries['countries_name']; ?></td>
              <td class="tleft"><?php echo $countries['countries_localname']; ?></td>
              <td class="tcenter"><?php echo $countries['countries_iso_code_2']; ?></td>
              <td class="tcenter"><?php echo $countries['countries_iso_code_3']; ?></td>
              <td class="tcenter">
              <?php   if ($countries['country_visible'] == '1') echo  tep_image(DIR_WS_ICONS . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_COUNTRIES, 'action=update&amp;country_visible=0&amp;cID=' . $countries['countries_id'] . '&amp;page=' . $page) . '">' . tep_image(DIR_WS_ICONS . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT) . '</a>';
                      else echo '<a href="' . tep_href_link(FILENAME_COUNTRIES, 'action=update&amp;country_visible=1&amp;cID=' . $countries['countries_id'] . '&amp;page=' . $page) . '">' . tep_image(DIR_WS_ICONS . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT) . '</a>&nbsp;&nbsp;' . tep_image(DIR_WS_ICONS . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED); ?>
              </td>
              <td class="row_action">
                  <span class="view fils fleft">
                  <?php
                      echo '<a href="' . tep_href_link(FILENAME_COUNTRIES,  tep_get_all_get_params(array('action','cID')).'cID=' .$countries['countries_id'] . '&amp;action=list') . '">' . tep_image(DIR_WS_ICONS . 'icon_plus.gif', ICON_FOLDER) . '</a>';
                      echo '<a  class="buttonimg" href="' . tep_href_link(FILENAME_COUNTRIES, 'page=' . $page . '&amp;cID=' . $countries['countries_id'] . '&amp;row_by_page='.$row_by_page.'&amp;action=edit') . '">' . tep_image(DIR_WS_ICONS . 'icon_edit.png',IMAGE_EDIT ) . '</a> <a  class="buttonimg" href="' . tep_href_link(FILENAME_COUNTRIES, 'page=' . $page . '&amp;cID=' . $countries['countries_id'] .'&amp;row_by_page='.$row_by_page. '&amp;action=delete') . '">' .  tep_image(DIR_WS_ICONS . 'icon_delete.png',IMAGE_DELETE ) . '</a> ';
                  ?>
                  </span>
                  <span class="fright">
                  <?php   if (isset($cInfo) && is_object($cInfo) && ($countries['countries_id'] == $cInfo->countries_id) ) { echo tep_image(DIR_WS_ICONS . 'icon_arrow_right.gif', ''); }
                  else { echo '<a href="' . tep_href_link(FILENAME_COUNTRIES, 'page=' . $page . '&amp;cID=' . $countries['countries_id'].'&amp;row_by_page='.$row_by_page) . '">' . tep_image(DIR_WS_ICONS . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>
                  </span>
              </td>
          </tr>
        <?php } ?>
      </tbody>
    </table>
  </div>
<?php } ?>
<?php
  $heading = array();
  $contents = array();

if($action=='list'){
  switch ($saction) {
    case 'new':
      $heading[] = array('text' => TEXT_INFO_HEADING_NEW_ZONE );
      $contents = array('form' => tep_draw_form('zones', FILENAME_COUNTRIES, tep_get_all_get_params(array('saction')).'saction=insert'));
      $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
      $contents[] = array('class' => 'block_input', 'text' => TEXT_INFO_ZONES_NAME . tep_draw_input_field('zone_name'));
      $contents[] = array('class' => 'block_input', 'text' => TEXT_INFO_ZONES_CODE . tep_draw_input_field('zone_code'));
      $contents[] = array('class' => 'block_input', 'text' => TEXT_INFO_COUNTRY_NAME . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(), $cID));
      $contents[] = array('class' => 'button_nav', 'text' => tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' <a  class="button" href="' . tep_href_link(FILENAME_COUNTRIES, tep_get_all_get_params(array('page_admin','saction')) ) . '">' .  IMAGE_CANCEL . '</a>');
      break;
    case 'edit':
      $heading[] = array('text' => TEXT_INFO_HEADING_EDIT_ZONE );
      $contents = array('form' => tep_draw_form('zones', FILENAME_COUNTRIES, tep_get_all_get_params(array('saction','rID')).'rID=' . $cInfo->zone_id.'&amp;saction=save'));
      $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
      $contents[] = array('class' => 'block_input', 'text' => TEXT_INFO_ZONES_NAME . tep_draw_input_field('zone_name','', $cInfo->zone_name));
      $contents[] = array('class' => 'block_input', 'text' => TEXT_INFO_ZONES_CODE . tep_draw_input_field('zone_code','', $cInfo->zone_code));
      $contents[] = array('class' => 'block_input', 'text' => TEXT_INFO_COUNTRY_NAME . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(), $cInfo->countries_id));
      $contents[] = array('class' => 'button_nav', 'text' => tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a  class="button" href="' . tep_href_link(FILENAME_COUNTRIES, tep_get_all_get_params(array('saction')).'rID=' . $cInfo->zone_id) . '">' .  IMAGE_CANCEL . '</a>');
      break;
    case 'delete':
      $heading[] = array('text' => TEXT_INFO_HEADING_DELETE_ZONE );
      $contents = array('form' => tep_draw_form('zones', FILENAME_COUNTRIES, tep_get_all_get_params(array('saction','rID')).'rID=' . $cInfo->zone_id.'&amp;action=deleteconfirm'));
      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
      $contents[] = array('text' => '<strong>' . $cInfo->zone_name . '</strong>');
      $contents[] = array('class' => 'button_nav', 'text' => tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a  class="button" href="' . tep_href_link(FILENAME_COUNTRIES, tep_get_all_get_params(array('saction','rID')).'rID=' . $cInfo->zone_id) . '">' .  IMAGE_CANCEL . '</a>');
      break;
    default:
      if (isset($cInfo) && is_object($cInfo)) {
        $heading[] = array('text' => $cInfo->zone_name);
        $contents[] = array('text' => TEXT_INFO_ZONES_NAME . $cInfo->zone_name . ' (' . $cInfo->zone_code . ')');
        $contents[] = array('text' => TEXT_INFO_COUNTRY_NAME . $cInfo->countries_name);
      }
//     break;
  }
}else {

    if (isset($cInfo) && is_object($cInfo) && ($countries['countries_id'] == $cInfo->countries_id) ){
    $country_visible = ($cInfo->country_visible == '1') ? VISIBLE_YES : VISIBLE_NO;
    $country_visible_Y = ($cInfo->country_visible == '1') ? true : false;
    $country_visible_N = ($cInfo->country_visible == '0') ? true : false;
  } else {
      $country_visible = VISIBLE_YES ;
      $country_visible_Y =  true ;
      $country_visible_N =  false;
  }


  switch ($action) {
    case 'new':
      $heading[] = array('text' => TEXT_INFO_HEADING_NEW_COUNTRY );
      $contents = array('form' => tep_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $page .'&amp;row_by_page='.$row_by_page. '&amp;action=insert'));
      $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_NAME . tep_draw_input_field('countries_name'));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_LOCALNAME . tep_draw_input_field('countries_localname'));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_CODE_2 . tep_draw_input_field('countries_iso_code_2'));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_CODE_3 . tep_draw_input_field('countries_iso_code_3'));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_ADDRESS_FORMAT . tep_draw_pull_down_menu('address_format_id', tep_get_address_formats()));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_VISIBLE . tep_draw_radio_field('country_visible', 'country_visible_1', '1', $country_visible_Y) . '&nbsp;&nbsp;' . VISIBLE_YES . '&nbsp;&nbsp;' . tep_draw_radio_field('country_visible', 'country_visible_0', '0', $country_visible_N) . '&nbsp;&nbsp;' . VISIBLE_NO);
      $contents[] = array('class' => 'button_nav', 'text' => tep_image_submit('button_insert.gif', IMAGE_INSERT) . '&nbsp;<a  class="button" href="' . tep_href_link(FILENAME_COUNTRIES, tep_get_all_get_params(array('page_admin', 'action'))) . '">' .  IMAGE_CANCEL . '</a>');
      break;
    case 'edit':
      $heading[] = array('text' => TEXT_INFO_HEADING_EDIT_COUNTRY );
      $contents = array('form' => tep_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $page . '&amp;cID=' . $cInfo->countries_id .'&amp;row_by_page='.$row_by_page. '&amp;action=save'));
      $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_NAME . tep_draw_input_field('countries_name', '', $cInfo->countries_name));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_LOCALNAME . tep_draw_input_field('countries_localname', '', $cInfo->countries_localname));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_CODE_2 . tep_draw_input_field('countries_iso_code_2', '', $cInfo->countries_iso_code_2));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_CODE_3 . tep_draw_input_field('countries_iso_code_3', '', $cInfo->countries_iso_code_3));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_ADDRESS_FORMAT . tep_draw_pull_down_menu('address_format_id', tep_get_address_formats(), $cInfo->address_format_id));
      $contents[] = array('class' => 'block_input','text' => TEXT_INFO_COUNTRY_VISIBLE . tep_draw_radio_field('country_visible', 'country_visible_1', '1', $country_visible_Y) . '&nbsp;&nbsp;' . VISIBLE_YES . '&nbsp;&nbsp;' . tep_draw_radio_field('country_visible', 'country_visible_0', '0', $country_visible_N) . '&nbsp;&nbsp;' . VISIBLE_NO);
      $contents[] = array('class' => 'button_nav','text' => tep_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a  class="button" href="' . tep_href_link(FILENAME_COUNTRIES, 'page=' . $page . '&amp;cID=' . $cInfo->countries_id .'&amp;row_by_page='.$row_by_page) . '">' . IMAGE_CANCEL . '</a>');
      break;
    case 'delete':
      $heading[] = array('text' => TEXT_INFO_HEADING_DELETE_COUNTRY );
      $contents = array('form' => tep_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $page . '&amp;cID=' . $cInfo->countries_id .'&amp;row_by_page='.$row_by_page. '&amp;action=deleteconfirm'));
      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
      $contents[] = array('text' => '<strong>' . $cInfo->countries_name . '</strong>');
      $contents[] = array('class' => 'button_nav','text' => tep_image_submit('button_delete.gif', IMAGE_UPDATE) . '&nbsp;<a  class="button" href="' . tep_href_link(FILENAME_COUNTRIES, 'page=' . $page . '&amp;cID=' . $cInfo->countries_id) . '">' . IMAGE_CANCEL . '</a>');
      break;

    default:
      if (isset($cInfo) && is_object($cInfo)) {
        $heading[] = array('text' => $cInfo->countries_name );
        $contents[] = array('text' => TEXT_INFO_COUNTRY_NAME . $cInfo->countries_name);
        $contents[] = array('text' => TEXT_INFO_COUNTRY_LOCALNAME . $cInfo->countries_localname);
        $contents[] = array('text' => TEXT_INFO_COUNTRY_CODE_2 . $cInfo->countries_iso_code_2);
        $contents[] = array('text' => TEXT_INFO_COUNTRY_CODE_3 . $cInfo->countries_iso_code_3);
        $contents[] = array('text' => TEXT_INFO_ADDRESS_FORMAT . $cInfo->address_format_id);
        $contents[] = array('text' => TEXT_INFO_COUNTRY_VISIBLE . $country_visible);
      }
      break;
  }
  }
?>
<div class="box_right">
<?php
  if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
    $box = new box;
    echo $box->infoBox($heading, $contents);
  }
?>
</div>
</div>