currencies.php

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

PHP
243
字号
<?php
/*
  [SOOBIC!] admin/currencies.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."/currencies.php");

if ($action) {
    switch ($action) {
      case 'new':      
        $db->query("insert into $table_currencies (title, code, symbol_left, symbol_right, decimal_point, thousands_point,decimal_places,value) values ('" . $title . "', '" . $code. "', '" .$symbol_left. "', '" .$symbol_right. "', '" . $decimal_point. "', '" . $thousands_point. "', '" . $decimal_places. "', '" . $value. "')");
        if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) {
            $db->query("update $table_configuration set configuration_value = '" . ($code) . "' where configuration_key = 'DEFAULT_CURRENCY'");
        }
				updatecache("settings");
				tep_session_unregister('currency');
				cpmsg("Soolan!货币成功添加。",tep_href_link('admincp.php', 'act=currencies&page=' . $HTTP_GET_VARS['page'] )); 
        break;
      case 'save':

        $currency_id = $cID;
        
        $db->query("update $table_currencies set 
                                title = '$title',
                                code = '$code',
                                symbol_left = '$symbol_left',
                                symbol_right = '$symbol_right',
                                decimal_point = '$decimal_point',
                                thousands_point = '$thousands_point',
                                decimal_places = '$decimal_places',
                                value = $value
                      where currencies_id = '" . (int)$currency_id . "'");
        if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) {
            $db->query("update $table_configuration set configuration_value = '" . ($code) . "' where configuration_key = 'DEFAULT_CURRENCY'");
        }
				updatecache("settings");
				tep_session_unregister('currency');
				cpmsg("Soolan!货币成功编辑。",tep_href_link('admincp.php', 'act=currencies&page=' . $HTTP_GET_VARS['page'] )); 
      break;

      case 'delete':
        $currency_id = safe_input($HTTP_GET_VARS['cID']);
        $currency_query = $db->query("select currencies_id from $table_currencies where code = '" . DEFAULT_CURRENCY . "'");
        if ($currency['currencies_id'] == $currencies_id) {
             $db->query("update $table_configuration set configuration_value = '' where configuration_key = 'DEFAULT_CURRENCY'");
        }
				$db->query("delete from $table_currencies where currencies_id = '" . (int)$currency_id . "'");
        updatecache("settings");
				cpmsg("Soolan!货币成功删除。",tep_href_link('admincp.php', 'act=currencies&page=' . $HTTP_GET_VARS['page']));  
        break;
    }
}elseif($type){
    switch ($type) {
      case 'delete':
        $currencies_id = safe_input($HTTP_GET_VARS['cID']);

        $currency_query = $db->query("select code from $table_currencies where currencies_id = '" . (int)$currencies_id . "'");
        $currency = $db->fetch_array($currency_query);
        if ($currency['code'] == DEFAULT_CURRENCY) {
            cpmsg(ERROR_REMOVE_DEFAULT_CURRENCY,'');
        }
        cpmsg("本操作不可恢复,您确定要删除该货币?", tep_href_link('admincp.php', 'act=currencies&page=' . $HTTP_GET_VARS['page'].'&cID='.$cID.'&action=delete', 'NONSSL'), "form");
      break;
      case 'edit':
        $query = $db->query("select currencies_id, title, code, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, last_updated, value from $table_currencies  where currencies_id='".$cID."' ");
		    $currency = $db->fetch_array($query); 
		    $checked= (DEFAULT_CURRENCY == $currency['code'])  ? 'checked' : '';
?>

<form method="post" action="<?=tep_href_link('admincp.php','act=currencies')?>">
<input type="hidden" name="action" value="save">
<input type="hidden" name="cID" value="<?=$currency['currencies_id']?>">
<table cellspacing="0" cellpadding="0" border="0" width="80%" align="center">
<tr><td bgcolor="<?=BORDERCOLOR?>">
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="100%">

<tr class="header"><td colspan="2"><?=TEXT_INFO_HEADING_EDIT_CURRENCY?>--<?=TEXT_INFO_EDIT_INTRO?></td></tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td width="40%" align="right"><?=TEXT_INFO_CURRENCY_TITLE?></td>
<td align="left"><input type="text" size="50" name="title" value="<?=$currency['title']?>"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG1?>"><td width="40%" align="right"><?=TEXT_INFO_CURRENCY_CODE?></td>
<td align="left"><input type="text" size="50" name="code" value=<?=$currency['code']?>></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td width="40%" align="right"><?=TEXT_INFO_CURRENCY_SYMBOL_LEFT?></td>
<td align="left"><input type="text" size="50" name="symbol_left" value="<?=$currency['symbol_left']?>"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG1?>"><td width="40%" align="right"><?=TEXT_INFO_CURRENCY_SYMBOL_RIGHT?></td>
<td align="left"><input type="text" size="50" name="symbol_right" value=<?=$currency['symbol_right']?>></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_CURRENCY_DECIMAL_POINT?></td>
<td align="left"><input type="text" size="50" name="decimal_point" value=<?=$currency['decimal_point']?>></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_CURRENCY_THOUSANDS_POINT?></td>
<td align="left"><input type="text" size="50" name="thousands_point" value=<?=$currency['thousands_point']?>></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_CURRENCY_DECIMAL_PLACES?></td>
<td align="left"><input type="text" size="50" name="decimal_places" value=<?=$currency['decimal_places']?>></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_CURRENCY_VALUE?></td>
<td align="left"><input type="text" size="50" name="value" value=<?=$currency['value']?>></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_SET_AS_DEFAULT?></td>
<td align="left"><input type="checkbox" name="default" value="on" <?=$checked?>></td>
</tr>

</table></td></tr></table><br><center><?=$warning?>
<input type="submit" name="submit" value="提   交">&nbsp;
</center></form><br><br>


<?
      break;
      
    }

}else{
?>
<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><li>如果您接受外币购物,请设置汇率<br>
<li>设置方法:查询相关网站,获得外币的汇率,例如如果人民币为预设值,而美元对人民币的<br>汇率为8.2,则将人民币的币值设为1,而将美元的币值设为8.2</td>

</tr></table></td></tr></table></td></tr></table>

<?
   if($page) {
	     $start_limit = ($page - 1) * MAX_DISPLAY_SEARCH_RESULTS ;
   } else {
	     $start_limit = 0;
	     $page = 1;
   }
    
   $query = $db->query("SELECT COUNT(*) from $table_currencies ");
   $multipage = multi($db->result($query, 0), MAX_DISPLAY_SEARCH_RESULTS, $page, "admincp.php?act=currencies".($desc ? "&desc=$desc" : NULL));
    
   $query = $db->query("select currencies_id, title, code, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, last_updated, value from $table_currencies order by title LIMIT $start_limit, ".MAX_DISPLAY_SEARCH_RESULTS);
   $altbg1 = ALTBG1;
   $altbg2 = ALTBG2;
   $productcount = 0;
?>
<br><br>
<?=$multipage?> 
<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%">
<tr class="header"><td><?=TABLE_HEADING_CURRENCY_NAME?></td><td><?=TABLE_HEADING_CURRENCY_CODES?></td><td><?=TABLE_HEADING_CURRENCY_VALUE?></td><td width="20%" align="center"><?=TABLE_HEADING_ACTION?></td></tr>
<?
		while ($currency = $db->fetch_array($query)) {
         $bgno = $productcount++ % 2 + 1;
         //echo DEFAULT_CURRENCY;
?>
<tr bgcolor="<?=${'altbg'.$bgno}?>">
<? 
         if (DEFAULT_CURRENCY == $currency['code']) {
             echo '<td><b>' . $currency['title'] . ' (' . TEXT_DEFAULT . ')</b></td>' . "\n";
         } else {
             echo '<td>' . $currency['title'] . '</td>' . "\n";
         }
?>
<td><?=$currency['code']?></td><td><?=number_format($currency['value'], 8)?></td><td align="center"><a href="<?=tep_href_link('admincp.php', 'act=currencies&page=' . $HTTP_GET_VARS['page'] . '&type=edit&cID=' .$currency['currencies_id'])?>">详情</a>&nbsp;&nbsp;&nbsp;<a href="<?=tep_href_link('admincp.php', 'act=currencies&page=' . $HTTP_GET_VARS['page'] . '&type=delete&cID=' .$currency['currencies_id'])?>">删除</a></td></tr>
<?
    }
?>
</table></td></tr></table>   
<?=$multipage?>      
<br><br>

<form method="post" action="<?=tep_href_link('admincp.php','act=currencies')?>">
<input type="hidden" name="action" value="new">
<table cellspacing="0" cellpadding="0" border="0" width="80%" align="center">
<tr><td bgcolor="<?=BORDERCOLOR?>">
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="100%">
<tr class="header"><td colspan="7"><?=TEXT_INFO_INSERT_INTRO?></td></tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td width="40%" align="right"><?=TEXT_INFO_CURRENCY_TITLE?></td>
<td align="left"><input type="text" size="50" name="title"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG1?>"><td width="40%" align="right"><?=TEXT_INFO_CURRENCY_CODE?></td>
<td align="left"><input type="text" size="50" name="code"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td width="40%" align="right"><?=TEXT_INFO_CURRENCY_SYMBOL_LEFT?></td>
<td align="left"><input type="text" size="50" name="symbol_left"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG1?>"><td width="40%" align="right"><?=TEXT_INFO_CURRENCY_SYMBOL_RIGHT?></td>
<td align="left"><input type="text" size="50" name="symbol_right"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_CURRENCY_DECIMAL_POINT?></td>
<td align="left"><input type="text" size="50" name="decimal_point"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_CURRENCY_THOUSANDS_POINT?></td>
<td align="left"><input type="text" size="50" name="thousands_point"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_CURRENCY_DECIMAL_PLACES?></td>
<td align="left"><input type="text" size="50" name="decimal_places"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_CURRENCY_VALUE?></td>
<td align="left"><input type="text" size="50" name="value"></td>
</tr>

<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_INFO_SET_AS_DEFAULT?></td>
<td align="left"><input type="checkbox" name="default" value="on"></td>
</tr>

</table></td></tr></table><br><center><?=$warning?>
<input type="submit" name="submit" value="提   交">&nbsp;
</center></form><br><br>
    
<?}?>

⌨️ 快捷键说明

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