Hi there,
In current version (1.6 RC4), we can only use one selection for email template from Admin Panel -> Settings -> Preferences. You can see that, there is a "Default Email Template:" directive, with drop-down combobox that Admin SHOULD select one of some selections.
In fact, only one record available that Admin can select from this directive. It is: "osTicket Default Template"!. Although if we add new record in email_template table, this drop-down combobox will still contains only one selection! :(
Now I made MOD Multiple Email Template, in order Admin can select another one from this selections after we add new record in email_template table.
Okay. Let's getting started now.
Open \include\staff\templates.inc.php, and FIND:
<?php
if(!defined('OSTADMININC') || !$thisuser->isadmin()) die('Access Denied');
$tpl=null;
$id=1;
$sql='SELECT * FROM '.EMAIL_TEMPLATE_TABLE.' WHERE tpl_id=1 AND cfg_id='.db_input($cfg->getId());
$tpl=Format:(($errors && $_POST)?$_POST(db_query($sql)));
?>
<div class="msg">Email Templates</div>
<table width="100%" border="0" cellspacing=0 cellpadding=0>
<form action="admin.php?t=templates" method="post">
<input type="hidden" name="t" value="templates">
<input type="hidden" name="do" value="update">
<input type="hidden" name="id" value="1">
REPLACE WITH:
<?php
if(!defined('OSTADMININC') || !$thisuser->isadmin()) die('Access Denied');
$tpl=null;
// MOD: Multiple Email Template, by Masino Sinaga, April 18, 2009
$id=db_input($cfg->getDefaultTemplateId());
$sql='SELECT * FROM '.EMAIL_TEMPLATE_TABLE.' WHERE tpl_id='.$id.' AND cfg_id='.db_input($cfg->getId());
$tpl=Format:(($errors && $_POST)?$_POST(db_query($sql)));
?>
<div class="msg">Email Templates: <?php echo $tpl; ?></div>
<table width="100%" border="0" cellspacing=0 cellpadding=0>
<form action="admin.php?t=templates" method="post">
<input type="hidden" name="t" value="templates">
<input type="hidden" name="do" value="update">
<input type="hidden" name="id" value="<?php echo ($id); ?>">
<?php // MOD: Multiple Email Template, by Masino Sinaga, April 18, 2009 ?>
Open file \scp\admin.php, FIND:
' WHERE tpl_id='.db_input($_POST);
REPLACE WITH:
' WHERE tpl_id='.db_input($_POST).' AND cfg_id='.db_input($cfg->getId()).'';
// MOD: Multiple Email Template, by Masino Sinaga, April 18, 2009
Open file \include\staff\preference.inc.php, FIND:
$templates=db_query('SELECT tpl_id,name FROM '.EMAIL_TEMPLATE_TABLE.' WHERE tpl_id=1 AND cfg_id='.db_input($cfg->getId()));
REPLACE WITH:
// MOD: Multiple Email Template, by Masino Sinaga, April 18, 2009
$templates=db_query('SELECT tpl_id,name FROM '.EMAIL_TEMPLATE_TABLE.' WHERE cfg_id='.db_input($cfg->getId()));
Now, we will see the effect. Please follow these three steps:
First, Add a new record in email_template table, with different name template that already exists in that table. Please make sure in "cfg_id" field the value = 1 whereas autonumber value in "tpl_id"; in this case the value of "tpl_id" = 2. Enter the different name in "name" field, i.e: "Another Template One".
Second, Go to Admin Panel -> Settings -> Preferences. You should now have another selections in "Default Email Template:" drop-down. Tarraaa... now we have "Another Template One" selection. Select this new item, and save this new setting by clicking on "Save Changes" button.
Third, Go to Admin Panel -> Emails -> Templates. Now, you should see that the name of this template is: "Email Template: Another Template One". Each time you want to use/change to another template, you have to go first to Admin Panel -> Settings -> Preferences, then change default setting from "Default Email Template:" directive, save the new setting, then goto Admin Panel -> Emails -> Templates.
That's all, everyone. I know some of you need list of email template to make easy for editing. But I still don't have much time to do this.
Hope this helpful for you. Have a nice code, and Cheers! :)
Best regards,
Masino Sinaga