protected function set_up_display() { if (isset($this->project_id)) { $project = Project::find_by_id((int) $this->project_id); $this->project_code = $project->project_code; } }
protected function set_up_display() { if (isset($this->category_id)) { $category = Category::find_by_id((int) $this->category_id); $this->category = $category->category; // $this->unit_price = $category->unit_price; $this->price = $this->unit_price * $this->quantity; $this->price_company = $this->company_unit_price * $this->quantity; if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { $formatter = new NumberFormatter('en_CH', NumberFormatter::CURRENCY); $this->price = $formatter->formatCurrency($this->price, 'CHF'); $this->price_company = $formatter->formatCurrency($this->price_company, 'CHF'); // $this->unit_price=$formatter->formatCurrency($this->unit_price, 'CHF'); // $this->company_unit_price=$formatter->formatCurrency($this->company_unit_price, 'CHF'); } } if (isset($this->project_id)) { $project = Project::find_by_id((int) $this->project_id); $this->project_code = $project->project_code; } }
function activity($id = FALSE, $condition = FALSE, $activityID = FALSE) { $this->load->helper('notification'); $project = Project::find_by_id($id); //$activity = ProjectHasAktivity::find_by_id($activityID); switch ($condition) { case 'add': if ($_POST) { unset($_POST['send']); $_POST['subject'] = htmlspecialchars($_POST['subject']); $_POST['message'] = strip_tags($_POST['message'], '<br><br/><p></p><a></a><b></b><i></i><u></u><span></span>'); $_POST['project_id'] = $id; $_POST['client_id'] = $this->client->id; $_POST['type'] = "comment"; unset($_POST['files']); $_POST['datetime'] = time(); $activity = ProjectHasActivity::create($_POST); if (!$activity) { $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_error')); } else { $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_success')); foreach ($project->project_has_workers as $workers) { send_notification($workers->user->email, "[" . $project->name . "] " . $_POST['subject'], $_POST['message'] . '<br><strong>' . $project->name . '</strong>'); } if (isset($project->company->client->email)) { send_notification($project->company->client->email, "[" . $project->name . "] " . $_POST['subject'], $_POST['message'] . '<br><strong>' . $project->name . '</strong>'); } } //redirect('projects/view/'.$id); } break; case 'update': break; case 'delete': break; } }
function assign($id = FALSE) { $this->load->helper('notification'); if ($_POST) { unset($_POST['send']); $id = $_POST['id']; $project = Project::find_by_id($id); $sql = "SELECT user_id FROM project_has_workers WHERE project_id=" . $id; $query = $this->db->query($sql); $query = $query->result_array(); foreach ($query as $k => $a) { if (is_array($a)) { $query[$k] = $a['user_id']; } } $added = array_diff($_POST["user_id"], $query); $removed = array_diff($query, $_POST["user_id"]); foreach ($added as $value) { $sql = "INSERT INTO `project_has_workers` (`project_id`, `user_id`) VALUES (" . $id . ", " . $value . ")"; $query = $this->db->query($sql); $receiver = User::find_by_id($value); send_notification($receiver->email, $this->lang->line('application_notification_project_assign_subject'), $this->lang->line('application_notification_project_assign') . '<br><strong>' . $project->name . '</strong>'); } foreach ($removed as $value) { $sql = "DELETE FROM `project_has_workers` WHERE user_id = " . $value . " AND project_id=" . $id; $query = $this->db->query($sql); //$receiver = User::find_by_id($value); } if (!$query) { $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_project_error')); } else { $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_project_success')); } redirect('projects/view/' . $id); } else { $this->view_data['users'] = User::find('all', array('conditions' => array('status=?', 'active'))); $this->view_data['project'] = Project::find($id); $this->theme_view = 'modal'; $this->view_data['title'] = $this->lang->line('application_assign_to_agents'); $this->view_data['form_action'] = 'projects/assign'; $this->content_view = 'projects/_assign'; } }