} ?> <?php echo _l('%s of %s hours have been logged:', $completed_value, $hours_value); ?> <input type="hidden" name="job_task[<?php echo $task_id; ?> ][completed]" value="<?php echo $task_data['completed']; ?> "> <br/> <?php // show a log of any existing hours against this task. $task_logs = module_job::get_task_log($task_id); foreach ($task_logs as $task_log) { if (function_exists('decimal_time_out')) { $hours_value = decimal_time_out($task_log['hours']); } else { $hours_value = number_out($task_log['hours'], true); } echo _l('%s hrs <span class="text_shrink">%s</a> - <span class="text_shrink">%s</span>', $hours_value, print_date($task_log['log_time'], true), $staff_member_rel[$task_log['create_user_id']]); ?> <a href="#" class="error_text" onclick="return delete_task_hours(<?php echo $task_id; ?> ,<?php echo $task_log['task_log_id']; ?> );">x</a> <?php
public static function generate_task_preview($job_id, $job, $task_id, $task_data, $task_editable = true, $options = array()) { ob_start(); // can we edit this task? // if its been invoiced we cannot edit it. if ($task_editable && $task_data['invoiced'] && module_config::c('job_task_lock_invoiced_items', 1) && $task_data['fully_completed']) { $task_editable = false; // don't allow editable invoiced tasks } // todo-move this into a method so we can update it via ajax. $percentage = self::get_percentage($task_data); /*if($task_data['hours'] <= 0 && $task_data['fully_completed']){ $percentage = 1; }else if ($task_data['completed'] > 0) { if($task_data['hours'] > 0){ $percentage = round($task_data['completed'] / $task_data['hours'],2); $percentage = min(1,$percentage); }else{ $percentage = 1; } }else{ $percentage = 0; }*/ $task_due_time = strtotime($task_data['date_due']); $show_task_numbers = module_config::c('job_show_task_numbers', 1) && $job['auto_task_numbers'] != 2; $staff_members = module_user::get_staff_members(); $staff_member_rel = array(); foreach ($staff_members as $staff_member) { $staff_member_rel[$staff_member['user_id']] = $staff_member['name']; } // hack to set the done_date if none exists. if ($percentage >= 1) { if ($task_data['task_id'] && isset($task_data['date_done']) && (!$task_data['date_done'] || $task_data['date_done'] == '0000-00-00')) { $task_logs = module_job::get_task_log($task_id); $done_date = $task_data['date_updated']; foreach ($task_logs as $task_log) { if ($task_log['log_time']) { $done_date = date('Y-m-d', $task_log['log_time']); } } if ($done_date) { update_insert('task_id', $task_data['task_id'], 'task', array('date_done' => $done_date)); $task_data['date_done'] = $done_date; } } } else { if ($task_data['task_id'] && isset($task_data['date_done']) && $task_data['date_done'] && $task_data['date_done'] != '0000-00-00') { $done_date = '0000-00-00'; update_insert('task_id', $task_data['task_id'], 'task', array('date_done' => $done_date)); $task_data['date_done'] = $done_date; } } // new different formats for job data. if ((!isset($task_data['manual_task_type']) || $task_data['manual_task_type'] < 0) && isset($job['default_task_type'])) { // use the job task type $task_data['manual_task_type'] = $job['default_task_type']; // if this task has been invoiced then we lock the manual_task_type to wahtever the job default currently is // this helps with the upgrade. if ($task_data['invoiced'] && $task_data['invoice_id']) { update_insert('task_id', $task_data['task_id'], 'task', array('manual_task_type' => $job['default_task_type'])); } } include 'pages/ajax_task_preview.php'; return ob_get_clean(); }