· 6 years ago · Jan 30, 2020, 11:08 AM
1<?php
2if ($user_type == 'ADMIN'){
3 include ('admin/admin_customer_menu.php');
4 $customer_userid = $_GET["customer_id"];
5 $customer_detail = $CommonFunc->getCustomerDetailsByUserId($customer_userid);
6 $customer_loginid = $customer_detail->id;
7 $customer_usertype = $customer_detail->user_type;
8}else{
9 $customer_loginid = $_SESSION["login_id"];
10 $customer_userid = $_SESSION["user_id"];
11 $customer_usertype = $_SESSION["user_type"];
12}
13if (isset($_POST["UPDATE_PROFILE"])) {
14 $fname = $_POST["first_name"];
15 $lname = $_POST["last_name"];
16 $mobile = $_POST["mobile"];
17 $email = $_SESSION["email"];
18 // print_r($_POST);
19 $update_profile = $Opr->updateProfile($fname, $lname, $mobile, $email, $customer_userid,$customer_loginid, $customer_usertype);
20}elseif (isset($_POST['PHOTO_UPLOAD'])) {
21 $profile_pic = $_FILES["profile_pic"];
22 if(isset($profile_pic)){
23 $img = $profile_pic;
24 if(!empty($img)){
25 $val = $profile_pic;
26 $target_dir = "images/profile-picture/";
27 $ext = pathinfo($val["name"], PATHINFO_EXTENSION);
28 if(in_array($ext, array('jpeg','png','jpg','JPG'))){
29 $newname = $customer_usertype."-".$customer_userid.".".$ext;
30 $media_path = $target_dir.$newname;
31 $update_profile_pic = $CommonFunc->updateCustomerProfilePic($media_path, $customer_userid);
32 if ($update_profile_pic){
33 move_uploaded_file($val['tmp_name'], $media_path);
34 }
35 }else{
36 $display = $Opr->messageDisplay("","Wrong extension");
37 }
38 }
39 }
40}elseif (isset($_POST["CHANGE_PASSWORD"])) {
41 $current_pass = $_POST["current_pass"];
42 $new_pass = $_POST["new_pass"];
43 $confirm_new_pass = $_POST["confirm_new_pass"];
44 $change_password = $Opr->resetPassword($current_pass, $new_pass, $confirm_new_pass, $customer_loginid);
45}elseif (isset($_POST["ADD_ADDRESS"])) {
46 $street = $_POST["street"];
47 $state = $_POST["state"];
48 $suburb = $_POST["town"];
49 $postcode = $_POST["post_code"];
50 $active = 'Y';
51 $login_id = $customer_loginid;
52 $create_address = $Opr->createAddress($login_id, $state, $suburb, $street, $postcode, $active);
53}elseif (isset($_POST["PRIMARY_ADDRESS"])) {
54 $address_id = $_POST["address_id"];
55 $primary_address = $CommonFunc->updateDefaultCustomer($address_id, $customer_userid);
56}elseif (isset($_POST["DELETE_ADDRESS"])) {
57 $address_id = $_POST["address_id"];
58 $delete_address = $CommonFunc->updateAddressActiveTag($address_id, $customer_loginid);
59}?>
60
61<!--
62 <link rel="stylesheet" href="bower_components/select2/dist/css/select2.min.css">
63 <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDHiBM54E3qFB4M8IN8UGtdAefIRkD_nUU&libraries=places"></script>
64 <script>
65 function initialize() {
66 var input = document.getElementById('address');
67 var autocomplete = new google.maps.places.Autocomplete(input);
68 google.maps.event.addListener(autocomplete, 'place_changed', function () {
69 var place = autocomplete.getPlace();
70 document.getElementById('state').value = place.name;
71 document.getElementById('state').value = place.name;
72 });
73 }
74 google.maps.event.addDomListener(window, 'load', initialize);
75 </script> -->
76<div class="mt-20 mb-20 mr-30 ml-20">
77 <div class="row"><?php
78 $get_customer_detail = $CommonFunc->getCustomerDetailById($customer_userid);
79 if ($get_customer_detail){?>
80 <div class="col-md-6">
81 <div style="background: #fff; border-radius: 10px;" class="pl-20 pr-20">
82 <div class="row"><?php
83 if (isset($_POST["UPDATE_PROFILE"]) OR (isset($_POST["CHANGE_PASSWORD"]))) {
84 include("classes/statusMsg.php");
85 }?>
86 <div class="col-sm-6">
87 <h3 id="profileTitle">Personal Details</h3>
88 </div>
89 <div class="col-sm-6 pt-20">
90 <div class="pull-right">
91 <button id="passclosebtn" class="btn btn-flat btn-sm btn-danger" style="display: none;" onclick="showUpdateProfile()">Close</button>
92 <button id="passbtn" class="btn btn-flat btn-sm btn-warning" onclick="showChangePassword()">Change Password</button>
93 <button id="closebtn" class="btn btn-flat btn-sm btn-danger" style="display: none;" onclick="addReadOnly()">Close</button>
94 <button id="editbtn" class="btn btn-flat btn-sm btn-primary" onclick="removeReadOnly()">Edit</button>
95 <button id="closedp" class="btn btn-flat btn-sm btn-danger" style="display: none;" onclick="closePhotoUpload()">Close</button>
96 </div>
97 </div>
98 </div><hr>
99 <div class="row" id="editprofilepicture">
100 <div class="form-group col-md-12" id="profilepicture">
101 <center><img src="../<?php echo $get_customer_detail->profile_pic; ?>" class="img-responsive" width="150" height="150" style="border-radius: 50%; width: 150px; height: 150px; object-fit: cover;"><br>
102 <button id="uploadPhoto" class="btn btn-flat btn-xs btn-primary" onclick="uploadPhoto()">Upload Photo</button></center>
103 </div>
104 <form method="POST" class="clearfix" enctype="multipart/form-data">
105 <div class="form-group col-md-12" id="profilepic" style="display: none;">
106 <label for="profile_pic">Upload Your Profile Picture</label>
107 <input name="profile_pic" class="form-control" type="file">
108 </div>
109 <div class="form-group col-md-12 text-center">
110 <button id="updatePhoto" type="submit" class="btn btn-flat btn-dark btn-sm" name="PHOTO_UPLOAD" style="display: none;">Upload</button>
111 </div>
112 </form>
113 </div>
114 <form id="updateProfile" class="clearfix" method="POST">
115 <div class="row">
116 <div class="form-group col-md-6">
117 <label for="form_fname">First Name</label>
118 <input id="f_name" name="first_name" class="form-control" value="<?php echo $get_customer_detail->first_name; ?>" type="text" autofocus readonly required>
119 </div>
120 <div class="form-group col-md-6">
121 <label for="form_lname">Last Name</label>
122 <input id="l_name" name="last_name" class="form-control" value="<?php echo $get_customer_detail->last_name; ?>" type="text" readonly required>
123 </div>
124 </div>
125 <div class="row">
126 <div class="form-group col-md-12">
127 <label for="form_email">Email</label>
128 <input name="email" class="form-control" value="<?php echo $get_customer_detail->email; ?>" type="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" readonly required>
129 <p id="emailtext" style="font-size: 10px; display: none;">*Email ID cannot be changed</p>
130 </div>
131 <div class="form-group col-md-12">
132 <label for="form_mobile">Mobile Number</label>
133 <div class="input-group">
134 <div class="input-group-addon"><b>+61</b></div>
135 <input id="mobile" name="mobile" class="form-control" value="<?php echo $get_customer_detail->mobile; ?>" type="number" readonly required>
136 </div>
137 </div>
138 <div class="form-group col-md-12">
139 <button style="display: none;" type="submit" id="btnDisplay" class="btn btn-flat btn-dark btn-md pull-right" name="UPDATE_PROFILE">Submit</button>
140 </div>
141 </div>
142 </form>
143 <form id="changePassword" class="clearfix" method="POST" style="display: none;">
144 <div class="row">
145 <div class="form-group col-md-12">
146 <label>Current Password</label>
147 <input name="current_pass" class="form-control" type="password" placeholder="Enter Your Current Password" autofocus required>
148 </div>
149 <div class="form-group col-md-12">
150 <label>New Password</label>
151 <input name="new_pass" class="form-control" type="password" placeholder="Enter New Password" required>
152 </div>
153 <div class="form-group col-md-12">
154 <label>Confirm New Password</label>
155 <input name="confirm_new_pass" class="form-control" type="password" placeholder="Enter New Confirm Password" required>
156 </div>
157 <div class="form-group col-md-12 text-center">
158 <button type="submit" class="btn btn-flat btn-dark btn-md" name="CHANGE_PASSWORD">Submit</button>
159 </div>
160 </div>
161 </form>
162 </div>
163 </div><?php
164 }?>
165 <div class="col-md-6">
166 <div style="background: #fff; border-radius: 10px;" class="pl-20 pr-20 pb-20">
167 <div class="row"><?php
168 if (isset($_POST["ADD_ADDRESS"])) {
169 include("classes/statusMsg.php");
170 }?>
171 <div class="col-sm-12">
172 <h3>Addresses</h3>
173 </div>
174 </div><hr>
175 <div class="row">
176 <div class="col-md-6 mt-10">
177 <div style="border: 1px solid; border-color: #d3d3d3; border-radius: 10px;" class="pt-20 pb-10" data-toggle="modal" data-target="#addAddress">
178 <center>
179 <i class="fa fa-plus" style="font-size:60px; color: #d3d3d3;"></i>
180 <span ><h4 style="font-size: 120%">Add Address</h4></span>
181 </center>
182 </div>
183 </div><?php
184 $user_address = $CommonFunc->getAddressfromLoginId($customer_loginid, $customer_userid);
185 if ($user_address){
186 foreach ($user_address as $key => $address) {
187 if ($key <= 2) {?>
188 <div class="col-md-6 mt-10">
189 <div style="border: 1px solid; border-color: #d3d3d3; border-radius: 10px;" class="pl-20 pr-20 pt-20"><?php
190 if($address['address_id'] == $address['default_add']){?>
191 <p class="text-center" style="color: #008bcf;"><b>Primary Address</b></p><?php
192 }?>
193 <p><?php echo $address['street']; ?>,<br><span><?php echo $address['town_suburb']; ?> -</span><span> <?php echo $address['postcode']; ?>,</span><br><span><?php echo $address['state']; ?></span></p>
194 <form method="POST">
195 <div class="form-group text-center">
196 <input type="hidden" name="address_id" value="<?php echo $address['address_id']; ?>"><?php
197 if($address['address_id']!=$address['default_add']){?>
198 <button type="submit" name="PRIMARY_ADDRESS" class="btn btn-flat btn-sm btn-success"><i class="fa fa-check"></i></button>
199 <button type="submit" name="DELETE_ADDRESS" class="btn btn-flat btn-sm btn-danger"><i class="fa fa-trash"></i></button><?php
200 }?>
201 </div>
202 </form>
203 </div>
204 </div><?php
205 }else{?>
206 <div class="row">
207 <div class="col-md-12 mt-10 text-center">
208 <button class="btn btn-flat btn-sm btn-primary">View All Addresses</button>
209 </div>
210 </div><?php
211 }
212 }
213 }?>
214 </div>
215 </div>
216 </div>
217 </div>
218</div>
219
220<div class="modal fade" role="dialog" id="addAddress" aria-labelledby="Address">
221 <div class="modal-dialog modal-md">
222 <div class="modal-content pb-5 pl-20 pr-20">
223 <h3 style="color: #008bcf;">Add Address</h3><hr>
224 <form class="clearfix" method="POST" autocomplete="off">
225 <div class="row">
226 <div id="locationField" class="form-group col-md-12">
227 <input id="a_autocomplete" placeholder="Enter Your Location" onFocus="geolocate()" type="text" name="location" class="form-control">
228 </div>
229 <div class="form-group col-md-6">
230 <label>State</label>
231 <input id="a_state" placeholder="Enter Your State" type="text" name="state" class="form-control" required="">
232 </div>
233 <div class="form-group col-md-6">
234 <label>Town</label>
235 <input id="a_locality" placeholder="Enter Your Town" type="text" name="town" class="form-control" required="">
236 </div>
237 <div class="form-group col-md-6">
238 <label>Street</label>
239 <input id="a_street_number" placeholder="Enter Your Street" type="text" name="street" class="form-control" required="">
240 </div>
241 <div class="form-group col-md-6">
242 <label>Post Code</label>
243 <input id="a_postal_code" placeholder="Enter Your Post Code" type="number" name="post_code" class="form-control" required="">
244 </div>
245 <div class="form-group col-md-12 text-center">
246 <button type="submit" id="btnDisplay" class="btn btn-flat btn-dark btn-md" name="ADD_ADDRESS">Add Address</button>
247 </div>
248 </div>
249 </form>
250 </div>
251 </div>
252</div>
253
254<script>
255 function removeReadOnly(){
256 $('#profileTitle').text('Edit Profile Details');
257 $('#f_name').removeAttr('readonly');
258 $('#l_name').removeAttr('readonly');
259 $('#mobile').removeAttr('readonly');
260 $('#emailtext').show();
261 $('#btnDisplay').show();
262 $('#closebtn').show();
263 $('#passbtn').hide();
264 $('#editbtn').hide();
265 $('#changePassword').hide();
266 $('#profilepicture').hide();
267 }
268 function addReadOnly(){
269 $('#profileTitle').text('Personal Details');
270 $('#f_name').attr('readonly', '');
271 $('#l_name').attr('readonly', '');
272 $('#mobile').attr('readonly', '');
273 $('#emailtext').hide();
274 $('#btnDisplay').hide();
275 $('#editbtn').show();
276 $('#closebtn').hide();
277 $('#passbtn').show();
278 $('#profilepicture').show();
279 }
280 function showChangePassword(){
281 $('#profileTitle').text('Change Password');
282 $('#updateProfile').hide();
283 $('#changePassword').show();
284 $('#editbtn').hide();
285 $('#passbtn').hide();
286 $('#passclosebtn').show();
287 $('#editprofilepicture').hide();
288 }
289 function showUpdateProfile(){
290 $('#profileTitle').text('Personal Details');
291 $('#updateProfile').show();
292 $('#changePassword').hide();
293 $('#editbtn').show();
294 $('#passbtn').show();
295 $('#passclosebtn').hide();
296 $('#editprofilepicture').show();
297 }
298 function uploadPhoto(){
299 $('#profilepic').show();
300 $('#uploadPhoto').hide();
301 $('#updateProfile').hide();
302 $('#passbtn').hide();
303 $('#editbtn').hide();
304 $('#updatePhoto').show();
305 $('#profileTitle').text('Edit Profile Picture');
306 $('#closedp').show();
307 }
308 function closePhotoUpload(){
309 $('#profilepic').hide();
310 $('#updateProfile').show();
311 $('#uploadPhoto').show();
312 $('#profileTitle').text('Personal Details');
313 $('#closedp').hide();
314 $('#updatePhoto').hide();
315 $('#passbtn').show();
316 $('#editbtn').show();
317 }
318</script>
319<script>
320// This sample uses the Autocomplete widget to help the user select a
321// place, then it retrieves the address components associated with that
322// place, and then it populates the form fields with those details.
323// This sample requires the Places library. Include the libraries=places
324// parameter when you first load the API. For example:
325// <script
326// src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">
327
328var placeSearch, autocomplete;
329
330var componentForm = {
331 street_number: 'short_name',
332 route: 'long_name',
333 locality: 'long_name',
334 administrative_area_level_1: 'short_name',
335 country: 'long_name',
336 postal_code: 'short_name'
337};
338
339function initAutocomplete() {
340 // Create the autocomplete object, restricting the search predictions to
341 // geographical location types.
342 //autocomplete = new google.maps.places.Autocomplete(document.getElementById('autocomplete'), {types: ['geocode']});
343 autocomplete = new google.maps.places.Autocomplete(document.getElementById('a_autocomplete'));
344
345 // document.getElementById('autocomplete');
346
347 // Avoid paying for data that you don't need by restricting the set of
348 // place fields that are returned to just the address components.
349 autocomplete.setFields(['address_component']);
350
351 // When the user selects an address from the drop-down, populate the
352 // address fields in the form.
353 autocomplete.addListener('place_changed', fillInAddress);
354}
355
356function fillInAddress() {
357 // Get the place details from the autocomplete object.
358//alert('hello');
359
360var place = autocomplete.getPlace();
361
362 for (var i = 0; i < place.address_components.length; i++) {
363 var addressType = place.address_components[i].types[0];
364 if (addressType == "administrative_area_level_1") {
365 var administrative_area_level_1 = place.address_components[i]["long_name"];
366
367 }
368 if (addressType == "route") {
369 var route = place.address_components[i]["long_name"];
370
371 }
372 if (addressType == "street_number") {
373 var street_number = place.address_components[i]["long_name"];
374 // document.getElementById('street_number').value = val;
375 }
376 if (addressType == "postal_code") {
377 var postal_code = place.address_components[i]["long_name"];
378
379 }
380 if (addressType == "locality") {
381 var locality = place.address_components[i]["long_name"];
382
383 }
384 }
385 document.getElementById('a_state').value = administrative_area_level_1;
386 document.getElementById('a_street_number').value = street_number+', '+route;
387 document.getElementById('a_postal_code').value = postal_code;
388 document.getElementById('a_locality').value = locality;
389}
390
391// Bias the autocomplete object to the user's geographical location,
392// as supplied by the browser's 'navigator.geolocation' object.
393function geolocate() {
394 if (navigator.geolocation) {
395 navigator.geolocation.getCurrentPosition(function(position) {
396 var geolocation = {
397 lat: position.coords.latitude,
398 lng: position.coords.longitude
399 };
400 var circle = new google.maps.Circle(
401 {center: geolocation, radius: position.coords.accuracy});
402 autocomplete.setBounds(circle.getBounds());
403 });
404 }
405}
406</script>
407<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDHiBM54E3qFB4M8IN8UGtdAefIRkD_nUU&libraries=places&callback=initAutocomplete" async defer></script>