Location: PHPKode > projects > TimeSheet4dotProject > ts4dp/timesheet/startPage.php
<?php
require_once('session.php');
require_once('global4app.php');
if ($_SESSION['uid'] == "")
{
	echo '<html><head><meta http-equiv="refresh" content="5; URL=index.php"></head><body>';
	echo '<center>Fatal Error. You haven\'t logged in properly<br/><a href=index.php>'.'Click Here To exit and login again </a> (forwarded in 5 sec.)</center></body></html>';
	exit();
}

?>
<html>
<head>
<title>Timesheet4dP</title>
<link rel=stylesheet type="text/css" href="./css/main.css">
<link rel="stylesheet" type="text/css" href="./yui/fonts/fonts-min.css?_yuiversion=2.5.0" />
<link rel="stylesheet" type="text/css" href="./yui/button/assets/skins/sam/button.css?_yuiversion=2.5.0" />
<link rel="stylesheet" type="text/css" href="./yui/container/assets/skins/sam/container.css?_yuiversion=2.5.0" />
<link rel="stylesheet" type="text/css" href="./yui/calendar/assets/skins/sam/calendar.css?_yuiversion=2.5.0" />

<script type="text/javascript" src="./yui/yahoo-dom-event/yahoo-dom-event.js?_yuiversion=2.5.0"></script>
<script type="text/javascript" src="./yui/utilities/utilities.js?_yuiversion=2.5.0"></script>
<script type="text/javascript" src="./yui/button/button.js?_yuiversion=2.5.0"></script>
<script type="text/javascript" src="./yui/container/container.js?_yuiversion=2.5.0"></script>
<script type="text/javascript" src="./yui/calendar/calendar.js?_yuiversion=2.5.0"></script>
<script language="javascript" type="text/javascript" src="./js/getObj.js"></script> 
<style type=text/css>
	#cal1Container { display:none; position:absolute; left:83px;top:20px;}
</style>
<script language="JavaScript" type="text/JavaScript">
function changeProjects()
{
	getObj('projectImage').src = './img/ajaxOn.gif';
	selectedCompanyID = getObj('companyName')[getObj('companyName').selectedIndex].value;
	getObj('projectName').disabled = true;
	if (selectedCompanyID > 0)
	{
		// populate projects
		var http = getHTTPObject();
      		var URLString = 'getProjects.php'
		// always use post, so that IE will not cache the outputs...
      		http.open("POST", URLString, true); 
		var params = "companyId=" + selectedCompanyID;
		//alert (params);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");
      		http.onreadystatechange = function() 
      		{ 
              		if (http.readyState == 4) 
              		{ 
                    		//alert(http.responseText); 
                    		getObj("projectList").innerHTML = http.responseText;
                    		getObj('projectName').disabled = false;
		    		getObj('projectImage').src = './img/ajaxOff.gif';
              		} 
      		} 
      		http.send(params);
	}
	else
	{
		alert("Select a valid company");
		getObj('projectImage').src = './img/ajaxOff.gif';
		getObj('taskImage').src = './img/ajaxOff.gif';
		return false;
	}
}
function changeTask()
{
	getObj('taskImage').src = './img/ajaxOn.gif';
	selectedProjectID = getObj('projectName')[getObj('projectName').selectedIndex].value;
	//alert(selectedProjectID);
	getObj('taskName').disabled =  true;
	if (selectedProjectID > 0)
	{
		// populate Tasks
		var http = getHTTPObject();
		var URLString = 'getTasks.php';
		//alert (URLString);
		http.open("POST", URLString, true); 
		var params = "projectId=" + selectedProjectID;
		//alert (params);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");		
		http.onreadystatechange = function() 
		{ 
			if (http.readyState == 4) 
			{ 
			    //alert(http.responseText); 
			    getObj("taskList").innerHTML = http.responseText;
			    getObj('taskName').disabled = false;
			    getObj('taskImage').src = './img/ajaxOff.gif';		    			  
			} 
		} 
		http.send(params);		
	}
	else
	{
		alert("Select a valid project");
		getObj('projectImage').src = './img/ajaxOff.gif';
		getObj('taskImage').src = './img/ajaxOff.gif';
		return false;
	}
}

YAHOO.namespace("example.container");

function init() {
	
	// Define various event handlers for Dialog
	var handleSubmit = function() {
		this.submit();
	};
	var handleCancel = function() {
		this.cancel();
	};
	var handleSuccess = function(o) {
		var response = o.responseText;
		response = response.split("<!")[0];
		document.getElementById("resp").innerHTML = response;
		document.forms[0].reset()
		document.forms[1].reset();
		document.forms[1].taskDate.disabled = true;
	};
	var handleFailure = function(o) {
		alert("Submission failed: " + o.status);
	};
	
	// Instantiate the Dialog
	YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1", 
	{ width : "300px",
	  fixedcenter : true,
	  visible : false, 
	  constraintoviewport : true,
	  buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
				  { text:"Cancel", handler:handleCancel } ]
	 } );	
																 
	
	// Validate the entries in the form to require that both first and last name are entered
	YAHOO.example.container.dialog1.validate = function() {
		
		var data = this.getData();
		
		if (data.taskDate == "") {
			alert("Please select a date for this task	");
			return false;
		} 
		if (data.hours == 0)
		{
			alert("Please select task duration (hours worked) ");
			return false;
		}
		if (data.ttitle == "")
		{
			alert("Please enter task title ");
			return false;		
		}
		if (data.desc == "")
		{
			alert("Please enter task description ");
			return false;		
		}
		document.forms[1].taskDate.disabled = false;
		return true;
		
		
	};
	// Wire up the success and failure handlers
	YAHOO.example.container.dialog1.callback = { success: handleSuccess,failure: handleFailure };	

	// Render the Dialog
	YAHOO.example.container.dialog1.render();

	YAHOO.util.Event.addListener("show", "click", YAHOO.example.container.dialog1.show, YAHOO.example.container.dialog1, true);
	YAHOO.util.Event.addListener("hide", "click", YAHOO.example.container.dialog1.hide, YAHOO.example.container.dialog1, true);
}

YAHOO.util.Event.onDOMReady(init);

var todayDate = new Date();
var pgdate = todayDate.getMonth()+1 + "/" + todayDate.getFullYear();
var endDate = todayDate.getMonth()+1 + "/" + todayDate.getDate() + "/" + todayDate.getFullYear();
var startDate = todayDate.getMonth() + "/" + todayDate.getDate() + "/" + todayDate.getFullYear();

function showNewTaskScreen()
{
	selectedCompanyID = getObj('companyName').selectedIndex;
	if (selectedCompanyID <= 0 )
	{
		alert("Select a Company");
		return false;
	}
	selectedProjectID = getObj('projectName').selectedIndex;
	if (selectedProjectID <= 0 ) 
	{
		alert("Select a Project");
		return false;
	}	
	selectedTaskID = getObj('taskName').selectedIndex;
	if (selectedTaskID <= 0 ) 
	{
		alert("Select a Task");
		return false;
	}
	//document.forms[1].form1Values.value = document.forms[0].companyName.value + "," + document.forms[0].projectName.value + "," + document.forms[0].taskName.value ;
	document.forms[1].form1Values.value = document.forms[0].taskName.value;
	//alert (document.forms[1].form1Values.value);
	YAHOO.example.container.dialog1.show();
	
}
</script>
</head>
<body class=" yui-skin-sam" bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- User name is the input to proceed further...-->
<br><br><hr/>
<form method=post action=#>
<table width="500" border="0" cellspacing="2" cellpadding="10" align="center" valign=center>
<tr>
	<td colspan=3 align=right>Welcome <? print $_SESSION['username'] ?>, <a href=index.php> Logout </a></td>
</tr>
<tr>	
	<td colspan=3><b>Task Logs</b></td>
</tr>
<tr>
	<td nowrap>Select Company </td>
	<td><select name=companyName id=companyName style="{width:275}" onChange=changeProjects();><option id=0>Select a Company</option>
	<?php
	$result = db_loadList('select * from companies');
	foreach($result as $row)
	{
		echo '<option value='.$row['company_id'].'>'.$row['company_name'].'</option>';
	}
	
	?>
	</select></td>
	<td></td>
</tr>
<tr>
	<td>Select Project </td>
	<td><div id=projectList><select name=projectName id=projectName disabled style="{width:275}" onChange=changeTask();><option id=0>Select a Project</option></select></div></td>
	<td><img id=projectImage src="./img/ajaxOff.gif"></td>
</tr>
<tr>
	<td>Select Task </td>
	<td><div id=taskList><select name=taskName id=taskName disabled style="{width:275}"><option id=0>Select a Task</option></select></div></td>
	<td><img id=taskImage src="./img/ajaxOff.gif"></td>
</tr>
<tr>
	<!-- <td><input type=Button value="View Task Logs" id=viewLogButton onClick="YAHOO.example.container.viewlogs.show();"></td> -->
	<td colspan=3 align=center><input type=Button value="View Task Logs" id=viewLogButton onClick="javascript:location.href='getMyTaskLogs.php'"> &nbsp; <input type=Button value="Submit a New Task Log" onClick="showNewTaskScreen();">  &nbsp; 
	<?php
	if ($_SESSION['username'] == "admin")
	{
	?>
	<input type=button value="Assign Hierarchy / Reporting" onClick="javascript:location.href='showReporting.php'">
	<?php
	}
	?>
	
	<img id=submitImage src="./img/ajaxOff.gif"></td>
</tr>
<tr><td colspan=3><div id=resp></div></td></tr>
<tr><td colspan=3 align=center>Note: To view logs you need not select company / project / task. <a href=http://timesheet4dp.sourceforge.net target="_blank"> http://timesheet4dp.sourceforge.net </a></td></tr>
</table>
</form>
<div id="dialog1">
<div class="hd">.:| New Task Log |:.</div>
<div class="bd">
<form method=post action=saveTask.php>
		<table border="0" cellspacing="2" cellpadding="2" align="center" valign=center>
		<tr><td colspan=2><b>New Task Log / Entry <input type=hidden name=form1Values id=form1Values></b></td></tr>
		<tr><td>Date<div id="cal1Container"></div></td> <td><input type=text size=12 name=taskDate id=taskDate disabled> <button type="button" id="showCal" align=center title="Show Calendar" style="height:19"><img src="./img/calbtn.gif" alt="Calendar" align=center style="height:19"></button></td></tr>
		<tr><td>Hours Worked</td><td><select name=hours id=hours><option value=0>0</option><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option></option><option value=9>9</option><option value=10>10</option><option value=11>11</option><option value=12>12</option></select></td></tr>
		<tr><td>Title</td><td><input type=text size=25 name=ttitle id=ttitle></td></tr>
		<tr><td>Description</td><td><textarea id=desc name=desc rows=5 cols=25></textarea></td></tr>
		</table>
</form>
<br><br>
</div>
</div>
<script type="text/javascript">	
	YAHOO.namespace("example.calendar");

	YAHOO.example.calendar.init = function() {
        	
		YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("cal1","cal1Container" ,{ pagedate: ""+pgdate, mindate: ""+startDate, maxdate: ""+endDate, title:"Choose a date:", close:true });
		YAHOO.example.calendar.cal1.render();
		YAHOO.util.Event.addListener("showCal", "click", YAHOO.example.calendar.cal1.show, YAHOO.example.calendar.cal1, true);
		
		var mySelectHandler = function(type,args,obj) {
		var selected = args[0];
			
		if (YAHOO.example.calendar.cal1.getSelectedDates().length > 0) 
		{
                var selDate = YAHOO.example.calendar.cal1.getSelectedDates()[0];

                // Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
                //var wStr = YAHOO.example.calendar.cal1.cfg.getProperty("WEEKDAYS_LONG")[selDate.getDay()];
                var dStr = selDate.getDate();
                //var mStr = YAHOO.example.calendar.cal1.cfg.getProperty("MONTHS_LONG")[selDate.getMonth()];
                var mStr = selDate.getMonth() + 1;
                var yStr = selDate.getFullYear();

                YAHOO.util.Dom.get("taskDate").value =  yStr + "-" + mStr + "-" + dStr;
            } else {
                YAHOO.util.Dom.get("taskDate").value = "";
            }			
			YAHOO.example.calendar.cal1.hide();
		};

		YAHOO.example.calendar.cal1.selectEvent.subscribe(mySelectHandler, YAHOO.example.calendar.cal1, true);
		
       
	}

	YAHOO.util.Event.onDOMReady(YAHOO.example.calendar.init);

</script>
<?php
include ('footer.php');
?>
</body>
</html>
Return current item: TimeSheet4dotProject