getRow($sql); return $result; } public function get_client_name($id,$table) { global $database; $sql = " SELECT clients.company_name FROM $table,clients WHERE $table".".id = '$id' AND $table".".client_id = clients.id "; list($company_name) = $database->getRow($sql); return $company_name; } public function get_foreign_details($id,$table) { global $database; $job_types[0] = "Single Site"; $job_types[1] = "Single Site"; $job_types[2] = "Multi Site"; $job_types[3] = "LED Media"; $job_types[4] = "Cost Plus"; $job_types[5] = "Quick Jobs"; if($table == "quotes") { $sql = " SELECT job_name,job_type,priority,id FROM $table WHERE $table".".id = '$id' "; list($job_name,$job_type,$priority,$quote_id) = $database->getRow($sql); if($job_type == 2) $job_id = $database->getOne("SELECT id FROM jobs WHERE quote_id = '$quote_id' AND parent_job ='1'"); else $job_id = $database->getOne("SELECT id FROM jobs WHERE quote_id = '$quote_id'"); $job_type = $job_types[$job_type]; } else if($table == "jobs") { $sql = " SELECT jobs.job_name,quotes.job_type,jobs.priority, jobs.quote_id,jobs.id FROM jobs, quotes WHERE jobs.id = '$id' AND jobs.quote_id = quotes.id "; list($job_name,$job_type,$priority,$quote_id,$job_id) = $database->getRow($sql); $job_type = $job_types[$job_type]; } return array("job_name" => $job_name,"job_type" => $job_type,"priority" => $priority,"quote_id" => $quote_id,"job_id" => $job_id); } public function get_departments($context) { $task_departments = $context['task_departments']; $departments = $context['departments']; $departments_str = ""; if(count($task_departments)) { foreach($task_departments AS $dep_key => $task_department) $departments_str .= $departments[$task_department]['name'].","; $departments_str = substr($departments_str,0,strlen($departments_str) - 1); } return $departments_str; } public function get_owners($context) { global $database; $groups = $context['groups']; $departments = $context['departments']; $users = ""; if((count($departments) > 0) && (count($groups) > 0)) { $ids = ""; foreach($departments AS $department) $ids .= "'".$department."',"; $departments_sql = "AND departments_users.department_id IN (".substr($ids,0,strlen($ids) - 1).")"; $ids = ""; foreach($groups AS $group) $ids .= "'".$group."',"; $groups_sql = "AND users.group_id IN (".substr($ids,0,strlen($ids) - 1).")"; $get_users = " SELECT users.id, concat(ucase(SUBSTRING( users.first_name, 1, 1 )),'',ucase(SUBSTRING(users.last_name,1,1))) as name FROM ".DB_CLIENT_ACCOUNTS."users AS users,".DB_CLIENT."departments_users as departments_users WHERE departments_users.user_id = users.id $departments_sql $groups_sql "; $users_array = $database->getAll($get_users); if(count($users) > 0) { foreach($users_array AS $user) $users .= ''.$user['name'].''.", "; $users = substr($users,0,strlen($users) - 3); } } return $users; } public function setActionRead($id){ global $database; $submitter = $_SESSION['user']['id']; $current_date_time = date('Y-m-d G:i:s'); $update = " UPDATE project_workflow SET read_by = '$submitter' WHERE id = '$id' "; $database->query($update); } } ?>