Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.controller('pendataanDBKBJPB2', ['$scope', '$http','$stateParams','$state','$modal','$sce', 'toaster', '$cookieStore', '$timeout', function($scope, $http, $stateParams, $state, $modal, $sce, toaster, $cookieStore, $timeout) {
- filterable();
- var offset = ((parseInt($stateParams.page) - 1) * 10) || 0;
- try {
- $scope.search = ($stateParams.search!==undefined) ? JSON.parse($stateParams.search) : [];
- } catch(e){
- $scope.search = [];
- }
- angular.element(document).ready(function(){
- var flash_message = $cookieStore.get('flash_message');
- if(flash_message!=undefined && flash_message!=null && flash_message.type!=undefined){
- $timeout(function(){
- toaster.pop(flash_message.type,flash_message.title,flash_message.text);
- $cookieStore.remove('flash_message');
- }, 1000);
- }
- });
- $scope.data = {};
- $scope.data.search_tahun = $scope.search[0];
- $scope.data.search_kelas = $scope.search[1];
- $scope.search_tahun = $scope.search[0];
- $scope.search_kelas = $scope.search[1];
- $scope.info = '';
- $scope.search_submit = function(){
- $state.go($state.current,{search:JSON.stringify([$scope.data.search_tahun || '', $scope.data.search_kelas || ''])},{reload:true});
- };
- // var search_q = [],
- // search_col = [],
- // col = ['thn_dbkb_jpb2','kls_dbkb_jpb2'];
- // for(key in $scope.search){
- // if($scope.search[key]){
- // search_q.push($scope.search[key]);
- // search_col.push(col[key]);
- // }
- // }
- // $http({
- // method: 'POST',
- // url: "/pendataan/Dbkb_jpb02/index/"+offset,
- // data: $.param({
- // tahun:search_q[0],
- // kelas:search_q[1],
- // go:'1',
- // }),
- // headers: {'Content-Type': 'application/x-www-form-urlencoded'}
- var current_tahun = $scope.data.search_tahun;
- var current_kelas = $scope.data.search_kelas;
- $http({
- method: 'POST',
- url: "/pendataan/Dbkb_jpb02/index/"+offset,
- data: $.param({
- tahun : current_tahun,
- kelas : current_kelas,
- go:1,
- }),
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
- }).success(function(response){
- //response.data.table = [];
- $scope.search = response.data.search;
- $scope.list = response.data.table;
- $scope.total = parseInt(response.data.tot_row);
- $scope.offset = parseInt(response.data.offset);
- $scope.perpage = parseInt(response.data.perpage);
- $scope.maxoffset = ($scope.offset + $scope.perpage);
- $scope.maxoffset = $scope.maxoffset > $scope.total ? $scope.total : $scope.maxoffset;
- $scope.page = parseInt($stateParams.page);
- $scope.maxpage = Math.ceil(parseInt(response.data.tot_row) / parseInt(response.data.perpage));
- $scope.getNumber = function(current,maxpage){
- var numbers = [],
- end = Math.ceil((current) / 10) * 10,
- start = Math.floor((current - 1) / 10) * 10;
- if(end > maxpage) end = maxpage;
- if(start < 1) start = 1;
- for(i=start; i <= end; ++i) numbers.push(i);
- return numbers;
- };
- var page_info = angular.element(document.getElementById('HeaderDD')).scope();
- page_info.refresh(function(res){
- $scope.info = res.content_help;
- });
- if($scope.list.length < 1 && $scope.page > 1){
- $state.go($state.current,{page:1},{reload:true});
- }
- });
- $scope.refresh = function(){
- $state.go($state.current,{page:$stateParams.page,search:$stateParams.search || ''},{reload:true});
- };
- $scope.info_btn = function(){
- var modalInstance = $modal.open({
- templateUrl: 'info_modal',
- controller: 'modal_info',
- });
- modalInstance.info = $scope.info;
- };
- }]);
- app.controller('refKecamatanTambah', ['$scope', '$http','$stateParams', '$sce', 'toaster', '$state', '$cookieStore', '$modal', '$window', function($scope, $http, $stateParams, $sce, toaster, $state, $cookieStore, $modal, $window) {
- var id = $stateParams.id;
- $scope.data = {
- KD_PROPINSI : '',
- KD_DATI2 : '',
- KD_KECAMATAN : '',
- NM_KECAMATAN : '',
- };
- $http.get("/referensi/wilayah_kecamatan/create").success(function(response){
- $scope.data.KD_PROPINSI = response.data.propinsi;
- $scope.data.KD_DATI2 = response.data.dati2;
- var page_info = angular.element(document.getElementById('HeaderDD')).scope();
- page_info.refresh(function(res){
- $scope.info = res.content_help;
- });
- });
- $scope.submit = function(){
- $http({
- method: 'POST',
- url: '/referensi/wilayah_kecamatan/store',
- data: $.param(lowerCaseKey($scope.data)),
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
- }).success(function(response){
- if(response.status){
- $cookieStore.put('flash_message',{type:'success',title:'Sukses',text:'Data berhasil ditambahkan'});
- $state.go('^',null,{reload:true});
- } else {
- toaster.pop('error', 'Error', response.msg, 3000, 'trustedHtml');
- }
- });
- };
- $scope.back = function(){
- $window.history.back();
- };
- $scope.info_btn = function(){
- var modalInstance = $modal.open({
- templateUrl: 'info_modal',
- controller: 'modal_info',
- });
- modalInstance.info = $scope.info;
- };
- }]);
- app.controller('refKecamatanEdit',function($scope, $http, $stateParams, $sce, toaster, $state, $cookieStore, $modal, $filter, $window) {
- var id = $stateParams.id;
- $http.get("/referensi/wilayah_kecamatan/edit/"+id.split('-').join('/')).success(function(response){
- $scope.data = response.data.table[0];
- $scope.id = id;
- $scope.update = function(_id){
- _id = _id.split('-');
- $http({
- method: 'POST',
- url: '/referensi/wilayah_kecamatan/update',
- data: $.param(lowerCaseKey($scope.data)),
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
- }).success(function(response){
- if(response.status){
- $cookieStore.put('flash_message',{type:'success',title:'Sukses',text:'Perubahan berhasil disimpan'});
- $state.go('^',{page:$stateParams.page,search:$stateParams.search || ''},{reload:true});
- } else {
- toaster.pop('error', 'Error', response.msg, 3000, 'trustedHtml');
- }
- });
- };
- $scope.back = function(){
- $window.history.back();
- };
- $scope.info = '';
- var page_info = angular.element(document.getElementById('HeaderDD')).scope();
- page_info.refresh(function(res){
- $scope.info = res.content_help;
- });
- });
- $scope.info_btn = function(){
- var modalInstance = $modal.open({
- templateUrl: 'info_modal',
- controller: 'modal_info',
- });
- modalInstance.info = $scope.info;
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement