<?php
ini_set('display_errors','1');
error_reporting(E_ALL);
session_start();
include ('start.php');
require ('functions/base.functions.php');
#require ('functions/users.inc.php');
include ('classes/global.class.php');
set_lang($_SESSION['lang']);
$login_type = new users();
if ($_SESSION['permissions']['admin'] !== "1"){
Header("Location: timesheet.php");
exit();
}
if(isset($_POST['pid']) && isset($_POST['task_name']) && isset($_POST['add_task'])){
$pid = $_POST['pid'];
$query = new Tasks;
if(isset($_POST['status'])){ $status='Y';}else{$status='N';}
$query->addTask($_POST['pid'],$_POST['task_name'],$_POST['task_index'],$status,$_POST['start']);
Header("Location: tasks_setup.php?pid=$pid");
exit();
}
if(isset($_POST['pid']) && isset($_POST['tid']) && isset($_POST['update_task'])){
$pid = $_POST['pid'];
$query = new Tasks;
if(isset($_POST['status'])){ $status='Y';}else{$status='N';}
$query->updateTask($_POST['tid'],$_POST['pid'],$_POST['task_name'],$_POST['task_index'],$status,$_POST['start']);
Header("Location: tasks_setup.php?pid=$pid");
exit();
}
?><!-- Headers -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/jqueryslidemenu.css" />
<link rel="stylesheet" href="js/addons/pager/jquery.tablesorter.pager.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="css/themes/blue/style.css" type="text/css" media="print, projection, screen" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="js/jqueryslidemenu.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.pager.js"></script>
<!--[if lte IE 7]>
<style type="text/css">
html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/
</style>
<![endif]-->
<script type="text/javascript">
$(document).ready(function()Â {Â
    $("#tablesorter")Â
    .tablesorter({widthFixed: true, widgets: ['zebra']})Â
    .tablesorterPager({container: $(".pager")});Â
});Â
</script>
<script type="text/javascript">
$(document).ready(function()Â {Â
$('.add_task_button').bind('click',function(){
if ( $('.add_task').css('display') == 'block' ) $('.add_task').css({'display':'none'})
else $('.add_task').css({'display':'block'})
})
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('.button').live('click',function(){
var id = $(this).attr('id');
if($("."+id).is(":visible")){
$("."+id).hide();
}else{
$("."+id).show();
}
return(false); // disable normal anchor behavior
});
});
</script>
<title>Tasks Settings</title>
</head>
<body>
<?php
include ('include/menu.settings.inc.html');
$pid=$_GET['pid'];
$tasks = new Projects;
$users=new Users;
#print_r($tasks->getProjectTasks($pid));
#$group=new Groups;
foreach($tasks->getProjectTasks($pid) as $tid=>$value){
?>
<div class="<?php echo $tid;?>" style=" width:40%;height: 300px;top: 20px; border: 1px solid black; left:30%;position:absolute; z-index:22;background: #F0F0F6;display:none;">
<div style="position:absolute; z-index:20;width:22px;height: 22px;top: -10px;right:-10px;"><a href="#" id="<?php echo $tid; ?>" class="button"><img style="border:0px;"src="images/button_cancel.png"></img></a></div>
<center><p>РедакÑиÑование даннÑÑ
:</p></center>
<form method='post' action=''>
<table style='margin: 10px;'>
<tbody>
<tr><td style='width:30%;'><?php echo gettext('Task Name');?></td><td><input type='text' name='task_name' maxlength="64" size='40' value="<?php echo $value['task_name']; ?>"></input></td></tr>
<tr><td><?php echo gettext('Task Index');?></td><td><input type='text' name='task_index' maxlength="64" size='40' value='<?php echo $value['task_index'];?>'></input></td></tr>
<tr><td><?php echo gettext('status');?></td><td>
<?php
if ($value['status'] == 'Y'){
echo "<input type='checkbox' name='status' value='Y' checked>";
}elseif($value['status'] == 'N'){
echo "<input type='checkbox' value='Y' name='status'>";
}
?>
</input></td></tr>
<tr><td><?php echo gettext('created at');?></td><td><input type='text' name='start' maxlength="64" size='40' value='<?php echo $value['start'];?>'></input></td></tr>
</tbody>
</table>
<input type="hidden" name='tid' value="<?php echo $tid; ?>">
<input type="hidden" name='pid' value="<?php echo $pid; ?>">
<center> <input type="submit" name='update_task' value="ÐÐ" ></input></center>
</form>
</div>
<?php
}
$task = new Tasks;
$index = $task->makeIndex($pid); #make task index for new task
#get Tasks List
$task_array = $tasks->getProjectTasks($pid);
#if NULL draw add_task
if (is_null($task_array)){
?>
<div class="add_task" style="width:40%;height: 300px;top: 50px; border: 1px solid black; left:30%;position:absolute; z-index:22;background: #F0F0F6;display:block;">
<center><p><?php echo gettext('New Task');?></p></center>
<form method='post' action=''>
<table style='margin: 10px;'>
<tbody>
<tr><td><?php echo gettext('task name');?></td><td><input type='text' name='task_name' maxlength="64" size='40'></input></td></tr>
<tr><td><?php echo gettext('task index');?></td><td><input type='text' name='task_index' maxlength="64" size='40' value='<?php echo $task->makeIndex($pid);?>'></input></td></tr>
<tr><td><?php echo gettext('status');?></td><td><input type='checkbox' name='status' value='Y' checked></input></td></tr>
<tr><td><?php echo gettext('created at');?></td><td><input type='text' name='start' maxlength="64" size='40' value='<?php echo date('Y-m-j');?>'></input></td></tr>
</tbody></table>
<input type='hidden' name='pid' value='<?php echo $pid;?>'>
<center> <input type="submit" name='add_task' value="ÐÐ" ></input></center>
</form>
</div>
<?php
exit();
}
?>
<div>
<table class="tablesorter" cellspacing="1" id="tablesorter" style="width:90%;">
<thead>
<tr>
<th><?php echo gettext('task name');?></th>
<th><?php echo gettext('task index');?></th>
<th><?php echo gettext('status');?></th>
<th><?php echo gettext('created at');?></th>
<th><?php echo gettext('action');?></th>
<th><?php echo gettext('ppls');?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo gettext('task name');?></th>
<th><?php echo gettext('task index');?></th>
<th><?php echo gettext('status');?></th>
<th><?php echo gettext('created at');?></th>
<th><?php echo gettext('action');?></th>
<th><?php echo gettext('ppls');?></th>
</tr>
</tfoot>
<tbody>
<?php
foreach($task_array as $tid=>$value){
if($value['status'] == 'Y') {
?>
<tr>
<td><?php echo $value['task_name'];?></td>
<td><?php echo $value['task_index'];?></td>
<td><?php echo $value['status'];?></td>
<td><?php echo $value['start'];?></td>
<td><a href="#" id="<?php echo $tid;?>" class="button"><img style="border: 0px;" src="images/edit.png"></img></a></td>
<td><a href="users_tasks.php?tid=<?php echo $tid;?>" class=""><img style="border: 0px;" src="images/kdmconfig.png"></img></a></td>
</tr>
<?php
}
}
foreach($tasks->getProjectTasks($pid) as $tid=>$value){
if($value['status'] == 'N') {
?>
<tr>
<td><?php echo $value['task_name'];?></td>
<td><?php echo $value['task_index'];?></td>
<td><?php echo $value['status'];?></td>
<td><?php echo $value['start'];?></td>
<td><a href="#" id="<?php echo $tid;?>" class="button"><img style="border: 0px;" src="images/edit.png"></img></a></td>
<td></td>
</tr>
<?php
}
}
#$task = new Tasks;
#$index = $task->makeIndex($pid);
?>
</tbody>
</table>
</div>
<div id="pager" class="pager">
<img src="js/addons/pager/icons/first.png" class="first"/>
<img src="js/addons/pager/icons/prev.png" class="prev"/>
<input type="text" class="pagedisplay"/>
<img src="js/addons/pager/icons/next.png" class="next"/>
<img src="js/addons/pager/icons/last.png" class="last"/>
<select class="pagesize">
<option selected="selected" value="20">20</option>
<option value="40">40</option>
<option value="60">60</option>
</select>
</div>
<!-- Button 'New User' -->
<div class="" style=" width:50px;height: 50px;top: 50px; border: 0px; right:50px;position:absolute; z-index:10;">
<a href="#" id="add_task" class="add_task_button"><img style="border: 0px;" src="images/add_user_48.png"></img></a>
</div>
<!-- New User Windows -->
<div class="add_task" style=" width:40%;height: 300px;top: 20px; border: 1px solid black; left:30%;position:absolute; z-index:22;background: #F0F0F6;display:none;">
<div style="position:absolute; z-index:20;width:22px;height: 22px;top: -10px;right:-10px;"><a href="#" class="add_task_button"><img style="border:0px;"src="images/button_cancel.png"></img></a></div>
<center><p><?php echo gettext('New Task');?></p></center>
<form method='post' action=''>
<table style='margin: 10px;'>
<tbody>
<!-- <tr><td style='width:30%;'><?php echo gettext('Task Name');?></td><td><input type='text' name='task_name' maxlength="64" size='40'></input></td></tr> -->
<tr><td><?php echo gettext('task name');?></td><td><input type='text' name='task_name' maxlength="64" size='40'></input></td></tr>
<tr><td><?php echo gettext('task index');?></td><td><input type='text' name='task_index' maxlength="64" size='40' value='<?php echo $task->makeIndex($pid);?>'></input></td></tr>
<tr><td><?php echo gettext('status');?></td><td><input type='checkbox' name='status' value='Y' checked></input></td></tr>
<tr><td><?php echo gettext('created at');?></td><td><input type='text' name='start' maxlength="64" size='40' value='<?php echo date('Y-m-j');?>'></input></td></tr>
</tbody></table>
<input type='hidden' name='pid' value='<?php echo $pid;?>'>
<center> <input type="submit" name='add_task' value="ÐÐ" ></input></center>
</form>
</div>
</body>
</html>