Blame view

app/partials/ContactView/ContactView.controller.js 3 KB
4bb02bb84   Rishav   new integration w...
1
2
3
4
  'use strict';
  
   //Load controller
    angular.module('acufuel')
49676befb   Anchit Jindal   new changes applied
5
  	.controller('ContactViewController', ['$scope', '$uibModal', 'ContactViewService', 'ViewCompanyService', 'ViewcontactService', 'NgTableParams', function($scope, $uibModal, ContactViewService, ViewCompanyService, ViewcontactService, NgTableParams) {
2c476c756   Anchit Jindal   added new code
6
7
8
9
10
11
          
          $(document).ready(function() {
              $('#contacts').DataTable();
          });
          
          ContactViewService.getContacts().then(function(result) {
2c476c756   Anchit Jindal   added new code
12
          	$scope.contactList = result;
2c476c756   Anchit Jindal   added new code
13
          })
7e481a068   Rishav   implement toogle ...
14

7152ff131   Rishav   model handle
15
16
17
          $scope.reset = function(){
            $("input").val("");
          }
49676befb   Anchit Jindal   new changes applied
18
19
          
          $scope.data = {};
da24c95c8   Rishav Singla   confirmation mess...
20
  		    getAllContacts();
7152ff131   Rishav   model handle
21

7e481a068   Rishav   implement toogle ...
22
          $scope.changePriceEmail = function(id, index){
d24318592   Rishav   changes and new i...
23
            event.stopPropagation();
da24c95c8   Rishav Singla   confirmation mess...
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
            var contactId = id;
            var statusData = "status=" + $scope.contactList[index].priceEmail;
            ViewcontactService.changePriceEmail(contactId, statusData).then(function(result) {
                if(result.success){
                    $('#toogleMail').css('display', 'block');
                    if($scope.contactList[index].priceEmail == true){
                      $scope.messageText = 'You have enabled price distribution for this contact';
                    }else{
                      $scope.messageText = 'You have disabled price distribution for this contact';
                    }
                }
            })
          }
  
          $scope.cancelToogle = function(){
            $('#toogleMail').css('display', 'none');
7e481a068   Rishav   implement toogle ...
40
          }
2c476c756   Anchit Jindal   added new code
41
          
49676befb   Anchit Jindal   new changes applied
42
43
          
          function getAllContacts(){
da24c95c8   Rishav Singla   confirmation mess...
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
            ContactViewService.getContacts().then(function(result) {
              console.log('log', result);
              $scope.contactList = result;
              for (var i = 0; i < $scope.contactList.length; i++) {
              	if ($scope.contactList[i].owner != null) {
              		if ($scope.contactList[i].owner.companyName != null || $scope.contactList[i].owner.companyName != undefined) {
              			$scope.contactList[i].owner = $scope.contactList[i].owner.companyName;
              		}
              	}
              }
              $scope.displayContactList = new NgTableParams({
                page: 1,
                count: 10,
              }, {
                data: $scope.contactList
              });
            })
  		    }
49676befb   Anchit Jindal   new changes applied
62
63
64
          
          
          /*ContactViewService.getCompanies().then(function(result) {
2c476c756   Anchit Jindal   added new code
65
66
          	$scope.companies = result;
            
49676befb   Anchit Jindal   new changes applied
67
          })*/
2c476c756   Anchit Jindal   added new code
68
69
70
71
          
          $scope.contactData = {};
          $scope.contactData.contactList = [];
          $scope.addContact = function(){
2c476c756   Anchit Jindal   added new code
72
73
74
75
76
77
78
79
80
81
82
83
84
85
            $scope.contactData.contactList.push($scope.data);
            ViewCompanyService.addContact($scope.contactData).then(function(result) {
              if(result.success){
                toastr.success(''+result.success+'', {
                    closeButton: true
                  })
                  $('#contact-modal-3').modal('hide');
              }else{
                toastr.error(''+result.statusText+'', {
                    closeButton: true
                  })
              }
            })
          }
4bb02bb84   Rishav   new integration w...
86
87
  
      }]);