Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace app\controllers;
- use Yii;
- use yii\web\Controller;
- use yii\filters\VerbFilter;
- use yii\web\NotFoundHttpException;
- use app\models\Soapmodel;
- use app\models\Setting;
- use yii\helpers\Json;
- use app\models\TmpMhs;
- use app\models\Prodi;
- use app\models\TmpKelas;
- /**
- * Data Controller
- * @copyright : Yusuf Ayuba
- * @licensi : Comersial
- * @year : 2016
- * @since : 1.0.0
- */
- class DataController extends Controller
- {
- protected $wsdl;
- protected $token;
- protected $session;
- protected $xx;
- const ERROR_SYNC = 0;
- //const STATUS_ACTIVE = 1;
- public function behaviors()
- {
- return [
- 'verbs' => [
- 'class' => VerbFilter::className(),
- 'actions' => [
- //'sync-mhs' => ['post'],
- ],
- ],
- ];
- }
- public function init()
- {
- $this->session = Yii::$app->session;
- $this->wsdl = new Soapmodel();
- $setting = Setting::find()->one();
- //$this->token = $this->wsdl->token($setting->ws_user,$setting->ws_password);
- $this->token = Yii::$app->session['siap']['ws_token'];
- }
- /*
- Fungsi Data untuk menampilkan data mahasiswa secara ajax ke Datatable
- */
- public function actionMhs()
- {
- $temp_cols = ['id_pd','nipd','nm_pd','tgl_lahir',
- 'nm_lemb','nm_agama','mulai_smt','nm_stat_mhs'];
- $i=0;
- foreach ($temp_cols as $item) {
- $column[$i] = $item;
- $i++;
- }
- $search = Yii::$app->request->post('search');
- $sSearch = trim($search['value']);
- $iStart = Yii::$app->request->post('start');
- $iLength = Yii::$app->request->post('length');
- $iOrder = Yii::$app->request->post('order');
- $limit = $iLength?$iLength : Yii::$app->params['limit'];
- $offset = $iStart?$iStart : Yii::$app->params['offset'];
- $order = $iOrder?$column[$iOrder[0]['column']].' '.$iOrder[0]['dir']:'mulai_smt DESC';
- $temp_total = $this->wsdl->count_all(
- $this->token,
- Yii::$app->params['mahasiswa_pt'],
- Yii::$app->params['filter']
- );
- $totalData = $temp_total['result'];
- $totalFiltered = $totalData;
- $temp_rec = $this->wsdl->list_mhs(
- $this->token,
- Yii::$app->params['filter'],
- $order,
- $limit,
- $offset
- );
- //var_dump($temp_rec);
- if (!empty($sSearch)) {
- $filter = "((LOWER(nm_pd) LIKE '%".strtolower($sSearch)."%') OR
- (LOWER(jk) LIKE '%".strtolower($sSearch)."%') OR
- (LOWER(nm_lemb) LIKE '%".strtolower($sSearch)."%') OR
- (LOWER(nm_agama) LIKE '%".strtolower($sSearch)."%') OR
- (nipd LIKE '%".$sSearch."%') OR
- (mulai_smt LIKE '%".$sSearch."%') OR
- (LOWER(ket_keluar) LIKE '%".strtolower($sSearch)."%')
- )";
- $temp_rec = $this->wsdl->list_mhs(
- $this->token,
- $filter,
- $order,
- $limit,
- $offset
- );
- //$__total = $this->wsdl->count_all(
- // $this->token,
- // Yii::$app->params['mahasiswa_pt'],
- // $filter
- // );
- $__total = count($temp_rec['result']);
- //$totalFiltered = $__total['result'];
- $totalFiltered = $__total;
- }
- $temp_error_code = $temp_rec['error_code'];
- $temp_error_desc = $temp_rec['error_desc'];
- if (($temp_error_code==0) && ($temp_error_desc=='')) {
- $temp_data = [];
- $i=0;
- foreach ($temp_rec['result'] as $key) {
- $temp_data[] = [
- //++$i+$this->offset,
- ++$iStart+Yii::$app->params['offset'],
- $key['nipd'],
- $key['nm_pd'],
- $key['jk'],
- date('d-m-Y',strtotime($key['tgl_lahir'])),
- $key['nm_lemb'],
- $key['nm_agama'],
- substr($key['mulai_smt'], 0,4),
- $key['nm_stat_mhs']
- ];
- }
- $temp_output = [
- 'draw' => intval(Yii::$app->request->get('draw')),
- 'recordsTotal' => intval( $totalData ),
- 'recordsFiltered' => intval( $totalFiltered ),
- 'data' => $temp_data
- ];
- echo Json::encode($temp_output);
- }
- }
- /*
- Fungsi Data untuk menampilkan data Kelas Perkuliahan secara ajax ke Datatable
- */
- public function actionKls()
- {
- $temp_cols = ['id_kls','nm_lemb','id_smt',
- 'kode_mk','nm_mk','nm_kls',
- 'sks_mk','jmlmhs','dosen'];
- $i=0;
- foreach ($temp_cols as $item) {
- $column[$i] = $item;
- $i++;
- }
- $search = Yii::$app->request->post('search');
- $sSearch = trim($search['value']);
- $iStart = Yii::$app->request->post('start');
- $iLength = Yii::$app->request->post('length');
- $iOrder = Yii::$app->request->post('order');
- $limit = $iLength?$iLength:Yii::$app->params['limit'];
- $offset = $iStart?$iStart:Yii::$app->params['offset'];
- $order = $iOrder?$column[$iOrder[0]['column']].' '.$iOrder[0]['dir']:'nm_smt DESC';
- $temp_total = $this->wsdl->count_all(
- $this->token,
- Yii::$app->params['kelas'],
- Yii::$app->params['filter']
- );
- $totalData = $temp_total['result'];
- $totalFiltered = $totalData;
- $temp_rec = $this->wsdl->list_kelas(
- $this->token,
- Yii::$app->params['filter'],
- $order,
- $limit,
- $offset
- );
- if (!empty($sSearch)) {
- /*
- Filter di field sks_mk = ambigu
- */
- $filter = "((LOWER(nm_kls) LIKE '%".strtolower($sSearch)."%') OR
- (LOWER(kode_mk) LIKE '%".strtolower($sSearch)."%') OR
- (LOWER(nm_mk) LIKE '%".strtolower($sSearch)."%') OR
- (nm_smt LIKE '%".$sSearch."%') OR
- (LOWER(nm_sdm) LIKE '%".strtolower($sSearch)."%')
- )";
- $temp_rec = $this->wsdl->list_kelas(
- $this->token,
- $filter,
- $order,
- $limit,
- $offset
- );
- //$__total = $this->wsdl->count_all(
- // $this->token,
- // Yii::$app->params['mahasiswa_pt'],
- // $filter
- // );
- $__total = count($temp_rec['result']);
- //$totalFiltered = $__total['result'];
- $totalFiltered = $__total;
- }
- $temp_error_code = $temp_rec['error_code'];
- $temp_error_desc = $temp_rec['error_desc'];
- if (($temp_error_code==0) && ($temp_error_desc=='')) {
- $temp_data = [];
- $i=0;
- foreach ($temp_rec['result'] as $key) {
- $temp_data[] = [
- //++$i+$this->offset,
- ++$iStart+Yii::$app->params['offset'],
- $key['nm_lemb'],
- $key['nm_smt'],
- $key['kode_mk'],
- $key['nm_mk'],
- $key['nm_kls'],
- $key['sks_mk'],
- $key['jmlmhs'],
- $key['dosen']
- ];
- }
- $temp_output = [
- 'draw' => intval(Yii::$app->request->get('draw')),
- 'recordsTotal' => intval( $totalData ),
- 'recordsFiltered' => intval( $totalFiltered ),
- 'data' => $temp_data
- ];
- echo Json::encode($temp_output);
- }
- }
- /*
- Fungsi Data untuk menampilkan data Aktifitas Kuliah Mahasiswa secara ajax ke Datatable
- */
- public function actionAkm()
- {
- $temp_cols = ['id_pd','nipd','nm_pd','nm_lemb','nm_smt',
- 'mulai_smt','ips','ipk','sks_smt',
- 'sks_total','nm_stat_mhs'];
- $i=0;
- foreach ($temp_cols as $item) {
- $column[$i] = $item;
- $i++;
- }
- $search = Yii::$app->request->post('search');
- $sSearch = trim($search['value']);
- $iStart = Yii::$app->request->post('start');
- $iLength = Yii::$app->request->post('length');
- $iOrder = Yii::$app->request->post('order');
- $limit = $iLength?$iLength : Yii::$app->params['limit'];
- $offset = $iStart?$iStart : Yii::$app->params['offset'];
- $order = $iOrder?$column[$iOrder[0]['column']].' '.$iOrder[0]['dir']:'id_smt DESC';
- //echo $order;
- $temp_total = $this->wsdl->count_all(
- $this->token,
- Yii::$app->params['mahasiswa_pt'],
- Yii::$app->params['filter']
- );
- $totalData = $temp_total['result'];
- $totalFiltered = $totalData;
- $temp_rec = $this->wsdl->list_kuliah(
- $this->token,
- Yii::$app->params['filter'],
- $order,
- $limit,
- $offset
- );
- //var_dump($temp_rec['result']);
- if (!empty($sSearch)) {
- $filter = "((LOWER(nm_pd) LIKE '%".strtolower($sSearch)."%') OR
- (LOWER(nm_lemb) LIKE '%".strtolower($sSearch)."%') OR
- (LOWER(nm_smt) LIKE '%".strtolower($sSearch)."%') OR
- (nipd LIKE '%".$sSearch."%') OR
- (mulai_smt LIKE '%".$sSearch."%') OR
- (LOWER(nm_stat_mhs) LIKE '%".strtolower($sSearch)."%')
- )";
- $temp_rec = $this->wsdl->list_kuliah(
- $this->token,
- $filter,
- $order,
- $limit,
- $offset
- );
- $__total = count($temp_rec['result']);
- //$totalFiltered = $__total['result'];
- $totalFiltered = $__total;
- }
- $temp_error_code = $temp_rec['error_code'];
- $temp_error_desc = $temp_rec['error_desc'];
- if (($temp_error_code==0) && ($temp_error_desc=='')) {
- $temp_data = [];
- $i=0;
- foreach ($temp_rec['result'] as $key) {
- $temp_data[] = [
- //++$i+$this->offset,
- ++$iStart+Yii::$app->params['offset'],
- $key['nipd'],
- $key['nm_pd'],
- $key['nm_lemb'],
- $key['nm_smt'],
- substr($key['mulai_smt'], 0,4),
- round($key['ips'],2),
- round($key['ipk'],2),
- $key['sks_smt'],
- $key['sks_total'],
- $key['nm_stat_mhs']
- ];
- }
- $temp_output = [
- 'draw' => intval(Yii::$app->request->get('draw')),
- 'recordsTotal' => intval( $totalData ),
- 'recordsFiltered' => intval( $totalFiltered ),
- 'data' => $temp_data
- ];
- echo Json::encode($temp_output);
- }
- }
- /*
- Fungsi Data untuk menampilkan data Mahasiswa Lulus/DO secara ajax ke Datatable
- */
- public function actionLulus()
- {
- $temp_cols = ['id_pd','nipd','nm_pd','nm_lemb',
- 'mulai_smt','ket_keluar','tgl_keluar','ket'];
- $i=0;
- foreach ($temp_cols as $item) {
- $column[$i] = $item;
- $i++;
- }
- $search = Yii::$app->request->post('search');
- $sSearch = trim($search['value']);
- $iStart = Yii::$app->request->post('start');
- $iLength = Yii::$app->request->post('length');
- $iOrder = Yii::$app->request->post('order');
- $limit = $iLength?$iLength : Yii::$app->params['limit'];
- $offset = $iStart?$iStart : Yii::$app->params['offset'];
- $order = $iOrder?$column[$iOrder[0]['column']].' '.$iOrder[0]['dir']:'id_smt DESC';
- $temp_total = $this->wsdl->count_all(
- $this->token,
- Yii::$app->params['mahasiswa_pt'],
- Yii::$app->params['filter']
- );
- $totalData = $temp_total['result'];
- $totalFiltered = $totalData;
- $temp_rec = $this->wsdl->list_lulus(
- $this->token,
- Yii::$app->params['filter'],
- $order,
- $limit,
- $offset
- );
- //var_dump($temp_rec['result']);
- if (!empty($sSearch)) {
- $filter = "((LOWER(nm_pd) LIKE '%".strtolower($sSearch)."%') OR
- (LOWER(s.nm_lemb) LIKE '%".strtolower($sSearch)."%') OR
- (nipd LIKE '%".$sSearch."%') OR
- (mulai_smt LIKE '%".$sSearch."%') OR
- (LOWER(ket_keluar) LIKE '%".strtolower($sSearch)."%')
- )";
- $temp_rec = $this->wsdl->list_lulus(
- $this->token,
- $filter,
- $order,
- $limit,
- $offset
- );
- $__total = count($temp_rec['result']);
- //$totalFiltered = $__total['result'];
- $totalFiltered = $__total;
- }
- $temp_error_code = $temp_rec['error_code'];
- $temp_error_desc = $temp_rec['error_desc'];
- if (($temp_error_code==0) && ($temp_error_desc=='')) {
- $temp_data = [];
- $i=0;
- foreach ($temp_rec['result'] as $key) {
- $temp_data[] = [
- ++$iStart+Yii::$app->params['offset'],
- $key['nipd'],
- $key['nm_pd'],
- $key['nm_lemb'],
- substr($key['mulai_smt'], 0,4),
- $key['ket_keluar'],
- date('d-m-Y',strtotime($key['tgl_keluar'])),
- $key['ket']
- ];
- }
- $temp_output = [
- 'draw' => intval(Yii::$app->request->get('draw')),
- 'recordsTotal' => intval( $totalData ),
- 'recordsFiltered' => intval( $totalFiltered ),
- 'data' => $temp_data
- ];
- echo Json::encode($temp_output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement