Location: PHPKode > projects > PushOk SEMA > html/web/note/note_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 note or modify existing.
*/
$nIdParent = 0;// if this variable isset then we here to add new issue to object
if ( isset($_GET['idparent']) && $_GET['idparent']>0 )
	$nIdParent = $_GET['idparent'];
	
$nIdNote = 0;// if this variable isset then we here to modify existing issue
if ( isset($_GET['idnote']) && $_GET['idnote']>0 )
	$nIdNote = $_GET['idnote'];

class web_Note extends web_Layout 
{
	function Info()
	{
		global $nIdParent, $nIdNote;
		
		if ( $nIdNote ) {
			$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_NOTE_SEARCH", $oIn = array('id' => $nIdNote, 'idcontact_current' => $_SESSION['iduser']), $arNoteInfo);
			if (count($arNoteInfo)==0)
			{
				web_PageError(_LW("Access denied, or object deleted !"));
				return;
			}
			$this->formStart($arNoteInfo['notes'][$nIdNote]['title']);
		}
		else 	
			$this->formStart(_LW("New note"));
        echo "<FORM method=post>\n";
		echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_NOTE_CREATE\"></INPUT>\n";
		$sLink = web_GetPrevPage();
		if (!strlen($sLink))
			$sLink = "?page=/web/note/note_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=\"idparent\" value=\"$nIdParent\"></INPUT>\n";
		echo "<INPUT type=\"hidden\" name=\"idnote\" value=\"$nIdNote\"></INPUT>\n";
		
		// if was some error then show the message about
		$bError = isset($_SESSION['last_post']);

		// title column 
		$sFieldValue = "";
		if ( $nIdNote && isset($arNoteInfo['notes'][$nIdNote]['title']) ) 
			$sFieldValue = $arNoteInfo['notes'][$nIdNote]['title'];
		if ( $bError )
			$sFieldValue = $_SESSION['last_post']['data']['title'];
		$this->formInputItem(_LW("Title"),"edit","title",$sFieldValue, array('size'=>100));

		// text column (issue_content table data)
        $this->formSection(_LW("Body"));

		$sFieldValue = "";
		if ( $nIdNote && isset($arNoteInfo['notes'][$nIdNote]['body']) ) 
			$sFieldValue = $arNoteInfo['notes'][$nIdNote]['body'];
		if ( $bError )
			$sFieldValue = $_SESSION['last_post']['data']['body'];
		$this->formInputItem(_LW("Text"),"text","body",$sFieldValue, array('cols'=>80, 'rows'=>40));
		
		$sFieldValue = $nIdNote?_LW("Modify"):_LW("Create");
		$this->formInputItem($sFieldValue,"submit","","");						
        echo "</FORM>";
		$this->formEnd();
		?>
		<?PHP
	}
}

$oPage = new web_Note;
if ( $nIdNote ) 
	$oPage->m_windowHeader = _LW("Modify note");
else 
	$oPage->m_windowHeader = _LW("Create note");
$oPage->WebStack("note_form.php", $oPage->m_windowHeader, $oPage->m_windowHeader, web_GetPageGetParams());

if ( !isset($_SESSION['iduser']) )
	web_RedirectRelative("sema.php");
	
$oPage->idobject = $nIdNote;
$oPage->object_type = ID_SEMA_NOTE;
$oPage->m_menuFLvl = "Notes";
$oPage->RenderPage();

?>
Return current item: PushOk SEMA