products_attributes_add_p.php

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

PHP
318
字号
<?php
/*
  [SOOBIC!] admin/products_attributes_add_p.php 

	Version: 1.5
	Author: Soolan (soolan@qq.com)
	Copyright: soolan (www.soobic.com)
	Last Modified: 2005/4/13 10:00

*/
if(!defined('IN_SOOBIC')) {
        exit('Access Denied');
}

require('admin/languages/'.$language.'/products_attributes.php');

cpheader();
$languages = tep_get_languages();

if (tep_not_null($action)) {
    $page_info = '';
    if (isset($HTTP_GET_VARS['option_page'])) $page_info .= 'option_page=' . $HTTP_GET_VARS['option_page'] . '&';
    if (isset($HTTP_GET_VARS['value_page'])) $page_info .= 'value_page=' . $HTTP_GET_VARS['value_page'] . '&';
    if (isset($HTTP_GET_VARS['attribute_page'])) $page_info .= 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] . '&';
    if (tep_not_null($page_info)) {
        $page_info = substr($page_info, 0, -1);
    }

    switch ($action) {
      case 'add_product_attributes':
         $db->query("insert into $table_products_attributes values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . ($value_price) . "', '" . ($price_prefix) . "')");

         if (DOWNLOAD_ENABLED == 'true') {
             $products_attributes_id = $db->insert_id();
             if (tep_not_null($products_attributes_filename)) {
                 $db->query("insert into $table_products_attributes_download values (" . (int)$products_attributes_id . ", '" . ($products_attributes_filename) . "', '" . ($products_attributes_maxdays) . "', '" . ($products_attributes_maxcount) . "')");
             }
         }
         tep_redirect(tep_href_link('admincp.php', 'act=products_attributes_add_p&'.$page_info));
      break;
     case 'update_product_attribute':
         $db->query("update $table_products_attributes set products_id = '" . (int)$products_id . "', options_id = '" . (int)$options_id . "', options_values_id = '" . (int)$values_id . "', options_values_price = '" . ($value_price) . "', price_prefix = '" . ($price_prefix) . "' where products_attributes_id = '" . (int)$attribute_id . "'");

         if (DOWNLOAD_ENABLED == 'true') {

            if (tep_not_null($products_attributes_filename)) {
                $db->query("replace into $table_products_attributes_download set products_attributes_id = '" . (int)$attribute_id . "', products_attributes_filename = '" . ($products_attributes_filename) . "', products_attributes_maxdays = '" .($products_attributes_maxdays) . "', products_attributes_maxcount = '" . ($products_attributes_maxcount) . "'");
            }
         }

         tep_redirect(tep_href_link('admincp.php', 'act=products_attributes_add_p&'.$page_info));
      break;
      case 'delete_attribute':
         $db->query("delete from $table_products_attributes where products_attributes_id = '" . (int)$attribute_id . "'");

         $db->query("delete from $table_products_attributes_download where products_attributes_id = '" . (int)$attribute_id . "'");

         tep_redirect(tep_href_link('admincp.php', 'act=products_attributes_add_p&'.$page_info));
      break;
   }
}elseif (tep_not_null($type)) {
   
	 switch($type){
      case 'delete_product_attribute':
          cpmsg('你确定要删除此商品属性吗?',tep_href_link('admincp.php', 'act=products_attributes_add_p&action=delete_attribute&attribute_id='.$attribute_id),'form');
      break;
      case 'update_attribute':
			    $query = $db->query("select pa.* from $table_products_attributes pa left join $table_products_description pd on pa.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' where products_attributes_id='$attribute_id' order by pd.products_name ");
          $attributes_values = $db->fetch_array($query);

          $products_name_only = tep_get_products_name($attributes_values['products_id']);
          $options_name = tep_options_name($attributes_values['options_id']);
          $values_name = tep_values_name($attributes_values['options_values_id']);
?>    
<form name="attributes" action="<?php echo tep_href_link('admincp.php', 'act=products_attributes_add_p&action=update_product_attribute&option_page=' . $option_page . '&value_page=' . $value_page . '&attribute_page=' . $attribute_page); ?>" method="post">
<table cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
<tr><td bgcolor="<?=BORDERCOLOR?>">
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="100%">
          <tr class="header">
            <td width="8%"><?php echo TABLE_HEADING_ID; ?></td>
            <td width="12%"><?php echo TABLE_HEADING_PRODUCT; ?></td>
            <td width="12%"><?php echo TABLE_HEADING_OPT_NAME; ?></td>
            <td><?php echo TABLE_HEADING_OPT_VALUE; ?></td>
            <td align="right" width="12%"><?php echo TABLE_HEADING_OPT_PRICE; ?></td>
            <td align="center" width="8%"><?php echo TABLE_HEADING_OPT_PRICE_PREFIX; ?></td>
          </tr>
          <tr bgcolor="<?=ALTBG2?>">
            <td><?php echo $attributes_values['products_attributes_id']; ?><input type="hidden" name="attribute_id" value="<?php echo $attributes_values['products_attributes_id']; ?>">&nbsp;</td>
            <td><select name="products_id">
<?php
          $products = $db->query("select p.products_id, pd.products_name from $table_products p, $table_products_description pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
          while($products_values = $db->fetch_array($products)) {
              if ($attributes_values['products_id'] == $products_values['products_id']) {
                 echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $products_values['products_name'] . '</option>';
              } else {
                  echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . '</option>';
              }
          } 
?>
            </select></td>
            <td><select name="options_id">
<?php
          $options = $db->query("select * from $table_products_options where language_id = '" . $languages_id . "' order by products_options_name");
          while($options_values = $db->fetch_array($options)) {
               if ($attributes_values['options_id'] == $options_values['products_options_id']) {
                   echo "\n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '" SELECTED>' . $options_values['products_options_name'] . '</option>';
               } else {
                   echo "\n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '">' . $options_values['products_options_name'] . '</option>';
               }
          } 
?>
            </select></td>
            <td class="smallText">&nbsp;<select name="values_id">
<?php
          $values = $db->query("select * from $table_products_options_values where language_id ='" . $languages_id . "' order by products_options_values_name");
          while($values_values = $db->fetch_array($values)) {
             if ($attributes_values['options_values_id'] == $values_values['products_options_values_id']) {
                 echo "\n" . '<option name="' . $values_values['products_options_values_name'] . '" value="' . $values_values['products_options_values_id'] . '" SELECTED>' . $values_values['products_options_values_name'] . '</option>';
             } else {
                 echo "\n" . '<option name="' . $values_values['products_options_values_name'] . '" value="' . $values_values['products_options_values_id'] . '">' . $values_values['products_options_values_name'] . '</option>';
             }
          } 
?>        
            </select></td>
            <td align="right"><input type="text" name="value_price" value="<?php echo $attributes_values['options_values_price']; ?>" size="6"></td>
            <td align="center"><input type="text" name="price_prefix" value="<?php echo $attributes_values['price_prefix']; ?>" size="2"></td>
          </tr>
<?php
          
				  if (DOWNLOAD_ENABLED == 'true') {
               $download_query_raw ="select products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount 
                              from $table_products_attributes_download 
                              where products_attributes_id='" . $attributes_values['products_attributes_id'] . "'";
               $download_query = $db->query($download_query_raw);
               if ($db->num_rows($download_query) > 0) {
                  $download = $db->fetch_array($download_query);
                  $products_attributes_filename = $download['products_attributes_filename'];
                  $products_attributes_maxdays  = $download['products_attributes_maxdays'];
                  $products_attributes_maxcount = $download['products_attributes_maxcount'];
               }
?>
          <tr bgcolor="<?=ALTBG2?>">
            <td>&nbsp;</td>
            <td colspan="5">
              <table>
                <tr>
                  <td><?php echo TABLE_HEADING_DOWNLOAD; ?>&nbsp;</td>
                  <td><?php echo TABLE_TEXT_FILENAME; ?></td>
                  <td><?php echo tep_draw_input_field('products_attributes_filename', $products_attributes_filename, 'size="15"'); ?>&nbsp;</td>
                  <td><?php echo TABLE_TEXT_MAX_DAYS; ?></td>
                  <td><?php echo tep_draw_input_field('products_attributes_maxdays', $products_attributes_maxdays, 'size="5"'); ?>&nbsp;</td>
                  <td><?php echo TABLE_TEXT_MAX_COUNT; ?></td>
                  <td><?php echo tep_draw_input_field('products_attributes_maxcount', $products_attributes_maxcount, 'size="5"'); ?>&nbsp;</td>
                </tr>
              </table>
            </td>
          </tr>
</table></td></tr></table>    
<br>

⌨️ 快捷键说明

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