Here is an addition to the PDA Interface to make it a little more useful on mobile devices when staff members are "in the field."
This modification adds the same "Attachments" section to a ticket post as is seen on the staff view ticket page.
INSTALLATION INSTRUCTIONS:
All modifications for this install are to the
/modules/tickets/pda_manage.php file.
STEP 1: add the code below directly beneath the line "echo $contents;"
PHP Code:
<?
$contents = &$val["contents"];
echo $contents;
//ADD ACCESS TO ATTACHMENTS FROM PDA SITE
if (count($val["attachments"]))
{
?><BR /><BR /><fieldset class="swiftfieldsetnopad"><legend><?=$_SWIFT["language"]["attachments"]?></legend><div class="navsub"><?
foreach ($val["attachments"] as $atkey=>$atval)
{
$extension = getFileExtension($atval["filename"]);
$mimedata = $mimelist[$extension];
if (!empty($mimedata[1]))
{
$icon = $mimedata[1];
} else {
$icon = "mimeico_blank.gif";
}
echo '<table width="100%"><tr>';
echo '<td><a href="index.php?_m=tickets&_a=ticketactions&ticketid='. intval($_ticket["ticketid"]) .'&action=attachment&attachmentid='. intval($atval["attachmentid"]) .'" target="_blank"><img src="'. $_SWIFT["themepath"] . $icon .'" border="0" align="absmiddle" /> '. $atval["filename"] .'</a> ('. formattedSize($atval["filesize"]) .')'.'</td>';
echo '<td align="right"><a href="index.php?_m=tickets&_a=ticketactions&ticketid='. intval($_ticket["ticketid"]) .'&action=delattachment&attachmentid='. intval($atval["attachmentid"]) .'"><img src="'. $_SWIFT["themepath"] . "icon_delete.gif" .'" border="0" align="middle"/></a></td>';
echo '</tr></table>';
}
?></div></fieldset><?
}
//END ADD ACCESS TO ATTACHMENTS FROM PDA SITE
STEP 2: Locate the "TICKET ACTIONS" section at the end of the file. We are going to add some code at the end. Replace the text at the end of the file with the following code, starting at the comment marker.
PHP Code:
// Couple of things, 1) If we have the ticket id then great, just redirect to it 2) If we have no ticket id, we need to redirect to ticket listing 3) Blah Blah Blah
if (!empty($_ticketid))
{
header("location: index.php?_m=tickets&_a=viewticket&ticketid=".intval($_ticketid));
} else {
header("location: index.php?_m=tickets&_a=manage&departmentid=".intval($_ticketobj->ticket["departmentid"])."&ticketstatusid=".intval($_ticketobj->ticket["ticketstatusid"]));
}
exit;
}
//BEGIN ADD ACCESS TO TICKET ATTACHMENTS ON PDA SITE
else if ($_GET["action"] == "attachment") {
$_ticketobj =& new TicketMain($_GET["ticketid"], true);
if (!$_ticketobj->ticket)
{
echo $_SWIFT["language"]["errorticketaccess"];
exit;
}
if (!empty($_GET["attachmentid"]))
{
require_once ("./modules/tickets/functions_attachments.php");
$_attach = new TicketAttachments();
$_attach->dispatchAttachment($_GET["attachmentid"], $_ticketobj->ticket["ticketid"]);
exit;
}
}
else if ($_GET["action"] == "delattachment") {
$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);
if (!$_ticketobj->ticket)
{
echo $_SWIFT["language"]["errorticketaccess"];
exit;
}
if ($_SWIFT["staff"]["tdeletepost"] != "0")
{
if (!empty($_GET["attachmentid"]))
{
// Are we using the filesytem or the database for storage?
$dbCore->query("SELECT `data` FROM `". TABLE_PREFIX ."settings` WHERE `vkey` = 'tickets_attachtype';");
$dbCore->nextRecord();
$AttachmentType = $dbCore->Record["data"];
if ($AttachmentType == 2) // This means we are using the filesystem
{
// Get filename
$dbCore->query("SELECT `storefilename` FROM `". TABLE_PREFIX ."attachments` WHERE `attachmentid` = '".intval($_GET["attachmentid"])."';");
$dbCore->nextRecord();
$StoreFilename = $dbCore->Record["storefilename"];
// Delete the file
unlink("./files/".$StoreFilename);
}
// Clean up the database
$dbCore->query("DELETE FROM `". TABLE_PREFIX ."attachments` WHERE `attachmentid` = '". intval($_GET["attachmentid"]) ."';"); // Delete attachment entry
$dbCore->query("DELETE * FROM `". TABLE_PREFIX ."attachmentchunks` WHERE `attachmentid` = '". intval($_GET["attachmentid"]) ."';"); // Delete attachment contents (if using database for storage; otherwise this does nothing)
// Clear hasattachments ticket indicator if there are no more attachments
$count = $dbCore->queryFetch("SELECT COUNT(*) AS count FROM `". TABLE_PREFIX ."attachments` WHERE `ticketid`= '". intval($_ticketobj->ticket["ticketid"]) ."';");
if(empty($count["count"]))
{
$dbCore->query("UPDATE `". TABLE_PREFIX ."tickets` SET `hasattachments` = '0' WHERE `ticketid` = '". intval($_ticketobj->ticket["ticketid"]) ."';"); // Delete attachment entry
}
}
header("location: index.php?_m=tickets&_a=viewticket&ticketid=". intval($_ticketobj->ticket["ticketid"]) ."&atdelconfirm=1");
}else {
header("location: index.php?_m=tickets&_a=viewticket&ticketid=". intval($_ticketobj->ticket["ticketid"]));
}
exit;
}
}
?>
STEP 3: PROFIT! $$$