Advertisement
Guest User

CONTROLLER

a guest
Feb 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.48 KB | None | 0 0
  1. angular.module('app.controllers', [])
  2.  
  3. .controller('pageCtrl', ['$scope', '$stateParams', // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
  4. // You can include any angular dependencies as parameters for this function
  5. // TIP: Access Route Parameters for your page via $stateParams.parameterName
  6. function ($scope, $stateParams) {
  7.  
  8.  
  9. }])
  10.  
  11. .controller('welcomescreenCtrl', ['$scope', '$stateParams', // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
  12. // You can include any angular dependencies as parameters for this function
  13. // TIP: Access Route Parameters for your page via $stateParams.parameterName
  14. function ($scope, $stateParams) {
  15.  
  16.  
  17. }])
  18.  
  19. .controller('mainCtrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  20.  
  21.  
  22. }])
  23.  
  24. .controller('updatepassCtrl',function ($scope,$http,$ionicPopup,$state,$ionicHistory,$stateParams,$ionicLoading) {
  25.  
  26.  
  27. $scope.reset= function(data){
  28.  
  29. $ionicLoading.show({
  30. template: '<p>Please Wait ...</p><ion-spinner></ion-spinner>'
  31. });
  32.  
  33. var link ='http://dewanstudio.biz/SIT//cms_begawan/api/updatepass/' ;
  34. $http.post(link, {d : localStorage.getItem('id_reset'), s : data.password})
  35. .then(function (res){
  36. $ionicLoading.hide();
  37. var alertPopup = $ionicPopup.alert({
  38. template: 'Password Berhasil di Update'
  39. });
  40. $state.go('login', {}, {location: "replace", reload: true});
  41. });
  42. };
  43.  
  44. })
  45.  
  46.  
  47. .controller('forgetpassCtrl',function ($scope, $stateParams, $http, $state, $ionicPopup,$ionicHistory) {
  48.  
  49. $scope.user = {};
  50. $scope.resetpass=function(){
  51. str="http://dewanstudio.biz/SIT/cms_begawan/api/resetpass/index.php?em="+$scope.user.email;
  52. $http.get(str)
  53. .success(function (response){
  54. $scope.user_details = response.records;
  55.  
  56. localStorage.setItem('id_reset', $scope.user_details.id);
  57.  
  58. var idres = $scope.user_details.id;
  59. $state.go('updatepass', {}, {id_reset : $scope.user_details.id});
  60. }).error(function() {
  61. var alertPopup = $ionicPopup.alert({
  62. title: '',
  63. template: 'Email Tidak Terdaftar'
  64. });
  65. });
  66. }
  67.  
  68.  
  69. })
  70.  
  71.  
  72. .controller('signupCtrl',function ($scope, $stateParams,$http,$ionicPopup,$state,$ionicHistory,$ionicPlatform ) {
  73.  
  74. $scope.daftar=function(data){
  75.  
  76. var link = 'http://dewanstudio.biz/SIT/cms_begawan/api/register/';
  77. //using http post as we are passing password.
  78. $http.post(link, {f : data.fullname, e : data.email,u : data.username, ps : data.password })
  79. .then(function (res){ //if a response is recieved from the server.
  80.  
  81. $scope.response = res.data.result; //contains Register Result
  82.  
  83. //Shows the respective popup and removes back link
  84. if($scope.response.created=="1"){
  85. $scope.title="Account Created!";
  86. $scope.template="Your account has been successfully created!";
  87.  
  88. //no back option
  89. $ionicHistory.nextViewOptions({
  90. disableAnimate: true,
  91. disableBack: true
  92. });
  93. // the user is redirected to login page after sign up
  94. $state.go('login', {}, {location: "replace", reload: true});
  95.  
  96. }else if($scope.response.exists=="1"){
  97. $scope.title="Email Already exists";
  98. $scope.template="Please click forgot password if necessary";
  99.  
  100. }else{
  101. $scope.title="Failed";
  102. $scope.template="Contact Our Technical Team";
  103. }
  104. var alertPopup = $ionicPopup.alert({
  105. title: $scope.title,
  106. template: $scope.template
  107. });
  108.  
  109. });
  110. }
  111.  
  112. })
  113.  
  114.  
  115.  
  116. .controller('loginCtrl', function ($scope, $stateParams, $http, $state, $ionicHistory, $ionicLoading, $ionicPlatform, $ionicPopup, $timeout,$rootScope) {
  117.  
  118. $scope.show = function() {
  119. $ionicLoading.show({
  120. template: '<p>Please Wait ...</p><ion-spinner></ion-spinner>'
  121. });
  122. };
  123.  
  124. $scope.hide = function(){
  125. $ionicLoading.hide();
  126. };
  127.  
  128. $scope.user = {};
  129.  
  130. $ionicPlatform.ready(function () {
  131.  
  132. if(localStorage.loggedin_id){
  133. $scope.show($ionicLoading);
  134. $timeout(function() {
  135. $scope.hide($ionicLoading);
  136. }, 2000);
  137.  
  138. $state.go('menu', {}, {location: "replace", reload: true});
  139. }
  140.  
  141.  
  142.  
  143. $scope.login = function() {
  144. $scope.show($ionicLoading);
  145. str="http://dewanstudio.biz/SIT/cms_begawan/api/user_detil/index.php?e="+$scope.user.email+"&p="+$scope.user.password;
  146. $http.get(str)
  147. .success(function (response){
  148. $scope.user_details = response.records;
  149. console.log(response.records);
  150.  
  151. sessionStorage.setItem('loggedin_id', $scope.user_details.id);
  152. sessionStorage.setItem('loggedin_fullname', $scope.user_details.fullname);
  153. sessionStorage.setItem('loggedin_email', $scope.user_details.email);
  154. sessionStorage.setItem('loggedin_username', $scope.user_details.username);
  155.  
  156. $rootScope.loggedin_id = $scope.user_details.id;
  157.  
  158. $ionicHistory.nextViewOptions({
  159. disableAnimate: true,
  160. disableBack: true
  161. });
  162.  
  163. lastView = $ionicHistory.backView();
  164. console.log('Last View',lastView);
  165. $state.go('menu', {}, {location: "replace", reload: true});
  166.  
  167. $timeout(function() {
  168. $scope.hide($ionicLoading);
  169. }, 2000);
  170.  
  171. }).error(function() {
  172. var alertPopup = $ionicPopup.alert({
  173. title: 'Login failed!',
  174. template: 'Please check your Email & Password !'
  175. });
  176. $timeout(function() {
  177. $scope.hide($ionicLoading);
  178. }, 2000);
  179. });
  180. };
  181.  
  182. });
  183.  
  184.  
  185. })
  186.  
  187.  
  188.  
  189.  
  190.  
  191. .controller('menuCtrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  192.  
  193.  
  194. }])
  195.  
  196. .controller('katasambutanCtrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  197.  
  198.  
  199. }])
  200.  
  201. .controller('kawasanCtrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  202.  
  203.  
  204. }])
  205.  
  206. .controller('minatbeliCtrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  207.  
  208.  
  209. }])
  210.  
  211. .controller('detilminatbeliCtrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  212.  
  213.  
  214. }])
  215.  
  216. .controller('detilminatbeli2Ctrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  217.  
  218.  
  219. }])
  220.  
  221. .controller('paymentmbCtrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  222.  
  223.  
  224. }])
  225.  
  226. .controller('kontakCtrl',function ($scope, $stateParams,$http,$ionicPopup,$ionicHistory,$state) {
  227.  
  228.  
  229. $scope.addpesan = function(data) {
  230.  
  231. $http.post('http://dewanstudio.biz/SIT/cms_begawan/api/informasi_pemasaran/', {
  232. dnama: data.nama,
  233. demail: data.email,
  234. dtelp: data.notlp,
  235. dmessage: data.pesan,
  236. })
  237.  
  238.  
  239. .success(function(data, status, headers, config) {
  240. var alertPopup = $ionicPopup.alert({
  241. title: 'Thank You!',
  242. template: 'Laporan Anda Terkirim'
  243. });
  244. $ionicHistory.clearCache();
  245. $ionicHistory.clearHistory();
  246. $state.go('kontak', {}, { location: "replace", reload: true });
  247.  
  248. });
  249.  
  250. console.log(data);
  251. }
  252.  
  253.  
  254.  
  255.  
  256. })
  257.  
  258.  
  259.  
  260. .controller('fasilitasCtrl',function ($scope, $stateParams,$ionicModal) {
  261.  
  262.  
  263. $scope.modalData = {};
  264. $scope.showAlert = function(konsep) {
  265.  
  266. if(konsep == 1){
  267. $scope.modalData.textColor = '#acce22';
  268. $scope.modalData.Title = '';
  269. $scope.modalData.Desc = "";
  270. $scope.modalData.Image = './img/fasilitaspopup.png';
  271. }
  272.  
  273. $scope.modalData.From = 'konsep';
  274. $scope.modalData.No = konsep;
  275.  
  276. $ionicModal.fromTemplateUrl('templates/alert_modal.html', {
  277. scope: $scope,
  278. animation: 'none'
  279. }).then(function(modal) {
  280. $scope.modal = modal;
  281. $scope.modal.show();
  282. // window.plugins.nativepagetransitions.slide();
  283. });
  284.  
  285. };
  286.  
  287. // Close the modal
  288. $scope.closeModal = function() {
  289. $scope.modal.hide();
  290. $scope.modal.remove();
  291. };
  292.  
  293.  
  294. })
  295.  
  296. .controller('promosiCtrl', function ($scope, $stateParams, $http,$filter,$ionicModal,$ionicLoading) {
  297.  
  298. $ionicLoading.show({
  299. template: 'Mengambil Data Dari Server <br><br> <ion-spinner icon="android"></ion-spinner>'
  300. });
  301.  
  302. $http.get("http://dewanstudio.biz/SIT/cms_begawan/api/promosi/")
  303. .success(function (data) {
  304. $scope.getpromosi = data.item;
  305. $ionicLoading.hide();
  306.  
  307.  
  308. });
  309.  
  310. $scope.modalData = {};
  311. $scope.showAlert = function(konsep,id,file_name) {
  312.  
  313. localStorage.setItem('promosi_id', id);
  314. localStorage.setItem('promosi_file_name', file_name);
  315.  
  316. $scope.id = localStorage.getItem('promosi_id');
  317.  
  318. console.log($scope.id);
  319.  
  320. if(konsep == localStorage.getItem('promosi_id') ){
  321. $scope.modalData.textColor = '#acce22';
  322. $scope.modalData.Title = '';
  323. $scope.modalData.Desc = "";
  324. $scope.modalData.Image = 'http://dewanstudio.biz/SIT/cms_begawan/clients/promosi/'+localStorage.getItem('promosi_file_name');
  325. }
  326.  
  327.  
  328. $scope.modalData.From = 'konsep';
  329. $scope.modalData.No = konsep;
  330.  
  331. $ionicModal.fromTemplateUrl('templates/alert_modal.html', {
  332. scope: $scope,
  333. animation: 'none'
  334. }).then(function(modal) {
  335. $scope.modal = modal;
  336. $scope.modal.show();
  337. // window.plugins.nativepagetransitions.slide();
  338. });
  339.  
  340. };
  341.  
  342. // Close the modal
  343. $scope.closeModal = function() {
  344. $scope.modal.hide();
  345. $scope.modal.remove();
  346. };
  347.  
  348.  
  349.  
  350.  
  351. })
  352.  
  353. .controller('menupopupCtrl',function ($scope, $stateParams, $ionicModal) {
  354.  
  355. $scope.modalData = {};
  356. $scope.showAlert = function(konsep) {
  357.  
  358. if(konsep == 1){
  359. $scope.modalData.textColor = '#acce22';
  360. $scope.modalData.Title = '';
  361. $scope.modalData.Desc = "";
  362. $scope.modalData.Image = './img/menu_popup/lokasi.png';
  363. }else if(konsep == 2){
  364. $scope.modalData.textColor = '#fabf01';
  365. $scope.modalData.Title = '';
  366. $scope.modalData.Desc = "";
  367. $scope.modalData.Image = './img/menu_popup/akses_strategis.png';
  368. }else if(konsep == 3){
  369. $scope.modalData.textColor = '#1962ae';
  370. $scope.modalData.Title = '';
  371. $scope.modalData.Desc = "";
  372. $scope.modalData.Image = './img/menu_popup/peluangbisnis.png';
  373. }else if(konsep == 4){
  374. $scope.modalData.textColor = '#01aebc';
  375. $scope.modalData.Title = '';
  376. $scope.modalData.Desc = "";
  377. $scope.modalData.Image = './img/menu_popup/premium_student.png';
  378. }else if(konsep == 5){
  379. $scope.modalData.textColor = '#01aebc';
  380. $scope.modalData.Title = '';
  381. $scope.modalData.Desc = "";
  382. $scope.modalData.Image = './img/menu_popup/unit.png';
  383. }else if(konsep == 6){
  384. $scope.modalData.textColor = '#1962ae';
  385. $scope.modalData.Title = '';
  386. $scope.modalData.Desc = "";
  387. $scope.modalData.Image = './img/fasilitaspopup.png';
  388. }else if(konsep == 7){
  389. $scope.modalData.textColor = '#acce22';
  390. $scope.modalData.Title = '';
  391. $scope.modalData.Desc = "";
  392. $scope.modalData.Image = './img/menu_popup/harga_menarik.png';
  393. }else if(konsep == 8){
  394. $scope.modalData.textColor = '#fabf01';
  395. $scope.modalData.Title = '';
  396. $scope.modalData.Desc = "";
  397. $scope.modalData.Image = './img/menu_popup/developer.png';
  398. }
  399.  
  400. $scope.modalData.From = 'konsep';
  401. $scope.modalData.No = konsep;
  402.  
  403. $ionicModal.fromTemplateUrl('templates/alert_modal.html', {
  404. scope: $scope,
  405. animation: 'none'
  406. }).then(function(modal) {
  407. $scope.modal = modal;
  408. $scope.modal.show();
  409. // window.plugins.nativepagetransitions.slide();
  410. });
  411.  
  412. };
  413.  
  414. // Close the modal
  415. $scope.closeModal = function() {
  416. $scope.modal.hide();
  417. $scope.modal.remove();
  418. };
  419.  
  420.  
  421. })
  422.  
  423. .controller('unitplanCtrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  424.  
  425.  
  426. }])
  427.  
  428. .controller('unitplan2Ctrl', ['$scope', '$stateParams',function ($scope, $stateParams) {
  429.  
  430.  
  431. }])
  432.  
  433. .controller('unitplan3Ctrl',function ($scope, $stateParams, $ionicModal) {
  434.  
  435.  
  436. $scope.modalData = {};
  437. $scope.showAlert = function(konsep) {
  438.  
  439. if(konsep == 1){
  440. $scope.modalData.textColor = '#acce22';
  441. $scope.modalData.Title = '';
  442. $scope.modalData.Desc = "";
  443. $scope.modalData.Image = './img/flor_map.png';
  444. }
  445.  
  446. $scope.modalData.From = 'konsep';
  447. $scope.modalData.No = konsep;
  448.  
  449. $ionicModal.fromTemplateUrl('templates/alert_modal.html', {
  450. scope: $scope,
  451. animation: 'none'
  452. }).then(function(modal) {
  453. $scope.modal = modal;
  454. $scope.modal.show();
  455. // window.plugins.nativepagetransitions.slide();
  456. });
  457.  
  458. };
  459.  
  460. // Close the modal
  461. $scope.closeModal = function() {
  462. $scope.modal.hide();
  463. $scope.modal.remove();
  464. };
  465.  
  466.  
  467. })
  468.  
  469.  
  470. .controller('bisnispotensialCtrl',function ($scope, $stateParams) {
  471.  
  472.  
  473. })
  474.  
  475. .controller('unitcustomizedCtrl',function ($scope, $stateParams, $ionicModal) {
  476.  
  477.  
  478. $scope.modalData = {};
  479. $scope.showAlert = function(konsep) {
  480.  
  481. if(konsep == 1){
  482. $scope.modalData.textColor = '#acce22';
  483. $scope.modalData.Title = '';
  484. $scope.modalData.Desc = "";
  485. $scope.modalData.Image = './img/detil_unitcustomized.png';
  486. }
  487.  
  488. $scope.modalData.From = 'konsep';
  489. $scope.modalData.No = konsep;
  490.  
  491. $ionicModal.fromTemplateUrl('templates/alert_modal.html', {
  492. scope: $scope,
  493. animation: 'none'
  494. }).then(function(modal) {
  495. $scope.modal = modal;
  496. $scope.modal.show();
  497. // window.plugins.nativepagetransitions.slide();
  498. });
  499.  
  500. };
  501.  
  502. // Close the modal
  503. $scope.closeModal = function() {
  504. $scope.modal.hide();
  505. $scope.modal.remove();
  506. };
  507.  
  508.  
  509. })
  510.  
  511. .controller('simulasipembayaranCtrl',function ($scope, $stateParams,$ionicModal,$ionicHistory,$state) {
  512.  
  513. $scope.modalData = {};
  514. $scope.showAlert = function(konsep,data) {
  515.  
  516. localStorage.setItem('jenis_pembayaran', data.pembayaran);
  517. localStorage.setItem('kpa_bank', data.kpa);
  518. localStorage.setItem('bank_konvensional', data.konvensional);
  519. localStorage.setItem('harga_unit', data.hargaunit);
  520. localStorage.setItem('diskon', data.diskon);
  521. localStorage.setItem('dp', data.dp);
  522. localStorage.setItem('utj', data.utj);
  523. localStorage.setItem('angsuran', data.angsuran);
  524.  
  525.  
  526. if(konsep == 1){
  527. $scope.modalData.textColor = '#acce22';
  528. $scope.modalData.jenis_pembayaran = data.pembayaran;
  529.  
  530. $scope.modalData.hargaunit =parseInt(data.hargaunit);
  531. $scope.modalData.diskon = parseInt(data.diskon);
  532. $scope.modalData.dp = parseInt(data.dp);
  533. $scope.modalData.utj= parseInt(data.utj);
  534. $scope.modalData.angsuran=parseInt(data.angsuran);
  535. var tambah = $scope.modalData.hargaunit+$scope.modalData.diskon+$scope.modalData.dp+$scope.modalData.utj;
  536. $scope.modalData.hasil= tambah / $scope.modalData.angsuran;
  537. console.log(tambah/$scope.modalData.angsuran);
  538.  
  539. $scope.modalData.Desc = "";
  540. $scope.modalData.Image = './img/detil_tipestudio.png';
  541. }
  542. $scope.modalData.From = 'konsep';
  543. $scope.modalData.No = konsep;
  544.  
  545. $ionicModal.fromTemplateUrl('templates/result_simulasi.html', {
  546. scope: $scope,
  547. animation: 'none'
  548. }).then(function(modal) {
  549. $scope.modal = modal;
  550. $scope.modal.show();
  551. // window.plugins.nativepagetransitions.slide();
  552. });
  553.  
  554. };
  555.  
  556. // Close the modal
  557. $scope.closeModal = function() {
  558. $scope.modal.hide();
  559. $scope.modal.remove();
  560.  
  561. $ionicHistory.clearCache();
  562. $ionicHistory.clearHistory();
  563. $state.go('simulasipembayaran', {}, { location: "replace", reload: true });
  564. };
  565.  
  566.  
  567. })
  568.  
  569. .controller('resultsimulasiCtrl',function ($scope, $stateParams) {
  570.  
  571.  
  572. })
  573.  
  574.  
  575. .controller('eventCtrl',function ($scope, $stateParams,$http,$stateParams,$state,$ionicLoading) {
  576.  
  577. $ionicLoading.show({
  578. template: 'Mohon Tunggu <br> <ion-spinner icon="android"></ion-spinner>'
  579. });
  580.  
  581. $http.get("http://dewanstudio.biz/SIT/cms_begawan/api/event/")
  582. .success(function (data) {
  583.  
  584. $scope.getevent = data.item;
  585. console.log(data);
  586. $ionicLoading.hide();
  587. });
  588.  
  589.  
  590.  
  591. $scope.eventview = function(id, file_name, desc) {
  592. localStorage.setItem('event_id', id);
  593. localStorage.setItem('event_gambar', file_name);
  594. localStorage.setItem('event_deskripsi', desc);
  595. window.location.href = "#/eventview";
  596. console.log(id,desc,file_name);
  597. }
  598.  
  599.  
  600. })
  601.  
  602. .controller('eventviewCtrl',function ($scope, $stateParams,$http,$state,$stateParams) {
  603.  
  604. angular.element(document).ready(function() {
  605.  
  606. $scope.id = localStorage.getItem('event_id');
  607. $scope.gambar = localStorage.getItem('event_gambar');
  608. $scope.deskripsi = localStorage.getItem('event_deskripsi');
  609. });
  610.  
  611.  
  612.  
  613. })
  614.  
  615. .controller('desainunitCtrl',function ($scope, $stateParams, $ionicModal) {
  616.  
  617.  
  618.  
  619. $scope.modalData = {};
  620. $scope.showAlert = function(konsep) {
  621.  
  622. if(konsep == 1){
  623. $scope.modalData.textColor = '#acce22';
  624. $scope.modalData.Title = '';
  625. $scope.modalData.Desc = "";
  626. $scope.modalData.Image = './img/detil_tipestudio.png';
  627. }else if(konsep == 2){
  628. $scope.modalData.textColor = '#fabf01';
  629. $scope.modalData.Title = '';
  630. $scope.modalData.Desc = "";
  631. $scope.modalData.Image = './img/detil_tipe2bedroom.png';
  632. }else if(konsep == 3){
  633. $scope.modalData.textColor = '#1962ae';
  634. $scope.modalData.Title = '';
  635. $scope.modalData.Desc = "";
  636. $scope.modalData.Image = './img/detil_tipe2bedroomcorner.png';
  637. }
  638.  
  639. $scope.modalData.From = 'konsep';
  640. $scope.modalData.No = konsep;
  641.  
  642. $ionicModal.fromTemplateUrl('templates/alert_modal.html', {
  643. scope: $scope,
  644. animation: 'none'
  645. }).then(function(modal) {
  646. $scope.modal = modal;
  647. $scope.modal.show();
  648. // window.plugins.nativepagetransitions.slide();
  649. });
  650.  
  651. };
  652.  
  653. // Close the modal
  654. $scope.closeModal = function() {
  655. $scope.modal.hide();
  656. $scope.modal.remove();
  657. };
  658.  
  659.  
  660. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement