Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php namespace App\Http\Controllers;
- use Session;
- use Request;
- use DB;
- use CRUDBooster;
- use QrCode;
- class AdminWisudawanController extends \crocodicstudio\crudbooster\controllers\CBController {
- public function cbInit() {
- $dt = explode("|",CRUDBooster::getSetting('periode_wisuda'));
- # START CONFIGURATION DO NOT REMOVE THIS LINE
- $this->title_field = "nama";
- $this->limit = "20";
- $this->orderby = "nrp,asc";
- $this->global_privilege = false;
- $this->button_table_action = true;
- $this->button_bulk_action = true;
- $this->button_action_style = "button_icon";
- $this->button_add = true;
- $this->button_edit = true;
- $this->button_delete = true;
- $this->button_detail = true;
- $this->button_show = true;
- $this->button_filter = true;
- $this->button_import = true;
- $this->button_export = true;
- $this->table = "wisudawan";
- # END CONFIGURATION DO NOT REMOVE THIS LINE
- # START COLUMNS DO NOT REMOVE THIS LINE
- $this->col = [];
- $this->col[] = ["label"=>"Nrp","name"=>"nrp"];
- $this->col[] = ["label"=>"Nama","name"=>"nama"];
- $this->col[] = ["label"=>"No Kursi","name"=>"no_kursi"];
- $this->col[] = ["label"=>"Fakultas","name"=>"fakultas"];
- $this->col[] = ["label"=>"Jurusan","name"=>"jurusan"];
- $this->col[] = ["label"=>"Jumlah Undangan","name"=>"Jumundangan"];
- $this->col[] = ["label"=>"Toga ?","name"=>"is_toga"];
- $this->col[] = ["label"=>"Undangan ?","name"=>"is_undangan"];
- $this->col[] = ["label"=>"Topi ?","name"=>"is_topi"];
- $this->col[] = ["label"=>"Kartu ?","name"=>"is_kartu"];
- $this->col[] = ["label"=>"Status","name"=>"status"];
- $this->col[] = ["label"=>"Predikat","name"=>"predikat"];
- # END COLUMNS DO NOT REMOVE THIS LINE
- # START FORM DO NOT REMOVE THIS LINE
- $this->form = [];
- $this->form[] = ['label'=>'Periode','name'=>'periode_id','type'=>'hidden','validation'=>'required','width'=>'col-sm-9','value'=>'1'];
- $this->form[] = ['label'=>'Nrp','name'=>'nrp','type'=>'text','validation'=>'required|min:1|max:255','width'=>'col-sm-10'];
- $this->form[] = ['label'=>'No Kursi','name'=>'no_kursi','type'=>'text','validation'=>'required','width'=>'col-sm-9'];
- $this->form[] = ['label'=>'Nama','name'=>'nama','type'=>'text','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
- $this->form[] = ['label'=>'Jurusan','name'=>'jurusan','type'=>'text','validation'=>'required|string|min:0','width'=>'col-sm-10'];
- $this->form[] = ['label'=>'Fakultas','name'=>'fakultas','type'=>'text','validation'=>'required|string|min:0','width'=>'col-sm-10'];
- $this->form[] = ['label'=>'Status','name'=>'status','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Non-Active;1|Active','value'=>'1'];
- $this->form[] = ['label'=>'Sudah ambil Toga?','name'=>'is_toga','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
- $this->form[] = ['label'=>'Sudah ambil Undangan?','name'=>'is_undangan','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
- $this->form[] = ['label'=>'Sudah ambil Topi?','name'=>'is_topi','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
- $this->form[] = ['label'=>'Sudah ambil Kartu','name'=>'is_kartu','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah', 'value'=>'0'];
- $this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9','value'=>'0'];
- $this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9','value'=>'0'];
- $this->form[] = ['label'=>'Tanggal Lulus','name'=>'tanggal_lulus','type'=>'datetime','width'=>'col-sm-9'];
- $this->form[] = ['label'=>'Alamat','name'=>'alamat','type'=>'text','width'=>'col-sm-9'];
- $this->form[] = ['label'=>'Judulta','name'=>'judulta','type'=>'text','width'=>'col-sm-9'];
- $this->form[] = ['label'=>'Predikat','name'=>'predikat','type'=>'select2','validation'=>'required','width'=>'col-sm-9','dataenum'=>'Sangat Memuaskan;Biasa','value'=>'Biasa'];
- # END FORM DO NOT REMOVE THIS LINE
- # OLD START FORM
- //$this->form = [];
- //$this->form[] = ['label'=>'Periode','name'=>'periode_id','type'=>'hidden','validation'=>'required','width'=>'col-sm-9'];
- //$this->form[] = ['label'=>'Nrp','name'=>'nrp','type'=>'text','validation'=>'required|min:1|max:255','width'=>'col-sm-10'];
- //$this->form[] = ['label'=>'No Kursi','name'=>'no_kursi','type'=>'text','validation'=>'required','width'=>'col-sm-9'];
- //$this->form[] = ['label'=>'Nama','name'=>'nama','type'=>'text','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
- //$this->form[] = ['label'=>'Jurusan','name'=>'jurusan_id','type'=>'text','validation'=>'required|string|min:0','width'=>'col-sm-10'];
- //$this->form[] = ['label'=>'Fakultas','name'=>'fakultas_id','type'=>'text','validation'=>'required|string|min:0','width'=>'col-sm-10'];
- //$this->form[] = ['label'=>'Status','name'=>'status','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Non-Active;1|Active','value'=>'1'];
- //$this->form[] = ['label'=>'Sudah ambil Toga?','name'=>'is_toga','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
- //$this->form[] = ['label'=>'Sudah ambil Undangan?','name'=>'is_undangan','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
- //$this->form[] = ['label'=>'Sudah ambil Topi?','name'=>'is_topi','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
- //$this->form[] = ['label'=>'Sudah ambil Kartu','name'=>'is_kartu','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah', 'value'=>'0'];
- //$this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9','value'=>'0'];
- //$this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9','value'=>'0'];
- //$this->form[] = ['label'=>'Tanggal Lulus','name'=>'tanggal_lulus','type'=>'datetime','width'=>'col-sm-9'];
- //$this->form[] = ['label'=>'Alamat','name'=>'alamat','type'=>'text','width'=>'col-sm-9'];
- //$this->form[] = ['label'=>'Judulta','name'=>'judulta','type'=>'text','width'=>'col-sm-9'];
- //$this->form[] = ['label'=>'Predikat','name'=>'predikat','type'=>'select2','validation'=>'required','width'=>'col-sm-9'];
- # OLD END FORM
- /*BACKUP F_HAN
- $this->form = [];
- $this->form[] = ['label'=>'Periode','name'=>'periode_id','type'=>'hidden','validation'=>'required','width'=>'col-sm-9','value'=>$dt[0]];
- $this->form[] = ['label'=>'Nrp','name'=>'nrp','type'=>'text','validation'=>'required|min:1|max:255','width'=>'col-sm-10'];
- $this->form[] = ['label'=>'No Kursi','name'=>'no_kursi','type'=>'text','validation'=>'required','width'=>'col-sm-9'];
- $this->form[] = ['label'=>'Nama','name'=>'nama','type'=>'text','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
- $this->form[] = ['label'=>'Jurusan','name'=>'jurusan_id','type'=>'select2','validation'=>'required|integer|min:0','width'=>'col-sm-10','datatable'=>'jurusan,nama','datatable_ajax'=>'true'];
- $this->form[] = ['label'=>'Fakultas','name'=>'fakultas_id','type'=>'select2','validation'=>'required|integer|min:0','width'=>'col-sm-10','datatable'=>'fakultas,nama','datatable_ajax'=>'true'];
- $this->form[] = ['label'=>'Status','name'=>'status','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Non-Active;1|Active','value'=>'1'];
- $this->form[] = ['label'=>'Sudah ambil Toga?','name'=>'is_toga','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
- $this->form[] = ['label'=>'Sudah ambil Undangan?','name'=>'is_undangan','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
- $this->form[] = ['label'=>'Sudah ambil Topi?','name'=>'is_topi','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
- $this->form[] = ['label'=>'Sudah ambil Kartu','name'=>'is_kartu','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah', 'value'=>'0'];
- $this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9'];
- */
- /*
- | ----------------------------------------------------------------------
- | Sub Module
- | ----------------------------------------------------------------------
- | @label = Label of action
- | @path = Path of sub module
- | @foreign_key = foreign key of sub table/module
- | @button_color = Bootstrap Class (primary,success,warning,danger)
- | @button_icon = Font Awesome Class
- | @parent_columns = Sparate with comma, e.g : name,created_at
- |
- */
- $this->sub_module = array();
- /*
- | ----------------------------------------------------------------------
- | Add More Action Button / Menu
- | ----------------------------------------------------------------------
- | @label = Label of action
- | @url = Target URL, you can use field alias. e.g : [id], [name], [title], etc
- | @icon = Font awesome class icon. e.g : fa fa-bars
- | @color = Default is primary. (primary, warning, succecss, info)
- | @showIf = If condition when action show. Use field alias. e.g : [id] == 1
- |
- */
- $this->addaction = array();
- $this->addaction[] = ['label'=>'','url'=>CRUDBooster::mainpath('set-qrcode/[nrp]'),'icon'=>'fa fa-qrcode','color'=>'info', 'target'=>'blank'];
- //dd($this->addaction);
- /*
- | ----------------------------------------------------------------------
- | Add More Button Selected
- | ----------------------------------------------------------------------
- | @label = Label of action
- | @icon = Icon from fontawesome
- | @name = Name of button
- | Then about the action, you should code at actionButtonSelected method
- |
- */
- $this->button_selected = array();
- $this->button_selected[] = ['label'=>'Set Active','icon'=>'fa fa-check','name'=>'set_active'];
- $this->button_selected[] = ['label'=>'Set Deactive','icon'=>'fa fa-check','name'=>'set_deactive'];
- $this->button_selected[] = ['label'=>'Generate Qr Code','icon'=>'fa fa-qrcode','name'=>'generate_qrcode'];
- /*
- | ----------------------------------------------------------------------
- | Add alert message to this module at overheader
- | ----------------------------------------------------------------------
- | @message = Text of message
- | @type = warning,success,danger,info
- |
- */
- $this->alert = array();
- /*
- | ----------------------------------------------------------------------
- | Add more button to header button
- | ----------------------------------------------------------------------
- | @label = Name of button
- | @url = URL Target
- | @icon = Icon from Awesome.
- |
- */
- $this->index_button = array();
- //timexecution lebih dari 30 second. hati2
- // $this->index_button[] = ['label'=>'Get All QRCode','url'=>CRUDBooster::mainpath("print"),"icon"=>"fa fa-qrcode"];
- /*
- | ----------------------------------------------------------------------
- | Customize Table Row Color
- | ----------------------------------------------------------------------
- | @condition = If condition. You may use field alias. E.g : [id] == 1
- | @color = Default is none. You can use bootstrap success,info,warning,danger,primary.
- |
- */
- $this->table_row_color = array();
- // $this->table_row_color[] = ["condition"=>"[status] == '1' && [is_toga] == '1'","color"=>"danger"];
- /*
- | ----------------------------------------------------------------------
- | You may use this bellow array to add statistic at dashboard
- | ----------------------------------------------------------------------
- | @label, @count, @icon, @color
- |
- */
- $this->index_statistic = array();
- $this->index_statistic[] = ['label'=>'Total Mahasiswa yang Lulus','count'=>DB::table('wisudawan')->count(),'icon'=>'fa fa-user','color'=>'success'];
- $this->index_statistic[] = ['label'=>'Total Mahasiswa yang ikut Wisuda','count'=>DB::table('wisudawan')->where('status',1)->count(),'icon'=>'fa fa-graduation-cap','color'=>'red'];
- $this->index_statistic[] = ['label'=>'Total Wisudawan yang lengkap','count'=>DB::table('wisudawan')->where('status',1)->where('is_toga',1)->where('is_topi',1)->where('is_undangan',1)->where('is_kartu',1)->count(),'icon'=>'fa fa-flag','color'=>'yellow'];
- $this->index_statistic[] = ['label'=>'Total wisudawan yang undangan >2','count'=>DB::table('wisudawan')->where('status',1)->where('jumundangan','>',2)->count(),'icon'=>'fa fa-envelope-o','color'=>'blue'];
- /*
- | ----------------------------------------------------------------------
- | Add javascript at body
- | ----------------------------------------------------------------------
- | javascript code in the variable
- | $this->script_js = "function() { ... }";
- |
- */
- $this->script_js = NULL;
- /*
- | ----------------------------------------------------------------------
- | Include HTML Code before index table
- | ----------------------------------------------------------------------
- | html code to display it before index table
- | $this->pre_index_html = "<p>test</p>";
- |
- */
- $this->pre_index_html = "<h3> Data Wisudawan Periode: ".explode("|",CRUDBooster::getSetting('periode_wisuda'))[1] ." </h3>";
- /*
- | ----------------------------------------------------------------------
- | Include HTML Code after index table
- | ----------------------------------------------------------------------
- | html code to display it after index table
- | $this->post_index_html = "<p>test</p>";
- |
- */
- $this->post_index_html = "
- <div class=\"box\">
- <p><b>Keterangan:</b></p>
- <ol>
- <li> Status menunjukkan status wisudawan yang terdaftar apakah jadi mengikuti acara seremonial wisuda periode tersebut </li>
- <li> 'Topi ?' menunjukkan apakah wisudawan sudah mengambil topi atau tidak. <b>Nilai (1)</b> berarti sudah mengambil, <b>Nilai (0)</b> berarti belum mengambil/diambil </li>
- <li> 'Toga ?' menunjukkan apakah wisudawan sudah mengambil toga atau tidak. <b>Nilai (1)</b> berarti sudah mengambil, <b>Nilai (0)</b> berarti belum mengambil/diambil </li>
- <li> 'Undangan ?' menunjukkan apakah wisudawan sudah mengambil undangan atau tidak. <b>Nilai (1)</b> berarti sudah mengambil, <b>Nilai (0)</b> berarti belum mengambil/diambil </li>
- <li> 'Kartu ?' menunjukkan apakah wisudawan sudah mengambil kartu atau tidak. <b>Nilai (1)</b> berarti sudah mengambil, <b>Nilai (0)</b> berarti belum mengambil/diambil </li>
- </ol>
- </div>
- ";
- /*
- | ----------------------------------------------------------------------
- | Include Javascript File
- | ----------------------------------------------------------------------
- | URL of your javascript each array
- | $this->load_js[] = asset("myfile.js");
- |
- */
- $this->load_js = array();
- /*
- | ----------------------------------------------------------------------
- | Add css style at body
- | ----------------------------------------------------------------------
- | css code in the variable
- | $this->style_css = ".style{....}";
- |
- */
- $this->style_css = NULL;
- /*
- | ----------------------------------------------------------------------
- | Include css File
- | ----------------------------------------------------------------------
- | URL of your css each array
- | $this->load_css[] = asset("myfile.css");
- |
- */
- $this->load_css = array();
- }
- private function genTextQR($nrp)
- {
- return md5($nrp."wisuda18");
- }
- private function actionGenerate($datamahasiswa)
- {
- QrCode::format('png')->encoding('ASCII')->size(300)->generate($this->genTextQR($datamahasiswa->nrp),'../qrcodes/'.$datamahasiswa->nrp.'_'.$datamahasiswa->nama.'.png');
- DB::table('wisudawan')->where('nrp', $datamahasiswa->nrp)->update(['encrypt_code' => $this->genTextQR($datamahasiswa->nrp)]);
- }
- public function print()
- {
- $data = DB::table('wisudawan')->where('status',1)->get();
- foreach($data as $d)
- {
- $this->actionGenerate($d);
- }
- return redirect('/admin/wisudawan');
- }
- public function getSetQrcode($id) {
- //DB::table('products')->where('id',$id)->update(['status'=>$status]);
- //dd($status);
- //QrCode::format('png')->size(300)->generate($id);
- $datamahasiswa = DB::table('wisudawan')->where('nrp',$id)->first();
- //dd($data);
- if (count($datamahasiswa)<=0) echo 'Nothing happened!';
- else
- echo '<html>
- <head></head>
- <body>
- <a href="'.CRUDBooster::mainpath("").'">BACK</a><br/>
- <h3>QR Code untuk nrp='.$datamahasiswa->nrp.' dan nama = '.$datamahasiswa->nama.' </h3>
- <p>
- Klik QR Code ini untuk download<br/>
- <a href="data:image/png;base64, '. base64_encode(QrCode::format('png')->encoding('ASCII')->size(300)->generate($this->genTextQR($datamahasiswa->nrp))) . '" download="'.$datamahasiswa->nrp.'_'.$datamahasiswa->nama.'.png">
- <img src="data:image/png;base64, '. base64_encode(QrCode::format('png')->encoding('ASCII')->size(300)->generate($this->genTextQR($datamahasiswa->nrp))) . '" /> </a>
- </p>
- </body>
- </html>';
- //bisa dibuat: {"name":"Baba","address":"sby"}
- //This will redirect back and gives a message
- //CRUDBooster::redirect($_SERVER['HTTP_REFERER'],"The status product has been updated !","info");
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for button selected
- | ----------------------------------------------------------------------
- | @id_selected = the id selected
- | @button_name = the name of button
- |
- */
- public function actionButtonSelected($id_selected,$button_name) {
- //Your code here
- if($button_name == 'set_active') {
- DB::table('wisudawan')->whereIn('id',$id_selected)->update(['status'=>1]);
- }
- if($button_name == 'set_deactive') {
- DB::table('wisudawan')->whereIn('id',$id_selected)->update(['status'=>0]);
- }
- if($button_name =='generate_qrcode')
- {
- foreach($id_selected as $idd)
- {
- $this->actionGenerate($d);
- }
- //dd($id_selected);
- }
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for manipulate query of index result
- | ----------------------------------------------------------------------
- | @query = current sql query
- |
- */
- public function hook_query_index(&$query) {
- //Your code here
- //$query->where('wisudawan.status',1);
- $data = explode("|",CRUDBooster::getSetting('periode_wisuda'));
- $query->where('wisudawan.periode_id',$data[0]);
- //$query->where('wisudawan.status',1);
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for manipulate row of index table html
- | ----------------------------------------------------------------------
- |
- */
- public function hook_row_index($column_index,&$column_value) {
- //Your code here
- if ($column_index ==6)
- {
- if ($column_value >2)
- {
- $column_value='<span class="label label-warning fa fa-arrow-up" > '.$column_value.' </span>';
- }
- }
- if($column_index ==11)
- {
- if ($column_value == 0)
- {
- $column_value='<span class="label label-warning" > 0 | Non-Active </span>';
- }
- else if ($column_value == 1)
- {
- $column_value='<span class="label label-success" >1 | Active </span>';
- }
- }
- if($column_index ==7 || $column_index ==8|$column_index ==9|$column_index ==10)
- {
- if ($column_value == 0)
- {
- $column_value='<span class="label label-danger" > 0 | Belum </span>';
- }
- else if ($column_value == 1)
- {
- $column_value='<span class="label label-primary" > 1 | Sudah </span>';
- }
- }
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for manipulate data input before add data is execute
- | ----------------------------------------------------------------------
- | @arr
- |
- */
- public function hook_before_add(&$postdata) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for execute command after add public static function called
- | ----------------------------------------------------------------------
- | @id = last insert id
- |
- */
- public function hook_after_add($id) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for manipulate data input before update data is execute
- | ----------------------------------------------------------------------
- | @postdata = input post data
- | @id = current id
- |
- */
- public function hook_before_edit(&$postdata,$id) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for execute command after edit public static function called
- | ----------------------------------------------------------------------
- | @id = current id
- |
- */
- public function hook_after_edit($id) {
- //Your code here
- $tmbhundangan = Request::get('tambahan_undangan');
- DB::table('wisudawan')->where('id', $id)->update(['jumundangan' => 2+$tmbhundangan]);
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for execute command before delete public static function called
- | ----------------------------------------------------------------------
- | @id = current id
- |
- */
- public function hook_before_delete($id) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for execute command after delete public static function called
- | ----------------------------------------------------------------------
- | @id = current id
- |
- */
- public function hook_after_delete($id) {
- //Your code here
- }
- //By the way, you can still create your own method in here... :)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement