Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1.  
  2.     function approvefile($id){
  3.         $allowed = array(0);
  4.         auth_redirect($allowed);
  5.         $current_user               = get_current_login();
  6.         $login_type                 = get_login_type();
  7.  
  8.         $datetime       = date('Y-m-d H:i:s');
  9.         $con['id'] = $id;
  10.         $file = $this->model_member->get_data('files',$con);
  11.  
  12.         if ( $login_type != 0 ){
  13.             // Set JSON data
  14.             $data = array(
  15.                 'message'   => 'error',
  16.                 'data'      => '<button class="close" data-close="alert"></button>Hanya admin yang dapat melakukan aksi ini.',
  17.             );
  18.             die(json_encode($data));
  19.         }
  20.         if ( !$file ){
  21.             // Set JSON data
  22.             $data = array(
  23.                 'message'   => 'error',
  24.                 'data'      => '<button class="close" data-close="alert"></button>Data file tidak ditemukan.',
  25.             );
  26.             die(json_encode($data));
  27.         }
  28.  
  29.         if ( $file->status == 2 ){
  30.             // Set JSON data
  31.             $data = array(
  32.                 'message'   => 'error',
  33.                 'data'      => '<button class="close" data-close="alert"></button>File ini sudah disetujui.',
  34.             );
  35.             die(json_encode($data));
  36.         }
  37.  
  38.         $data_update = array (
  39.             'status'        => 2,
  40.             'datemodified'  => $datetime
  41.         );
  42.  
  43.         if ($this->model_member->update_data('files',$con,$data_update)) {
  44.             update_register_document_upload_status($file->id_registration);
  45.             // Set JSON data
  46.             $data = array(
  47.                 'message'   => 'success',
  48.                 'data'      => '<button class="close" data-close="alert"></button>Status file berhasil diubah menjadi "diterima".',
  49.                 'status'    => '<center><span class="label label-sm label-success">Diterima</span></center>',
  50.             );
  51.             die(json_encode($data));
  52.         } else {
  53.             // Set JSON data
  54.             $data = array(
  55.                 'message'   => 'error',
  56.                 'data'      => '<button class="close" data-close="alert"></button>Ubah status file gagal.',
  57.             );
  58.             die(json_encode($data));
  59.         }
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement