load->model('project_notifications_model'); $this->load->model('project_notifications_email_templates_model'); $this->load->model('contract_types_model'); $this->load->model('projects_model'); $this->load->helper('url'); } public function index() { close_setup_menu(); if (!has_permission('project_notifications', '', 'view')) { access_denied('project_notifications'); } if ($this->input->is_ajax_request()) { $this->app->get_table_data(module_views_path('project_notifications', 'tables/list')); } $data['title'] = _l('pn_title'); $this->load->view('project_notifications', $data); } public function configure($id="") { if (!has_permission('project_notifications', '', 'view')) { access_denied('project_notifications'); } $data['contractTypes'] = $this->contract_types_model->get(); $data['projectData'] = $this->project_notifications_model->getProjectDataForConfigurations(); $data['pan'] = $this->project_notifications_model->get($id); $data['id'] = $id; $data['title'] = _l('pn_configure_title'); $data['templates'] = $this->project_notifications_email_templates_model->get(); $this->load->view('configure', $data); } public function configuration($id="") { if (trim($id)!=='') { if (!has_permission('project_notifications', '', 'edit')) { access_denied('project_notifications'); } } else { if (!has_permission('project_notifications', '', 'add')) { access_denied('project_notifications'); } } if ($this->input->post()) { $post = $this->input->post(); $data['triggertime'] = $post['triggertime']; $data['triggerday'] = $post['triggerday']; $data['emails'] = $post['emails']; $data['choice_type'] = $post['choice_type']; $data['contract_type'] = $post['contract_type']; $data['projects'] = $post['projects']; $data['dataset'] = (isset($post['prev_week']) && $post['prev_week']=='Y')?'PREV-WEEK':'SO-FAR'; $data['info_to_send'] = ''; $data['email_template'] = $post['email_template']; if (trim($id)!=='') { $data['id'] = $id; } $success = $this->project_notifications_model->upsert($data); } redirect('project_notifications'); } public function delete($id) { $success = $this->project_notifications_model->delete($id); redirect('project_notifications'); } public function execute($id) { execute_project_notification($id); redirect('project_notifications'); } public function email_templates() { close_setup_menu(); if (!has_permission('project_notifications', '', 'view')) { access_denied('project_notifications'); } $data['title'] = _l('pn_email_template_title'); $data['tickets'] = $this->project_notifications_email_templates_model->get(); $this->load->view('email_templates', $data); } public function email_template($id="") { close_setup_menu(); if (!has_permission('project_notifications', '', 'view')) { access_denied('project_notifications'); } $data['template'] = $this->project_notifications_email_templates_model->get($id); $data['title'] = $data['template']->name; $data['id'] = $id; $data['available_merge_fields'] = $this->project_notifications_email_templates_model->available_merge_fields(); $this->load->view('template', $data); } public function upsertemailtemplate($id="") { if (trim($id)!=='') { if (!has_permission('project_notifications', '', 'edit')) { access_denied('project_notifications'); } } else { if (!has_permission('project_notifications', '', 'add')) { access_denied('project_notifications'); } } if ($this->input->post()) { $post = $this->input->post(); $data['type'] = $post['type']; $data['slug'] = $post['slug']; $data['language'] = $post['language']; $data['name'] = $post['name']; $data['subject'] = $post['subject']; $data['message'] = $post['message']; $data['fromname'] = $post['fromname']; $data['fromemail'] = $post['fromemail']; $data['plaintext'] = $post['plaintext']; $data['active'] = $post['active']; $data['order'] = $post['order']; if (trim($id)!=='') { $data['id'] = $id; } $success = $this->project_notifications_email_templates_model->upsert($data); } redirect('project_notifications/email_templates'); } // proivate utilities // This should not be in the controller and we should be using CI Active Record. // moved to model }