Location: PHPKode > projects > PushOk SEMA > html/web/task/task_main.php
<?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

$nIdProject = 0;
if ( isset($_GET['idproject']) && $_GET['idproject']>0 )
	$nIdProject = $_GET['idproject'];
	
class web_Task extends web_Layout 
{
	function Info()
	{
		global $arTaskStatus, $nIdProject, $arTaskTT, $arTaskPriority;
		
		// filter section
		$this->formStart("", "filter");
        echo "<FORM method=get>";
        echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_TASK_SEARCH\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"action\" value=\"filter\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"redirect\" value=\"page@@/web/task/hide@address.com@@$nIdProject\"></INPUT>\n";
        
        // fill filter with default values
        if ( !isset($_SESSION['last_filter']) || $_SESSION['last_filter']['idform'] != "FM_TASK_SEARCH" )
        	$_SESSION['last_filter'] = array('status'=>-1, 'my_tasks'=>'', 'own_tasks'=>'', 'idform'=>"FM_TASK_SEARCH");
    	
        $arStatuses = $arTaskStatus; 
        $arStatuses[-1] = _LW("Active");
        $arStatuses[-2] = _LW("All");
        $sFieldValue = 0;
        if ( isset($_SESSION['last_filter']['status']) )
        	$sFieldValue = $_SESSION['last_filter']['status'];
        $this->formInputItem(_LW("Status"),"select","status",$sFieldValue,$arStatuses);
        
        $sFieldValue = 0;
        if ( isset($_SESSION['last_filter']['overdue']) )
        	$sFieldValue = 1;
        $this->formInputItem(_LW("Overdue"),"checkbox","overdue",$sFieldValue);
        
        $sFieldValue = 1;
        if ( !isset($_SESSION['last_filter']['my_tasks']) )
        	$sFieldValue = 0;
        $this->formInputItem(_LW("My tasks"),"checkbox","my_tasks",$sFieldValue);
        
        $sFieldValue = 1;
        if ( !isset($_SESSION['last_filter']['own_tasks']) )
        	$sFieldValue = 0;
        $this->formInputItem(_LW("Own tasks"),"checkbox","own_tasks",$sFieldValue);
        
        $this->formInputItem(_LW("Refresh"), "submit");
		echo "</FORM>\n";
		$this->formEnd();
		
		// main section
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_SHORTINFO", $oIn = array('idcontact_current'=>$_SESSION['iduser']), $arContacts);
		
		$oIn = array('idcontact_current' => $_SESSION['iduser'], 'status'=>$_SESSION['last_filter']['status']);
		// overdue tasks
		if ( isset($_SESSION['last_filter']['overdue']) )
			$oIn['overdue'] = 1;
		// tasks for work with
		if ( isset($_SESSION['last_filter']['my_tasks']) )
			$oIn['my_tasks'] = 1;
		// user's tasks
		if ( isset($_SESSION['last_filter']['own_tasks']) )
			$oIn['own_tasks'] = 1;	
			
		if ( $nIdProject )
			$oIn['idparent'] = $nIdProject;
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_TASK_SEARCH", $oIn, $arTasks);
		
		$this->tableStart();
		$arHeader = array( 
			array('value'=>_LW('Parent object'), 'colspan'=>0),
			array('value'=>_LW('ID'), 'colspan'=>0),
			array('value'=>_LW('Title'), 'colspan'=>0),
			array('value'=>_LW('TT'), 'colspan'=>0),
			array('value'=>_LW('Start date'), 'colspan'=>0),
			array('value'=>_LW('End date'), 'colspan'=>0),
			array('value'=>_LW('Work time'), 'colspan'=>0),
			array('value'=>_LW('Owner'), 'colspan'=>0),
			array('value'=>_LW('Worker'), 'colspan'=>0),
			array('value'=>_LW('Responsible'), 'colspan'=>0),
			array('value'=>_LW('Doc chain'), 'colspan'=>0),
			array('value'=>_LW('Priority'), 'colspan'=>0),
			array('value'=>_LW('Status'), 'colspan'=>0),
			array('value'=>_LW('Action'), 'colspan'=>0),
							);
		$this->tableHeader($arHeader);
		
		if ( count($arTasks['tasks']) )
		{	
			// get info about available chains
			$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CHAIN_GET", $oIn=array(), $arChains=array());
			// prepare data for showing
			$arChainData = array();
			if ( isset($arChains['chains']) && count($arChains['chains']) )
				foreach ( $arChains['chains'] as $nId => $arChainInfo )
					$arChainData[$nId] = $arChainInfo['name'];
					
			foreach ( $arTasks['tasks'] as $nIdTask => $arTaskInfo )
			{
				$this->tableRow();
				$sSingle = "";
				if (isset($arTaskInfo['parent_object']) && $arTaskInfo['parent_object']>0) {
					$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$arTaskInfo['parent_object'], 'mask'=>'R');
					$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut=array());
					if (isset($_oOut['result']) && $_oOut['result'])
						$sSingle = $this->singleItem("link",$arTaskInfo['parent_title'], array('href'=> "?page=/web/object_view.php&id=".$arTaskInfo['parent_object']));
					else 
						$sSingle = $this->singleItem("string",$arTaskInfo['parent_title']);
				}
				$this->tableCol($sSingle);
				$this->tableCol($this->singleItem("string", $nIdTask));
				$this->tableCol($this->singleItem("link",$arTaskInfo['title'], array("href" => "?page=/web/task/task_view.php&idtask=$nIdTask")));
				$this->tableCol($this->singleItem("string",$arTaskTT[$arTaskInfo['time_type']]));
				$this->tableCol($this->singleItem("date",$arTaskInfo['bdate']));
				$this->tableCol($this->singleItem("date",$arTaskInfo['edate']));
				$this->tableCol($this->singleItem("string",$arTaskInfo['work_time']));
				$this->tableCol($this->singleItem("string",$arContacts['contacts'][$arTaskInfo['idowner']]));
				$this->tableCol($this->singleItem("string",$arContacts['contacts'][$arTaskInfo['idworker']]));
				$this->tableCol($this->singleItem("string",$arContacts['contacts'][$arTaskInfo['idresponsible']]));
				$this->tableCol($this->singleItem("string",$arChainData[$arTaskInfo['iddoc_chain']]));
				$this->tableCol($this->singleItem("string",$arTaskPriority[$arTaskInfo['priority']]));
				$this->tableCol($this->singleItem("string",$arTaskStatus[$arTaskInfo['status']]));

				$this->tableCol();
				// prepare actions for current task
				$_oIn=array('idobject'=>$nIdTask, 'type'=>ID_SEMA_TASK);
				$GLOBALS['WEB_DISPATCHER']->ProcessMessage("WM_ACTION_MENU_CREATE", $_oIn, $_oOut=array());
				if ( count($_oOut) )
				{
					krsort($_oOut);
					foreach ($_oOut as $nPriority=>$arMenues) 
						foreach ($arMenues as $sName => $arData) 
        	            	echo $this->singleItem("action",$sName,$arData);
				}
			}
		}
		$this->tableEnd();
		?>
		<?PHP
	}
}

$oPage = new web_Task;
$oPage->m_windowHeader = _LW("Tasks");
$oPage->WebStack("task_main.php", $oPage->m_windowHeader, $oPage->m_windowHeader, web_GetPageGetParams());

if ( !isset($_SESSION['iduser']) )
	web_RedirectRelative("sema.php");
	
$oPage->m_menuFLvl = "Tasks";
$oPage->RenderPage();

?>
Return current item: PushOk SEMA