Skip to content

Commit

Permalink
ongoing draft for #20 Timeline view of tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerg committed May 13, 2014
1 parent a34a7c8 commit a0e3283
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 53 deletions.
52 changes: 11 additions & 41 deletions controllers/tickets_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,51 +86,21 @@ public function index($id = null, $order = "", $dir = true, $page = 1, $dim = 20
* view all tickets in a timeline view
*/

public function timeline($id = null, $order = "", $dir = true, $page = 1, $dim = 200) {
$conf = Configure::getInstance() ;
public function timeline ($id = null, $order = "", $dir = true, $page = 1, $dim = 200) {
$conf = Configure::getInstance() ;
$filter["object_type_id"] = array($conf->objectTypes['ticket']["id"]);
$filter["user_created"] = "";
$filter["Ticket.severity"] = (!empty($this->data['severity'])) ? $this->data['severity'] : "";
if(!empty($this->data['status'])) {
$filter["Ticket.ticket_status"] = array_keys($this->data['status']);
} else {
$ticketStatus = array_intersect($conf->ticketStatus, array("draft", "on"));
$filter["Ticket.ticket_status"] = array_keys($ticketStatus);
}
if(empty($this->data) || !empty($this->data['hide_status_off'])) {
$filter["status"] = "<> 'off'";
}

if (!empty($this->data['assigned_to'])) {
$filter["ObjectUser.switch"] = "assigned";
$filter["ObjectUser.user_id"] = $this->data['assigned_to'];
}

$filter["exp_resolution_date"] = "";
$filter["BEObject.user_created"] = (!empty($this->data['reporter'])) ? $this->data['reporter'] : "";
$filter["count_annotation"] = array("EditorNote");
$f = $filter;
$filter["count_annotation"] = array("Comment","EditorNote");
$this->paginatedList($id, $filter, $order, $dir, $page, $dim);
$this->loadCategories($filter["object_type_id"]);
$this->loadReporters();
$this->loadAssignedUsers();
if(!empty($this->data['status'])) {
$f["f_status"] = $this->data['status'];
}
if(!empty($this->data['reporter'])) {
$f["f_reporter"] = $this->data['reporter'];
}
if(!empty($this->data['severity'])) {
$f["f_severity"] = $this->data['severity'];
}
if(empty($this->data) || !empty($this->data['hide_status_off'])) {
$f["hide_status_off"] = "true";
}
if (!empty($this->data['assigned_to'])) {
$f["f_assigned_to"] = $this->data['assigned_to'];

foreach ($this->viewVars["objects"] as &$obj) {
$datetime1 = new DateTime($obj["created"]); //TODO date_start
$datetime2 = new DateTime($obj["modified"]); //TODO exp_resolution_date
$interval = $datetime1->diff($datetime2);
$obj["days"] = $interval->format('%a');
}
$this->set("filter",$f);
}
}


public function view($id = null) {
$this->viewObject($this->Ticket, $id);
Expand Down
4 changes: 4 additions & 0 deletions views/elements/menuleft.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
<li {if $method eq 'timeline'}class="on"{/if}>{$tr->link('Timeline', '/tickets/timeline')}</li>

<li {if $method eq 'categories'}class="on"{/if}>{$tr->link('Categories', '/tickets/categories')}</li>

{if $module_modify eq '1'}
<li><a href="{$html->url('/tickets/view')}">{t}Create new ticket{/t}</a></li>
{/if}

</ul>

<h1>{$method}</h1>

{$view->element("export")}

{if (!empty($method)) && $method eq "index"}
Expand Down
16 changes: 4 additions & 12 deletions views/elements/timeline.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@

<div style="width:640px">
{foreach from=$objects item=obj}

{$start=$obj.created|getUnixTimestamp}
{$end=$obj.modified|getUnixTimestamp}
{$delta=$end-$start}
{$days=$delta/86400}
<div class="flowticket" style="background-color:pink; width:{$days|ceil}%">
{$days|ceil}
{if $obj.days > 0}
<div class="flowticket" style="background-color:pink; width:{$obj.days*10}px">
ciao / {$obj.days}
</div>
{$start=0}
{$end=0}
{$delta=0}
{$days=0}
{/if}
{/foreach}
</div>


{dump var=$objects}

0 comments on commit a0e3283

Please sign in to comment.