本文整理汇总了PHP中ProjectTasks::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectTasks::findById方法的具体用法?PHP ProjectTasks::findById怎么用?PHP ProjectTasks::findById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectTasks
的用法示例。
在下文中一共展示了ProjectTasks::findById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPreviousTasks
static function getPreviousTasks($task_id)
{
$previous_tasks = array();
$deps = self::getDependenciesForTask($task_id);
foreach ($deps as $dep) {
/* @var $dep ProjectTaskDependency */
$task = ProjectTasks::findById($dep->getPreviousTaskId());
if ($task instanceof ProjectTask) {
$previous_tasks[] = $task;
}
}
return $previous_tasks;
}
示例2: percent_complete_delete
function percent_complete_delete($time_slot)
{
$timeslot_time = ($time_slot->getEndTime()->getTimestamp() - ($time_slot->getStartTime()->getTimestamp() + $time_slot->getSubtract())) / 3600;
$task = ProjectTasks::findById($time_slot->getRelObjectId());
if ($task->getTimeEstimate() > 0) {
$timeslot_percent = round($timeslot_time * 100 / ($task->getTimeEstimate() / 60));
$total_percentComplete = $task->getPercentCompleted() - $timeslot_percent;
if ($total_percentComplete < 0) {
$total_percentComplete = 0;
}
$task->setPercentCompleted($total_percentComplete);
$task->save();
}
}
示例3: index
function index()
{
$tasksUserId = array_var($_GET, 'tu');
if (is_null($tasksUserId)) {
$tasksUserId = user_config_option('TM tasks user filter', logged_user()->getId());
} else {
if (user_config_option('TM tasks user filter') != $tasksUserId) {
set_user_config_option('TM tasks user filter', $tasksUserId, logged_user()->getId());
}
}
$timeslotsUserId = array_var($_GET, 'tsu');
if (is_null($timeslotsUserId)) {
$timeslotsUserId = user_config_option('TM user filter', 0);
} else {
if (user_config_option('TM user filter') != $timeslotsUserId) {
set_user_config_option('TM user filter', $timeslotsUserId, logged_user()->getId());
}
}
$showTimeType = array_var($_GET, 'stt');
if (is_null($showTimeType)) {
$showTimeType = user_config_option('TM show time type', 0);
} else {
if (user_config_option('TM show time type') != $showTimeType) {
set_user_config_option('TM show time type', $showTimeType, logged_user()->getId());
}
}
$start = array_var($_GET, 'start', 0);
$limit = 20;
$tasksUser = Contacts::findById($tasksUserId);
$timeslotsUser = Contacts::findById($timeslotsUserId);
//Active tasks view
$open_timeslots = Timeslots::instance()->listing(array("extra_conditions" => " AND end_time = '" . EMPTY_DATETIME . "' AND contact_id = " . $tasksUserId))->objects;
$tasks = array();
foreach ($open_timeslots as $open_timeslot) {
$task = ProjectTasks::findById($open_timeslot->getRelObjectId());
if ($task instanceof ProjectTask && !$task->isCompleted() && !$task->isTrashed() && !$task->isArchived()) {
$tasks[] = $task;
}
}
ProjectTasks::populateTimeslots($tasks);
//Timeslots view
$total = 0;
switch ($showTimeType) {
case 0:
//Show only timeslots added through the time panel
$result = Timeslots::getGeneralTimeslots(active_context(), $timeslotsUser, $start, $limit);
$timeslots = $result->objects;
$total = $result->total;
break;
default:
throw new Error('Unrecognised TM show time type: ' . $showTimeType);
}
//Get Users Info
$users = array();
$context = active_context();
if (!can_manage_time(logged_user())) {
if (can_add(logged_user(), $context, Timeslots::instance()->getObjectTypeId())) {
$users = array(logged_user());
}
} else {
if (logged_user()->isMemberOfOwnerCompany()) {
$users = Contacts::getAllUsers();
} else {
$users = logged_user()->getCompanyId() > 0 ? Contacts::getAllUsers(" AND `company_id` = " . logged_user()->getCompanyId()) : array(logged_user());
}
$tmp_users = array();
foreach ($users as $user) {
if (can_add($user, $context, Timeslots::instance()->getObjectTypeId())) {
$tmp_users[] = $user;
}
}
$users = $tmp_users;
}
//Get Companies Info
if (logged_user()->isMemberOfOwnerCompany() || logged_user()->isAdminGroup()) {
$companies = Contacts::getCompaniesWithUsers();
} else {
$companies = array();
if (logged_user()->getCompanyId() > 0) {
$companies[] = logged_user()->getCompany();
}
}
$required_dimensions = DimensionObjectTypeContents::getRequiredDimensions(Timeslots::instance()->getObjectTypeId());
$draw_inputs = !$required_dimensions || count($required_dimensions) == 0;
if (!$draw_inputs) {
$ts_ots = DimensionObjectTypeContents::getDimensionObjectTypesforObject(Timeslots::instance()->getObjectTypeId());
$context = active_context();
foreach ($context as $sel) {
if ($sel instanceof Member) {
foreach ($ts_ots as $ts_ot) {
if ($sel->getDimensionId() == $ts_ot->getDimensionId() && $sel->getObjectTypeId() == $ts_ot->getDimensionObjectTypeId()) {
$draw_inputs = true;
break;
}
}
if ($draw_inputs) {
break;
}
}
}
//.........这里部分代码省略.........
示例4: save
/**
* Save this list
*
* @param void
* @return boolean
*/
function save()
{
if (!$this->isNew()) {
$old_me = ProjectTasks::findById($this->getId(), true);
if (!$old_me instanceof ProjectTask) {
return;
}
// TODO: check this!!!
// This was added cause deleting some tasks was giving an error, couldn't reproduce it again, but this solved it
}
if ($this->isNew() || $this->getAssignedToContactId() != $old_me->getAssignedToContactId()) {
$this->setAssignedBy(logged_user());
$this->setAssignedOn(DateTimeValueLib::now());
}
$due_date_changed = false;
if (!$this->isNew()) {
$old_due_date = $old_me->getDueDate();
$due_date = $this->getDueDate();
if ($due_date instanceof DateTimeValue) {
if (!$old_due_date instanceof DateTimeValue || $old_due_date->getTimestamp() != $due_date->getTimestamp()) {
$due_date_changed = true;
}
} else {
if ($old_due_date instanceof DateTimeValue) {
$due_date_changed = true;
}
}
}
//update Depth And Parents Path
$parent_id_changed = false;
$new_parent_id = $this->getParentId();
if (!$this->isNew()) {
$old_parent_id = $old_me->getParentId();
if ($old_parent_id != $new_parent_id) {
$this->updateDepthAndParentsPath($new_parent_id);
}
} else {
$this->updateDepthAndParentsPath($new_parent_id);
}
parent::save();
if ($due_date_changed) {
$id = $this->getId();
$sql = "UPDATE `" . TABLE_PREFIX . "object_reminders` SET\r\n\t\t\t\t`date` = date_sub((SELECT `due_date` FROM `" . TABLE_PREFIX . "project_tasks` WHERE `object_id` = {$id}),\r\n\t\t\t\t\tinterval `minutes_before` minute) WHERE `object_id` = {$id};";
DB::execute($sql);
}
$old_parent_id = isset($old_me) && $old_me instanceof ProjectTask ? $old_me->getParentId() : 0;
if ($this->isNew() || $old_parent_id != $new_parent_id) {
//update Depth And Parents Path for subtasks
$subtasks = $this->getSubTasks();
if (is_array($subtasks)) {
foreach ($subtasks as $subtask) {
$subtask->updateDepthAndParentsPath($this->getId());
$subtask->save();
}
// if
}
// if
}
return true;
}
示例5: executeReport
/**
* Execute a report and return results
*
* @param $id
* @param $params
*
* @return array
*/
static function executeReport($id, $params, $order_by_col = '', $order_by_asc = true, $offset = 0, $limit = 50, $to_print = false)
{
if (is_null(active_context())) {
CompanyWebsite::instance()->setContext(build_context_array(array_var($_REQUEST, 'context')));
}
$results = array();
$report = self::getReport($id);
$show_archived = false;
if ($report instanceof Report) {
$conditionsFields = ReportConditions::getAllReportConditionsForFields($id);
$conditionsCp = ReportConditions::getAllReportConditionsForCustomProperties($id);
$ot = ObjectTypes::findById($report->getReportObjectTypeId());
$table = $ot->getTableName();
if ($ot->getType() == 'dimension_object' || $ot->getType() == 'dimension_group') {
$hook_parameters = array('report' => $report, 'params' => $params, 'order_by_col' => $order_by_col, 'order_by_asc' => $order_by_asc, 'offset' => $offset, 'limit' => $limit, 'to_print' => $to_print);
$report_result = null;
Hook::fire('replace_execute_report_function', $hook_parameters, $report_result);
if ($report_result) {
return $report_result;
}
}
eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();");
eval('$item_class = ' . $ot->getHandlerClass() . '::instance()->getItemClass(); $object = new $item_class();');
$order_by = '';
if (is_object($params)) {
$params = get_object_vars($params);
}
$report_columns = ReportColumns::getAllReportColumns($id);
$allConditions = "";
$contact_extra_columns = self::get_extra_contact_columns();
if (count($conditionsFields) > 0) {
foreach ($conditionsFields as $condField) {
if ($condField->getFieldName() == "archived_on") {
$show_archived = true;
}
$skip_condition = false;
$model = $ot->getHandlerClass();
$model_instance = new $model();
$col_type = $model_instance->getColumnType($condField->getFieldName());
$allConditions .= ' AND ';
$dateFormat = 'm/d/Y';
if (isset($params[$condField->getId()])) {
$value = $params[$condField->getId()];
if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) {
$dateFormat = user_config_option('date_format');
}
} else {
$value = $condField->getValue();
}
if ($ot->getHandlerClass() == 'Contacts' && in_array($condField->getFieldName(), $contact_extra_columns)) {
$allConditions .= self::get_extra_contact_column_condition($condField->getFieldName(), $condField->getCondition(), $value);
} else {
if ($value == '' && $condField->getIsParametrizable()) {
$skip_condition = true;
}
if (!$skip_condition) {
$field_name = $condField->getFieldName();
if (in_array($condField->getFieldName(), Objects::getColumns())) {
$field_name = 'o`.`' . $condField->getFieldName();
}
if ($condField->getCondition() == 'like' || $condField->getCondition() == 'not like') {
$value = '%' . $value . '%';
}
if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) {
if ($value == date_format_tip($dateFormat)) {
$value = EMPTY_DATE;
} else {
$dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value);
$value = $dtValue->format('Y-m-d');
}
}
if ($condField->getCondition() != '%') {
if ($col_type == DATA_TYPE_INTEGER || $col_type == DATA_TYPE_FLOAT) {
$allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value);
} else {
if ($condField->getCondition() == '=' || $condField->getCondition() == '<=' || $condField->getCondition() == '>=') {
if ($col_type == DATA_TYPE_DATETIME || $col_type == DATA_TYPE_DATE) {
$equal = 'datediff(' . DB::escape($value) . ', `' . $field_name . '`)=0';
} else {
$equal = '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value);
}
switch ($condField->getCondition()) {
case '=':
$allConditions .= $equal;
break;
case '<=':
case '>=':
$allConditions .= '(`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value) . ' OR ' . $equal . ') ';
break;
}
} else {
$allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value);
//.........这里部分代码省略.........
示例6: total_task_times_by_task_print
function total_task_times_by_task_print()
{
$this->setLayout("html");
$task = ProjectTasks::findById(get_id());
$st = DateTimeValueLib::make(0, 0, 0, 1, 1, 1900);
$et = DateTimeValueLib::make(23, 59, 59, 12, 31, 2036);
$timeslotsArray = Timeslots::getTaskTimeslots(null, null, null, $st, $et, get_id());
tpl_assign('estimate', $task->getTimeEstimate());
//tpl_assign('timeslots', $timeslots);
tpl_assign('timeslotsArray', $timeslotsArray);
tpl_assign('workspace', $task->getProject());
tpl_assign('template_name', 'total_task_times');
tpl_assign('title', lang('task time report'));
tpl_assign('task_title', $task->getTitle());
$this->setTemplate('report_printer');
}
示例7: findByContext
/**
* Same that getContentObjects but reading from sahring table
* @deprecated by parent::listing()
**/
static function findByContext( $options = array () ) {
// Initialize method result
$result = new stdClass();
$result->total = 0 ;
$result->objects = array() ;
// Read arguments and Init Vars
$limit = array_var($options,'limit');
$members = active_context_members(false); // 70
$type_id = self::instance()->getObjectTypeId();
if (!count($members)) return $res ;
$uid = logged_user()->getId() ;
if ($limit>0){
$limit_sql = "LIMIT $limit";
}else{
$limit_sql = '' ;
}
// Build Main SQL
$sql = "
SELECT distinct(id) FROM ".TABLE_PREFIX."objects
WHERE
id IN (
SELECT object_id FROM ".TABLE_PREFIX."sharing_table
WHERE group_id IN (
SELECT permission_group_id FROM ".TABLE_PREFIX."contact_permission_groups WHERE contact_id = $uid
)
) AND
id IN (
SELECT object_id FROM ".TABLE_PREFIX."object_members
WHERE member_id IN (".implode(',', $members).")
GROUP BY object_id
HAVING count(member_id) = ".count($members)."
) AND
object_type_id = $type_id AND ".SQL_NOT_DELETED."
$limit_sql";
// Execute query and build the resultset
$rows = DB::executeAll($sql);
foreach ($rows as $row) {
$task = ProjectTasks::findById($row['id']);
if ( ( $task && $task instanceof ProjectTask ) && !$task->isTemplate() ) {
if($task->getDueDate()){
$k = "#".$task->getDueDate()->getTimestamp().$task->getId();
$result->objects[$k] = $task ;
}else{
$result->objects[] = $task ;
}
$result->total++;
}
}
// Sort by key
ksort($result->objects);
// Remove keys
$result->objects = array_values($result->objects);
return $result;
}
示例8: change_start_due_date
function change_start_due_date()
{
$task = ProjectTasks::findById(get_id());
if (!$task->canEdit(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$tochange = array_var($_GET, 'tochange', '');
if (($tochange == 'both' || $tochange == 'due') && $task->getDueDate() instanceof DateTimeValue) {
$year = array_var($_GET, 'year', $task->getDueDate()->getYear());
$month = array_var($_GET, 'month', $task->getDueDate()->getMonth());
$day = array_var($_GET, 'day', $task->getDueDate()->getDay());
$new_date = new DateTimeValue(mktime(0, 0, 0, $month, $day, $year));
$task->setDueDate($new_date);
}
if (($tochange == 'both' || $tochange == 'start') && $task->getStartDate() instanceof DateTimeValue) {
$year = array_var($_GET, 'year', $task->getStartDate()->getYear());
$month = array_var($_GET, 'month', $task->getStartDate()->getMonth());
$day = array_var($_GET, 'day', $task->getStartDate()->getDay());
$new_date = new DateTimeValue(mktime(0, 0, 0, $month, $day, $year));
$task->setStartDate($new_date);
}
try {
DB::beginWork();
$task->save();
DB::commit();
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error change date'));
}
// try
ajx_current("empty");
}
示例9: add_timeslot
function add_timeslot()
{
$object_id = array_var($_REQUEST, "object_id", false);
ajx_current("empty");
$timeslot_data = array_var($_POST, 'timeslot');
if ($object_id) {
$object = Objects::findObject($object_id);
if (!$object instanceof ContentDataObject || !$object->canAddTimeslot(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$member_ids = $object->getMemberIds();
} else {
$member_ids = json_decode(array_var($_POST, 'members', array()));
// clean member_ids
$tmp_mids = array();
foreach ($member_ids as $mid) {
if (!is_null($mid) && trim($mid) != "") {
$tmp_mids[] = $mid;
}
}
$member_ids = $tmp_mids;
if (empty($member_ids)) {
if (!can_add(logged_user(), active_context(), Timeslots::instance()->getObjectTypeId())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
} else {
if (count($member_ids) > 0) {
$enteredMembers = Members::findAll(array('conditions' => 'id IN (' . implode(",", $member_ids) . ')'));
} else {
$enteredMembers = array();
}
if (!can_add(logged_user(), $enteredMembers, Timeslots::instance()->getObjectTypeId())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
}
$object_id = 0;
}
try {
$hoursToAdd = array_var($timeslot_data, 'hours', 0);
$minutes = array_var($timeslot_data, 'minutes', 0);
if (strpos($hoursToAdd, ',') && !strpos($hoursToAdd, '.')) {
$hoursToAdd = str_replace(',', '.', $hoursToAdd);
}
if (strpos($hoursToAdd, ':') && !strpos($hoursToAdd, '.')) {
$pos = strpos($hoursToAdd, ':') + 1;
$len = strlen($hoursToAdd) - $pos;
$minutesToAdd = substr($hoursToAdd, $pos, $len);
if (!strlen($minutesToAdd) <= 2 || !strlen($minutesToAdd) > 0) {
$minutesToAdd = substr($minutesToAdd, 0, 2);
}
$mins = $minutesToAdd / 60;
$hours = substr($hoursToAdd, 0, $pos - 1);
$hoursToAdd = $hours + $mins;
}
if ($minutes) {
$min = str_replace('.', '', $minutes / 6);
$hoursToAdd = $hoursToAdd + ("0." . $min);
}
if ($hoursToAdd <= 0) {
flash_error(lang('time has to be greater than 0'));
return;
}
$startTime = getDateValue(array_var($timeslot_data, 'date'));
$startTime = $startTime->add('h', 8 - logged_user()->getTimezone());
$endTime = getDateValue(array_var($timeslot_data, 'date'));
$endTime = $endTime->add('h', 8 - logged_user()->getTimezone() + $hoursToAdd);
//use current time
if (array_var($_REQUEST, "use_current_time", false)) {
$currentStartTime = DateTimeValueLib::now();
$currentEndTime = DateTimeValueLib::now();
$currentStartTime = $currentStartTime->add('h', -$hoursToAdd);
$startTime->setHour($currentStartTime->getHour());
$startTime->setMinute($currentStartTime->getMinute());
$endTime->setHour($currentEndTime->getHour());
$endTime->setMinute($currentEndTime->getMinute());
}
$timeslot_data['start_time'] = $startTime;
$timeslot_data['end_time'] = $endTime;
$timeslot_data['description'] = html_to_text($timeslot_data['description']);
$timeslot_data['name'] = $timeslot_data['description'];
$timeslot_data['rel_object_id'] = $object_id;
//array_var($timeslot_data,'project_id');
$timeslot = new Timeslot();
//Only admins can change timeslot user
if (!array_var($timeslot_data, 'contact_id', false) || !SystemPermissions::userHasSystemPermission(logged_user(), 'can_manage_time')) {
$timeslot_data['contact_id'] = logged_user()->getId();
}
$timeslot->setFromAttributes($timeslot_data);
$user = Contacts::findById($timeslot_data['contact_id']);
$billing_category_id = $user->getDefaultBillingId();
$bc = BillingCategories::findById($billing_category_id);
if ($bc instanceof BillingCategory) {
$timeslot->setBillingId($billing_category_id);
$hourly_billing = $bc->getDefaultValue();
//.........这里部分代码省略.........
示例10: edit
/**
* Edit timeslot
*
* @param void
* @return null
*/
function edit() {
$this->setTemplate('add_timeslot');
$timeslot = Timeslots::findById(get_id());
if(!($timeslot instanceof Timeslot)) {
flash_error(lang('timeslot dnx'));
ajx_current("empty");
return;
}
$object = $timeslot->getRelObject();
if(!($object instanceof ContentDataObject)) {
flash_error(lang('object dnx'));
ajx_current("empty");
return;
}
if(!($object->canAddTimeslot(logged_user()))) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
if(!($timeslot->canEdit(logged_user()))) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$timeslot_data = array_var($_POST, 'timeslot');
if(!is_array($timeslot_data)) {
$timeslot_data = array(
'contact_id' => $timeslot->getContactId(),
'description' => $timeslot->getDescription(),
'start_time' => $timeslot->getStartTime(),
'end_time' => $timeslot->getEndTime(),
'is_fixed_billing' => $timeslot->getIsFixedBilling(),
'hourly_billing' => $timeslot->getHourlyBilling(),
'fixed_billing' => $timeslot->getFixedBilling()
);
}
tpl_assign('timeslot_form_object', $object);
tpl_assign('timeslot', $timeslot);
tpl_assign('timeslot_data', $timeslot_data);
tpl_assign('show_billing', BillingCategories::count() > 0);
if(is_array(array_var($_POST, 'timeslot'))) {
try {
$timeslot->setContactId(array_var($timeslot_data, 'contact_id', logged_user()->getId()));
$timeslot->setDescription(array_var($timeslot_data, 'description'));
$st = getDateValue(array_var($timeslot_data, 'start_value'),DateTimeValueLib::now());
$st->setHour(array_var($timeslot_data, 'start_hour'));
$st->setMinute(array_var($timeslot_data, 'start_minute'));
$et = getDateValue(array_var($timeslot_data, 'end_value'),DateTimeValueLib::now());
$et->setHour(array_var($timeslot_data, 'end_hour'));
$et->setMinute(array_var($timeslot_data, 'end_minute'));
$st = new DateTimeValue($st->getTimestamp() - logged_user()->getTimezone() * 3600);
$et = new DateTimeValue($et->getTimestamp() - logged_user()->getTimezone() * 3600);
$timeslot->setStartTime($st);
$timeslot->setEndTime($et);
if ($timeslot->getStartTime() > $timeslot->getEndTime()){
flash_error(lang('error start time after end time'));
ajx_current("empty");
return;
}
$seconds = array_var($timeslot_data,'subtract_seconds',0);
$minutes = array_var($timeslot_data,'subtract_minutes',0);
$hours = array_var($timeslot_data,'subtract_hours',0);
$subtract = $seconds + 60 * $minutes + 3600 * $hours;
if ($subtract < 0){
flash_error(lang('pause time cannot be negative'));
ajx_current("empty");
return;
}
$testEndTime = new DateTimeValue($timeslot->getEndTime()->getTimestamp());
$testEndTime->add('s',-$subtract);
if ($timeslot->getStartTime() > $testEndTime){
flash_error(lang('pause time cannot exceed timeslot time'));
ajx_current("empty");
return;
}
//.........这里部分代码省略.........
示例11: lang
echo $task->getId();
?>
', '<?php
echo $template_id;
?>
')"><?php
echo lang('set parent task');
?>
</a>
<?php
} else {
if (array_var($_GET, 'template_task', false)) {
$parentTask = TemplateTasks::findById($task_data['parent_id']);
} else {
$parentTask = ProjectTasks::findById($task_data['parent_id']);
}
if ($parentTask instanceof ProjectTask || $parentTask instanceof TemplateTask) {
?>
<span style="display: none;" id="no-task-selected<?php
echo $genid;
?>
"><?php
echo lang('none');
?>
</span>
<a style="display: none;margin-left: 10px" id="<?php
echo $genid;
?>
parent_before" href="#" onclick="og.pickParentTemplateTask(this, '<?php
echo $genid;
示例12: close
function close($description = null)
{
if ($this->isPaused()) {
$this->setEndTime($this->getPausedOn());
} else {
$dt = DateTimeValueLib::now();
$this->setEndTime($dt);
}
$timeslot_time = ($this->getEndTime()->getTimestamp() - ($this->getStartTime()->getTimestamp() + $this->getSubtract())) / 3600;
$task = ProjectTasks::findById($this->getRelObjectId());
if ($task->getTimeEstimate() > 0) {
$timeslot_percent = $timeslot_time * 100 / ($task->getTimeEstimate() / 60);
$total_percentComplete = $timeslot_percent + $task->getPercentCompleted();
if ($total_percentComplete < 0) {
$total_percentComplete = 0;
}
$task->setPercentCompleted($total_percentComplete);
$task->save();
}
//FIXME: Set billing info
/* if ($this->getRelObject() instanceof ContentDataObject && $this->getRelObject()->getProject() instanceof Project){
$hours = $this->getMinutes() / 60;
$user = $this->getUser();
$billing_category_id = $user->getDefaultBillingId();
$project = $this->getRelObject()->getProject();
$this->setBillingId($billing_category_id);
$hourly_billing = $project->getBillingAmount($billing_category_id);
$this->setHourlyBilling($hourly_billing);
$this->setFixedBilling(round($hourly_billing * $hours, 2));
$this->setIsFixedBilling(false);
}
*/
if ($description) {
$this->setDescription($description);
}
}
示例13: save
/**
* Save this list
*
* @param void
* @return boolean
*/
function save() {
if (!$this->isNew()) {
$old_me = ProjectTasks::findById($this->getId(), true);
if (!$old_me instanceof ProjectTask) return; // TODO: check this!!!
// This was added cause deleting some tasks was giving an error, couldn't reproduce it again, but this solved it
}
if ($this->isNew() ||
$this->getAssignedToContactId() != $old_me->getAssignedToContactId()) {
$this->setAssignedBy(logged_user());
$this->setAssignedOn(DateTimeValueLib::now());
}
$due_date_changed = false;
if (!$this->isNew()) {
$old_due_date = $old_me->getDueDate();
$due_date = $this->getDueDate();
if ($due_date instanceof DateTimeValue) {
if (!$old_due_date instanceof DateTimeValue || $old_due_date->getTimestamp() != $due_date->getTimestamp()) {
$due_date_changed = true;
}
} else {
if ($old_due_date instanceof DateTimeValue) {
$due_date_changed = true;
}
}
}
parent::save();
if ($due_date_changed) {
$id = $this->getId();
$sql = "UPDATE `".TABLE_PREFIX."object_reminders` SET
`date` = date_sub((SELECT `due_date` FROM `".TABLE_PREFIX."project_tasks` WHERE `id` = $id),
interval `minutes_before` minute) WHERE `object_id` = $id;";
DB::execute($sql);
}
$tasks = $this->getSubTasks();
if(is_array($tasks)) {
$task_ids = array();
foreach($tasks as $task) {
$task_ids[] = $task->getId();
} // if
} // if
return true;
} // save
示例14: select_task_list
/**
* Render select task list box
*
* @param string $name Form control name
* @param Project $project
* @param integer $selected ID of selected object
* @param boolean $open_only List only active task lists (skip completed)
* @param array $attach_data Additional attributes
* @return string
*/
function select_task_list($name, $project = null, $selected = null, $open_only = false, $attributes = null)
{
if (is_null($project)) {
$project = active_or_personal_project();
}
//if (!($project instanceof Project)) throw new InvalidInstanceError('$project', $project, 'Project');
if (is_array($attributes)) {
if (!isset($attributes['class'])) {
$attributes['class'] = 'select_task_list';
}
} else {
$attributes = array('class' => 'select_task_list');
}
// if
$options = array(option_tag(lang('none'), 0));
if ($project instanceof Project) {
$task_lists = $open_only ? $project->getOpenTasks() : $project->getTasks();
} else {
$task_lists = $open_only ? ProjectTasks::getProjectTasks(null, null, 'ASC', null, null, null, null, null, null, true) : ProjectTasks::getProjectTasks(null, null, 'ASC', 0, null, null, null, null, null, false);
}
$selected_exists = is_null($selected);
if (is_array($task_lists)) {
foreach ($task_lists as $task_list) {
if ($task_list->getId() == $selected) {
$selected_exists = true;
$option_attributes = array('selected' => 'selected');
} else {
$option_attributes = null;
}
$options[] = option_tag($task_list->getTitle(), $task_list->getId(), $option_attributes);
}
// foreach
}
// if
if (!$selected_exists) {
$task = ProjectTasks::findById($selected);
if ($task instanceof ProjectTask) {
$options[] = option_tag($task->getTitle(), $task->getId(), array("selected" => "selected"));
}
}
return select_box($name, $options, $attributes);
}
示例15: lang
/*if($task_list->canReorderTasks(logged_user()) && is_array($task_list->getOpenSubTasks())) {
add_page_action(lang('reorder sub tasks'), $task_list->getReorderTasksUrl($on_list_page), 'ico-properties');
} // if*/
$this->assign('on_list_page', true);
?>
<div style="padding: 7px">
<div class="tasks"><?php
/*
* This section builds the task title
*/
$title = $task_list->getObjectName() != '' ? $task_list->getObjectName() : $task_list->getText();
$description = '';
$parentInf = '';
//
$task = ProjectTasks::findById(get_id());
//start
if ($task_list->getParent() instanceof ProjectTask && $task->canEdit(logged_user())) {
$parent = $task_list->getParent();
$parentInf = '<div class="member-path-dim-block"><b>' . lang('subtask of', $parent->getViewUrl(), $parent->getObjectName() != '' ? clean($parent->getObjectName()) : clean($parent->getText())) . " " . '</b></div>';
}
//end
$status = '<div class="taskStatus">';
if (!$task_list->isCompleted()) {
if ($task_list->canEdit(logged_user()) && !$task_list->isTrashed()) {
$status .= '<b>' . lang('status') . ': </b><a class=\'internalLink \' style="background-position:0 -501px !important;" href=\'' . $task_list->getCompleteUrl(rawurlencode(get_url('task', 'view', array('id' => $task_list->getId())))) . '\' title=\'' . escape_single_quotes(lang('complete task')) . '\'>' . lang('pending') . '</a>';
} else {
$status .= '<div style="display:inline;"><b>' . lang('status') . ': </b>' . lang('pending') . '</div>';
}
} else {
$status .= lang('status') . ': ';