<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
/**
* @version $Id: product.product_form.php,v 1.17 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__ );

require_once( CLASSPATH.'ps_product_discount.php' );

$limitstart = mosGetParam( $_REQUEST, 'limitstart', 0 );
$keyword = mosGetParam( $_REQUEST, 'keyword', "" );
$product_id = mosGetParam( $_REQUEST, 'product_id');
$product_parent_id = mosGetParam( $_REQUEST, 'product_parent_id');
$next_page = mosGetParam( $_REQUEST, 'next_page', "product.product_display" );

$dl_checked = "";
$curr_filename = "";
$list = Array();
$my_categories = array();

if ($product_parent_id) {
    if ($product_id) {
        $action = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_UPDATE_ITEM_LBL;
    } 
    else {
        $action = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_NEW_ITEM_LBL;
    }
    $info_label = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_ITEM_INFO_LBL;
    $status_label = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_ITEM_STATUS_LBL;
    $dim_weight_label = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL;
    $images_label = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_ITEM_IMAGES_LBL;
    $delete_message = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_DELETE_ITEM_MSG;
}
else {
    $product_parent_id = '';
    if ($product_id = @$vars["product_id"]) {
        $action = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_UPDATE_PRODUCT_LBL;
    } 
    else {
        $action = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_NEW_PRODUCT_LBL;
    }
    $info_label = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_PRODUCT_INFO_LBL;
    $status_label = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_PRODUCT_STATUS_LBL;
    $dim_weight_label = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL;
    $images_label = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_PRODUCT_IMAGES_LBL;
    $delete_message = $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_DELETE_PRODUCT_MSG;
}
if (!empty($product_id)) {
  // get the Database object we're filling the product form with
  $db = $ps_product->sql($product_id); 
  $db->next_record();
  
  // Get category IDs
  $db2 = new ps_DB;
  $q = "SELECT category_id FROM #__pshop_product_category_xref WHERE product_id='$product_id'";
  $db2->query($q);
  while ($db2->next_record()) {
      $my_categories[$db2->f("category_id")] = "1";
  }
  
  // Get the Manufacturer ID
  $db2->query("SELECT manufacturer_id FROM #__pshop_product_mf_xref WHERE product_id='$product_id'");
  $db2->next_record();
  $manufacturer_id = $db2->f("manufacturer_id");
  
  // Look if the Product is downloadable
  $q_dl = "SELECT attribute_name,attribute_value AS filename FROM #__pshop_product_attribute WHERE ";
  $q_dl .= "product_id='$product_id' AND attribute_name='download'";
  $db2->query($q_dl);
  if ($db2->next_record()) {
    $dl_checked = "checked=\"checked\"";
  }
  $curr_filename = $db2->f("filename");
  
}
elseif (empty($vars["error"])) {
  $default["product_publish"] = "Y";
  $default["product_weight_uom"] = "pounds";
  $default["product_lwh_uom"] = "inches";
}
?>
<link rel="stylesheet" type="text/css" media="all" href="<?php echo $mosConfig_live_site ?>/includes/js/calendar/calendar-mos.css" title="green" />
<!-- import the calendar script -->
<script type="text/javascript" src="<?php echo $mosConfig_live_site ?>/includes/js/calendar/calendar.js"></script>
<!-- import the language module -->
<script type="text/javascript" src="<?php echo $mosConfig_live_site ?>/includes/js/calendar/lang/calendar-en.js"></script>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
<script language="Javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>

<table width="100%">
  <tr>
    <td width="10%">
    <br />&nbsp;&nbsp;&nbsp;<img src="<?php echo IMAGEURL ?>ps_image/product_code.png" border="0" />
    </td>
    <td width="20%" valign="middle">
    <span class="sectionname"><?php echo $action; ?></span>
    </td>
    <td align="70%" align="center">
    <?php if(!empty($product_id)) { // show a link to the shop- flypage 
    
            $flypage = $ps_product->get_flypage($product_id); ?>
            
      <a href="<?php echo $mosConfig_live_site."/index2.php?option=com_phpshop&page=shop.product_details&flypage=$flypage&product_id=$product_id" ?>" target="_blank">
          <? echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_SHOW_FLYPAGE ?></a>
    <?php } ?>
    </td>
  </tr>
</table>
<?php
    $tabs = new mShopTabs(0, 1, "_main");
    $tabs->startPane("content-pane");
    $tabs->startTab( "<img src=\"". IMAGEURL ."ps_image/edit.png\" align=\"center\" width=\"16\" height=\"16\" border=\"0\" />&nbsp;$info_label", "info-page");
?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" name="adminForm" enctype="multipart/form-data">
  <input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
  <input type="hidden" name="product_parent_id" value="<?php echo $product_parent_id; ?>" />
  <input type="hidden" name="func" value="<?php if ($product_id) { echo "productUpdate";} else {echo "productAdd";} ?>" />
  <input type="hidden" name="page" value="<?php echo $next_page ?>" />
  <input type="hidden" name="option" value="com_phpshop" />
  <input type="hidden" name="keyword" value="<?php echo $keyword ?>" />
  <input type="hidden" name="limitstart" value="<?php echo $limitstart ?>" />

<table width="100%" border="0">
  <tr> 
   <td>
     <table width="100%" border="0">
      <tr> 
       <td colspan="2">&nbsp;</td>
    </tr>
    <tr> 
      <td  width="21%" ><div align="right"><strong>
      <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_PUBLISH ?>:</strong></div>
      </td>
      <td width="79%" > <?php if ($db->sf("product_publish")=="Y") { 
    echo "<input type=\"checkbox\" name=\"product_publish\" value=\"Y\" checked=\"checked\" />";
} 
else {
    echo "<input type=\"checkbox\" name=\"product_publish\" value=\"Y\" />";
}
?> </td>
    </tr>
    <tr> 
      <td width="21%" ><strong>
        <div align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_SKU ?>:</div></strong>
      </td>
      <td width="79%" height="2"> 
        <input type="text" class="inputbox"  name="product_sku" value="<?php $db->sp("product_sku"); ?>" size="32" maxlength="64" />
      </td>
    </tr>
    <tr> 
      <td width="21%" height="18"><strong><div align="right">
      <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_NAME ?>:</div></strong>
      </td>
      <td width="79%" height="18" > 
        <input type="text" class="inputbox"  name="product_name" value="<?php $db->sp("product_name"); ?>" size="32" maxlength="255" />
      </td>
    </tr>
    <tr> 
      <td width="21%"><strong><div align="right">
        <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_URL ?>:</div></strong>
      </td>
      <td width="79%"> 
        <input type="text" class="inputbox"  name="product_url" value="<?php $db->sp("product_url"); ?>" size="32" maxlength="255" />
      </td>
    </tr>
    <?php
    if (!$product_parent_id) { ?>
    <tr> 
      <td width="21%" valign="top"><strong><div align="right">
       <?php echo $PHPSHOP_LANG->_PHPSHOP_CATEGORIES ?>:<br/><br/>
       <?php echo $PHPSHOP_LANG->_PHPSHOP_MULTISELECT ?></div></strong>
       </td>
      <td width="79%" ><?php 
        $ps_product_category->list_all("product_categories[]", "", $my_categories, 10, false, true); ?></td>
    </tr>
    <?php
    }
    ?>
    
        <tr> 
      <td width="21%"><strong><div align="right">
        <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_VENDOR ?>:</div></strong>
      </td>
      <td width="79%" ><?php $ps_product->list_vendor($db->sf("vendor_id"));  ?></td>
    </tr>
    <tr> 
      <td width="21%" ><strong><div align="right">
        <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_MANUFACTURER ?>:</div></strong>
      </td>
      <td width="79%" ><?php $ps_product->list_manufacturer(@$manufacturer_id);  ?></td>
    </tr>
    <tr> 
      <td width="21%" ><strong><div align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_PRICE ?>:</div></strong>
      </td>
      <td width="79%" >
        <table border="0">
            <tr>
            <td>
                <input type="text" class="inputbox" name="product_price" 
                value="<?php $price = $ps_product->get_retail_price($product_id); echo $price["product_price"]; ?>" size="10" maxlength="10" />
                <input type="hidden" name="product_price_id" value="<? echo @$price["product_price_id"] ?>" />
            </td>
            <td><?php
              if(empty($price["product_currency"]))
                $price["product_currency"] = $vendor_currency;
              $ps_html->list_currency("product_currency",$price["product_currency"]) ?>
            </td>
            <td>&nbsp;<?php
                echo $PHPSHOP_LANG->_PHPSHOP_PRICE_FORM_GROUP . ": ";
                $shopper_db = new ps_DB;
                // get the default shopper group
                $q =  "SELECT * FROM #__pshop_shopper_group WHERE ";
                $q .= "`default`= '1' AND vendor_id='".$db->f("vendor_id")."'";
                $shopper_db->query($q);
                if (!$shopper_db->num_rows()) {  // when there is no "default", take the first in the table 
                    $q =  "SELECT shopper_group_id,shopper_group_name from #__pshop_shopper_group WHERE vendor_id='$ps_vendor_id'";
                    $shopper_db->query($q);
                }
                $shopper_db->next_record();
                $my_shopper_group_id = $shopper_db->f("shopper_group_id");
                $shopper_db->p("shopper_group_name"); ?>               
                <input type="hidden" name="shopper_group_id" value="<? echo $my_shopper_group_id ?>" />
             </td>
            </tr>
        </table>
      </td>
  <?php /*
  if ($product_id) {
    $price = $ps_product->get_price($product_id);
    $url  = $PHP_SELF . "?page=$modulename/product_price_list&product_id=$product_id&product_parent_id=$product_parent_id";
    $url .= "&return_args=" . urlencode("page=$page&product_id=$product_id&product_parent_id=$product_parent_id");
    echo "<A HREF=" . $sess->url($url) . ">";
    if ($price) {
      if ($price["item"]) {
        echo $price["product_price"];
      } else {
        echo "none";
      } 
    } else {
      echo "none";
    } 
    echo "</A>";
  } else {
    echo "none";
  }*/
  ?>
    </tr>
    <tr>
      <td width="21%" ><strong><div align="right">
        <?php echo $PHPSHOP_LANG->_PHPSHOP_RATE_FORM_VAT_ID ?>:</div></strong></td>
      <td width="79%" >
        <?php
        require_once(CLASSPATH.'ps_tax.php');
        ps_tax::list_tax_value("product_tax_id",$db->sf("product_tax_id")) ?>
      </td>
    </tr>
    <tr> 
      <td width="21%" valign="top"><strong><div align="right">
          <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_S_DESC ?>:</div></strong>
      </td>
      <td width="79%"  valign="top">
          <textarea class="inputbox" name="product_s_desc" id="short_desc" cols="35" rows="6" ><?php echo $db->sf("product_s_desc"); ?></textarea> 
      </td>
    </tr><?php if (defined('_PSHOP_ADMIN')) { ?>
  </table>
   </td>
   <td>
      <table><? } ?>
          <tr> 
            <td valign="top"><strong><div align="right">
                <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_DESCRIPTION ?>:</div></strong>
             </td>
             <td><?
            
          editorArea( 'editor1', $db->sf("product_desc"), 'product_desc', '350', '300', '55', '25' )
        
            ?></td>
          </tr>
      </table>
   </td>
   </tr>
  </table>
  
<?php
$tabs->endTab();
$tabs->startTab( "<img src=\"". IMAGEURL ."ps_image/options.png\" width=\"16\" height=\"16\" align=\"center\" border=\"0\" />&nbsp;$status_label", "status-page");
?>

  <table width="100%" border="0" cellspacing="0" cellpadding="2">
    <tr> 
      <td colspan="2" height="2" >&nbsp;</td>
    </tr>

    <tr> 
      <td width="21%" height="2" ><div align="right"><strong>
      <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_IN_STOCK ?>:</div></strong>
      </td>
      <td width="79%" height="2" > 
        <input type="text" class="inputbox"  name="product_in_stock" value="<?php $db->sp("product_in_stock"); ?>" size="10" />
      </td>
    </tr>
    <tr> 
      <td width="21%" ><strong><div align="right">
        <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_AVAILABLE_DATE ?>:</div></strong>
      </td>
      <td width="79%" >
          <input class="inputbox" type="text" name="product_available_date" id="product_available_date" size="20" maxlength="19" value="<?php echo date('Y-m-d', $db->sf("product_available_date") ); ?>" />
          <input name="reset" type="reset" class="button" onClick="return showCalendar('product_available_date', 'y-mm-dd');" value="..." />
     </td>
    </tr>
    <tr><td colspan="2">&nbsp;</td></tr>
    <tr>
      <td valign="top" width="21%" ><strong><div align="right">
          <?php echo $PHPSHOP_LANG->_PHPSHOP_AVAILABILITY ?>:</div></strong>
      </td>
      <td width="79%" >
        <input type="text" class="inputbox" name="product_availability" value="<?php $db->sp("product_availability"); ?>" />
      <?php
      echo mosToolTip($PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_AVAILABILITY_TOOLTIP1); ?>
      <br /><br />
        <select class="inputbox" name="image" onchange="javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='<?php echo IMAGEURL ?>availability/' + document.forms[0].image.options[selectedIndex].value; document.forms[0].product_availability.value=document.forms[0].image.options[selectedIndex].value;} else {document.imagelib.src='<?php echo $mosConfig_live_site ?>/images/stories/noimage.png'}">
          <option value="">Select Image</option><?php
            $path = IMAGEPATH."availability";
            $files = mosReadDirectory( "$path", ".", true, true);
            foreach ($files as $file) { 
                $file_info = pathinfo($file);
                $filename = $file_info['basename']; 
                if ($filename != "index.html") {?>
                <option <?php echo ($db->f("product_availability")==$filename) ? "selected=\"selected\"" : "" ?> value="<?php echo $filename ?>">
                <?php echo $filename ?>
                </option><?php 
                }
            }  ?>
        </select>&nbsp;
        <?php echo mosToolTip($PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_AVAILABILITY_TOOLTIP2);?>
        &nbsp;&nbsp;&nbsp;
        <img src="<?php echo $db->f("product_availability") ? IMAGEURL."availability/".$db->sf("product_availability") : $mosConfig_live_site ."/images/stories/noimage.png"; ?>" name="imagelib" border="0" alt="Preview" />
      </td>
    <tr> 
      <td width="21%" ><strong><div align="right">
      <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_SPECIAL ?>:</div></strong>
      </td>
      <td width="79%" ><?php if ($db->sf("product_special")=="Y") { ?>
        <input type="checkbox" name="product_special" value="Y" checked="checked" />
    <?    } 
       else { ?>
        <input type="checkbox" name="product_special" value="Y" />
    <? }
    ?> </td>
    </tr>
    <tr> 
      <td width="21%" ><strong><div align="right">
        <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_DISCOUNT_TYPE ?>:</div></strong>
      </td>
      <td width="79%" ><?php
        echo ps_product_discount::discount_list( $db->sf("product_discount_id") ); ?>
      </td>
    </tr>
      <!-- Added for the avanced attribute modification -->
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
        <td align="right" width="21%" valign="top"><strong><div align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_ATTRIBUTE_LIST ?>:</div></strong></td> 
        <td width="79%" >
        <input class="inputbox" type="text" name="product_advanced_attribute" value="<?php $db->sp("attribute"); ?>" size="64" />
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_ATTRIBUTE_LIST_EXAMPLES ?></td></tr>
  <!-- END added for the advanced attribute modification --> 
  
  <!-- Added for the custom attribute modification -->
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
        <td align="right" width="21%" valign="top"><strong><div align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_CUSTOM_ATTRIBUTE_LIST ?>:</div></strong></td> 
        <td width="79%" >
        <input class="inputbox" type="text" name="product_custom_attribute" value="<?php $db->sp("custom_attribute"); ?>" size="64" />
    </tr>
    <tr>
     <td>&nbsp;</td>
     <td><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_CUSTOM_ATTRIBUTE_LIST_EXAMPLES ?></td>
	</tr>
  <!-- END added for the custom attribute modification -->
  </table>
  
  
  <?php
$db_items = $ps_product->items_sql($product_id);
if (!$product_parent_id and $product_id and $db_items->num_rows() > 0) { 
?> 
  <table width="100%" border="0" cellspacing="0" cellpadding="2">
    <tr> 
      <td colspan="4">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="4"><strong><div align="right">
          <?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_PRODUCT_ITEMS_LBL ?><div align="right"></strong>
      </td>
    </tr>
    <tr nowrap> 
      <td><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_NAME ?></td>
      <td><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_SKU ?></td>
      <td><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_PRICE ?></td>
      <?php
  $db_heading = $ps_product->attribute_sql("",$product_id);
  while ($db_heading->next_record()) {
?> 
      <td><?php echo $db_heading->sf("attribute_name"); ?></td>
      <?php
  }
?> </tr>
    <tr> 
      <td colspan="<?php echo $db_heading->num_rows() + 3 ?>"> 
        <hr size="1" />
      </td>
    </tr>
    <?php
  while ($db_items->next_record()) {
?> 
    <tr nowrap> 
      <td> <?php
    $url = $_SERVER['PHP_SELF'] . "?page=$modulename.product_form&product_id=" . $db_items->f("product_id") . "&product_parent_id=$product_id";
    echo "<a href=\"" . $sess->url($url) . "\">";
    echo $db_items->f("product_name"); 
    echo "</a>"; 
?> </td>
      <td><?php $db_items->sp("product_sku"); ?> </td>
      <td> <?php
    $price = $ps_product->get_price($db_items->f("product_id"));
    $url  = $_SERVER['PHP_SELF'] . "?page=$modulename.product_price_list&product_id=" . $db_items->f("product_id") . "&product_parent_id=$product_parent_id";
    $url .= "&return_args=" . urlencode("page=$page&product_id=$product_id");
    echo "<a href=\"" . $sess->url($url) . "\">";
    if ($price) {
      if (!empty($price["item"])) {
        echo $price["product_price"];
      } else {
        echo "none";
      } 
    } else {
      echo "none";
    }
    echo "</a>";
?> </td>
      <?php
    $db_detail = $ps_product->attribute_sql($db_items->f("product_id"),$product_id);
    while ($db_detail->next_record()) {
?> 
      <td><?php $db_detail->p("attribute_value"); ?></td>
      <?php
    }
?> </tr>
    <?php
  } 
?> 
  </table>
  <?php
} elseif ($product_parent_id) {
?> 
  <table width="100%" border="0" cellspacing="0" cellpadding="2">
    <tr> 
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2"><strong><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_ITEM_ATTRIBUTES_LBL ?></strong></td>
    </tr>
    <?php
  if (!empty($_REQUEST['product_id'])) {
    $db_attribute = $ps_product->attribute_sql($product_id,$product_parent_id);
  } else {
    $db_attribute = $ps_product->attribute_sql("",$product_parent_id);
  }
  $num = 0;
  while ($db_attribute->next_record()) {
    $num++; ?> 
    <tr nowrap> 
      <td width="21%" height="22" > 
        <div align="right"><?php
          echo $db_attribute->sf("attribute_name") . ":";
          $field_name = "attribute_$num"; ?></div>
      </td>
      <td width="79%" > 
        <input type="text" class="inputbox"  name="<?php echo $field_name; ?>" size="32" maxlength="255" value="<?php $db_attribute->sp("attribute_value"); ?>" />
      </td>
    </tr>
    <?php
  } ?> 
  </table>
  <?php
} 

$tabs->endTab();
$tabs->startTab( "<img src=\"". IMAGEURL ."ps_image/info.png\" width=\"16\" height=\"16\" align=\"center\" border=\"0\" />&nbsp;$dim_weight_label", "about-page");

?>

<table>
 <tr>
  <td width="50%"><?php
    echo "<h2>$dim_weight_label</h2>";
?><table>
    <tr> 
      <td width="21%" valign="top" > 
        <div align="right"><strong><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_LENGTH ?>:</strong></div>
      </td>
      <td width="21%" > 
        <input type="text" class="inputbox"  name="product_length" value="<?php $db->sp("product_length"); ?>" size="15" maxlength="15" />
      </td>
    </tr>
    <tr> 
      <td width="21%" valign="top" > 
        <div align="right"><strong><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_WIDTH ?>:</strong></div>
      </td>
      <td width="21%" > 
        <input type="text" class="inputbox"  name="product_width" value="<?php $db->sp("product_width"); ?>" size="15" maxlength="15" />
      </td>
    </tr>
    <tr> 
      <td width="21%" valign="top" > 
        <div align="right"><strong><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_HEIGHT ?>:</strong></div>
      </td>
      <td width="21%" > 
        <input type="text" class="inputbox"  name="product_height" value="<?php $db->sp("product_height"); ?>" size="15" maxlength="15" />
      </td>
    </tr>
    <tr> 
      <td width="21%" valign="top" > 
        <div align="right"><strong><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_DIMENSION_UOM ?>:</strong></div>
      </td>
      <td width="21%" > 
        <input type="text" class="inputbox"  name="product_lwh_uom" value="<?php $db->sp("product_lwh_uom"); ?>" size="8" maxlength="32" />
      </td>
    </tr>
    <tr> 
      <td width="21%" valign="top" >&nbsp;</td>
      <td width="21%" >&nbsp;</td>
    </tr>
    <tr> 
      <td width="21%" valign="top" > 
        <div align="right"><strong><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_WEIGHT ?>:</strong></div>
      </td>
      <td width="21%" > 
        <input type="text" class="inputbox"  name="product_weight" size="15" maxlength="15" value="<?php $db->sp("product_weight"); ?>" />
      </td>
    </tr>
    <tr> 
      <td width="21%" valign="top" > 
        <div align="right"><strong><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_WEIGHT_UOM ?>:</strong></div>
      </td>
      <td width="21%" > 
        <input type="text" class="inputbox"  name="product_weight_uom" value="<?php $db->sp("product_weight_uom"); ?>" size="8" maxlength="32" />
      </td>
    </tr>
  </table>
  </td>
  <td width="50%" valign="top">
  <h2><?php echo $PHPSHOP_LANG->_PHPSHOP_ADMIN_CFG_DOWNLOADABLEGOODS ?></h2>
  <table width="100%" border="0" cellspacing="0" cellpadding="2">
    <tr> 
      <td width="31%"><strong><div align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_DOWNLOADABLE ?></div></strong></td>
      <td align="left" width="69%">
      <input class="inputbox" <?php echo $dl_checked ?> type="checkbox" name="downloadable" onchange="javascript: if(document.adminForm.downloadable.checked==true) document.adminForm.filename.disabled=false; else {document.adminForm.filename.disabled=true;}" value="Y" /></td>
    </tr>
    <tr> 
      <td width="31%"><div align="right"><?php if($curr_filename) echo $PHPSHOP_LANG->_PHPSHOP_FILES_FORM_CURRENT_FILE.":"; ?></div></td>
      <td valign="top" align="left" width="69%"><?php echo $curr_filename; ?>
      </td>
    </tr>
    <tr> 
      <td width="31%"><div align="right"><?php
      echo mosToolTip($PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_FILENAME_TOOLTIP); ?>
      &nbsp;&nbsp;<strong><?php 
      echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_FILENAME; ?>:</strong></div></td>
      <td valign="top" align="left" width="69%">
        <input type="text" name="filename" class="inputbox" value="<?php echo $curr_filename; ?>" size="32" />
      </td>
    </tr>
    <tr> 
      <td width="31%"><div align="right"><?php
      echo mosToolTip($PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_UPLOAD_TOOLTIP); ?>
      &nbsp;&nbsp;<strong><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_UPLOAD ?>:</strong></div></td>
      <td valign="top" align="left" width="69%">
        <input type="file" name="file_upload" class="inputbox" size="32" />
      </td>
    </tr>
  </table>
  </td>
 </tr>
</table>
<?php
$tabs->endTab();
$tabs->startTab( "<img src=\"". IMAGEURL ."ps_image/image.png\" width=\"16\" height=\"16\" align=\"center\" border=\"0\" />&nbsp;$images_label", "images-page");
?>


  <table width="100%" border="0" cellspacing="0" cellpadding="2">

    <tr> 
      <td colspan="2">&nbsp;
      <?php
        if( !stristr( $db->f("product_thumb_image"), "http") ) { ?>
        <input type="hidden" name="product_thumb_image_curr" value="<?php $db->p("product_thumb_image") ?>" />
      <?php
        }
        if( !stristr( $db->f("product_full_image"), "http") ) { ?>
        <input type="hidden" name="product_full_image_curr" value="<?php $db->p("product_full_image"); ?>" />
      <?php
        } ?>
      </td>
    </tr>
    <tr> 
      <td width="21%" > 
        <div align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_THUMB_IMAGE ?>:</div>
      </td>
      <td width="79%" ><?php $ps_product->show_image($db->f("product_thumb_image"), "", 0); ?></td>
    </tr>
    <tr> 
      <td width="21%" >&nbsp;</td>
      <td width="79%" ><?php if ($product_id) {
          echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_IMAGE_UPDATE_LBL . "<br>"; } ?> 
        <input type="file" class="inputbox" name="product_thumb_image" size="32" maxlength="255" onchange="if(document.adminForm.product_thumb_image.value!='') document.adminForm.product_thumb_image_url.value='';" />
        <?php 
        if ($product_id and $db->f("product_thumb_image")) {
          echo "<br />" . $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_IMAGE_DELETE_LBL; 
        } ?>
      </td>
    </tr>
    <tr> 
      <td width="21%" >&nbsp;</td>
      <td width="79%" >
        <?php 
        echo _URL." ("._CMN_OPTIONAL.")&nbsp;";
        if( stristr($db->f("product_thumb_image"), "http") )
          $product_thumb_image_url = $db->f("product_thumb_image");
        else if(!empty($_REQUEST['product_thumb_image_url']))
          $product_thumb_image_url = $_REQUEST['product_thumb_image_url'];
        else
          $product_thumb_image_url = "";
        ?>
        <input type="text" class="inputbox" size="70" name="product_thumb_image_url" value="<?php echo $product_thumb_image_url ?>" />
      </td>
    </tr>
    <tr> 
      <td colspan="2"><hr /></td>
    </tr>
    <tr> 
      <td width="21%" > 
        <div align="right"><?php echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_FULL_IMAGE ?>:</div>
      </td>
      <td width="79%" ><?php $ps_product->show_image($db->f("product_full_image"), "", 0); ?></td>
    </tr>
    <tr> 
      <td width="21%" >&nbsp;</td>
      <td width="79%" ><?php 
        if ($product_id) {
          echo $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_IMAGE_UPDATE_LBL . "<br />"; } ?> 
        <input type="file" class="inputbox" name="product_full_image" size="32" maxlength="255" />
        <?php 
        if ($product_id and $db->f("product_full_image")) {
          echo "<br />" . $PHPSHOP_LANG->_PHPSHOP_PRODUCT_FORM_IMAGE_DELETE_LBL; } ?>
      </td>
    </tr>
    <tr> 
      <td width="21%" >&nbsp;</td>
      <td width="79%" >
        <?php 
        echo _URL." ("._CMN_OPTIONAL."!)&nbsp;";
        if( stristr($db->f("product_full_image"), "http") )
          $product_full_image_url = $db->f("product_full_image");
        else if(!empty($_REQUEST['product_full_image_url']))
          $product_full_image_url = $_REQUEST['product_full_image_url'];
        else
          $product_full_image_url = "";
        ?>
        <input type="text" class="inputbox" size="70" name="product_full_image_url" value="<?php echo $product_full_image_url ?>" />
      </td>
    </tr>
    <tr> 
      <td width="21%">&nbsp;</td>
      <td width="79%">&nbsp;</td>
    </tr>
  </table>
</div>
  <input type="hidden" name="task" value="" />
</form>

<?php
$tabs->endTab();
$tabs->endPane();
?>   
<script language="javascript">
<!--
if(document.adminForm.downloadable.checked==true) {
  document.adminForm.filename.disabled=false; 
}
else {
  document.adminForm.filename.disabled=true;
}
-->
</script>
