} if ($obj->project_actual_end_date) { $date = new CDate($obj->project_actual_end_date); $obj->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL); } // let's check if there are some assigned departments to project //部门分配 if (!dPgetParam($_POST, "project_departments", 0)) { //返回一个部门的id $obj->project_departments = implode(",", dPgetParam($_POST, "dept_ids", array())); } $del = dPgetParam($_POST, 'del', 0); // prepare (and translate) the module name ready for the suffix if ($del) { $project_id = dPgetParam($_POST, 'project_id', 0); $canDelete = $obj->canDelete($msg, $project_id); if (!$canDelete) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } if ($msg = $obj->delete()) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } else { $AppUI->setMsg("Project deleted", UI_MSG_ALERT); $AppUI->redirect("m=projects"); } } else { if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else {
$canRead = $perms->checkModuleItem($m, 'view', $project_id); $canEdit = $perms->checkModuleItem($m, 'edit', $project_id); $canEditT = $perms->checkModule('tasks', 'add'); if (!$canRead) { $AppUI->redirect('m=public&a=access_denied'); } $tab = $AppUI->processIntState('ProjVwTab', $_GET, 'tab', 0); // check if this record has dependencies to prevent deletion $msg = ''; $project = new CProject(); // Now check if the proect is editable/viewable. $denied = $project->getDeniedRecords($AppUI->user_id); if (in_array($project_id, $denied)) { $AppUI->redirect('m=public&a=access_denied'); } $canDelete = $project->canDelete($msg, $project_id); // get critical tasks (criteria: task_end_date) $criticalTasks = $project_id > 0 ? $project->getCriticalTasks($project_id) : null; // get ProjectPriority from sysvals $projectPriority = w2PgetSysVal('ProjectPriority'); $projectPriorityColor = w2PgetSysVal('ProjectPriorityColor'); // load the record data $project->loadFull($AppUI, $project_id); if (!$project) { $AppUI->setMsg('Project'); $AppUI->setMsg('invalidID', UI_MSG_ERROR, true); $AppUI->redirect(); } else { $AppUI->savePlace(); } $total_hours = $project->getTotalHours();
} $tab = $AppUI->getState('ProjVwTab') !== NULL ? $AppUI->getState('ProjVwTab') : 0; // check if this record has dependencies to prevent deletion $msg = ''; $obj = new CProject(); // Now check if the proect is editable/viewable. $denied = $obj->getDeniedRecords($AppUI->user_id); if (in_array($project_id, $denied)) { $AppUI->setMsg('Access denied', UI_MSG_ERROR); $AppUI->redirect(); } $obj->load($project_id); $isProjectManager = $AppUI->user_id == $obj->getManager(); $canEdit = $perms->checkModuleItem($m, 'edit', $project_id) && ($AppUI->user_type == SYSADMIN || $isProjectManager); $canEditT = $obj->canCreateTasks(); $canDelete = $obj->canDelete($msg, $project_id) && ($AppUI->user_type == SYSADMIN || $AppUI->user_id == $obj->project_owner); $canViewReport = $isProjectManager || $AppUI->user_type <= MANAGER; // get critical tasks (criteria: task_end_date) $criticalTasks = $project_id > 0 ? $obj->getCriticalTasks($project_id) : NULL; // get ProjectPriority from sysvals $projectPriority = dPgetSysVal('ProjectPriority'); $projectPriorityColor = dPgetSysVal('ProjectPriorityColor'); $working_hours = $dPconfig['daily_working_hours'] ? $dPconfig['daily_working_hours'] : 8; $q = new DBQuery(); //check that project has tasks; otherwise run seperate query $q->addTable('tasks'); $q->addQuery('COUNT(distinct tasks.task_id) AS total_tasks'); $q->addWhere('task_project = ' . $project_id); $hasTasks = $q->loadResult(); $q->clear(); // load the record data
<?php if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly.'); } // @todo convert to template $project_id = (int) w2PgetParam($_GET, 'project_id', 0); $project = new CProject(); if (!$project->load($project_id)) { $AppUI->redirect(ACCESS_DENIED); } $canEdit = $project->canEdit(); $canDelete = $project->canDelete(); $tab = $AppUI->processIntState('ProjVwTab', $_GET, 'tab', 0); //TODO: is this different from the above checks for some reason? // Now check if the project is editable/viewable. $denied = $project->getDeniedRecords($AppUI->user_id); if (in_array($project_id, $denied)) { $AppUI->redirect(ACCESS_DENIED); } // get critical tasks (criteria: task_end_date) $criticalTasks = $project_id > 0 ? $project->getCriticalTasks($project_id) : null; // create Date objects from the datetime fields $end_date = intval($project->project_end_date) ? new w2p_Utilities_Date($project->project_end_date) : null; $actual_end_date = null; if (isset($criticalTasks)) { $actual_end_date = intval($criticalTasks[0]['task_end_date']) ? new w2p_Utilities_Date($criticalTasks[0]['task_end_date']) : null; } $style = $actual_end_date > $end_date && !empty($end_date) ? 'style="color:red; font-weight:bold"' : ''; // setup the title block $titleBlock = new w2p_Theme_TitleBlock('View Project', 'icon.png', $m);
if ($obj->project_end_date) { $date = new CDate($obj->project_end_date); $obj->project_end_date = $date->format(FMT_DATETIME_MYSQL); } if ($obj->project_actual_end_date) { $date = new CDate($obj->project_actual_end_date); $obj->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL); } // let's check if there are some assigned departments to project if (!dPgetParam($_POST, "project_departments", 0)) { $obj->project_departments = implode(",", dPgetParam($_POST, "dept_ids", array())); } $del = dPgetParam($_POST, 'del', 0); // prepare (and translate) the module name ready for the suffix if ($del) { if (!$obj->canDelete($msg)) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } if ($msg = $obj->delete()) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } else { $AppUI->setMsg("Project deleted", UI_MSG_ALERT); $AppUI->redirect("m=projects"); } } else { if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { $isNotNew = @$_POST['project_id'];