<?php
    $heading = array();
    $contents = array();
    switch ($action) {
      case 'new_category':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_NEW_CATEGORY . '</b>');
        $contents = array('form' => go_fetch_form('newcategory', NAME_OF_FILE_CATEGORIES, 'action=insert_category&bigPfad=' . $bigPfad, 'post', 'enctype="multipart/form-data"'));
        $contents[] = array('text' => TEXT_NEW_CATEGORY_INTRO);
        $category_inputs_string = '';
        $category_desc_string = '';
        $languages = go_get_languages();
        for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
          $category_inputs_string .= '<br>' . go_picture(FOLDER_RELATIV_LANG_TEMPLATES . $languages[$i]['directory'] . '/picture/' . $languages[$i]['picture'], $languages[$i]['name']) . '&nbsp;' . go_fetch_inputfeld('categories_name[' . $languages[$i]['id'] . ']');
          $zeigen = '<textarea class="mce" name="categories_desc' . $languages[$i]['id'].'"></textarea></br>';
          $category_desc_string .= '<table><tr><td><br><br>' . go_picture(FOLDER_RELATIV_LANG_TEMPLATES . $languages[$i]['directory'] . '/picture/' . $languages[$i]['picture'], $languages[$i]['name']) . '&nbsp;</td><td>' . $zeigen . '</td></tr></table>'; 
        }
        $contents[] = array('text' => '<br>' . TEXT_CATEGORIES_NAME . $category_inputs_string);       
        $contents[] = array('text' => '<br>' . TEXT_CATEGORIES_NAME . $category_desc_string);        
        $zeigen2 = '<textarea class="mceimg" name="categories_picture"></textarea></br>';
        $contents[] = array('text' => '<br>' . TEXT_CATEGORIES_PICTURE . '<br>' . $zeigen2);
        $contents[] = array('text' => '<br>' . TEXT_SORT_ORDER . '<br>' . go_fetch_inputfeld('sort_order', '', 'size="2"'));
        $contents[] = array('text' => '<br>' . TEXT_CHANGE_STATUS . '<br>' . go_fetch_inputfeld('categories_status', '1', 'size="2"') . '1=Sichtbar 0=Unsichtbar');
        $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_save.gif', PICTURE_SAVE) . ' <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        break;
      case 'change_category':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_CHANGE_CATEGORY . '</b>');
        $contents = array('form' => go_fetch_form('categories', NAME_OF_FILE_CATEGORIES, 'action=update_category&bigPfad=' . $bigPfad, 'post', 'enctype="multipart/form-data"') . go_fetch_hidden_field('categories_id', $bigwareInfo->categories_id));
        $contents[] = array('text' => TEXT_CHANGE_INTRO);
        $category_inputs_string = '';
        $category_desc_string = '';
        $languages = go_get_languages();
        for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
          $category_inputs_string .= '<br>' . go_picture(FOLDER_RELATIV_LANG_TEMPLATES . $languages[$i]['directory'] . '/picture/' . $languages[$i]['picture'], $languages[$i]['name']) . '&nbsp;' . go_fetch_inputfeld('categories_name[' . $languages[$i]['id'] . ']', go_get_category_name($bigwareInfo->categories_id, $languages[$i]['id'])); 
          $zeigen = '<textarea class="mce" name="categories_desc' . $languages[$i]['id'].'">'.stripslashes(go_get_category_desc($bigwareInfo->categories_id, $languages[$i]['id'])).'</textarea>';
          $category_desc_string .= '<table><tr><td><br><br>' . go_picture(FOLDER_RELATIV_LANG_TEMPLATES . $languages[$i]['directory'] . '/picture/' . $languages[$i]['picture'], $languages[$i]['name']) . '&nbsp;</td><td>' . $zeigen . '</td></tr></table>';
        }
        $contents[] = array('text' => '<br>' . TEXT_CHANGE_CATEGORIES_NAME . $category_inputs_string);
        $contents[] = array('text' => '<br>' . TEXT_CHANGE_CATEGORIES_DESC . $category_desc_string);
        $contents[] = array('text' => '<br>' . go_info_picture($bigwareInfo->categories_picture, $bigwareInfo->categories_name, ABOVE_PICTURE_WIDTH, ABOVE_PICTURE_HEIGHT) . '<br>' . FOLDER_RELATIV_CATALOG_PICTURES . '<br><b>' . $bigwareInfo->categories_picture . '</b>'); 
	$categories_picture = $bigwareInfo->categories_picture;
	if ($categories_picture != ""){
		$categories_picture = '<IMG src="' . FOLDER_RELATIV_CATALOG_PICTURES . $categories_picture . '">';
	}
        $zeigen2 = '<textarea class="mceimg" name="categories_picture">'.stripslashes($categories_picture).'</textarea></br>';
        $contents[] = array('text' => '<br>' . TEXT_CHANGE_CATEGORIES_PICTURE . '<br>' . $zeigen2);
        $contents[] = array('text' => '<br>' . TEXT_CHANGE_SORT_ORDER . '<br>' . go_fetch_inputfeld('sort_order', $bigwareInfo->sort_order, 'size="2"')); 
        $contents[] = array('text' => '<br>' . TEXT_CHANGE_STATUS . '<br>' . go_fetch_inputfeld('categories_status', $bigwareInfo->categories_status, 'size="2"') . '1=Sichtbar 0=Unsichtbar');
				$contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_save.gif', PICTURE_SAVE) . ' <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $bigwareInfo->categories_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        break;
      case 'delete_category':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_DELETE_CATEGORY . '</b>');
        $contents = array('form' => go_fetch_form('categories', NAME_OF_FILE_CATEGORIES, 'action=delete_category_confirm&bigPfad=' . $bigPfad) . go_fetch_hidden_field('categories_id', $bigwareInfo->categories_id));
        $contents[] = array('text' => TEXT_DELETE_CATEGORY_INTRO);
        $contents[] = array('text' => '<br><b>' . $bigwareInfo->categories_name . '</b>');
        if ($bigwareInfo->childs_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_CHILDS, $bigwareInfo->childs_count));
        if ($bigwareInfo->items_count < 500){
        if ($bigwareInfo->items_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_ITEMS, $bigwareInfo->items_count));
        $contents[] = array('align' => 'center', 'text' => '<br>'. go_picture_submit('button_delete.gif', PICTURE_DELETE) . ' <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $bigwareInfo->categories_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
	}
        else{
        if ($bigwareInfo->items_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_ZU_VIEL_ITEMS, $bigwareInfo->items_count));
        $contents[] = array('align' => 'center', 'text' => '<br> <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $bigwareInfo->categories_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        }
        break; 
      case 'neu_im_category':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_NEU_IM . '</b>');
        $contents = array('form' => go_fetch_form('categories', NAME_OF_FILE_CATEGORIES, 'action=neu_im_category_confirm&bigPfad=' . $bigPfad) . go_fetch_hidden_field('categories_id', $bigwareInfo->categories_id));
        $contents[] = array('text' => sprintf(TEXT_NEUE_PRODUKTE_INTRO, $bigwareInfo->categories_name));
        $contents[] = array('text' => '<br><b>' . $bigwareInfo->categories_name . '</b>');
        $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_save.gif', PICTURE_MOVE) . ' <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $bigwareInfo->categories_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        break;
      case 'move_category':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_MOVE_CATEGORY . '</b>');
        $contents = array('form' => go_fetch_form('categories', NAME_OF_FILE_CATEGORIES, 'action=move_category_confirm&bigPfad=' . $bigPfad) . go_fetch_hidden_field('categories_id', $bigwareInfo->categories_id));
        $contents[] = array('text' => sprintf(TEXT_MOVE_CATEGORIES_INTRO, $bigwareInfo->categories_name));
        $contents[] = array('text' => '<br>' . sprintf(TEXT_MOVE, $bigwareInfo->categories_name) . '<br>' . go_fetch_pull_down_menu('move_to_category_id', go_get_category_tree(), $current_category_id));
        $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_move.gif', PICTURE_MOVE) . ' <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $bigwareInfo->categories_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        break;
      case 'delete_item':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_DELETE_ITEM . '</b>');
        $contents = array('form' => go_fetch_form('items', NAME_OF_FILE_ALL_ITEMS_LIST, 'action=delete_item_confirm&bigPfad=' . $bigPfad) . go_fetch_hidden_field('items_id', $pInfo->items_id));
        $contents[] = array('text' => TEXT_DELETE_ITEM_INTRO);
        $contents[] = array('text' => '<br><b>' . $pInfo->items_name . '</b>');
        $item_categories_string = '';
        $item_categories = go_generate_category_path($pInfo->items_id, 'item');
        for ($i = 0, $n = sizeof($item_categories); $i < $n; $i++) {
          $category_path = '';
          for ($j = 0, $k = sizeof($item_categories[$i]); $j < $k; $j++) {
            $category_path .= $item_categories[$i][$j]['text'] . '&nbsp;&gt;&nbsp;';
          }
          $category_path = substr($category_path, 0, -16);
          $item_categories_string .= go_fetch_checkbox_field('item_categories[]', $item_categories[$i][sizeof($item_categories[$i])-1]['id'], true) . '&nbsp;' . $category_path . '<br>';
        }
        $item_categories_string = substr($item_categories_string, 0, -4);
        $contents[] = array('text' => '<br>' . $item_categories_string);
        $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_delete.gif', PICTURE_DELETE) . ' <a href="' . go_href_link(NAME_OF_FILE_ALL_ITEMS_LIST, 'bigPfad=' . $bigPfad . '&bigID=' . $pInfo->items_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        break; 
      case 'neues_item':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_NEUES_ITEM . '</b>');
        $contents = array('form' => go_fetch_form('items', NAME_OF_FILE_CATEGORIES, 'action=neues_item_confirm&bigPfad=' . $bigPfad) . go_fetch_hidden_field('items_id', $pInfo->items_id));
        $contents[] = array('text' => TEXT_NEU_ITEM_INTRO);
        $contents[] = array('text' => '<br><b>' . $pInfo->items_name . '</b>');
        $item_categories_string = '';
        $item_categories = go_generate_category_path($pInfo->items_id, 'item');
        for ($i = 0, $n = sizeof($item_categories); $i < $n; $i++) {
          $category_path = '';
          for ($j = 0, $k = sizeof($item_categories[$i]); $j < $k; $j++) {
            $category_path .= $item_categories[$i][$j]['text'] . '&nbsp;&gt;&nbsp;';
          }
          $category_path = substr($category_path, 0, -16);
          $item_categories_string .= go_fetch_checkbox_field('item_categories[]', $item_categories[$i][sizeof($item_categories[$i])-1]['id'], true) . '&nbsp;' . $category_path . '<br>';
        }
        $item_categories_string = substr($item_categories_string, 0, -4);
        $contents[] = array('text' => '<br>' . $item_categories_string);
        $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_save.gif', PICTURE_DELETE) . ' <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $pInfo->items_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        break;
      case 'move_item':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_MOVE_ITEM . '</b>');
        $contents = array('form' => go_fetch_form('items', NAME_OF_FILE_CATEGORIES, 'action=move_item_confirm&bigPfad=' . $bigPfad) . go_fetch_hidden_field('items_id', $pInfo->items_id));
        $contents[] = array('text' => sprintf(TEXT_MOVE_ITEMS_INTRO, $pInfo->items_name));
        $contents[] = array('text' => '<br>' . TEXT_INFO_CURRENT_CATEGORIES . '<br><b>' . go_output_generated_category_path($pInfo->items_id, 'item') . '</b>');
        $contents[] = array('text' => '<br>' . sprintf(TEXT_MOVE, $pInfo->items_name) . '<br>' . go_fetch_pull_down_menu('move_to_category_id', go_get_category_tree(), $current_category_id));
        $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_move.gif', PICTURE_MOVE) . ' <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $pInfo->items_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        break;
      case 'copy_to':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_COPY_TO . '</b>');
        $contents = array('form' => go_fetch_form('copy_to', NAME_OF_FILE_CATEGORIES, 'action=copy_to_confirm&bigPfad=' . $bigPfad) . go_fetch_hidden_field('items_id', $pInfo->items_id));
        $contents[] = array('text' => TEXT_INFO_COPY_TO_INTRO);
        $contents[] = array('text' => '<br>' . TEXT_INFO_CURRENT_CATEGORIES . '<br><b>' . go_output_generated_category_path($pInfo->items_id, 'item') . '</b>');
        $contents[] = array('text' => '<br>' . TEXT_CATEGORIES . '<br>' . go_fetch_pull_down_menu('categories_id', go_get_category_tree(), $current_category_id));
        $contents[] = array('text' => '<br>' . TEXT_HOW_TO_COPY . '<br>' . go_fetch_radio_field('copy_as', 'link', true) . ' ' . TEXT_COPY_AS_LINK . '<br>' . go_fetch_radio_field('copy_as', 'duplicate') . ' ' . TEXT_COPY_AS_DUPLICATE);
        $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_copy.gif', PICTURE_COPY) . ' <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $pInfo->items_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        break;
      default:
        if ($rows > 0) {
          if (isset($bigwareInfo) && is_object($bigwareInfo)) { 
            $heading[] = array('text' => '<b>' . $bigwareInfo->categories_name . '</b>'); 
            $contents[] = array('align' => 'center', 'text' => '<a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $bigwareInfo->categories_id . '&action=change_category') . '">' . go_picture_button('button_change.gif', PICTURE_CHANGE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $bigwareInfo->categories_id . '&action=delete_category') . '">' . go_picture_button('button_delete.gif', PICTURE_DELETE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $bigwareInfo->categories_id . '&action=move_category') . '">' . go_picture_button('button_move.gif', PICTURE_MOVE) . '</a>' . '</a> <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $bigwareInfo->categories_id . '&action=neu_im_category') . '">' . go_picture_button('button_neue_produkte.gif', PICTURE_MOVE) . '</a>');
            $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . go_date_short($bigwareInfo->date_added));
            if (go_not_null($bigwareInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . go_date_short($bigwareInfo->last_modified));
            $contents[] = array('text' => '<br>' . go_info_picture($bigwareInfo->categories_picture, $bigwareInfo->categories_name, ABOVE_PICTURE_WIDTH, ABOVE_PICTURE_HEIGHT) . '<br>' . $bigwareInfo->categories_picture);
            $contents[] = array('text' => '<br>' . TEXT_SUBCATEGORIES . ' ' . $bigwareInfo->childs_count . '<br>' . TEXT_ITEMS . ' ' . $bigwareInfo->items_count);
          } elseif (isset($pInfo) && is_object($pInfo)) { 
            $heading[] = array('text' => '<b>' . go_get_values_from_items_description($pInfo->items_id, $languages_id, 'items_name') . '</b>'); 
            $contents[] = array('align' => 'center', 'text' => '<a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $pInfo->items_id . '&action=new_item') . '">' . go_picture_button('button_change.gif', PICTURE_CHANGE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $pInfo->items_id . '&action=delete_item') . '">' . go_picture_button('button_delete.gif', PICTURE_DELETE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $pInfo->items_id . '&action=move_item') . '">' . go_picture_button('button_move.gif', PICTURE_MOVE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $pInfo->items_id . '&action=copy_to') . '">' . go_picture_button('button_copy_to.gif', PICTURE_COPY_TO) . '</a>'. '</a> <a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $pInfo->items_id . '&action=neues_item') . '">' . go_picture_button('button_neue_produkte.gif', PICTURE_COPY_TO) . '</a>');
            $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED_BEGIN . ' ' . go_date_short($pInfo->items_date_added));
            $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED_END . ' ' . go_date_short($pInfo->items_date_added_end));
            if (go_not_null($pInfo->items_last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . go_date_short($pInfo->items_last_modified));
            $contents[] = array('text' => TEXT_DATE_AVAILABLE_BEGIN . ' ' . go_date_short($pInfo->items_date_available));
            $contents[] = array('text' => TEXT_DATE_AVAILABLE_END . ' ' . go_date_short($pInfo->items_date_available_end));
            # FIXME if (date('Y-m-d') < $pInfo->items_date_available) $contents[] = array('text' => TEXT_DATE_AVAILABLE_BEGIN . ' ' . go_date_short($pInfo->items_date_available));
            # FIXME if (date('Y-m-d') < $pInfo->items_date_available_end) $contents[] = array('text' => TEXT_DATE_AVAILABLE_END . ' ' . go_date_short($pInfo->items_date_available_end));
            $contents[] = array('text' => '<br>' . go_info_picture($pInfo->items_picture, $pInfo->items_name, SMALL_PICTURE_WIDTH, SMALL_PICTURE_HEIGHT) . '<br>' . $pInfo->items_picture);
if ($pInfo->items_price == "123456.7890"){$rein = PRICE_QUESTION;}else{$rein = $currencies->format($pInfo->items_price);}
            $contents[] = array('text' => '<br>' . TEXT_ITEMS_PRICE_INFO . ' ' . $rein .'&nbsp; / '. $getPriceOption. '<br>' . TEXT_ITEMS_QUANTITY_INFO . ' ' . $pInfo->items_quantity);
            $contents[] = array('text' => '<br>' . TEXT_ITEMS_PRICE_UVP_INFO . ' ' . $currencies->format($pInfo->items_price_uvp));
            $contents[] = array('text' => '<br>' . TEXT_ITEMS_AVERAGE_RATING . ' ' . number_format($pInfo->average_rating, 2) . '%');
          }
        } else { 
          $heading[] = array('text' => '<b>' . EMPTY_CATEGORY . '</b>');
          $contents[] = array('text' => TEXT_NO_CHILD_CATEGORIES_OR_ITEMS);
        }
        break;
    }
    if ( (go_not_null($heading)) && (go_not_null($contents)) ) {
      echo '            <td width="25%" valign="top">' . "\n";
      $frame = new frame;
      echo $frame->infoBox($heading, $contents);
      echo '            </td>' . "\n";  
    }  
?>
