-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddopportunities.php
More file actions
222 lines (189 loc) · 8.69 KB
/
addopportunities.php
File metadata and controls
222 lines (189 loc) · 8.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
$permission = "VIEW";
require_once('head.php');
require_once('bodystart.php');
?>
<script type="text/javascript">
$(document).ready(function() {
//Fill all the drop downs from look up API
fillDropDown("api/getSalesStage.php", "#salesStage");
fillDropDown("api/getSocialStage.php", "#socialStage");
fillDropDown("api/getEmpList.php", "#assigned");
fillDropDown("api/getCustomerList.php", "#customer");
fillDropDown("api/getProjectTypeList.php", "#projType");
fillDropDown("api/getProductList.php", "#baseProd");
//If Change request then fill project whenever customer is changing
$("#customer").on("change", function(event, value) {
if ($('#typeOppor-1').is(":checked")) {
fillDropDown("api/getProjectList.php?cust=" + $('#customer').val(), "#proj");
}
});
//Datepicker does not cose on out of focus
$(".datepicker").datepicker({
autoclose: true
});
//Whenever change request selected then project control
//WHenever New project selected then show project type product etc
$('input[name="typeOppor"]').click(function() {
$('.togglehid').addClass('hidden');
// code changed here --> add the class hidden to all div's with class togglehid
if ($(this).attr('id') == 'typeOppor-0') {
$("#typeOppor-0-container").toggleClass('hidden');
emptyDropDown("#proj");
fillDropDown("api/getProjectTypeList.php", "#projType");
fillDropDown("api/getProductList.php", "#baseProd");
} else if ($(this).attr('id') == 'typeOppor-1') {
$("#typeOppor-1-container").toggleClass('hidden');
emptyDropDown("#projType");
emptyDropDown("#baseProd");
fillDropDown("api/getProjectList.php?cust=" + $('#customer').val(), "#proj");
document.getElementById("newExisting-1").checked = true;
document.getElementById("newExisting-0").checked = false;
}
}); //Close radio [Change request/Mew project]
//Full Submit
$('#opportunity-form').on('submit', function(e) {
// if the validator does not prevent form submit
if (!e.isDefaultPrevented()) {
var url = "api/createOpp.php";
// POST values in the background the the script URL
$.ajax({
type: "POST",
url: url,
data: $(this).serialize(),
success: function(data) {
var messageAlert = 'alert-' + data.type;
var messageText = data.message;
var alertBox = '<div class="alert ' + messageAlert + ' alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + messageText + '<a class="alert-link" href="' + data
.navigate + '">Click to view Details</a></div>';
// If we have messageAlert and messageText
if (messageAlert && messageText) {
// inject the alert to .messages div in our form
$('#opportunity-form').find('.messages').html(alertBox);
// empty the form
$('#opportunity-form')[0].reset();
}
} //CLose Success
}); //Close Ajax
return false;
} //close if isDefaultPrevented
}) //Close on Submit
}); //Close ondocument ready
</script>
<legend>Add Sales Opportunities</legend>
<div class="row">
<form id="opportunity-form" method="post" action="api/createOpp.php" role="form">
<div class="messages"></div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<!-- Multiple Radios (inline) -->
<label for="newExisting">Opportunity Type</label>
<br>
<label for="typeOppor-0">
<input type="radio" name="typeOppor" id="typeOppor-0" value="1" checked="checked">
New Project
</label>
<label class="radio-inline" for="typeOppor-1">
<input type="radio" name="typeOppor" id="typeOppor-1" value="2">
Change Request
</label>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="salesStage">Sales Stage</label>
<select id="salesStage" name="salesStage" class="form-control">
</select>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="socialStage">Social Stage</label>
<select id="socialStage" name="socialStage" class="form-control">
</select>
</div>
<div class="clearfix"></div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="customer">Customer</label>
<select id="customer" name="customer" class="form-control">
</select>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="oppname">Opportunity Name</label>
<input type="text" class="form-control" id="oppname" name="oppname" placeholder="Enter Opportunity Name" required>
<div class="form-control-feedback"></div>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="oppname">Proposal Document Path</label>
<input type="url" class="form-control" id="propPath" name="propPath" placeholder="Enter Proposal Document Path [URL LINK]" required>
</div>
<div class="clearfix"></div>
<div class="form-group col-xm-10 col-sm-4 col-md-4 col-lg-4">
<label for="oppname">Opportunity Details</label>
<textarea class="form-control" id="opptext" name="opptext" rows="5" placeholder="Enter Opportunity Details" required></textarea>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="assigned">Assigned to</label>
<select id="assigned" name="assigned" class="form-control">
</select>
</div>
<div class="clearfix"></div>
<div id="typeOppor-0-container" class="togglehid ">
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="projType">Project Type</label>
<select id="projType" name="projType" class="form-control">
</select>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="baseProd">Base Product</label>
<select id="baseProd" name="baseProd" class="form-control">
</select>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<!-- Multiple Radios (inline) -->
<label for="newExisting">Customer</label>
<br>
<label for="newExisting-0">
<input type="radio" name="newExisting" id="newExisting-0" value="1" checked="checked">
New
</label>
<label class="radio-inline" for="newExisting-1">
<input type="radio" name="newExisting" id="newExisting-1" value="2">
Existing
</label>
</div>
</div>
<div class="clearfix"></div>
<div id="typeOppor-1-container" class="togglehid hidden">
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="proj">Project</label>
<select id="proj" name="proj" class="form-control">
</select>
</div>
</div>
<div class="clearfix"></div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="initAmt">Initial Proposed Amount</label>
<input type="number" class="form-control" id="initAmt" name="initAmt" placeholder="Enter Initial Proposed Amount" required>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="currAmt">Current Proposed Amount</label>
<input type="number" class="form-control" id="currAmt" name="currAmt" placeholder="Enter Current Proposed Amount" required>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="noRegAmt">No Regret Amount</label>
<input type="number" class="form-control" id="noRegAmt" name="noRegAmt" placeholder="Enter No Regret Amount" required>
</div>
<div class="clearfix"></div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="startDate">Start Date</label>
<input type="text" data-provide="datepicker" data-date-orientation="right" data-date-format="yyyy-mm-dd" class="form-control datepicker" id="startDate" name="startDate" placeholder="Enter State Date (YYYY-MM-DD)" required>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="closureDate">Expected Closure Date</label>
<input type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" class="form-control datepicker" id="closureDate" name="closureDate" placeholder="Enter Expected Closure Date (YYYY-MM-DD)" required>
</div>
<div class="clearfix"></div>
<div class="col-xs-10 col-sm-4 col-md-4 col-lg-4">
<button class="btn btn-primary btn-md" type="submit">Add Opportunity</button>
</div>
</form>
</div>
<?php
require_once('bodyend.php');
?>