Skip to content

Commit

Permalink
Hardcoded statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
Micke1101 committed Apr 13, 2017
1 parent ed91216 commit 116d3f5
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/class.nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ function getNavLinks(){
$navs['tickets']=array('desc'=>sprintf(__('Tickets (%d)'),$user->getNumTickets($user->canSeeOrgTickets())),
'href'=>'tickets.php',
'title'=>__('Show all tickets'));
if($user->canSeeOrgTickets()){
$navs['requests']=array('desc'=>sprintf(__('Requests (%d)'),$user->getNumTickets($user->canSeeOrgTickets())),
'href'=>'requests.php',
'title'=>__('Show all requests'));
}
} else {
$navs['tickets']=array('desc'=>__('View Ticket Thread'),
'href'=>sprintf('tickets.php?id=%d',$user->getTicketId()),
Expand Down
127 changes: 127 additions & 0 deletions include/client/requests.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php
if(!defined('OSTCLIENTINC') || !is_object($thisclient) || !$thisclient->isValid() || !$thisclient->canSeeOrgTickets()) die('Access Denied');

$tickets = Ticket::objects();

$qs = array();
$status=null;

$sortOptions=array('id'=>'number', 'subject'=>'cdata__subject',
'status'=>'status__name', 'dept'=>'dept__name','date'=>'created');

$basic_filter = Ticket::objects();
$basic_filter->filter(array('status' => 8));

This comment has been minimized.

Copy link
@Micke1101

Micke1101 Apr 13, 2017

Author Owner

8 is the id of the status that is waiting for approval.

This comment has been minimized.

Copy link
@Micke1101

Micke1101 Apr 17, 2017

Author Owner

Replaced with settings page


$visibility = $basic_filter->copy()
->values_flat('ticket_id')
->filter(array('user_id' => $thisclient->getId()))
->union($basic_filter->copy()
->values_flat('ticket_id')
->filter(array('thread__collaborators__user_id' => $thisclient->getId()))
, false);

$visibility = $visibility->union(
$basic_filter->copy()->values_flat('ticket_id')
->filter(array('user__org_id' => $thisclient->getOrgId()))
, false);

$tickets->distinct('ticket_id');

$total=$visibility->count();
$page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
$pageNav=new Pagenate($total, $page, PAGE_LIMIT);
$qstr = '&amp;'. Http::build_query($qs);
$pageNav->setURL('requests.php', $qs);
$tickets->filter(array('ticket_id__in' => $visibility));
$pageNav->paginate($tickets);

$showing =$total ? $pageNav->showing() : "";
if(!$results_type)
{
$results_type=ucfirst($status).' '.__('Requests');
}
$showing.=($status)?(' '.$results_type):' '.__('All Requests');

$tickets->values(
'ticket_id', 'number', 'created', 'isanswered', 'source', 'status_id',
'status__state', 'status__name', 'cdata__subject', 'dept_id',
'dept__name', 'dept__ispublic', 'user__name'
);

?>

<h1 style="margin:10px 0">
<a href="<?php echo Format::htmlchars($_SERVER['REQUEST_URI']); ?>"
><i class="refresh icon-refresh"></i>
<?php echo __('Requests'); ?>
</a>
</h1>
<table id="ticketTable" width="800" border="0" cellspacing="0" cellpadding="0">
<caption><?php echo $showing; ?></caption>
<thead>
<tr>
<th nowrap>
<?php echo __('Ticket #');?>
</th>
<th width="100">
<?php echo __('Create Date');?>
</th>
<th width="120">
<?php echo __('User');?>
</th>
<th width="300">
<?php echo __('Subject');?>
</th>
<th width="70">
<?php echo __('Approve');?>
</th>
<th width="70">
<?php echo __('Deny');?>
</th>
</tr>
</thead>
<tbody>
<?php
$subject_field = TicketForm::objects()->one()->getField('subject');
if ($tickets->exists(true)) {
foreach ($tickets as $T) {
$subject = $subject_field->display(
$subject_field->to_php($T['cdata__subject']) ?: $T['cdata__subject']
);
$user = $T['user__name'];
if (false) // XXX: Reimplement attachment count support
$subject.=' &nbsp;&nbsp;<span class="Icon file"></span>';

$ticketNumber=$T['number'];
if($T['isanswered'] && !strcasecmp($T['status__state'], 'open')) {
$subject="<b>$subject</b>";
$ticketNumber="<b>$ticketNumber</b>";
}
?>
<tr id="<?php echo $T['ticket_id']; ?>">
<td>
<a class="Icon <?php echo strtolower($T['source']); ?>Ticket"
href="tickets.php?id=<?php echo $T['ticket_id']; ?>"><?php echo $ticketNumber; ?></a>
</td>
<td><?php echo Format::date($T['created']); ?></td>
<td><?php echo $user; ?></td>
<td>
<div style="max-height: 1.2em; max-width: 320px;" class="link truncate" href="tickets.php?id=<?php echo $T['ticket_id']; ?>"><?php echo $subject; ?></div>
</td>
<td><a href="requests.php?id=<?php echo $T['ticket_id']; ?>&change=approved">Approve</a></td>
<td><a href="requests.php?id=<?php echo $T['ticket_id']; ?>&change=denied">Deny</a></td>
</tr>
<?php
}

} else {
echo '<tr><td colspan="5">'.__('Your query did not match any records').'</td></tr>';
}
?>
</tbody>
</table>
<?php
if ($total) {
echo '<div>&nbsp;'.__('Page').':'.$pageNav->getPageLinks().'&nbsp;</div>';
}
?>
32 changes: 32 additions & 0 deletions requests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
require('secure.inc.php');
if(!is_object($thisclient) || !$thisclient->isValid() || !$thisclient->canSeeOrgTickets()) die('Access denied'); //Double check again.

require_once(INCLUDE_DIR.'class.ticket.php');
require_once(INCLUDE_DIR.'class.json.php');
$ticket=null;
global $cfg;
if($_REQUEST['id'] && $_REQUEST['change']) {
if (!($ticket = Ticket::lookup($_REQUEST['id']))) {
$errors['err']=__('Unknown or invalid ticket ID.');
} elseif(!$ticket->checkUserAccess($thisclient)) {
$errors['err']=__('Unknown or invalid ticket ID.');
$ticket=null;
}
if($ticket){
if(strtolower($_REQUEST['change']) == 'approved'){
$ticket->setStatusId(9);

This comment has been minimized.

Copy link
@Micke1101

Micke1101 Apr 13, 2017

Author Owner

9 is the id of the status that a ticket gets when it gets approved.

This comment has been minimized.

Copy link
@Micke1101

Micke1101 Apr 17, 2017

Author Owner

Replaced with settings page

} elseif(strtolower($_REQUEST['change']) == 'denied'){
$ticket->setStatusId(10);

This comment has been minimized.

Copy link
@Micke1101

Micke1101 Apr 13, 2017

Author Owner

10 is the id of the status that a ticket gets when it gets denied.

This comment has been minimized.

Copy link
@Micke1101

Micke1101 Apr 17, 2017

Author Owner

Replaced with settings page

} else {
$errors['err']=__('Invalid change.');
$ticket=null;
}
}
}

$nav->setActiveNav('requests');
include(CLIENTINC_DIR.'header.inc.php');
include(CLIENTINC_DIR.'requests.inc.php');
include(CLIENTINC_DIR.'footer.inc.php');
?>

1 comment on commit 116d3f5

@mfmajor
Copy link

@mfmajor mfmajor commented on 116d3f5 Jan 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Mike, in the latest version ( v1.10.4 ), this one doesnt have requests.inc.php and the file requests.php is in another folder, do you have planned any review to this files.
Thanks.

Please sign in to comment.