Example #1
0
 public function getProjectPhasesByTypeId($type_id = NULL, $phase_type = 'default')
 {
     if (empty($type_id)) {
         return '';
     }
     $project_type = ProjectType::find($type_id);
     if (!$project_type) {
         return '';
     } else {
         switch ($phase_type) {
             case 'media':
                 return $project_type->media_phases;
                 break;
             case 'default':
             default:
                 return $project_type->phases;
                 break;
         }
     }
 }
Example #2
0
 function view($id = FALSE)
 {
     $this->view_data['submenu'] = array();
     $this->view_data['project_type'] = ProjectType::find($id);
     $this->content_view = 'projects/types/view';
 }
Example #3
0
 function create()
 {
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['files']);
         $_POST['reference_photo'] = '';
         $config['upload_path'] = './files/media/projects/references/';
         $config['encrypt_name'] = TRUE;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         if ($this->upload->do_upload()) {
             $data = array('upload_data' => $this->upload->data());
             $_POST['reference_photo'] = $data['upload_data']['file_name'];
         }
         unset($_POST['userfile']);
         unset($_POST['dummy']);
         $_POST['datetime'] = time();
         $_POST['company_id'] = $this->client->company->id;
         $_POST = array_map('htmlspecialchars', $_POST);
         $_POST['phases'] = $this->projectlib->getProjectPhasesByTypeId($_POST['project_type_id']);
         $_POST['media_phases'] = $this->projectlib->getProjectPhasesByTypeId($_POST['project_type_id'], 'media');
         $project = Project::create($_POST);
         $new_project_reference = $_POST['reference'] + 1;
         $project_reference = Setting::first();
         $project_reference->update_attributes(array('project_reference' => $new_project_reference));
         if (!$project) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_project_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_project_success'));
             //$attributes = array('project_id' => $project->id, 'user_id' => $this->user->id);
             //ProjectHasWorker::create($attributes);
         }
         redirect('cprojects');
     } else {
         $this->view_data['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['project_types'] = ProjectType::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['shipping_methods'] = ShippingMethod::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['next_reference'] = Project::last();
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_project');
         $this->view_data['form_action'] = 'cprojects/create';
         $this->content_view = 'projects/_cproject';
     }
 }
Example #4
0
 function update($id = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         $id = $_POST['id'];
         unset($_POST['files']);
         $project = Project::find($id);
         $_POST['reference_photo'] = $project->reference_photo;
         if (!empty($_FILES['userfile']['name'])) {
             $config['upload_path'] = self::UPLOAD_PATH;
             $config['encrypt_name'] = TRUE;
             $config['allowed_types'] = '*';
             $this->load->library('upload', $config);
             if ($this->upload->do_upload()) {
                 $data = array('upload_data' => $this->upload->data());
                 $_POST['reference_photo'] = $data['upload_data']['file_name'];
                 if (!empty($project->reference_photo)) {
                     @unlink(self::UPLOAD_PATH . $project->reference_photo);
                 }
             }
         }
         $_POST = array_map('htmlspecialchars', $_POST);
         if (!isset($_POST["progress_calc"])) {
             $_POST["progress_calc"] = 0;
         }
         $_POST['phases'] = $this->projectlib->getProjectPhasesByTypeId($_POST['project_type_id']);
         $_POST['media_phases'] = $this->projectlib->getProjectPhasesByTypeId($_POST['project_type_id'], 'media');
         $project->update_attributes($_POST);
         if (!$project) {
             $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['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['project_types'] = ProjectType::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['project'] = Project::find($id);
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_edit_project');
         $this->view_data['form_action'] = 'projects/update';
         $this->content_view = 'projects/_project';
     }
 }