<?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 time_track
*/
$idObject = 0;
if (isset($_GET['id']) && $_GET['id'] > 0)
$idObject = $_GET['id'];
class web_TimeTrack extends web_Layout
{
function Info()
{
global $idObject;
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_SHORTINFO", $oIn = array('idcontact_current'=>$_SESSION['iduser']), $arContacts);
if (isset($arContacts['contacts']))
foreach ($arContacts['contacts'] as $key => $val) {
$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$key, 'type'=>ID_SEMA_CONTACT, 'mask'=>'3');
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
if (!(isset($_oOut['result']) && $_oOut['result']))
unset($arContacts['contacts'][$key]);
}
$arKeys = null;
if ($idObject > 0) {
$oIn['id'] = $idObject;
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_TBOARD_SEARCH", $oIn, $arTbT);
if (is_array($arTbT));
$arKeys = array_keys($arTbT['tbt']);
}
if ($idObject > 0)
$this->formStart(_LW("Modify time board track"));
else
$this->formStart(_LW("New time board track"));
echo "<FORM method=post>";
echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_TBOARD_CREATE\"></INPUT>\n";
$sLink = web_GetPrevPage();
if (!strlen($sLink))
$sLink = "?page=/web/time_board/time_board_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=\"idobject\" value=\"$idObject\"></INPUT>\n";
// if was some error then show the message about
$bError = isset($_SESSION['last_post']);
// idworker column
$sFieldValue = "";
if (is_array($arKeys))
$sFieldValue = $arTbT['tbt'][$arKeys[0]]['idworker'];
if ($bError)
$sFieldValue = $_SESSION['last_post']['data']['idworker'];
$this->formInputItem(_LW("Worker"), "select", "idworker", $sFieldValue, $arContacts['contacts']);
// date column
$sFieldValue = date("Y-m-d");
if (is_array($arKeys))
$sFieldValue = $arTbT['tbt'][$arKeys[0]]['date'];
if ($bError)
$sFieldValue = $_SESSION['last_post']['data']['date'];
$this->formInputItem(_LW("Date"), "date", "date", $sFieldValue);
// start column
$sFieldValue = date("H:i:s");//default value
if (is_array($arKeys))
$sFieldValue = $arTbT['tbt'][$arKeys[0]]['start'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['start'];
$this->formInputItem(_LW("Start"),"edit","start",$sFieldValue);
// end column
$sFieldValue = "00:00:00";
if (is_array($arKeys))
$sFieldValue = $arTbT['tbt'][$arKeys[0]]['end'];
if ( $bError )
$sFieldValue = $_SESSION['last_post']['data']['end'];
$this->formInputItem(_LW("End"),"edit","end",$sFieldValue);
if ($idObject > 0)
$sFieldValue = _LW("Modify");
else
$sFieldValue = _LW("Create");
$this->formInputItem($sFieldValue,"submit","","");
echo "</FORM>";
$this->formEnd();
?>
<?PHP
}
}
$oPage = new web_TimeTrack;
$oPage->m_windowHeader = _LW("Create time track");
$oPage->WebStack("time_track_form.php", $oPage->m_windowHeader, $oPage->m_windowHeader, web_GetPageGetParams());
if ( !isset($_SESSION['iduser']) )
web_RedirectRelative("sema.php");
$oPage->RenderPage();
?>