Hello, all,
I am currently modifying one of our template pages, specifically
submitdepartmentlist. I want to be able to create my own radio buttons from the available departments. Creating the radio buttons is no problem, but getting the actual data from the database is causing issues.
Instead of passwords, our users enter their serial number. The first four digits of the serial number are used to determine which department their ticket goes to.
The problem I'm having is actually finding out which deparment our user should see. I have created a giant switch statement to do this, but I don't know how to call it from the template page. I inserted PHP between "<{...}>" but that is apprently only for calling variables. Thus, I created a JavaScript version, but when I use "javascript
:myFunction()" it doesn't actually get called and the text shows up. Please see my code below for clarification. :b (Certain variables have been changed to protect my company's privacy.)
HTML Code:
<{displaytemplate name="header"}>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td align="left" valign="top">
<form name="submitticket" method="post" action="<{$basepath}>">
<fieldset class="swiftfieldset">
<legend><{$language[selectdepartment]}></legend>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<!-- <{foreach key=key value=item from=$ticketdepartments}>
<tr>
<td width="1" align="left" valign="top" class="row2"><label for="departmentid[<{$item[departmentid]}>]"><input type="radio" name="departmentid" id="departmentid[<{$item[departmentid]}>]" value="<{$item[departmentid]}>"<{if $tgroup[departmentid] == $item[departmentid]}> checked<{/if}>></label></td>
<td><span class="smalltext"><label for="departmentid[<{$item[departmentid]}>]" style="CURSOR: pointer;"><{$item[title]}></label></span></td>
</tr>
<{/foreach}>
-->
<script language="JavaScript">
/**Returns an array index for $ticketdepartments.
@param serial The serial number for the client's software.
@param language The languageid from the client database.
@returns langid The department to which the client should submit his/her tickets.
*/
function batchSelect(serial, language)
{
var lm_product = "NOTHING";
var email = ouremail@domain.com;
var SerialNumber = serial.substring(0, 4);
var langid = -1;
//shortened for simplicity
switch($SerialNumber)
{
case 100:
lm_product="our product";
break;
case 101:
lm_product="our product";
break;
case 102:
lm_product="our product";
email="affiliate1@domain.fr";
break;
case 103:
lm_product="our product";
email="affiliate2@domain.de";
break;
case 107:
lm_product="our product";
email="affiliate3@domain.co.uk";
break;
case 108:
lm_product="our product";
email="affiliate4@domain.nl";
break;
case 110:
lm_product="our product";
email="affiliate5@domain.it";
break;
case 111:
lm_product="ourproduct";
email="affiliate6@domain.es";
break;
case 113:
lm_product="our product";
email="affiliate7@domain.com.au";
break;
}//end switch
if (email == "affiliate1@domain.fr")
{
langid = 3; //affiliate, French
}
else if (email == "affiliate2@domain.de")
{
langid = 4; //affiliate, German
}
else if (email == "affiliate4@domain.nl")
{
langid = 5; //affiliate, Dutch
}
else if (email == "affiliate6@domain.es")
{
langid = 6; //affiliate, Spanish
}
else if (email == "affiliate5@domain.it")
{
langid = 7; //affiliate, Italian
}
else if (email == "affiliate3@domain.co.uk" || email == "affiliate7@domain.com.au")
{
langid = 8; //affiliate, English
}
else
{
if (language == 1)
{
langid = 1; //us, English
}
else if (language == 2)
{
langid = 2; //us, French
}//end if-else if
}//end if...else
return langid;
}//end batchSelect
</script>
<tr>
<td width="1" align="left" valign="top" class="row2">
<{$ticketdepartments[1][departmentid]}> <!--works - shows "1"-->
<{$ticketdepartments[1][title]}> <!--works - shows "Support (us)"-->
<{$ticketdepartments[$langid][departmentid]}>
<{$ticketdepartments[$langid][title]}>
<{$ticketdepartments[javascript:batchSelect($_USER[userpasswordtxt], $_USER[languageid])][departmentid]}> <!-- outputs "ArrayjavascriptbatchSelect100-xxx-xx1departmentid" (100-xxx-xx = serial, 1 = language) -->
<{$ticketdepartments[javascript:batchSelect($_USER[userpasswordtxt], $_USER[languageid])][title]}>
<label for="departmentid[<{$ticketdepartments[$langid][departmentid]}>]"><input type="radio" name="departmentid" id="departmentid[<{$ticketdepartments[$langid][departmentid]}>]" value="<{$ticketdepartments[$langid][departmentid]}>" checked></label></td>
<td><span class="smalltext"><label for="departmentid[<{$ticketdepartments[$langid][departmentid]}>]" style="CURSOR: pointer;">Custom: <{$ticketdepartments[$langid][title]}></label></span></td>
</tr>
</table>
</fieldset>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td><input name="submit" type="submit" class="bluebutton" value="<{$language[tcknext]}>"> <input name="reset" type="reset" class="orangebutton" value="<{$language[treset]}>"></td>
</tr>
</table>
<input type="hidden" name="_m" value="tickets">
<input type="hidden" name="_a" value="submit">
<input type="hidden" name="step" value="1">
<{$formextension}>
</form>
</td><td width="5"><img src="<{$themepath}>space.gif" width="5" height="1"></td></tr>
</table>
<{displaytemplate name="footer"}> Any ideas on how to do this would be greatly appreciated...
... Mike.