<?PHP
// Pushok's SEMA (Small Enterprise Management Application)
//
// Copyright (C) 2004 Pushok Software http://www.pushok.com
//
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
/*
subscription: contain main information about active tasks as gant diagram.
*/
require_once('web/html_gant.pinc');
$nIdParent = 0;
if (isset($_GET['idparent']) && $_GET['idparent']>=0)
$nIdParent = $_GET['idparent'];
else
web_RedirectRelative("sema.php");
class web_Task extends web_Layout
{
function Info()
{
global $nIdParent;
// fill filter with default values
if ( !isset($_SESSION['last_filter']) || $_SESSION['last_filter']['idform'] != "FM_TASK_SEARCH_DIAGRAM" ) {
$nNow = time();
$nWeek = 86400*7;
$_SESSION['last_filter'] = array('bdate'=>date("Y-m-d", $nNow-$nWeek), 'edate'=>date("Y-m-d", $nNow+$nWeek), 'idform'=>"FM_TASK_SEARCH_DIAGRAM", 'show'=>0);
}
// get list of available contacts
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_SHORTINFO", $oIn = array('idcontact_current'=>$_SESSION['iduser']), $arContacts);
// get object children (tasks)
$_oIn = array('idcontact_current'=>$_SESSION['iduser'], 'idobjects'=>array($nIdParent));
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_OBJECT_GET_CHILD", $_oIn, $arTasksIds=array());
$_oOut = array();
if (isset($_SESSION['last_filter']['show']) && $_SESSION['last_filter']['show'] != 2) {
// get info about tasks //
// find necessary data
$_oIn = array('idcontact_current'=>$_SESSION['iduser'], 'idtasks'=>$arTasksIds, 'bdate'=>$_SESSION['last_filter']['bdate'],
'edate'=>$_SESSION['last_filter']['edate']);
// add to filter info about user for which to show gant table
if (isset($_SESSION['last_filter']['idcontacts']) && $_SESSION['last_filter']['idcontacts'] > 0)
$_oIn['idcontacts'] = $_SESSION['last_filter']['idcontacts'];
// add to filter info about info to show
if (isset($_SESSION['last_filter']['show']) && $_SESSION['last_filter']['show'] == 1)
$_oIn['time_type'] = 1;
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_TASK_SEARCH_DIAGRAM", $_oIn, $_oOut=array());
} else {
// get info about time tracks //
// find necessary data
$_oIn = array('idcontact_current'=>$_SESSION['iduser'], 'idtasks'=>$arTasksIds, 'start'=>$_SESSION['last_filter']['bdate'],
'end'=>$_SESSION['last_filter']['edate']);
// add to filter info about user for which to show gant table
if (isset($_SESSION['last_filter']['idcontacts']) && $_SESSION['last_filter']['idcontacts'] > 0)
$_oIn['idcontacts'] = $_SESSION['last_filter']['idcontacts'];
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_TIMETRACK_SEARCH_DIAGRAM", $_oIn, $_oOut=array());
}
$this->formStart("", "filter");
echo "<FORM method=get>";
echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_TASK_SEARCH_DIAGRAM\"></INPUT>\n";
echo "<INPUT type=\"hidden\" name=\"action\" value=\"filter\"></INPUT>\n";
echo "<INPUT type=\"hidden\" name=\"redirect\" value=\"page@@/web/task/task_gant.php&idparent=$nIdParent\"></INPUT>\n";
$sFieldValue = 0;
$arShowValues = array("All tasks", "Fixed tasks", "Time tracks");
if ( isset($_SESSION['last_filter']['show']) )
$sFieldValue = $_SESSION['last_filter']['show'];
$this->formInputItem(_LW("Items to show"),"select","show",$sFieldValue,$arShowValues);
if ( isset($_SESSION['last_filter']['bdate']) )
$sFieldValue = $_SESSION['last_filter']['bdate'];
$this->formInputItem(_LW("Start date"),"date","bdate",$sFieldValue);
if ( isset($_SESSION['last_filter']['edate']) )
$sFieldValue = $_SESSION['last_filter']['edate'];
$this->formInputItem(_LW("End date"),"date","edate",$sFieldValue);
$sFieldValue = 0;
$arContacts['contacts'][0] = "All";
if (isset($_SESSION['last_filter']['idcontacts']))
$sFieldValue = $_SESSION['last_filter']['idcontacts'];
$this->formInputItem(_LW("Worker"),"select","idcontacts",$sFieldValue, $arContacts['contacts']);
$this->formInputItem(_LW("Search"), "submit");
$this->formEnd();
$this->formStart("");
$this->formItem("", "subitem");
if (isset($_oOut['data']) && count($_oOut['data'])) {
$oGant = new web_Resource();
$oGant->m_arData = $_oOut;
$oGant->Init();
$oGant->Show();
}
$this->formEnd();
?>
<?PHP
}
}
$oPage = new web_Task;
$oPage->m_windowHeader = _LW("Task gant");
$oPage->WebStack("task_gant.php", $oPage->m_windowHeader, $oPage->m_windowHeader, web_GetPageGetParams());
if ( !isset($_SESSION['iduser']) )
web_RedirectRelative("sema.php");
$oPage->m_menuFLvl = "Tasks";
$oPage->RenderPage();
?>