<?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['project_name']) && isset($_POST['add_project'])){
$query = new Projects;
if(isset($_POST['billable'])){ $billable='Y';}else{$billable='N';}
if(isset($_POST['status'])){ $status='Y';}else{$status='N';}
$query->addProject($_POST['owner_id'],$_POST['project_name'],$_POST['project_index'],$_POST['project_type'],$status,$billable,$_POST['start'],'');
Header("Location: projects_setup.php");
exit();
}
if(isset($_POST['project_name']) && isset($_POST['update_project'])){
$query = new Projects;
$project_type = $_POST['project_type'];
if(isset($_POST['billable'])){ $billable='Y';}else{$billable='N';}
if(isset($_POST['status'])){ $status='Y';}else{$status='N';}
$query->updateProject($_POST['project_id'],$_POST['owner'],$_POST['project_name'],$_POST['project_index'],$_POST['project_type'],$status,$billable,$_POST['start'],'');
Header("Location: projects_setup.php?type=$project_type");
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_project_button').live('click',function(){
if ( $('.add_project').css('display') == 'block' ) $('.add_project').css({'display':'none'})
else $('.add_project').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>Project Settings</title>
</head>
<body>
<?php
include ('include/menu.settings.inc.html');
if(isset($_POST['type'])){
$temp = array_keys($_POST['type']);
$correntType = $temp['0'];
}elseif(isset($_GET['type'])){
$correntType = $_GET['type'];
}else{$correntType = 'project'; }
?>
<form method='post' action=''>
<table cellspacing="1" style="width:60%;">
<tr>
<?php
if($correntType == 'project'){
echo "<td><button disabled>".gettext('projects')."</button></td></button></td>";
} else {
echo "<td><button name='type[project]' type='submit'>".gettext('projects')."</button></td></button></td>";
}
if($correntType == 'tender'){
echo "<td><button disabled>".gettext('tenders')."</button></td></button></td>";
} else {
echo "<td><button name='type[tender]' type='submit' >".gettext('tenders')."</button></td></button></td>";
}
if($correntType == 'office'){
echo "<td><button disabled>".gettext('office work')."</button></td></button></td>";
} else {
echo "<td><button name='type[office]' type='submit'>".gettext('office work')."</button></td></button></td>";
}
if($correntType == 'off_hours'){
echo "<td><button disabled>".gettext('off hours')."</button></td></button></td>";
} else {
echo "<td><button name='type[off_hours]' type='submit'>".gettext('off hours')."</button></td></button></td>";
}
?>
</tr></table></form>
<?php
$projects = new Projects;
$users=new Users;
#$group=new Groups;
foreach($projects->getProjectsByType($correntType) as $num=>$value){
?>
<div class="<?php echo $value['id'];?>" 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 $value['id']; ?>" 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('Project Name');?></td><td><input type='text' name='project_name' maxlength="64" size='40' value="<?php echo $value['proj_name']; ?>"></input></td></tr>
<tr><td><?php echo gettext('Project Index');?></td><td><input type='text' name='project_index' maxlength="64" size='40' value='<?php echo $value['proj_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('billable');?></td><td>
<?php
if ($value['billable'] == 'Y'){
echo "<input type='checkbox' name='billable' value='Y' checked>";
}elseif($value['billable'] == 'N'){
echo "<input type='checkbox' value='Y' name='billable'>";
}
?>
</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>
<tr><td><?php echo gettext('owner');?></td><td><select name='owner'>
<option selected value="<?php echo $value['owner_id'];?>"><?php echo $users->getRealName($value['owner_id']);?></option>
<?php
foreach ($users->getUsersbyType('pm') as $key=>$data){
if ($key != $value['owner_id']){
echo '<option value="'.$key.'">'.$data['real_name'].'</option>';
}
}
?>
</select></td></tr>
</tbody>
</table>
<input type="hidden" name='project_id' value="<?php echo $value['id']; ?>"></input>
<input type='hidden' name='project_type' value='<?php echo $correntType;?>'></input>
<center> <input type="submit" name='update_project' value="ÐÐ" ></input></center>
</form>
</div>
<?php
}
?>
<div>
<table class="tablesorter" cellspacing="1" id="tablesorter" style="width:90%;">
<thead>
<tr>
<th><?php echo gettext('project name');?></th>
<th><?php echo gettext('project index');?></th>
<th><?php echo gettext('status');?></th>
<th><?php echo gettext('billable');?></th>
<th><?php echo gettext('created at');?></th>
<th><?php echo gettext('owner');?></th>
<th><?php echo gettext('action');?></th>
<th><?php echo gettext('ppls');?></th>
<th><?php echo gettext('tasks');?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo gettext('project name');?></th>
<th><?php echo gettext('project index');?></th>
<th><?php echo gettext('status');?></th>
<th><?php echo gettext('billable');?></th>
<th><?php echo gettext('created at');?></th>
<th><?php echo gettext('owner');?></th>
<th><?php echo gettext('action');?></th>
<th><?php echo gettext('ppls');?></th>
<th><?php echo gettext('tasks');?></th>
</tr>
</tfoot>
<tbody>
<?php
foreach($projects->getProjectsByType($correntType) as $num=>$value){
if($value['status'] == 'Y') {
?>
<tr>
<td><?php echo $value['proj_name'];?></td>
<td><?php echo $value['proj_index'];?></td>
<td><?php echo $value['status'];?></td>
<td><?php echo $value['billable'];?></td>
<td><?php echo $value['start'];?></td>
<td><?php echo $users->getRealName($value['owner_id']);?></td>
<td><a href="#" id="<?php echo $value['id'];?>" class="button"><img style="border: 0px;" src="images/edit.png"></img></a></td>
<td><a href="users_projects.php?pid=<?php echo $value['id'];?>" class=""><img style="border: 0px;" src="images/kdmconfig.png"></img></a></td>
<td><a href="tasks_setup.php?pid=<?php echo $value['id'];?>" class=""><img style="border: 0px;" src="images/task_22.png"></img></a></td>
</tr>
<?php
}
}
foreach($projects->getProjectsByType($correntType) as $num=>$value){
if($value['status'] == 'N') {
?>
<tr>
<td><?php echo $value['proj_name'];?></td>
<td><?php echo $value['proj_index'];?></td>
<td><?php echo $value['status'];?></td>
<td><?php echo $value['billable'];?></td>
<td><?php echo $value['start'];?></td>
<td><?php echo $users->getRealName($value['owner_id']);?></td>
<td><a href="#" id="<?php echo $value['id'];?>" class="button"><img style="border: 0px;" src="images/edit.png"></img></a></td>
<td></td>
<td></td>
</tr>
<?php
}
}
?>
</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_project" class="add_project_button"><img style="border: 0px;" src="images/add_user_48.png"></img></a>
</div>
<!-- New User Windows -->
<div class="add_project" 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_project_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('Project Name');?></td><td><input type='text' name='project_name' maxlength="64" size='40'></input></td></tr>
<tr><td><?php echo gettext('Project Index');?></td><td><input type='text' name='project_index' maxlength="64" size='40' value="<?php echo $projects->makeIndex($correntType); ?>"></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('billable');?></td><td><input type='checkbox' name='billable' 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>
<tr><td><?php echo gettext('owner');?></td><td><select name='owner_id'>
<?php
foreach ($users->getUsersbyType('pm') as $key=>$data){
echo '<option value="'.$key.'">'.$data['real_name'].'</option>';
}
?>
</select></td></tr>
</tbody></table>
<input type='hidden' name='project_type' value='<?php echo $correntType;?>'></input>
<center> <input type="submit" name='add_project' value="ÐÐ" ></input></center>
</form>
</div>
</body>
</html>