<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
/**
* @version $Id: product.product_category_form.php,v 1.3 2005/01/27 19:34:03 soeren_nb Exp $
* @package mambo-phpShop
* @subpackage HTML
* Contains code from PHPShop(tm):
* 	@copyright (C) 2000 - 2004 Edikon Corporation (www.edikon.com)
*	Community: www.phpshop.org, forums.phpshop.org
* Conversion to Mambo and the rest:
* 	@copyright (C) 2004-2005 Soeren Eberhardt
*
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* mambo-phpShop is Free Software.
* mambo-phpShop comes with absolute no warranty.
*
* www.mambo-phpshop.net
*/
mm_showMyFileName( __FILE__ );

$category_id = mosgetparam($_REQUEST, 'category_id', 0);

?>

<h2><?php echo $PHPSHOP_LANG->_PHPSHOP_CATEGORY_FORM_LBL ?></h2>

<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr> 
    <td align="center"> <?php 
  if ($category_id) {
    $q = "SELECT * from #__pshop_category,#__pshop_category_xref ";
    $q .= "where #__pshop_category.category_id='$category_id' ";
    $q .= "AND #__pshop_category_xref.category_child_id=#__pshop_category.category_id";
    $db->query($q);
    $db->next_record();
  } 
  elseif (empty($vars["error"])) {
    $default["category_publish"] = "Y";
    $default["category_flypage"] = "shop.flypage";
    $default["category_browsepage"] = CATEGORY_TEMPLATE;
    $default["products_per_row"] = PRODUCTS_PER_ROW;
  }
?> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td>
            <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" name="adminForm">
              <table width="100%" border="0" cellspacing="0" cellpadding="2" >
                <tr> 
                  <td width="38%" nowrap align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_CATEGORY_FORM_PUBLISH ?>:</td>
                  <td width="62%"><?php 
                    if ($db->sf("category_publish")=="Y") { 
                      echo "<input type=\"checkbox\" name=\"category_publish\" value=\"Y\" checked=\"checked\" />";
                    } 
                    else {
                      echo "<input type=\"checkbox\" name=\"category_publish\" value=\"Y\" />";
                    }
                  ?> 
                  </td>
                </tr>
                <tr> 
                  <td width="38%" nowrap align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_CATEGORY_FORM_NAME ?>:</td>
                  <td width="62%"> 
                    <input type="text" class="inputbox" name="category_name" size="60" value="<?php $db->sp('category_name') ?>" />
                    <input type="hidden" name="category_id" value="<?php echo $category_id ?>" />
                    <input type="hidden" name="task" value="" />
                    <input type="hidden" name="page" value="<?php echo $modulename ?>.product_category_list" />
                    <input type="hidden" name="func" value="<?php if (!empty($category_id)) { echo "productCategoryUpdate";} else {echo "productCategoryAdd";} ?>" />
                    <input type="hidden" name="option" value="com_phpshop" />
                  </td>
                </tr>
                <tr> 
                  <td width="38%" nowrap align="right" valign="top"><?php echo $PHPSHOP_LANG->_PHPSHOP_CATEGORY_FORM_DESCRIPTION ?>:</td>
                  <td width="62%" valign="top"><?php
                    editorArea( 'editor1', $db->f("category_description"), 'category_description', '300', '100', '60', '6' ) ?>
                  </td>
                </tr>
                <tr>
                  <td align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_MODULE_LIST_ORDER ?>: </td>
                  <td valign="top"><?php 
                    echo $ps_product_category->list_level( $db->f("category_parent_id"), $db->f("category_id"), $db->f("list_order"));
                    echo "<input type=\"hidden\" name=\"currentpos\" value=\"".$db->f("list_order")."\" />";
                  ?>
                  </td>
                </tr>
                <tr> 
                  <td width="38%" nowrap align="right" valign="top"><?php echo $PHPSHOP_LANG->_PHPSHOP_CATEGORY_FORM_PARENT ?>:</td>
                  <td width="62%" valign="top"> <?php 
                      if (!$category_id) {
                        $ps_product_category->list_all("parent_category_id", $category_id);
                      }
                      else {
                        $ps_product_category->list_all("category_parent_id", $category_id);
                      }
                    echo "<input type=\"hidden\" name=\"current_parent_id\" value=\"".$db->f("category_parent_id")."\" />"; ?>
                  </td>
                </tr>
                <tr>
                  <td colspan="2"><br /></td>
                </tr>
                <tr>
                  <td align="right">Category Browse Page: </td>
                  <td valign="top">
                  <input type="text" class="inputbox" name="category_browsepage" value="<?php $db->sp("category_browsepage"); ?>" />
                  </td>
                </tr>
                <tr>
                  <td align="right">Show x products per row: </td>
                  <td valign="top">
                  <input type="text" class="inputbox" size="3" name="products_per_row" value="<?php $db->sp("products_per_row"); ?>" />
                  </td>
                </tr>
                <tr>
                  <td colspan="2"><br /></td>
                </tr>
                 <tr>
                  <td align="right">
                    <?php echo $PHPSHOP_LANG->_PHPSHOP_CATEGORY_FORM_FLYPAGE ." ". $PHPSHOP_LANG->_PHPSHOP_LEAVE_BLANK ?>:
                  </td>
                  <td valign="top">
                  <input type="text" class="inputbox" name="category_flypage" value="<?php $db->sp("category_flypage"); ?>" />
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr> 
            <td colspan="2" align="center">&nbsp;</td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
  <tr> 
    <td align="center">&nbsp; </td>
  </tr>
  <tr> 
    <td align="center"><?php
?></td>
  </tr>
</table>
