<?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.
*/
$nIdContact = 0;// if this variable isset then we here to modify existing contact
if ( isset($_GET['idcontact']) && $_GET['idcontact']>0 )
$nIdContact = $_GET['idcontact'];
class web_Contact extends web_Layout
{
function Info()
{
global $nIdContact;
if ( $nIdContact )
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_SEARCH", $oIn = array('id'=>$nIdContact, 'idcontact_current'=>$_SESSION['iduser']), $arContact);
$this->formStart("ModifyContact");
echo "<FORM method=post>";
echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_CONTACT_CREATE\"></INPUT>\n";
$sLink = web_GetPrevPage();
if (!strlen($sLink))
$sLink = "?page=/web/contact/contact_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=\"idcontact\" value=\"$nIdContact\"></INPUT>\n";
// first name column
$bError = isset($_SESSION['last_post']);
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['first_name']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['first_name'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['first_name'];
$this->formInputItem(_LW("First name"),"edit","first_name",$sFieldValue);
// middle name column
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['middle_name']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['middle_name'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['middle_name'];
$this->formInputItem(_LW("Middle name"),"edit","middle_name",$sFieldValue);
// last name column
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['last_name']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['last_name'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['last_name'];
$this->formInputItem(_LW("Last name"),"edit","last_name",$sFieldValue);
// nick name column
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['nick_name']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['nick_name'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['nick_name'];
$this->formInputItem(_LW("Nick name"),"edit","nick_name",$sFieldValue);
// work place column
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['work_place']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['work_place'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['work_place'];
$this->formInputItem(_LW("Work place"),"edit","work_place",$sFieldValue);
// login column
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['login']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['login'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['login1'];
$this->formInputItem(_LW("Login"),"edit","login1",$sFieldValue);
// password column
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['password']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['password'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['password1'];
$this->formInputItem(_LW("Password"),"password","password1",$sFieldValue);
// password confirmation column
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['password']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['password'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['password2'];
$this->formInputItem(_LW("Confirm password"),"password","password2",$sFieldValue);
// active e-mail column
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['email']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['email'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['email'];
$this->formInputItem(_LW("E-mail"),"edit","email",$sFieldValue);
$_oIn = array('idcontact'=>$_SESSION['iduser']);
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_ISROOT", $_oIn, $_oOut=array());
if (isset($_oOut['result']) && $_oOut['result']) {
// flags column
$sFieldValue = "";
if ( $nIdContact && isset($arContact['contacts'][$nIdContact]['flags']) )
$sFieldValue = $arContact['contacts'][$nIdContact]['flags'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['flags'];
$this->formInputItem(_LW("Flags"),"contactflags","flags",$sFieldValue);
}
$sFieldValue = $nIdContact?_LW("Modify"):_LW("Create");
$this->formInputItem($sFieldValue,"submit","","");
$this->formEnd();
echo "</FORM>";
?>
<?PHP
}
}
$oPage = new web_Contact;
if ( $nIdContact )
$oPage->m_windowHeader = _LW("Modify contact");
else
$oPage->m_windowHeader = _LW("Create contact");
$oPage->WebStack("contact_form.php", $oPage->m_windowHeader, $oPage->m_windowHeader, web_GetPageGetParams());
if ( !isset($_SESSION['iduser']) )
web_RedirectRelative("sema.php");
$oPage->idobject = $nIdContact;
$oPage->object_type = ID_SEMA_CONTACT;
$oPage->m_menuFLvl = "Contacts";
$oPage->RenderPage();
?>