table = $context['table']; $this->foreign_id = $context['id']; $this->submitter = $context['submitter']; $this->show_pagination = $context['show_pagination']; $this->show_search = $context['show_search']; $this->objects = array( "jobs" => array("plural" => "Job","image" => "hard_hat_small.png"), "quotes" => array("plural" => "Quote","image" => "med_small.png"), "timesheets" => array("plural" => "Timesheet","image" => "clock_small.png"), "tasks" => array("plural" => "Task","image" => "database_small.png"), "departments" => array("plural" => "Department","image" => "expense_small.png"), "my_account" => array("plural" => "My Account","image" => "database_small.png"), "clients" => array("plural" => "Client","image" => "database_small.png"), "users" => array("plural" => "User","image" => "staff_small.png"), "schedules" => array("plural" => "Schedule","image" => "calendar_small.png"), "system" => array("plural" => "System","image" => "setup_small.png"), "items" => array("plural" => "Smart Asset","image" => "present_small.png"), "contacts" => array("plural" => "Contact","image" => "present_small.png"), "clients_locations" => array("plural" => "Client Location","image" => "present_small.png"), "suppliers" => array("plural" => "Supplier","image" => "present_small.png"), "timesheets" => array("plural" => "Timesheet","image" => "clock_small.png"), "job_trackings" => array("plural" => "Job Tracking","image" => "waiting_small.png"), "leaves" => array("plural" => "Leave","image" => "present_small.png") ); $this->actions = array( "1" => array("plural" => "Created New","image" => "star_small.png"), "2" => array("plural" => "Edited","image" => "edit_small.png"), "3" => array("plural" => "Changed status for","image" => "status_change_small.png"), "4" => array("plural" => "Note","image" => "note_small.png"), "5" => array("plural" => "Converted","image" => "cms_small.png"), "6" => array("plural" => "Emailed","image" => "email_invoice_small.png"), "7" => array("plural" => "Changed Priority for","image" => "priority_small.png"), "8" => array("plural" => "Added to ","image" => "add_small.png"), "9" => array("plural" => "Uploaded file to ","image" => "upload_small.png"), "10" => array("plural" => "Updated ","image" => "update_small.png"), "11" => array("plural" => "Updated ","image" => "complete_task_small.png"), "12" => array("plural" => "Updated ","image" => "stamp_small.png"), "13" => array("plural" => "Updated ","image" => "question_small.png"), "14" => array("plural" => "Updated ","image" => "star_small.png"), "15" => array("plural" => "Approved ","image" => "tick_small.png"), "16" => array("plural" => "Declined ","image" => "error_small.png"), "17" => array("plural" => "Locked Job ","image" => "lock_small.png"), "18" => array("plural" => "Unlocked Job ","image" => "lock_small.png"), "19" => array("plural" => "Completed Task ","image" => "clock_orange_small.png"), "20" => array("plural" => "Opened Task ","image" => "reactivate_small.png"), ); $this->order = (empty($context['order'])) ? "DESC" : $context['order']; $this->method = (empty($context['method'])) ? "date_submitted" : $context['method']; return $this; } public function set_data() { $table = $this->table; $foreign_id = $this->foreign_id; $start_date = $this->start_date; $end_date = $this->end_date; $submitter_sql = (empty($this->submitter)) ? "" : "AND submitter = '".$this->submitter."'"; if(empty($start_date) && empty($end_date)) $date_sql = ""; else if(!empty($start_date) && empty($end_date)) $date_sql = "AND date_submitted >= '$start_date 00:00:00'"; else if(empty($start_date) && !empty($end_date)) $date_sql = "AND date_submitted <= '$end_date 23:59:59'"; else if(!empty($start_date) && !empty($end_date)) $date_sql = "AND date_submitted >= '$start_date 00:00:00' AND date_submitted <= '$end_date 23:59:59'"; $table_sql = (empty($table)) ? "" : "AND table_name = '$table' AND foreign_id = '$foreign_id'"; $this->sql_where = "WHERE 1=1 $submitter_sql $date_sql $table_sql"; return $this; } public function get_data() { global $database; self::set_data(); $sql_where = $this->sql_where; $get_jobs = " SELECT * FROM logs_notes $sql_where "; $results = $database->getAll($get_jobs); $return_results = array(); $objects = $this->objects; $actions = $this->actions; $users = common_users::get_users(); if(is_array($results)) { foreach($results AS $result) { $id = $result['id']; $action_type = $result['action_type']; $table_name = $result['table_name']; $foreign_id = $result['foreign_id']; $description = $result['description']; $submitter_id = $result['submitter']; $submitter = $users[$result['submitter']]; $date_submitted = $result['date_submitted']; if($action_type == 1) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; else if($action_type == 2) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; else if($action_type == 3) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; else if($action_type == 4) $description = "added a ".$actions[$action_type]['plural']." to ".$objects[$table_name]['plural']." #".$result['foreign_id']; else if($action_type == 5) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; else if($action_type == 6) { $email = unserialize(base64_decode($description)); $to = $email['email'][0]; $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id']." to ".$to; } else if($action_type == 7) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; else if($action_type == 8) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; else if($action_type == 9) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; else if($action_type == 10) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; else if(($action_type == 11) || ($action_type == 12) || ($action_type == 13)) { if(($action_type == 11) || ($action_type == 12)) $num_notes = logs::num_notes("project_tasks",$result['foreign_id']); else $num_notes = logs::num_notes("project_workflow",$result['foreign_id']); $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; if($num_notes > 0) $description .= $num_notes." notes"; } else if($action_type == 15) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; else if($action_type == 16) $description = $actions[$action_type]['plural']." ".$objects[$table_name]['plural']." #".$result['foreign_id'].", ".$description; $description .= " by ".''.$submitter.''." at ".dates::change_date_time($date_submitted); //$num_notes = logs::num_notes($objects[$table_name],$result['foreign_id']); $return_results[] = array( "id" => $id, "action_type" => $action_type, "table_name" => $table_name, "notes" => $num_notes, "foreign_id" => $foreign_id, "description" => $description, "submitter" => $submitter, "date_submitted" => $date_submitted ); } } $this->final_results = $return_results; return $this; } public function show() { global $database; $order = $this->order; $method = $this->method; $avail_edit = $this->avail_edit; $results = $this->final_results; $normalised_results = filter::sort_results($method,$order,$results); $normalise_get = filter::normalise_get($order); $pagination_results = filter::pagination($normalised_results,$normalise_get); $pagination_results['show_pagination'] = $this->show_pagination; $pagination_results['show_search'] = $this->show_search; filter::pagination_html($pagination_results); $pagination = $pagination_results['pagination']; $start = $pagination_results['start']; $size = $pagination_results['size']; $total_results = $pagination_results['total_results']; $max_size = $pagination_results['max_size']; $order = ($order == "ASC") ? "DESC" : "ASC"; $normalise_get = filter::normalise_get($order); $new_normalised_results = array(); foreach($normalised_results AS $key => $value) $new_normalised_results[] = $key; $actions = $this->actions; ?> 0) { for($i = $start; $i < $max_size; $i++) { $key = $new_normalised_results[$i]; $mod = $count%2; $class = ($mod == 0) ? "odd" : "even"; $count++; $id = $results[$key]['id']; $action_type = $results[$key]['action_type']; $table_name = $results[$key]['table_name']; $foreign_id = $results[$key]['foreign_id']; $description = $results[$key]['description']; $submitter = $results[$key]['submitter']; $date_submitted = $results[$key]['date_submitted']; $date_submitted = dates::change_date_time($date_submitted); ?>
  Description
   
show_pagination) || empty($this->show_pagination)) echo $pagination; } }