예제 #1
0
 public function update_image_students()
 {
     $this->use->use_model('data_base');
     $this->use->use_lib('table/tpl_students');
     $this->use->use_lib('system/image/class_upload_image');
     $tpl = new tpl_students();
     $image = new class_upload_image('image_students_update', 'include/img/student');
     if ($image->get_type() == 'image/png' || $image->get_type() == 'image/jpeg') {
         if ($image->get_error()) {
             $image_path = $image->move_file();
             if ($image_path == false) {
                 echo json_encode(array('valid' => false));
             } else {
                 $db = new data_base($tpl->table(), array($tpl->image() => $image_path), array($tpl->id() => $_POST['id_image_update']));
                 if ($db->change()) {
                     echo json_encode(array('valid' => true, 'image' => $image_path));
                 } else {
                     echo json_encode(array('valid' => false));
                 }
             }
         } else {
             echo json_encode(array('valid' => false));
         }
     } else {
         echo json_encode(array('valid' => false));
     }
 }
예제 #2
0
 public function update_specialty()
 {
     $this->use->use_model('data_base');
     $this->use->use_lib('table/tpl_specialty');
     $tpl = new tpl_specialty();
     $db = new data_base($tpl->table(), array($tpl->id_college() => $_POST['name_college_update'], $tpl->name() => $_POST['name_update']), array($tpl->id() => $_POST['id']));
     echo json_encode(array('valid' => $db->change(), 'massage' => '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>Update success </strong></div>'));
 }
예제 #3
0
 public function update_user()
 {
     $this->use->use_model('data_base');
     $this->use->use_lib('table/tpl_users');
     $tpl = new tpl_users();
     $data = array($tpl->username() => $_POST['username_update']);
     if (!empty($_POST['password_update'])) {
         $data[$tpl->password()] = md5($_POST['password_update']);
     }
     $db = new data_base($tpl->table(), $data, array($tpl->id() => $_POST['id']));
     echo json_encode(array('valid' => $db->change(), 'massage' => '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>Update success </strong></div>'));
 }
 public function update_status()
 {
     $id = $_POST[tpl_specialty::specialty() . '_' . tpl_specialty::id()];
     $status = $_POST[tpl_specialty::specialty() . '_' . tpl_specialty::active()];
     $db = new data_base(tpl_specialty::specialty(), array(tpl_specialty::active() => $status), array(tpl_specialty::id() => $id));
     $results = $db->change();
     $status_data = $status == 1 ? 'active' : 'dative';
     if ($results) {
         echo json_encode(array('valid' => 1, 'title' => 'Successfully !!', 'massage' => 'I\'ve been Update ' . $status_data));
     } else {
         echo json_encode(array('valid' => 0, 'title' => 'Oops !!', 'massage' => 'Was not Update ' . $status_data . ', please try again'));
     }
 }