· 8 years ago · Sep 24, 2017, 12:46 PM
1<?php
2/* This is the model class for table "user". */
3//vnnovate file
4
5if (!defined('BASEPATH'))
6
7 exit('No direct script access allowed');
8
9
10class webservice_model extends CI_Model
11{
12
13 function __construct()
14 {
15
16 parent::__construct();
17 $data = array();
18 }
19
20
21 /* This function check individual user validate or not
22
23
24
25 * @params : N/A
26
27
28
29 * @return : return array of success or failure message */
30
31
32 // public function validateUser() {
33
34
35 // if ($this->input->get_post('email', TRUE) && $this->input->get_post('password', TRUE)) {
36
37
38 // if (!filter_var($this->input->get_post('email', TRUE), FILTER_VALIDATE_EMAIL) === false) {
39
40
41 // $email = $this->input->get_post('email', TRUE);
42
43
44 // $token = $this->input->get_post('token', TRUE);
45
46
47 // // $user_type = $this->input->get_post('user_type', TRUE);
48
49
50 // $password = base64_encode($this->input->get_post('password', TRUE));
51
52
53 // $row = $this->db->from('user')->where('email', $email)->where('password', $password)->get()->row();
54
55
56 // if (count($row) > 0) {
57
58
59 // $data = $this->getClientRecord($row, 'login');
60
61
62 // $data['status'] = "success";
63
64
65 // $data['message'] = "Login Successfull";
66
67 // //}
68
69 // } else {
70
71
72 // $data['status'] = "failure";
73
74
75 // $data['message'] = "Login Failed. The email or password you entered is incorrect";
76
77 // }
78
79 // } else {
80
81 // $data['status'] = "failure";
82
83 // $data['message'] = "Please enter valid email address";
84
85 // }
86
87 // } else {
88
89
90 // $data['status'] = "failure";
91
92
93 // $data['message'] = "Please enter email and password";
94
95 // }
96
97
98 // return $data;
99
100 // }
101
102 public function validateUser()
103 {
104
105 if ($this->input->get_post('email', TRUE) &&filter_var($this->input->get_post('email', TRUE), FILTER_VALIDATE_EMAIL) === true) {
106
107
108
109 $login_type = $this->input->get_post('login_type');
110 $fb_id = $this->input->get_post('fb_id');
111 $email = $this->input->get_post('email', TRUE);
112 $token = $this->input->get_post('token', TRUE);
113 $first_name = $this->input->get_post('first_name', TRUE);
114 $last_name = $this->input->get_post('last_name', TRUE);
115 $password = base64_encode($this->input->get_post('password', TRUE));
116
117 if (isset($_POST['password'])) {
118
119 $row = $this->db->from('user')->where('email', $email)->where('password', $password)->get()->row();
120 if (count($row) > 0) {
121 $data = $this->getClientRecord($row, $row->login_type, 'login');
122 $id = $row->id;
123 $this->db->where('id', $id);
124 $flag = $this->db->update('user', array('token' => $token));
125
126 if ($flag) {
127
128 $data['status'] = "success";
129
130 $data['message'] = "Login Successfull";
131 }
132 } else {
133
134 $data['status'] = "failure";
135 $data['message'] = "Login Failed. The email or password you entered is incorrect";
136 }
137 } else {
138
139 $image = $this->input->get_post('image', TRUE);
140 $path = FCPATH . "assets/profilepic/";
141 //$imageStr = str_replace('data:image/png;base64,', '', $file);
142 $imageStr = str_replace(' ', '+', $image);
143 $dataStr = base64_decode($imageStr);
144 $fileName = uniqid() . '.png';
145 $file = $path . $fileName;
146 $success = file_put_contents($file, $dataStr);
147
148 $rowArr = $this->db->get_where('user', array('email' => $this->input->get_post('email', TRUE)))->result();
149
150 if (count($rowArr) > 0) {
151
152 $data['status'] = "failure";
153
154 $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
155 } else {
156
157 $row = $this->db->from('user')->where('fb_id', $fb_id)->get()->row();
158 if (count($row) > 0) {
159 $data = $this->getClientRecord($row, $row->login_type, 'login');
160 $id = $row->id;
161 $this->db->where('id', $id);
162 $flag = $this->db->update('user', array('token' => $token));
163 if ($flag) {
164 $data['status'] = "success";
165 $data['message'] = "Login Successfull";
166 } else {
167 $data['status'] = "failure";
168 $data['message'] = "Login Failed. The email or password you entered is incorrect";
169 }
170 } else {
171 $fbArr = array(
172 'email' => $email,
173 'fb_id' => $fb_id,
174 'first_name' => $first_name,
175 'last_name' => $last_name,
176 'image' => $fileName,
177 'login_type' => 'fb'
178 );
179
180 $fbDataSave = $this->db->insert('user', $fbArr);
181 $row = $this->db->from('user')->where('fb_id', $fb_id)->get()->row();
182 if (count($row) > 0) {
183 $data = $this->getClientRecord($row, $row->login_type, 'login');
184 $id = $row->id;
185 $this->db->where('id', $id);
186 $flag = $this->db->update('user', array('token' => $token));
187 if ($flag) {
188 $data['status'] = "success";
189 $data['message'] = "Login Successfull";
190 } else {
191 $data['status'] = "failure";
192 $data['message'] = "Login Failed. The email or password you entered is incorrect";
193 }
194 } else {
195 $data['status'] = "failure";
196 $data['message'] = "data not found";
197 }
198 }
199 }
200 }
201
202 } else {
203 $data['status'] = "failure";
204 $data['message'] = "Please enter email and password";
205 }
206 return ($this->normaliseArray($data));
207 }
208
209
210 /**
211 * @param $row
212 * @param $login
213 * @param $login_type
214 * @return mixed
215 */
216 public function getClientRecord($row, $login, $login_type)
217 {
218
219 $data['status'] = "success";
220 if (!empty($login) && $login == 'signup') {
221
222 $data['message'] = "user successfully registered";
223
224 } else {
225
226 $data['message'] = "user successfully logged";
227
228 }
229 $data['userId'] = $row->id;
230
231 $data['login_type'] = $row->login_type;
232 $data['fb_id'] = $row->fb_id;
233
234 $data['first_name'] = $row->first_name;
235
236 $data['last_name'] = $row->last_name;
237
238 $data['email'] = $row->email;
239
240 $data['password'] = base64_decode($row->password);
241
242 $data['phone'] = $row->phone;
243
244 $data['state'] = $row->state;
245
246 $data['neighborhood'] = $row->neighborhood;
247
248 $data['school'] = $row->school;
249
250 $profile_pic = $row->image;
251 $pics = "http://" . $_SERVER['SERVER_NAME'] . "/girlfriend_app/assets/profilepic/" . $profile_pic;
252
253 $data['image'] = $pics;
254 //$data['trainer_email'] = $row->trainer_email;
255
256 return $data;
257
258 }
259
260
261 // public function UserProfile() {
262 // if ($this->input->get_post('email', TRUE)) {
263 // $rowArr = $this->db->get_where('user', array('email' => $this->input->get_post('email', TRUE)))->result();
264 // if (count($rowArr) > 0) {
265 // $data['status'] = "failure";
266 // $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
267 // } else {
268 // $first_name = "";
269
270 // $last_name = "";
271
272 // $email = "";
273
274 // $password = "";
275
276 // $phone = "";
277
278 // $state = "";
279
280 // $city = "";
281
282 // $neighborhood = "";
283
284 // $school = "";
285
286 // $image = "";
287
288 // if ($this->input->get_post('first_name', TRUE)) {
289
290 // $first_name = $this->input->get_post('first_name', TRUE);
291
292 // }
293
294 // if ($this->input->get_post('last_name', TRUE)) {
295
296 // $last_name = $this->input->get_post('last_name', TRUE);
297 // }
298
299 // if ($this->input->get_post('email', TRUE)) {
300
301 // $email = $this->input->get_post('email', TRUE);
302 // }
303
304 // if ($this->input->get_post('phone', TRUE)) {
305
306 // $phone = $this->input->get_post('phone', TRUE);
307 // }
308 // if ($this->input->get_post('state', TRUE)) {
309
310 // $state = $this->input->get_post('state', TRUE);
311 // }
312 // if ($this->input->get_post('city', TRUE)) {
313 // $city = $this->input->get_post('city', TRUE);
314 // }
315
316 // if ($this->input->get_post('neighborhood', TRUE)) {
317
318 // $neighborhood = $this->input->get_post('neighborhood', TRUE);
319 // }
320
321 // if ($this->input->get_post('school', TRUE)) {
322 // $school = $this->input->get_post('school', TRUE);
323
324 // }
325
326 // if ($this->input->get_post('image', TRUE)) {
327
328 // $image = $this->input->get_post('image', TRUE);
329
330 // $path = FCPATH . "assets/profilepic/";
331
332 // //$imageStr = str_replace('data:image/png;base64,', '', $file);
333
334 // $imageStr = str_replace(' ', '+', $image);
335
336 // $dataStr = base64_decode($imageStr);
337
338 // $fileName = uniqid() . '.png';
339
340 // $file = $path . $fileName;
341
342 // $success = file_put_contents($file, $dataStr);
343
344 // }
345
346 // $password = base64_encode($this->input->get_post('password', TRUE));
347
348 // $insArr = array(
349
350 // 'first_name' => $first_name,
351
352 // 'last_name' => $last_name,
353
354 // 'email' => $email,
355
356 // 'password' => $password,
357
358 // 'phone' => $phone,
359
360 // 'state' => $state,
361
362 // 'city' => $city,
363
364 // 'school' =>$school,
365
366 // 'image' => $fileName,
367
368 // 'neighborhood' => $neighborhood
369
370 // );
371
372 // $flag = $this->db->insert('user', $insArr);
373
374
375 // if ($flag) {
376
377
378 // //$rows = $this->db->from('user')->where('id', $this->db->insert_id())->get()->row();
379
380
381 // //$data = $this->getTrainerRecord($rows, 'signup');
382
383 // $data['status'] = "success";
384
385 // $data['message'] = "register successfully.";
386
387 // $data['result'] = $insArr;
388
389
390 // } else {
391
392
393 // $data['status'] = "failure";
394
395
396 // $data['message'] = "Trainer does not register";
397
398 // }
399
400 // }
401
402 // } else {
403
404
405 // $data['status'] = "failure";
406
407
408 // $data['message'] = "Please enter email address";
409
410 // }
411
412 // return $data;
413
414 // }
415
416
417 public function UserProfile()
418 {
419
420 if ($this->input->get_post('user_id', TRUE)) {
421
422 $user_id = $this->input->get_post('user_id', TRUE);
423
424
425 if ($this->input->get_post('first_name', TRUE)) {
426
427 $first_name = $this->input->get_post('first_name', TRUE);
428 }
429
430 if ($this->input->get_post('last_name', TRUE)) {
431
432 $last_name = $this->input->get_post('last_name', TRUE);
433 }
434
435 if ($this->input->get_post('state', TRUE)) {
436
437 $state = $this->input->get_post('state', TRUE);
438 }
439
440 if ($this->input->get_post('city', TRUE)) {
441
442 $city = $this->input->get_post('city', TRUE);
443 }
444 if ($this->input->get_post('neighborhood', TRUE)) {
445
446 $neighborhood = $this->input->get_post('neighborhood', TRUE);
447 }
448 if ($this->input->get_post('school', TRUE)) {
449
450 $school = $this->input->get_post('school', TRUE);
451 }
452 if ($this->input->get_post('image', TRUE)) {
453
454 $image = $this->input->get_post('image', TRUE);
455
456 $path = FCPATH . "assets/profilepic/";
457
458 //$imageStr = str_replace('data:image/png;base64,', '', $file);
459
460 $imageStr = str_replace(' ', '+', $image);
461
462 $dataStr = base64_decode($imageStr);
463
464 $fileName = uniqid() . '.png';
465
466 $file = $path . $fileName;
467
468 $success = file_put_contents($file, $dataStr);
469 }
470
471 $password = base64_encode($this->input->get_post('password', TRUE));
472
473
474 $insArr = array(
475 'id' => $user_id,
476 'first_name' => $first_name,
477 'last_name' => $last_name,
478 'state' => $state,
479 'city' => $city,
480 'school' => $school,
481 'image' => $fileName,
482 'neighborhood' => $neighborhood
483
484 );
485
486 $this->db->where('id', $user_id);
487
488 if ($this->db->update('user', $insArr)) {
489
490 $data['status'] = "success";
491 $data['message'] = "user details update successfully .";
492 $data['result'] = $insArr;
493 } else {
494
495 $data['status'] = "failure";
496
497 $data['message'] = "Trainer does not register";
498 }
499
500 } else {
501 $data['status'] = "failure";
502 $data['message'] = "Please enter user id";
503 }
504
505 return $data;
506 }
507
508
509
510
511 // public function UserRegister()
512 // {
513
514 // $email = $this->input->get_post('email', TRUE);
515
516 // if ($email == "") {
517
518 // $data['status'] = "failure";
519
520 // $data['message'] = "enter email adrress";
521
522 // }
523
524 // $password = $this->input->get_post('password', TRUE);
525
526 // if ($password == "") {
527
528 // $data['status'] = "failure";
529
530 // $data['message'] = "enter password";
531
532 // }
533
534 // return $data;
535
536 // }
537
538
539 public function UserRegister()
540 {
541 if ($this->input->get_post('email', TRUE)) {
542
543 $rowArr = $this->db->get_where('user', array('email' => $this->input->get_post('email', TRUE)))->result();
544
545 if (count($rowArr) > 0) {
546
547 $data['status'] = "failure";
548
549 $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
550 } else {
551 $email = "";
552 $password = "";
553 $email = $this->input->get_post('email', TRUE);
554
555 $rowArr = $this->db->get_where('friend_invites', array('to_email' => $this->input->get_post('email', TRUE)))->result();
556
557
558 if ($this->input->get_post('email', TRUE)) {
559
560 $email = $this->input->get_post('email', TRUE);
561 }
562
563 if ($this->input->get_post('password', TRUE)) {
564
565 $password = $this->input->get_post('password', TRUE);
566 }
567
568 $password = base64_encode($this->input->get_post('password', TRUE));
569
570
571 $insArr = array(
572
573 'email' => $email,
574 'password' => $password,
575 'created_date' => date('Y-m-d H:i:s')
576 );
577
578
579 $str_arr = $this->db->insert('user', $insArr);
580 $insert_id = $this->db->insert_id();
581 $user_id = (string)$insert_id;
582 $insArr['user_id'] = $user_id;
583
584
585 foreach ($rowArr as $key => $value) {
586
587 $from_user_id = $value->from_id;
588 $from_email = $value->from_email;
589 $to_email = $value->to_email;
590
591
592 $friend_data_insert = array(
593 'user_id' => $from_user_id,
594 'friend_id' => $insert_id,
595 'email' => $email,
596 'status' => '1',
597 'created_date' => date('Y-m-d H:i:s')
598 );
599 $this->db->insert('friends', $friend_data_insert);
600
601
602 $friend_data = array(
603 'user_id' => $insert_id,
604 'friend_id' => $from_user_id,
605 'email' => $from_email,
606 'status' => '1',
607 'created_date' => date('Y-m-d H:i:s')
608 );
609
610 $this->db->insert('friends', $friend_data);
611
612 $payment_data = array(
613 'user_id' => $insert_id,
614 'friend_id' => $from_user_id,
615 'payment_status' => '0',
616 'created_date' => date('Y-m-d H:i:s')
617 );
618 $this->db->insert('payment', $payment_data);
619
620 }
621 $rowArr = $this->db->get_where('friend_invites', array('to_email' => $this->input->get_post('email', TRUE)))->row();
622 if (count($rowArr) > 0) {
623 $id = $rowArr->id;
624 $email = $rowArr->email;
625 $this->db->where('id', $id);
626 $this->db->delete('friend_invites');
627 }
628
629 if ($str_arr) {
630
631 $data['status'] = "success";
632 $data['message'] = "user register successfully";
633 $data['result'] = $insArr;
634
635 } else {
636
637 $data['status'] = "failure";
638 $data['message'] = "user not register";
639 }
640 }
641 } else {
642 $data['status'] = "failure";
643 $data['message'] = "Please enter email address";
644 }
645 return $data;
646 }
647
648
649
650
651
652 // public function registerUserProfilechange() {
653
654 // if ($this->input->get_post('user_id', TRUE)) {
655
656 // $user_id = $this->input->get_post('user_id', TRUE);
657
658 // $image = "";
659
660 // if ($_FILES['image']['name']) {
661
662 // $image = $_FILES['image']['name'];
663
664 // $this->config = array(
665
666 // 'upload_path' => './assets/profilepic/',
667
668 // 'allowed_types' => 'jpg|jpeg|png|gif',
669
670 // 'file_name' => $_FILES['image']['name']
671
672 // );
673
674
675 // $this->load->library('upload', $this->config);
676
677 // if ($this->upload->do_upload('image')) {
678
679 // $value = array('image' => $image);
680
681 // $this->db->where('id', $user_id);
682
683 // if ($this->db->update('user', $value)) {
684
685 // $data['status'] = "success";
686
687 // $data['message'] = "User Profile Upload successfully";
688
689 // } else {
690
691 // $data['status'] = "failure";
692 // $data['message'] = "User does not register";
693 // }
694
695 // } else {
696 // $data['error'] = array('error' => $this->upload->display_errors());
697 // }
698
699 // }
700
701 // } else {
702
703 // $data['status'] = "failure";
704 // $data['message'] = "Please enter user id";
705 // }
706 // return $data;
707 // }
708
709
710 public function registerUserProfilechange()
711 {
712
713 if ($this->input->get_post('user_id', TRUE)) {
714
715 $user_id = $this->input->get_post('user_id', TRUE);
716
717
718 if ($this->input->get_post('first_name', TRUE)) {
719
720 $first_name = $this->input->get_post('first_name', TRUE);
721 }
722
723 if ($this->input->get_post('last_name', TRUE)) {
724
725 $last_name = $this->input->get_post('last_name', TRUE);
726 }
727
728 if ($this->input->get_post('state', TRUE)) {
729
730 $state = $this->input->get_post('state', TRUE);
731 }
732
733 if ($this->input->get_post('city', TRUE)) {
734
735 $city = $this->input->get_post('city', TRUE);
736 }
737 if ($this->input->get_post('neighborhood', TRUE)) {
738
739 $neighborhood = $this->input->get_post('neighborhood', TRUE);
740 }
741 if ($this->input->get_post('school', TRUE)) {
742
743 $school = $this->input->get_post('school', TRUE);
744 }
745 if ($this->input->get_post('image', TRUE)) {
746
747 $image = $this->input->get_post('image', TRUE);
748
749 $path = FCPATH . "assets/profilepic/";
750
751 //$imageStr = str_replace('data:image/png;base64,', '', $file);
752
753 $imageStr = str_replace(' ', '+', $image);
754
755 $dataStr = base64_decode($imageStr);
756
757 $fileName = uniqid() . '.png';
758
759 $file = $path . $fileName;
760
761 $success = file_put_contents($file, $dataStr);
762 }
763
764 $password = base64_encode($this->input->get_post('password', TRUE));
765
766
767 // $image = $_FILES['image']['name'];
768 // $this->config = array(
769 // 'upload_path' => './assets/profilepic/',
770 // 'allowed_types' => 'jpg|jpeg|png|gif',
771 // 'file_name' => $_FILES['image']['name']
772 // );
773
774
775 // $pics = $this->load->library('upload', $this->config);
776
777 // if($this->upload->do_upload('image'))
778 // {
779 // $value = $image;
780 // }
781 // else {
782
783 // $data['error'] = array('error' => $this->upload->display_errors());
784 // }
785
786
787 $insArr = array(
788 'first_name' => $first_name,
789 'last_name' => $last_name,
790 'state' => $state,
791 'city' => $city,
792 'school' => $school,
793 'image' => $fileName,
794 'neighborhood' => $neighborhood
795 );
796
797 $this->db->where('id', $user_id);
798
799 if ($this->db->update('user', $insArr)) {
800
801 $data['status'] = "success";
802 $data['message'] = "user details update successfully .";
803 $data['result'] = $insArr;
804 } else {
805
806 $data['status'] = "failure";
807
808 $data['message'] = "Trainer does not register";
809 }
810
811 } else {
812 $data['status'] = "failure";
813 $data['message'] = "Please enter user id";
814 }
815
816 return $data;
817 }
818
819
820 public function add_event()
821 {
822 $current_date = date('M d Y');
823
824 $time = date('h:i A');
825 // echo $time;die;
826 // echo $time;die;
827 // $c1 = date('M d Y h:i:s a',strtotime($current_date));
828 //echo $c1;die;
829 //get the previes date into current date.
830 //$d = date('M d Y', strtotime('-1 day', strtotime($current_date)));
831
832
833 $user_id = $this->input->get_post('user_id', TRUE);
834 $event_title = $this->input->get_post('event_title', TRUE);
835 $event_location = $this->input->get_post('event_location', TRUE);
836 $event_date = $this->input->get_post('event_date', TRUE);
837 $event_time = $this->input->get_post('event_time', TRUE);
838
839 $a1 = $event_date . " " . $event_time;
840 $c1 = date('Y-m-d h:i A', strtotime($a1));
841 $this->db->where('event.event_date_time <', $c1);
842 $this->db->delete('event');
843
844
845 if ($user_id == "") {
846 $data['status'] = "failure";
847 $data['message'] = "enter user id";
848 }
849 if ($event_title == "") {
850 $data['status'] = "failure";
851 $data['message'] = "enter event title";
852 }
853 if ($event_location == "") {
854 $data['status'] = "failure";
855 $data['message'] = "enter event location";
856 }
857 if ($event_date == "") {
858 $data['status'] = "failure";
859 $data['message'] = "enter event date";
860 }
861 if ($event_time == "") {
862 $data['status'] = "failure";
863 $data['message'] = "enter event time";
864 } else {
865
866 $insert_array = array(
867 'user_id' => $user_id,
868 'event_title' => $event_title,
869 'event_location' => $event_location,
870 'event_date' => $event_date,
871 'event_time' => $event_time,
872 'event_date_time' => $c1,
873 'created_date' => date('Y-m-d H:i:s')
874 );
875
876 $event = $this->db->insert('event', $insert_array);
877 if ($event) {
878 $data['status'] = "success";
879 $data['message'] = "event create successfully";
880 $data['result'] = $insert_array;
881 } else {
882 $data['status'] = "failure";
883 $data['message'] = "try again";
884 }
885 }
886 return $data;
887
888 }
889
890 public function event_update()
891 {
892
893 $id = $this->input->get_post('id', TRUE);
894 $event_title = $this->input->get_post('event_title', TRUE);
895 $event_location = $this->input->get_post('event_location', TRUE);
896 $event_date = $this->input->get_post('event_date', TRUE);
897 $event_time = $this->input->get_post('event_time', TRUE);
898
899 if ($user_id == "") {
900 $data['status'] = "failure";
901 $data['message'] = "enter user id";
902 }
903 if ($event_title == "") {
904 $data['status'] = "failure";
905 $data['message'] = "enter event title";
906 }
907 if ($event_location == "") {
908 $data['status'] = "failure";
909 $data['message'] = "enter event location";
910 }
911 if ($event_date == "") {
912 $data['status'] = "failure";
913 $data['message'] = "enter event date";
914 }
915 if ($event_time == "") {
916 $data['status'] = "failure";
917 $data['message'] = "enter event time";
918 } else {
919
920 $insert_array = array(
921 // 'user_id' => $user_id,
922 'event_title' => $event_title,
923 'event_location' => $event_location,
924 'event_date' => $event_date,
925 'event_time' => $event_time,
926 'created_date' => date('Y-m-d H:i:s')
927 );
928 $this->db->where('id', $id);
929 $event = $this->db->update('event', $insert_array);
930 if ($event) {
931 $data['status'] = "success";
932 $data['message'] = "event update successfully";
933 $data['result'] = $insert_array;
934 } else {
935 $data['status'] = "failure";
936 $data['message'] = "event not updated";
937 }
938 }
939 return $data;
940 }
941
942
943 public function event_notification()
944 {
945 $user_id = $this->input->get_post('user_id', TRUE);
946 $current_date = date('M d Y');
947 $checkId = $this->db->get_where('event', array('user_id' => $user_id))->result();
948
949 if (count($checkId) > 0) {
950 $this->db->select('event.event_title,event.event_date,user.token,user.id,event.event_title');
951 $this->db->from('event');
952 $this->db->join('user', 'event.user_id = user.id', 'left');
953 $this->db->where('event.user_id', $user_id);
954 $this->db->where('event.event_date', $current_date);
955 $query = $this->db->get();
956 $result = $query->result();
957
958
959 foreach ($result as $value) {
960 $event_date = $value->event_date;
961 $token = $value->token;
962 $message = $value->event_title;
963 //$current_data = date('M-d-Y');
964 $id = $value->id;
965
966 if ($event_date == $current_date) {
967
968 $this->iosPushNotificationtoUser($token, $message, $id);
969
970 $eventArr = array(
971 'user_id' => $user_id,
972 'notification' => $message,
973 'created_date' => date('Y-m-d H:i:s')
974 );
975 $eventSave = $this->db->insert('log', $eventArr);
976 if ($eventSave) {
977 $data['status'] = "success";
978 $data['message'] = "notification save";
979 $data['result'] = $eventArr;
980 } else {
981 $data['status'] = "failure";
982 $data['message'] = "data not dave";
983 }
984 } else {
985 $data['status'] = "failure";
986 $data['message'] = "notification fail";
987 }
988 }
989 } else {
990 $data['status'] = "failure";
991 $data['message'] = "user id not found";
992 }
993 return $data;
994 }
995
996 public function notification_list()
997 {
998 $user_id = $this->input->get_post('user_id', TRUE);
999
1000 $this->db->select('log.user_id,user.first_name,user.last_name,user.image,log.notification,log.created_date');
1001 $this->db->from('log');
1002 $this->db->join('user', 'log.user_id = user.id');
1003 $this->db->where('log.user_id', $user_id);
1004 $query = $this->db->get();
1005 $result = $query->result_array();
1006 if (count($result) > 0) {
1007 $i = 0;
1008 foreach ($result as $value) {
1009 $pics = $value['image'];
1010 if ($pics == "") {
1011 $pics = 'download.png';
1012 $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
1013 $img = $result[$i]['image'];
1014 $i++;
1015 $result->image = $img;
1016 } else {
1017 $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
1018 $pics = $result[$i]['image'];
1019 $i++;
1020 $result->image = $pics;
1021 }
1022 $data['status'] = "success";
1023 $data['message'] = "get notification list";
1024 $data['result'] = $result;
1025 }
1026
1027 } else {
1028 $data['status'] = "failure";
1029 $data['message'] = "data not found";
1030 }
1031 return $data;
1032 }
1033
1034 public function event_list()
1035 {
1036
1037 $current_date = date('M d Y');
1038 $user_id = $this->input->get_post('user_id', TRUE);
1039 $this->db->select('event.id,event.user_id,event.event_title,event.event_title,event.event_location,event.event_date,event.event_time,event.event_date_time,event.event_timer');
1040 $this->db->from('event');
1041 $this->db->where('event.user_id', $user_id);
1042 $this->db->order_by('event.event_date', 'ASC');
1043 $query = $this->db->get();
1044 $result = $query->result_array();
1045
1046
1047 if (count($result) > 0) {
1048 $i = 0;
1049 foreach ($result as $key => $row) {
1050 $datetime1 = new DateTime();
1051 $event_timer = $row['event_timer'];
1052 $event_date = $row['event_date'];
1053 $get_date = $row['event_date'];
1054 $time = date("H:i", strtotime($row['event_time']));
1055 $event_date1 = date('Y-m-d', strtotime($get_date));
1056
1057 $month = strtotime($get_date);
1058 $get_month = date("M", $month);
1059 $get_day = date("d", $month);
1060 $new_date_time = $event_date1 . " " . $time;
1061 $datetime2 = new DateTime($new_date_time);
1062 $interval = $datetime1->diff($datetime2);
1063 echo $interval->format('%Y-%m-%d %H:%i:%s');
1064
1065 $result[$i]['month'] = $get_month;
1066 $result[$i]['day'] = $get_day;
1067 $result[$i]['event_date'] = $event_date;
1068 $result[$i]['date_time'] = $event_date1 . " " . $time;
1069 $result[$i]['new_date_time'] = $datetime2;
1070 $i++;
1071
1072 }
1073 $event_date_time = date('Y-m-d h:i A');
1074 $this->db->where('event.event_date_time <', $event_date_time);
1075 $this->db->delete('event');
1076
1077 // }
1078
1079 $data['status'] = "success";
1080 $data['message'] = "event list";
1081 $data['result'] = $result;
1082
1083 } else {
1084
1085 $data['status'] = "failure";
1086 $data['message'] = "try again";
1087 }
1088
1089 return $data;
1090 }
1091
1092
1093 // public function change_password(){
1094
1095 // //$new_password = $this->input->get_post('new_password', TRUE);
1096 // $confirm_password = $this->input->get_post('new_password', TRUE);
1097 // $id = $this->input->get_post('user_id', TRUE);
1098
1099 // if($new_password){
1100 // $data['status'] = "failure";
1101 // $data['mesage'] = "enter password";
1102 // }if($confirm_password){
1103 // $data['status'] = "failure";
1104 // $data['mesage'] = "enter password";
1105 // }else{
1106
1107 // $confirm_password = base64_encode($this->input->get_post('password', TRUE));
1108 // $updatArr = array(
1109 // 'password' => $confirm_password,
1110 // 'created_date' => date('Y-m-d H:i:s')
1111 // );
1112 // $abc = $this->db->where('id',$id);
1113 // $Arr_update = $this->db->update('user',$updatArr);
1114
1115 // $data['status'] = "success";
1116 // $data['message']= "change password";
1117 // $data['result'] = $updatArr;
1118 // }
1119 // return $data;
1120 // }
1121
1122
1123 public function change_password()
1124 {
1125
1126 $password = $this->input->get_post('password', TRUE);
1127 $old_password = base64_encode($this->input->get_post('old_password', TRUE));
1128 $user_id = $this->input->get_post('user_id', TRUE);
1129
1130 if ($new_password) {
1131 $data['status'] = "failure";
1132 $data['mesage'] = "enter password";
1133 }
1134 if ($confirm_password) {
1135 $data['status'] = "failure";
1136 $data['mesage'] = "enter password";
1137 } else {
1138
1139 $pass_get = $this->db->get_where('user', array('id' => $user_id))->result();
1140
1141 if (count($pass_get) > 0) {
1142 foreach ($pass_get as $password) {
1143 $get_old_password = $password->password;
1144
1145 if ($old_password == $get_old_password) {
1146
1147 $password = base64_encode($this->input->get_post('password', TRUE));
1148
1149 $updatArr = array(
1150 'password' => $password,
1151 'created_date' => date('Y-m-d H:i:s')
1152 );
1153
1154 $abc = $this->db->where('id', $user_id);
1155 $Arr_update = $this->db->update('user', $updatArr);
1156
1157 $data['status'] = "success";
1158 $data['message'] = "password change successfully";
1159 $data['result'] = $updatArr;
1160
1161 } else {
1162 $data['status'] = "failure";
1163 $data['message'] = "old password is wrong";
1164 }
1165 }
1166 }
1167 // $password = base64_encode($this->input->get_post('password', TRUE));
1168 // $updatArr = array(
1169 // 'password' => $password,
1170 // 'created_date' => date('Y-m-d H:i:s')
1171 // );
1172
1173 // $abc = $this->db->where('id',$user_id);
1174 // $Arr_update = $this->db->update('user',$updatArr);
1175
1176 // $data['status'] = "success";
1177 // $data['message']= "password change successfully";
1178 // $data['result'] = $updatArr;
1179 }
1180 return $data;
1181 }
1182
1183
1184 public function add_friends()
1185 {
1186 if (count($_POST) > 0) {
1187 if (!empty($_POST['email'])) {
1188 // $checkEmailId = $this->db->get_where('user',array('email' => $this->input->get_post('email',TRUE)))->result();
1189 // if(count($checkEmailId) > 0){
1190 // $data['status'] = "failure";
1191 // $data['message'] = "email address is not register";
1192 // }
1193 //else{
1194
1195 $msg = $this->sendFriendRequestEmail($_POST);
1196
1197 if ($msg['resp'] == 'success') {
1198
1199 $data['status'] = "success";
1200
1201 $data['message'] = $msg['msg'];
1202 } else {
1203
1204 $data['status'] = "failure";
1205
1206 $data['message'] = $msg['msg'];
1207 }
1208 //}
1209 } else {
1210
1211 $data['status'] = "failure";
1212 $data['message'] = "Please enter valid email address";
1213 }
1214 } else {
1215
1216 $data['status'] = "failure";
1217 $data['message'] = "Please enter email address";
1218 }
1219
1220 return $data;
1221
1222 }
1223
1224 public function friend_list()
1225 {
1226 $user_id = $this->input->get_post('user_id', TRUE);
1227 $this->db->select('friends.user_id,friends.friend_id,friends.email,friends.status,user.first_name,user.last_name,user.image');
1228 $this->db->from('friends');
1229 $this->db->join('user', 'friends.email = user.email');
1230 $this->db->where('status', 1);
1231 $this->db->where('friends.user_id', $user_id);
1232 // $this->db->where('friends.user_id = user.id');
1233 $query = $this->db->get();
1234 $result = $query->result_array();
1235
1236 // $checkId = $this->db->get_where('user',array('id' => $user_id))->row();
1237 // $user_email = $checkId->email;
1238
1239 if (count($result) > 0) {
1240 $i = 0;
1241 foreach ($result as $image) {
1242 //print_r($image);exit;
1243 $friend_user_id = $image['id'];
1244 $friend_email = $image['email'];
1245 $pics = $image['image'];
1246 if ($pics == "") {
1247 $pics = 'download.png';
1248 $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
1249 $img = $result[$i]['image'];
1250 $i++;
1251 $result->image = $img;
1252 } else {
1253 $pics = $image['image'];
1254 $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
1255 $img = $result[$i]['image'];
1256 $i++;
1257 $result->image = $img;
1258 //}
1259 }
1260 if ($email > 0) {
1261 $update_array = array(
1262 'status' => 1,
1263 'created_date' => date('Y-m-d H:i:s')
1264 );
1265 $this->db->where('id', $get_id);
1266 $update_Arr = $this->db->update('friends', $update_array);
1267 }
1268 }
1269
1270 // $checkData = $this->db->get_where('friends',array('user_id' => $friend_user_id,'friend_id' => $friends_id))->result();
1271
1272 // if(count($checkData) > 0){
1273 // }else{
1274 // $dataSave = array(
1275 // 'user_id' => $friend_user_id,
1276 // 'email' => $user_email,
1277 // 'friend_id' => $friends_id,
1278 // 'created_date' => date('Y-m-d H:i:s')
1279 // );
1280 // $insertArr = $this->db->insert('friends',$dataSave);
1281
1282 // }
1283
1284 $data['status'] = "success";
1285 $data['message'] = "friends list";
1286 $data['result'] = $result;
1287 } else {
1288 $data['status'] = "failure";
1289 $data['message'] = "data not found";
1290 }
1291 return $data;
1292 }
1293
1294 public function friends_list_details()
1295 {
1296 $this->db->select('user.id,user.email');
1297 $this->db->from('user');
1298 $this->db->order_by('id', 'desc');
1299 $this->db->limit(1);
1300 $query = $this->db->get();
1301 $result = $query->row();
1302 $last_id = $result->id;
1303 $id = $this->input->get_post('id', TRUE);
1304 $this->db->select('user.id,user.first_name,user.image');
1305 $this->db->from('user');
1306 $this->db->join('friends', 'user.email = friends.email');
1307 //$this->db->join('fill_question_answer','user.id = fill_question_answer.user_id');
1308 $this->db->where('user.id', $id);
1309 $query = $this->db->get();
1310 $row = $query->row();
1311
1312 if (count($row) > 0) {
1313 $pics1 = $row->image;
1314 if ($pics1 == "") {
1315 $row->image = base_url() . "assets/profilepic/download.png";
1316 } else {
1317 $profile = $row->image;
1318 $path2 = base_url() . "assets/profilepic/" . $profile;
1319 $row->image = $path2;
1320 }
1321 $data['status'] = "success";
1322 $data['message'] = "friends details";
1323 $data['result'] = $row;
1324
1325 }
1326
1327 $this->db->select('user.id,fill_question_answer.QuestionName,fill_question_answer.answer,fill_question_answer.Other');
1328 $this->db->from('fill_question_answer');
1329 $this->db->join('user', 'fill_question_answer.user_id = user.id');
1330 $this->db->where('user.id', $id);
1331 $query = $this->db->get();
1332 $result = $query->result();
1333
1334 if (count($row) > 0) {
1335 // $pics = $row->image;
1336 // $path = base_url()."assert/profilepic/".$pics;
1337 // $row->image = $path;
1338 $data['status'] = "success";
1339 $data['message'] = "friend details";
1340 // $data['result'] = $row;
1341 $data['question_answer'] = $result;
1342 } else {
1343 $data['status'] = "failure";
1344 $data['message'] = "data not found";
1345 }
1346
1347 return $data;
1348
1349 }
1350
1351 public function all_question_qnswer()
1352 {
1353
1354 $this->db->select('question_answer.question_id,question_answer.answer_id,question_answer.answer');
1355 $this->db->from('question_answer');
1356 $query = $this->db->get();
1357 $result = $query->result();
1358
1359 $data['status'] = "success";
1360 $data['message'] = "all question answer";
1361 $data['result'] = $result;
1362
1363 return $data;
1364 }
1365
1366
1367 /*public function fill_question_answer()
1368 {
1369 $user_id = $this->input->get_post('user_id',TRUE);
1370 $questions = $this->input->get_post('questions',TRUE);
1371
1372 $questionArr = json_decode($questions,TRUE);
1373
1374
1375
1376 foreach ($questionArr as $key1 => $value1) {
1377
1378 $QuestionId = $value1['QuestionId'];
1379 $AnswerId = $value1['AnswerId'];
1380 $Other = $value1['Other'];
1381 $Gifted = $value1['Gifted'];
1382 $FriendId = $value1['FriendId'];
1383 $QuestionName = $value1['QuestionName'];
1384 $answer = $value1['answer'];
1385
1386 $queAnsArr = array(
1387 'user_id' => $user_id,
1388 'QuestionId' => $QuestionId,
1389 'AnswerId' => $AnswerId,
1390 'Other' => $Other,
1391 'FriendId' => $FriendId,
1392 'Gifted' => $Gifted,
1393 'QuestionName'=> $QuestionName,
1394 'answer' => $answer,
1395 'created_date' => date('Y-m-d H:i:s')
1396 );
1397
1398 $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
1399 }
1400
1401 $data['status'] = "success";
1402 $data['message'] = "save all question answer";
1403 $data['result'] = $queAnsArr;
1404
1405 return $data;
1406 } */
1407
1408 // public function fill_question_answer()
1409 // {
1410 // $user_id = $this->input->get_post('user_id',TRUE);
1411 // $questions = $this->input->get_post('questions',TRUE);
1412 // $payment = $this->input->get_post('payment',TRUE);
1413 // $questionArr = json_decode($questions,TRUE);
1414
1415 // $this->db->where('user_id',$user_id);
1416 // $delArr = $this->db->delete('fill_question_answer');
1417
1418
1419 // // foreach ($questionArr as $key => $arr) {
1420
1421 // foreach ($questionArr as $key1 => $value1) {
1422
1423 // $QuestionId = $value1['QuestionId'];
1424 // $AnswerId = $value1['AnswerId'];
1425 // $Other = $value1['Other'];
1426 // $Gifted = $value1['Gifted'];
1427 // $FriendId = $value1['FriendId'];
1428 // $QuestionName = $value1['QuestionName'];
1429 // $answer = $value1['answer'];
1430 // // $payment = $value1['payment'];
1431
1432 // $queAnsArr = array(
1433 // 'user_id' => $user_id,
1434 // 'QuestionId' => $QuestionId,
1435 // 'AnswerId' => $AnswerId,
1436 // 'Other' => $Other,
1437 // 'FriendId' => $FriendId,
1438 // 'Gifted' => $Gifted,
1439 // 'QuestionName'=> $QuestionName,
1440 // 'answer' => $answer,
1441 // 'payment' => $payment,
1442 // 'created_date' => date('Y-m-d H:i:s')
1443 // );
1444
1445
1446 // $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
1447 // //}
1448 // }
1449
1450 // $insPay = array(
1451 // 'user_id' => $user_id,
1452 // 'payment_status' => $payment,
1453 // 'friend_id' => $user_id,
1454 // 'payment_date' => date('Y-m-d H:i:s'),
1455 // 'created_date' => date('Y-m-d H:i:s')
1456 // );
1457 // //$this->db->where('id',$user_id);
1458 // // $this->db->update('user',array('payment_status'=> $payment));
1459 // $this->db->insert('payment',$insPay);
1460
1461
1462 // // $this->db->where('id',$user_id);
1463 // // $this->db->update('user','payment_status' => $payment);
1464 // $unique_number = rand(1,100);
1465 // $otheransArr = array(
1466 // 'question_id' => $QuestionId,
1467 // 'answer_id' => $unique_number,
1468 // 'other_ans_id' => $unique_number,
1469 // 'answer' => $Other,
1470 // 'created_date' => date('Y-m-d H:i:s')
1471 // );
1472
1473 // $this->db->insert('question_answer',$otheransArr);
1474
1475 // $data['status'] = "success";
1476 // $data['message'] = "save all question answer";
1477 // $data['result'] = $queAnsArr;
1478
1479 // return $data;
1480 // }
1481
1482
1483 // public function fill_question_answer()
1484 // {
1485 // $user_id = $this->input->get_post('user_id',TRUE);
1486 // $questions = $this->input->get_post('questions',TRUE);
1487 // $payment = $this->input->get_post('payment',TRUE);
1488 // $questionArr = json_decode($questions,TRUE);
1489
1490
1491 // $this->db->where('user_id',$user_id);
1492 // $delArr = $this->db->delete('fill_question_answer');
1493
1494
1495 // foreach ($questionArr as $key => $arr) {
1496
1497 // foreach ($arr as $key1 => $value1) {
1498
1499 // $QuestionId = $value1['QuestionId'];
1500 // $AnswerId = $value1['AnswerId'];
1501 // $Other = $value1['Other'];
1502 // $Gifted = $value1['Gifted'];
1503 // $FriendId = $value1['FriendId'];
1504 // $QuestionName = $value1['QuestionName'];
1505 // $answer = $value1['answer'];
1506 // // $payment = $value1['payment'];
1507
1508 // $queAnsArr = array(
1509 // 'user_id' => $user_id,
1510 // 'QuestionId' => $QuestionId,
1511 // 'AnswerId' => $AnswerId,
1512 // 'Other' => $Other,
1513 // 'FriendId' => $FriendId,
1514 // 'Gifted' => $Gifted,
1515 // 'QuestionName'=> $QuestionName,
1516 // 'answer' => $answer,
1517 // 'payment' => $payment,
1518 // 'created_date' => date('Y-m-d H:i:s')
1519 // );
1520
1521
1522 // $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
1523 // }
1524 // }
1525 // $insPay = array(
1526 // 'user_id' => $user_id,
1527 // 'payment_status' => $payment,
1528 // 'friend_id' => $user_id,
1529 // 'payment_date' => date('Y-m-d H:i:s'),
1530 // 'created_date' => date('Y-m-d H:i:s')
1531 // );
1532 // //$this->db->where('id',$user_id);
1533 // // $this->db->update('user',array('payment_status'=> $payment));
1534 // $this->db->insert('payment',$insPay);
1535
1536 // // }
1537
1538
1539 // // $this->db->where('id',$user_id);
1540 // // $this->db->update('user','payment_status' => $payment);
1541
1542 // $data['status'] = "success";
1543 // $data['message'] = "save all question answer";
1544 // $data['result'] = $queAnsArr;
1545
1546 // return $data;
1547 // }
1548
1549 public function fill_question_answer()
1550 {
1551 $user_id = $this->input->get_post('user_id', TRUE);
1552 $questions = $this->input->get_post('questions', TRUE);
1553 $payment = $this->input->get_post('payment', TRUE);
1554 $questionArr = json_decode($questions, TRUE);
1555
1556 $this->db->where('user_id', $user_id);
1557 $delArr = $this->db->delete('fill_question_answer');
1558
1559
1560 // foreach ($questionArr as $key => $arr) {
1561
1562 foreach ($questionArr as $key1 => $value1) {
1563
1564 $QuestionId = $value1['QuestionId'];
1565 $AnswerId = $value1['AnswerId'];
1566 $Other = $value1['Other'];
1567 $Gifted = $value1['Gifted'];
1568 $FriendId = $value1['FriendId'];
1569 $QuestionName = $value1['QuestionName'];
1570 $answer = $value1['answer'];
1571 // $payment = $value1['payment'];
1572
1573 $queAnsArr = array(
1574 'user_id' => $user_id,
1575 'QuestionId' => $QuestionId,
1576 'AnswerId' => $AnswerId,
1577 'Other' => $Other,
1578 'FriendId' => $FriendId,
1579 'Gifted' => $Gifted,
1580 'QuestionName' => $QuestionName,
1581 'answer' => $answer,
1582 'payment' => $payment,
1583 'created_date' => date('Y-m-d H:i:s')
1584 );
1585
1586 $questionAnsSave = $this->db->insert('fill_question_answer', $queAnsArr);
1587 //}
1588
1589
1590 $insPay = array(
1591 'user_id' => $user_id,
1592 'payment_status' => $payment,
1593 'friend_id' => $user_id,
1594 'payment_date' => date('Y-m-d H:i:s'),
1595 'created_date' => date('Y-m-d H:i:s')
1596 );
1597
1598 $this->db->insert('payment', $insPay);
1599
1600 //if(!empty($Other)){
1601 if ($answer == "other") {
1602 $unique_number = rand(1, 100);
1603 $otheransArr = array(
1604 'question_id' => $QuestionId,
1605 'answer_id' => $unique_number,
1606 'other_ans_id' => $unique_number,
1607 'answer' => $Other,
1608 'created_date' => date('Y-m-d H:i:s')
1609 );
1610 $this->db->insert('question_answer', $otheransArr);
1611 }
1612 }
1613 $data['status'] = "success";
1614 $data['message'] = "save all question answer";
1615 $data['result'] = $queAnsArr;
1616
1617 return $data;
1618 }
1619
1620
1621 public function update_all_quetion_answer()
1622 {
1623 $id = $this->input->get_post('id', TRUE);
1624 $questions = $this->input->get_post('questions', TRUE);
1625 $user_id = $this->input->get_post('user_id', TRUE);
1626 $payment = $this->input->get_post('payment', TRUE);
1627
1628 $questionArr = json_decode($questions, TRUE);
1629
1630 foreach ($questionArr as $key1 => $value1) {
1631 foreach ($value1 as $key1 => $arr) {
1632
1633 $id = $arr['id'];
1634 $QuestionId = $arr['QuestionId'];
1635 $AnswerId = $arr['AnswerId'];
1636 $Other = $arr['Other'];
1637 $Gifted = $arr['Gifted'];
1638 $FriendId = $arr['FriendId'];
1639 $QuestionName = $arr['QuestionName'];
1640 $answer = $arr['answer'];
1641
1642 $queAnsArr = array(
1643 'user_id' => $user_id,
1644 'QuestionId' => $QuestionId,
1645 'AnswerId' => $AnswerId,
1646 'Other' => $Other,
1647 'FriendId' => $FriendId,
1648 'Gifted' => $Gifted,
1649 'QuestionName' => $QuestionName,
1650 'answer' => $answer,
1651 'payment' => $payment,
1652 'created_date' => date('Y-m-d H:i:s')
1653 );
1654
1655 $this->db->where('id', $id);
1656 $questionAnsSave = $this->db->update('fill_question_answer', $queAnsArr);
1657 }
1658 }
1659
1660 $data['status'] = "success";
1661 $data['message'] = "update all question answer";
1662 $data['result'] = $queAnsArr;
1663
1664 return $data;
1665 }
1666
1667 public function iosPushNotificationtoUser($token, $message, $id)
1668 {
1669
1670 $dataArr = array("token" => $token, "message" => $message, "id" => $id);
1671
1672 $url = "https://recoverrefuel.com/webservices/ios_push_notification_girlfriendgift";
1673 $curl = curl_init();
1674
1675 curl_setopt_array($curl, array(
1676 CURLOPT_RETURNTRANSFER => 1,
1677 CURLOPT_URL => $url,
1678 CURLOPT_USERAGENT => 'Push',
1679 CURLOPT_POST => 1,
1680 CURLOPT_POSTFIELDS => $dataArr
1681 ));
1682 $resp = curl_exec($curl);
1683
1684//print_r($resp);exit;
1685 }
1686
1687 // public function fill_question_answer()
1688 // {
1689
1690 // $user_id = $this->input->get_post('user_id',TRUE);
1691 // $questions = $this->input->get_post('questions',TRUE);
1692
1693
1694 // // $questionArr = json_encode($questions);
1695 // $questionArr = json_decode($questions,TRUE);
1696
1697 // foreach ($questionArr as $key => $row) {
1698
1699 // $QuestionId = $row['QuestionId'];
1700 // $AnswerId = $row['AnswerId'];
1701 // $Other = $row['Other'];
1702 // $Gifted = $row['Gifted'];
1703 // $FriendId = $row['FriendId'];
1704 // $QuestionName = $row['QuestionName'];
1705
1706 // $queAnsArr = array(
1707 // 'user_id' => $user_id,
1708 // 'QuestionId' => $QuestionId,
1709 // 'AnswerId' => $AnswerId,
1710 // 'Other' => $Other,
1711 // 'FriendId' => $FriendId,
1712 // 'Gifted' => $Gifted,
1713 // 'QuestionName'=> $QuestionName,
1714 // 'created_date' => date('Y-m-d H:i:s')
1715 // );
1716 // $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
1717
1718 // }
1719 // $data['status'] = "success";
1720 // $data['message'] = "save all question answer";
1721 // $data['result'] = $queAnsArr;
1722
1723 // return $data;
1724 // }
1725
1726
1727 // public function fill_question_answer()
1728 // {
1729
1730 // $user_id = $this->input->get_post('user_id',TRUE);
1731 // $questions = $this->input->get_post('questions',TRUE);
1732
1733 // // $questionArr = json_encode($questions);
1734
1735 // echo '<pre>';
1736 // print_r($questions);
1737 // exit;
1738
1739 // $questionArr = json_decode($questions,TRUE);
1740
1741 // foreach ($questionArr as $value) {
1742
1743 // //foreach ($row as $key => $value) {
1744
1745
1746 // // $id = $row['question_id'];
1747 // // $question = $row['question'];
1748 // // $answer = $row['answer'];
1749 // // $other = $row['other'];
1750 // // $gifted = $row['gifted'];
1751 // // $friend_id = $row['friend_id'];
1752 // $QuestionId = $value['QuestionId'];
1753
1754 // $AnswerId = $value['AnswerId'];
1755 // $Other = $value['Other'];
1756 // $Gifted = $value['Gifted'];
1757 // $FriendId = $value['FriendId'];
1758 // $QuestionName = $value['QuestionName'];
1759
1760 // // $queAnsArr = array(
1761 // // 'user_id' => $user_id,
1762 // // 'question_id' => $id,
1763 // // 'question' => $question,
1764 // // 'answer' => $answer,
1765 // // 'other' => $other,
1766 // // 'friend_id' => $friend_id,
1767 // // 'gifted' => $gifted,
1768 // // 'created_date' => date('Y-m-d H:i:s')
1769 // // );
1770
1771 // $queAnsArr = array(
1772 // 'user_id' => $user_id,
1773 // 'QuestionId' => $QuestionId,
1774 // 'AnswerId' => $AnswerId,
1775 // 'Other' => $Other,
1776 // 'FriendId' => $FriendId,
1777 // 'Gifted' => $Gifted,
1778 // 'QuestionName'=> $QuestionName,
1779 // 'created_date' => date('Y-m-d H:i:s')
1780 // );
1781
1782
1783 // $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
1784 // // }
1785 // }
1786 // $data['status'] = "success";
1787 // $data['message'] = "save all question answer";
1788 // $data['result'] = $queAnsArr;
1789
1790 // return $data;
1791 // }
1792
1793 // 05/07/2017
1794 // public function fill_question_answer_show(){
1795 // $user_id = $this->input->get_post('user_id',TRUE);
1796
1797 // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
1798 // $this->db->from('fill_question_answer');
1799 // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
1800 // $this->db->join('user','fill_question_answer.user_id = user.id');
1801
1802 // $this->db->where('fill_question_answer.user_id',$user_id);
1803 // $query = $this->db->get();
1804 // $result = $query->result_array();
1805
1806
1807 // if(count($result) > 0){
1808 // $i = 0;
1809 // foreach ($result as $image) {
1810 // $friend_id = $image['FriendId'];
1811 // $name = $image['first_name'];
1812 // $pics = $image['image'];
1813 // $QuestionId = $image['QuestionId'];
1814 // if($friend_id == 0){
1815
1816 // $result[$i]['first_name'] = "";
1817 // $result[$i]['image'] = "";
1818 // $i++;
1819 // }else{
1820 // $result->first_name = $name;
1821 // $result[$i]['image'] = base_url()."assets/profilepic/". $pics;
1822 // $pics = $result[$i]['image'];
1823 // $i++;
1824 // $result->image = $pics;
1825 // }
1826 // $data['status'] = "success";
1827 // $data['message'] = "get question answer";
1828 // if($QuestionId == 1){
1829 // $answer = $image['Other'];
1830 // $result[0]['answer'] = $answer;
1831 // }
1832 // else{
1833 // $answer = $image['Other'];
1834 // }
1835 // $data['result'] = $result;
1836 // }
1837 // }else{
1838
1839 // $data['status'] = "failure";
1840 // $data['message'] = "data not found";
1841
1842 // }
1843
1844
1845 // return $data;
1846 // }
1847
1848
1849 // public function fill_question_answer_show(){
1850 // $user_id = $this->input->get_post('user_id',TRUE);
1851
1852 // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
1853 // $this->db->from('fill_question_answer');
1854 // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
1855 // $this->db->join('user','fill_question_answer.user_id = user.id');
1856
1857 // $this->db->where('fill_question_answer.user_id',$user_id);
1858 // $query = $this->db->get();
1859 // $result = $query->result_array();
1860
1861 // if(count($result) > 0){
1862 // $i = 0;
1863 // foreach ($result as $image) {
1864 // $friend_id = $image['FriendId'];
1865 // $name = $image['first_name'];
1866 // $pics = $image['image'];
1867 // $QuestionId = $image['QuestionId'];
1868 // if($friend_id == 0){
1869 // $result[$i]['first_name'] = "";
1870 // $result[$i]['image'] = "";
1871 // $i++;
1872 // }else{
1873 // $check_friends_id = $this->db->get_where('user',array('id' =>$friend_id))->result_array();
1874 // if(count($check_friends_id) > 0){
1875 // foreach ($check_friends_id as $key =>$value) {
1876 // $friends_first_name = $value['first_name'];
1877 // $friends_last_name = $value['last_name'];
1878 // $friends_image = $value['image'];
1879 // $result[$i]['first_name'] = $friends_first_name." ".$friends_last_name;
1880 // $friends = $result[$i]['first_name'];
1881 // //print_r($friends);exit;
1882 // $result[$i]['first_name'] = $friends;
1883 // $result[$i]['image'] = base_url()."assets/profilepic/". $friends_image;
1884 // $pics = $result[$i]['image'];
1885 // $i++;
1886 // $result->image = $pics;
1887 // }
1888
1889 // }else{
1890 // $result->first_name = $name;
1891 // $result[$i]['image'] = base_url()."assets/profilepic/". $pics;
1892 // $pics = $result[$i]['image'];
1893 // $i++;
1894 // $result->image = $pics;
1895
1896 // }
1897 // }
1898 // $data['status'] = "success";
1899 // $data['message'] = "get question answer";
1900 // if($QuestionId == 1){
1901 // $answer = $image['Other'];
1902 // $result[0]['answer'] = $answer;
1903 // }
1904 // else{
1905 // $answer = $image['Other'];
1906 // }
1907 // $data['result'] = $result;
1908 // }
1909 // }else{
1910
1911 // $data['status'] = "failure";
1912 // $data['message'] = "data not found";
1913
1914 // }
1915
1916
1917 // return $data;
1918 // }
1919
1920
1921 // public function fill_question_answer_show(){
1922 // $user_id = $this->input->get_post('user_id',TRUE);
1923 // $this->db->select('fill_question_answer.id as fill_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.payment');
1924 // $this->db->from('fill_question_answer');
1925 // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
1926 // $this->db->join('user','fill_question_answer.user_id = user.id');
1927 // // $this->db->join('payment','fill_question_answer.payment = payment.payment_status');
1928 // $this->db->where('fill_question_answer.user_id',$user_id);
1929 // //$this->db->where('payment.payment_status','0');
1930
1931 // $query = $this->db->get();
1932 // $result = $query->result_array();
1933 // //print_r($result);exit;
1934
1935 // $paymentCheck = $this->db->get_where('payment',array('user_id' => $user_id))->result();
1936 // foreach ($paymentCheck as $payment) {
1937 // $get_payment = $payment->payment_status;
1938 // }
1939
1940 // if(count($result) > 0){
1941 // $i = 0;
1942 // foreach ($result as $image) {
1943 // $friend_id = $image['FriendId'];
1944 // $name = $image['first_name'];
1945 // $pics = $image['image'];
1946 // $other = $image['Other'];
1947 // $payment = $image['payment'];
1948 // $QuestionId = $image['QuestionId'];
1949 // //$friend_id1 = $image['friend_id'];
1950
1951 // if($friend_id == 0){
1952 // $result[$i]['first_name'] = "";
1953 // $result[$i]['image'] = "";
1954 // $i++;
1955 // }else{
1956 // if($pics == ""){
1957 // $result->image = $pics;
1958 // }else{
1959 // $result->first_name = $name;
1960 // $result[$i]['image'] = base_url()."assets/profilepic/". $pics;
1961 // $pics = $result[$i]['image'];
1962 // $i++;
1963 // $result->image = $pics;
1964 // }
1965 // }
1966 // }
1967 // $data['status'] = "success";
1968 // $data['message'] = "get question answer";
1969 // if($QuestionId == 1){
1970 // $answer = $image['Other'];
1971 // $result[0]['answer'] = $answer;
1972 // }else{
1973 // $answer = $image['Other'];
1974 // }
1975 // if($payment == 0){
1976
1977 // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
1978 // $this->db->from('fill_question_answer');
1979 // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
1980 // $this->db->join('user','fill_question_answer.user_id = user.id');
1981 // // $this->db->join('payment','user_id')
1982 // $this->db->where('fill_question_answer.user_id',$user_id);
1983 // //$this->db->where('fill_question_answer.QuestionId',$q_id);
1984 // $this->db->order_by('fill_question_answer.QuestionId','ASC');
1985 // $this->db->limit(10, 0);
1986 // $query_str = $this->db->get();
1987 // $result_array = $query_str->result_array();
1988 // //print_r($result1); exit;
1989 // $data['status'] = "success";
1990 // $data['message'] = "get question answer show";
1991 // $data['payment'] = $payment;
1992 // $data['result'] = $result_array;
1993 // // }
1994 // }else{
1995 // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.payment');
1996 // $this->db->from('fill_question_answer');
1997 // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
1998 // $this->db->join('user','fill_question_answer.user_id = user.id');
1999 // // $this->db->join('payment','user.id = payment.user_id');
2000 // $this->db->where('fill_question_answer.user_id',$user_id);
2001 // $this->db->where('fill_question_answer.payment','1');
2002 // $str_qry = $this->db->get();
2003 // $ret = $str_qry->result_array();
2004 // // print_r($ret);exit;
2005 // $data['status'] = "success";
2006 // $data['message'] = "getting all question answer";
2007 // $data['payment'] = $payment;
2008 // $data['result'] = $ret;
2009 // //}
2010 // }
2011 // //$data['result'] = $result;
2012 // //}
2013 // }else{
2014 // $data['status'] = "failure";
2015 // $data['message'] = "data not found";
2016 // }
2017 // return $data;
2018 // }
2019
2020
2021 public function fill_question_answer_show()
2022 {
2023
2024 $user_id = $this->input->get_post('user_id', TRUE);
2025 $this->db->select('fill_question_answer.id as fill_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.payment');
2026 $this->db->from('fill_question_answer');
2027 $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2028 $this->db->join('user', 'fill_question_answer.user_id = user.id');
2029 // $this->db->join('payment','fill_question_answer.payment = payment.payment_status');
2030 $this->db->where('fill_question_answer.user_id', $user_id);
2031 //$this->db->where('payment.payment_status','0');
2032
2033 $query = $this->db->get();
2034 $result = $query->result_array();
2035 //print_r($result);exit;
2036
2037 $paymentCheck = $this->db->get_where('payment', array('user_id' => $user_id))->result();
2038 foreach ($paymentCheck as $payment) {
2039 $get_payment = $payment->payment_status;
2040 }
2041
2042
2043 if (count($result) > 0) {
2044 $i = 0;
2045 foreach ($result as $image) {
2046 $friend_id = $image['FriendId'];
2047 $name = $image['first_name'];
2048 $pics = $image['image'];
2049 $other = $image['Other'];
2050 $payment = $image['payment'];
2051 $QuestionId = $image['QuestionId'];
2052 //$friend_id1 = $image['friend_id'];
2053
2054 // $checkFriendId = $this->db->get_where('user',array('id' => $friend_id))->row();
2055 // if(count($checkFriendId) > 0 ){
2056 // $friend_id = $checkFriendId->id;
2057 // $first_name = $checkFriendId->first_name;
2058 // $last_name = $checkFriendId->last_name;
2059 // $full_name = $first_name . "" .$last_name;
2060 // if($friend_id == 0){
2061 // $result[$i]['first_name'] = "";
2062 // $result[$i]['image'] = "";
2063 // $i++;
2064 // }else{
2065 // if($pics == ""){
2066 // $result->image = $pics;
2067 // }else{
2068 // $result->first_name = $full_name;
2069 // $result[$i]['image'] = base_url()."assets/profilepic/". $pics;
2070 // $pics = $result[$i]['image'];
2071 // $i++;
2072 // $result->image = $pics;
2073 // }
2074 // }
2075 // }else{
2076 // $result[$i]['first_name'] = "";
2077 // $result[$i]['image'] = "";
2078 // $i++;
2079 // }
2080
2081 }
2082 $data['status'] = "success";
2083 $data['message'] = "get question answer";
2084 //$data['result'] = $result;
2085 // if($QuestionId == 1){
2086 // $answer = $image['Other'];
2087 // $result[0]['answer'] = $answer;
2088 // }else{
2089 // $answer = $image['Other'];
2090 // }
2091 if ($payment == 0) {
2092 $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.created_date');
2093 $this->db->from('fill_question_answer1');
2094 $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2095 $this->db->join('user', 'fill_question_answer.user_id = user.id');
2096 // $this->db->join('payment','user_id')
2097 $this->db->where('fill_question_answer.user_id', $user_id);
2098 //$this->db->where('fill_question_answer.QuestionId',$q_id);
2099 $this->db->order_by('fill_question_answer.QuestionId', 'ASC');
2100 $this->db->limit(10, 0);
2101 $query_str = $this->db->get();
2102 // print_r($this->db->last_query());exit;
2103 $result_array = $query_str->result_array();
2104
2105 $i = 0;
2106 foreach ($result_array as $birthDate) {
2107 $friend_id = $birthDate['FriendId'];
2108 $questionId = $birthDate['QuestionId'];
2109 $date = $birthDate['created_date'];
2110 $created_date = $birthDate['created_date'];
2111
2112 //$creat_date = date($created_date);
2113 $creat_date = date('d-M-Y', strtotime($created_date));
2114 $checkFriendId = $this->db->get_where('user', array('id' => $friend_id))->row();
2115 if (count($checkFriendId) > 0) {
2116 $friend_id = $checkFriendId->id;
2117 $first_name = $checkFriendId->first_name;
2118 $last_name = $checkFriendId->last_name;
2119 $fri_full_name = $first_name . " " . $last_name;
2120 if ($friend_id == 0) {
2121 $result_array[$i]['date'] = $creat_date;
2122 $result_array[$i]['first_name'] = "";
2123 $result_array[$i]['image'] = "";
2124 $i++;
2125 } else {
2126 if ($pics == "") {
2127 $result_array->image = $pics;
2128 } else {
2129 $result_array[$i]['date'] = $creat_date;
2130 $result_array[$i]['first_name'] = $fri_full_name;
2131 $result_array[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
2132 $pics = $result_array[$i]['image'];
2133 $i++;
2134 $result_array->image = $pics;
2135 $result_array->first_name = $name;
2136 }
2137 }
2138 } else {
2139 $result_array[$i]['first_name'] = "";
2140 $result_array[$i]['image'] = "";
2141 $i++;
2142 }
2143
2144 if ($questionId == 1) {
2145 $birthDate = $birthDate['Other'];
2146 $result_array[0]['answer'] = $birthDate;
2147 } else {
2148 $answer = $birthDate['Other'];
2149 }
2150
2151 }
2152 $data['status'] = "success";
2153 $data['message'] = "get question answer show";
2154 $data['payment'] = $payment;
2155 $data['result'] = $result_array;
2156
2157 // }
2158 } else {
2159
2160 $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.payment,fill_question_answer.created_date');
2161 $this->db->from('fill_question_answer');
2162 $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2163 $this->db->join('user', 'fill_question_answer.user_id = user.id');
2164 // $this->db->join('payment','user.id = payment.user_id');
2165 $this->db->where('fill_question_answer.user_id', $user_id);
2166 $this->db->where('fill_question_answer.payment', '1');
2167 $this->db->order_by('fill_question_answer.QuestionId', 'ASC');
2168 $str_qry = $this->db->get();
2169 $result_array = $str_qry->result_array();
2170 //print_r($result_array);
2171 $i = 0;
2172
2173 $final_array = [];
2174 foreach ($result_array as $birthDate) {
2175 $questionId = $birthDate['QuestionId'];
2176 $date = $birthDate['created_date'];
2177 $created_date = $birthDate['created_date'];
2178
2179 //$creat_date = date($created_date);
2180 $creat_date = date('d-M-Y', strtotime($created_date));
2181 $friend_id = $birthDate['FriendId'];
2182
2183 $checkFriendId = $this->db->get_where('user', array('id' => $friend_id))->row();
2184 //print_r($checkFriendId);
2185 ///---
2186
2187
2188 $arr['QuestionName'] = isset($birthDate['QuestionName']) ? $birthDate['QuestionName'] : '';
2189 $arr['AnswerId'] = isset($birthDate['AnswerId']) ? $birthDate['AnswerId'] : '';
2190 $arr['QuestionId'] = isset($birthDate['QuestionId']) ? $birthDate['QuestionId'] : '';
2191 $arr['FriendId'] = isset($checkFriendId->id) ? $checkFriendId->id : '0';
2192 $arr['Gifted'] = isset($birthDate['Gifted']) ? $birthDate['Gifted'] : '';
2193 $arr['Other'] = isset($birthDate['Other']) ? $birthDate['Other'] : '';
2194 $arr['answer'] = isset($birthDate['answer']) ? $birthDate['answer'] : '';
2195 $arr['first_name'] = $checkFriendId->first_name . " " . $checkFriendId->last_name;
2196 if ($arr['FriendId'] != 0) {
2197 $arr['image'] = isset($checkFriendId->image) && $checkFriendId->image != "" ? base_url() . "assets/profilepic/" . $checkFriendId->image : base_url() . "assets/profilepic/download.png";
2198 } else {
2199 $arr['image'] = "";
2200 }
2201 $arr['payment'] = isset($birthDate['payment']) ? $birthDate['payment'] : '';
2202 $arr['created_date'] = isset($birthDate['created_date']) ? $birthDate['created_date'] : '';
2203
2204
2205 if ($questionId == 1) {
2206 $arr['answer'] = $birthDate['Other'];
2207 } else {
2208 $arr['answer'] = $birthDate['answer'];
2209 }
2210
2211
2212 //$birthDate['frend'] = $arr;
2213
2214
2215 $mer = array_merge($birthDate, $arr);
2216
2217 $final_array[] = $arr;
2218
2219 ///--
2220
2221 /**
2222 * if(count($checkFriendId) > 0 ){
2223 * // print_r($checkFriendId);
2224 * $friend_id = $checkFriendId->id;
2225 * $first_name = $checkFriendId->first_name;
2226 * $last_name = $checkFriendId->last_name;
2227 * $fri_full_name = $first_name . " " .$last_name;
2228 * $pics = $checkFriendId->image;
2229 * if($friend_id == 0){
2230 * $result_array[$i]['date'] = $creat_date;
2231 * $result_array[$i]['first_name'] = "";
2232 * $result_array[$i]['image'] = "";
2233 * $i++;
2234 * }else{
2235 * if($pics == ""){
2236 * $result_array->image = $pics;
2237 * }else{
2238 *
2239 * $result_array[$i]['date'] = $creat_date;
2240 * $result_array[$i]['first_name'] = $fri_full_name;
2241 * // print_r($result_array[$i]['first_name']);exit;
2242 * $result_array[$i]['image'] = base_url()."assets/profilepic/". $pics;
2243 * $pics = $result_array[$i]['image'];
2244 * $i++;
2245 * $result_array->image = $pics;
2246 * $result_array->first_name = $name;
2247 * }
2248 * }
2249 * }else{
2250 * $result_array[$i]['first_name'] = "";
2251 * $result_array[$i]['image'] = "";
2252 * $i++;
2253 * }
2254 *
2255 * if($questionId == 1){
2256 * $birthDate = $birthDate['Other'];
2257 * $result_array[0]['answer'] = $birthDate;
2258 * }else{
2259 * $answer = $birthDate['Other'];
2260 * }
2261 */
2262 }
2263 //echo $friend_id = $birthDate['FriendId'];
2264 // print_r($result_array);exit;
2265 $data['status'] = "success";
2266 $data['message'] = "getting all question answer";
2267 $data['payment'] = $payment;
2268 $data['result'] = $final_array;//$result_array;
2269 //}
2270 }
2271
2272 //$data['result'] = $result;
2273 //}
2274 } else {
2275 $data['status'] = "failure";
2276 $data['message'] = "data not found";
2277 }
2278 return $data;
2279 }
2280
2281
2282
2283
2284 // public function friends_question_answer_show(){
2285 // $user_id = $this->input->get_post('user_id',TRUE);
2286 // $friend_id = $this->input->get_post('friend_id',TRUE);
2287
2288 // $this->db->select('fill_question_answer.id,fill_question_answer.user_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer');
2289 // $this->db->from('fill_question_answer');
2290 // $this->db->join('question_answer','fill_question_answer.QuestionId = question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2291 // $this->db->join('payment','fill_question_answer.user_id = payment.friend_id');
2292 // //$this->db->join('user','fill_question_answer.user_id = user.id');
2293 // // $this->db->join('payment','fill_question_answer.payment = payment.payment_status');
2294 // $this->db->where('payment.user_id',$user_id);
2295 // $this->db->where('payment.friend_id',$friend_id);
2296 // //$this->db->where('payment.payment_status','1');
2297 // $query = $this->db->get();
2298 // $result = $query->result_array();
2299
2300 // $checkPaymentArr = $this->db->get_where('payment',array('user_id' => $user_id,'friend_id' => $friend_id))->row();
2301 // $payment_status = $checkPaymentArr->payment_status;
2302 // if(count($result) > 0){
2303
2304 // foreach ($result as $image) {
2305
2306 // $friend_id = $image['FriendId'];
2307 // $name = $image['first_name'];
2308 // $pics = $image['image'];
2309 // $other = $image['Other'];
2310 // //$payment = $image['payment_status'];
2311 // $QuestionId = $image['QuestionId'];
2312 // if($payment_status == 0){
2313
2314 // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
2315 // $this->db->from('fill_question_answer');
2316 // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2317 // $this->db->join('user','fill_question_answer.user_id = user.id');
2318 // $this->db->where('fill_question_answer.user_id',$user_id);
2319 // $this->db->where("QuestionId >= 1 and QuestionId <= 10");
2320
2321 // // $this->db->order_by('fill_question_answer.QuestionId','ASC');
2322
2323 // $query_str = $this->db->get();
2324 // // print_r($this->db->last_query())->result();
2325 // $result_array = $query_str->result_array();
2326 // //print_r($result_array);exit;
2327 // $data['status'] = "success";
2328 // $data['message'] = "get question answer show";
2329 // $data['payment'] = $payment_status;
2330 // $data['result'] = $result_array;
2331 // // }
2332 // }else{
2333 // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,payment.payment_status');
2334 // $this->db->from('fill_question_answer');
2335 // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2336 // $this->db->join('user','fill_question_answer.user_id = user.id');
2337 // $this->db->join('payment','user.id = payment.user_id');
2338 // $this->db->where('fill_question_answer.user_id',$user_id);
2339 // $this->db->where('payment.payment_status','1');
2340 // $str_qry = $this->db->get();
2341 // $ret = $str_qry->result_array();
2342 // // print_r($ret);exit;
2343 // $data['status'] = "success";
2344 // $data['message'] = "getting all question answer";
2345 // $data['payment'] = $get_payment;
2346 // $data['result'] = $ret;
2347 // //}
2348 // }
2349
2350 // }
2351 // // $data['status'] = "success";
2352 // // $data['message'] = "friends question answer details";
2353 // // $data['result'] = $result;
2354 // }else{
2355 // $data['status'] = "failure";
2356 // $data['message'] = "data not found";
2357 // }
2358 // return $data;
2359 // }
2360
2361
2362 public function friends_payment_status()
2363 {
2364 $user_id = $this->input->get_post('user_id', TRUE);
2365 $friend_id = $this->input->get_post('friend_id', TRUE);
2366 $payment = $this->input->get_post('payment', TRUE);
2367
2368 $checkId = $this->db->get_where('payment', array('user_id' => $user_id, 'friend_id' => $friend_id, 'payment_status' => '0'))->result();
2369 if ($checkId) {
2370
2371 $upudateArr = array(
2372 'payment_status' => 1
2373 );
2374
2375 $this->db->where('user_id', $user_id)->where('friend_id', $friend_id);
2376 $updateSave = $this->db->update('payment', $upudateArr);
2377
2378 $data['status'] = "success";
2379 $data['message'] = "update successfully";
2380 $data['result'] = $upudateArr;
2381 } else {
2382
2383 $paymentArr = array(
2384 'user_id' => $user_id,
2385 'friend_id' => $friend_id,
2386 'payment_status' => $payment,
2387 'create_date' => date('Y-m-d H:i:s')
2388 );
2389
2390 $insertArr = $this->db->insert('payment', $paymentArr);
2391 if (count($insertArr)) {
2392
2393 $data['status'] = "success";
2394 $data['message'] = "payment successfully";
2395 $data['result'] = $paymentArr;
2396 //$data['payment']
2397 } else {
2398
2399 $data['status'] = "failure";
2400 $data['message'] = "data not found";
2401 }
2402 }
2403 return $data;
2404 }
2405
2406
2407 public function friends_question_answer_show()
2408 {
2409 $user_id = $this->input->get_post('user_id', TRUE);
2410 $friend_id = $this->input->get_post('friend_id', TRUE);
2411
2412 $this->db->select('fill_question_answer.id,fill_question_answer.user_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,fill_question_answer.payment');
2413 $this->db->from('fill_question_answer');
2414 $this->db->join('question_answer', 'fill_question_answer.QuestionId = question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2415 // $this->db->join('payment','fill_question_answer.user_id = payment.friend_id');
2416 $this->db->join('user', 'fill_question_answer.user_id = user.id');
2417 // $this->db->join('payment','fill_question_answer.payment = payment.payment_status');
2418 $this->db->where('user.id', $friend_id);
2419 // $this->db->where('payment.user_id',$user_id);
2420 //$this->db->where('payment.friend_id',$friend_id);
2421 //$this->db->where('payment.payment_status','1');
2422 $query = $this->db->get();
2423 $result = $query->result_array();
2424
2425 // print_r($result);exit;
2426
2427 $checkPaymentArr = $this->db->get_where('payment', array('user_id' => $user_id, 'friend_id' => $friend_id))->row();
2428
2429 $payment_status = $checkPaymentArr->payment_status;
2430 if ($payment_status == "") {
2431 $payment_status = "0";
2432 } else {
2433 $payment_status = $checkPaymentArr->payment_status;
2434 }
2435 $get_friend_id = $checkPaymentArr->friend_id;
2436 $get_user_id = $checkPaymentArr->user_id;
2437
2438 $user_payment = $this->db->get_where('fill_question_answer', array('user_id' => $friend_id))->result();
2439
2440 //print_r($user_payment);exit;
2441 foreach ($user_payment as $user_pay) {
2442 $total_payment = $user_pay->payment;
2443 }
2444
2445 if (count($result) > 0) {
2446 foreach ($result as $image) {
2447 $friend_id = $image['FriendId'];
2448 $name = $image['first_name'];
2449 $pics = $image['image'];
2450 $other = $image['Other'];
2451 //$payment = $image['payment_status'];
2452 $QuestionId = $image['QuestionId'];
2453 if ($payment_status == 0) {
2454 $friend_id = $this->input->get_post('friend_id', TRUE);
2455 $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
2456 $this->db->from('fill_question_answer');
2457 $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2458 $this->db->join('user', 'fill_question_answer.user_id = user.id');
2459 //$this->db->where('fill_question_answer.user_id',$get_friend_id);
2460 $this->db->where('fill_question_answer.user_id', $friend_id);
2461 $this->db->where("QuestionId >= 1 and QuestionId <= 10");
2462
2463 $this->db->order_by('fill_question_answer.QuestionId', 'ASC');
2464
2465 $query_str = $this->db->get();
2466 // print_r($this->db->last_query())->result();
2467 $result_array = $query_str->result_array();
2468 //print_r($result_array);exit;
2469
2470 foreach ($result_array as $birthDate) {
2471 $questionId = $birthDate['QuestionId'];
2472 if ($questionId == 1) {
2473 $birthDate = $birthDate['Other'];
2474 $result_array[0]['answer'] = $birthDate;
2475 } else {
2476 $answer = $birthDate['Other'];
2477 }
2478 if ($questionId == 2) {
2479 $rose = $birthDate['Other'];
2480 if ($rose == "") {
2481 $rose1 = $birthDate['answer'];
2482 $result_array[1]['answer'] = $rose1;
2483 } else {
2484 $result_array[1]['answer'] = $rose;
2485 }
2486
2487 } else if ($questionId == 3) {
2488
2489 $fragrances = $birthDate['Other'];
2490 if ($fragrances == "") {
2491 $fragrances1 = $birthDate['answer'];
2492 $result_array[2]['answer'] = $fragrances1;
2493 } else {
2494 $result_array[2]['answer'] = $fragrances;
2495 }
2496
2497
2498 } else if ($questionId == 4) {
2499 $body = $birthDate['Other'];
2500 if ($body == "") {
2501 $body1 = $birthDate['answer'];
2502 $result_array[3]['answer'] = $body1;
2503 } else {
2504 $result_array[3]['answer'] = $body;
2505 }
2506 } else if ($questionId == 5) {
2507 $body = $birthDate['Other'];
2508 if ($body == "") {
2509 $body1 = $birthDate['answer'];
2510 $result_array[4]['answer'] = $body1;
2511 } else {
2512 $result_array[4]['answer'] = $body;
2513 }
2514
2515 } else if ($questionId == 6) {
2516 $restorent = $birthDate['Other'];
2517 if ($restorent == "") {
2518 $restorent1 = $birthDate['answer'];
2519 $result_array[5]['answer'] = $restorent1;
2520 } else {
2521 $result_array[5]['answer'] = $restorent;
2522 }
2523 } else if ($questionId == 7) {
2524 $cocktail = $birthDate['Other'];
2525 if ($cocktail == "") {
2526 $cocktail1 = $birthDate['answer'];
2527 $result_array[6]['answer'] = $cocktail1;
2528 } else {
2529 $result_array[6]['answer'] = $cocktail;
2530 }
2531 } else if ($questionId == 8) {
2532 $answer = $birthDate['Other'];
2533 if ($answer == "") {
2534 $answer1 = $birthDate['answer'];
2535 $result_array[7]['answer'] = $answer1;
2536 } else {
2537 $result_array[7]['answer'] = $answer;
2538 }
2539 } else if ($questionId == 9) {
2540 $answer = $birthDate['Other'];
2541 if ($answer == "") {
2542 $answer1 = $birthDate['answer'];
2543 $result_array[8]['answer'] = $answer1;
2544 } else {
2545 $result_array[8]['answer'] = $answer;
2546 }
2547 } else if ($questionId == 10) {
2548 $answer = $birthDate['Other'];
2549 if ($answer == "") {
2550 $answer1 = $birthDate['answer'];
2551 $result_array[9]['answer'] = $answer1;
2552 } else {
2553 $result_array[9]['answer'] = $answer;
2554 }
2555 } else {
2556
2557 }
2558 }
2559
2560 $data['status'] = "success";
2561 $data['message'] = "get question answer show";
2562 $data['payment'] = $payment_status;
2563 $data['total_payment'] = $total_payment;
2564 $data['result'] = $result_array;
2565 // }
2566 } else {
2567 //echo "hi";exit;
2568 $this->db->select('fill_question_answer.user_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
2569 $this->db->from('fill_question_answer');
2570 $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2571 $this->db->join('user', 'fill_question_answer.user_id = user.id');
2572 //$this->db->join('payment','user.id = payment.user_id');
2573 $this->db->where('fill_question_answer.user_id', $get_friend_id);
2574 // $this->db->where('payment.friend_id',$get_friend_id);
2575 //$this->db->where('payment.payment_status','1');
2576 $str_qry = $this->db->get();
2577 $ret = $str_qry->result_array();
2578 // print_r($ret);exit;
2579 $data['status'] = "success";
2580 $data['message'] = "getting all question answer";
2581 $data['payment'] = $payment_status;
2582 $data['total_payment'] = $total_payment;
2583 $data['result'] = $ret;
2584 //}
2585 }
2586
2587 }
2588 // $data['status'] = "success";
2589 // $data['message'] = "friends question answer details";
2590 // $data['result'] = $result;
2591 } else {
2592 $data['status'] = "failure";
2593 $data['message'] = "data not found";
2594 }
2595 return $data;
2596 }
2597
2598
2599 public function all_question_answer()
2600 {
2601
2602 $this->db->select('question_answer.question_id,question_list.question,question_answer.answer_id,question_answer.answer');
2603 $this->db->from('question_answer');
2604 $this->db->join('question_list', 'question_answer.question_id = question_list.id');
2605 // $this->db->join('fill_question_answer','question_list.id = fill_question_answer.question_id');
2606 $query = $this->db->get();
2607 $result = $query->result();
2608
2609 // $questionArr = $this->db->get_where('question_answer',array('answer' => ""))->result();
2610 // foreach ($questionArr as $value) {
2611 // $get_id = $value->id;
2612 // $this->db->where('id',$get_id);
2613 // $this->db->delete('question_answer');
2614 // }
2615
2616 if (count($result) > 0) {
2617 $data['status'] = "success";
2618 $data['message'] = "all question answer list";
2619 $data['result'] = $result;
2620 } else {
2621 $data['status'] = "failure";
2622 $data['message'] = "data not found";
2623 }
2624
2625 return $data;
2626 }
2627
2628
2629 public function rating_review()
2630 {
2631 $user_id = $this->input->get_post('user_id', TRUE);
2632 $rate = $this->input->get_post('rate', TRUE);
2633 $review = $this->input->get_post('review', TRUE);
2634
2635 if ($rate == "") {
2636 $data['status'] = "failure";
2637 $data['message'] = "enter rate";
2638 }
2639 if ($review == "") {
2640 $data['status'] = "failure";
2641 $data['message'] = "enter review";
2642 } else {
2643 $insertArr = array(
2644 'user_id' => $user_id,
2645 'rate' => $rate,
2646 'review' => $review,
2647 'created_date' => date('Y-m-d H:i:s')
2648 );
2649
2650 $saveArr = $this->db->insert('rating', $insertArr);
2651
2652 if ($saveArr) {
2653 $data['status'] = "success";
2654 $data['message'] = "rating save";
2655 $data['result'] = $insertArr;
2656 } else {
2657 $data['status'] = "failure";
2658 $data['message'] = "data not save";
2659 }
2660 }
2661 return $data;
2662 }
2663
2664
2665 public function givenQueAns()
2666 {
2667
2668 $user_id = $this->input->get_post('user_id', TRUE);
2669 $this->db->select('fill_question_answer.id,fill_question_answer.user_id,fill_question_answer.FriendId,fill_question_answer.QuestionId,fill_question_answer.QuestionName,fill_question_answer.Other,fill_question_answer.Gifted,user.first_name,user.image,fill_question_answer.answer');
2670 $this->db->from('fill_question_answer');
2671 $this->db->join('user', 'fill_question_answer.user_id = user.id');
2672 $this->db->join('question_answer', 'fill_question_answer.QuestionId = question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
2673 $this->db->where('fill_question_answer.user_id', $user_id);
2674 $query = $this->db->get();
2675 $result = $query->result_array();
2676
2677 if (count($result) > 0) {
2678 $i = 0;
2679 $data['status'] = "success";
2680 $data['message'] = "user question answer list";
2681 // while($res = mysql_fetch_array($result)){
2682
2683 foreach ($result as $image) {
2684 $friend_id = $image['FriendId'];
2685 $QuestionId = $image['QuestionId'];
2686 $AnswerId = $image['AnswerId'];
2687 $QuestionName = $image['QuestionName'];
2688 $Other = $image['Other'];
2689 $Gifted = $image['Gifted'];
2690 $answer = $image['answer'];
2691 $name = $image['first_name'];
2692 $pics = $image['image'];
2693
2694 // $data['user_id'] = $user_id;
2695 // $data['friend_id'] = $friend_id;
2696 // $data['question_id'] = $QuestionId;
2697 // $data['question_name'] = $QuestionName;
2698 // if($AnswerId == 0){
2699 // $data['answer'] = $Other;
2700 // }else{
2701 // $data['answer'] = $answer;
2702 // }
2703 // $data['other'] = $Other;
2704 // $data['gifted'] = $Gifted;
2705 // $data['first_name'] = $name;
2706 // $data['image'] = $pics;
2707
2708
2709 if ($friend_id == 0) {
2710 $result[$i]['first_name'] = "";
2711 // $result->first_name = "";
2712 //$result->image = "";
2713 $result[$i]['image'] = "";
2714 $i++;
2715 } else {
2716 // $result[$i]['first_name'] = $name;
2717 $result->first_name = $name;
2718 $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
2719 $pics = $result[$i]['image'];
2720 $i++;
2721 $result->image = $pics;
2722
2723 }
2724
2725
2726 if ($QuestionId == 1) {
2727 $answer = $image['Other'];
2728 $result[0]['answer'] = $answer;
2729 } else {
2730 $data['answer'] = $Other;
2731 }
2732 $data['result'] = $result;
2733 }
2734 } else {
2735 $data['status'] = "failure";
2736 $data['message'] = "data not found";
2737 }
2738 return $data;
2739 }
2740
2741
2742 public function set_upload_options_certi()
2743 {
2744
2745 //upload an image options
2746
2747 $config = array();
2748
2749 $config['upload_path'] = './assets/certificates/';
2750
2751 $config['allowed_types'] = 'pdf|doc|docx|txt';
2752
2753 $config['max_size'] = '0';
2754
2755 $config['overwrite'] = FALSE;
2756
2757
2758 return $config;
2759
2760 }
2761
2762
2763 public function forgotPassword()
2764 {
2765
2766 //if ($this->input->get_post('email', TRUE)) {
2767
2768 // if (!filter_var($this->input->get_post('email', TRUE), FILTER_VALIDATE_EMAIL) === false) {
2769
2770 $msg = $this->sendForgotPasswordEmail($this->input->get_post('email', TRUE));
2771 if ($msg['resp'] == 'success') {
2772
2773 $data['status'] = "success";
2774
2775 $data['message'] = $msg['msg'];
2776
2777 } else {
2778
2779 $data['status'] = "failure";
2780
2781 $data['message'] = $msg['msg'];
2782
2783 }
2784
2785 // }
2786 // else {
2787
2788
2789 // $data['status'] = "failure";
2790
2791
2792 // $data['message'] = "Please enter valid email address";
2793
2794 // }
2795
2796 // } else {
2797
2798
2799 // // $data['status'] = "failure";
2800
2801
2802 // // $data['message'] = "Please enter email address";
2803
2804 // // }
2805
2806
2807 return $data;
2808
2809 }
2810
2811
2812 function sendForgotPasswordEmail($postdata)
2813 {
2814
2815 // $email = $this->input->get_post('email',TRUE);
2816 $row = $this->db->from('user')->where('email', $postdata)->get()->row();
2817 //echo $this->db->last_query();
2818
2819 if (count($row) > 0) {
2820
2821 $temp_pass = md5(uniqid());
2822
2823
2824 $this->session->set_userdata('temp_pass', $temp_pass);
2825
2826
2827 $tstamp = $_SERVER["REQUEST_TIME"];
2828
2829
2830 $message = "Hello " . $row->first_name . " " . $row->last_name . ",";
2831
2832
2833 $message .= "<br/>";
2834
2835
2836 $message .= "<br/>";
2837
2838
2839 $message .= "Hope you are doing great..!!";
2840
2841
2842 $message .= "<br/>";
2843
2844
2845 $message .= "<br/>";
2846
2847
2848 $message .= "You recently requested to reset your password for your Girlfriends' app account. click the button below to reset it.";
2849
2850
2851 $message .= "<br/>";
2852
2853
2854 $message .= "<br/>";
2855
2856
2857 $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "admin/resetPassword/" . $this->session->userdata('temp_pass') . "/" . $tstamp . "'>Reset Your Password</a>";
2858
2859
2860 $message .= "<br/>";
2861
2862
2863 $message .= "<br/>";
2864
2865
2866 $message .= "If you did not request a password reset, you can safely ignore this email. Only a person with access to your email can reset your account password.";
2867
2868
2869 $message .= "<br/>";
2870
2871
2872 $message .= "This password reset is only valid for the next 24 hours.";
2873
2874
2875 $message .= "<br/>";
2876
2877
2878 $message .= "<br/>";
2879
2880
2881 $message .= "Thank you,";
2882
2883
2884 $message .= "<br/>";
2885
2886
2887 $message .= "Girlfriends' GiftBox Team";
2888
2889
2890 $this->load->library('email');
2891
2892
2893 $this->email->set_newline("\r\n");
2894
2895
2896 $this->email->set_mailtype("html");
2897
2898
2899 $this->email->from('noreply@giftbox.com', 'GiftBox');
2900
2901
2902 $this->email->to($row->email);
2903
2904
2905 $this->email->subject('Forgot Password Link');
2906
2907
2908 $this->email->message($message);
2909
2910
2911 if ($this->email->send()) {
2912
2913
2914 $this->db->where('id', $row->id);
2915
2916
2917 //$updatep = $this->db->update('user', array('temp_pass' => $this->session->userdata('temp_pass_ses'), "tstamp" => $tstamp));
2918 $updatep = $this->db->update('user', array('temp_pass' => $this->session->userdata('temp_pass'), "tstamp" => $tstamp));
2919
2920 if ($updatep) {
2921
2922 $msg = "Please check your email.";
2923
2924 return array('msg' => $msg, 'resp' => 'success');
2925 }
2926
2927 } else {
2928
2929 $msg = "Email does not send.";
2930
2931 return array('msg' => $msg, 'resp' => 'error');
2932 }
2933
2934 } else {
2935
2936 $msg = "Email does not found";
2937
2938 return array('msg' => $msg, 'resp' => 'error');
2939
2940 }
2941 }
2942
2943
2944 // function sendFriendRequestEmail($email = '') {
2945
2946 // $user_id = $this->input->get_post('user_id', TRUE);
2947
2948 // $email = $this->input->get_post('email', TRUE);
2949
2950 // // $rowArr = $this->db->get_where('friends', array('email' => $this->input->get_post('email', TRUE)))->result();
2951
2952 // // if (count($rowArr) > 0) {
2953
2954 // // $data['status'] = "failure";
2955
2956 // // $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
2957
2958 // // $msg = $this->input->get_post('email', TRUE) . " email address already exists!";
2959
2960 // // return array('msg' => $msg, 'resp' => 'success');
2961
2962
2963 // // }else{
2964
2965 // $message .= "Hi !";
2966
2967 // $message .="<br/>";
2968
2969 // $message .="<br/>";
2970
2971 // $message .= "I just downloaded a fabulous app called My Girlfriends Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out";
2972
2973 // $message .="<br/>";
2974
2975 // $message .="<br/>";
2976
2977 // // $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "admin/reqestAccept"."'>Request Accept</a>";
2978
2979
2980 // $message .="<br/>";
2981
2982 // $message .="Thank you,";
2983
2984 // $message .="<br/>";
2985
2986 // $message .="Regards Gf GiftBox Team";
2987
2988 // $this->load->library('email');
2989
2990 // $this->email->set_newline("\r\n");
2991
2992 // $this->email->set_mailtype("html");
2993
2994 // $this->email->from('krunal@cannydoer.com', 'GiftBox');
2995
2996 // // $this->email->to($row->email);
2997 // $this->email->to($email);
2998
2999 // $this->email->subject('Friend Request Accept');
3000
3001 // $this->email->message($message);
3002
3003 // if ($this->email->send()) {
3004
3005 // // $this->db->where('id', $row->id);
3006
3007 // // $updatep = $this->db->update('user', array('temp_pass' => $this->session->userdata('temp_pass_ses'), "tstamp" => $tstamp));
3008 // //return array('msg' => $msg, 'resp' => 'mail send');
3009 // //$login_user_id = $this->input->get_post('email', TRUE);
3010
3011 // // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
3012 // // if(count($checkUserAndFriendsId) > 0){
3013 // // $data['status'] = "failure";
3014 // // $data['message'] = "request already send";
3015 // // }else{
3016
3017 // $checkUserId = $this->db->get_where('user',array('id' => $user_id))->row();
3018 // $login_user_email = $checkUserId->email;
3019
3020 // $email = $this->input->get_post('email', TRUE);
3021 // $insert_Array = array(
3022 // 'email' => $email,
3023 // 'user_id' => $user_id,
3024 // 'created_date' => date('Y-m-d H:i:s')
3025 // );
3026 // $insert_data = $this->db->insert('friends',$insert_Array);
3027 // $insert_id = $this->db->insert_id();
3028
3029 // $getLastRecord = $this->db->get_where('friends',array('id' => $insert_id))->row();
3030 // $get_email = $getLastRecord->email;
3031 // $get_user_id = $getLastRecord->user_id;
3032
3033 // $checkemail = $this->db->get_where('user',array('email' => $get_email))->row();
3034 // $get_id = $checkemail->id;
3035 // $get_user_email = $checkemail->email;
3036
3037 // $updateArr = array(
3038 // 'friend_id' => $get_id,
3039 // );
3040 // $this->db->where('id',$insert_id);
3041 // $this->db->update('friends',$updateArr);
3042
3043 // // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
3044
3045 // //print_r($checkUserAndFriendsId);exit;
3046
3047 // $friendsArr = array(
3048 // 'user_id' => $get_id,
3049 // 'friend_id' => $get_user_id,
3050 // 'email' => $login_user_email,
3051 // 'created_date' => date('Y-m-d H:i:s')
3052 // );
3053
3054
3055 // $this->db->insert('friends',$friendsArr);
3056
3057
3058 // $paymentData = array(
3059 // 'user_id' => $get_user_id,
3060 // 'friend_id' =>$get_id,
3061 // 'payment_status' => 0,
3062 // 'create_date' => date('Y-m-d H:i:s')
3063 // );
3064 // $insertPaymentData = $this->db->insert('payment',$paymentData);
3065 // // }
3066 // // if ($updatep) {
3067
3068 // $msg = "Please check your email.";
3069
3070 // return array('msg' => $msg, 'resp' => 'success');
3071 // // }
3072 // } else {
3073
3074 // $msg = "Email does not send.";
3075
3076 // return array('msg' => $msg, 'resp' => 'error');
3077 // }
3078 // // }
3079 // //}
3080 // // else {
3081
3082 // // $msg = "Email does not found";
3083
3084 // // return array('msg' => $msg, 'resp' => 'error');
3085 // // }
3086
3087 // }
3088
3089 function sendFriendRequestEmail2($postdata)
3090 {
3091
3092 $user_id = $postdata['user_id'];
3093
3094 $email = $postdata['email'];
3095
3096 $rowArr = $this->db->get_where('user', array('email' => $email))->result();
3097
3098 if (count($rowArr) > 0) {
3099
3100 // $data['status'] = "failure";
3101
3102 // $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
3103
3104 // $msg = $this->input->get_post('email', TRUE) . " email address already exists!";
3105
3106 // return array('msg' => $msg, 'resp' => 'success');
3107
3108 $checkEmail = $this->db->get_where('friends', array('email' => $email))->row();
3109
3110 if (count($checkEmail) > 0) {
3111
3112 $getuserEmail = $this->db->get_where('user', array('email' => $email))->row();
3113 $getUserId = $getuserEmail->id;
3114
3115
3116 $friendsRequestCheck = $this->db->get_where('friends', array('user_id' => $user_id, 'friend_id' => $getUserId))->result();
3117 if (count($friendsRequestCheck) > 0) {
3118
3119 //$msg = "This email address already register as friend";
3120 $msg = "friends is already added";
3121 return array('msg' => $msg, 'resp' => 'failure');
3122 } else {
3123 $checkUserId = $this->db->get_where('user', array('id' => $user_id))->row();
3124 $login_user_email = $checkUserId->email;
3125 $first_name = $checkUserId->first_name;
3126 $last_name = $checkUserId->last_name;
3127
3128 $email = $this->input->get_post('email', TRUE);
3129
3130 $insertUserData = array(
3131 'email' => $email,
3132 );
3133
3134 //$this->db->insert('user',$insertUserData);
3135
3136 $insert_Array = array(
3137 'email' => $email,
3138 'user_id' => $user_id,
3139 'created_date' => date('Y-m-d H:i:s')
3140 );
3141 $insert_data = $this->db->insert('friends', $insert_Array);
3142 $insert_id = $this->db->insert_id();
3143
3144 $getLastRecord = $this->db->get_where('friends', array('id' => $insert_id))->row();
3145 $get_email = $getLastRecord->email;
3146 $get_user_id = $getLastRecord->user_id;
3147
3148 $checkemail = $this->db->get_where('user', array('email' => $get_email))->row();
3149
3150 $get_id = $checkemail->id;
3151 $get_user_email = $checkemail->email;
3152 $get_name = $checkemail->first_name;
3153
3154 $updateArr = array(
3155 'friend_id' => $get_id,
3156 );
3157 $this->db->where('id', $insert_id);
3158 $this->db->update('friends', $updateArr);
3159
3160 // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
3161
3162 //print_r($checkUserAndFriendsId);exit;
3163
3164 $friendsArr = array(
3165 'user_id' => $get_id,
3166 'friend_id' => $get_user_id,
3167 'email' => $login_user_email,
3168 'created_date' => date('Y-m-d H:i:s')
3169 );
3170
3171
3172 $this->db->insert('friends', $friendsArr);
3173
3174
3175 $paymentData = array(
3176 'user_id' => $get_user_id,
3177 'friend_id' => $get_id,
3178 'payment_status' => 0,
3179 'created_date' => date('Y-m-d H:i:s')
3180 );
3181 $insertPaymentData = $this->db->insert('payment', $paymentData);
3182
3183
3184 // $message = "Hi !";
3185
3186 $message = "Hello " . $get_name;
3187
3188 $message .= "<br/>";
3189
3190 $message .= "<br/>";
3191
3192 $message .= $first_name . " " . $last_name . " " . " " . "friends request send";
3193
3194 $message .= "<br/>";
3195
3196 $message .= "<br/>";
3197
3198 $message .= "I just downloaded a fabulous app called My Girlfriends Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out.";
3199
3200 $message .= "<br/>";
3201
3202 $message .= "<br/>";
3203
3204
3205 //$message .= "<a href="www.facebook"</a>";
3206 $message .= "To get started simply download the <a href='https://itunes.apple.com'>Girl Friend Application</a>";
3207
3208 $message .= "<br/>";
3209
3210 $message .= "<br/>";
3211
3212 $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "webservice/reqestAccept/$get_user_id/$get_id" . "'>Request Accept</a>";
3213
3214
3215 $message .= "<br/>";
3216
3217 $message .= "<br/>";
3218
3219 $message .= "Thank you,";
3220
3221 $message .= "<br/>";
3222
3223 $message .= "Regards Gf GiftBox Team";
3224
3225 $this->load->library('email');
3226
3227 $this->email->set_newline("\r\n");
3228
3229 $this->email->set_mailtype("html");
3230
3231 $this->email->from('krunal@cannydoer.com', 'GiftBox');
3232
3233 // $this->email->to($row->email);
3234 $this->email->to($email);
3235
3236 $this->email->subject('Friend Request Accept');
3237
3238 $this->email->message($message);
3239
3240 if ($this->email->send()) {
3241
3242 // $checkUserId = $this->db->get_where('user',array('id' => $user_id))->row();
3243 // $login_user_email = $checkUserId->email;
3244
3245 // $email = $this->input->get_post('email', TRUE);
3246
3247 // $insertUserData = array(
3248 // 'email' => $email,
3249 // );
3250
3251 // //$this->db->insert('user',$insertUserData);
3252
3253 // $insert_Array = array(
3254 // 'email' => $email,
3255 // 'user_id' => $user_id,
3256 // 'created_date' => date('Y-m-d H:i:s')
3257 // );
3258 // $insert_data = $this->db->insert('friends',$insert_Array);
3259 // $insert_id = $this->db->insert_id();
3260
3261 // $getLastRecord = $this->db->get_where('friends',array('id' => $insert_id))->row();
3262 // $get_email = $getLastRecord->email;
3263 // $get_user_id = $getLastRecord->user_id;
3264
3265 // $checkemail = $this->db->get_where('user',array('email' => $get_email))->row();
3266 // $get_id = $checkemail->id;
3267 // $get_user_email = $checkemail->email;
3268
3269 // $updateArr = array(
3270 // 'friend_id' => $get_id,
3271 // );
3272 // $this->db->where('id',$insert_id);
3273 // $this->db->update('friends',$updateArr);
3274
3275 // // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
3276
3277 // //print_r($checkUserAndFriendsId);exit;
3278
3279 // $friendsArr = array(
3280 // 'user_id' => $get_id,
3281 // 'friend_id' => $get_user_id,
3282 // 'email' => $login_user_email,
3283 // 'created_date' => date('Y-m-d H:i:s')
3284 // );
3285
3286
3287 // $this->db->insert('friends',$friendsArr);
3288
3289
3290 // $paymentData = array(
3291 // 'user_id' => $get_user_id,
3292 // 'friend_id' =>$get_id,
3293 // 'payment_status' => 0,
3294 // 'created_date' => date('Y-m-d H:i:s')
3295 // );
3296 // $insertPaymentData = $this->db->insert('payment',$paymentData);
3297 // }
3298 // if ($updatep) {
3299
3300 $msg = "Please check your email.";
3301
3302 return array('msg' => $msg, 'resp' => 'success');
3303 // }
3304 } else {
3305 $msg = "Email does not send.";
3306
3307 return array('msg' => $msg, 'resp' => 'error');
3308 }
3309
3310 }
3311 } else {
3312
3313 $checkUserId = $this->db->get_where('user', array('id' => $user_id))->row();
3314 $login_user_email = $checkUserId->email;
3315 $first_name = $checkUserId->first_name;
3316 $last_name = $checkUserId->last_name;
3317 $email = $this->input->get_post('email', TRUE);
3318
3319 $insertUserData = array(
3320 'email' => $email,
3321 );
3322
3323 //$this->db->insert('user',$insertUserData);
3324
3325 $insert_Array = array(
3326 'email' => $email,
3327 'user_id' => $user_id,
3328 'created_date' => date('Y-m-d H:i:s')
3329 );
3330 $insert_data = $this->db->insert('friends', $insert_Array);
3331 $insert_id = $this->db->insert_id();
3332
3333 $getLastRecord = $this->db->get_where('friends', array('id' => $insert_id))->row();
3334 $get_email = $getLastRecord->email;
3335 $get_user_id = $getLastRecord->user_id;
3336
3337 $checkemail = $this->db->get_where('user', array('email' => $get_email))->row();
3338
3339 $get_id = $checkemail->id;
3340 $get_user_email = $checkemail->email;
3341 $get_name = $checkemail->first_name;
3342
3343 $updateArr = array(
3344 'friend_id' => $get_id,
3345 );
3346 $this->db->where('id', $insert_id);
3347 $this->db->update('friends', $updateArr);
3348
3349 // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
3350
3351 //print_r($checkUserAndFriendsId);exit;
3352
3353 $friendsArr = array(
3354 'user_id' => $get_id,
3355 'friend_id' => $get_user_id,
3356 'email' => $login_user_email,
3357 'created_date' => date('Y-m-d H:i:s')
3358 );
3359
3360
3361 $this->db->insert('friends', $friendsArr);
3362
3363
3364 $paymentData = array(
3365 'user_id' => $get_user_id,
3366 'friend_id' => $get_id,
3367 'payment_status' => 0,
3368 'created_date' => date('Y-m-d H:i:s')
3369 );
3370 $insertPaymentData = $this->db->insert('payment', $paymentData);
3371
3372
3373 // $message = "Hi !";
3374 $message = "Hello " . $get_name;
3375
3376 $message .= "<br/>";
3377
3378 $message .= "<br/>";
3379
3380 $message .= $first_name . " " . $last_name . " " . " " . "friends request send";
3381
3382 $message .= "<br/>";
3383
3384 $message .= "<br/>";
3385
3386 $message .= "I just downloaded a fabulous app called My Girlfriends Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out.";
3387
3388 $message .= "<br/>";
3389
3390 $message .= "<br/>";
3391
3392
3393 $message .= "To get started simply download the <a href='https://itunes.apple.com'>Girl Friend Application</a>";
3394
3395 $message .= "<br/>";
3396
3397 $message .= "<br/>";
3398
3399
3400 $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "webservice/reqestAccept/$get_user_id/$get_id" . "'>Request Accept</a>";
3401
3402
3403 // $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "admin/reqestAccept"."'>Request Accept</a>";
3404
3405 $message .= "<br/>";
3406
3407 $message .= "<br/>";
3408
3409 $message .= "<br/>";
3410
3411 $message .= "Thank you,";
3412
3413 $message .= "<br/>";
3414
3415 $message .= "Regards Gf GiftBox Team";
3416
3417 $this->load->library('email');
3418
3419 $this->email->set_newline("\r\n");
3420
3421 $this->email->set_mailtype("html");
3422
3423 $this->email->from('krunal@cannydoer.com', 'GiftBox');
3424
3425 // $this->email->to($row->email);
3426 $this->email->to($email);
3427
3428 $this->email->subject('Friend Request Accept');
3429
3430 $this->email->message($message);
3431
3432 if ($this->email->send()) {
3433
3434 // $this->db->where('id', $row->id);
3435
3436 // $updatep = $this->db->update('user', array('temp_pass' => $this->session->userdata('temp_pass_ses'), "tstamp" => $tstamp));
3437 //return array('msg' => $msg, 'resp' => 'mail send');
3438 //$login_user_id = $this->input->get_post('email', TRUE);
3439
3440 // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
3441 // if(count($checkUserAndFriendsId) > 0){
3442 // $data['status'] = "failure";
3443 // $data['message'] = "request already send";
3444 // }else{
3445
3446
3447 // $checkUserId = $this->db->get_where('user',array('id' => $user_id))->row();
3448 // $login_user_email = $checkUserId->email;
3449
3450 // $email = $this->input->get_post('email', TRUE);
3451
3452 // $insertUserData = array(
3453 // 'email' => $email,
3454 // );
3455
3456 // //$this->db->insert('user',$insertUserData);
3457
3458 // $insert_Array = array(
3459 // 'email' => $email,
3460 // 'user_id' => $user_id,
3461 // 'created_date' => date('Y-m-d H:i:s')
3462 // );
3463 // $insert_data = $this->db->insert('friends',$insert_Array);
3464 // $insert_id = $this->db->insert_id();
3465
3466 // $getLastRecord = $this->db->get_where('friends',array('id' => $insert_id))->row();
3467 // $get_email = $getLastRecord->email;
3468 // $get_user_id = $getLastRecord->user_id;
3469
3470 // $checkemail = $this->db->get_where('user',array('email' => $get_email))->row();
3471 // $get_id = $checkemail->id;
3472 // $get_user_email = $checkemail->email;
3473
3474 // $updateArr = array(
3475 // 'friend_id' => $get_id,
3476 // );
3477 // $this->db->where('id',$insert_id);
3478 // $this->db->update('friends',$updateArr);
3479
3480 // // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
3481
3482 // //print_r($checkUserAndFriendsId);exit;
3483
3484 // $friendsArr = array(
3485 // 'user_id' => $get_id,
3486 // 'friend_id' => $get_user_id,
3487 // 'email' => $login_user_email,
3488 // 'created_date' => date('Y-m-d H:i:s')
3489 // );
3490
3491
3492 // $this->db->insert('friends',$friendsArr);
3493
3494
3495 // $paymentData = array(
3496 // 'user_id' => $get_user_id,
3497 // 'friend_id' =>$get_id,
3498 // 'payment_status' => 0,
3499 // 'created_date' => date('Y-m-d H:i:s')
3500 // );
3501 // $insertPaymentData = $this->db->insert('payment',$paymentData);
3502 // }
3503 // if ($updatep) {
3504
3505 $msg = "Please check your email.";
3506
3507 return array('msg' => $msg, 'resp' => 'success');
3508 // }
3509 } else {
3510
3511 $msg = "Email does not send.";
3512
3513 return array('msg' => $msg, 'resp' => 'error');
3514 }
3515
3516 }
3517 } else {
3518 //$msg = $this->input->get_post('email', TRUE) . " email address already exists!";
3519 $msg = "Mail not found";
3520 return array('msg' => $msg, 'resp' => 'failure');
3521
3522 }
3523
3524 }
3525
3526
3527 function sendFriendRequestEmail($postdata)
3528 {
3529
3530 $user_id = $postdata['user_id'];
3531
3532 $email = $postdata['email'];
3533
3534 $rowArr = $this->db->get_where('user', array('email' => $email))->row();
3535 $id = $rowArr->id;
3536
3537 $resultArr = $this->db->get_where('friends', array('user_id' => $user_id, 'friend_id' => $id, 'user_id' => $id, 'friend_id' => $user_id))->row();
3538
3539
3540 if (count($resultArr) > 0) {
3541
3542 $msg = "freinds is already added";
3543 return array('msg' => $msg, 'resp' => 'success');
3544 } else {
3545 $user_id = $this->input->get_post('user_id', TRUE);
3546 $email = $this->input->get_post('email', TRUE);
3547 $checkEmailArr = $this->db->get_where('user', array('email' => $email))->row();
3548
3549 if (count($checkEmailArr) > 0) {
3550 //echo "if";
3551 $rowuserArr = $this->db->get_where('user', array('email' => $email))->row();
3552 $name = $rowuserArr->first_name;
3553 $first_name = ucfirst($name);
3554 $friend_id = $rowuserArr->id;
3555 $friend_email = $rowuserArr->email;
3556
3557 $resultuserArr = $this->db->get_where('user', array('id' => $user_id))->row();
3558 $user_id = $resultuserArr->id;
3559 $user_email = $resultuserArr->email;
3560 $sender_name = $resultuserArr->first_name;
3561 $username = ucfirst($sender_name);
3562 $message = "Hello " . $first_name . ",";
3563
3564 $message .= "<br/>";
3565
3566 $message .= "<br/>";
3567
3568 $message .= $username . " " . $resultuserArr->last_name . " " . "has sent a friend request";
3569
3570 $message .= "<br/>";
3571
3572 $message .= "<br/>";
3573
3574 $message .= "I just downloaded a fabulous app called My Girlfriends' Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out.";
3575
3576 $message .= "<br/>";
3577
3578 $message .= "<br/>";
3579
3580
3581 //$message .= "<a href="www.facebook"</a>";
3582 $message .= "To get started simply download <a href='https://itunes.apple.com/us/app/my-girl-friends-favourite-gift/id1270615255?ls=1&mt=8'>My Girlfriends' Favorite Gifts application</a>";
3583
3584 $message .= "<br/>";
3585
3586 $message .= "<br/>";
3587
3588 $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "index.php/webservice/reqestAccept/$user_id/$friend_id" . "'>Request Accept</a>";
3589
3590
3591 $message .= "<br/>";
3592
3593 $message .= "<br/>";
3594
3595 $message .= "Thank you,";
3596
3597 $message .= "<br/>";
3598
3599 $message .= "Regards Gf Gift Team";
3600
3601 // $config = Array(
3602 // 'protocol' => 'smtp',
3603 // 'smtp_host' => 'ssl://smtp.googlemail.com',
3604 // 'smtp_port' => '587',
3605 // 'smtp_user' => 'akshay@vnnovate.com',
3606 // 'smtp_pass' => 'akshay@123',
3607 // 'mailtype' => 'html',
3608 // 'charset' => 'iso-8859-1',
3609 // 'wordwrap' => true
3610 // );
3611
3612 $this->load->library('email');
3613 $this->email->initialize();
3614
3615 $this->email->set_newline("\r\n");
3616
3617 $this->email->set_mailtype("html");
3618
3619 $this->email->from('noreply@giftbox.com', 'GiftBox');
3620
3621 // $this->email->to($row->email);
3622 $this->email->to($email);
3623
3624 $this->email->subject('Friend Request Accept');
3625
3626 $this->email->message($message);
3627 // $this->email->send();
3628 // echo $this->email->print_debugger();exit;
3629 if ($this->email->send()) {
3630 // echo $this->email->print_debugger();exit;
3631
3632 // $to = $email;
3633 // $subject = 'Friend Request Accept';
3634 // $headers = 'From: webmaster@example.com' . "\r\n" .
3635 // 'Reply-To: webmaster@example.com' . "\r\n" .
3636 // 'X-Mailer: PHP/' . phpversion();
3637
3638 // $mail = mail($to, $subject, $message, $headers);
3639 // if($mail){
3640 //insert the user data in freind table
3641 $UserData = array(
3642 'user_id' => $user_id,
3643 'friend_id' => $friend_id,
3644 'email' => $friend_email,
3645 'created_date' => date('Y-m-d H:i:s')
3646 );
3647 $this->db->insert('friends', $UserData);
3648 //end
3649
3650 //insert freinds data in friend table
3651 $FriendData = array(
3652 'user_id' => $friend_id,
3653 'friend_id' => $user_id,
3654 'email' => $user_email,
3655 'created_date' => date('Y-m-d H:i:s')
3656 );
3657 $this->db->insert('friends', $FriendData);
3658 //end
3659
3660 //payment data insert in payment table
3661 $paymentData = array(
3662 'user_id' => $user_id,
3663 'friend_id' => $friend_id,
3664 'payment_status' => 0,
3665 'created_date' => date('Y-m-d H:i:s')
3666 );
3667 $this->db->insert('payment', $paymentData);
3668 //end
3669
3670
3671 $msg = "send a mail freind's email id.";
3672 return array('msg' => $msg, 'resp' => 'success');
3673 } else {
3674 $msg = "Email does not send.";
3675 return array('msg' => $msg, 'resp' => 'error');
3676 }
3677
3678
3679 } else {
3680
3681 $user_id = $this->input->get_post('user_id', TRUE);
3682 $email = $this->input->get_post('email', TRUE);
3683
3684 $resultuserArr = $this->db->get_where('user', array('id' => $user_id))->row();
3685 $from_email = $resultuserArr->email;
3686
3687 $insertEmailId = array(
3688 'from_email' => $from_email,
3689 'from_id' => $user_id,
3690 'to_email' => $email
3691 );
3692 $insertEmail = $this->db->insert('friend_invites', $insertEmailId);
3693 $insert_id = $this->db->insert_id();
3694
3695 // $rowuserArr = $this->db->get_where('friend_invites', array('email' => $email))->row();
3696
3697 // $friend_id = $rowuserArr->id;
3698
3699
3700 $resultuserArr = $this->db->get_where('user', array('id' => $user_id))->row();
3701 $userEmail = $resultuserArr->email;
3702 $user_id = $resultuserArr->id;
3703 $first_name = $resultuserArr->first_name;
3704 $name = ucfirst($first_name);
3705
3706 $message = "Hello Friend,";
3707
3708 $message .= "<br/>";
3709
3710 $message .= "<br/>";
3711
3712 $message .= $name . " " . $resultuserArr->last_name . " " . "has sent a friend request";
3713
3714 $message .= "<br/>";
3715
3716 $message .= "<br/>";
3717
3718 $message .= "I just downloaded a fabulous app called My Girlfriends' Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out.";
3719
3720 $message .= "<br/>";
3721
3722 $message .= "<br/>";
3723
3724 //$message .= "<a href="www.facebook"</a>";
3725 $message .= "To get started simply download <a href='https://itunes.apple.com/us/app/my-girl-friends-favourite-gift/id1270615255?ls=1&mt=8'>My Girlfriends' Favorite Gifts application</a>";
3726
3727
3728 $message .= "<br/>";
3729
3730 $message .= "<br/>";
3731
3732 $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "index.php/webservice/reqestAccept/$user_id/$insert_id" . "'>Accept Request</a>";
3733
3734
3735 $message .= "<br/>";
3736
3737 $message .= "<br/>";
3738
3739 $message .= "Thank you";
3740
3741 $message .= "<br/>";
3742
3743 $message .= "Regards Gf Gift Team";
3744
3745 // $config = Array(
3746 // 'protocol' => 'smtp',
3747 // 'smtp_host' => 'ssl://smtp.googlemail.com',
3748 // 'smtp_port' => '465',
3749 // 'smtp_user' => 'akshay@vnnovate.com',
3750 // 'smtp_pass' => 'akshay@123',
3751 // 'mailtype' => 'html',
3752 // 'charset' => 'iso-8859-1',
3753 // 'wordwrap' => true
3754 // );
3755
3756 $this->load->library('email');
3757
3758 $this->email->initialize();
3759
3760 $this->email->set_newline("\r\n");
3761
3762 $this->email->set_mailtype("html");
3763
3764 $this->email->from('noreply@giftbox.com', 'GiftBox');
3765
3766 // $this->email->to($row->email);
3767 $this->email->to($email);
3768
3769 $this->email->subject('Friend Request Accept');
3770
3771 $this->email->message($message);
3772 // $this->email->send();
3773 // echo $this->email->print_debugger();exit;
3774
3775 if ($this->email->send()) {
3776 // echo $this->email->print_debugger();exit;
3777
3778 // $to = $email;
3779 // $subject = 'Friend Request Accept';
3780 // $headers = 'From: webmaster@example.com' . "\r\n" .
3781 // 'Reply-To: webmaster@example.com' . "\r\n" .
3782 // 'X-Mailer: PHP/' . phpversion();
3783
3784 // $mail = mail($to, $subject, $message, $headers);
3785
3786 // if ($mail) {
3787
3788 //fetch last inserted record in user table
3789 $getLastRecord = $this->db->get_where('friend_invites', array('id' => $insert_id))->row();
3790
3791 $frined_email = $getLastRecord->email;
3792 $frined_id = $getLastRecord->id;
3793 //end
3794
3795 //insert the user data in freind table
3796 // $UserData = array(
3797 // 'user_id' => $user_id,
3798 // 'friend_id' => $frined_id,
3799 // 'email' => $frined_email,
3800 // 'created_date' => date('Y-m-d H:i:s')
3801 // );
3802 // $this->db->insert('friends',$UserData);
3803 //end
3804
3805 //insert freinds data in friend table
3806 // $FriendData = array(
3807 // 'user_id' => $frined_id,
3808 // 'friend_id' => $user_id,
3809 // 'email' => $userEmail,
3810 // 'created_date' => date('Y-m-d H:i:s')
3811 // );
3812 // $this->db->insert('friends',$FriendData);
3813 //end
3814
3815 //payment data insert in payment table
3816 // $paymentData = array(
3817 // 'user_id' => $user_id,
3818 // 'friend_id' => $frined_id,
3819 // 'payment_status' => 0,
3820 // 'created_date' => date('Y-m-d H:i:s')
3821 // );
3822 // $this->db->insert('payment',$paymentData);
3823 //end
3824
3825 $msg = "send a mail freind's email id.";
3826 return array('msg' => $msg, 'resp' => 'success');
3827 } else {
3828 $msg = "Mail Does Not Send.";
3829 return array('msg' => $msg, 'resp' => 'failure');
3830 }
3831 }
3832 }
3833 }
3834
3835
3836 public function reqestAccept($user_id, $friend_id)
3837 {
3838
3839 $user_id = $this->uri->segment(3);
3840 $friend_id = $this->uri->segment(4);
3841 $frid = $this->uri->segment(5);
3842
3843 //check frined id in user table
3844 $chechUserId = $this->db->get_where('user', array('id' => $friend_id))->row();
3845
3846 $first_name = $chechUserId->first_name;
3847 if ($first_name == "") {
3848
3849 redirect('admin/registration');
3850 } //end
3851 else {
3852
3853 $checkUserFriendId = $this->db->get_where('friends', array('user_id' => $user_id, 'friend_id' => $friend_id))->row();
3854
3855
3856 //get user_id in friend table
3857
3858 $get_send_user_id = $checkUserFriendId->id;
3859
3860 $upate_user_array = array(
3861 'status' => 1
3862 );
3863 $this->db->where('id', $get_send_user_id);
3864 $this->db->update('friends', $upate_user_array);
3865
3866 $checkFriendsId = $this->db->get_where('friends', array('user_id' => $friend_id, 'friend_id' => $user_id))->row();
3867 //end
3868
3869 //get friend_id in friend table
3870 $get_user_friend_id = $checkFriendsId->id;
3871
3872 $update_friends_array = array(
3873 'status' => 1
3874 );
3875 $this->db->where('id', $get_user_friend_id);
3876 $this->db->update('friends', $update_friends_array);
3877 //end
3878 redirect('webservice/itunesPage');
3879 }
3880
3881 }
3882
3883 public function itunesPage()
3884 {
3885
3886 $myurl = "https://itunes.apple.com/us/app/my-girl-friends-favourite-gift/id1270615255?ls=1&mt=8";
3887 redirect($myurl);
3888 }
3889
3890 public function editTrainerProfile()
3891 {
3892
3893 if ($this->input->get_post('trainer_id', TRUE)) {
3894
3895 $trainer_id = "";
3896
3897 $first_name = "";
3898
3899 $last_name = "";
3900
3901 $business_name = "";
3902
3903 $gender = "";
3904
3905 $dob = "";
3906
3907 $email = "";
3908
3909 $credit_card = "";
3910
3911 $credit_card_exp = "";
3912
3913 $credit_card_csv = "";
3914
3915 $password = "";
3916
3917
3918 if ($this->input->get_post('trainer_id', TRUE)) {
3919
3920 $trainer_id = $this->input->get_post('trainer_id', TRUE);
3921
3922 }
3923
3924 if ($this->input->get_post('first_name', TRUE)) {
3925
3926 $first_name = $this->input->get_post('first_name', TRUE);
3927
3928 }
3929
3930 if ($this->input->get_post('last_name', TRUE)) {
3931
3932 $last_name = $this->input->get_post('last_name', TRUE);
3933
3934 }
3935
3936 if ($this->input->get_post('business_name', TRUE)) {
3937
3938 $business_name = $this->input->get_post('business_name', TRUE);
3939
3940 }
3941
3942 if ($this->input->get_post('gender', TRUE)) {
3943
3944 $gender = $this->input->get_post('gender', TRUE);
3945
3946 }
3947
3948 if ($this->input->get_post('dob', TRUE)) {
3949
3950 $dob = $this->input->get_post('dob', TRUE);
3951
3952 }
3953
3954 if ($this->input->get_post('email', TRUE)) {
3955
3956 $email = $this->input->get_post('email', TRUE);
3957
3958 }
3959
3960 if ($this->input->get_post('credit_card', TRUE)) {
3961
3962 $credit_card = $this->input->get_post('credit_card', TRUE);
3963
3964 }
3965
3966 if ($this->input->get_post('credit_card_exp', TRUE)) {
3967
3968 $credit_card_exp = $this->input->get_post('credit_card_exp', TRUE);
3969
3970 }
3971
3972 if ($this->input->get_post('credit_card_csv', TRUE)) {
3973
3974 $credit_card_csv = $this->input->get_post('credit_card_csv', TRUE);
3975
3976 }
3977
3978 $password = base64_encode($this->input->get_post('password', TRUE));
3979
3980
3981 $updArr = array(
3982
3983 'first_name' => $first_name,
3984
3985 'last_name' => $last_name,
3986
3987 'business_name' => $business_name,
3988
3989 'gender' => $gender,
3990
3991 'dob' => $dob,
3992
3993 'email' => $email,
3994
3995 'password' => $password,
3996
3997 'credit_card' => $credit_card,
3998
3999 'credit_card_exp' => $credit_card_exp,
4000
4001 'credit_card_csv' => $credit_card_csv
4002
4003 );
4004
4005
4006 $this->db->where('id', $trainer_id);
4007
4008
4009 if ($this->db->update('trainer', $updArr)) {
4010
4011 $data['status'] = "success";
4012
4013 $data['message'] = "Trainer Profile updated successfully.";
4014
4015 } else {
4016
4017 $data['status'] = "failure";
4018
4019 $data['message'] = "Trainer Profile not updated.";
4020
4021 }
4022
4023
4024 } else {
4025
4026
4027 $data['status'] = "failure";
4028
4029
4030 $data['message'] = "Please enter trainer id";
4031
4032
4033 }
4034
4035
4036 return $data;
4037
4038
4039 }
4040
4041
4042 public function normaliseArray($arr, $recurse = True)
4043 {
4044
4045
4046 if (!is_array($arr))
4047
4048 return $arr;
4049
4050
4051 if (count(array_filter(array_keys($arr), 'is_numeric')) == count($arr))
4052
4053 $arr = array_values($arr);
4054
4055
4056 if ($recurse) {
4057
4058
4059 foreach ($arr as $k => $a) {
4060
4061
4062 $arr[$k] = $this->normaliseArray($a, $recurse);
4063
4064 }
4065
4066 }
4067
4068
4069 return $arr;
4070
4071 }
4072
4073}