PageSourceSearch

https://b2b.sodanca.com/js/SoDanca/Controllers/dropshipControllers.js

js sodanca.com collected 2026-09-24 11:09:07 UTC 10,332 bytes, 296 lines download raw bytes

1// Dropship Controllers ========================================================================================
2
3// Variables -----------------------------------------------------
4// ---------------------------------------------------------------
5
6// Functions -----------------------------------------------------
7// ---------------------------------------------------------------
8
9// Ready ---------------------------------------------------------
10// ---------------------------------------------------------------
11
12angular.module('webSoDanca').controller('dropshipContactsController', ['$scope', 'util', 'dropshipService', 'dataService', function ($scope, util, dropshipService, dataService) {
13
14    // Variables -----------------------------------------------------
15    $scope.contacts         = [];
16
17
18    //{ name: 'Mobile', field: 'mobile', type: 1 },
19    //{ name: 'Email', field: 'email', type: 1 },
20    //{ name: 'Mobile', field: 'mobile', filters: [{ name: 'msEmpty' }] },
21    //{ name: 'Email', field: 'email', filters: [{ name: 'msEmpty' }] },
22
23    $scope.searchOptions    = [
24        { name: 'Name', field: 'name', type: 1 },
25        { name: 'Street', field: 'street', type: 1 },
26        { name: 'City', field: 'city', type: 1 },
27        { name: 'Zip', field: 'zip', type: 1 },
28        { name: 'State', field: 'state', type: 1 }
29    ];
30    //{ name: 'Type',             field: 'type',              filters: [{ name: 'msUserFilter', param: 'userTypes' }] },
31    $scope.tableHeaders     = [
32        { name: 'Name', field: 'name', filters: [{ name: 'msEmpty' }] },
33        { name: 'Street', field: 'street', filters: [{ name: 'msEmpty' }, { name: 'msSubstring', param: { min: 0, max: 15 } }] },
34        { name: 'City', field: 'city', filters: [{ name: 'msEmpty' }] },
35        { name: 'Zip', field: 'zip', filters: [{ name: 'msEmpty' }] },
36        { name: 'State', field: 'state', filters: [{ name: 'msEmpty' }] }
37    ];
38    // ---------------------------------------------------------------
39
40    // Functions -----------------------------------------------------
41    $scope.loadContacts     = function () {
42        try {
43            $scope.contacts = [];
44            util.loading(true);
45            dropshipService.getContacts(true, true).then(function (ret) {
46                $scope.contacts = ret;
47                util.loading(false);
48            }).catch(function (err) {
49                
50                util.loading(false);
51                util.throwError("82", true, true, err);
52
53            });
54
55
56        } catch (err) {
57            util.throwError("83", true, true, err);
58        }
59    };
60    $scope.lineClick        = function (contact) {
61
62        var asdsa = 0;
63        util.goToPage('dropshipContact', { id: contact.id });
64
65    };
66
67    $scope.newContact       = function () {
68        util.goToPage('dropshipNewContact');
69    };
70    // ---------------------------------------------------------------
71
72    // Ready ---------------------------------------------------------
73    $scope.loadContacts();
74    // ---------------------------------------------------------------
75
76}]);
77
78angular.module('webSoDanca').controller('dropshipContactController', ['$scope', 'util', '$stateParams', 'dropshipService', 'cartService', function ($scope, util, $stateParams, dropshipService, cartService) {
79
80    // Variables -----------------------------------------------------
81    $scope.contact      = null;
82    $scope.isDropship   = cartService.isDropShip;
83    // ---------------------------------------------------------------
84
85    // Functions -----------------------------------------------------
86    $scope.loadContact  = function () {
87
88        util.loading(true);
89        dropshipService.loadContact($stateParams.id).then(function (ret) {
90            $scope.contact = angular.copy(ret);
91            util.loading(false);
92        }).catch(function (err) {
93            
94            util.loading(false);
95            util.throwError("84", true, 0, err);
96
97        });
98
99    };
100
101
102    $scope.cancel       = function () {
103        util.goToPage("dropshipContacts");
104    };
105    $scope.checkout     = function () {
106        util.goToPage('checkout', { dropship_contact: $scope.contact });
107    };
108    $scope.edit         = function () {
109        util.goToPage('dropshipEditContact', { id: $scope.contact.
109id });
110    };
111    // ---------------------------------------------------------------
112
113    // Ready ---------------------------------------------------------
114    $scope.loadContact();
115    // ---------------------------------------------------------------
116
117}]);
118
119angular.module('webSoDanca').controller('dropshipNewContactController', ['$scope', 'util', 'dropshipService', 'states', 'countries', function ($scope, util, dropshipService, states, countries) {
120
121    // Variables -----------------------------------------------------
122    $scope.states       = states.results;
123    $scope.countries    = countries.results;
124    $scope.contact      = {};
125    // ---------------------------------------------------------------
126
127    // Functions -----------------------------------------------------
128    $scope.loadContact  = function () {
129
130        try {
131            util.loading(true);
132            var sid = $scope.states[0].id;
133            var cid = $scope.countries[0].id;
134
135            for (i = 0; i < $scope.countries.length; i++) {
136                var cname = angular.lowercase($scope.countries[i].name);
137                if (cname == "united states" || cname === "united states of america") {
138                    cid = $scope.countries[i].id;
139                    break;
140                }
141            }
142
143            for (i = 0; i < $scope.states.length; i++) {
144                var sname = angular.lowercase($scope.states[i].name);
145                if (sname == "florida") {
146                    sid = $scope.states[i].id;
147                    break;
148                }
149            }
150
151            $scope.contact.state_id = sid;
152            $scope.contact.country_id = cid;
153
154            util.loading(false);
155        } catch (err) {
156            util.throwError("85", true, true, err);
157        }
158
159
160
161    };
162
163    $scope.cancel       = function () {
164        var buttons = [
165            {
166                name: 'Ok',
167                func: function () {
168                    util.goToPage("dropshipContacts");
169                },
170                clickType: "ok"
171            },
172            {
173                name: 'Cancel',
174                func: function () { },
175                clickType: "ok"
176            }
177        ];
178        util.showConfirmationMsg('Do you want to cancel?', buttons);
179    };
180    $scope.save         = function () {
181
182        util.loading(true);
183        dropshipService.addContact($scope.contact).then(function (ret) {
184            var asdasd = 0;
185            var buttons = [
186                {
187                    name: 'Ok',
188                    func: function () {
189                        util.goToPage("dropshipContacts");
190                    },
191                    clickType: "ok"
192                },
193                {
194                    name: 'Use on checkout.',
195                    func: function () {
196                        util.goToPage("checkout", { dropship_contact: $scope.contact });
197                    },
198                    clickType: "ok"
199                },
200                {
201                    name: 'Cancel',
202                    func: function () { },
203                    clickType: "ok"
204                }
205            ];
206            util.showConfirmationMsg('Contact successfully added.', buttons);
207            util.loading(false);
208            //util.goToPage("dropshipContacts");
209        }).catch(function (err) {
210
211            if (err && err.b2b_error) {
212                util.loading(false);
213                util.showConfirmationMsg(err.msg);
214            } else {
215                util.loading(false);
216                util.throwError("86", true, false, err);
217            }
218
219        });
220
221
222    };
223    // ---------------------------------------------------------------
224
225    // Ready ---------------------------------------------------------
226    $scope.loadContact();
227    // ---------------------------------------------------------------
228
229}]);
230
231angular.module('webSoDanca').controller('dropshipEditContactController', ['$scope', 'util', 'dropshipService', '$stateParams', 'states', 'countries', function ($scope, util, dropshipService, $stateParams, states, countries) {
232
233    // Variables -----------------------------------------------------
234    $scope.states = states.results;
235    $scope.countries = countries.results;
236
237    $scope.contact = null;
238    // ---------------------------------------------------------------
239
240    // Functions -----------------------------------------------------
241    $scope.loadContact = function () {
242
243        util.loading(true);
244        dropshipService.loadContact($stateParams.id).then(function (ret) {
245            $scope.contact = ret;
246            util.loading(false);
247        }).catch(function (err) {
248            
249            util.loading(false);
250            util.throwError("87", true, 0, err);
251
252        });
253
254    };
255    $scope.cancel = function () {
256        var buttons = [
257            {
258                name: 'Ok',
259                func: function () {
260                    util.goToPage("dropshipContacts");
261                },
262                clickType: "ok"
263            },
264            {
265                name: 'Cancel',
266                func: function () { },
267                clickType: "ok"
268            }
269        ];
270        util.showConfirmationMsg('Do you want to cancel?', buttons);
271    };
272    $scope.save = function () {
273
274        util.loading(true);
275        dropshipService.editContact($scope.contact).then(function (ret) {
276            util.showConfirmationMsg('Contact successfully edited.');
277            util.goToPage("dropshipContacts");
278            util.loading(false);
279        }).catch(function (err) {
280            
281            util.loading(false);
282            util.throwError("88", true, false, err);
283
284        });
285
286
287    };
288    // ---------------------------------------------------------------
289
290    // Ready ---------------------------------------------------------
291    $scope.loadContact();
292    // ---------------------------------------------------------------
293
294}]);
295
296// ===========================================================================================================

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.