Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

December 08, 2021, 06:23:28 AM

Login with username, password and session length
Members
  • Total Members: 3831
  • Latest: pulgoki
Stats
  • Total Posts: 192617
  • Total Topics: 21020
  • Online Today: 152
  • Online Ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 1
Guests: 41
Total: 42

Author Topic: [Block] SimpleDesk  (Read 6735 times)

0 Members and 1 Guest are viewing this topic.

Offline Sayaka Maizono

  • Beta Tester
  • *
  • Posts: 31
  • $("div.content:dd").hide();
[Block] SimpleDesk
« on: November 04, 2015, 04:30:32 PM »
SimpleDesk Block

SMF 2.0
SimpleDesk 2.0 Anatidae



Code: [Select]
<?php

/**
 * @block SimpleDesk
 * @author Rhode Fey (Sayaka Maizono)
 * @version 1.0.0
 * @for SimpleDesk 2.0.0
*/

global $context$modSettings$txt$sourcedir;

$txt['shd_not_installed'] = 'Simple Desk is not currently installed!';

if (!
file_exists($sourcedir '/sd_source/SimpleDesk.php'))
{
echo '
<span class="smalltext" style="color: red;">
$txt['shd_not_installed']  . '
</span>'
;

return;
}

if (empty(
$modSettings['helpdesk_active']) || !empty($modSettings['shd_maintenance_mode']))
{
echo '
<span class="smalltext" style="color: red;">
$txt['shd_inactive'] . '
</span>'
;

return;
}

require_once(
$sourcedir '/sd_source/Subs-SimpleDesk.php');
require_once(
$sourcedir '/sd_source/SimpleDesk-SSI.php');

$is_staff false;
$staff_members shd_members_allowed_to('shd_staff');

if (
in_array($context['user']['id'], $staff_members))
$is_staff true;

if (
$is_staff)
show_tickets();
else
show_own_tickets();

function 
show_tickets()
{
global $context$scripturl$settings$txt;

$number_to_show 6;

$assigned_tickets ssi_staffAssignedTickets($context['user']['id'], $number_to_show'array');
$remaining_tickets ssi_getSDTickets('hdt.id_member_assigned != {int:assigned} AND hdt.status != {int:closed}', array('assigned' => $context['user']['id'], 'closed' => 6), $number_to_show'hdt.status ASC''array');

$tickets array_merge($assigned_tickets$remaining_tickets);
$tickets array_slice($tickets0$number_to_show);

ksort($tickets);
$ticket_count count($tickets);
$count 0;

if (empty($tickets))
{
echo '
<span class="smalltext" style="color: red;">
$txt['shd_error_no_tickets'] . '
</span>'
;

return;
}

echo '
<table style="width: 100%">'
;

foreach ($tickets as $ticket)
{
if ($ticket['assigned']['id'] == $context['user']['id'])
{
$assigned true;
$icon '<img src="' $settings['default_images_url'] . '/simpledesk/assign.png" alt="Assigned to ' $context['user']['name'] . '" />';
}
else
{
$assigned false;
$icon '<img src="' $settings['default_images_url'] . '/simpledesk/unread.png" alt="Ticket" />';
}

echo '
<tr>
<td style="width: 24px; text-align: center;"><a href="' 
$ticket['href'] . '">' $icon '</a></td>
<td style="padding: 5px 0; vertical-align: bottom; '
$ticket_count != ++$count ' border-bottom: 1px dashed #AAA;' '''">';

echo '
<a href="' 
$scripturl '?action=helpdesk;sa=ticket;ticket=' $ticket['id'] . '">' $ticket['subject'] . '</a><br />';

echo '
<div style="padding-top: 3px; font-size: 9px">'
;

echo '
$txt['shd_ticket_status'] . ': ' $ticket['status_text'] . '<br />';

echo '
$txt['shd_ticket_urgency'] . ': ' $ticket['urgency_string'] . '<br />';

echo '
$txt['shd_ticket_started_by'] . ': ' $ticket['opener']['link'] . '<br />';

echo '
$ticket['start_time'] . '<br />';

echo '
</div>'
;

echo '
</td>
</tr>'
;
}

echo '
</table>'
;
}

function 
show_own_tickets()
{
global $context$scripturl$settings$txt;

$number_to_show 3;

$tickets ssi_userTickets($context['user']['id'], $number_to_show'array');

ksort($tickets);
$ticket_count count($tickets);
$count 0;

if (empty($tickets))
{
echo '
<span class="smalltext" style="color: red;">
$txt['shd_error_no_tickets'] . '
</span>'
;

return;
}

echo '
<table style="width: 100%">'
;

foreach ($tickets as $ticket)
{
$icon '<img src="' $settings['default_images_url'] . '/simpledesk/unread.png" alt="Ticket" />';

echo '
<tr>
<td style="width: 24px; text-align: center;"><a href="' 
$ticket['href'] . '">' $icon '</a></td>
<td style="padding: 5px 0; vertical-align: bottom; '
$ticket_count != ++$count ' border-bottom: 1px dashed #AAA;' '''">';

echo '
<a href="' 
$scripturl '?action=helpdesk;sa=ticket;ticket=' $ticket['id'] . '">' $ticket['subject'] . '</a><br />';

echo '
<div style="padding-top: 3px; font-size: 9px">'
;

echo '
$txt['shd_ticket_status'] . ': ' $ticket['status_text'] . '<br />';

echo '
$ticket['start_time'] . '<br />';

echo '
</div>'
;

echo '
</td>
</tr>'
;
}

echo '
</table>'
;
}

?>

Offline Freddy

  • Moderator
  • *
  • Posts: 1615
    • AiDreams
Re: [Block] SimpleDesk
« Reply #1 on: November 05, 2015, 10:19:17 AM »
Thanks Sayaka :)

Offline Ken.

  • Support Team
  • *
  • Posts: 4361
    • Our FamilyForum
Re: [Block] SimpleDesk
« Reply #2 on: November 05, 2015, 10:38:01 AM »
Freddy and Sayaka... If this block code works OK maybe we should post it in the Block Code Snippets Index boards?
" If everything seems under control, you’re not going fast enough." - Mario Andretti
Yesterday When I was Young.

Offline Sayaka Maizono

  • Beta Tester
  • *
  • Posts: 31
  • $("div.content:dd").hide();
Re: [Block] SimpleDesk
« Reply #3 on: November 05, 2015, 02:02:17 PM »
Freddy and Sayaka... If this block code works OK maybe we should post it in the Block Code Snippets Index boards?

It works okay for it needs to do, I have it running under both local and live environment. I made adaptations to SimpleDesk's SSI for SMF 2.1 here on GitHub so hopefully its pulled into their repository, I added functionality to be able to call departments since this block unfortunately doesn't honor department settings (since the SSI for SD does not even factor it).

I'm not sure if I have the permission to post there as a Newbie member. I'm restricted quite a lot right now, I think the restrictions will be lifted once I meet a certain number of posts but there hasn't been any sign of them lifting (as of yet). Maybe it's 10 posts like on SM.org

Offline lurkalot

  • Administrator
  • *
  • Posts: 7334
    • Camera Craniums
Re: [Block] SimpleDesk
« Reply #4 on: November 05, 2015, 04:08:11 PM »

I'm not sure if I have the permission to post there as a Newbie member. I'm restricted quite a lot right now, I think the restrictions will be lifted once I meet a certain number of posts but there hasn't been any sign of them lifting (as of yet). Maybe it's 10 posts like on SM.org

Sayaka Maizono, welcome to the TP support site.  Thanks for sharing that block code, I'm sure it will be very useful.  O0

Oh, and Just in case you missed it, I've sent you a PM. ;)

Offline Ken.

  • Support Team
  • *
  • Posts: 4361
    • Our FamilyForum
Re: [Block] SimpleDesk
« Reply #5 on: November 05, 2015, 04:51:20 PM »
Yes,  Sayaka, welcome to TinyPortal.  O0

BTW... we love code snippets.  ;)
" If everything seems under control, you’re not going fast enough." - Mario Andretti
Yesterday When I was Young.

Offline Skhilled

  • Beta Tester
  • *
  • Posts: 1178
  • Once you stop learning, you stop living!
    • Doc Skillz
Re: [Block] SimpleDesk
« Reply #6 on: November 06, 2015, 07:31:23 PM »
Great job, Sayaka!

Reading can seriously damage your ignorance!