View Single Post
  #1  
Old 06-25-2009, 09:43 AM
 
necroflux necroflux is offline
 

Advanced Member
  
Join Date: Feb 2009
Posts: 47
 

Default At long last - edit Gift Certificate amounts and codes from your admin panel

This nice little elegant mod will allow you to add value back to a Gift Certificate when necessary, or even change the code itself if you'd like to use a custom Gift Certificate code.

It's safe too because it requires entering "edit mode" before you can change any of these values, lessening the probability of an accidental edit.

First, in /admin/giftcerts.php, BEFORE:

Code:
$expired_condition=($config["Gift_Certificates"]["gc_show_expired"]=="Y"?"":" and status!='E'");

Add (right after the else):

Code:
if($_GET["mode"]=="edit_values") { $smarty->assign("edit_values", true); }

In /skin1/modules/Gift_Certificates/gc_admin.tpl, after:

Code:
<form name="gcform" action="giftcerts.php" method="post"> <input type="hidden" name="mode" value="" /> <input type="hidden" name="tpl_file" value="" /> {if $giftcerts ne ""}

Add:

Code:
{if $edit_values} <div style="float:right"><a href="/cart/admin/giftcerts.php">Leave GC code/amount edit mode</a></div> {else} <div style="float:right"><a href="/cart/admin/giftcerts.php?mode=edit_values">Change GC code/amount</a></div> {/if}

Find:

Code:
<td><a href="giftcerts.php?mode=modify_gc&amp;gcid={$giftcerts[gc_num].gcid}">{$giftcerts[gc_num].gcid}</a>{if $giftcerts[gc_num].orderid} &nbsp;<img src="{$ImagesDir}/lock.gif" />{/if}</td>

And replace it with:
Code:
{if $edit_values} <td><input type="text" name="gcid-{$giftcerts[gc_num].gcid}" value="{$giftcerts[gc_num].gcid}" style="width:120px"></td> {else} <td><a href="giftcerts.php?mode=modify_gc&amp;gcid={$giftcerts[gc_num].gcid}">{$giftcerts[gc_num].gcid}</a>{if $giftcerts[gc_num].orderid} &nbsp;<img src="{$ImagesDir}/lock.gif" />{/if}</td> {/if}

Finally find:

Code:
{include file="currency.tpl" value=$giftcerts[gc_num].debit}/{include file="currency.tpl" value=$giftcerts[gc_num].amount}

And replace it with:

Code:
{if $edit_values} <input type="text" name="debit-{$giftcerts[gc_num].gcid}" value="{$giftcerts[gc_num].debit}" style="width:60px"> /{include file="currency.tpl" value=$giftcerts[gc_num].amount} {else} {include file="currency.tpl" value=$giftcerts[gc_num].debit}/{include file="currency.tpl" value=$giftcerts[gc_num].amount} {/if}

For appearances sake, I also prefer to change (on line 180):

Code:
<td align="center" nowrap="nowrap">

To:

Code:
<td align="left" nowrap="nowrap" style="padding-left:5px">
__________________
-----------------
X-cart version 4.2.1
Reply With Quote