2012-01-20 12:01:02 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
2012-01-26 09:33:01 -04:00
|
|
|
* Home controller
|
|
|
|
|
*
|
2012-01-20 12:01:02 -04:00
|
|
|
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
* @inherits Controller
|
|
|
|
|
* @access public
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class Home extends Controller
|
|
|
|
|
{
|
|
|
|
|
private $userID;
|
|
|
|
|
private $userName;
|
|
|
|
|
private $userFullName;
|
|
|
|
|
private $userRolName;
|
2012-01-31 18:45:30 -04:00
|
|
|
private $userUxType;
|
2012-01-20 12:01:02 -04:00
|
|
|
|
2012-02-01 17:28:30 -04:00
|
|
|
private $appListStart = 0;
|
|
|
|
|
private $appListLimit = 15;
|
|
|
|
|
|
2012-01-20 12:01:02 -04:00
|
|
|
public function __construct()
|
|
|
|
|
{
|
2012-01-31 18:45:30 -04:00
|
|
|
// setting as using simplified.
|
|
|
|
|
$_SESSION['current_ux'] = 'SIMPLIFIED';
|
|
|
|
|
|
|
|
|
|
// getting the ux type from user o group conf.
|
|
|
|
|
$this->userUxType = isset($_SESSION['user_experience'])? $_SESSION['user_experience']: $_SESSION['current_ux'];
|
|
|
|
|
|
2012-01-20 12:01:02 -04:00
|
|
|
if (isset($_SESSION['USER_LOGGED']) && !empty($_SESSION['USER_LOGGED'])) {
|
|
|
|
|
$this->userID = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : null;
|
|
|
|
|
$this->userName = isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : '';
|
|
|
|
|
$this->userFullName = isset($_SESSION['USR_FULLNAME']) ? $_SESSION['USR_FULLNAME'] : '';
|
|
|
|
|
$this->userRolName = isset($_SESSION['USR_ROLENAME']) ? $_SESSION['USR_ROLENAME'] : '';
|
|
|
|
|
}
|
2012-01-31 18:45:30 -04:00
|
|
|
//g::pr($_SESSION); die;
|
2012-01-20 12:01:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* getting default list
|
|
|
|
|
* @param string $httpData (opional)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function index($httpData)
|
|
|
|
|
{
|
|
|
|
|
G::LoadClass('process');
|
|
|
|
|
G::LoadClass('case');
|
|
|
|
|
|
|
|
|
|
$process = new Process();
|
|
|
|
|
$case = new Cases();
|
|
|
|
|
|
|
|
|
|
//Get ProcessStatistics Info
|
|
|
|
|
$start = 0;
|
|
|
|
|
$limit = '';
|
|
|
|
|
|
|
|
|
|
$proData = $process->getAllProcesses($start, $limit);
|
|
|
|
|
$processList = $case->getStartCasesPerType ( $_SESSION ['USER_LOGGED'], 'category' );
|
|
|
|
|
unset($processList[0]);
|
|
|
|
|
|
|
|
|
|
$this->setView('home/index');
|
|
|
|
|
$this->setVar('usrUid', $this->userID);
|
|
|
|
|
$this->setVar('userName', $this->userName);
|
|
|
|
|
$this->setVar('processList', $processList);
|
2012-01-26 09:33:01 -04:00
|
|
|
$this->setVar('canStartCase', $case->canStartCase($_SESSION ['USER_LOGGED']));
|
2012-01-31 18:45:30 -04:00
|
|
|
$this->setVar('userUxType', $this->userUxType);
|
2012-01-20 12:01:02 -04:00
|
|
|
|
|
|
|
|
G::RenderPage('publish', 'mvc');
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-26 09:33:01 -04:00
|
|
|
public function appList($httpData)
|
2012-02-01 17:28:30 -04:00
|
|
|
{
|
2012-02-01 17:59:27 -04:00
|
|
|
require_once ( "classes/model/AppNotes.php" );
|
|
|
|
|
$appNotes = new AppNotes();
|
|
|
|
|
|
2012-02-01 17:28:30 -04:00
|
|
|
$httpData->t = isset($httpData->t)? $httpData->t : 'in';
|
|
|
|
|
$title = $httpData->t != 'draft' ? 'My Inbox' : 'My Drafts';
|
|
|
|
|
$action = $httpData->t != 'draft' ? 'todo' : 'draft';
|
2012-02-01 17:59:27 -04:00
|
|
|
|
|
|
|
|
$notesStart = 0;
|
|
|
|
|
$notesLimit = 4;
|
|
|
|
|
|
2012-02-01 17:28:30 -04:00
|
|
|
//$cases = self::getAppList($httpData->t, $this->appListStart, $this->appListLimit);
|
|
|
|
|
|
|
|
|
|
G::LoadClass('applications');
|
|
|
|
|
$apps = new Applications();
|
|
|
|
|
$cases = $apps->getAll($this->appListStart, $this->appListLimit, $action);
|
2012-02-01 17:59:27 -04:00
|
|
|
|
|
|
|
|
foreach ($cases['data'] as $i => $row) {
|
|
|
|
|
$notes = $appNotes->getNotesList($row['APP_UID'], $this->userID, $notesStart, $notesLimit);
|
|
|
|
|
$notes = $notes['array'];
|
|
|
|
|
|
|
|
|
|
$cases['data'][$i]['NOTES_COUNT'] = $notes['totalCount'];
|
|
|
|
|
$cases['data'][$i]['NOTES_LIST'] = $notes['notes'];
|
|
|
|
|
}
|
2012-02-01 17:28:30 -04:00
|
|
|
|
|
|
|
|
// settings html template
|
|
|
|
|
$this->setView('home/appList');
|
|
|
|
|
|
|
|
|
|
// settings vars and rendering
|
|
|
|
|
$this->setVar('cases', $cases['data']);
|
|
|
|
|
$this->setVar('cases_count', $cases['totalCount']);
|
|
|
|
|
$this->setVar('title', $title);
|
|
|
|
|
$this->setVar('appListStart', $this->appListLimit);
|
2012-02-01 17:59:27 -04:00
|
|
|
$this->setVar('appListLimit', 10);
|
|
|
|
|
$this->setVar('listType', $httpData->t);
|
2012-02-01 17:28:30 -04:00
|
|
|
|
|
|
|
|
G::RenderPage('publish', 'mvc');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getApps($httpData)
|
|
|
|
|
{
|
|
|
|
|
G::LoadClass('applications');
|
|
|
|
|
$apps = new Applications();
|
2012-02-01 17:59:27 -04:00
|
|
|
|
|
|
|
|
require_once ( "classes/model/AppNotes.php" );
|
|
|
|
|
$appNotes = new AppNotes();
|
|
|
|
|
|
|
|
|
|
$notesStart = 0;
|
|
|
|
|
$notesLimit = 4;
|
|
|
|
|
|
|
|
|
|
$action = $httpData->t != 'draft' ? 'todo' : 'draft';
|
|
|
|
|
|
|
|
|
|
$cases = $apps->getAll($httpData->start, $httpData->limit, $action);
|
|
|
|
|
|
|
|
|
|
foreach ($cases['data'] as $i => $row) {
|
|
|
|
|
$notes = $appNotes->getNotesList($row['APP_UID'], $this->userID, $notesStart, $notesLimit);
|
|
|
|
|
$notes = $notes['array'];
|
|
|
|
|
|
|
|
|
|
$cases['data'][$i]['NOTES_COUNT'] = $notes['totalCount'];
|
|
|
|
|
$cases['data'][$i]['NOTES_LIST'] = $notes['notes'];
|
|
|
|
|
}
|
2012-02-01 17:28:30 -04:00
|
|
|
|
|
|
|
|
$this->setView('home/applications');
|
|
|
|
|
|
|
|
|
|
// settings vars and rendering
|
|
|
|
|
$this->setVar('cases', $cases['data']);
|
|
|
|
|
|
|
|
|
|
G::RenderPage('publish', 'mvc');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startCase($httpData)
|
|
|
|
|
{
|
|
|
|
|
G::LoadClass('case');
|
|
|
|
|
$case = new Cases();
|
|
|
|
|
$aData = $case->startCase($httpData->id, $_SESSION['USER_LOGGED']);
|
|
|
|
|
|
|
|
|
|
$_SESSION['APPLICATION'] = $aData['APPLICATION'];
|
|
|
|
|
$_SESSION['INDEX'] = $aData['INDEX'];
|
|
|
|
|
$_SESSION['PROCESS'] = $aData['PROCESS'];
|
|
|
|
|
$_SESSION['TASK'] = $httpData->id;
|
|
|
|
|
$_SESSION['STEP_POSITION'] = 0;
|
|
|
|
|
$_SESSION['CASES_REFRESH'] = true;
|
|
|
|
|
|
|
|
|
|
$oCase = new Cases();
|
|
|
|
|
$aNextStep = $oCase->getNextStep($_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION']);
|
|
|
|
|
//../cases/cases_Open?APP_UID={$APP.APP_UID}&DEL_INDEX={$APP.DEL_INDEX}&action=todo
|
|
|
|
|
$aNextStep['PAGE'] = '../cases/cases_Open?APP_UID='.$aData['APPLICATION'].'&DEL_INDEX='.$aData['INDEX'].'&action=draft';
|
|
|
|
|
$_SESSION ['BREAKSTEP'] ['NEXT_STEP'] = $aNextStep;
|
|
|
|
|
|
|
|
|
|
G::header('Location: ' . $aNextStep['PAGE']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getAppList($type, $start=null, $limit=null)
|
2012-01-20 12:01:02 -04:00
|
|
|
{
|
|
|
|
|
require_once ( "classes/model/AppCacheView.php" );
|
|
|
|
|
require_once ( "classes/model/Application.php" );
|
|
|
|
|
require_once ( "classes/model/AppNotes.php" );
|
|
|
|
|
|
|
|
|
|
$appCache = new AppCacheView();
|
|
|
|
|
$appNotes = new AppNotes();
|
|
|
|
|
|
|
|
|
|
$notesStart = 0;
|
|
|
|
|
$notesLimit = 4;
|
|
|
|
|
|
2012-01-26 09:33:01 -04:00
|
|
|
// getting user's cases on inbox
|
2012-02-01 17:28:30 -04:00
|
|
|
switch ($type) {
|
|
|
|
|
case 'inbox': case 'in':
|
2012-01-20 12:01:02 -04:00
|
|
|
$criteria = $appCache->getToDoListCriteria($this->userID);
|
|
|
|
|
break;
|
2012-02-01 17:28:30 -04:00
|
|
|
|
2012-01-20 12:01:02 -04:00
|
|
|
case 'draft':
|
|
|
|
|
default:
|
|
|
|
|
$criteria = $appCache->getDraftListCriteria($this->userID); //fast enough
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-01 17:28:30 -04:00
|
|
|
$distinct = $type == 'draft' ? true : false;
|
|
|
|
|
$criteriac = $appCache->getToDoCountCriteria($this->userID);
|
|
|
|
|
$totalCount = AppCacheViewPeer::doCount( $criteriac, $distinct );
|
|
|
|
|
|
|
|
|
|
if (isset($start))
|
|
|
|
|
$criteria->setOffset($start);
|
|
|
|
|
|
|
|
|
|
if (isset($limit))
|
|
|
|
|
$criteria->setLimit($limit);
|
2012-01-20 12:01:02 -04:00
|
|
|
|
|
|
|
|
$criteria->addDescendingOrderByColumn(AppCacheViewPeer::APP_NUMBER);
|
|
|
|
|
$dataset = AppCacheViewPeer::doSelectRS($criteria);
|
|
|
|
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
$cases = array();
|
|
|
|
|
//$data['totalCount'] = $totalCount;
|
|
|
|
|
$rows = array();
|
|
|
|
|
$priorities = array('1'=>'VL', '2'=>'L', '3'=>'N', '4'=>'H', '5'=>'VH');
|
|
|
|
|
$index = $start;
|
|
|
|
|
|
|
|
|
|
while ($dataset->next()) {
|
|
|
|
|
$row = $dataset->getRow();
|
|
|
|
|
if (is_numeric(str_replace('#', '', $row['APP_TITLE']))) {
|
|
|
|
|
$row['APP_TITLE'] = 'Case ' . str_replace('#', '', $row['APP_TITLE']);
|
|
|
|
|
}
|
|
|
|
|
// replacing the status data with their respective translation
|
|
|
|
|
if (isset($row['APP_STATUS'])) {
|
|
|
|
|
$row['APP_STATUS'] = G::LoadTranslation("ID_{$row['APP_STATUS']}");
|
|
|
|
|
}
|
|
|
|
|
// replacing the priority data with their respective translation
|
|
|
|
|
if (isset($row['DEL_PRIORITY'])) {
|
|
|
|
|
$row['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$priorities[$row['DEL_PRIORITY']]}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$row['DEL_DELEGATE_DATE'] = G::getformatedDate($row['DEL_DELEGATE_DATE'], 'M d, yyyy at h:i:s');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$notes = $appNotes->getNotesList($row['APP_UID'], $this->userID, $notesStart, $notesLimit);
|
|
|
|
|
$notes = $notes['array'];
|
|
|
|
|
|
|
|
|
|
$row['NOTES_COUNT'] = $notes['totalCount'];
|
|
|
|
|
$row['NOTES_LIST'] = $notes['notes'];
|
|
|
|
|
|
|
|
|
|
$cases[] = $row;
|
|
|
|
|
}
|
2012-01-26 09:33:01 -04:00
|
|
|
|
2012-02-01 17:28:30 -04:00
|
|
|
return array('data' => $cases, 'totalCount' => $totalCount);
|
2012-01-20 12:01:02 -04:00
|
|
|
}
|
|
|
|
|
}
|