· 7 years ago · Jan 05, 2018, 11:42 AM
1/*
2 * Your installation or use of this SugarCRM file is subject to the applicable
3 * terms available at
4 * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
5 * If you do not agree to all of the applicable terms or do not have the
6 * authority to bind the entity as an authorized representative, then do not
7 * install or use this SugarCRM file.
8 *
9 * Copyright (C) SugarCRM Inc. All rights reserved.
10 */
11/**
12 * @class View.Views.Base.Calls.CreateView
13 * @alias SUGAR.App.view.views.CallsCreateView
14 * @extends View.Views.Base.CreateView
15 */
16({
17 extendsFrom: 'CreateView',
18
19 /**
20 * @inheritdoc
21 */
22 initialize: function(options) {
23 this._super('initialize', [options]);
24 this.context.on('button:save_button:click', this.saveAccountPlanLines, this);
25 },
26
27 /**
28 * Defaults to {@link #saveAndClose}.
29 */
30 save: function() {
31 this.saveAndClose();
32 },
33
34 /**
35 * Save and close drawer
36 */
37 saveAndClose: function () {
38 this.initiateSave(_.bind(function () {
39 // pass to local
40 var self = this;
41 // init
42 //var names = [];
43 // loop through line items
44 // $('#table-line-items tbody').find('tr').each(function() {
45 // var name = $(this).find('input.name').val();
46 // names.push(name);
47
48 // });
49 //console.log(names);
50 // init
51 var objData = {
52 'id': this.model.get('id'),
53 'names' : $('.name').val(),
54 'product_category' : $('.product-category option:selected').val(),
55 'wallet_size' : $('.wallet-size').val(),
56 'bpi_share' : $('.bpi-share').val(),
57 'rm_strategy': $('.rm-strategy').val(),
58 'pm_strategy' : $('.pm-strategy').val()
59 }
60 // get url
61 var strUrl = app.api.buildURL('bpiaccelerator/saveaccountplanlines');
62 // call ajax
63 $.ajax({
64 url: strUrl,
65 data: objData,
66 dataType: "json",
67 headers: {
68 "OAuth-Token": app.api.getOAuthToken()
69 },
70 cache: false,
71 type: "POST",
72 success: function(objResponse) {
73 // Is this a json object
74 if (typeof(objResponse) == "string") {
75 // Decode
76 objResponse = $.parseJSON(objResponse);
77 }
78 console.log("mehul");
79 },
80 error: function(objResponse) {
81 console.log("error");
82 }
83 });
84 console.log(this.model.get('id'));
85 }, this));
86 },
87})