public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->w2PTrimAll(); $this->project_target_budget = str_replace(',', '', $this->project_target_budget); // ensure changes of state in checkboxes is captured $this->project_active = (int) $this->project_active; $this->project_private = (int) $this->project_private; $this->project_target_budget = $this->project_target_budget ? $this->project_target_budget : 0.0; $this->project_actual_budget = $this->project_actual_budget ? $this->project_actual_budget : 0.0; // Make sure project_short_name is the right size (issue for languages with encoded characters) if (mb_strlen($this->project_short_name) > 10) { $this->project_short_name = mb_substr($this->project_short_name, 0, 10); } if (empty($this->project_end_date)) { $this->project_end_date = null; } $errorMsgArray = $this->check(); if (count($errorMsgArray) > 0) { return $errorMsgArray; } $this->project_id = (int) $this->project_id; // convert dates to SQL format first if ($this->project_start_date) { $date = new CDate($this->project_start_date); $this->project_start_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_end_date) { $date = new CDate($this->project_end_date); $date->setTime(23, 59, 59); $this->project_end_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_actual_end_date) { $date = new CDate($this->project_actual_end_date); $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL); } // let's check if there are some assigned departments to project if ('' != $this->project_actual_end_date) { $obj->project_departments = implode(',', w2PgetParam($_POST, 'dept_ids', array())); } // check project parents and reset them to self if they do not exist if (!$this->project_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; } else { $parent_project = new CProject(); $parent_project->load($this->project_parent); $this->project_original_parent = $parent_project->project_original_parent; } if (!$this->project_original_parent) { $this->project_original_parent = $this->project_id; } /* * TODO: I don't like the duplication on each of these two branches, but I * don't have a good idea on how to fix it at the moment... */ if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->company_id)) { $q = new DBQuery(); $this->project_updated = $q->dbfnNow(); if ($msg = parent::store()) { return $msg; } addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id); $stored = true; } if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) { $q = new DBQuery(); $this->project_updated = $q->dbfnNow(); $this->project_created = $q->dbfnNow(); if ($msg = parent::store()) { return $msg; } if (0 == $this->project_parent || 0 == $this->project_original_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; if ($msg = parent::store()) { return $msg; } } addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id); $stored = true; } //split out related departments and store them seperatly. $q = new DBQuery(); $q->setDelete('project_departments'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_departments) { $departments = explode(',', $this->project_departments); foreach ($departments as $department) { $q->addTable('project_departments'); $q->addInsert('project_id', $this->project_id); $q->addInsert('department_id', $department); $q->exec(); $q->clear(); } } //split out related contacts and store them seperatly. $q->setDelete('project_contacts'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_contacts) { $contacts = explode(',', $this->project_contacts); foreach ($contacts as $contact) { if ($contact) { $q->addTable('project_contacts'); $q->addInsert('project_id', $this->project_id); $q->addInsert('contact_id', $contact); $q->exec(); $q->clear(); } } } if ($stored) { $custom_fields = new CustomFields('projects', 'addedit', $this->project_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->project_id); // Store Custom Fields } return $stored; }
/** * Tests deleting a task with children */ public function testDeleteWithChildren() { $this->obj->load(15); $children = $this->obj->getDeepChildren(); $this->obj->delete(); foreach ($children as $child) { $this->assertFalse($this->obj->load($child)); $this->assertEquals(0, count($this->obj->getAssignedUsers($child))); $this->assertEquals(0, count($this->obj->getTaskLogs($child))); $this->assertEquals(0, count($this->obj->getAssignedUsers($child))); $this->assertEquals(0, count($this->obj->getDependencyList($child))); $this->assertEquals(0, count($this->obj->getDependentTaskList($child))); } /** * Test to make sure project task count was updated */ $project = new CProject(); $project->load(1); $this->assertEquals(27, $project->project_task_count); }
<?php if (!defined('W2P_BASE_DIR')) { die('You should not call this file directly.'); } $sort = w2PgetParam($_REQUEST, 'sort', 'asc'); $forum_id = w2PgetParam($_REQUEST, 'forum_id', 0); $message_id = w2PgetParam($_REQUEST, 'message_id', 0); $perms =& $AppUI->acl(); if (!$perms->checkModuleItem('forums', 'view', $forum_id)) { $AppUI->redirect(ACCESS_DENIED); } $forum = new CForum(); $forum->load($forum_id); $project = new CProject(); $project->load($forum->forum_project); $messages = $forum->getMessages(null, $forum_id, $message_id, $sort); // get the prefered date format $df = $AppUI->getPref('SHDATEFORMAT'); $df .= ' ' . $AppUI->getPref('TIMEFORMAT'); $pdfdata = array(); $pdfhead = array('Date', 'User', 'Message'); foreach ($messages as $row) { // Find the parent message - the topic. if ($row['message_id'] == $message_id) { $topic = $row['message_title']; } $date = new w2p_Utilities_Date($AppUI->formatTZAwareTime($row['message_date'], '%Y-%m-%d %T')); $pdfdata[] = array($date->format($df), $row['contact_display_name'], '<b>' . $row['message_title'] . '</b>' . "\n" . $row['message_body']); } $font_dir = W2P_BASE_DIR . '/lib/ezpdf/fonts';
// get internal companies // 6 is standard value for internal companies $companies_internal = $row->listCompaniesByType(array('6')); $companies_internal = arrayMerge(array('0' => ''), $companies_internal); // pull users $q = new DBQuery(); $q->addTable('users', 'u'); $q->addTable('contacts', 'con'); $q->addQuery('user_id'); $q->addQuery('CONCAT_WS(", ",contact_last_name,contact_first_name)'); $q->addOrder('contact_last_name'); $q->addWhere('u.user_contact = con.contact_id'); $users = $q->loadHashList(); // load the record data $row = new CProject(); if (!$row->load($project_id, false) && $project_id > 0) { $AppUI->setMsg('Project'); $AppUI->setMsg("invalidID", UI_MSG_ERROR, true); $AppUI->redirect(); } else { if (count($companies) < 2 && $project_id == 0) { $AppUI->setMsg("noCompanies", UI_MSG_ERROR, true); $AppUI->redirect(); } } if ($project_id == 0 && $company_id > 0) { $row->project_company = $company_id; } // add in the existing company if for some reason it is dis-allowed if ($project_id && !array_key_exists($row->project_company, $companies)) { $q = new DBQuery();
function canUserEditTimeInformation() { global $AppUI; $project = new CProject(); $project->load($this->task_project); // Code to see if the current user is // enabled to change time information related to task $can_edit_time_information = false; // Let's see if all users are able to edit task time information if (dPgetConfig('restrict_task_time_editing') == true && $this->task_id > 0) { // Am I the task owner? if ($this->task_owner == $AppUI->user_id) { $can_edit_time_information = true; } // Am I the project owner? if ($project->project_owner == $AppUI->user_id) { $can_edit_time_information = true; } // Am I sys admin? if (getPermission('admin', 'edit')) { $can_edit_time_information = true; } } else { if (dPgetConfig('restrict_task_time_editing') == false || $this->task_id == 0) { // If all users are able, then don't check anything $can_edit_time_information = true; } } return $can_edit_time_information; }
/** * Tests deletion of a project. */ public function testDelete() { $this->obj->bind($this->post_data); $result = $this->obj->store(); $this->assertTrue($result); $original_id = $this->obj->project_id; $result = $this->obj->delete(); $item = new CProject(); $item->overrideDatabase($this->mockDB); $this->mockDB->stageHash(array('project_name' => '', 'project_url' => '')); $item->load($original_id); $this->assertTrue(is_a($item, 'CProject')); $this->assertEquals('', $item->project_name); $this->assertEquals('', $item->project_url); /* * TODO: Not sure on how to test the cascading deletes. They're handled * in PHP, not in the database, so we need some assurance that they * actually happen.. */ }
$printpdf = dPgetParam($_REQUEST, 'printpdf', 0); $monospacefont = dPgetParam($_REQUEST, 'monospacefont'); // Get the state of formatting variables here ///////////////////////////////////////////////////// ini_set('memory_limit', $dPconfig['reset_memory_limit']); include $AppUI->getLibraryClass('jpgraph/src/jpgraph'); include $AppUI->getLibraryClass('jpgraph/src/jpgraph_gantt'); require_once 'tasks.class.php'; $project_id = dPgetParam($_REQUEST, 'project_id', 0); $f = dPgetParam($_REQUEST, 'f', 0); // get the prefered date format $df = $AppUI->getPref('SHDATEFORMAT'); require_once $AppUI->getModuleClass('projects'); $project = new CProject(); if ($project_id > 0) { $criticalTasks = $project->getCriticalTasks($project_id); $project->load($project_id); } // pull valid projects and their percent complete information $q = new DBQuery(); $q->addTable('projects'); $q->addQuery('project_id, project_color_identifier, project_name' . ', project_start_date, project_end_date'); $q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project'); $q->addWhere('project_status != 7'); $q->addGroup('project_id'); $q->addOrder('project_name'); $project->setAllowedSQL($AppUI->user_id, $q); $projects = $q->loadHashList('project_id'); $q->clear(); $caller = defVal(@$_REQUEST['caller'], null); /** * if task filtering has been requested create the list of task_ids
public function canAdmin() { if (!$this->file_project) { return false; } if (!$this->file_id) { return false; } $project = new CProject(); $project->project_id = $this->file_project; $project->load(); return $project->project_owner == $this->_AppUI->user_id; }
/** * @deprecated */ public static function updateTaskCount($projectId, $taskCount) { trigger_error("CProject::updateTaskCount has been deprecated in v2.3 and will be removed by v4.0. Please use CProject::updateTaskCache instead.", E_USER_NOTICE); if ((int) $projectId) { $project = new CProject(); $project->load($projectId); $project->project_task_count = $taskCount; $project->store(); self::updatePercentComplete($projectId); } }
function getTaskTooltip($task_id) { global $AppUI; if (!$task_id) { return ''; } $df = $AppUI->getPref('SHDATEFORMAT'); $tf = $AppUI->getPref('TIMEFORMAT'); $task = new CTask(); // load the record data $task->load($task_id); // load the event types $types = w2PgetSysVal('TaskType'); $assignees = $task->assignees($task_id); $assigned = array(); foreach ($assignees as $user) { $assigned[] = $user['contact_name'] . ' ' . $user['perc_assignment'] . '%'; } $start_date = (int) $task->task_start_date ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($task->task_start_date, '%Y-%m-%d %T')) : null; $end_date = (int) $task->task_end_date ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($task->task_end_date, '%Y-%m-%d %T')) : null; // load the record data $project = new CProject(); $project->load($task->task_project); $task_project = $project->project_name; $company = new CCompany(); $company->load($project->project_company); $task_company = $company->company_name; $tt = '<table class="tool-tip">'; $tt .= '<tr>'; $tt .= ' <td valign="top" width="40%">'; $tt .= ' <strong>' . $AppUI->_('Details') . '</strong>'; $tt .= ' <table cellspacing="3" cellpadding="2" width="100%">'; $tt .= ' <tr>'; $tt .= ' <td class="tip-label">' . $AppUI->_('Company') . '</td>'; $tt .= ' <td>' . $task_company . '</td>'; $tt .= ' </tr>'; $tt .= ' <tr>'; $tt .= ' <td class="tip-label">' . $AppUI->_('Project') . '</td>'; $tt .= ' <td>' . $task_project . '</td>'; $tt .= ' </tr>'; $tt .= ' <tr>'; $tt .= ' <td class="tip-label">' . $AppUI->_('Type') . '</td>'; $tt .= ' <td>' . $AppUI->_($types[$task->task_type]) . '</td>'; $tt .= ' </tr> '; $tt .= ' <tr>'; $tt .= ' <td class="tip-label">' . $AppUI->_('Progress') . '</td>'; $tt .= ' <td>' . sprintf("%.1f%%", $task->task_percent_complete) . '</td>'; $tt .= ' </tr> '; $tt .= ' <tr>'; $tt .= ' <td class="tip-label">' . $AppUI->_('Starts') . '</td>'; $tt .= ' <td>' . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . '</td>'; $tt .= ' </tr>'; $tt .= ' <tr>'; $tt .= ' <td class="tip-label">' . $AppUI->_('Ends') . '</td>'; $tt .= ' <td>' . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . '</td>'; $tt .= ' </tr>'; $tt .= ' <tr>'; $tt .= ' <td class="tip-label">' . $AppUI->_('Assignees') . '</td>'; $tt .= ' <td>'; $tt .= implode('<br />', $assigned); $tt .= ' </tr>'; $tt .= ' </table>'; $tt .= ' </td>'; $tt .= ' <td width="60%" valign="top">'; $tt .= ' <strong>' . $AppUI->_('Description') . '</strong>'; $tt .= ' <table cellspacing="0" cellpadding="2" border="0" width="100%">'; $tt .= ' <tr>'; $tt .= ' <td class="tip-label description">'; $tt .= ' ' . $task->task_description; $tt .= ' </td>'; $tt .= ' </tr>'; $tt .= ' </table>'; $tt .= ' </td>'; $tt .= '</tr>'; $tt .= '</table>'; return $tt; }
$row = new CCompany(); $companies = $row->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name'); $companies = arrayMerge(array('0' => ''), $companies); // pull users $q = new DBQuery(); $q->addTable('users', 'u'); $q->addTable('contacts', 'c'); $q->addQuery('user_id'); $q->addQuery('CONCAT_WS(" ",contact_first_name,contact_last_name)'); $q->addOrder('contact_last_name'); $q->addWhere('u.user_contact = c.contact_id'); $q->addWhere('user_id <> 1'); $users = $q->loadHashList(); // load the record data $row = new CProject(); if ($project_id > 0 && !$row->load($project_id, false)) { $AppUI->setMsg('Project'); $AppUI->setMsg("invalidID", UI_MSG_ERROR, true); $AppUI->redirect(); } else { if (count($companies) < 2 && $project_id == 0) { $AppUI->setMsg("noCompanies", UI_MSG_ERROR, true); $AppUI->redirect(); } } if ($project_id == 0 && $company_id > 0) { $row->project_company = $company_id; } // add in the existing company if for some reason it is dis-allowed if ($project_id && !array_key_exists($row->project_company, $companies)) { $q = new DBQuery();
/** * Called by the Event Queue processor to process a reminder * on a task. * @access public * @param string $notUsed Module name (not used) * @param string $notUsed2 Type of event (not used) * @param integer $id ID of task being reminded * @param integer $owner Originator of event * @param mixed $notUsed event-specific arguments. * * @return mixed true, dequeue event, false, event stays in queue. * -1, event is destroyed. */ public function remind($notUsed = null, $notUsed2 = null, $id, $owner, $notUsed3 = null) { // At this stage we won't have an object yet if (!$this->load($id)) { return -1; // No point it trying again later. } $this->htmlDecode(); // Only remind on working days. $today = new w2p_Utilities_Date(); if (!$today->isWorkingDay()) { return true; } // Check if the task is completed if ($this->task_percent_complete == 100) { return -1; } $contacts = $this->assignees($this->task_id); $contact = new CContact(); $owner = $contact->findContactByUserId($this->task_owner); $contacts[$owner->contact_id] = array('user_id' => $this->task_owner, 'contact_id' => $owner->contact_id, 'contact_name' => $owner->contact_display_name, 'contact_email' => $owner->contact_email); // build the subject line, based on how soon the // task will be overdue. $starts = new w2p_Utilities_Date($this->task_start_date); $expires = new w2p_Utilities_Date($this->task_end_date); $now = new w2p_Utilities_Date(); $diff = $expires->dateDiff($now); $diff *= $expires->compare($expires, $now); $prefix = $this->_AppUI->_('Task Due', UI_OUTPUT_RAW); if ($diff == 0) { $msg = $this->_AppUI->_('TODAY', UI_OUTPUT_RAW); } elseif ($diff == 1) { $msg = $this->_AppUI->_('TOMORROW', UI_OUTPUT_RAW); } elseif ($diff < 0) { $msg = $this->_AppUI->_(array('OVERDUE', abs($diff), 'DAYS')); $prefix = $this->_AppUI->_('Task', UI_OUTPUT_RAW); } else { $msg = $this->_AppUI->_(array($diff, 'DAYS')); } $project = new CProject(); $project->overrideDatabase($this->_query); $project_name = $project->load($this->task_project)->project_name; // Check to see that the project is both active and not a template if (!$project->project_active || $project->project_status == w2PgetConfig('template_projects_status_id', 0)) { return -1; } $subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name; $emailManager = new w2p_Output_EmailManager($this->_AppUI); $body = $emailManager->getTaskRemind($this, $msg, $project_name, $contacts); $mail = new w2p_Utilities_Mail(); $mail->Subject($subject); foreach ($contacts as $contact) { $user_id = $contact['user_id']; $this->_AppUI->loadPrefs($user_id); $df = $this->_AppUI->getPref('SHDATEFORMAT'); $tz = $this->_AppUI->getPref('TIMEZONE'); $body = str_replace('START-TIME', $starts->convertTZ($tz)->format($df), $body); $body = str_replace('END-TIME', $expires->convertTZ($tz)->format($df), $body); $mail->Body($body, $this->_locale_char_set); $mail->To($contact['contact_email'], true); $mail->Send(); } return true; }
/** * Delete Request Handler * * This method is called when a request is a DELETE * * @return array */ public function executeDelete() { $valid = $this->hasRequiredParameters($this->requiredParams); if ($valid instanceof Frapi_Error) { return $valid; } $username = $this->getParam('username'); $password = $this->getParam('password'); $project_id = $this->getParam('project_id', self::TYPE_INT); // Attempt to login as user, a little bit of a hack as we currently // require the $_POST['login'] var to be set as well as a global AppUI $AppUI = new CAppUI(); $GLOBALS['AppUI'] = $AppUI; $_POST['login'] = '******'; if (!$AppUI->login($username, $password)) { throw new Frapi_Error('INVALID_LOGIN'); } $project = new CProject(); $project->load($project_id); if (!$project->delete($AppUI)) { throw new Frapi_Error('PERMISSION_ERROR'); } $this->data['success'] = true; return $this->toArray(); }
public function getTaskEmailLog(CTask $task, CTask_Log $log) { $project = new CProject(); $projname = $project->load($task->task_project)->project_name; $contact = new CContact(); $creatorname = $contact->findContactByUserid($log->task_log_creator)->contact_display_name; $body = $this->_AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $projname . "\n"; if ($task->task_parent != $task->task_id) { $tmpTask = new CTask(); $taskname = $tmpTask->load($task->task_parent)->task_name; $body .= $this->_AppUI->_('Parent Task', UI_OUTPUT_RAW) . ': ' . $taskname . "\n"; } $body .= $this->_AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $task->task_name . "\n"; $task_types = w2PgetSysVal('TaskType'); $body .= $this->_AppUI->_('Task Type', UI_OUTPUT_RAW) . ':' . $task_types[$task->task_type] . "\n"; $body .= $this->_AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $task->task_id . "\n\n"; $body .= "------------------------\n\n"; $body .= $this->_AppUI->_('User', UI_OUTPUT_RAW) . ': ' . $creatorname . "\n"; $body .= $this->_AppUI->_('Hours', UI_OUTPUT_RAW) . ': ' . $log->task_log_hours . "\n"; $body .= $this->_AppUI->_('Summary', UI_OUTPUT_RAW) . ': ' . $log->task_log_name . "\n\n"; $body .= $log->task_log_description; $user = new CUser(); $body .= "\n--\n" . $user->load($this->_AppUI->user_id)->user_signature; return $body; }
?> </th> <th><?php echo $AppUI->_('Status'); ?> </th> </tr> <?php //while ($line = mysql_fetch_array($res, MYSQL_ASSOC)) { $s = ''; foreach ($st_projects_arr as $project) { $line = $project[0]; $level = $project[1]; if ($line['project_id']) { $s_project = new CProject(); $s_project->load($line['project_id']); $s_company = new CCompany(); $s_company->load($s_project->project_company); $start_date = intval($s_project->project_start_date) ? new CDate($s_project->project_start_date) : null; $end_date = intval($s_project->project_end_date) ? new CDate($s_project->project_end_date) : null; $actual_end_date = intval($s_project->project_actual_end_date) ? new CDate($s_project->project_actual_end_date) : null; $style = $actual_end_date > $end_date && !empty($end_date) ? 'style="color:red; font-weight:bold"' : ''; $x++; $row_class = $x % 2 ? 'style="background:#fff;"' : 'style="background:#f0f0f0;"'; $row_classr = $x % 2 ? 'style="background:#fff;text-align:right;"' : 'style="background:#f0f0f0;text-align:right;"'; $s .= '<tr><td ' . $row_class . ' align="center"><a href="./index.php?m=projects&a=addedit&project_id=' . $line['project_id'] . '"><img src="' . w2PfindImage('icons/' . ($project_id == $line['project_id'] ? 'pin' : 'pencil') . '.gif') . '" border=0 /></b></a></td>'; $s .= '<td ' . $row_classr . ' nowrap="nowrap">' . $line['project_id'] . '</td>'; if ($level) { $sd = str_repeat(' ', $level - 1) . w2PshowImage('corner-dots.gif', 16, 12) . ' ' . '<a href="./index.php?m=projects&a=view&project_id=' . $line['project_id'] . '">' . $line['project_name'] . '</a>'; } else { $sd = '<a href="./index.php?m=projects&a=view&project_id=' . $line['project_id'] . '">' . $line['project_name'] . '</a>';
<?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);
function notifyContacts() { global $AppUI, $dPconfig, $locale_char_set; //if no project specified than we will not do anything if ($this->file_project != 0) { $project = new CProject(); $project->load($this->file_project); $mail = new Mail(); if (intval($this->file_task) != 0) { //notify task contacts $task = new CTask(); $task->load($this->file_task); $mail->Subject($project->project_name . '::' . $task->task_name . '::' . $this->file_name, $locale_char_set); } else { //notify project contacts $mail->Subject($project->project_name . '::' . $this->file_name, $locale_char_set); } $body = $AppUI->_('Project') . ': ' . $project->project_name; $body .= "\n" . $AppUI->_('URL') . ': ' . DP_BASE_URL . '/index.php?m=projects&a=view&project_id=' . $this->file_project; $users = array(); if (intval($this->file_task) != 0) { $body .= "\n\n" . $AppUI->_('Task') . ': ' . $task->task_name; $body .= "\n" . $AppUI->_('URL') . ': ' . DP_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->file_task; $body .= "\n" . $AppUI->_('Description') . ":\n" . $task->task_description; $this->_query->clear(); $this->_query->addTable('project_contacts', 'pc'); $this->_query->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id'); $this->_query->addQuery('c.contact_email as contact_email' . ', c.contact_first_name as contact_first_name' . ', c.contact_last_name as contact_last_name'); $this->_query->addWhere('pc.project_id = ' . $this->file_project); $pc_users = $this->_query->loadList(); $this->_query->clear(); $this->_query->addTable('task_contacts', 'tc'); $this->_query->addJoin('contacts', 'c', 'c.contact_id = tc.contact_id'); $this->_query->addQuery('c.contact_email as contact_email' . ', c.contact_first_name as contact_first_name' . ', c.contact_last_name as contact_last_name'); $this->_query->addWhere('tc.task_id = ' . $this->file_task); $tc_users = $this->_query->loadList(); $this->_query->clear(); $users = array_merge($pc_users, $tc_users); } else { $this->_query->addTable('project_contacts', 'pc'); $this->_query->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id'); $this->_query->addQuery('c.contact_email as contact_email' . ', c.contact_first_name as contact_first_name' . ', c.contact_last_name as contact_last_name'); $this->_query->addWhere('pc.project_id = ' . $this->file_project); $users = $this->_query->loadList(); $this->_query->clear(); } $body .= "\n\nFile " . $this->file_name . ' was ' . $this->_message . ' by ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name; if ($this->_message != 'deleted') { $body .= "\n" . $AppUI->_('URL') . ': ' . DP_BASE_URL . '/fileviewer.php?file_id=' . $this->file_id; $body .= "\n" . $AppUI->_('Description') . ":\n" . $this->file_description; if ($this->file_co_reason != '') { $body .= "\n" . $AppUI->_('Checkout Reason') . ':' . "\n" . $this->file_co_reason; } } // send mail $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''); $mail->From('"' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name . '" <' . $AppUI->user_email . '>'); foreach ($users as $row) { if ($mail->ValidEmail($row['contact_email'])) { $mail->To($row['contact_email'], true); $mail->Send(); } } } return ''; }
/** Import tasks from another project * * @param int Project ID of the tasks come from. * @return bool **/ function importTasks($from_project_id) { // Load the original $origProject = new CProject(); $origProject->load($from_project_id); $q = new DBQuery(); $q->addTable('tasks'); $q->addQuery('task_id'); $q->addWhere('task_project =' . $from_project_id); $sql = $q->prepare(); $q->clear(); $tasks = array_flip(db_loadColumn($sql)); $origDate = new CDate($origProject->project_start_date); $destDate = new CDate($this->project_start_date); $timeOffset = $destDate->getTime() - $origDate->getTime(); $objTask = new CTask(); // Dependencies array $deps = array(); // Copy each task into this project and get their deps, y tambien copia los usuarios asignados foreach ($tasks as $orig => $void) { $objTask->load($orig); $destTask = $objTask->copy($this->project_id); $tasks[$orig] = $destTask; if ($this->project_company == $origProject->project_company) { // guarda en user_tasks todos los usuarios asignados a la tarea original, solo si this y // origProy pertenecen a la misma compañía. $sql = "select * from user_tasks where task_id = {$orig}"; $rows = db_LoadList($sql); foreach ($rows as $row) { $sql2 = "INSERT INTO user_tasks (user_id, user_type, task_id, perc_assignment, user_task_priority) \n\t\t\t\t\t\t\t\tVALUES (" . $row['user_id'] . "," . $row['user_type'] . "," . $destTask->task_id . "," . $row['perc_assignment'] . "," . $row['user_task_priority'] . ")"; db_exec($sql2); } } $deps[$orig] = $objTask->getDependencies(); } // Fix record integrity foreach ($tasks as $old_id => $newTask) { // Fix parent Task // This task had a parent task, adjust it to new parent task_id if ($newTask->task_id != $newTask->task_parent) { $newTask->task_parent = $tasks[$newTask->task_parent]->task_id; } // Fix task start date from project start date offset $origDate->setDate($newTask->task_start_date); $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME); $destDate = $newTask->next_working_day($destDate); $newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL); // Fix task end date from start date + work duration $newTask->calc_task_end_date(); // Dependencies if (!empty($deps[$old_id])) { $oldDeps = explode(',', $deps[$old_id]); // New dependencies array $newDeps = array(); foreach ($oldDeps as $dep) { $newDeps[] = $tasks[$dep]->task_id; } // Update the new task dependencies $csList = implode(',', $newDeps); $newTask->updateDependencies($csList); } // end of update dependencies //Asignados $newTask->store(); } // end Fix record integrity }
$canEdit = getPermission('tasks', 'add'); } } if (!$canEdit) { $AppUI->redirect('m=public&a=access_denied&err=noedit'); } //check permissions for the associated project $canReadProject = getPermission('projects', 'view', $obj->task_project); $durnTypes = dPgetSysVal('TaskDurationType'); //check the document access (public, participant, private) if (!$obj->canAccess($AppUI->user_id)) { $AppUI->redirect('m=public&a=access_denied&err=noaccess'); } //pull the related project $project = new CProject(); $project->load($task_project); //Pull all users $perms =& $AppUI->acl(); $users = $perms->getPermittedUsers('tasks'); function getSpaces($amount) { return $amount == 0 ? '' : str_repeat(' ', $amount); } function constructTaskTree($task_data, $depth = 0) { global $projTasks, $all_tasks, $parents, $task_parent_options, $task_parent, $task_id; $projTasks[$task_data['task_id']] = $task_data['task_name']; $selected = $task_data['task_id'] == $task_parent ? ' selected="selected"' : ''; $task_data['task_name'] = mb_strlen($task_data[1]) > 45 ? mb_substr($task_data['task_name'], 0, 45) . '...' : $task_data['task_name']; $task_parent_options .= '<option value="' . $task_data['task_id'] . '"' . $selected . '>' . getSpaces($depth * 3) . dPFormSafe($task_data['task_name']) . '</option>'; if (isset($parents[$task_data['task_id']])) {
public function notify($assignees, $update = false, $clash = false) { global $AppUI, $locale_char_set, $w2Pconfig; $mail_owner = $AppUI->getPref('MAILALL'); $assignee_list = explode(',', $assignees); $owner_is_assigned = in_array($this->event_owner, $assignee_list); if ($mail_owner && !$owner_is_assigned && $this->event_owner) { array_push($assignee_list, $this->event_owner); } // Remove any empty elements otherwise implode has a problem foreach ($assignee_list as $key => $x) { if (!$x) { unset($assignee_list[$key]); } } if (!count($assignee_list)) { return; } $q = $this->_query; $q->addTable('users', 'u'); $q->addTable('contacts', 'con'); $q->addQuery('user_id, contact_first_name, contact_last_name, con.contact_id, contact_email'); $q->addWhere('u.user_contact = con.contact_id'); $q->addWhere('user_id in (' . implode(',', $assignee_list) . ')'); $users = $q->loadHashList('user_id'); $date_format = $AppUI->getPref('SHDATEFORMAT'); $time_format = $AppUI->getPref('TIMEFORMAT'); $fmt = $date_format . ' ' . $time_format; $start_date = new w2p_Utilities_Date($this->event_start_date); $end_date = new w2p_Utilities_Date($this->event_end_date); $mail = new w2p_Utilities_Mail(); $type = $update ? $AppUI->_('Updated') : $AppUI->_('New'); if ($clash) { $mail->Subject($AppUI->_('Requested Event') . ': ' . $this->event_title, $locale_char_set); } else { $mail->Subject($type . ' ' . $AppUI->_('Event') . ': ' . $this->event_title, $locale_char_set); } $body = ''; if ($clash) { $emailManager = new w2p_Output_EmailManager(); $body .= $emailManager->getCalendarConflictEmail($AppUI); } $body .= $AppUI->_('Event') . ":\t" . $this->event_title . "\n"; if (!$clash) { $body .= $AppUI->_('URL') . ":\t" . w2PgetConfig('base_url') . "/index.php?m=calendar&a=view&event_id=" . $this->event_id . "\n"; } $body .= $AppUI->_('Starts') . ":\t" . $start_date->format($fmt) . " GMT/UTC\n"; $body .= $AppUI->_('Ends') . ":\t" . $end_date->format($fmt) . " GMT/UTC\n"; // Find the project name. if ($this->event_project) { $project = new CProject(); $project->load($this->event_project); $body .= $AppUI->_('Project') . ":\t" . $project->project_name . "\n"; } $types = w2PgetSysVal('EventType'); $body .= $AppUI->_('Type') . ":\t" . $AppUI->_($types[$this->event_type]) . "\n"; $body .= $AppUI->_('Attendees') . ":\t"; $body_attend = ''; foreach ($users as $user) { $body_attend .= ($body_attend ? ', ' : '') . $user['contact_first_name'] . ' ' . $user['contact_last_name']; } $body .= $body_attend . "\n\n" . $this->event_description . "\n"; $mail->Body($body, $locale_char_set); foreach ($users as $user) { if (!$mail_owner && $user['user_id'] == $this->event_owner) { continue; } $mail->To($user['contact_email'], true); $mail->Send(); } }
/** Import tasks from another project * * @param int Project ID of the tasks come from. * @return bool **/ function importTasks($from_project_id, $scale_project = false) { // Load the original $origProject = new CProject(); $origProject->load($from_project_id); $q = new DBQuery(); $q->addTable('tasks'); $q->addQuery('task_id'); $q->addWhere('task_project =' . $from_project_id); $sql = $q->prepare(); $q->clear(); $tasks = array_flip(db_loadColumn($sql)); //Pristine Start and End Dates of Source and Destination Projects $origStartDate = new CDate($origProject->project_start_date); $origEndDate = new CDate($origProject->project_end_date); $destStartDate = new CDate($this->project_start_date); $destEndDate = new CDate($this->project_end_date); $dateOffset = $destStartDate->dateDiff($origStartDate); //Check that we have enough information to scale properly //(i.e. no information is missing or "zero") if (empty($origProject->project_start_date) || empty($origProject->project_end_date) || empty($this->project_start_date) || empty($this->project_end_date) || $origProject->project_start_date == '0000-00-00 00:00:00' || $origProject->project_end_date == '0000-00-00 00:00:00' || $this->project_start_date == '0000-00-00 00:00:00' || $this->project_end_date == '0000-00-00 00:00:00') { $scale_project = false; } if ($scale_project) { //get ratio for scaling, protect from division by 0 $ratio = (abs($destEndDate->dateDiff($destStartDate)) + 1) / (abs($origEndDate->dateDiff($origStartDate)) + 1); } // Old dependencies array from imported tasks $deps = array(); // New dependencies array for new copies of imported tasks $newDeps = array(); // Old2New task ID array $taskXref = array(); // New task ID to old parent array $nid2op = array(); // Copy each task into this project and get their deps foreach ($tasks as $orig => $void) { $objTask = new CTask(); $objTask->load($orig); // Grab the old parent id $oldParent = (int) $objTask->task_parent; $deps[$orig] = $objTask->getDependencies(); $destTask = $objTask->copy($this->project_id, 0); $nid2op[$destTask->task_id] = $oldParent; $tasks[$orig] = $destTask; $taskXref[$orig] = (int) $destTask->task_id; } // Build new dependencies array foreach ($deps as $odkey => $od) { $ndt = ''; $ndkey = $taskXref[$odkey]; $odep = explode(',', $od); foreach ($odep as $odt) { $ndt = $ndt . $taskXref[$odt] . ','; } $ndt = rtrim($ndt, ','); $newDeps[$ndkey] = $ndt; } $q->addTable('tasks'); $q->addQuery('task_id'); $q->addWhere('task_project =' . $this->project_id); $tasks = $q->loadColumn(); // Update dates based on new project's start date. $origDate = new CDate($origProject->project_start_date); $origStartHour = new CDate($this->project_start_date); $destDate = new CDate($this->project_start_date); foreach ($tasks as $task_id) { $newTask = new CTask(); $newTask->load($task_id); if (in_array($task_id, $taskXref)) { $task_date_vars = array('task_start_date', 'task_end_date'); //Adjust task dates based on calculated offsets foreach ($task_date_vars as $my_date) { if (!empty($newTask->{$my_date}) && $newTask->{$my_date} != '0000-00-00 00:00:00') { $origDate->setDate($newTask->{$my_date}); $origStartHour->setDate($newTask->{$my_date}); $origStartHour->setTime(intval(dPgetConfig('cal_day_start'))); $destDate->setDate($newTask->{$my_date}); $destDate->addDays($dateOffset); if ($scale_project) { $offsetAdd = round($origDate->dateDiff($origStartDate) * $ratio) - $origDate->dateDiff($origStartDate); $destDate->addDays($offsetAdd); $hours_in = $origStartHour->calcDuration($origDate); $offsetAddHours = round($hours_in * $ratio) - $hours_in; if ($offsetAddHours % dPgetConfig('daily_working_hours')) { $destDate->addDuration($offsetAddHours); } } $destDate = $destDate->next_working_day(); $newTask->{$my_date} = $destDate->format(FMT_DATETIME_MYSQL); } } //Adjust durration to scale if ($scale_project) { $newTask->task_duration = round($newTask->task_duration * $ratio, 2); } $newTask->task_parent = $taskXref[$nid2op[$newTask->task_id]]; $newTask->store(); $newTask->updateDependencies($newDeps[$task_id]); } // end check if imported task $newTask->store(); } // end Fix record integrity }
/** Import tasks from another project * * @param int Project ID of the tasks come from. * @return bool **/ function importTasks($from_project_id) { // Load the original $origProject = new CProject(); $origProject->load($from_project_id); $q = new DBQuery(); $q->addTable('tasks'); $q->addQuery('task_id'); $q->addWhere('task_project =' . $from_project_id); $sql = $q->prepare(); $q->clear(); $tasks = array_flip(db_loadColumn($sql)); $origDate = new CDate($origProject->project_start_date); $destDate = new CDate($this->project_start_date); $timeOffset = $destDate->getTime() - $origDate->getTime(); // Dependencies array $deps = array(); // Copy each task into this project and get their deps foreach ($tasks as $orig => $void) { $objTask = new CTask(); $objTask->load($orig); $destTask = $objTask->copy($this->project_id); $tasks[$orig] = $destTask; $deps[$orig] = $objTask->getDependencies(); } // Fix record integrity foreach ($tasks as $old_id => $newTask) { // Fix parent Task // This task had a parent task, adjust it to new parent task_id if ($newTask->task_id != $newTask->task_parent) { $newTask->task_parent = $tasks[$newTask->task_parent]->task_id; } // Fix task start date from project start date offset $origDate->setDate($newTask->task_start_date); $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME); $destDate = $destDate->next_working_day(); $newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL); // Fix task end date from start date + work duration //$newTask->calc_task_end_date(); if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') { $origDate->setDate($newTask->task_end_date); $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME); $destDate = $destDate->next_working_day(); $newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL); } // Dependencies if (!empty($deps[$old_id])) { $oldDeps = explode(',', $deps[$old_id]); // New dependencies array $newDeps = array(); foreach ($oldDeps as $dep) { $newDeps[] = $tasks[$dep]->task_id; } // Update the new task dependencies $csList = implode(',', $newDeps); $newTask->updateDependencies($csList); } // end of update dependencies $newTask->store(); } // end Fix record integrity }
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->w2PTrimAll(); // ensure changes of state in checkboxes is captured $this->project_active = (int) $this->project_active; $this->project_private = (int) $this->project_private; $this->project_target_budget = filterCurrency($this->project_target_budget); $this->project_actual_budget = filterCurrency($this->project_actual_budget); // Make sure project_short_name is the right size (issue for languages with encoded characters) $this->project_short_name = mb_substr($this->project_short_name, 0, 10); if (empty($this->project_end_date)) { $this->project_end_date = null; } $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $this->project_id = (int) $this->project_id; // convert dates to SQL format first if ($this->project_start_date) { $date = new w2p_Utilities_Date($this->project_start_date); $this->project_start_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_end_date) { $date = new w2p_Utilities_Date($this->project_end_date); $date->setTime(23, 59, 59); $this->project_end_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_actual_end_date) { $date = new w2p_Utilities_Date($this->project_actual_end_date); $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL); } // check project parents and reset them to self if they do not exist if (!$this->project_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; } else { $parent_project = new CProject(); $parent_project->load($this->project_parent); $this->project_original_parent = $parent_project->project_original_parent; } if (!$this->project_original_parent) { $this->project_original_parent = $this->project_id; } /* * TODO: I don't like the duplication on each of these two branches, but I * don't have a good idea on how to fix it at the moment... */ $q = $this->_query; $this->project_updated = $q->dbfnNowWithTZ(); if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->project_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) { $this->project_created = $q->dbfnNowWithTZ(); if ($msg = parent::store()) { return $msg; } if (0 == $this->project_parent || 0 == $this->project_original_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; if ($msg = parent::store()) { return $msg; } } $stored = true; } //split out related departments and store them seperatly. $q->setDelete('project_departments'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_departments) { foreach ($this->project_departments as $department) { if ($department) { $q->addTable('project_departments'); $q->addInsert('project_id', $this->project_id); $q->addInsert('department_id', $department); $q->exec(); $q->clear(); } } } //split out related contacts and store them seperatly. $q->setDelete('project_contacts'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_contacts) { foreach ($this->project_contacts as $contact) { if ($contact) { $q->addTable('project_contacts'); $q->addInsert('project_id', $this->project_id); $q->addInsert('contact_id', $contact); $q->exec(); $q->clear(); } } } if ($stored) { $custom_fields = new w2p_Core_CustomFields('projects', 'addedit', $this->project_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->project_id); // Store Custom Fields CTask::storeTokenTask($AppUI, $this->project_id); } return $stored; }
$task_log_id = (int) w2PgetParam($_GET, 'task_log_id', 0); $log = new CTaskLog(); if ($task_log_id) { if (!$canEdit || !$canViewTask) { $AppUI->redirect('m=public&a=access_denied'); } $log->load($task_log_id); } else { if (!$canAdd || !$canViewTask) { $AppUI->redirect('m=public&a=access_denied'); } $log->task_log_task = $obj->task_id; $log->task_log_name = $obj->task_name; } $proj = new CProject(); $proj->load($obj->task_project); $q = new w2p_Database_Query(); $q->addTable('billingcode'); $q->addQuery('billingcode_id, billingcode_name'); $q->addWhere('billingcode_status=0'); $q->addWhere('(company_id=' . $proj->project_company . ' OR company_id = 0)'); $q->addOrder('billingcode_name'); $task_log_costcodes[0] = ''; $rows = $q->loadList(); echo db_error(); $nums = 0; foreach ($rows as $key => $row) { $task_log_costcodes[$row['billingcode_id']] = $row['billingcode_name']; } $taskLogReference = w2PgetSysVal('TaskLogReference'); // Task Update Form
/** * Called by the Event Queue processor to process a reminder * on a task. * @access public * @param string $module Module name (not used) * @param string $type Type of event (not used) * @param integer $id ID of task being reminded * @param integer $owner Originator of event * @param mixed $args event-specific arguments. * @return mixed true, dequeue event, false, event stays in queue. * -1, event is destroyed. */ public function remind($module, $type, $id, $owner, &$args) { global $locale_char_set, $AppUI; $q = new w2p_Database_Query(); // At this stage we won't have an object yet if (!$this->load($id)) { return -1; // No point it trying again later. } $this->htmlDecode(); // Only remind on working days. $today = new w2p_Utilities_Date(); if (!$today->isWorkingDay()) { return true; } // Check if the task is completed if ($this->task_percent_complete == 100) { return -1; } $contacts = $this->getAssigned(); // Now we also check the owner of the task, as we will need // to notify them as well. $owner_is_not_assignee = false; $q->addTable('users', 'u'); $q->addJoin('contacts', 'c', 'c.contact_id = u.user_contact', 'inner'); $q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email'); $q->addWhere('u.user_id = ' . (int) $this->task_owner); if ($q->exec(ADODB_FETCH_NUM)) { list($owner_contact, $owner_first_name, $owner_last_name, $owner_email) = $q->fetchRow(); if (!isset($contacts[$owner_contact])) { $owner_is_not_assignee = true; $contacts[$owner_contact] = array('contact_id' => $owner_contact, 'contact_first_name' => $owner_first_name, 'contact_last_name' => $owner_last_name, 'contact_email' => $owner_email); } } $q->clear(); // build the subject line, based on how soon the // task will be overdue. $starts = new w2p_Utilities_Date($this->task_start_date); $expires = new w2p_Utilities_Date($this->task_end_date); $now = new w2p_Utilities_Date(); $diff = $expires->dateDiff($now); $diff *= w2p_Utilities_Date::compare($expires, $now); $prefix = $AppUI->_('Task Due', UI_OUTPUT_RAW); if ($diff == 0) { $msg = $AppUI->_('TODAY', UI_OUTPUT_RAW); } elseif ($diff == 1) { $msg = $AppUI->_('TOMORROW', UI_OUTPUT_RAW); } elseif ($diff < 0) { $msg = $AppUI->_(array('OVERDUE', abs($diff), 'DAYS')); $prefix = $AppUI->_('Task', UI_OUTPUT_RAW); } else { $msg = $AppUI->_(array($diff, 'DAYS')); } $project = new CProject(); $project_name = $project->load($this->task_project)->project_name; // Check to see that the project is both active and not a template if (!$project->project_active || $project->project_status == w2PgetConfig('template_projects_status_id', 0)) { return -1; } $subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name; $body = $AppUI->_('Task Due', UI_OUTPUT_RAW) . ': ' . $msg . "\n" . $AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $project_name . "\n" . $AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $this->task_name . "\n" . $AppUI->_('Start Date', UI_OUTPUT_RAW) . ': START-TIME' . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': END-TIME' . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . '&reminded=1' . "\n\n" . $AppUI->_('Resources', UI_OUTPUT_RAW) . ":\n"; foreach ($contacts as $contact) { if (!$owner_is_not_assignee || $owner_is_not_assignee && $contact['contact_id'] != $owner_contact) { $body .= $contact['contact_first_name'] . ' ' . $contact['contact_last_name'] . ' <' . $contact['contact_email'] . ">\n"; } } $body .= "\n" . $AppUI->_('Description', UI_OUTPUT_RAW) . ":\n" . $this->task_description . "\n"; $mail = new w2p_Utilities_Mail(); $mail->Subject($subject, $locale_char_set); foreach ($contacts as $contact) { $user_id = CUser::getUserIdByContactID($contact['contact_id']); $AppUI->loadPrefs($user_id); $df = $AppUI->getPref('DISPLAYFORMAT'); $tz = $AppUI->getPref('TIMEZONE'); $body = str_replace('START-TIME', $starts->convertTZ($tz)->format($df), $body); $body = str_replace('END-TIME', $expires->convertTZ($tz)->format($df), $body); $mail->Body($body, $locale_char_set); if ($mail->ValidEmail($contact['contact_email'])) { $mail->To($contact['contact_email'], true); $mail->Send(); } } return true; }
echo $str; if ($project_id == 0) { $pdfdata[] = array($task['project_name'], $task['task_name'], $task['task_description'], $users, $start_date != ' ' ? $start_date->format($df) : ' ', $end_date != ' ' ? $end_date->format($df) : ' ', $task['task_percent_complete'] . '%'); } else { $start_date = new w2p_Utilities_Date($task['task_start_date']); $end_date = new w2p_Utilities_Date($task['task_end_date']); $spacer = str_repeat(' ', $task['depth']); $pdfdata[] = array($spacer . $task['task_name'], $task['task_description'], implode($users, ', '), $start_date != ' ' ? $start_date->format($df) : ' ', $end_date != ' ' ? $end_date->format($df) : ' ', $task['task_percent_complete'] . '%'); } } } echo '</table>'; if ($log_pdf) { // make the PDF file $project = new CProject(); $project->load((int) $project_id); $pname = $project->project_name; $temp_dir = W2P_BASE_DIR . '/files/temp'; $output = new w2p_Output_PDFRenderer('A4', 'landscape'); $output->addTitle($AppUI->_('Project Task Report')); $output->addDate($df); $output->addSubtitle(w2PgetConfig('company_name')); if ($project_id != 0) { $output->addSubtitle($pname); } $subhead = ''; if ($log_all) { $title = $AppUI->_('All task entries'); } else { if ($end_date != ' ') { $title = $AppUI->_('Task entries from') . ' ' . $start_date->format($df) . $AppUI->_('to') . ' ' . $end_date->format($df);
<?php /* PROJECTS $Id: reports.php,v 1.12.2.3 2007/01/31 09:36:52 ajdonnison Exp $ */ define("MANAGER", 5); //error_reporting( E_ALL ); if (!defined('DP_BASE_DIR')) { die('You should not access this file directly'); } $project_id = intval(dPgetParam($_REQUEST, "project_id", 0)); $report_type = dPgetParam($_REQUEST, "report_type", ''); // check permissions for this record $perms =& $AppUI->acl(); $obj = new CProject(); $obj->load($project_id); $canRead = $perms->checkModuleItem($m, 'view', $project_id) && ($AppUI->user_id == $obj->project_owner || $AppUI->user_type <= MANAGER); if (!$canRead) { $AppUI->setMsg('Access denied', UI_MSG_ERROR); $AppUI->redirect(); } $display_project_name = $obj->project_name; if (!$suppressHeaders) { ?> <script language="javascript"> function changeIt() { var f=document.changeMe; f.submit(); } </script> <?php
} // load the event types $types = w2PgetSysVal('EventType'); // load the event recurs types $recurs = array('Never', 'Hourly', 'Daily', 'Weekly', 'Bi-Weekly', 'Every Month', 'Quarterly', 'Every 6 months', 'Every Year'); $assigned = $event->getAssigned(); if ($event->event_owner != $AppUI->user_id && !canView('admin')) { $canEdit = false; } $df = $AppUI->getPref('SHDATEFORMAT'); $tf = $AppUI->getPref('TIMEFORMAT'); $start_date = $event->event_start_date ? new w2p_Utilities_Date($event->event_start_date) : new w2p_Utilities_Date(); $end_date = $event->event_end_date ? new w2p_Utilities_Date($event->event_end_date) : new w2p_Utilities_Date(); if ($event->event_project) { $project = new CProject(); $event_project = $project->load($event->event_project)->project_name; } // setup the title block $titleBlock = new CTitleBlock('View Event', 'myevo-appointments.png', $m, $m . '.' . $a); if ($canEdit) { $titleBlock->addCell(); $titleBlock->addCell(' <form action="?m=calendar&a=addedit" method="post" accept-charset="utf-8"> <input type="submit" class="button" value="' . $AppUI->_('new event') . '" /> </form>', '', '', ''); } $titleBlock->addCrumb('?m=calendar&date=' . $start_date->format(FMT_TIMESTAMP_DATE), 'month view'); $titleBlock->addCrumb('?m=calendar&a=day_view&date=' . $start_date->format(FMT_TIMESTAMP_DATE) . '&tab=0', 'day view'); if ($canEdit) { $titleBlock->addCrumb('?m=calendar&a=addedit&event_id=' . $event_id, 'edit this event'); if ($canDelete) {
$q->addWhere('project_company = ' . (int) $company_id); } $q->addWhere('project_original_parent = ' . (int) $original_project_id); $pjobj->setAllowedSQL($AppUI->user_id, $q, null, 'pr'); $q->addGroup('pr.project_id'); $q->addOrder('project_start_date, project_end_date, project_name'); $projects = $q->loadHashList('project_id'); $q->clear(); $width = w2PgetParam($_GET, 'width', 600); $start_date = w2PgetParam($_GET, 'start_date', 0); $end_date = w2PgetParam($_GET, 'end_date', 0); $showAllGantt = w2PgetParam($_REQUEST, 'showAllGantt', '1'); $gantt = new w2p_Output_GanttRenderer($AppUI, $width); $gantt->localize(); $original_project = new CProject(); $original_project->load($original_project_id); $tableTitle = $original_project->project_name . ': ' . $AppUI->_('Multi-Project Gantt'); $gantt->setTitle($tableTitle, '#eeeeee'); $columnNames = array('Project name', 'Start Date', 'Finish', 'Actual End'); $columnSizes = array(200, 75, 75, 75); $gantt->setColumnHeaders($columnNames, $columnSizes); /* * TODO: Technically, doing the date math below using the strtotime is bad * form because it is suseptible to the 2038 date bug. Hopefully, we'll * either have this bug fixed and resolved by then and/or no one is * scheduling projects 28 years into the future. Regardless, it's much * easier than actual date math. * ~ caseydk 22 Aug 2010 */ if (!$start_date || !$end_date) { $i = 0;
<?php define('SYSADMIN', 1); $id = intval(dPgetParam($_GET, 'project_id', 0)); // check permissions for this record $perms =& $AppUI->acl(); $canRead = $perms->checkModuleItem($m, 'view', $id); if (!$canRead) { $AppUI->showMsg('Access denied', UI_MSG_ERROR); exit; } $obj = new CProject(); $denied = $obj->getDeniedRecords($AppUI->user_id); if (in_array($id, $denied)) { $AppUI->showMsg('Access denied', UI_MSG_ERROR); exit; } $obj->load($id); $isProjectManager = $AppUI->user_id == $obj->getManager(); $canEdit = $perms->checkModuleItem($m, 'edit', $id) && ($AppUI->user_type == SYSADMIN || $isProjectManager); if (!$canEdit) { $AppUI->showMsg('Access denied', UI_MSG_ERROR); exit; } $q = new DBQuery(); $q->addTable('projects'); $q->addUpdate('project_status', $_GET['status']); $q->addWhere('project_id = ' . $id); $q->exec(); echo 'OK';