2017-05-05 17:17:39 -06:00
< ? php
2017-12-16 14:25:31 -07:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http :// mozilla . org / MPL / 2.0 /. */
2017-05-05 17:17:39 -06:00
require_once __DIR__ . '/../required.php' ;
redirectifnotloggedin ();
//$tasks = $database->debug()->select('assigned_tasks', ['[>]tasks' => ['taskid' => 'taskid']], '*', ["AND" => ['assigned_tasks.userid' => $_SESSION['uid'], 'assigned_tasks.statusid' => [0, 1, 3, 4], '#taskassignedon[<=]' => 'NOW()'], "ORDER" => ['0 - taskdueby' => "DESC"]]);
$tasks = $database -> query ( " SELECT * FROM assigned_tasks LEFT JOIN tasks ON assigned_tasks.taskid = tasks.taskid WHERE assigned_tasks.userid = ' " . $_SESSION [ 'uid' ] . " ' AND assigned_tasks.statusid IN (0,1,3,4) AND taskassignedon <= NOW() AND tasks.deleted = 0 ORDER BY 0 - taskdueby DESC " ) -> fetchAll ();
if ( count ( $tasks ) > 0 ) {
foreach ( $tasks as $task ) {
if ( isset ( $_GET [ 'alone' ]) || ( isset ( $pageid ) && $pageid != " home " )) {
echo " <div class= \" col-xs-12 col-md-6 \" > " ;
}
$panelclass = 'panel-default' ;
if ( $task [ 'taskdueby' ] == null ) {
// This bit is just here to skip the rest of the branches if we need to
} else if ( strtotime ( $task [ 'taskdueby' ]) - time () < 0 ) { // deadline overdue
$panelclass = 'panel-danger' ;
} else if ( strtotime ( $task [ 'taskdueby' ]) - time () < 60 * 60 * 3 ) { // less than three hours
$panelclass = 'panel-warning' ;
} else if ( strtotime ( $task [ 'taskdueby' ]) - time () < 60 * 60 * 8 ) { // less than eight hours
$panelclass = 'panel-primary' ;
}
?>
< div class = 'panel <?php echo $panelclass ?>' >
< div class = 'panel-heading' >
< h3 class = 'panel-title' >< ? php echo $task [ 'tasktitle' ] ?>
< ? php
if ( $task [ 'statusid' ] == 1 ) {
?>
2017-05-06 00:23:31 -06:00
< span class = 'pull-right' >< i class = 'fa fa-fw fa-play' ></ i > < ? php lang ( " started " ) ?> </span>
< ? php
} else if ( $task [ 'statusid' ] == 3 ) {
?>
< span class = 'pull-right' >< i class = 'fa fa-fw fa-pause' ></ i > < ? php lang ( " paused " ) ?> </span>
< ? php
} else if ( $task [ 'statusid' ] == 4 ) {
?>
< span class = 'pull-right' >< i class = 'fa fa-fw fa-exclamation' ></ i > < ? php lang ( " problem " ) ?> </span>
2017-05-05 17:17:39 -06:00
< ? php
}
?>
</ h3 >
</ div >
2017-05-22 02:58:12 -06:00
< div class = 'panel-body task-description' >
2017-05-05 17:17:39 -06:00
< ? php echo $task [ 'taskdesc' ] ?>
</ div >
< div class = 'panel-footer' >
< div class = 'row' >
2017-05-06 00:23:31 -06:00
< div class = 'col-xs-12 col-sm-6 col-md-6 col-lg-5' >
2017-05-06 00:42:02 -06:00
< i class = 'fa fa-hourglass-start fa-fw' ></ i > < ? php lang2 ( " assigned on " , [ " date " => date ( " F j, Y, g:i a " , strtotime ( $task [ 'taskassignedon' ]))]) ?>
2017-05-05 17:17:39 -06:00
< br />
2017-05-13 14:30:24 -06:00
< i class = 'fa fa-hourglass-end fa-fw' ></ i > < ? php lang2 ( " due by " , [ " date " => ( $task [ 'taskdueby' ] > 0 ? date ( " F j, Y, g:i a " , strtotime ( $task [ 'taskdueby' ])) : lang ( " no due date " , false ))]) ?>
2017-05-06 00:42:02 -06:00
< ? php
if ( $task [ 'statusid' ] > 0 ) {
?>
< br />
< i class = 'fa fa-play fa-fw' ></ i > < ? php lang2 ( " started on " , [ " date " => date ( " F j, Y, g:i a " , strtotime ( $task [ 'starttime' ]))]) ?>
< ? php
}
?>
< ? php
if ( $task [ 'statusid' ] == 2 ) {
?>
< br />
< i class = 'fa fa-stop fa-fw' ></ i > < ? php lang2 ( " finished on " , [ " date " => date ( " F j, Y, g:i a " , strtotime ( $task [ 'endtime' ]))]) ?>
< ? php
}
?>
2017-05-05 17:17:39 -06:00
</ div >
2017-05-06 00:23:31 -06:00
< div class = 'col-xs-12 col-sm-6 col-md-6 col-lg-7' >
2017-05-05 17:17:39 -06:00
< ? php lang ( " actions " ) ?> :<br />
< ? php
if ( $task [ 'statusid' ] == 0 ) {
?>
2017-11-13 16:17:14 -07:00
< form
action = 'action.php'
method = 'POST'
data - taskid = " <?php echo $task['taskid'] ?> "
data - action = " start "
class = 'form-inline inblock task-btn' >
2017-05-05 17:17:39 -06:00
< input type = 'hidden' name = 'taskid' value = '<?php echo $task[' taskid '] ?>' />
< input type = 'hidden' name = 'action' value = 'start' />
2017-05-06 00:23:31 -06:00
< button type = 'submit' id = 'starttaskbtn<?php echo $task[' taskid '] ?>' class = 'btn btn-primary' >< i class = 'fa fa-fw fa-play' ></ i > < ? php lang ( " start " ) ?> </button>
2017-05-05 17:17:39 -06:00
</ form >
< ? php
} else if ( $task [ 'statusid' ] == 1 ) {
?>
2017-11-13 16:17:14 -07:00
< form
action = 'action.php'
method = 'POST'
data - taskid = " <?php echo $task['taskid'] ?> "
data - action = " finish "
class = 'form-inline inblock task-btn padleft-5px' >
2017-05-05 17:17:39 -06:00
< input type = 'hidden' name = 'taskid' value = '<?php echo $task[' taskid '] ?>' />
< input type = 'hidden' name = 'action' value = 'finish' />
< button type = 'submit' id = 'finishtaskbtn<?php echo $task[' taskid '] ?>' class = 'btn btn-success' >< i class = 'fa fa-stop' ></ i > < ? php lang ( " finish " ) ?> </button>
</ form >
2017-11-13 16:17:14 -07:00
< form
action = 'action.php'
method = 'POST'
data - taskid = " <?php echo $task['taskid'] ?> "
data - action = " pause "
class = 'form-inline inblock task-btn padleft-5px' >
2017-05-06 00:23:31 -06:00
< input type = 'hidden' name = 'taskid' value = '<?php echo $task[' taskid '] ?>' />
< input type = 'hidden' name = 'action' value = 'pause' />
< button type = 'submit' id = 'pausetaskbtn<?php echo $task[' taskid '] ?>' class = 'btn btn-warning' >< i class = 'fa fa-pause' ></ i > < ? php lang ( " pause " ) ?> </button>
</ form >
2017-11-13 16:17:14 -07:00
< form
action = 'action.php'
method = 'POST'
data - taskid = " <?php echo $task['taskid'] ?> "
data - action = " problem "
class = 'form-inline inblock task-btn padleft-5px' >
2017-05-06 00:23:31 -06:00
< input type = 'hidden' name = 'taskid' value = '<?php echo $task[' taskid '] ?>' />
< input type = 'hidden' name = 'action' value = 'problem' />
< button type = 'submit' id = 'problemtaskbtn<?php echo $task[' taskid '] ?>' class = 'btn btn-danger' >< i class = 'fa fa-exclamation' ></ i > < ? php lang ( " problem " ) ?> </button>
</ form >
< ? php
} else if ( $task [ 'statusid' ] == 3 || $task [ 'statusid' ] == 4 ) {
?>
2017-11-13 16:17:14 -07:00
< form
action = 'action.php'
method = 'POST'
data - taskid = " <?php echo $task['taskid'] ?> "
data - action = " resume "
class = 'form-inline inblock task-btn' >
2017-05-06 00:23:31 -06:00
< input type = 'hidden' name = 'taskid' value = '<?php echo $task[' taskid '] ?>' />
2017-05-06 00:42:02 -06:00
< input type = 'hidden' name = 'action' value = 'resume' />
< button type = 'submit' id = 'resumetaskbtn<?php echo $task[' taskid '] ?>' class = 'btn btn-primary' >< i class = 'fa fa-play' ></ i > < ? php lang ( " resume " ) ?> </button>
2017-05-06 00:23:31 -06:00
</ form >
2017-05-05 17:17:39 -06:00
< ? php
}
?>
</ div >
</ div >
</ div >
</ div >
< ? php
if ( isset ( $_GET [ 'alone' ]) || ( isset ( $pageid ) && $pageid != " home " )) {
echo " </div> " ;
}
}
} else {
if ( isset ( $_GET [ 'alone' ]) || ( isset ( $pageid ) && $pageid != " home " )) {
echo " <div class= \" col-xs-12 col-sm-6 col-md-4 col-sm-offset-3 col-md-offset-4 \" > " ;
}
echo " <div class='alert alert-success'><i class='fa fa-check'></i> " . lang ( " all caught up " , false ) . " </div> " ;
if ( isset ( $_GET [ 'alone' ]) || ( isset ( $pageid ) && $pageid != " home " )) {
echo " </div> " ;
}
}
?>
< ? php
if ( DEBUG ) {
var_dump ( $tasks );
}
?>