public function submit($pj_id = NULL, $type)
 {
     parent::submit($pj_id, $type);
     $this->load->model('common/tb_owner');
     $this->load->database();
     // /*========================================*/
     // /*======= TRANSACTION START ==============*/
     // /*========================================*/
     $this->db->trans_start();
     $a_id_ref = $this->input->post('a_id');
     // /*============================*/
     // /*======= ADD SUBMITED =======*/
     // /*============================*/
     $msg_err = "Add";
     if ($type == "added") {
         $this->tb_owner->record(array('a_id_ref' => $a_id_ref, 'pj_id_ref' => $pj_id));
     } else {
         if ($type == "edited") {
         }
     }
     /*==================================*/
     /*======= TRANSACTION COMMIT =======*/
     /*==================================*/
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         $this->message_error_type = "fail";
         $this->message_error = $msg_err . " user failure";
         $this->assign($pj_id);
     } else {
         $this->message_error_type = "success";
         $this->message_error = $msg_err . " user succesfully";
         $this->assign($pj_id);
     }
 }
 public function submit($pm_id = NULL, $type)
 {
     parent::submit($pm_id, $type);
     $this->load->model('common/tb_permission');
     $this->load->database();
     // /*========================================*/
     // /*======= TRANSACTION START ==============*/
     // /*========================================*/
     $this->db->trans_start();
     $pm_name = $this->input->post('pm_name');
     $question_mgnt = $this->input->post('question_mgnt');
     $survey_mgnt = $this->input->post('survey_mgnt');
     $survey_result_mgnt = $this->input->post('survey_result_mgnt');
     $admin_mgnt = $this->input->post('admin_mgnt');
     $project_mgnt = $this->input->post('project_mgnt');
     // /*============================*/
     // /*======= ADD SUBMITED =======*/
     // /*============================*/
     $msg_err = "Add";
     if ($type == "added") {
         if ($pm_name == "" || $pm_name == NULL) {
             $this->message_error_type = "fail";
             $this->message_error = "Your permission name not empty.";
             $this->add();
             return;
         }
         $pm_id = $this->tb_permission->record(array('pm_name' => $pm_name, 'question_mgnt' => $question_mgnt, 'survey_mgnt' => $survey_mgnt, 'survey_result_mgnt' => $survey_result_mgnt, 'admin_mgnt' => $admin_mgnt, 'project_mgnt' => $project_mgnt));
     } else {
         if ($type == "edited") {
             $msg_err = "Update";
             if ($pm_name == "" || $pm_name == NULL) {
                 $this->message_error_type = "fail";
                 $this->message_error = "Your permission name not empty.";
                 $this->edit($pm_id);
                 return;
             }
             $this->tb_permission->update(array('pm_name' => $pm_name, 'question_mgnt' => $question_mgnt, 'survey_mgnt' => $survey_mgnt, 'survey_result_mgnt' => $survey_result_mgnt, 'admin_mgnt' => $admin_mgnt, 'project_mgnt' => $project_mgnt), $pm_id);
         }
     }
     /*==================================*/
     /*======= TRANSACTION COMMIT =======*/
     /*==================================*/
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         $this->message_error_type = "fail";
         $this->message_error = $msg_err . " permission failure";
         $this->edit($pm_id);
     } else {
         $this->message_error_type = "success";
         $this->message_error = $msg_err . " permission succesfully";
         $this->edit($pm_id);
     }
 }
 public function submit($a_id = NULL, $type)
 {
     parent::submit($a_id, $type);
     $this->load->model('common/tb_permission');
     $this->load->model('common/tb_admin');
     $this->load->database();
     // /*========================================*/
     // /*======= TRANSACTION START ==============*/
     // /*========================================*/
     $this->db->trans_start();
     $a_user = $this->input->post('a_user');
     $a_pass = $this->input->post('a_pass');
     $a_name = $this->input->post('a_name');
     $a_permission = $this->input->post('a_permission');
     // /*============================*/
     // /*======= ADD SUBMITED =======*/
     // /*============================*/
     $msg_err = "Add";
     if ($type == "added") {
         if ($a_user == "" || $a_user == NULL || $a_pass == "" || $a_pass == NULL || $a_name == "" || $a_name == NULL) {
             $this->message_error_type = "fail";
             $this->message_error = "Your Username/Password/Name not empty.";
             $this->add();
             return;
         }
         $a_id = $this->tb_admin->record(array('a_user' => $a_user, 'a_pass' => md5($a_pass), 'a_name' => $a_name, 'a_permission' => $a_permission));
     } else {
         if ($type == "edited") {
             $msg_err = "Update";
             if ($a_user == "" || $a_user == NULL || $a_name == "" || $a_name == NULL) {
                 $this->message_error_type = "fail";
                 $this->message_error = "Your Username/Password/Name not empty.";
                 $this->edit($a_id);
                 return;
             }
             $this->tb_admin->update(array('a_user' => $a_user, 'a_name' => $a_name, 'a_permission' => $a_permission), $a_id);
         }
     }
     /*==================================*/
     /*======= TRANSACTION COMMIT =======*/
     /*==================================*/
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         $this->message_error_type = "fail";
         $this->message_error = $msg_err . " admin failure";
         $this->edit($a_id);
     } else {
         $this->message_error_type = "success";
         $this->message_error = $msg_err . " admin succesfully";
         $this->edit($a_id);
     }
 }
 public function submit($as_id = NULL, $type)
 {
     parent::submit($as_id, $type);
     $this->load->model('tb_answer_style');
     $this->load->database();
     /*========================================*/
     /*======= TRANSACTION START ==============*/
     /*========================================*/
     $this->db->trans_start();
     $as_name = $this->input->post('as_name');
     $as_description = $this->input->post('as_description');
     $as_text_color = $this->input->post('as_text_color');
     $as_identifier = $this->input->post('as_identifier');
     /*============================*/
     /*======= ADD SUBMITED =======*/
     /*============================*/
     $msg_err = "Add";
     if ($type == "added") {
         $as_id = $this->tb_answer_style->record(array('as_name' => $as_name, 'as_description' => $as_description, 'as_text_color' => $as_text_color, 'as_identifier' => $as_identifier));
     } else {
         if ($type == "edited") {
             $msg_err = "Update";
             $this->tb_answer_style->update(array('as_name' => $as_name, 'as_description' => $as_description, 'as_text_color' => $as_text_color, 'as_identifier' => $as_identifier), $as_id);
         }
     }
     /*==================================*/
     /*======= TRANSACTION COMMIT =======*/
     /*==================================*/
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         $this->message_error_type = "fail";
         $this->message_error = $msg_err . " answer style failure";
         $this->edit($as_id);
     } else {
         $this->message_error_type = "success";
         $this->message_error = $msg_err . " answer style succesfully";
         $this->edit($as_id);
     }
 }
 public function submit($sm_id, $type)
 {
     parent::submit($sm_id, $type);
     $this->load->database();
     $this->load->model('tb_survey_mapping');
     /*========================================*/
     /*=============== DATA ===================*/
     /*========================================*/
     $sm_name = $this->input->post('sm_name');
     $sm_description = $this->input->post('sm_description');
     $ff = $this->input->post('question_group');
     $question_group = @array_filter(@array_unique($this->input->post('question_group')));
     /*========================================*/
     /*======= TRANSACTION START ==============*/
     /*========================================*/
     $survey_empty = $sm_name == NULL || $sm_name == "" ? TRUE : FALSE;
     $question_group_empty = count($question_group) <= 0 || $question_group == NULL ? TRUE : FALSE;
     if ($survey_empty == TRUE || $question_group_empty == TRUE) {
         $this->message_error_type = "fail";
         $this->message_error = "Survey name not empty / select question at least 1.";
         if ($type == 'added') {
             $this->add();
         } else {
             $this->edit($sm_id);
         }
         return;
     }
     $sm_image = "default.png";
     $this->load->library('upload', $this->upload_survey_config(time("his")));
     if ($this->upload->do_upload('sm_image')) {
         $data = array('upload_data' => $this->upload->data());
         $sm_image = $data['upload_data']['file_name'];
     }
     $this->db->trans_start();
     $msg_err = "Add";
     if ($type == 'added') {
         $sm_id = $this->tb_survey_mapping->record(array('sm_name' => $sm_name, 'sm_description' => $sm_description, 'sm_order_column' => implode(",", $question_group), 'sm_update_at' => date("Y-m-d H:i:s"), 'sm_image' => $sm_image));
         $this->tb_survey_mapping->update(array('sm_table_code' => "SV" . $sm_id), $sm_id);
         $this->tb_survey_mapping->create_table_survey($this->prefix_table_name . $sm_id, $question_group);
     } else {
         if ($type == 'edited') {
             $upload_data = $this->upload->data();
             $isUpload = $upload_data['file_size'] > 0 ? TRUE : FALSE;
             $msg_err = "Update";
             if (!$isUpload) {
                 $this->tb_survey_mapping->update(array('sm_name' => $sm_name, 'sm_description' => $sm_description, 'sm_order_column' => implode(",", $question_group), 'sm_update_at' => date("Y-m-d H:i:s")), $sm_id);
             } else {
                 $this->tb_survey_mapping->update(array('sm_name' => $sm_name, 'sm_description' => $sm_description, 'sm_order_column' => implode(",", $question_group), 'sm_update_at' => date("Y-m-d H:i:s"), 'sm_image' => $sm_image), $sm_id);
             }
             $this->tb_survey_mapping->update_table_survey($this->prefix_table_name . $sm_id, $question_group);
         }
     }
     /*==================================*/
     /*======= TRANSACTION COMMIT =======*/
     /*==================================*/
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         $this->message_error_type = "fail";
         $this->message_error = $msg_err . " survey failure.";
         $this->edit($sm_id);
     } else {
         $this->message_error_type = "success";
         $this->message_error = $msg_err . " survey succesfully.";
         $this->edit($sm_id);
     }
 }
 public function submit($pj_id = NULL, $type)
 {
     parent::submit($pj_id, $type);
     $this->load->model('common/tb_project');
     $this->load->database();
     // /*========================================*/
     // /*======= TRANSACTION START ==============*/
     // /*========================================*/
     $this->db->trans_start();
     $pj_name = $this->input->post('pj_name');
     $pj_description = $this->input->post('pj_description');
     $pj_db_ref = $this->input->post('pj_db_ref');
     $pj_image = "default.png";
     $this->load->library('upload', $this->upload_config($pj_db_ref . time("his")));
     if ($this->upload->do_upload('pj_image')) {
         $data = array('upload_data' => $this->upload->data());
         $pj_image = $data['upload_data']['file_name'];
     }
     // /*============================*/
     // /*======= ADD SUBMITED =======*/
     // /*============================*/
     $msg_err = "Add";
     if ($type == "added") {
         if ($pj_name == "" || $pj_name == NULL || $pj_db_ref == "" || $pj_db_ref == NULL) {
             $this->message_error_type = "fail";
             $this->message_error = "Your project name / Database name is not empty.";
             $this->add();
             return;
         }
         $this->load->model('common/database');
         $result = $this->database->create($pj_db_ref);
         if ($result == FALSE) {
             $this->message_error_type = "fail";
             $this->message_error = "Create Database Error. ensure your database name is not exist.";
             $this->add();
             return;
         } else {
             $pj_id = $this->tb_project->record(array('pj_name' => $pj_name, 'pj_description' => $pj_description, 'pj_db_ref' => $pj_db_ref, 'pj_image' => $pj_image));
         }
     } else {
         if ($type == "edited") {
             $msg_err = "Update";
             if ($pj_name == "" || $pj_name == NULL) {
                 $this->message_error_type = "fail";
                 $this->message_error = "Your project name is not empty.";
                 $this->edit($pj_id);
                 return;
             }
             $upload_data = $this->upload->data();
             $isUpload = $upload_data['file_size'] > 0 ? TRUE : FALSE;
             if (!$isUpload) {
                 $this->tb_project->update(array('pj_name' => $pj_name, 'pj_description' => $pj_description), $pj_id);
             } else {
                 $this->tb_project->update(array('pj_name' => $pj_name, 'pj_description' => $pj_description, 'pj_image' => $pj_image), $pj_id);
             }
         }
     }
     /*==================================*/
     /*======= TRANSACTION COMMIT =======*/
     /*==================================*/
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         $this->message_error_type = "fail";
         $this->message_error = $msg_err . " project failure";
         $this->edit($pj_id);
     } else {
         $this->message_error_type = "success";
         $this->message_error = $msg_err . " project succesfully";
         $this->edit($pj_id);
     }
 }
 public function submit($aq_id = NULL, $type)
 {
     parent::submit($aq_id, $type);
     $this->load->model('tb_all_question');
     $this->load->model('tb_all_answer');
     $this->load->database();
     /*========================================*/
     /*======= TRANSACTION START ==============*/
     /*========================================*/
     $this->db->trans_start();
     $MAX_ANSWER = 20;
     $aq_description = $this->input->post('aq_description');
     $aa_descriptions = $this->input->post('aa_description');
     //array_filter($this->input->post('aa_description'));
     $aa_actives = $this->input->post('aa_active');
     $colors = "#000000";
     $types = $this->input->post('type');
     $aq_auto_display_result = $this->input->post('aq_auto_display');
     if ($aq_auto_display_result == NULL) {
         $aq_auto_display_result = 0;
     } else {
         $aq_auto_display_result = 1;
     }
     /*============================*/
     /*======= ADD SUBMITED =======*/
     /*============================*/
     $msg_err = "Add";
     if ($type == "added") {
         if ($aq_description == "" || $aq_description == NULL) {
             $this->message_error_type = "fail";
             $this->message_error = "Your question message not empty.";
             $this->add();
             return;
         }
         if (count($aa_descriptions) > $MAX_ANSWER || count($aa_descriptions) == 0) {
             $this->message_error_type = "fail";
             $this->message_error = "The answer mustn't over " . $MAX_ANSWER . " choice or not empty.";
             $this->add();
             return;
         }
         $aq_id = $this->tb_all_question->record(array('aq_description' => $aq_description, 'active' => 'Y', 'aq_auto_display' => $aq_auto_display_result));
         $i = 0;
         foreach ($aa_descriptions as $aa_description) {
             $this->tb_all_answer->record(array('aa_description' => $aa_description, 'active' => $aa_actives[$i] == 'Active' ? 'Y' : 'N', 'type' => $types[$i], 'aq_id_ref' => $aq_id));
             $i++;
         }
     } else {
         if ($type == "edited") {
             $msg_err = "Update";
             if ($aq_description == "" || $aq_description == NULL) {
                 $this->message_error_type = "fail";
                 $this->message_error = "Your question message not empty.";
                 $this->edit($aq_id);
                 return;
             }
             if (count($aa_descriptions) > $MAX_ANSWER || count($aa_descriptions) == 0) {
                 $this->message_error_type = "fail";
                 $this->message_error = "The answer mustn't over " . $MAX_ANSWER . " choice or not empty.";
                 $this->edit($aq_id);
                 return;
             }
             $this->tb_all_question->update(array('aq_description' => $aq_description, 'active' => 'Y', 'aq_auto_display' => $aq_auto_display_result), $aq_id);
             //UPDATE EXIST ANSWERS
             $aa_ids = $this->input->post('aa_id');
             $count_answers = $this->input->post('count_answers');
             for ($i = 0; $i < $count_answers; $i++) {
                 $this->tb_all_answer->update(array('aa_description' => $aa_descriptions[$i], 'active' => $aa_actives[$i] == 'Active' ? 'Y' : 'N', 'type' => $types[$i]), $aa_ids[$i]);
             }
             //INSERT NEW ANSWERS
             for ($i = $count_answers; $i < count($aa_descriptions); $i++) {
                 $this->tb_all_answer->record(array('aa_description' => $aa_descriptions[$i], 'active' => $aa_actives[$i] == 'Active' ? 'Y' : 'N', 'type' => $types[$i], 'aq_id_ref' => $aq_id));
             }
         }
     }
     /*==================================*/
     /*======= TRANSACTION COMMIT =======*/
     /*==================================*/
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         $this->message_error_type = "fail";
         $this->message_error = $msg_err . " question failure";
         $this->edit($aq_id);
     } else {
         $this->message_error_type = "success";
         $this->message_error = $msg_err . " question succesfully";
         $this->edit($aq_id);
     }
 }