Location: PHPKode > projects > PushOk SEMA > html/web/project/project_form.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

/*
subscription: contain form to create new project or modify existing.
*/
$nIdProject = 0;// if this variable isset then we here to modify existing project
if ( isset($_GET['idproject']) && $_GET['idproject']>0 )
	$nIdProject = $_GET['idproject'];

class web_Project extends web_Layout 
{
	function Info()
	{
		global $arProjectStatus, $nIdProject, $arProjectTT;
		
		if ( $nIdProject ) 
		{
			$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_PROJECT_SEARCH", $oIn = array('id' => $nIdProject, 'idcontact_current' => $_SESSION['iduser']), $arProjectInfo);
			if (count($arProjectInfo)==0)
			{
				web_PageError(_LW("Access denied, or object deleted !"));
				return;
			}
		}
		
		$this->formStart(_LW("Project"));
        echo "<FORM method=post>";
		echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_PROJECT_CREATE\"></INPUT>\n";
		$sLink = web_GetPrevPage();
		if (!strlen($sLink))
			$sLink = "?page=/web/project/project_main.php";
		echo "<INPUT type=\"hidden\" name=\"onsuccess\" value=\"$sLink\"></INPUT>\n";
		echo "<INPUT type=\"hidden\" name=\"onerror\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
		echo "<INPUT type=\"hidden\" name=\"idproject\" value=\"$nIdProject\"></INPUT>\n";
		
		// if was some error then show the message about
		$bError = isset($_SESSION['last_post']);

		// title column 
		$sFieldValue = "";
		if ( $nIdProject && isset($arProjectInfo['projects'][$nIdProject]['title']) ) 
			$sFieldValue = $arProjectInfo['projects'][$nIdProject]['title'];
		if ( $bError )
			$sFieldValue = $_SESSION['last_post']['data']['title'];
		$this->formInputItem(_LW("Name"),"edit","title",$sFieldValue);
		
		// description column 
		$sFieldValue = "";
		if ( $nIdProject && isset($arProjectInfo['projects'][$nIdProject]['description']) ) 
			$sFieldValue = $arProjectInfo['projects'][$nIdProject]['description'];
		if ( $bError )
			$sFieldValue = $_SESSION['last_post']['data']['description'];
		$this->formInputItem(_LW("Description"),"text","description",$sFieldValue, array('cols'=>40, 'rows'=>5));
			
		// time_type column 
		$sFieldValue = "";
		if ( $nIdProject && isset($arProjectInfo['projects'][$nIdProject]['time_type']) ) 
			$sFieldValue = $arProjectInfo['projects'][$nIdProject]['time_type'];
		if ( $bError )
			$sFieldValue = $_SESSION['last_post']['data']['time_type'];
		$this->formInputItem(_LW("Time type"),"select","time_type",$sFieldValue, $arProjectTT);			
			
		// bdate column 
		$sFieldValue = "";
		if ( $nIdProject && isset($arProjectInfo['projects'][$nIdProject]['bdate']) ) 
			$sFieldValue = $arProjectInfo['projects'][$nIdProject]['bdate'];
		if ( $bError )
			$sFieldValue = $_SESSION['last_post']['data']['bdate'];
		$this->formInputItem(_LW("Start date"),"date","bdate",$sFieldValue);			
			
		// edate column 
		$sFieldValue = "";
		if ( $nIdProject && isset($arProjectInfo['projects'][$nIdProject]['edate']) ) 
			$sFieldValue = $arProjectInfo['projects'][$nIdProject]['edate'];
		if ( $bError )
			$sFieldValue = $_SESSION['last_post']['data']['edate'];
		$this->formInputItem(_LW("End date"),"date","edate",$sFieldValue);			
			
		// status column 
		$sFieldValue = 0;
		if ( $nIdProject && isset($arProjectInfo['projects'][$nIdProject]['status']) ) 
			$sFieldValue = $arProjectInfo['projects'][$nIdProject]['status'];
		if ( $bError )
			$sFieldValue = $_SESSION['last_post']['data']['status'];
		$this->formInputItem(_LW("Status"),"select","status",$sFieldValue, $arProjectStatus);		
			
		$sFieldValue = $nIdProject?_LW("Modify"):_LW("Create");
		$this->formInputItem($sFieldValue,"submit","","");						
        echo "</FORM>";
		$this->formEnd();
		?>
		<?PHP
	}
}

$oPage = new web_Project;
if ( $nIdProject )
	$oPage->m_windowHeader = _LW("Modify project");
else
	$oPage->m_windowHeader = _LW("Create project");
$oPage->WebStack("project_form.php", $oPage->m_windowHeader, $oPage->m_windowHeader, web_GetPageGetParams());

if ( !isset($_SESSION['iduser']) )
	web_RedirectRelative("sema.php");

$oPage->idobject = $nIdProject;
$oPage->object_type = ID_SEMA_PROJECT;
$oPage->m_menuFLvl = "Projects";
$oPage->RenderPage();

?>
Return current item: PushOk SEMA