本文整理汇总了PHP中ProjectMilestones::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectMilestones::findById方法的具体用法?PHP ProjectMilestones::findById怎么用?PHP ProjectMilestones::findById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectMilestones
的用法示例。
在下文中一共展示了ProjectMilestones::findById方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMilestone
function getMilestone()
{
if ($this->getMilestoneId() > 0 && !$this->milestone) {
$this->milestone = ProjectMilestones::findById($this->getMilestoneId());
}
return $this->milestone;
}
示例2: open
/**
* Open specific milestone
*
* @access public
* @param void
* @return null
*/
function open()
{
$milestone = ProjectMilestones::findById(get_id());
if (!$milestone instanceof ProjectMilestone) {
flash_error(lang('milestone dnx'));
$this->redirectTo('milestone');
}
// if
if (!$milestone->canChangeStatus(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('milestone'));
}
// if
try {
$milestone->setCompletedOn(null);
$milestone->setCompletedById(0);
DB::beginWork();
$milestone->save();
ApplicationLogs::createLog($milestone, active_project(), ApplicationLogs::ACTION_OPEN);
DB::commit();
flash_success(lang('success open milestone', $milestone->getName()));
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error open milestone'));
}
// try
$this->redirectToReferer($milestone->getViewUrl());
}
示例3: getExternalColumnValue
function getExternalColumnValue($field, $id, $manager = null, $object = null)
{
$value = '';
if ($field == 'user_id' || $field == 'contact_id' || $field == 'created_by_id' || $field == 'updated_by_id' || $field == 'assigned_to_contact_id' || $field == 'assigned_by_id' || $field == 'completed_by_id' || $field == 'approved_by_id') {
$contact = Contacts::findById($id);
if ($contact instanceof Contact) {
$value = $contact->getObjectName();
}
} else {
if ($field == 'milestone_id') {
$milestone = ProjectMilestones::findById($id);
if ($milestone instanceof ProjectMilestone) {
$value = $milestone->getObjectName();
}
} else {
if ($field == 'company_id') {
$company = Contacts::findById($id);
if ($company instanceof Contact && $company->getIsCompany()) {
$value = $company->getObjectName();
}
} else {
if ($field == 'rel_object_id') {
$value = $id;
} else {
if ($manager instanceof ContentDataObjects) {
$value = $manager->getExternalColumnValue($field, $id);
}
}
}
}
}
Hook::fire('custom_reports_get_external_column_value', array('field' => $field, 'external_id' => $id, 'manager' => $manager, 'object' => $object), $value);
return $value;
}
示例4: getMilestone
/**
* Return milestone
*
* @access public
* @param void
* @return array
*/
function getMilestone()
{
if (is_null($this->milestone)) {
$this->milestone = ProjectMilestones::findById($this->getMilestoneId());
}
// if
return $this->milestone;
}
示例5: change_due_date
function change_due_date()
{
$milestone = ProjectMilestones::findById(get_id());
if (!$milestone->canEdit(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$year = array_var($_GET, 'year', $milestone->getDueDate()->getYear());
$month = array_var($_GET, 'month', $milestone->getDueDate()->getMonth());
$day = array_var($_GET, 'day', $milestone->getDueDate()->getDay());
try {
DB::beginWork();
$milestone->setDueDate(new DateTimeValue(mktime(0, 0, 0, $month, $day, $year)));
$milestone->save();
DB::commit();
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error change due date milestone'));
}
// try
ajx_current("empty");
}
示例6: quick_edit_task
function quick_edit_task()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
ajx_current("empty");
$task = ProjectTasks::findById(get_id());
if (!$task instanceof ProjectTask) {
flash_error(lang('task list dnx'));
return;
}
// if
if (!$task->canEdit(logged_user())) {
flash_error(lang('no access permissions'));
return;
}
// if
$task_data = array_var($_POST, 'task');
if (is_array($task_data)) {
$task_data['due_date'] = getDateValue(array_var($task_data, 'task_due_date'));
$task_data['start_date'] = getDateValue(array_var($task_data, 'task_start_date'));
$old_milestone_id = $task->getMilestoneId();
$task->setFromAttributes($task_data);
$project = Projects::findById(array_var($task_data, 'project_id', 0));
//$task->setOrder(ProjectTasks::maxOrder(array_var($task_data, "parent_id", 0), array_var($task_data, "milestone_id", 0)));
// Set assigned to
$assigned_to = explode(':', array_var($task_data, 'assigned_to', ''));
$company_id = array_var($assigned_to, 0, 0);
$user_id = array_var($assigned_to, 1, 0);
$can_assign = can_assign_task_to_company_user(logged_user(), $task, $company_id, $user_id);
if ($can_assign !== true) {
flash_error($can_assign);
return;
}
$task->setAssignedToCompanyId($company_id);
$task->setAssignedToUserId($user_id);
//$task->setIsPrivate(false); // Not used, but defined as not null.
/*if (array_var($task_data,'is_completed',false) == 'true'){
$task->setCompletedOn(DateTimeValueLib::now());
$task->setCompletedById(logged_user()->getId());
}*/
if (array_var($_GET, 'dont_mark_as_read')) {
$is_read = $task->getIsRead(logged_user()->getId());
}
try {
DB::beginWork();
$task->save();
if (array_var($_GET, 'dont_mark_as_read') && !$is_read) {
$task->setIsRead(logged_user()->getId(), false);
}
if ($project instanceof Project && $task->canAdd(logged_user(), $project)) {
$task->setProject($project);
}
$task->setTagsFromCSV(array_var($task_data, 'tags'));
// apply values to subtasks
$subtasks = $task->getAllSubTasks();
$project = $task->getProject();
$milestone_id = $task->getMilestoneId();
//Check for milestone workspace restrictions, update the task's workspace if milestone changed
if ($milestone_id > 0 && $old_milestone_id != $milestone_id) {
$milestone = ProjectMilestones::findById($milestone_id);
$milestoneWs = $milestone->getProject();
if ($milestoneWs->getId() != $project->getId() && !$milestoneWs->isParentOf($project)) {
$project = $milestoneWs;
if ($task->canAdd(logged_user(), $project)) {
$task->setProject($project);
} else {
throw new Exception(lang('no access permissions'));
}
}
}
$apply_ws = array_var($task_data, 'apply_ws_subtasks', '') == "checked";
$apply_ms = array_var($task_data, 'apply_milestone_subtasks', '') == "checked";
$apply_at = array_var($task_data, 'apply_assignee_subtasks', '') == "checked";
$modified_subtasks = array();
foreach ($subtasks as $sub) {
$modified = false;
if ($apply_at || !$sub->getAssignedTo() instanceof ApplicationDataObject) {
$sub->setAssignedToCompanyId($company_id);
$sub->setAssignedToUserId($user_id);
$modified = true;
}
if ($apply_ws) {
$sub->setProject($project);
$modified = true;
}
if ($apply_ms) {
$sub->setMilestoneId($milestone_id);
$modified = true;
}
if ($modified) {
$sub->save();
$modified_subtasks[] = $sub;
}
}
//Add new work timeslot for this task
if (array_var($task_data, 'hours') != '' && array_var($task_data, 'hours') > 0) {
$hours = array_var($task_data, 'hours');
//.........这里部分代码省略.........
示例7: getMilestoneGroups
private function getMilestoneGroups($conditions, $show_more_conditions, $list_subtasks_cond)
{
$milestone_field = "`milestone_id`";
$groupId = $show_more_conditions['groupId'];
$start = $show_more_conditions['start'];
$limit = $show_more_conditions['limit'];
$groups = ProjectTasks::instance()->listing(array("select_columns" => array($milestone_field . " AS group_id ", $milestone_field . " AS group_name ", "COUNT(o.id) AS total"), "extra_conditions" => $conditions . $list_subtasks_cond, "group_by" => " `group_name`", "count_results" => false, "raw_data" => true))->objects;
$more_group_ret = array();
foreach ($groups as $key => $group) {
if (!is_null($groupId) && $group['group_id'] != $groupId) {
continue;
}
$group_conditions = " AND " . $milestone_field . " = '" . $group['group_id'] . "'";
$tasks_in_group = $this->getTasksInGroup($conditions . $group_conditions . $list_subtasks_cond, $start, $limit);
$groups[$key]['root_total'] = $tasks_in_group['total_roots_tasks'];
$groups[$key]['group_tasks'] = $tasks_in_group['tasks'];
if ($group['group_id'] > 0) {
$milestone = ProjectMilestones::findById($group['group_id']);
$groups[$key]['group_name'] = $milestone->getName();
} else {
$groups[$key]['group_name'] = lang('unclassified');
}
$groups[$key]['group_icon'] = 'ico-milestone';
//group totals
$totals = $this->getGroupTotals($conditions . $group_conditions);
foreach ($totals as $total_key => $total) {
$groups[$key][$total_key] = $total;
}
if (!is_null($groupId)) {
$more_group_ret[] = $groups[$key];
}
}
if (user_config_option('tasksShowEmptyMilestones')) {
//group totals
$join_params['join_type'] = "LEFT ";
$join_params['table'] = TABLE_PREFIX . "project_tasks";
$join_params['jt_field'] = "milestone_id";
$join_params['e_field'] = "object_id";
$empty_milestones = ProjectMilestones::instance()->listing(array("select_columns" => array("`e`.`object_id` AS group_id ", "`name` AS group_name "), "extra_conditions" => " AND `jt`.`object_id` IS NULL", "join_params" => $join_params, "count_results" => false, "raw_data" => true))->objects;
foreach ($empty_milestones as $keym => $empty_milestone) {
$empty_group = array();
$empty_group['group_name'] = $empty_milestone['group_name'];
$empty_group['group_id'] = $empty_milestone['group_id'];
$empty_group['group_icon'] = 'ico-milestone';
$empty_group['group_tasks'] = array();
$groups[] = $empty_group;
}
}
if (!is_null($groupId)) {
return $more_group_ret;
} else {
return $groups;
}
}
示例8: getExternalColumnValue
function getExternalColumnValue($field, $id, $manager = null){
$value = '';
if($field == 'user_id' || $field == 'contact_id' || $field == 'created_by_id' || $field == 'updated_by_id' || $field == 'assigned_to_contact_id' || $field == 'completed_by_id'|| $field == 'approved_by_id'){
$contact = Contacts::findById($id);
if($contact instanceof Contact) $value = $contact->getObjectName();
} else if($field == 'milestone_id'){
$milestone = ProjectMilestones::findById($id);
if($milestone instanceof ProjectMilestone) $value = $milestone->getObjectName();
} else if($field == 'company_id'){
$company = Contacts::findById($id);
if($company instanceof Contact && $company->getIsCompany()) $value = $company->getObjectName();
} else if ($manager instanceof ContentDataObjects) {
$value = $manager->getExternalColumnValue($field, $id);
}
return $value;
}
示例9: getMilestone
/**
* Return milestone obj
*
* @access public
* @param void
* @return Project
*/
function getMilestone()
{
return ProjectMilestones::findById($this->getMilestoneId());
}
示例10: select_milestone
/**
* Renders select milestone box
*
* @param string $name
* @param Project $project
* @param integer $selected ID of selected milestone
* @param array $attributes Array of additional attributes
* @return string
* @throws InvalidInstanceError
*/
function select_milestone($name, $project = null, $selected = null, $attributes = null)
{
if (is_array($attributes)) {
if (!isset($attributes['class'])) {
$attributes['class'] = 'select_milestone';
}
} else {
$attributes = array('class' => 'select_milestone');
}
// if
$options = array(option_tag(lang('none'), 0));
if ($project) {
$milestones = $project->getOpenMilestones();
} else {
$milestones = ProjectMilestones::getActiveMilestonesByUser(logged_user());
}
if (is_array($milestones)) {
if ($selected) {
//Fixes bug: If task is in a subworkspace of it's milestone's workspace, and user is standing on it, the assigned milestone is set to none when task is edited.
$is_in_array = false;
foreach ($milestones as $milestone) {
if ($milestone->getId() == $selected) {
$is_in_array = true;
}
}
if (!$is_in_array) {
$milestone = ProjectMilestones::findById($selected);
if ($milestone) {
$milestones[] = $milestone;
}
}
}
foreach ($milestones as $milestone) {
$option_attributes = $milestone->getId() == $selected ? array('selected' => 'selected') : null;
$options[] = option_tag($milestone->getName(), $milestone->getId(), $option_attributes);
}
// foreach
}
// if
return select_box($name, $options, $attributes);
}
示例11: getExternalColumnValue
static function getExternalColumnValue($field, $id)
{
$value = '';
if ($field == 'company_id' || $field == 'assigned_to_company_id') {
$company = Companies::findById($id);
if ($company instanceof Company) {
$value = $company->getName();
}
} else {
if ($field == 'user_id' || $field == 'created_by_id' || $field == 'updated_by_id' || $field == 'assigned_to_user_id' || $field == 'completed_by_id') {
$user = Users::findById($id);
if ($user instanceof User) {
$value = $user->getUsername();
}
} else {
if ($field == 'milestone_id') {
$milestone = ProjectMilestones::findById($id);
if ($milestone instanceof ProjectMilestone) {
$value = $milestone->getName();
}
} else {
if ($field == 'object_subtype') {
$object_subtype = ProjectCoTypes::findById($id);
if ($object_subtype instanceof ProjectCoType) {
$value = $object_subtype->getName();
}
}
}
}
}
return $value;
}