products.php

来自「全新且完善的强大网上商店系统」· PHP 代码 · 共 504 行 · 第 1/2 页

PHP
504
字号
           case '0': $in_status = false; $out_status = true; 
					 break;
           case '1':
           default: $in_status = true; $out_status = false;
       }
       $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'edit_product' : 'new_product';
?>
<div id="spiffycalendar" class="text"></div>
<table cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="<?=TABLEWIDTH?>" class="tableout" align="center">
<tr class="header"><td colspan="2"><?=TEXT_INFO_HEADING_NEW_CATEGORY;?></td></tr>

<link rel="stylesheet" type="text/css" href="./includes/javascript/spiffyCal/spiffyCal_v2_1.css">

<script language="JavaScript" src="./includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
<script language="javascript"><!--
  var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?=$products_date_available;?>",scBTNMODE_CUSTOMBLUE);
//--></script>

<script language="javascript"><!--
var tax_rates = new Array();
<?php
    for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) {
      if ($tax_class_array[$i]['id'] > 0) {
        echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n";
      }
    }
?>

function doRound(x, places) {
  return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
}

function getTaxRate() {
  var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex;
  var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value;

  if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
    return tax_rates[parameterVal];
  } else {
    return 0;
  }
}

function updateGross() {
  var taxRate = getTaxRate();
  var grossValue = document.forms["new_product"].products_price.value;

  if (taxRate > 0) {
    grossValue = grossValue * ((taxRate / 100) + 1);
  }

  document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);
}

function updateNet() {
  var taxRate = getTaxRate();
  var netValue = document.forms["new_product"].products_price_gross.value;

  if (taxRate > 0) {
    netValue = netValue / ((taxRate / 100) + 1);
  }

  document.forms["new_product"].products_price.value = doRound(netValue, 4);
}
//--></script>
<form method="post" name="new_product" action="<?=tep_href_link('admincp.php','act=products&action='.$form_action.'&cPath='.$cPath.(isset($pID) ? '&pID=' . $pID : ''))?>" enctype="multipart/form-data">

			<tr >
        <td bgcolor="<?=ALTBG1?>"><?=TEXT_NEW_PRODUCT?></td>
        <td bgcolor="<?=ALTBG1?>" align="left"><?=tep_output_generated_category_path($current_category_id)?></td>
         
      </tr>
      <tr>
        <td bgcolor="<?=ALTBG1?>"><?php echo TEXT_PRODUCTS_STATUS; ?></td>
        <td bgcolor="<?=ALTBG1?>"><?php echo tep_draw_radio_field('products_status', '1', $in_status) . '&nbsp;' . TEXT_PRODUCT_AVAILABLE . '&nbsp;' . tep_draw_radio_field('products_status', '0', $out_status) . '&nbsp;' . TEXT_PRODUCT_NOT_AVAILABLE; ?></td>
      </tr>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td>
         <td bgcolor="<?=ALTBG1?>"><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td>
      </tr>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td>
         <td bgcolor="<?=ALTBG1?>"><?php echo tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $manufacturers_id); ?></td>
      </tr>
      
<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
		    $query = $db->query("select products_name from $table_products_description where products_id = '" . (int)$products_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
        $product_name = $db->fetch_array($query);
?>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td>
         <td bgcolor="<?=ALTBG1?>"><? echo '<img src="'.IMGDIR.'/'. $languages[$i]['directory'] . '/' . $languages[$i]['image'].'" border="0" alt="'.$languages[$i]['name'].'">&nbsp;<input name="products_name['.$languages[$i]['id'].']" size="" value="'.$product_name['products_name'].'">';?></td>
      </tr>
<?php
    }
?>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td>
         <td bgcolor="<?=ALTBG1?>"><?php echo tep_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $products_tax_class_id, 'onchange="updateGross()"'); ?></td>
      </tr>
      <tr>
         <td bgcolor="<?=ALTBG1?>""><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td>
         <td bgcolor="<?=ALTBG1?>"><input type="text" name="products_price" value="<?=$products_price?>" onKeyUp="updateGross()"></td>
      </tr>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td>
         <td bgcolor="<?=ALTBG1?>"><input type="text" name="products_price_gross" value="<?=$products_price?>" OnKeyUp="updateNet()"></td>
      </tr>
      
<script language="javascript"><!--
updateGross();
//--></script>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>
         <td bgcolor="<?=ALTBG1?>"><input type="text" name="products_quantity" value="<?=$products_quantity?>" ></td>
      </tr>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php echo TEXT_PRODUCTS_MODEL; ?></td>
         <td bgcolor="<?=ALTBG1?>"><input type="text" name="products_model" value="<?=$products_model?>" ></td>
      </tr>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php echo TEXT_PRODUCTS_IMAGE; ?></td>
         <td bgcolor="<?=ALTBG1?>"><?if($products_image){?><img src="upload/images/products/<?=$products_image?>" name="" border="0" ><br><?}?><?php echo '<input type="file" name="products_image"><br>&nbsp;' . $products_image . '<input type="hidden" name="products_previous_image" value="'.$products_image.'">'; ?></td>
      </tr>
      
<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
        $query = $db->query("select products_url from $table_products_description where products_id = '" . (int)$products_id . "' and language_id = '" . (int)$languages[$i]['id']. "'");
        $product_products_url = $db->fetch_array($query);

?>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td>
         <td bgcolor="<?=ALTBG1?>"><?php echo '<img src="'.IMGDIR.'/'. $languages[$i]['directory'] . '/' . $languages[$i]['image'].'" border="0" alt="'.$languages[$i]['name'].'">&nbsp;<input type="text" name="products_url[' . $languages[$i]['id'] . ']" value="'.$product_products_url['products_url'].'" ></td>'?>
      </tr>
<?php
    }
?>
      <tr>
         <td bgcolor="<?=ALTBG1?>"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
         <td bgcolor="<?=ALTBG1?>"><input type="text" name="products_weight" value="<?=$products_weight?>"></td>
      </tr>
<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
        $query = $db->query("select products_description from $table_products_description where products_id = '" . (int)$products_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
        $products_description = $db->fetch_array($query);
?>
      <tr>
         <td bgcolor="<?=ALTBG1?>" valign="top" align="right"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?><?php echo '<img src="'.IMGDIR.'/'. $languages[$i]['directory'] . '/' . $languages[$i]['image'].'" border="0" alt="'.$languages[$i]['name'].'">';?>&nbsp;</td>
         <td bgcolor="<?=ALTBG1?>"><?php echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '70', '6', safe_output($products_description['products_description'])); ?></td>
      </tr>
<?php
    }
?>
   
</table>
    
    
<br><center><?=$warning?>
<input type="submit" name="submit" value="提   交">&nbsp;
</center></form><br><br>

<?
     break;
     case 'delete_product':
        $product_query = $db->query("select pd.products_name, p.products_id, p.categories_id from $table_products p, $table_products_description pd, $table_products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "'");
				$product = $db->fetch_array($product_query);
        @extract($product);
        
        $product_categories_string = '';
        $product_categories = tep_generate_category_path($products_id, 'product');
        for ($i = 0, $n = sizeof($product_categories); $i < $n; $i++) {
            $category_path = '';
            for ($j = 0, $k = sizeof($product_categories[$i]); $j < $k; $j++) {
                $category_path .= $product_categories[$i][$j]['text'] . '&nbsp;&gt;&nbsp;';
            }
            $category_path = substr($category_path, 0, -16);
            $product_categories_string .= tep_draw_checkbox_field('product_categories[]', $product_categories[$i][sizeof($product_categories[$i])-1]['id'], true) . '&nbsp;' . $category_path . '<br>';
        }
        $product_categories_string = substr($product_categories_string, 0, -4);
        

?>
<br>
<table cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="<?=TABLEWIDTH?>" class="tableout" align="center" style="word-break:break-all;">
<tr class="header" ><td colspan="2">特别提示</td></tr>
<tr bgcolor="<?=ALTBG1?>"><td width="30%"><li><?=TEXT_INFO_HEADING_DELETE_PRODUCT;?></td><td><b><?=$products_name?></b></td></tr>
<tr bgcolor="<?=ALTBG1?>"><td><li><?=TEXT_INFO_CURRENT_CATEGORIES;?></td><td><b><?=tep_output_generated_category_path($products_id, 'product')?></b></td></tr>
</table>
<br>

<form method="post" name="products" action="<?=tep_href_link('admincp.php', 'act=products&action=delete_product&cPath='.$cPath)?>">
<input type="hidden" name="products_id" value="<?=$products_id;?>">
<table cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="<?=TABLEWIDTH?>" class="tableout" align="center" style="word-break:break-all;">
<tr>
<td bgcolor="<?=ALTBG1?>" align="right" width="30%"></td>
<td bgcolor="<?=ALTBG1?>" align="left"><?=$product_categories_string?></td>
</tr>
</table>
<br><center>
<?=tep_image_submit('button_delete.gif', IMAGE_DELETE)?> <a href="<?=tep_href_link('admincp.php', 'act=catalog&cPath=' . $cPath . '&pID=' . $products_id)?>"><?=tep_image_button('button_cancel.gif', IMAGE_CANCEL)?></a>
</center></form><br><br>

<?
     break;
     case 'move_product':
        $product_query = $db->query("select pd.products_name, p.products_id, p.categories_id from $table_products p left join $table_categories c on c.categories_id=p.categories_id, $table_products_description pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
        $product = $db->fetch_array($product_query);
        @extract($product);
        
        
?>
<br>
<table cellspacing="0" cellpadding="0" border="0" width="95%" align="center">
<tr><td bgcolor="<?=BORDERCOLOR?>">
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="100%">
<tr class="header"><td>特别提示</td></tr>
<tr bgcolor="<?=ALTBG1?>"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr><td>
<ul><li><?=TEXT_INFO_HEADING_MOVE_PRODUCT;?><b><?=$products_name?></b></ul>
<ul><li><?=TEXT_INFO_CURRENT_CATEGORIES; echo '<b>' . tep_output_generated_category_path($products_id, 'product') . '</b>';?></ul>
</td><td align="right" ><a href="<?=tep_href_link('admincp.php', 'act=catalog&cPath='.$cPath.'&pID='.$products_id)?>"><img src="<?=IMGDIR?>/<?=$language?>/button_cancel.gif" border="0" alt="<?=IMAGE_CANCEL?>"></a>&nbsp;</td>
</tr></table></td></tr></table></td></tr></table>
<br>

<form method="post" name="products" action="<?=tep_href_link('admincp.php', 'act=products&action=move_product&cPath='.$cPath.(isset($pID) ? '&pID=' . $pID : ''))?>" enctype="multipart/form-data">
<input type="hidden" name="products_id" value="<?=$products_id;?>">
<table cellspacing="0" cellpadding="0" border="0" width="95%" align="center" style="word-break:break-all;"> 
<tr><td bgcolor="<?=BORDERCOLOR?>"> 
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="100%" style="word-break:break-all;"> 

<tr>
<td bgcolor="<?=ALTBG1?>" align="right" width="40%"><?=TEXT_MOVE_TO?></td>
<td bgcolor="<?=ALTBG1?>" align="left"><?  echo tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $categories_id); ?></td>
</tr>
</table></td></tr></table>

<br><center><?=$warning?>
<input type="image" src="<?=IMGDIR?>/<?=$language?>/button_move.gif" border="0" alt="<?=IMAGE_MOVE?>" title=" <?=IMAGE_MOVE?> ">&nbsp;
</center></form><br><br>

<? 

     break;
		 default:
  }
}
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?