-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy patheditClient.php
More file actions
298 lines (284 loc) · 17.5 KB
/
Copy patheditClient.php
File metadata and controls
298 lines (284 loc) · 17.5 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?php
$title = 'Edit Client';
include('include/header.php');
date_default_timezone_set('Asia/Kolkata');
$date = date('ymdGis');
include_once 'LoaderManager.php';
$loaderManager = new LoaderManager();
$manageIdStatus = $loaderManager->manageIdStatus();
include_once 'ClientManager.php';
$clientManager = new ClientManager();
$result = $clientManager->listClients();
$clientIdType = $clientManager->getClientIdType();
if (isset($_GET['client_id'])) {
$client_id = trim(stripslashes($_GET['client_id']));
$clientDetails = $clientManager->getClientDetails($client_id);
$total = $clientManager->getClientProjects($client_id);
}
else {
header('Location:viewClients');
}
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>Edit Client</h1>
<?php include_once('include/notificationBell.php'); ?>
</section>
<!-- Main content -->
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-md-12">
<!-- general form elements -->
<div class="box box-primary">
<form role="form" id="createClientForm" method="POST" action="ClientController.php" enctype="multipart/form-data">
<div class="box-body">
<div class="row">
<?php
if(isset($_SESSION['ErrorMsg'])) {
?>
<div class="col-md-12 error-message">
<p class="alert alert-danger"><?php echo $_SESSION['ErrorMsg'];?><span style="color:#fff;" class="clear-error-msg close">×</span></p>
</div>
<?php
unset($_SESSION['ErrorMsg']);
}
?>
<p class="col-md-12"><label>Note: <span class="mandatory"> * </span></label> fields are mandatory.</p>
<div class="col-md-6">
<div class="form-group">
<label for="name">Name <span class="mandatory">*</span></label>
<input value="<?php echo $clientDetails['name']; ?>" class="form-control" id="name" placeholder="Enter Client Name" type="text" name="name" autocomplete="off" required autofocus>
</div>
<div class="form-group">
<label for="email">Email <span class="mandatory">*</span></label>
<input value="<?php echo $clientDetails['email']; ?>" name="email" class="form-control remove-space" id="email" placeholder="Enter Client Email Address" type="email" autocomplete="off" required>
</div>
<div class="form-group">
<label for="phone_no">Phone No. <span class="mandatory">*</span></label>
<input value="<?php echo $clientDetails['phone_no']; ?>" name="phone_no" class="form-control" id="phone_no" placeholder="Enter Client Phone Number" type="text" autocomplete="off" required>
</div>
<div class="form-group">
<label for="photo">Photo</label>
<span style="color:#0000FF">[ Please upload a passport size photo of only JPG, GIF, PNG format and maximum size of 500 kb. For better resolution use 160 x 160 px image. ]</span>
<input type="file" data-allowed-file-extensions="png jpg jpeg" name="photo" class="dropify" data-default-file="<?php echo 'uploads/client_image/'.$clientDetails['photo'];?>" data-height="100" style="height: 100% !important;">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="auto_generated_id">Client Id <span class="mandatory">*</span></label>
<?php if($manageIdStatus['client_id'] == 1) {?>
<input name="client_id" value="<?php echo $clientDetails['client_id']; ?>" class="form-control" id="auto_generated_id" placeholder="Enter Client Id" type="text" autocomplete="off" readonly="" required>
<?php } elseif($manageIdStatus['client_id'] == 2) {?>
<input value="<?php echo $clientDetails['client_id']; ?>" name="client_id" class="form-control" id="auto_generated_id" placeholder="Enter Client Id" type="text" autocomplete="off" required>
<?php } else {?>
<input name="client_id" class="form-control" id="auto_generated_id" placeholder="Choose type of client Id by clicking the link above" type="text" autocomplete="off" readonly="" required>
<?php } ?>
</div>
<div class="form-group">
<label for="currentAddress">Address <span class="mandatory">*</span></label>
<input value="<?php echo $clientDetails['address']; ?>" name="address" class="form-control" id="currentAddress" placeholder="Enter Client Address" type="text" autocomplete="off" required>
</div>
<div class="form-group">
<label for="country">Country <span class="mandatory">*</span></label>
<select id="country" name="country" class="bfh-countries form-control" data-country="<?php echo $clientDetails['country']; ?>" required>
</select>
</div>
<?php
$var_state = $clientDetails['state'];
//echo $var_state;
if(is_numeric($var_state)) {
$display = 'display:block;';
$disabled = '';
} else {
$display = 'display:none;';
$disabled = 'disabled="disabled"';
}
?>
<div id="hide_div_state" style="<?php echo $display; ?>">
<div class="form-group">
<label for="name">State <span class="mandatory">*</span></label>
<select id="state" class="form-control" name="state" required <?php echo $disabled;?>>
<?php for ($i=0; $i < $totalStates ; $i++) { ?>
<option value="<?php echo $adminManager->state_id[$i]; ?>" <?php if ($clientDetails['state']== $i+1) { echo "selected"; } ?>><?php echo $adminManager->state_name[$i]; ?> (<?php echo $adminManager->state_gst_code[$i]; ?>)</option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label for="name">GSTIN </label>
<input class="form-control" id="gstin" value="<?php echo $clientDetails['gstin']; ?>" placeholder="Enter Client GSTIN" type="text" name="gstin" autocomplete="off" <?php echo $disabled;?>>
</div>
</div>
<?php if(!is_numeric($var_state)) {
$display = 'display:block;';
$disabled = '';
} else {
$display = 'display:none;';
$disabled = 'disabled="disabled"';
}
?>
<div class="form-group" id="foreign_state_div" style="<?php echo $display; ?>">
<label for="name">State <span class="mandatory">*</span></label>
<input value="<?php echo $clientDetails['state'];?>" class="form-control" id="foreign_state" placeholder="Enter Client State" type="text" name="state" autocomplete="off" <?php echo $disabled;?>>
</div>
</div>
</div>
<?php
if($total > 0) {
for ($i=0; $i < $total ; $i++) { ?>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="projectTitle">Project Title <span class="mandatory">*</span></label>
<input value="<?php echo $clientManager->title[$i];?>" name="project_title[]" class="form-control project_title_input" id="projectTitle" placeholder="Enter Project Title" type="text" autocomplete="off" required>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="projectDescription">Project Description <span class="mandatory">*</span></label>
<textarea class="form-control project_description_textarea" name="project_description[]" placeholder="Write about project..." rows="5" required><?php echo $clientManager->description[$i];?></textarea>
</div>
</div>
</div>
<input type="hidden" name="project_id[]" value="<?php echo $clientManager->project_id[$i];?>">
<?php }
} else { ?>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="projectTitle">Project Title <span class="mandatory">*</span></label>
<input name="project_title_clone[]" class="form-control project_title_input" id="projectTitle" placeholder="Enter Project Title" type="text" autocomplete="off" required>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="projectDescription">Project Description <span class="mandatory">*</span></label>
<textarea class="form-control project_description_textarea" name="project_description_clone[]" placeholder="Write about project..." rows="5" required></textarea>
</div>
</div>
</div>
<?php } ?>
<div class="row clone-div">
</div>
<!-- /.box-body -->
</div>
<input type="hidden" name="oldPhoto" value="<?php echo $clientDetails['photo'];?>">
<div class="box-footer">
<a id="add-more" class="btn btn-success">Add More Projects</a>
<?php if($manageIdStatus['client_id'] == 2) {?>
<a id="manageId" class="btn btn-primary pull-right">Update</a>
<?php } else {?>
<input type="submit" class="btn btn-primary pull-right" value="Update" name="editClientDetails">
<?php }?>
</div>
</form>
</div>
<!-- /.box -->
</div>
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php include('include/footer.php');?>
<script type="text/javascript">
//toggle div state and GST
if($('#country').val() == 'India') {
$('#hide_div_state').css('display','block');
$('#foreign_state_div').css('display','none');
}
$('#country').change( function() {
if($(this).val() == 'India') {
$('#foreign_state_div').css('display','none');
$('#foreign_state').attr('disabled', 'disabled');
$('#state').removeAttr('disabled');
$('#gstin').removeAttr('disabled');
$('#hide_div_state').css('display','block');
} else {
$('#foreign_state_div').css('display','block');
$('#foreign_state').removeAttr('disabled');
$('#state').attr('disabled', 'disabled');
$('#gstin').attr('disabled', 'disabled');
$('#hide_div_state').css('display','none');
}
});
// add more projects
var div_id =1;
$('#add-more').click(function() {
$('.clone-div').append('<div data-id="'+div_id+'"><div class="col-md-12"><div class="form-group"><label for="projectTitle'+div_id+'">Project Title <span class="mandatory">*</span></label><input name="project_title_clone[]" class="form-control project_title_input" id="projectTitle'+div_id+'" placeholder="Enter Project Title" type="text" autocomplete="off" required></div></div><div class="col-md-12"><div class="form-group"><label for="projectDescription'+div_id+'">Project Description <span class="mandatory">*</span></label><textarea class="form-control project_description_textarea" id="projectDescription'+div_id+'" name="project_description_clone[]" placeholder="Write about project..." rows="5" required></textarea></div></div><div class="col-md-12"><a class="remove-clone-div btn btn-warning" onclick="removeCloneDiv('+div_id+');">Remove</a><br></div></div>');
div_id++;
});
function removeCloneDiv(div_id) {
$('[data-id=' + div_id + ']').remove();
}
// check dublicate entry for client Id
$('#auto_generated_id').keyup( function() {
var check_employee_id = $(this).val();
$.ajax({
url: "EmployeeController.php",
type: "post",
cache: false,
data: {"check_employee_id": check_employee_id},
success: function(result){
if(result==1) {
$('#auto_generated_id').val('');
$('#auto_generated_id').html('');
swal("Oops!!", "Employee Id already exists. Please try another one.", "error");
}
}
});
});
// fade error message div
$( ".clear-error-msg" ).click(function() {
$( ".error-message" ).fadeOut( "slow" );
});
// trim space
$('.remove-space').each(function() {
$(this).keyup(function() {
var field = $(this);
var str = $(this).val();
$(this).val($.trim(str))
});
});
// check dublicate entry
$('.check-dublicate').each(function() {
$(this).keyup(function() {
var field = $(this);
var str = $(this).val();
$(this).val($.trim(str));
var field_name = $(this).attr('name');
var check_already_exist_client = $(this).val();
var oldValue = '<?php echo $clientDetails['email'];?>';
if(oldValue != check_already_exist_client) {
$.ajax({
url: "ClientController.php",
type: "post",
cache: false,
data: {"check_already_exist_client": check_already_exist_client, "field_name": field_name},
success: function(result){
if(result==1) {
field.val('');
field.focus();
swal("oops", "Given "+field_name+" already exist.Please try another.", "error");
}
}
});
}
});
});
</script>
<?php
if(isset($_SESSION['employeeIdTypeSelected'])) {
?>
<script type="text/javascript">
swal('Congrats', 'Employee Id Type Choosen Successfully.', 'success');
</script>
<?php
unset($_SESSION['employeeIdTypeSelected']);
}
?>
</body>
</html>