/**
  * delete picture
  */
 public function delete_picture()
 {
     $this->layout = 'none';
     if ($this->input->post() && $this->input->is_ajax_request()) {
         $json = array();
         $post = $this->input->post();
         if (isset($post['id']) && $post['id'] > 0 && ctype_digit($post['id'])) {
             $detail = $this->Quiz_model->GetQuiz($post['id']);
             if ($detail && ($detail['image'] != '' && file_exists(UPLOAD_DIR . 'admin/' . $detail['image']))) {
                 $id = $post['id'];
                 unlink(UPLOAD_DIR . 'admin/' . $detail['image']);
                 @unlink(UPLOAD_DIR . 'admin/tmb_' . $detail['image']);
                 @unlink(UPLOAD_DIR . 'admin/sml_' . $detail['image']);
                 $data_update = array('image' => '');
                 $this->Quiz_model->UpdateRecord($post['id'], $data_update);
                 $json['success'] = alert_box('File hase been deleted.', 'success');
                 // insert to log
                 $data_log = array('id_user' => id_auth_user(), 'id_group' => id_auth_group(), 'action' => 'User Quiz', 'desc' => 'Delete Picture User Quiz; ID: ' . $id . ';');
                 insert_to_log($data_log);
                 // end insert to log
             } else {
                 $json['error'] = alert_box('Failed to remove File. Please try again.', 'danger');
             }
         }
         header('Content-type: application/json');
         exit(json_encode($json));
     }
     redirect($this->class_path_name);
 }
 /**
  * validate change password form
  * @return boolean
  */
 private function validatePassword()
 {
     $this->load->model('Admin_model');
     $id = id_auth_user();
     $post = $this->input->post();
     $err = '';
     $detail = $this->Admin_model->getAdmin($id);
     if ($post['old_password'] == '') {
         $err .= 'Please insert Old Password.<br/>';
     } else {
         if (!password_verify($post['old_password'], $detail['userpass']) && $detail['userpass'] != '') {
             $err .= 'Your Old Password is incorrect.<br/>';
         }
     }
     if ($post['new_password'] == '') {
         $err .= 'Please input your New Password.<br/>';
     } else {
         if (strlen($post['new_password']) <= 6) {
             $err .= 'Please input New Password more than 6 characters.<br/>';
         } else {
             if ($post['conf_password'] != $post['new_password']) {
                 $err .= 'Your Confirmation Password is not same with Your New Password.<br/>';
             }
         }
     }
     if ($err) {
         $this->error = alert_box($err, 'danger');
         return false;
     } else {
         return true;
     }
 }
 /**
  * delete page
  */
 public function delete()
 {
     $this->layout = 'none';
     if ($this->input->post() && $this->input->is_ajax_request()) {
         $post = $this->input->post();
         $json = array();
         if ($post['ids'] != '') {
             $array_id = array_map('trim', explode(',', $post['ids']));
             if (count($array_id) > 0) {
                 foreach ($array_id as $row => $id) {
                     $record = $this->Menu_model->GetMenu($id);
                     if ($record) {
                         if ($record['is_superadmin'] && !is_superadmin()) {
                             $json['error'] = alert_box('You don\'t have permission to delete this record(s). Please contact the Menuistrator.', 'danger');
                             break;
                         } else {
                             /*if (!$this->Menu_model->checkUserHaveRightsMenu(id_auth_group(),$id)) {
                                   $json['error'] = alert_box('You don\'t have permission to delete this record(s). Please contact the Menuistrator.','danger');
                                   break;
                               } else {*/
                             $this->Menu_model->DeleteRecord($id);
                             // insert to log
                             $data_log = array('id_user' => id_auth_user(), 'id_group' => id_auth_group(), 'action' => 'Delete Admin Menu', 'desc' => 'Delete Admin Menu; ID: ' . $id . ';');
                             insert_to_log($data_log);
                             // end insert to log
                             $json['success'] = alert_box('Data has been deleted', 'success');
                             $this->session->set_flashdata('flash_message', $json['success']);
                             //}
                         }
                     } else {
                         $json['error'] = alert_box('Failed. Please refresh the page.', 'danger');
                         break;
                     }
                 }
             }
         }
         header('Content-type: application/json');
         exit(json_encode($json));
     }
     redirect($this->class_path_name);
 }