specials.php

来自「全新且完善的强大网上商店系统」· PHP 代码 · 共 215 行

PHP
215
字号
<?php
/*
  [SOOBIC!] admin/specials.php 

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

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

include ("admin/languages/".$language."/specials.php");

if ($action) {
  switch($action){
     case 'setflag':
        if ($flag == '1') {
            $db->query("update $table_specials set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$id . "'");
        } elseif ($flag == '0') {
            $db->query("update $table_specials set status = '0', date_status_change = now() where specials_id = '" . (int)$id . "'");
        }
				tep_redirect(tep_href_link('admincp.php', 'act=specials'.(isset($page) ? '&page=' . $page: '') . '&sID=' . $id, 'NONSSL'));
     break;
		 case 'new_specials':

        if (ereg("[0-9]%{1,}",$specials_price)) {
            $query = $db->query("select products_id, products_price from $table_products where products_id = '" . (int)$products_id . "'");
            $new_special_insert = $db->fetch_array($query);
            $products_price = $new_special_insert['products_price'];
            $specials_price = (($specials_price / 100) * $products_price);
        }

        $expires_date = '';
        if (isset($day) && isset($month) && isset($year)) {
          $expires_date = $year;
          $expires_date .= (strlen($month) == 1) ? '0' . $month : $month;
          $expires_date .= (strlen($day) == 1) ? '0' . $day : $day;
        }

        $db->query("insert into $table_specials (products_id, specials_new_products_price, specials_date_added, expires_date, status) values ('" . (int)$products_id . "', '" . safe_input($specials_price) . "', now(), '" . safe_input($expires_date) . "', '1')");
        cpmsg("Soobic!特价商品操作成功。",tep_href_link('admincp.php', 'act=specials&page='.$HTTP_GET_VARS['page'])); 
		 case 'edit_specials':
        $products_price = trim($products_price);
				$specials_price = (ereg("[0-9]%{1,}",$specials_price)) ? (($specials_price/100) * $products_price) : $specials_price;
        $expires_date = '';
        if (isset($day) && isset($month) && isset($year)) {
           $expires_date = $year;
           $expires_date .= (strlen($month) == 1) ? '0' . $month : $month;
           $expires_date .= (strlen($day) == 1) ? '0' . $day : $day;
        }

        $db->query("update $table_specials set specials_new_products_price = '" . addslashes($specials_price) . "', specials_last_modified = now(), expires_date = '" . addslashes($expires_date) . "' where specials_id = '" . (int)$specials_id . "'");
        cpmsg("Soobic! 特价商品操作成功。",tep_href_link('admincp.php', 'act=specials&page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials_id)); 
     break;
     case 'delete_specials': 
        $db->query("delete from $table_specials where specials_id = '" . (int)$HTTP_GET_VARS['sID']. "'");
		    cpmsg("Soobic! 特价商品删除成功。",tep_href_link('admincp.php', 'act=specials&page=' . $HTTP_GET_VARS['page'])); 
     break;     
     default:
  }
}elseif($type){

	switch($type){
     case 'delete_specials':
        cpmsg("本操作不可恢复,您确定要删除该特价商品?", tep_href_link('admincp.php', 'act=specials&page=' . $HTTP_GET_VARS['page'].'&sID='.$sID.'&action=delete_specials', 'NONSSL'), "form");
     break;
     case 'new_specials':
     case 'edit_specials':
?>

<link rel="stylesheet" type="text/css" href="./includes/javascript/calendar.css">
<script language="JavaScript" src="./includes/javascript/calendarcode.js"></script>
<div id="popupcalendar" class="text"></div>
<?
        $form_action = $type == 'edit_specials' ? 'edit_specials': 'new_specials';
        if ( ($type == 'edit_specials') && isset($HTTP_GET_VARS['sID']) ) {
            $query = $db->query("select p.products_id, pd.products_name, p.products_price, s.specials_new_products_price, s.expires_date from $table_products p, $table_products_description pd, $table_specials s where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id and s.specials_id = '" . (int)$HTTP_GET_VARS['sID'] . "'");
            @extract($db->fetch_array($query));
       }else {
            $specials_array = array();
            $specials_query = $db->query("select p.products_id from $table_products p, $table_specials s where s.products_id = p.products_id");
            while ($specials = $db->fetch_array($specials_query)){
                  $specials_array[] = $specials['products_id'];
            }
            $query = $db->query("select p.products_id, pd.products_name, p.products_price from $table_products p, $table_products_description pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");
            $select_string= '<select name="products_id">';
			         while ($products = $db->fetch_array($query)) {
                  if (!in_array($products['products_id'], $specials_array)) {
                     $select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . '(' . $currencies->format($products['products_price']) . ')</option>';
                  }
           }
       }
       $select_string.= '</select>';
?>


<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><?=SPECIALS_NOTICE?></td></tr>
<tr bgcolor="<?=ALTBG1?>"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr><td><?=TEXT_SPECIALS_PRICE_TIP;?></td> 
<td align="right"><input type="button" value="<?=IMAGE_BACK?>" onClick="history.go(-1);">&nbsp;</td>
</tr></table></td></tr></table></td></tr></table>
<br>

<form name="new_special" <?php echo 'action="' . tep_href_link('admincp.php', 'act=specials&info='.$info.'&sID='.$sID.'&action='.$form_action, 'NONSSL') . '"'; ?> method="post">
<input type="hidden" name="specials_id" value="<?=$HTTP_GET_VARS['sID'];?>">
<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 colspan="7"><?=HEADING_TITLE;?></td></tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_SPECIALS_PRODUCT;?></td>
<td bgcolor="<?=ALTBG2?>" align="left"><?php echo (isset($products_name)) ? $products_name . '&nbsp;&nbsp;(' . $currencies->format($products_price) . ')' : $select_string ; echo tep_draw_hidden_field('products_price', (isset($products_price) ? $products_price : '')); ?></td>
</tr>
<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_SPECIALS_SPECIAL_PRICE;?></td>
<td align="left" bgcolor="<?=ALTBG2?>"><?php echo tep_draw_input_field('specials_price', (isset($specials_new_products_price) ? $specials_new_products_price : '')); ?></td>
</tr>
<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_SPECIALS_EXPIRES_DATE;?></td>
<td bgcolor="<?=ALTBG2?>" align="left"><?php echo tep_draw_input_field('day', (isset($expires_date) ? substr($expires_date, 8, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('month', (isset($expires_date) ? substr($expires_date, 5, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('year', (isset($expires_date) ? substr($expires_date, 0, 4) : ''), 'size="4" maxlength="4" class="cal-TextBox"'); ?><a class="so-BtnLink" href="javascript:calClick();return false;" onmouseover="calSwapImg('BTN_date', 'img_Date_OVER',true);" onmouseout="calSwapImg('BTN_date', 'img_Date_UP',true);" onclick="calSwapImg('BTN_date', 'img_Date_DOWN');showCalendar('new_special','dteWhen','BTN_date');return false;"><img src="images/common/cal_date_up.gif" border="0" act="Calendar" align="absmiddle" name="BTN_date"></a></td>
</tr>

</table></td></tr></table>
<br><center><?=$warning?>
<input type="submit" name="submit" value="<?=SUBMIT?>">&nbsp;<input type="button" value="返 回" onClick="history.go(-1);">
</center></form><br><br>
<?
			 
		 break;
		 default:
  }
}else{

	 if($page) {
		  $start_limit = ($page - 1) * MAX_DISPLAY_SEARCH_RESULTS ;
	 } else {
		  $start_limit = 0;
		  $page = 1;
	 }
	 $query = $db->query("SELECT COUNT(*) FROM $table_specials order by products_id DESC");
	 $multipage = multi($db->result($query, 0), MAX_DISPLAY_SEARCH_RESULTS, $page, "admincp.php?act=specials&order=$order".($desc ? "&desc=$desc" : NULL));
   
?>  
 
<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><?=SPECIALS_NOTICE?></td></tr>
<tr bgcolor="<?=ALTBG1?>"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr><td></td>
<td align="right" class="bold"><?php echo '<a href="'.tep_href_link('admincp.php', 'act=specials&page=' . $HTTP_GET_VARS['page'] . '&type=new_specials').'">'.IMAGE_NEW_PRODUCT.'</a>'; ?>&nbsp;</td>
</tr></table></td></tr></table></td></tr></table>
<br>
<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?>" colspan="2">
<?=$multipage?></td></tr>
</table></td></tr></table>
<br>
<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 class="header" align="center">
<td><?=TABLE_HEADING_PRODUCTS; ?></td>
<td><?=TABLE_HEADING_PRODUCTS_PRICE; ?></td>
<td><?=TABLE_HEADING_STATUS; ?></td>
<td><?=TABLE_HEADING_ACTION; ?></td></tr>
<?
   $query = $db->query("select p.products_id, pd.products_name, p.products_price, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status from $table_products p, $table_specials s, $table_products_description pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id order by pd.products_name");
   while ($specials = $db->fetch_array($query)) {
       @extract($specials);//echo $currency;
?>
              <tr>  
								<td bgcolor="<?=ALTBG1?>"><?=$products_name; ?></td>
                <td bgcolor="<?=ALTBG1?>" align="center"><?php echo $currencies->format($products_price); ?><?php echo $currencies->format($specials_new_products_price); ?></td>
                <td bgcolor="<?=ALTBG1?>" align="center">
<?php
      if ($status == '1') {
          echo '<img src="./images/icons/icon_status_green.gif" border="0" alt="'.IMAGE_ICON_STATUS_GREEN.'" height="10" weight="10">&nbsp;&nbsp;<a href="' . tep_href_link('admincp.php', 'act=specials&action=setflag&flag=0&id=' . $specials['specials_id'], 'NONSSL') . '"><img src="./images/icons/icon_status_red_light.gif" border="0" alt="'.IMAGE_ICON_STATUS_RED_LIGHT.'" height="10" weight="10"></a>';
      } else {
          echo '<a href="' . tep_href_link('admincp.php', 'act=specials&action=setflag&flag=1&id=' . $specials['specials_id'], 'NONSSL') . '"><img src="./images/icons/icon_status_green_light.gif" border="0" alt="'.IMAGE_ICON_STATUS_GREEN_LIGHT.'" height="10" weight="10"></a>&nbsp;&nbsp;<img src="./images/icons/icon_status_red.gif" border="0" alt="'.IMAGE_ICON_STATUS_RED.'" height="10" weight="10">';
      }
?>								
								</td>
                <td bgcolor="<?=ALTBG2?>" align="center" width="15%">
								             <a href="<?echo tep_href_link("admincp.php", 'act=specials&type=edit_specials&page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials['specials_id']);?>">编辑</a>
								             <a href="<?echo tep_href_link("admincp.php", 'act=specials&type=delete_specials&page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials['specials_id']);?>">删除</a>
								</td>
              </tr>
<?php
   }
?>
</table></td></tr></table>
<br>
<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?>" colspan="2">
<?=$multipage?></td></tr>
</table></td></tr></table>

<?
}
?>

⌨️ 快捷键说明

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