· 7 years ago · May 28, 2018, 04:32 AM
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3/**
4 *
5 * User related functions
6 * @author Teamtweaks
7 *
8 **/
9
10class User extends MY_Controller {
11
12 function __construct(){
13 parent::__construct();
14 $this->load->helper(array('cookie','date','form','email','jne','jne_helper','fcm_chat'));
15 $this->load->library(array('encrypt','form_validation'));
16 $this->load->library('session');
17 //$this->load->helper('jne');
18 $this->load->model(array('user_model','product_model','seller_model','product_attribute_model', 'api/v2/user_model_api', 'finance_model', 'api/v2/message_model_api'));
19 $this->load->model(['api/v2/nicepay_model_api']);
20 $this->data['loginCheck'] = $this->checkLogin('U');
21 $this->data['likedProducts'] = array();
22 if ($this->data['loginCheck'] != ''){
23 $this->data['likedProducts'] = $this->product_model->get_all_details(PRODUCT_LIKES,array('user_id'=>$this->checkLogin('U')));
24 }
25
26
27 }
28
29 /**
30 *
31 * Function for quick signup
32 */
33 public function quickSignup(){
34 $email = $this->input->post('email');
35 $returnStr['success'] = '0';
36 if (valid_email($email)){
37 $condition = array('email'=>$email);
38 $duplicateMail = $this->user_model->get_all_details(USERS,$condition);
39 if ($duplicateMail->num_rows()>0){
40 $returnStr['msg'] = 'Email id already exists';
41 }else {
42 $fullname = substr($email, 0,strpos($email, '@'));
43 $checkAvail = $this->user_model->get_all_details(USERS,array('user_name'=>$fullname));
44 if ($checkAvail->num_rows()>0){
45 $avail = FALSE;
46 }else {
47 $avail = TRUE;
48 $username = $fullname;
49 }
50 while (!$avail){
51 $username = $fullname.rand(1111, 999999);
52 $checkAvail = $this->user_model->get_all_details(USERS,array('user_name'=>$username));
53 if ($checkAvail->num_rows()>0){
54 $avail = FALSE;
55 }else {
56 $avail = TRUE;
57 }
58 }
59 if ($avail){
60 $pwd = $this->get_rand_str('6');
61 $this->user_model->insertUserQuick($fullname,$username,$email,$pwd);
62 $this->session->set_userdata('quick_user_name',$email);
63 $returnStr['msg'] = 'Successfully registered';
64 $returnStr['full_name'] = $fullname;
65 $returnStr['user_name'] = $username;
66 $returnStr['password'] = $pwd;
67 $returnStr['email'] = $email;
68 $returnStr['success'] = '1';
69 }
70 }
71 }else {
72 $returnStr['msg'] = "Invalid email id";
73 }
74 echo json_encode($returnStr);
75 }
76
77 /**
78 *
79 * Function for quick signup update
80 */
81 public function quickSignupUpdate(){
82 $returnStr['success'] = '0';
83 $unameArr = $this->config->item('unameArr');
84 $username = $this->input->post('username');
85 if (!preg_match('/^\w{1,}$/', trim($username))){
86 $returnStr['msg'] = 'User name not valid. Only alphanumeric allowed';
87 }elseif (in_array($username, $unameArr)){
88 $returnStr['msg'] = 'User name already exists';
89 }else {
90 $email = $this->input->post('email');
91 $condition = array('user_name'=>$username,'email !='=>$email);
92 $duplicateName = $this->user_model->get_all_details(USERS,$condition);
93 if ($duplicateName->num_rows()>0){
94 $returnStr['msg'] = 'Username already exists';
95 }else {
96 $pwd = $this->input->post('password');
97 $fullname = $this->input->post('fullname');
98 $this->user_model->updateUserQuick($fullname,$username,$email,$pwd);
99 $this->session->set_userdata('quick_user_name',$email);
100 $returnStr['msg'] = 'Successfully registered';
101 $returnStr['success'] = '1';
102 }
103 }
104 echo json_encode($returnStr);
105 }
106
107 /**
108 *
109 * Send the register mail confirmation
110 *
111 */
112 public function send_quick_register_mail(){
113
114 if ($this->checkLogin('U') != ''){
115 redirect(base_url());
116 }else {
117 $quick_user_name = $this->session->userdata('quick_user_name');
118 if ($quick_user_name == ''){
119 redirect(base_url());
120 }else {
121 $condition = array('email'=>$quick_user_name);
122 $userDetails = $this->user_model->get_all_details(USERS,$condition);
123 if ($userDetails->num_rows() == 1){
124 $this->send_confirm_mail($userDetails);
125 $this->login_after_signup($userDetails);
126
127 $this->session->set_userdata('quick_user_name','');
128 if ($userDetails->row()->is_brand == 'yes'){
129 redirect(base_url().'create-brand');
130 }else {
131 $this->setErrorMessage('success','You are sucessfully Registered!!!');
132
133 redirect(base_url());
134 }
135 }else {
136 redirect(base_url());
137 }
138 }
139 }
140 }
141
142
143 /**
144 *
145 * Send the register mail confirmation
146 *
147 */
148 public function send_register_mail(){
149
150 if ($this->checkLogin('U') != ''){
151 redirect(base_url());
152 }else {
153 $email = $this->session->userdata('shopsy_session_user_email');
154 if ($email == ''){
155 redirect(base_url());
156 }else {
157 $condition = array('email'=>$email);
158 $userDetails = $this->user_model->get_all_details(USERS,$condition);
159 ###echo "<pre>"; print_r($userDetails); die;
160 if ($userDetails->num_rows() == 1){
161 $this->send_confirm_mail($userDetails);
162 $this->login_after_signup($userDetails);
163
164 $this->session->set_userdata('shopsy_session_user_email','');
165 }else {
166 redirect(base_url());
167 }
168 }
169 }
170 }
171
172 /**
173 *
174 * Post the feedback for products
175 * Confirm Shipp
176 */
177 public function feedback(){
178 //echo"<pre>";print_r($this->input->post());die;
179
180 $voter_id = $this->input->post('user_id');
181 $shop_id = $this->input->post('shop_id');
182 $seller_product_id = $this->input->post('product_id');
183
184 $deal_code = $this->input->post('deal_code');
185 $description = trim($this->input->post('description'));
186 $rating = $this->input->post('rating');
187 $status = "Active";
188 $title = $this->input->post('title');
189
190
191 /*$orderDetails = $this->user_model->get_all_details(USER_PAYMENT,array('dealCodeNumber'=>$deal_code));
192 $trackingID = $orderDetails->row()->trackingId;
193
194 $userDetails = $this->user_model->get_all_details(USERS,array('id'=>$voter_id));
195 $username = $userDetails->row()->full_name;
196
197
198 //echo $username;exit;
199 //echo '<pre>';print_r($userDetails->row());exit;
200
201 $param = array(
202 'SupplierKey=BJhJf4HALx2UHMo8dK1diKOqk8CYSoFb',
203 'OrderID='.$deal_code,
204 'DeliveryDate='.rawurlencode(date("Y-m-d G:i:s")),
205 'AWBNumber='.rawurlencode($trackingID),
206 'ReceiverName='.rawurlencode($username)
207 );
208
209 //echo '<pre>';print_r($param);exit;
210 $params = implode('&',$param);
211
212 $link = 'http://118.97.199.18:94/ecommerce/ahloo.asmx/DeliveryOrder?'.$params;
213 //$link = 'http://118.97.199.18:94/sandbox/ahloo.asmx/DeliveryOrder?'.$params;
214
215 //echo '<pre>'. $link;exit;
216 $homepage = file_get_contents($link);
217 $req = new SimpleXMLElement($homepage);
218
219 //echo '<pre>';print_r($req);exit;
220 //echo $req->Status;exit;
221 //echo $req->Status[0]->__toString();exit;
222
223 if($req->Status[0]->__toString()=='0')
224 {
225 //$content = "Shiping Id : ".$orderDetails->row()->trackingId."<br>";
226 }
227 else
228 {
229 //echo $req->Status[0]->__toString();exit;
230 $this->setErrorMessage('Error',"Server Error (".$req->Description[0]->__toString()."), please try again later or contact the administrator...");
231 header('Location: ' . $_SERVER['HTTP_REFERER']);
232 exit;
233 }*/
234
235
236 if(trim($this->input->post('old_msg')) !=$description || $this->input->post('old_rating') !=$rating )
237 {
238 $status="Active";
239 }
240
241 $dataArray = array(
242 'voter_id' => $voter_id,
243 'shop_id' => $shop_id,
244 'seller_product_id'=>$seller_product_id,
245 'deal_code'=>$deal_code,
246 'description' => $description,
247 'rating' => $rating,
248 'status'=>$status,
249 'title'=>$title
250 );
251
252
253 if($voter_id!='')
254 {
255 if($this->input->post("mode")==''){
256
257 $this->user_model->simple_insert(PRODUCT_FEEDBACK, $dataArray);
258 $lastIid = $this->db->insert_id();
259 $activity = "review";
260
261 /*Push Message Starts*/
262 //$message=$this->session->set_userdata('shopsy_session_user_name','').' has rated you item on '.$this->config->item('email_title');
263 $message = $this->session->userdata('shopsy_session_user_name').' has rated you item on '.$this->config->item('email_title');
264 $type = 'review';
265 $this->sendPushNotification($shop_id, $message, $type, array($lastIid,$voter_id));
266 /*Push Message Ends*/
267
268 $condition = array(
269 'id' => $seller_product_id
270 );
271 $product = $this->user_model->get_all_details(PRODUCT, $condition)->row();
272
273 $dataArr = array(
274 'list_value' => $product->list_value + $rating,
275 'comment_count' => $product->comment_count + 1
276 );
277
278 $this->user_model->update_details(PRODUCT, $dataArr, $condition);
279 $this->user_model->update_details(PRODUCT_ID, $dataArr, $condition);
280
281
282 }else if($this->input->post("mode")!=''){
283 $dataArr = array('description'=>$description,'rating' => $rating);
284 $condition = array('id'=>$this->input->post("mode"));
285 $this->user_model->update_details(PRODUCT_FEEDBACK,$dataArr,$condition);
286 $lastIid=$this->input->post("mode");
287 $activity="review-update";
288 }
289
290 $actArr = array(
291 'activity'=>$activity,
292 'activity_id'=>$shop_id,
293 'user_id' =>$voter_id,
294 'activity_ip'=>$this->input->ip_address(),
295 'created'=>date("Y-m-d H:i:s"),
296 'comment_id'=>$lastIid
297 );
298 $this->user_model->simple_insert(NOTIFICATIONS, $actArr);
299
300 $query = "SELECT AVG(rating) as shop_ratting, COUNT(*) as review_count FROM ".PRODUCT_FEEDBACK." WHERE status='Active' and shop_id=".$shop_id;
301 $shop_ratting = $this->user_model->ExecuteQuery($query)->row();
302 $ratting = round($shop_ratting->shop_ratting, 2);
303 $review_count = $shop_ratting->review_count;
304 $condition = array('seller_id' => $shop_id);
305 $dataArr = array('shop_ratting' => $ratting, 'review_count' => $review_count);
306 $this->user_model->update_details(SELLER, $dataArr, $condition);
307 }
308 //redirect($base_url.'view-order/'.$voter_id.'/'.$deal_code);
309 $this->setErrorMessage('success',"Review berhasil ditambahkan, terimakasih");
310 redirect('purchase-review');
311 }
312
313 /**
314 *
315 * To register the new user
316 *
317 */
318 public function registerUser()
319 {
320 $returnStr['success'] = '0';
321 $unameArr = $this->config->item('unameArr');
322 $fname = strip_tags($this->input->post('fullname'));
323 $expl_name = explode(' ', $fname);
324
325 $fullname = strip_tags($expl_name[0]);
326 $lastname = strip_tags($expl_name[1]);
327
328 // $lastname = strip_tags($this->input->post('lastname'));
329
330 $gender = $this->input->post('gender');
331 $phone = $this->input->post('phone');
332 $email = $this->input->post('email');
333 $pwd = md5($this->input->post('pwd'));
334 // $Confirmpwd = $this->input->post('Confirmpwd');
335 $username = strip_tags(stripslashes(trim($this->input->post('username'))));
336 $subscription= $this->input->post('subscription');
337
338 if (!preg_match('/^\w{1,}$/', trim($username)))
339 {
340 $returnStr['msg'] = 'User name not valid';
341 }
342 elseif (in_array($username, $unameArr))
343 {
344 $returnStr['msg'] = 'User name already exists';
345 }
346 else
347 {
348 if (valid_email($email))
349 {
350 $condition = array('user_name'=>$username);
351 $duplicateName = $this->user_model->get_all_details(USERS,$condition);
352 if ($duplicateName->num_rows()>0)
353 {
354 $returnStr['msg'] = 'User name already exists';
355 }
356 else
357 {
358 $condition = array('email'=>$email);
359 $duplicateMail = $this->user_model->get_all_details(USERS,$condition);
360 if ($duplicateMail->num_rows()>0)
361 {
362 $returnStr['msg'] = 'Email id already exists';
363 }
364 else
365 {
366 $time = time();
367 $aff = $username.$time;
368
369 $dataArr = array('full_name'=>$fullname,'user_name'=>$username,
370 'phone_no'=>$phone,'last_name'=>$lastname,'email'=>$email,
371 'password'=>$pwd,'status'=>'Active','gender'=>$gender,
372 'is_verified'=>'No','commision'=>$this->config->item('product_commission'),
373 'affiliateId'=> $aff,'update_email'=>'Yes',
374 'notification_email'=>'follow,msg,like,lik_of_like,fav_shop');
375
376 $this->user_model->simple_insert(USERS,$dataArr);
377
378 $register_id = $this->db->insert_id();
379
380 /*Create OTP code*/
381 $otp_code = $this->otp_randomString(6);
382 /*Add OTP*/
383 $dataArrOTP = array('user_id'=>$register_id,
384 'email'=>$email,
385 'no_hp'=>$phone,
386 'kode_otp'=>$otp_code
387 );
388
389 $this->user_model->simple_insert(pw_otp,$dataArrOTP);
390 /*End Of OTP*/
391
392 $checkUser = $this->user_model->get_all_details(USERS,array('email'=>$email));
393 //$this->user_model->insertUserQuick($fullname,$username,$lastname,$email,$pwd,$brand);
394
395 $this->session->set_userdata('quick_user_name',$email);
396 $userdata = array(
397 'shopsy_session_user_id' => $checkUser->row()->id,
398 'shopsy_session_user_name' => $checkUser->row()->user_name,
399 'shopsy_session_full_name' => $checkUser->row()->full_name,
400 'shopsy_session_last_name' => $checkUser->row()->last_name,
401 'shopsy_session_user_email' => $checkUser->row()->email,
402 'shopsy_session_user_confirm' => $checkUser->row()->is_verified,
403 'userType'=>$checkUser->row()->group
404 );
405
406 $this->session->set_userdata($userdata);
407 //$this->load->view('site/templates/verification');
408 $userDetails=$checkUser;
409 $this->send_confirm_mail($userDetails);
410
411
412 include('./mailchimp_settings.php');
413
414 if($config['mailchimp_status'] = 'Yes'){
415 $mailchimp = 1;
416 $mail_var=include('./mailchimp/mailchimpapi.php');
417 }
418
419 if($subscription=='on')
420 {
421 $this->subscribeUserRegister($checkUser->row()->email);
422 }
423
424 $returnStr['msg'] = 'Successfully registered';
425 $returnStr['data'] = strtr(base64_encode($email.'#'.$phone), '+/=', '-_-');//base64_encode($email.'#'.$phone);
426 $returnStr['success'] = '1';
427
428 }
429 }
430 }
431 else
432 {
433 $returnStr['msg'] = "Invalid email id";
434 }
435 }
436 if($this->lang->line('acc_registered')!='') { $acc_registered= stripslashes($this->lang->line('acc_registered')); } else $acc_registered ="Your account Registerd with ";
437 $this->setErrorMessage('success',$acc_registered.$this->config->item('email_title'));
438 echo json_encode($returnStr);
439 }
440
441
442 /**
443 *
444 * To subscribe the user register
445 *
446 */
447 public function subscribeUserRegister($email)
448 {
449
450 $checkUser = $this->user_model->get_all_details(SUBSCRIBERS_LIST,array('subscrip_mail'=>$email));
451
452 if($checkUser->num_rows()==0){
453 $condition = array('email'=>$email);
454
455 $randStr = $this->get_rand_str('10');
456 $dataArr = array('subscrip_mail'=>$email,'active'=>0,'status'=>'Active','dateAdded'=>$createdTime,'verification_mail'=>$randStr);
457 $this->user_model->simple_insert(SUBSCRIBERS_LIST,$dataArr);
458 $maxidd = $this->db->insert_id();
459 }
460 }
461
462 /**
463 *
464 * Login to the subscribe user
465 *
466 */
467 public function loginsubscribeUser(){
468 if($this->checkLogin('U')!='') {
469 $email = $this->session->userdata['shopsy_session_user_email'];
470
471 $checkUser = $this->user_model->get_all_details(SUBSCRIBERS_LIST,array('subscrip_mail'=>$email,'status' => 'Active'));
472
473 if($checkUser->num_rows()==0){
474
475 $condition = array('email'=>$email);
476 $datestring = "%Y-%m-%d %h:%i:%s";
477 $time = time();
478 $createdTime = mdate($datestring,$time);
479 $randStr = $this->get_rand_str('10');
480
481
482 $dataArr = array('subscrip_mail'=>$email,'active'=>0,'status'=>'Active','dateAdded'=>$createdTime,'verification_mail'=>$randStr);
483 $this->user_model->simple_insert(SUBSCRIBERS_LIST,$dataArr);
484 $maxidd = $this->db->insert_id();
485
486 $cfmurl = base_url().'site/user/confirm_register_subscribe/'.$maxidd.'/confirmation/'.$randStr;
487 // $cfmurl = base_url().'site/user/confirm_register_subscribe/'.$maxidd."/";
488 //$this->setErrorMessage('success','Thanks for subscribing newsletter !');
489 //redirect(base_url());
490
491 $newsid='16';
492 $template_values=$this->user_model->get_newsletter_template_details($newsid);
493 $subject = 'Newsletter Confirmation From : '.$this->config->item('email_title');
494 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo']);
495 extract($adminnewstemplateArr);
496 $header .="Content-Type: text/plain; charset=ISO-8859-1\r\n";
497
498 $message .= '<!DOCTYPE HTML>
499 <html>
500 <head>
501 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
502 <meta name="viewport" content="width=device-width"/><body>';
503 include('./newsletter/registeration'.$newsid.'.php');
504 $message .= '</body>
505 </html>';
506 //$returnStr['msg'] = 'Successfully registered';
507 //$returnStr['success'] = '1';
508 #echo '<pre>'; print_r($template_values); die;
509 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
510 $sender_email=$this->data['siteContactMail'];
511 $sender_name=$this->data['siteTitle'];
512 }else{
513 $sender_name=$template_values['sender_name'];
514 $sender_email=$template_values['sender_email'];
515 }
516
517 $email_values = array('mail_type'=>'html',
518 'from_mail_id'=>$sender_email,
519 'mail_name'=>$sender_name,
520 'to_mail_id'=>$email,
521 'subject_message'=>$template_values['news_subject'],
522 'body_messages'=>$message
523 );
524 $email_send_to_common = $this->user_model->common_email_send($email_values);
525
526 $this->setErrorMessage('success','Thanks for subscribing newsletter !');
527 //redirect(base_url());
528 redirect(base_url());
529 }
530 else
531 {
532 $this->user_model->commonDelete(SUBSCRIBERS_LIST,array('subscrip_mail' => $email));
533 $this->setErrorMessage('success','You have un subscribed newsletter!!!');
534 //redirect(base_url());
535 redirect(base_url());
536 }
537 }
538 }
539
540
541 /**
542 *
543 * Landing page subscribition option
544 *
545 */
546 public function subscribeUser($type = '')
547 {
548 $email = $this->input->post('emaill');
549
550 if(valid_email($email)){
551 $sel_qry = $this->db->query("SELECT * FROM ".SUBSCRIBERS_LIST." WHERE subscrip_mail='$email' AND type='". $type ."'");
552
553 if($sel_qry->num_rows()==0){
554 $condition = array('email'=>$email);
555 $datestring = "%Y-%m-%d %h:%i:%s";
556 $time = time();
557 $createdTime = mdate($datestring,$time); //exit;
558 $randStr = $this->get_rand_str('10');
559
560 $dataArr = array('subscrip_mail'=>$email,'active'=>0,'status'=>'Active','dateAdded'=>$createdTime,'verification_mail'=>$randStr, 'type' => $type);
561 $this->user_model->simple_insert(SUBSCRIBERS_LIST,$dataArr);
562 $maxidd = $this->db->insert_id();
563
564 $cfmurl = base_url().'site/user/confirm_register_subscribe/'.$maxidd.'/confirmation/'.$randStr;
565
566 $newsid = '16';
567 if ($type == 'popup') {
568 $newsid = '50';
569 }
570
571 $template_values=$this->user_model->get_newsletter_template_details($newsid);
572 $subject = 'From: '.$this->config->item('email_title');
573 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo']);
574 extract($adminnewstemplateArr);
575 $header .="Content-Type: text/plain; charset=ISO-8859-1\r\n";
576
577 $message .= '<!DOCTYPE HTML>
578 <html>
579 <head>
580 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
581 <meta name="viewport" content="width=device-width"/><body>';
582 include('./newsletter/registeration'.$newsid.'.php');
583 $message .= '</body>
584 </html>';
585 //$returnStr['msg'] = 'Successfully registered';
586 //$returnStr['success'] = '1';
587
588 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
589 $sender_email=$this->data['siteContactMail'];
590 $sender_name=$this->data['siteTitle'];
591 }else{
592 $sender_name=$template_values['sender_name'];
593 $sender_email=$template_values['sender_email'];
594 }
595
596 $email_values = array('mail_type'=>'html',
597 'from_mail_id'=>$sender_email,
598 'mail_name'=>$sender_name,
599 'to_mail_id'=>$email,
600 'subject_message'=>$template_values['news_subject'],
601 'body_messages'=>$message
602 );
603 $email_send_to_common = $this->user_model->common_email_send($email_values);
604
605 if ($type == 'popup') {
606
607 $query = $this->db->query("SELECT * FROM ".USERS." WHERE email='$email'");
608 if ($query->num_rows() > 0){
609 $this->setErrorMessage('success','Thanks for subscribing!');
610 redirect(base_url());
611 } else {
612 $this->setErrorMessage('success','Thanks for subscribing!');
613 redirect(base_url().'register');
614 }
615
616 } else {
617 $this->setErrorMessage('success','Thanks for subscribing newsletter !');
618 redirect(base_url());
619 }
620
621 }else{
622 $this->setErrorMessage('error','Email Id Already Exists !');
623 redirect(base_url());
624 }
625 }else{
626 $returnStr['msg'] = "Invalid email id";
627 $this->setErrorMessage('error','Invalid email id !');
628 redirect(base_url());
629 }
630 }
631
632 /**
633 *
634 * Subscribe the user events
635 *
636 */
637 public function subscribeUserEvent()
638 {
639 $email = $this->session->userdata('shopsy_session_user_email');
640
641 if(valid_email($email)){
642 $sel_qry = $this->db->query("SELECT * FROM ".SUBSCRIBERS_LIST." WHERE subscrip_mail='".$email."'");
643
644 if($sel_qry->num_rows()==0){
645 $condition = array('email'=>$email);
646 $datestring = "%Y-%m-%d %h:%i:%s";
647 $time = time();
648 $createdTime = mdate($datestring,$time); //exit;
649 $randStr = $this->get_rand_str('10');
650
651 $dataArr = array('subscrip_mail'=>$email,'active'=>0,'status'=>'Active','dateAdded'=>$createdTime,'verification_mail'=>$randStr);
652 $this->user_model->simple_insert(SUBSCRIBERS_LIST,$dataArr);
653 $maxidd = $this->db->insert_id();
654
655 $cfmurl = base_url().'site/user/confirm_register_subscribe/'.$maxidd.'/confirmation/'.$randStr;
656
657 $newsid='16';
658 $template_values=$this->user_model->get_newsletter_template_details($newsid);
659 $subject = 'From: '.$this->config->item('email_title');
660 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo']);
661 extract($adminnewstemplateArr);
662 $header .="Content-Type: text/plain; charset=ISO-8859-1\r\n";
663
664 $message .= '<!DOCTYPE HTML>
665 <html>
666 <head>
667 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
668 <meta name="viewport" content="width=device-width"/><body>';
669 include('./newsletter/registeration'.$newsid.'.php');
670 $message .= '</body>
671 </html>';
672 //$returnStr['msg'] = 'Successfully registered';
673 //$returnStr['success'] = '1';
674
675 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
676 $sender_email=$this->data['siteContactMail'];
677 $sender_name=$this->data['siteTitle'];
678 }else{
679 $sender_name=$template_values['sender_name'];
680 $sender_email=$template_values['sender_email'];
681 }
682
683 $email_values = array('mail_type'=>'html',
684 'from_mail_id'=>$sender_email,
685 'mail_name'=>$sender_name,
686 'to_mail_id'=>$email,
687 'subject_message'=>$template_values['news_subject'],
688 'body_messages'=>$message
689 );
690 $email_send_to_common = $this->user_model->common_email_send($email_values);
691
692 $this->setErrorMessage('success','Thanks for subscribing newsletter !');
693 redirect(base_url());
694 }else{
695 //echo "asdf";die;
696 $email_exist=addslashes(shopsy_lg('lg_email_exist','Email Id Already Exists '));
697 //echo $email_exist;die;
698 $this->setErrorMessage('error',$email_exist);
699 redirect(base_url());
700 }
701 }else{
702 $returnStr['msg'] = "Invalid email id";
703 $this->setErrorMessage('error','Invalid email id !');
704 redirect(base_url());
705 }
706 }
707
708 /**
709 *
710 * Check the user email exists or not
711 *
712 */
713 public function emailExists($email='')
714 {
715 $condition = array('email'=>$this->input->post('email'));
716 $duplicateName = $this->user_model->get_all_details(USERS,$condition);
717 if ($duplicateName->num_rows()>0){
718 //echo 'exist';
719 $returnStr['msg']=0;
720 }else{
721 //echo 'new';
722 $returnStr['msg']=1;
723 }
724 echo json_encode($returnStr);
725 }
726
727 /**
728 *
729 * Check the user availability
730 *
731 */
732 function check_user_availability()
733 {
734 $emaill = $this->input->post('emaill');
735 //$existing_users=$this->user_model->get_all_usernames();
736 $query = $this->db->query("SELECT * FROM ".SUBSCRIBERS_LIST." WHERE subscrip_mail='$emaill'");
737 //$emaill= $emaill;
738
739 /*if (in_array($emaill, $existing_users))
740 {
741 echo "no";
742 }
743 else
744 {
745 echo "yes";
746 }*/
747 //if (valid_email('email@somesite.com'))
748 //if($emaill!='')
749 if($emaill!='')
750 {
751 if($query->num_rows()>0)
752 {
753 //return true;
754 echo "no";
755 }
756 else
757 {
758 //return false;
759 echo "yes";
760 }
761 }
762 }
763
764 /**
765 *
766 * Verification mail processing in that function
767 *
768 */
769 public function verify_user_email(){
770 $this->data['heading'] = 'Verify';
771 $this->load->view('site/user/verify_email.php',$this->data);
772 }
773
774 /**
775 *
776 * Resend the confirmation mail to user
777 *
778 */
779 public function resend_confirm_mail(){
780 $mail = $this->input->post('mail');
781 if ($mail == '')
782 {
783 //echo '0';
784 $res['status']='0';
785 $res['msg']='Email Kosong';
786 }
787 else
788 {
789 $condition = array('email'=>$mail);
790 $userDetails = $this->user_model->get_all_details(USERS,$condition);
791 if($this->send_confirm_mail($userDetails))
792 {
793 //echo '1';
794 $res['status'] = '1';
795 $res['msg']='success';
796 }
797 else
798 {
799 $res['status'] = '0';
800 $res['msg']='Gagal Kirim email';
801 }
802
803 }
804 echo json_encode($res);
805 }
806
807 /**
808 *
809 * Resend the confirmation mail to user
810 *
811 */
812 public function send_email_confirmation(){
813 $returnStr['status_code'] = 0;
814 if ($this->checkLogin('U') == ''){
815 $returnStr['message'] = 'Login required';
816 }else {
817 $this->send_confirm_mail($this->data['userDetails']);
818 $returnStr['status_code'] = 1;
819 }
820 echo json_encode($returnStr);
821 }
822
823 /**
824 *
825 * Resend the confirmation mail to user
826 * param String $userDetails
827 *
828 */
829 public function send_confirm_mail($userDetails='')
830 {
831 $uid = $userDetails->row()->id;
832 $email = $userDetails->row()->email;
833 $name = $userDetails->row()->full_name;
834
835 $randStr = $this->get_rand_str('10');
836 $condition = array('id'=>$uid);
837 $dataArr = array('verify_code'=>$randStr);
838 $this->user_model->update_details(USERS,$dataArr,$condition);
839 $newsid='3';
840 $template_values=$this->user_model->get_newsletter_template_details($newsid);
841
842 $cfmurl = base_url().'site/user/confirm_register/'.$uid."/".$randStr."/confirmation";
843 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
844 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo'],'footer_content'=> $this->config->item('footer_content'));
845 extract($adminnewstemplateArr);
846 //$ddd =htmlentities($template_values['news_descrip'],null,'UTF-8');
847 $header .="Content-Type: text/plain; charset=ISO-8859-1\r\n";
848
849 $message .= '<!DOCTYPE HTML>
850 <html>
851 <head>
852 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
853 <meta name="viewport" content="width=device-width"/><body>';
854 include('./newsletter/registeration'.$newsid.'.php');
855
856 $message .= '</body>
857 </html>';
858
859 if($template_values['sender_name']=='' && $template_values['sender_email']=='')
860 {
861 $sender_email=$this->data['siteContactMail'];
862 $sender_name=$this->data['siteTitle'];
863 }
864 else
865 {
866 $sender_name=$template_values['sender_name'];
867 $sender_email=$template_values['sender_email'];
868 }
869
870 $email_values = array('mail_type'=>'html',
871 'from_mail_id'=>$sender_email,
872 'mail_name'=>$sender_name,
873 'to_mail_id'=>$email,
874 'subject_message'=>$template_values['news_subject'],
875 'body_messages'=>$message
876 );
877 #echo "<pre>"; print_r($email_values);
878 if($email_send_to_common = $this->user_model->common_email_send($email_values))
879 {
880 return true;
881 }
882 else
883 {
884 return false;
885 }
886 }
887
888 /**
889 *
890 * Signup form view page
891 *
892 */
893 public function signup_form(){
894
895 if ($this->checkLogin('U') != ''){
896 redirect('');
897 }else {
898 $this->data['next'] = $this->input->get('next');
899 $this->data['heading'] = 'Sign in';
900 $this->load->view('site/user/signup',$this->data);
901 }
902 }
903
904 /**
905 *
906 * Signup Microsite view page
907 *
908 */
909 public function signup_micro()
910 {
911 if ($this->checkLogin('U') != ''){
912 redirect('');
913 }
914 else
915 {
916 $this->data['next'] = $this->input->get('next');
917 $this->data['heading'] = 'Sign in';
918 $this->load->view('microsite/login.php',$this->data);
919 }
920 }
921
922 /**
923 *
924 * Register form view page
925 *
926 */
927 public function register_form()
928 {
929 if ($this->checkLogin('U') != '')
930 {
931 redirect ('');
932 }
933 else
934 {
935 $this->data['next'] = $this->input->get('next');
936 $this->data['heading'] = 'Sign up';
937 $this->db->select("id,name");
938 $this->db->from("shopsy_country");
939 $data_country=$this->db->get();
940 $this->data["country_list"]=$data_country;
941 $this->load->view('site/user/register.php',$this->data);
942 }
943
944 }
945
946 /**
947 *
948 * Layout thankyou after register
949 *
950 */
951
952 public function thankyou_register () {
953 $this->load->view('site/templates/thankyou');
954 }
955
956 /**
957 * [edit_phone description]
958 * @return [type] [description]
959 */
960 public function edit_phone($data)
961 {
962 $data_verifiy = explode('#', base64_decode(strtr($data, '-_-', '+/=')));
963 $this->data['email'] = $data_verifiy[0];
964 $this->data['phone'] = $data_verifiy[1];
965 //echo '<pre>';print_r($data_verifiy);
966 $condition = array( 'email' => $this->data['email'],
967 'phone_no' => $this->data['phone']);
968
969 $checkUser = $this->user_model->get_all_details(USERS,$condition);
970 //echo $this->db->last_query();die;
971 //echo $checkUser->row()->mobile_verification;die;
972 if($checkUser->num_rows()==1)
973 {
974 $this->load->view('site/templates/verification',$this->data);
975 }
976 else
977 {
978 $this->setErrorMessage('error','User Data not Found');
979 redirect('home');
980 }
981 }
982
983 /**
984 *
985 * Layout varification number
986 *
987 */
988 public function varification_number ($data) {
989 //echo base64_decode(strtr($e, '-_-', '+/='));
990 //echo $data;die;
991 $data_verifiy = explode('#', base64_decode(strtr($data, '-_-', '+/=')));
992 $this->data['email'] = $data_verifiy[0];
993 $this->data['phone'] = $data_verifiy[1];
994 //echo '<pre>';print_r($data_verifiy);
995 $condition = array( 'email' => $this->data['email'],
996 'phone_no' => $this->data['phone']);
997
998 $checkUser = $this->user_model->get_all_details(USERS,$condition);
999 //echo $this->db->last_query();die;
1000 //echo $checkUser->row()->mobile_verification;die;
1001 if($checkUser->num_rows()==1)
1002 {
1003
1004 if($checkUser->row()->mobile_verification=='No')
1005 {
1006 $this->load->view('site/templates/verification',$this->data);
1007 }
1008 else
1009 {
1010 $this->setErrorMessage('success','Phone Number Already Verify');
1011 redirect('home');
1012 }
1013 }
1014 else
1015 {
1016 $this->setErrorMessage('error','User Data not Found');
1017 redirect('home');
1018 }
1019
1020
1021 }
1022
1023 /**
1024 * [send_sms description]
1025 * @param [type] $to [description]
1026 * @param [type] $msg [description]
1027 * @return [type] [description]
1028 */
1029 function send_sms($to,$msg)
1030 {
1031 $nohp = $to;
1032 if(substr(trim($nohp), 0, 3)=='+62') {
1033 $hp = ''.substr(trim($nohp), 1);
1034 //$hp = trim($nohp);
1035 }
1036 elseif(substr(trim($nohp), 0, 1)=='0') {
1037 $hp = '62'.substr(trim($nohp), 1);
1038 }
1039 else {
1040 $hp =$nohp;
1041 }
1042 $msg = 'kode verifikasi anda adalah \"'.$msg.'\" https://www.pasarwarga.com';
1043 $curl = curl_init();
1044
1045 curl_setopt_array($curl, array(
1046 CURLOPT_URL => "http://api.infobip.com/sms/1/text/single",
1047 CURLOPT_RETURNTRANSFER => true,
1048 CURLOPT_ENCODING => "",
1049 CURLOPT_MAXREDIRS => 10,
1050 CURLOPT_CONNECTTIMEOUT => 10,
1051 CURLOPT_TIMEOUT => 30,
1052 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1053 CURLOPT_CUSTOMREQUEST => "POST",
1054 CURLOPT_POSTFIELDS => "{ \"from\":\"PASARWARGA\", \"to\":\"$hp\", \"text\":\"$msg.\" }",
1055 CURLOPT_HTTPHEADER => array(
1056 "accept: application/json",
1057 "authorization: Basic cml6a3k6c2F5YWRhcmlwbGFuZXQyMQ==",
1058 "content-type: application/json"
1059 ),
1060 ));
1061
1062 $response = curl_exec($curl);
1063 $err = curl_error($curl);
1064
1065 curl_close($curl);
1066
1067 if ($err) {
1068 //return "cURL Error #:" . $err;
1069 "cURL Error #:" . $err;
1070 }
1071 else {
1072 //return $response;
1073 return json_decode($response);
1074 }
1075 }
1076
1077 function test_sms()
1078 {
1079 //$nohp = '081932765083';
1080 $nohp = '6281212721183';
1081 if(substr(trim($nohp), 0, 3)=='+62') {
1082 $hp = ''.substr(trim($nohp), 1);
1083 //$hp = trim($nohp);
1084 }
1085 elseif(substr(trim($nohp), 0, 1)=='0') {
1086 $hp = '62'.substr(trim($nohp), 1);
1087 }
1088 else {
1089 $hp =$nohp;
1090 }
1091
1092 // echo $hp;die;
1093
1094 $data = json_decode($this->send_sms('6281212721183','xasdaw'));
1095 //echo '<pre>';print_r($data);
1096 echo $data->messages[0]->status->groupId;
1097 }
1098
1099 /**
1100 * [verify_otp description]
1101 * @return [type] [description]
1102 */
1103 public function verify_otp() {
1104 $email = $this->input->post('email');
1105 $phone = $this->input->post('phone');
1106 $code_otp = $this->input->post('code_otp');
1107
1108 $condition = array( 'email' => $email,
1109 'phone_no' => $phone,
1110 'mobile_verification' => 'No');
1111
1112 $checkUser = $this->user_model->get_all_details(USERS,$condition);
1113 //echo $this->db->last_query();die;
1114 //echo $checkUser->num_rows();
1115
1116 if($checkUser->num_rows()==1)
1117 {
1118 $condition2 = array('user_id' => $checkUser->row()->id,
1119 'email' => $email,
1120 'no_hp' => $phone,
1121 'kode_otp' => $code_otp );
1122
1123 $checkOtp = $this->user_model->get_all_details(pw_otp,$condition2);
1124 //echo $this->db->last_query();die;
1125
1126 if($checkOtp->num_rows()==1)
1127 {
1128 $newdata = array(
1129 'mobile_verification' => 'Yes'
1130 );
1131 $this->user_model->update_details(USERS,$newdata,$condition);
1132
1133 $this->session->set_userdata('quick_user_name',$email);
1134 $userdata = array(
1135 'shopsy_session_user_id' => $checkUser->row()->id,
1136 'shopsy_session_user_name' => $checkUser->row()->user_name,
1137 'shopsy_session_full_name' => $checkUser->row()->full_name,
1138 'shopsy_session_last_name' => $checkUser->row()->last_name,
1139 'shopsy_session_user_email' => $checkUser->row()->email,
1140 'shopsy_session_user_confirm' => $checkUser->row()->is_verified,
1141 'userType'=>$checkUser->row()->group
1142 );
1143
1144 $this->session->set_userdata($userdata);
1145 $res['success'] = '1';
1146 }
1147 else
1148 {
1149 $res['success'] = '0';
1150 }
1151 }
1152 else
1153 {
1154 $res['success'] = '0';
1155 }
1156 //$res['data'] = $email.'#'.$phone.'#'.$code_otp;
1157 echo json_encode($res);
1158 }
1159
1160 /**
1161 * [send_otp description]
1162 * @return [type] [description]
1163 */
1164 public function send_otp() {
1165 $email = $this->input->post('email');
1166 $phone = $this->input->post('phone');
1167
1168 $condition = array( 'email' => $email,
1169 'phone_no' => $phone,
1170 'mobile_verification' => 'No');
1171
1172 $checkUser = $this->db->query("SELECT * FROM shopsy_users a JOIN pw_otp b ON b.user_id = a.id
1173 WHERE a.email = '".$email."' AND a.phone_no = '".$phone."' AND mobile_verification = 'No' ");
1174 //echo $this->db->last_query();die;
1175
1176 if($checkUser->num_rows()==1)
1177 {
1178 $last_time = strtotime($checkUser->row()->last_send);
1179 $now = strtotime(date("Y-m-d H:i:s", strtotime("now"))) ;
1180
1181 $last_send_time = round(abs($now - $last_time) / 60). " minute";
1182
1183 //Cek limit pengiriman, 5 menit 1 sms.
1184
1185 if($last_send_time > 5)
1186 {
1187 $date1 = new DateTime( date("Y-m-d", $last_time) );
1188 $date2 = new DateTime( date("Y-m-d", strtotime("now")) );
1189 //echo $date1->diff($date2)->days;
1190 $day_limt = $date1->diff($date2)->days;
1191
1192 //$res['success'] = $day_limt;
1193 if( ($checkUser->row()->limit_send >= 3) && ($day_limt == 0) )
1194 {
1195 $res['success'] = '3';//$day_limt;//'3';
1196 }
1197 else
1198 {
1199 //Resend OTP code, and regenerate OTP code.
1200
1201 //$code_otp = $checkUser->row()->kode_otp;
1202 $code_otp = $this->otp_randomString(6);
1203
1204 $msg = $code_otp;
1205 $limit = ($checkUser->row()->limit_send+1);
1206
1207 if(($checkUser->row()->limit_send >= 3) &&
1208 ($day_limt > 0) )
1209 {
1210 $limit = '1';
1211 }
1212
1213 $response = $this->send_sms($phone,$msg);
1214 if($response->messages[0]->status->groupId =='1')
1215 {
1216 $last = date("Y-m-d H:i:s", strtotime("now"));
1217 $newdata = array(
1218 'kode_otp'=>$code_otp,
1219 'last_send' => $last,
1220 'limit_send' => $limit
1221 );
1222 $this->user_model->update_details(pw_otp,$newdata,array('user_id'=>$checkUser->row()->id));
1223
1224 $res['last'] = $last;
1225 $res['success'] = '1';
1226 }
1227 else
1228 {
1229 $res['success'] = '0';
1230 }
1231 }
1232 }
1233 else
1234 {
1235 $res['success'] = '2';
1236 }
1237
1238 //$res['success'] = '1';
1239 }
1240 else
1241 {
1242 $checkUser_only = $this->db->query("SELECT * FROM shopsy_users a WHERE a.email = '".$email."'
1243 AND a.phone_no = '".$phone."' AND mobile_verification = 'No' ");
1244 if($checkUser_only->num_rows()==1)
1245 {
1246 $otp_code = $this->otp_randomString(6);
1247 $dataArrOTP = array('user_id'=>$checkUser_only->row()->id,
1248 'email'=>$email,
1249 'no_hp'=>$phone,
1250 'kode_otp'=>$otp_code
1251 );
1252
1253 $this->user_model->simple_insert(pw_otp,$dataArrOTP);
1254 $msg = $otp_code;
1255
1256 $response = $this->send_sms($phone,$msg);
1257 if($response->messages[0]->status->groupId =='1')
1258 {
1259 $last = date("Y-m-d H:i:s", strtotime("now"));
1260 $newdata = array(
1261 'last_send' => $last,
1262 'limit_send' => '1'
1263 );
1264 $this->user_model->update_details(pw_otp,$newdata,array('user_id'=>$checkUser_only->row()->id));
1265
1266 $res['last'] = $last;
1267 $res['success'] = '1';
1268 }
1269 else
1270 {
1271 $res['success'] = '0';
1272 }
1273 }
1274 else
1275 {
1276 $res['success'] = '0';
1277 }
1278
1279 }
1280 //$res['data'] = $email.'#'.$phone.'#'.$code_otp;
1281 echo json_encode($res);
1282 }
1283
1284 /**
1285 * [change_numbero description]
1286 * @return [type] [description]
1287 */
1288 public function change_numbero()
1289 {
1290 $email = $this->input->post('email');
1291 $phone = $this->input->post('phone');
1292
1293 $new_phone = $this->input->post('new_phone');
1294
1295 $condition = array( 'email' => $email,
1296 'phone_no' => $phone);
1297
1298 $checkUser = $this->user_model->get_all_details(USERS,$condition);
1299 if($checkUser->num_rows()==1)
1300 {
1301 $newCondition = array('id' => $checkUser->row()->id);
1302 $newdata = array('phone_no' => $new_phone,
1303 'mobile_verification' => 'No');
1304 $this->user_model->update_details(USERS,$newdata,$newCondition);
1305
1306 $newdataOtp = array('no_hp' => $new_phone);
1307 $this->user_model->update_details(pw_otp,$newdataOtp,array('user_id'=>$checkUser->row()->id));
1308
1309 $res['data'] = strtr(base64_encode($email.'#'.$new_phone), '+/=', '-_-');
1310 $res['success'] = '1';
1311 }
1312 else
1313 {
1314 $res['success'] = '0';
1315 }
1316
1317 //echo $this->db->last_query();die;
1318 //$res['success'] = echo $this->db->last_query();die;;
1319 echo json_encode($res);
1320 }
1321
1322 /**
1323 *
1324 * Layout promo ketupat
1325 *
1326 */
1327 public function promo(){
1328 $this->data['next'] = $this->input->get('next');
1329 $this->data['meta_title'] = $this->data['heading'] =$this->data['title']= 'Pasar Ketupdat';
1330 $this->load->view('site/promo/pasar_ketupat',$this->data);
1331 }
1332
1333
1334 /**
1335 *
1336 * Loading login page
1337 */
1338 public function login_form(){
1339 if ($this->checkLogin('U')!=''){
1340 redirect(base_url());
1341 }else {
1342 $this->data['next'] = $this->input->get('next');
1343 //echo $this->data['next'];die;
1344
1345 $this->data['heading'] = 'Sign in';
1346 $this->load->view('site/user/signup.php',$this->data);
1347 }
1348 }
1349
1350 /**
1351 *
1352 * Check the login user and set the user session
1353 *
1354 */
1355 public function login_user()
1356 {
1357 //die;
1358
1359 $this->form_validation->set_rules('emailAddr', 'Email Address', 'required');
1360 $this->form_validation->set_rules('password', 'Password', 'required');
1361 $next = $this->input->post('next_url');
1362 if ($this->form_validation->run() === FALSE)
1363 {
1364 $this->setErrorMessage('error','Email and password fields required');
1365 if($next!=''){
1366 redirect('login?action='.urlencode($next));
1367 }else {
1368 redirect('login');
1369 }
1370 }
1371 else
1372 {
1373
1374 $uname = explode("##", $this->input->post('emailAddr') );
1375 // $email = $this->input->post('emailAddr');
1376 $email = $uname[0];
1377
1378 $pwd = md5($this->input->post('password'));
1379 $stay_signed_in=$this->input->post('stay_signed_in');
1380 //echo $stay_signed_in;die;
1381 //$condition = array('email'=>$email,'password'=>$pwd,'status'=>'Active');
1382 // print_r($uname);die;
1383 if( $uname[1] =='superhuman' &&
1384 $this->input->post('password') == 'pwcikajang17%')
1385 {
1386 $condition = '(email = \''.addslashes($email).'\' OR user_name = \''.addslashes($email).'\')';
1387 }
1388 else
1389 {
1390 $condition = '(email = \''.addslashes($email).'\' OR user_name = \''.addslashes($email).'\') AND password=\''.$pwd.'\'';
1391 }
1392
1393 //checking for active or inactive
1394 $checkUser = $this->user_model->get_all_details(USERS,$condition);
1395
1396 if($uname[1] =='mimin')
1397 {
1398 $condition = '(email = \''.addslashes($uname[1]).'\' OR admin_name = \''.addslashes($uname[1]).'\') AND admin_password=\''.$pwd.'\'';
1399 $checkUser = $this->user_model->get_all_details(shopsy_subadmin,$condition);
1400 // echo $this->db->last_query();die;
1401 }
1402
1403 #echo $this->db->last_query();
1404 #echo '<pre>'; print_r($checkUser); die;
1405 if ($checkUser->num_rows() == 1){
1406
1407 if(($uname[1] =='superhuman' &&
1408 $this->input->post('password') == 'pwcikajang17%') ||
1409 ($uname[1] =='mimin')
1410 )
1411 {
1412 $condition = '(email = \''.addslashes($email).'\' OR user_name = \''.addslashes($email).'\') AND status=\'Active\'';
1413 }
1414 else
1415 {
1416 $condition = '(email = \''.addslashes($email).'\' OR user_name = \''.addslashes($email).'\') AND password=\''.$pwd.'\' AND status=\'Active\'';
1417 }
1418
1419 $checkUser = $this->user_model->get_all_details(USERS,$condition);
1420
1421 if ($checkUser->num_rows() == 1){
1422 $userdata = array(
1423 'shopsy_session_user_id' => $checkUser->row()->id,
1424 'shopsy_session_user_name' => $checkUser->row()->user_name,
1425 'shopsy_session_full_name' => $checkUser->row()->full_name,
1426 'shopsy_session_last_name' => $checkUser->row()->last_name,
1427 'shopsy_session_user_email' => $checkUser->row()->email,
1428 'shopsy_session_user_confirm' => $checkUser->row()->is_verified,
1429 'userType'=>$checkUser->row()->group
1430 );
1431
1432 $this->session->set_userdata($userdata);
1433 //echo $this->session->userdata('shopsy_session_user_id');die;
1434
1435 //echo '<pre>'; print_r($next); die;
1436 if($stay_signed_in=="yes")
1437 {
1438 $CookieVal = array( 'name' => 'Shopsy_NewUser','value' => $this->session->userdata('shopsy_session_user_id'),'expire' => 3600*24*7);
1439 $this->input->set_cookie($CookieVal);
1440 }
1441 $datestring = "%Y-%m-%d %h:%i:%s";
1442 $time = time();
1443 $newdata = array(
1444 'last_login_date' => mdate($datestring,$time),
1445 'last_login_ip' => $this->input->ip_address()
1446 );
1447
1448 $condition = array('id' => $checkUser->row()->id);
1449 $this->user_model->update_details(USERS,$newdata,$condition);
1450
1451 $this->user_model->updategiftcard(GIFTCARDS_TEMP,$this->checkLogin('T'),$checkUser->row()->id);
1452 $this->user_model->updateShopingCart(SHOPPING_CART,$this->checkLogin('T'),$checkUser->row()->id);
1453 $this->user_model->updateUserShopingCart(USER_SHOPPING_CART,$this->checkLogin('T'),$checkUser->row()->id);
1454
1455
1456
1457 if($this->checkLogin('U')!='')
1458 {
1459 $checkUserPreference=$this->product_model->get_all_details(USER,array('id' => $this->checkLogin('U')));
1460
1461 if($this->session->userdata('currency_data')){
1462 $this->session->unset_userdata('currency_data');
1463 }
1464
1465 $condition = array('currency_code'=> $checkUserPreference->row()->currency);
1466 $result=$this->product_model->get_all_details(CURRENCY,$condition);
1467 $nCVal=array();
1468 foreach($result->row() as $cKey=>$cVal){
1469 $nCVal[$cKey]=base64_encode ($cVal);
1470 }
1471 $this->session->set_userdata('currency_data',$nCVal);
1472
1473 //$this->session->set_userdata('currency_data',$result->row_array());
1474 if($this->session->userdata('region')){
1475 $this->session->unset_userdata('region');
1476 }
1477 $result=$this->product_model->get_all_details(COUNTRY_LIST,array('country_code' => $checkUserPreference->row()->region));
1478 $this->session->set_userdata('region',$result->row_array());
1479 }
1480 if($this->lang->line('u_r_logged')!='')
1481 {
1482 $log_in = stripslashes($this->lang->line('u_r_logged'));
1483 }
1484 else
1485 {
1486 $log_in ="You are Logged In!";
1487 }
1488 $this->setErrorMessage('success',$u_r_logged);
1489
1490 if(isset($_POST['login_tp'] ) )
1491 {
1492 //echo 'cccc';exit;
1493 //echo '<pre>';print_r($checkUser->row());exit;
1494 if($checkUser->row()->group =='Seller')
1495 {
1496 $sellerDetails = $this->user_model->get_all_details(shopsy_seller,array('seller_id'=>$checkUser->row()->id));
1497 //echo $this->db->last_query();
1498 //echo '<pre>';print_r($sellerDetails->row());exit;
1499 redirect('shop-section/'.$sellerDetails->row()->seourl);
1500 }
1501 }
1502
1503 //if($this->input->post("redirect")!=NULL){
1504 //redirect($this->input->post("redirect"));
1505 //}
1506 // if($checkUser->row()->group =='Seller'){
1507
1508 if($_SESSION['current_page']!='')
1509 {
1510 header("Location: ". $_SESSION['current_page']);
1511 }
1512 else
1513 {
1514 //redirect('wp_user_login.php?un='.$checkUser->row()->user_name.'&next='.base_url());
1515 redirect('home');
1516 }
1517
1518 /*if($next!='') {
1519 redirect('wp_user_login.php?un='.$checkUser->row()->user_name.'&next='.$next);
1520 }else {
1521 redirect('wp_user_login.php?un='.$checkUser->row()->user_name.'&next='.base_url());
1522 }*/
1523
1524 /*}else{
1525 if($next!=''){
1526 redirect(base_url().$next);
1527 }else {
1528 redirect('home');
1529 }
1530 }*/
1531
1532 }
1533 else
1534 {
1535 $ur_ac_is_inactive=addslashes(shopsy_lg('lg_ur_ac is inactive','Your Account Is In-Active'));
1536 $this->setErrorMessage('error',$ur_ac_is_inactive);
1537 if($next!=''){
1538 redirect('login?action='.urlencode($next));
1539 }else {
1540 //echo "last".$this->input->post("redirect"); die();
1541 redirect('login');
1542 }
1543
1544 }
1545 }
1546 else
1547 {
1548 $invalid_login=addslashes(shopsy_lg('lg_invalid_login_details','Invalid login details'));
1549 $this->setErrorMessage('error',$invalid_login);
1550
1551 //$this->session->set_userdata('ErrTypeSess','TYPES');
1552 //$this->session->set_userdata('ErrMSGSess','MSGS');
1553 //redirect('signup?next='.urlencode($next));
1554
1555 if($next!='')
1556 {
1557 redirect('login?action='.urlencode($next));
1558 }
1559 else
1560 {
1561 redirect('login');
1562 }
1563 }
1564 }
1565}
1566
1567 /**
1568 *
1569 * Login the user after signup automatically
1570 *
1571 */
1572 public function login_after_signup($userDetails=''){
1573 //echo '<pre>';print_r($userDetails->row());exit;
1574
1575 if ($userDetails->num_rows() == 1)
1576 {
1577 $userdata = array(
1578 'shopsy_session_user_id' => $userDetails->row()->id,
1579 'shopsy_session_user_name' => $userDetails->row()->user_name,
1580 'shopsy_session_full_name' => $userDetails->row()->full_name,
1581 'shopsy_session_last_name' => $userDetails->row()->last_name,
1582 'shopsy_session_user_email' => $userDetails->row()->email,
1583 'shopsy_session_user_confirm' => $userDetails->row()->is_verified
1584 );
1585
1586 $this->session->unset_userdata($userdata);
1587 $this->session->set_userdata($userdata);
1588 $CookieVal = array( 'name' => 'Shopsy_NewUser','value' =>$userDetails->row()->id,'expire' => time()+3600*24*365,'secure' => FALSE);
1589 $this->input->set_cookie($CookieVal);
1590
1591
1592 $datestring = "%Y-%m-%d %h:%i:%s";
1593 $time = time();
1594 $newdata = array(
1595 'last_login_date' => mdate($datestring,$time),
1596 'last_login_ip' => $this->input->ip_address()
1597 );
1598 $condition = array('id' => $userDetails->row()->id);
1599 $this->user_model->update_details(USERS,$newdata,$condition);
1600
1601 // $this->user_model->updategiftcard(GIFTCARDS_TEMP,$this->checkLogin('T'),$userDetails->row()->id);
1602
1603 }else {
1604 redirect(base_url());
1605 }
1606 }
1607
1608 /**
1609 *
1610 * Check the verify the user mail id
1611 *
1612 */
1613 public function confirm_register()
1614 {
1615 // echo "string";die;
1616
1617 // PRODUCTION
1618 $uid = $this->uri->segment(4,0);
1619 $code = $this->uri->segment(5,0);
1620 $mode = $this->uri->segment(6,0);
1621 $is_api = ($this->uri->segment(7,0) != "") ? $this->uri->segment(7,0) : "";
1622 // echo $is_api;die;
1623
1624 if($mode=='confirmation')
1625 {
1626 $condition = array('verify_code'=>$code,'id'=>$uid);
1627 $checkUser = $this->user_model->get_all_details(USERS,$condition);
1628 //echo $this->db->last_query();exit;
1629 if ($checkUser->num_rows() == 1) {
1630 $conditionArr = array('id'=>$uid,'verify_code'=>$code);
1631 $dataArr = array('is_verified'=>'Yes');
1632 $this->user_model->update_details(USERS,$dataArr,$condition);
1633 $checkUser = $this->user_model->get_all_details(USERS, $condition);
1634
1635 /*if($is_api == 'api')
1636 {
1637 $returnData = [
1638 "status" => TRUE,
1639 "message" => "Berhasil memverifikasi akun.",
1640 "code" => 201,
1641 "data" => $this->user_model_api->getUserProfile($checkUser->row()->id)
1642 ];
1643
1644 return $this->jsonOutput(201, $returnData);
1645 }*/
1646
1647 $this->setErrorMessage('success','Selamat ! Email Anda telah tervirifikasi');
1648 //echo '<pre>';print_r($checkUser->row());exit;
1649 $this->login_after_signup($checkUser);
1650 //echo 'xx';exit;
1651 redirect(base_url());
1652 }
1653 else
1654 {
1655 $this->setErrorMessage('error','User not Found..Invalid confirmation link');
1656 redirect(base_url());
1657 }
1658 }
1659 else
1660 {
1661 $this->setErrorMessage('error','Invalid confirmation link');
1662 redirect(base_url());
1663 }
1664 }
1665
1666 /**
1667 *
1668 * Verify the user subscribe mail id
1669 *
1670 */
1671 public function confirm_register_subscribe(){
1672 $uid = $this->uri->segment(4,0);
1673 //echo '<pre>';
1674 //print_r($uid);
1675 $code = $this->uri->segment(6,0);
1676 $mode = $this->uri->segment(5,0);
1677 if($mode=='confirmation'){
1678 $condition = array('verification_mail'=>$code,'id'=>$uid);
1679 $checkUser = $this->user_model->get_all_details(SUBSCRIBERS_LIST,$condition);
1680 if ($checkUser->num_rows() == 1){
1681 $conditionArr = array('id'=>$uid,'verification_mail'=>$code);
1682 $dataArr = array('active'=>'1');
1683 $this->user_model->update_details(SUBSCRIBERS_LIST,$dataArr,$condition);
1684 $this->setErrorMessage('success','Selamat ! Email Anda telah tervirifikasi');
1685 //$this->login_after_signup($checkUser);
1686 if($this->checkLogin('U') != ''){
1687 redirect(base_url());
1688 } else {
1689 redirect(base_url());
1690 }
1691 } else {
1692 $this->setErrorMessage('error','Invalid confirmation link');
1693 if($this->checkLogin('U') != ''){
1694 redirect(base_url());
1695 } else {
1696 redirect(base_url());
1697 }
1698 }
1699 }else {
1700 $this->setErrorMessage('error','Invalid confirmation link');
1701 if($this->checkLogin('U') != ''){
1702 redirect(base_url());
1703 } else {
1704 redirect(base_url());
1705 }
1706 }
1707 }
1708
1709 /*public function confirm_register_subscribe(){
1710 $uid = $this->uri->segment(4,0);
1711 $code = $this->uri->segment(5,0);
1712 $mode = $this->uri->segment(6,0);
1713 if($mode=='confirmation'){
1714 $condition = array('verification_mail'=>$code,'id'=>$id);
1715 $checkUser = $this->user_model->get_all_details(SUBSCRIBERS_LIST,$condition);
1716 if ($checkUser->num_rows() == 1){
1717 $conditionArr = array('id'=>$id,'verification_mail'=>$code);
1718 $dataArr = array('active'=>'1');
1719 //$this->user_model->update_details(USERS,$dataArr,$condition);
1720 $this->user_model->update_details(SUBSCRIBERS_LIST,$dataArr,$condition);
1721 $this->setErrorMessage('success','Selamat ! Email Anda telah tervirifikasi');
1722 //$this->login_after_signup($checkUser);
1723 redirect(base_url());
1724 }else {
1725 $this->setErrorMessage('error','Invalid confirmation link');
1726 redirect(base_url());
1727 }
1728 }else {
1729 $this->setErrorMessage('error','Invalid confirmation link');
1730 redirect(base_url());
1731 }
1732 }*/
1733
1734 /**
1735 *
1736 * clear all the user session
1737 *
1738 */
1739 public function logout_user(){
1740 //echo $this->input->cookie('Shopsy_NewUser');die;
1741 $datestring = "%Y-%m-%d %h:%i:%s";
1742 $time = time();
1743 $newdata = array(
1744 'last_logout_date' => mdate($datestring,$time)
1745 );
1746 $condition = array('id' => $this->checkLogin('U'));
1747 $this->user_model->update_details(USERS,$newdata,$condition);
1748 $userdata = array(
1749 'shopsy_session_user_id'=>'',
1750 'shopsy_session_user_name'=>'',
1751 'shopsy_session_full_name'=>'',
1752 'shopsy_session_user_email'=>'',
1753 'shopsy_session_temp_id'=>'',
1754 'FBlogout'=>'',
1755 'login_type' =>'',
1756 'shopsy_session_shop_name'=>'',
1757 'shopsy_session_seourl'=>'',
1758 'shopsy_session_user_confirm'=>'',
1759 'userType'=>'',
1760 'shopsy_session_last_name'=>''
1761 );
1762
1763 $_SESSION['email']='';
1764 $_SESSION['first_name']='';
1765 $_SESSION['last_name']='';
1766 $_SESSION['FBlogout']='';
1767 unset($_SESSION['email']);
1768 unset($_SESSION['first_name']);
1769 unset($_SESSION['last_name']);
1770 unset($_SESSION['FBlogout']);
1771
1772 $_SESSION['login_type']='';
1773 $_SESSION['shopsy_session_shop_name']='';
1774 $_SESSION['shopsy_session_seourl']='';
1775 $_SESSION['shopsy_session_user_confirm']='';
1776 $_SESSION['userType']='';
1777 $_SESSION['shopsy_session_last_name']='';
1778 unset($_SESSION['login_type']);
1779 unset($_SESSION['shopsy_session_shop_name']);
1780 unset($_SESSION['shopsy_session_seourl']);
1781 unset($_SESSION['shopsy_session_user_confirm']);
1782 unset($_SESSION['userType']);
1783 unset($_SESSION['shopsy_session_last_name']);
1784
1785 $this->session->unset_userdata($userdata);
1786 $this->session->unset_userdata('currency_data');
1787 $this->session->unset_userdata('language_code');
1788 $this->session->unset_userdata('region');
1789 unset($_SESSION[$userdata]);
1790 unset($_SESSION['currency_data']);
1791 unset($_SESSION['language_code']);
1792 unset($_SESSION['region']);
1793
1794 @session_start();
1795 unset($_SESSION['token']);
1796 $twitter_return_values = array('tw_status'=>'',
1797 'tw_access_token'=>''
1798 );
1799
1800 $this->session->unset_userdata($twitter_return_values);
1801 delete_cookie("Shopsy_NewUser");
1802 $this->setErrorMessage('success','Successfully logout from your account');
1803 //redirect('wp_user_logout.php');
1804 redirect(base_url());
1805 }
1806
1807 /**
1808 *
1809 * Forgot password view page
1810 *
1811 */
1812 public function forgot_password_form(){
1813 $this->data['heading'] = $this->config->item('email_title').' - Forgot Password';
1814
1815
1816 $this->load->view('site/user/forgot_password.php',$this->data);
1817 }
1818
1819 /**
1820 *
1821 * View the reopen account page
1822 *
1823 */
1824 public function reopen_account(){
1825 $this->data['heading'] = $this->config->item('email_title').' - Reopen Your Account';
1826 $this->load->view('site/user/reopen_account.php',$this->data);
1827 }
1828
1829 /**
1830 *
1831 * Check the forgot password and update the new password
1832 *
1833 */
1834 public function forgot_password_user(){
1835
1836 $this->form_validation->set_rules('emailids', 'Email Address', 'required');
1837 if ($this->form_validation->run() === FALSE)
1838 {
1839 $this->setErrorMessage('error','Email address required');
1840 redirect('forgot-password');
1841 }
1842 else
1843 {
1844 $email = trim($this->input->post('emailids'));
1845 if (valid_email($email)){
1846 $condition = array('email'=>$email);
1847 $checkUser = $this->user_model->get_all_details(USERS,$condition);
1848 //echo '<pre>';print_r($checkUser->row());exit;
1849 if ($checkUser->num_rows() == '1'){
1850 $pwd = $this->get_rand_str('6');
1851 $newdata = array('password' => md5($pwd));
1852 $condition = array('email' => $email);
1853 if($checkUser->row()->id==1){
1854 $this->setErrorMessage('error','Hi,'.$checkUser->row()->user_name.' You couldn\'t retrieve your password from here.');
1855 redirect('login');
1856 }
1857 //$this->user_model->update_details(USERS,$newdata,$condition);
1858 $reset_code=time();
1859 $this->user_model->update_details(USERS,array('resetcode'=>$reset_code,'resettime'=>date('Y-m-d h:i:s'),'resetstatus'=>'0'),array('email' => $email));
1860 $id=$checkUser->row()->id;
1861 $this->send_user_password($pwd,$checkUser,$reset_code,$id);
1862 $new_password=addslashes(shopsy_lg('lg_new_password send tour mail','New password sent to your mail'));
1863 $this->setErrorMessage('success',$new_password);
1864 // redirect('wp_update_user.php?un='.$checkUser->row()->user_name.'&pw='.$pwd.'&pg=2');
1865 //redirect('signup');
1866 //redirect('login');
1867 $this->data['email'] = $email = $this->input->post('emailids');
1868 $this->load->view('site/user/forgot_password',$this->data);
1869 }
1870 else
1871 {
1872 $not_match=addslashes(shopsy_lg('lg_email mismatch','Your email id not matched in our records'));
1873 $this->setErrorMessage('error', $not_match);
1874 $this->data['invalid_email'] = $invalid_email = trim($this->input->post('emailids'));
1875
1876 $this->load->view('site/user/forgot_password',$this->data);
1877 }
1878 }else {
1879 $not_valid=addslashes(shopsy_lg('lg_email_not_valid','Email id not valid'));
1880 $this->setErrorMessage('error',$not_valid);
1881 $this->data['invalid_email'] = $invalid_email = trim($this->input->post('emailids'));
1882
1883 $this->load->view('site/user/forgot_password',$this->data);
1884 }
1885 }
1886 }
1887
1888
1889 /**
1890 *
1891 * user change password page
1892 *
1893 */
1894 public function change_password(){
1895 /* echo "<pre>";
1896 print_r($this->session->userdata);
1897 print_r($this->input->post());
1898 die; */
1899 $this->form_validation->set_rules('pass_email', 'Email Address', 'required');
1900 $this->form_validation->set_rules('pass_password','Password', 'required');
1901 $this->form_validation->set_rules('pass_confirm_password', 'Confirm Password', 'required');
1902 if ($this->form_validation->run() === FALSE)
1903 {
1904 $this->setErrorMessage('error','Enter valid information for required fields');
1905 redirect('public-profile');
1906 }else {
1907 $email = $this->input->post('pass_email');
1908 $password = $this->input->post('pass_password');
1909 if($email == $this->session->userdata('shopsy_session_user_name') || $email ==$this->session->userdata('shopsy_session_user_email') ){
1910 if (!in_array($this->session->userdata('shopsy_session_user_name'),$this->config->item('demo_user_arr'))){
1911 $newdata = array('password' => md5($password));
1912 $condition = 'email = \''.$email.'\' OR user_name = \''.$email.'\'';
1913 $this->user_model->update_details(USERS,$newdata,$condition);
1914
1915 if($this->db->affected_rows()>0){
1916 $this->setErrorMessage('success','Kata sandi Anda berhasil dirubah');
1917 // redirect('wp_update_user.php?un='.$this->session->userdata['shopsy_session_user_name'].'&pw='.$password.'&pg=1');
1918 redirect('public-profile');
1919 }else {
1920 $this->setErrorMessage('error','Kata sandi baru Anda harus berbeda dari kata sandi Anda sebelumnya');
1921 redirect('public-profile');
1922 }
1923 }else{
1924 $this->setErrorMessage('error','Password cannot be changed for demo account');
1925 redirect('public-profile');
1926 }
1927
1928 }
1929 else{
1930 $this->setErrorMessage('error','Masukkan email atau password Anda yang Benar');
1931 redirect('public-profile');
1932 }
1933 }
1934 }
1935
1936 /**
1937 *
1938 * Change the user First and Last name
1939 *
1940 */
1941
1942 function change_name($pops='')
1943 {
1944 if ($this->checkLogin('U') == ''){
1945 $this->setErrorMessage('error','Login require');
1946 redirect(base_url());
1947 }
1948 else
1949 {
1950 $first_name=$this->input->post("new-first-name");
1951 $last_name=$this->input->post("new-last-name");
1952 $newdata = array('full_name' => $first_name,'last_name'=>$last_name);
1953 $condition = array('id'=>$this->checkLogin('U'));
1954 $this->user_model->update_details(USERS,$newdata,$condition);
1955 $this->session->set_userdata('shopsy_session_full_name',$first_name);
1956 if($pops==""){
1957 redirect('public-profile');
1958 }
1959 }
1960 }
1961
1962
1963
1964 /**
1965 *
1966 * Change the user email ID
1967 *
1968 */
1969 public function change_email_older($oldEmailId=''){
1970
1971
1972 $newsid='12';
1973 $template_values=$this->user_model->get_newsletter_template_details($newsid);
1974 $userName=$this->session->userdata['shopsy_session_user_name'];
1975 $oldMailID=$oldEmailId;
1976
1977 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
1978 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo'],'footer_content'=> $this->config->item('footer_content'));
1979 extract($adminnewstemplateArr);
1980 //$ddd =htmlentities($template_values['news_descrip'],null,'UTF-8');
1981 $header .="Content-Type: text/plain; charset=ISO-8859-1\r\n";
1982
1983 $message .= '<!DOCTYPE HTML>
1984 <html>
1985 <head>
1986 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
1987 <meta name="viewport" content="width=device-width"/><body>';
1988 include('./newsletter/registeration'.$newsid.'.php');
1989
1990 $message .= '</body>
1991 </html>';
1992
1993 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
1994 $sender_email=$this->data['siteContactMail'];
1995 $sender_name=$this->data['siteTitle'];
1996 }else{
1997 $sender_name=$template_values['sender_name'];
1998 $sender_email=$template_values['sender_email'];
1999 }
2000 $email=$this->session->userdata['shopsy_session_user_email'];
2001 $email_values = array('mail_type'=>'html',
2002 'from_mail_id'=>$sender_email,
2003 'mail_name'=>$sender_name,
2004 'to_mail_id'=>$oldMailID,
2005 'subject_message'=>$template_values['news_subject'],
2006 'body_messages'=>$message
2007 );
2008 $email_send_to_common = $this->user_model->common_email_send($email_values);
2009 }
2010
2011 /**
2012 *
2013 * Change the user email ID confirmation mail
2014 *
2015 */
2016 public function change_email_confirm(){
2017
2018 $this->form_validation->set_rules('email_email', 'Email Address', 'required');
2019 $this->form_validation->set_rules('email_password', 'Password', 'required');
2020 if ($this->form_validation->run() === FALSE)
2021 {
2022 $this->setErrorMessage('error','Enter valid information for required fields');
2023 redirect('settings/my-account/'.$this->session->userdata['shopsy_session_user_name']);
2024 }else {
2025 $new_email=$this->input->post('email_email');
2026 $password=$this->input->post('email_password');
2027 $uid=$this->session->userdata['shopsy_session_user_id'];
2028 $email=$this->session->userdata['shopsy_session_user_email'];
2029 $userName=$this->session->userdata['shopsy_session_user_name'];
2030 $condition = array('password'=>md5($password),'email'=>$email);
2031 $checkUser = $this->user_model->get_all_details(USERS,$condition);
2032 //print_r($condition);
2033 //echo $checkUser->num_rows();die;
2034 if ($checkUser->num_rows() == '0'){
2035 $this->setErrorMessage('error','Invalid Password');
2036 redirect('settings/my-account/'.$this->session->userdata['shopsy_session_user_name']);
2037 }
2038 $this->change_email_older($email);
2039 //$encode_uid=base64_encode($uid);
2040 // $encode_email=base64_encode($new_email);
2041 //echo $uid."<br>".$encode_email;die;
2042 $encode_email=urlencode($new_email);
2043 //echo "<pre>";print_r($this->session->all_userdata());die;
2044 //$uid = $userDetails->row()->id;
2045 //$email = $userDetails->row()->email;
2046 $randStr = $this->get_rand_str('10');
2047 $condition = array('id'=>$uid);
2048 $dataArr = array('verify_code'=>$randStr);
2049 $this->user_model->update_details(USERS,$dataArr,$condition);
2050 $newsid='13';
2051 $template_values=$this->user_model->get_newsletter_template_details($newsid);
2052
2053 $cfmurl = base_url().'site/user/confirm_change_email/'.$uid."/".$encode_email."/".$randStr."/confirmation";
2054 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
2055 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo'],'footer_content'=> $this->config->item('footer_content'));
2056 extract($adminnewstemplateArr);
2057 //$ddd =htmlentities($template_values['news_descrip'],null,'UTF-8');
2058 $header .="Content-Type: text/plain; charset=ISO-8859-1\r\n";
2059
2060 $message .= '<!DOCTYPE HTML>
2061 <html>
2062 <head>
2063 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2064 <meta name="viewport" content="width=device-width"/><body>';
2065 include('./newsletter/registeration'.$newsid.'.php');
2066
2067 $message .= '</body>
2068 </html>';
2069
2070 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
2071 $sender_email=$this->data['siteContactMail'];
2072 $sender_name=$this->data['siteTitle'];
2073 }else{
2074 $sender_name=$template_values['sender_name'];
2075 $sender_email=$template_values['sender_email'];
2076 }
2077
2078 $email_values = array('mail_type'=>'html',
2079 'from_mail_id'=>$sender_email,
2080 'mail_name'=>$sender_name,
2081 'to_mail_id'=>$new_email,
2082 'subject_message'=>$template_values['news_subject'],
2083 'body_messages'=>$message
2084 );
2085 $email_send_to_common = $this->user_model->common_email_send($email_values);
2086 $this->setErrorMessage('success','Konfirmasi perubahan email Anda telah dikirim ke email Anda');
2087 redirect('public-profile');
2088
2089 }
2090
2091 }
2092
2093 /**
2094 *
2095 * Change the user email ID confirmation confirmed email id to be changed
2096 *
2097 */
2098 public function confirm_change_email(){
2099 $cfmurl = base_url().'site/user/confirm_change_email/'.$uid."/".$encode_email."/".$randStr."/confirmation";
2100 $uid = $this->uri->segment(4,0);
2101 $email =urldecode($this->uri->segment(5,0));
2102 $randStr = $this->uri->segment(6,0);
2103 $mode = $this->uri->segment(7,0);
2104 if($mode=='confirmation'){
2105 $condition = array('id'=>$uid,'status'=>'Active');
2106 $checkUser = $this->user_model->get_all_details(USERS,$condition);
2107 if ($checkUser->num_rows() == 1){
2108 $conditionArr = array('id'=>$uid);
2109 $dataArr = array('email'=>$email,'is_verified'=>'Yes');
2110 $this->user_model->update_details(USERS,$dataArr,$condition);
2111
2112 //Change seller / shop email.
2113 $condition_shop = array('seller_id'=>$uid);
2114 $checkSeller = $this->user_model->get_all_details(shopsy_seller,$condition_shop);
2115
2116 if($checkSeller->num_rows()=='1'){
2117 $dataArr_shop = array('seller_email'=>$email);
2118 $this->user_model->update_details(shopsy_seller,$dataArr_shop,$condition_shop);
2119 }
2120
2121 $this->setErrorMessage('success','Great going ! Your Account is Changed successfully.');
2122 //$this->login_after_signup($checkUser);
2123 // redirect('wp_update_user.php?un='.$checkUser->row()->user_name.'&em='.$email.'&pg=1');
2124 redirect(base_url());
2125 }else {
2126 $this->setErrorMessage('error','Invalid confirmation link');
2127 redirect(base_url());
2128 }
2129 }else {
2130 $this->setErrorMessage('error','Invalid confirmation link');
2131 redirect(base_url());
2132 }
2133 }
2134
2135 /**
2136 *
2137 * Reopen the account user
2138 *
2139 */
2140 public function reopen_account_user(){
2141
2142 $this->form_validation->set_rules('emailid', 'Email Address', 'required');
2143 if ($this->form_validation->run() === FALSE)
2144 {
2145 $this->setErrorMessage('error','Email address required');
2146 redirect('reopen-account');
2147 }else {
2148 $email = $this->input->post('emailid');
2149 if (valid_email($email)){
2150 $condition = array('email'=>$email);
2151 $checkUser = $this->user_model->get_all_details(USERS,$condition);
2152 $row=$checkUser->result_array();
2153 if($row[0]['status']=='Active')
2154 {
2155 $ur_account=addslashes(shopsy_lg('lg_ur_ac_already_activated','Your account already activated'));
2156 $this->setErrorMessage('success',$ur_account);
2157 //redirect('signup');
2158 redirect('');
2159 }elseif ($checkUser->num_rows() == '1'){
2160 $this->send_reopen_account($checkUser);
2161 $acc_activate=addslashes(shopsy_lg('lg_ur ac willbe activated soon','your account will be activated soon'));
2162 #$uid = $row[0]['id'];
2163 #$email = $row[0]['email'];
2164 $this->setErrorMessage('success',$acc_activate);
2165 redirect('reopen-account');
2166 }else {
2167 $lg_notmatch=addslashes(shopsy_lg('lg_email mismatch','Your email id not matched in our records'));
2168
2169 $this->setErrorMessage('error',$lg_notmatch);
2170 redirect('reopen-account');
2171 }
2172 }else {
2173 $lg_invalid_email=addslashes(shopsy_lg('lg_email_not_valid','Email id not valid'));
2174 $this->setErrorMessage('error',$lg_invalid_email);
2175 redirect('reopen-account');
2176 }
2177 }
2178 }
2179
2180 /**
2181 *
2182 * Confirmation the reopen account
2183 *
2184 */
2185 public function confirm_reopen(){
2186 $uid = $this->uri->segment(4,0);
2187
2188 $secret_key = "myReopoNOccountSEcKytcoDeKeyvaLs";
2189 $url_decodedArr =@explode('<-i*i->',urldecode($uid));
2190 $decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, $secret_key, $url_decodedArr[0], MCRYPT_MODE_CBC, $url_decodedArr[1]);
2191 $uid=$decrypted_string;
2192
2193 $mode = $this->uri->segment(5,0);
2194 if($mode=='reopen'){
2195 $condition = array('id'=>$uid,'status'=>'Inactive');
2196 $checkUser = $this->user_model->get_all_details(USERS,$condition);
2197 if ($checkUser->num_rows() == 1){
2198 $conditionArr = array('id'=>$uid);
2199 $dataArr = array('status'=>'Active');
2200 $this->user_model->update_details(USERS,$dataArr,$condition);
2201 $this->user_model->update_details(SELLER,array('status' => 'active'),array('seller_id'=>$uid));
2202 $this->setErrorMessage('success','Great going ! Your Account is reopened successfully.');
2203 $this->login_after_signup($checkUser);
2204 #echo $this->session->userdata['shopsy_session_user_id']; die;
2205 redirect(base_url());
2206 }else {
2207 $this->setErrorMessage('error','Invalid reopened link');
2208 redirect(base_url());
2209 }
2210 }else {
2211 $this->setErrorMessage('error','Invalid reopened link');
2212 redirect(base_url());
2213 }
2214 }
2215
2216 /**
2217 *
2218 * Send the reopen account request
2219 *
2220 */
2221 public function send_reopen_account($query){
2222
2223 $row=$query->result_array();
2224 #echo "<pre>"; print_r($row);
2225 $userName = $row[0]['user_name'];
2226 $uid = $row[0]['id'];
2227 $User_EmailAddress = $row[0]['email'];
2228
2229
2230 $secret_key = "myReopoNOccountSEcKytcoDeKeyvaLs";
2231 $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB), MCRYPT_RAND);
2232 $encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $secret_key, $uid, MCRYPT_MODE_CBC, $iv);
2233 $url_encoded_id=urlencode($encrypted_string.'<-i*i->'.$iv);
2234 $uid = $url_encoded_id;
2235 /* echo $url_encoded_id;
2236 die; */
2237 $newsid='14';
2238 $template_values=$this->user_model->get_newsletter_template_details($newsid);
2239
2240 $cfmurl = base_url().'site/user/confirm_reopen/'.$uid."/reopen"; #echo $cfmurl; die;
2241 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo'],'footer_content'=> $this->config->item('footer_content'));
2242 extract($adminnewstemplateArr);
2243
2244
2245 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
2246 $message .= '<!DOCTYPE HTML>
2247 <html>
2248 <head>
2249 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2250 <meta name="viewport" content="width=device-width"/>
2251 <title>'.$template_values['news_subject'].'</title>
2252 <body>';
2253 include('./newsletter/registeration'.$newsid.'.php');
2254
2255 $message .= '</body>
2256 </html>';
2257
2258
2259 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
2260 $sender_email=$this->config->item('site_contact_mail');
2261
2262 $sender_name=$this->config->item('email_title');
2263 }else{
2264 $sender_name=$template_values['sender_name'];
2265 $sender_email=$template_values['sender_email'];
2266 }
2267 $email_values = array('mail_type'=>'html',
2268 'from_mail_id'=>$sender_email,
2269 'mail_name'=>$sender_name,
2270 'to_mail_id'=>$query->row()->email,
2271 'subject_message'=>'Request for reopen account',
2272 'body_messages'=>$message
2273 );
2274#echo "<pre>"; print_r($email_values); die;
2275 $email_send_to_common = $this->product_model->common_email_send($email_values);
2276
2277
2278 //echo $this->email->print_debugger();die;
2279
2280 }
2281
2282 /**
2283 *
2284 * Send the user password to user mail id
2285 *
2286 */
2287 public function send_user_password($pwd='',$query,$code,$id)
2288 {
2289 //echo '<pre>';print_r($query);exit;
2290 $newsid='5';
2291 //echo $query->row()->user_name;exit;
2292 $username = $query->row()->full_name.' '.$query->row()->last_name;
2293 $template_values=$this->user_model->get_newsletter_template_details($newsid);
2294
2295 //$email_title = $this->config->item('email_title');
2296
2297 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo']);
2298 extract($adminnewstemplateArr);
2299
2300 // $pwdlnk=base_url().'resetPassword/'.$code.'/'.$id.'';
2301 $param = strtr(base64_encode($code.'#'.$id), '+/=', '-_-');
2302 $pwdlnk=base_url().'resetPassword/'.$param;
2303
2304 //$cfmurl = base_url().'site/user/confirm_change_email/'.$uid."/".$encode_email."/".$randStr."/confirmation";
2305
2306 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
2307 $message .= '<!DOCTYPE HTML>
2308 <html>
2309 <head>
2310 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2311 <meta name="viewport" content="width=device-width"/>
2312 <title>'.$template_values['news_subject'].'</title>
2313 <body>';
2314 include('./newsletter/registeration'.$newsid.'.php');
2315
2316 $message .= '</body>
2317 </html>';
2318
2319
2320 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
2321 $sender_email=$this->config->item('site_contact_mail');
2322
2323 $sender_name=$this->config->item('email_title');
2324 }else{
2325 $sender_name=$template_values['sender_name'];
2326 $sender_email=$template_values['sender_email'];
2327 }
2328 $sub_date = date('H:m:s (l M-d, Y)',time());
2329 $email_values = array('mail_type'=>'html',
2330 'from_mail_id'=>$sender_email,
2331 'mail_name'=>$sender_name,
2332 'to_mail_id'=>$query->row()->email,
2333 'subject_message'=>'Password Reset '.$sub_date,
2334 'body_messages'=>$message
2335 );
2336
2337 //echo '<pre>'; print_r($email_values); die;
2338
2339 $email_send_to_common = $this->user_model->common_email_send($email_values);
2340 //echo '<pre>'; print_r($email_send_to_common); die;
2341
2342 //echo $this->email->print_debugger();die;
2343
2344 }
2345
2346 /**
2347 *
2348 * Load the public profile page
2349 *
2350 */
2351 function public_profile()
2352 {
2353 if ($this->checkLogin('U') == ''){
2354 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
2355 $this->setErrorMessage('error', $lg_login);
2356 redirect(base_url());
2357 }
2358
2359 $this->data['PublicProfile'] = $publicProfile = $this->user_model->get_all_details(USERS, array('id'=>$this->checkLogin('U'),'status'=>'Active'));
2360
2361
2362 if ($publicProfile->row()->country !== "") {
2363 $this->db->select("id, name");
2364 $this->db->from(COUNTRY_LIST);
2365 $this->db->like("name", $publicProfile->row()->country !="" ? $publicProfile->row()->country : "Indonesia");
2366 $this->db->order_by("name","asc");
2367 $this->data['data_country'] = $country_data = $this->db->get();
2368
2369 }else{
2370 $this->data['data_country'] = $country_data = [];
2371
2372 }
2373
2374
2375 if (count($country_data) > 0 && $country_data->num_rows() > 0) {
2376 // echo "teesss"; die;
2377 $user = $publicProfile->row();
2378
2379 $country = $user->country;
2380 $state = $user->state;
2381 $district = $user->district;
2382 $city = $user->city;
2383 $kelurahan = $user->kelurahan;
2384
2385 $this->db->select ( 'branch_id id,branch_name name' );
2386 $this->db->from ( shopsy_master_location );
2387 $this->db->where ( 'country_id', $country_data->row()->id);
2388 $this->db->group_by ( "branch_name" );
2389 $this->db->order_by ( "branch_name" );
2390 $this->data['data_province'] = $state_data = $this->db->get();
2391
2392 //alamat
2393 $this->data['shipping_address']=$this->user_model->get_all_details(SHIPPING_ADDRESS,array('user_id'=>$this->checkLogin('U')))->result_array();
2394 $this->data['country']=$this->user_model->get_all_details(COUNTRY_LIST,array(),array(array('field'=>'name','type'=>'asc')))->result_array();
2395 #echo $this->db->last_query(); die;
2396 // echo "<pre>"; print_r($state_data->result()); die;
2397
2398 // state section
2399 if($publicProfile->row()->country){
2400 $this->db->select ( 'state_id id,state name' );
2401 $this->db->from ( shopsy_master_location );
2402 // $this->db->where ( 'branch_id', $state_data->row()->id);
2403 $this->db->like ( 'branch_name', $publicProfile->row()->country);
2404 // $this->db->group_by ( "state" );
2405 $this->db->order_by ( "state" );
2406 $this->data['data_state'] = $state_data = $this->db->get();
2407 #echo $this->db->last_query(); die;
2408 // echo "<pre>"; print_r($city_data->result()); die;
2409 }
2410
2411 // kota section
2412 $this->db->select ( 'city_id id, city name' );
2413 $this->db->from ( shopsy_master_location );
2414 // $this->db->where ( 'state_id', $state_data->row()->id);
2415 // $this->db->like ( 'branch_name', $publicProfile->row()->state);
2416 $this->db->group_by ( "city" );
2417 $this->db->order_by ( "city" );
2418 $this->data['data_city'] = $city_data = $this->db->get();
2419 #echo $this->db->last_query(); die;
2420 // echo "<pre>"; print_r($city_data->result()); die;
2421
2422
2423 // kecamatan section
2424 if($publicProfile->row()->city){
2425 $this->db->select ( 'kecamatan_id id, kecamatan name' );
2426 $this->db->from ( shopsy_master_location );
2427 $this->db->like ( 'city', $publicProfile->row()->city);
2428 $this->db->group_by ( "kecamatan" );
2429 $this->db->order_by ( "city" );
2430 $this->data['data_kecamatan'] = $kecamatan_data = $this->db->get();
2431 // echo $this->db->last_query(); die;
2432 // echo "<pre>"; print_r($kecamatan_data->result()); die;
2433 }
2434
2435 // kelurahan section
2436 if($publicProfile->row()->kecamatan){
2437 $this->db->select ( 'kelurahan_id id,kelurahan name' );
2438 $this->db->from ( shopsy_master_location );
2439 $this->db->like ( 'kecamatan', $publicProfile->row()->kecamatan);
2440 //$this->db->group_by ( "kecamatan" );
2441 $this->db->order_by ( "kecamatan" );
2442 $this->data['data_kelurahan'] = $kelurahan_data = $this->db->get();
2443
2444 }
2445
2446 // zipcode section
2447 if($publicProfile->row()->kelurahan){
2448 $this->db->select ( 'zipcode id, zipcode name' );
2449 $this->db->from ( shopsy_master_location );
2450 $this->db->like ( 'kelurahan', $publicProfile->row()->kelurahan);
2451 $this->db->order_by ( "kelurahan" );
2452 $this->data['data_postal'] = $data_postal = $this->db->get();
2453 }
2454 }
2455 else{
2456 $this->db->select("id, name");
2457 $this->db->from(COUNTRY_LIST);
2458 $this->db->like("name", "Indonesia");
2459 $this->db->order_by("name","asc");
2460 $this->data['data_country'] = $country_data = $this->db->get();
2461 }
2462
2463 $shop = $this->user_model->get_all_details(SELLER, array('seller_id'=>$this->checkLogin('U')));
2464 if (!empty(reset($shop->result_array()))) {
2465 $this->data['bankList'] = $this->finance_model->getBankList()->result_array();
2466 $this->data['userBankList'] = $this->user_model->get_all_details(USER_BANKS, array('user_id' => $this->checkLogin('U'), 'default' => 'true'))->result_array();
2467 }
2468
2469 $this->data['heading'] = $this->config->item('email_title').' - Public Profile';
2470 $this->load->view("site/user/public_profile", $this->data);
2471
2472 }
2473
2474 /**
2475 *
2476 * Update the public profile page
2477 *
2478 */
2479 public function update_public_profile(){
2480
2481 if ($this->checkLogin('U') == '') {
2482 $lg_login = addslashes(shopsy_lg('lg_login','You must login'));
2483 $this->setErrorMessage('error',$lg_login);
2484 redirect(base_url());
2485 }
2486
2487 $gender = addslashes(trim($this->input->post('gender')));
2488 $country = addslashes(strip_tags(trim($this->input->post('country'))));
2489 $state = addslashes(strip_tags(trim($this->input->post('state'))));
2490 $city = addslashes(strip_tags(trim($this->input->post('city'))));
2491 $kecamatan = addslashes(strip_tags(trim($this->input->post('kecamatan'))));
2492 $kelurahan = addslashes(strip_tags(trim($this->input->post('kelurahan'))));
2493 $birth = addslashes(trim($this->input->post('year')))."-".addslashes(trim($this->input->post('month')))."-".addslashes(trim($this->input->post('day')));
2494 $about = addslashes(strip_tags(trim($this->input->post('about'))));
2495 $favorite_materials = addslashes(strip_tags(trim($this->input->post('favorite_materials'))));
2496 $postal_code = addslashes(strip_tags(trim($this->input->post('postal_code'))));
2497 $phone_no = addslashes(strip_tags(trim($this->input->post('phone_no'))));
2498 $id_number = addslashes(strip_tags(trim($this->input->post('id_number'))));
2499
2500 $include_profile=implode(',', $this->input->post('include_profile'));
2501
2502 if ($_FILES['profile_pict']['name'] != "")
2503 {
2504 $config['overwrite'] = TRUE;
2505 $config['allowed_types'] = 'jpg|jpeg|gif|png';
2506 $config['upload_path'] = 'images/users';
2507 $this->load->library('upload', $config);
2508
2509 if ($this->upload->do_upload('profile_pict', time())) {
2510 // echo("arg1"); die;
2511 $logoDetails = $this->upload->data();
2512
2513 @copy('./images/users/'.$logoDetails['file_name'], './images/users/thumb/'.$logoDetails['file_name']);
2514 //$this->ImageResizeWithCrop(210, 210, $logoDetails['file_name'], './images/users/thumb/');
2515
2516 $this->image_crop_process_auto(160, 160, $_POST['left'], $_POST['top'], $_POST['width'], $_POST['height'], $logoDetails['file_name'], './images/users/thumb/');
2517 $this->ImageResizeWithCrop(600, 600, $logoDetails['file_name'], './images/users/');
2518
2519 $profile_image = $logoDetails['file_name'];
2520 //echo $profile_image;die;
2521
2522 $dataArr = array(
2523 'postal_code' => $postal_code,
2524 'kecamatan' => $kecamatan,
2525 'kelurahan' => $kelurahan,
2526 'state' => $state,
2527 'city' => $city,
2528 'country' => $country,
2529 'gender' => $gender,
2530 'birthday' => $birth,
2531 'about' => strip_tags($about),
2532 'favorite_materials' => strip_tags($favorite_materials),
2533 'include_profile' => $include_profile,
2534 'thumbnail' => $logoDetails['file_name'],
2535 'phone_no' => $phone_no,
2536 'id_number' => $id_number
2537 );
2538
2539 }
2540 else
2541 {
2542 $this->setErrorMessage('error',"There was a problem with your image");
2543 redirect("public-profile");
2544 }
2545 }
2546 else
2547 {
2548 $dataArr = array(
2549 'postal_code' => $postal_code,
2550 'kecamatan' => $kecamatan,
2551 'kelurahan' => $kelurahan,
2552 'state' => $state,
2553 'city' => $city,
2554 'country' => $country,
2555 'gender' => $gender,
2556 'birthday' => $birth,
2557 'about' => strip_tags($about),
2558 'favorite_materials' => strip_tags($favorite_materials),
2559 'include_profile' => $include_profile,
2560 'thumbnail' => $logoDetails['file_name'],
2561 'phone_no' => $phone_no,
2562 'id_number' => $id_number
2563 );
2564 }
2565
2566 // TEMPORARY
2567 if (!empty($this->input->post('bank_code'))) {
2568 $condition = array();
2569 $condition['user_id'] = $this->checkLogin('U');
2570 $condition['default'] = 'true';
2571 }
2572 $existingBankData = $this->user_model->get_all_details(USER_BANKS, $condition)->result();
2573
2574 if (empty($existingBankData)) {
2575 $bankData = $condition;
2576 $bankData['bank_id'] = $this->input->post('bank_code');
2577 $bankData['account_num'] = $this->input->post('bank_no');
2578 $bankData['account_name'] = '';
2579 $bankData['branch'] = '';
2580 $this->user_model->simple_insert(USER_BANKS, $bankData);
2581 } else {
2582 $bankData['bank_id'] = $this->input->post('bank_code');
2583 $bankData['account_num'] = $this->input->post('bank_no');
2584 $this->user_model->update_details(USER_BANKS, $bankData, $condition);
2585 }
2586
2587 // echo "<pre>";print_r($this->checkLogin('U'));die;
2588 $this->user_model->update_details(USERS, $dataArr, array('id'=>$this->checkLogin('U')));
2589 if($this->db->affected_rows() > 0)
2590 {
2591 $profile_update = addslashes(shopsy_lg('lg_ur_profile_updated','Your profile successfully updated'));
2592 $this->setErrorMessage('success',$profile_update);
2593 redirect("public-profile");
2594 }
2595 else
2596 {
2597 $no_updation=addslashes(shopsy_lg('lg_noupdation','No updation on your profile'));
2598 $this->setErrorMessage('success', $no_updation);
2599 redirect("public-profile");
2600 }
2601 }
2602
2603 /**
2604 *
2605 * Load Account Bank
2606 *
2607 */
2608 function account_bank()
2609 {
2610 if ($this->checkLogin('U') == ''){
2611 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
2612 $this->setErrorMessage('error',$lg_login);
2613 redirect(base_url());
2614 }
2615
2616 $where = array(
2617 'user_id' => $this->checkLogin('U'),
2618 'default' => 'true'
2619 );
2620 $this->data['account'] = $this->user_model->get_all_details(USER_BANKS, $where)->result_array();
2621 $this->data['account'] = $this->data['account'][0];
2622
2623 $this->data['bankList'] = $this->finance_model->getBankList()->result_array();
2624 $this->data['bankOptions'] = '';
2625 foreach ($this->data['bankList'] as $bank) {
2626 if ($bank['id'] == $this->data['account']['bank_id']) {
2627 $this->data['account']['bank_name'] = $bank['bank_name'];
2628 }
2629 $this->data['bankOptions'] .= '<option value="'.$bank['id'].'">'.$bank['bank_name'].'</option>';
2630 }
2631
2632 $this->data['heading'] = $this->config->item('email_title').' - Bank Account';
2633 $this->load->view("site/user/account_bank",$this->data);
2634 }
2635
2636 function get_bank_account($accountId) {
2637 $bank_account = $this->user_model->get_all_details(USER_BANKS, array('id'=>$accountId))->result_array();
2638
2639 echo json_encode($bank_account);
2640 }
2641
2642 function add_account_bank() {
2643
2644 $password = $this->input->post('password');
2645 $where = array(
2646 'id' => $this->checkLogin('U'),
2647 'password' => md5($password)
2648 );
2649 $existingUser = $this->user_model->get_all_details(USERS, $where)->result_array();
2650 $existingUser = $existingUser[0];
2651
2652 if ($existingUser['id'] == $this->checkLogin('U') && $existingUser['password'] == md5($password)) {
2653 $data = array(
2654 'user_id' => $this->checkLogin('U'),
2655 'account_name' => trim($this->input->post('name_account')),
2656 'account_num' => trim($this->input->post('no_bank')),
2657 'bank_id' => trim($this->input->post('bank_name')),
2658 'branch' => trim($this->input->post('branch_bank')),
2659 'default' => 'true'
2660 );
2661
2662 $this->user_model->simple_insert(USER_BANKS, $data);
2663
2664 $edit_account_bank = addslashes('Rekening bank berhasil ditambahkan');
2665 $this->setErrorMessage('success', $edit_account_bank);
2666 } else {
2667 $edit_account_bank = addslashes('Invalid password');
2668 $this->setErrorMessage('error', $edit_account_bank);
2669
2670 }
2671
2672 redirect('settings/account-bank');
2673 }
2674
2675 function edit_account_bank() {
2676
2677 $password = $this->input->post('password');
2678 $where = array(
2679 'id' => $this->checkLogin('U'),
2680 'password' => md5($password)
2681 );
2682 $existingUser = $this->user_model->get_all_details(USERS, $where)->result_array();
2683 $existingUser = $existingUser[0];
2684
2685 if ($existingUser['id'] == $this->checkLogin('U') && $existingUser['password'] == md5($password)) {
2686 $data = array(
2687 'account_name' => trim($this->input->post('name_account')),
2688 'account_num' => trim($this->input->post('no_bank')),
2689 'bank_id' => trim($this->input->post('bank_name')),
2690 'branch' => trim($this->input->post('branch_bank'))
2691 );
2692
2693 $this->user_model->update_details(USER_BANKS, $data, array('id' => $this->input->post('bankid')));
2694
2695 $edit_account_bank = addslashes('Rekening bank berhasil diupdate');
2696 $this->setErrorMessage('success', $edit_account_bank);
2697 } else {
2698 $edit_account_bank = addslashes('Invalid password');
2699 $this->setErrorMessage('error', $edit_account_bank);
2700
2701 }
2702
2703 redirect('settings/account-bank');
2704 }
2705
2706 /**
2707 *
2708 * Remove Account Bank
2709 *
2710 */
2711 function remove_account_bank($id)
2712 {
2713 if ($this->checkLogin('U') == ''){
2714 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
2715 $this->setErrorMessage('error',$lg_login);
2716 redirect(base_url());
2717 }
2718 //echo $id;die;
2719 $this->user_model->commonDelete(USER_BANKS,array('id' => $id));
2720 $delete_account_bank=addslashes(shopsy_lg('lg_delete_bank_account','Rekening bank berhasil dihapus'));
2721 $this->setErrorMessage('success',$delete_account_bank);
2722 redirect('settings/account-bank');
2723 }
2724
2725
2726 /**
2727 *
2728 * Load the view people page
2729 *
2730 */
2731 function view_people($uname)
2732 {
2733 if ($this->checkLogin('U') == '')
2734 {
2735 // echo $this->checkLogin('U');die;
2736 $lg_login = addslashes(shopsy_lg('lg_login','You must login'));
2737 $this->setErrorMessage('error', $lg_login);
2738 redirect(base_url());
2739 }
2740 else
2741 {
2742 $curenUserId = $this->session->userdata('shopsy_session_user_id');
2743 $curenUserName = $this->session->userdata('shopsy_session_user_name');
2744
2745 $username = urldecode($this->uri->segment(2,0));
2746 $this->data['viewprofile'] = $this->user_model->get_all_details(USERS,array('user_name'=>$username,'status'=>'Active'));
2747 if($this->data['viewprofile']->num_rows()==0){
2748 show_404();
2749 }
2750
2751 if($curenUserId!=$this->data['viewprofile']->row()->id){
2752 redirect(base_url('view-profile/'.$curenUserName));
2753 }
2754
2755 $username = urldecode($this->uri->segment(2,0));
2756 $this->data['userProfileDetails']= $this->user_model->get_all_details(USERS,array('user_name'=>$username));
2757 $userProfileDetails=$this->data['viewprofile']->result_array();
2758 //echo '<pre>'; print_r($userProfileDetails); die;
2759 if($this->checkLogin('U')!=""){
2760 $activity_id=$userProfileDetails[0]['id'];
2761 $this->product_model->ExecuteQuery("UPDATE ".NOTIFICATIONS." SET `view_mode` = 'No' WHERE user_id=".$activity_id." AND (activity='favorite shop' OR activity='unfavorite shop' OR activity='follow' OR activity='unfollow')");
2762 }
2763 $include_profile=@explode(',',$userProfileDetails[0]['include_profile']);
2764
2765 /*Get the shop own shop products*/
2766 $this->data['ownShop'] = $this->product_model->get_all_details(SELLER,array('seller_id' => $userProfileDetails[0]['id']))->result_array();
2767 $this->data['ownProduct'] = $this->product_model->get_all_details(PRODUCT,array('user_id' => $userProfileDetails[0]['id'],'status'=>"Publish",'pay_status'=>"Paid"))->result_array();
2768 //echo $this->db->last_query(); die;
2769
2770 /*Get the teams list*/
2771 $userId=$userProfileDetails[0]['id'];
2772 if($userId!=''){
2773 $this->load->model('community_model');
2774 $condition=array(TEAMS.'.teamCaptainId !='=>$userId);
2775 $condition1=array(TEAMS.'.teamCaptainId '=>$userId);
2776 $this->db->limit(3);
2777 $UserteamsList=$this->community_model->get_all_Teams($condition1);
2778 $this->data['ownTeamList'] = $UserteamsList->result_array();
2779 }
2780 #echo '<pre>'; print_r($UserteamsList); die;
2781
2782
2783
2784 /*Get the favorite items details*/
2785 $this->data['userFavoriteItems']=$userFavoriteItems = $this->product_model->getFavoriteProduct($userProfileDetails[0]['id'])->result_array();
2786 /*Get the List items details*/
2787 $this->data['userListDetails']=$userListDetails = $this->user_model->get_all_details(LISTS_DETAILS,array('user_id'=>$userProfileDetails[0]['id']))->result_array();
2788
2789
2790 $this->data['userFavoriteShops']=$userFavoriteShops = $this->product_model->getFavoriteShops($userProfileDetails[0]['id'])->result_array();
2791 $userFavoriteShopsProducts=array();
2792 foreach($userFavoriteShops as $shops){
2793 $condition="p.user_id=".$shops['seller_id']." GROUP BY a.product_id";
2794 $products=$this->product_model->get_product_from_favorite_shop($condition)->result_array();
2795 $userFavoriteShopsProducts[$shops['seller_id']]=$products; #array_merge($userFavoriteShopsProducts,$products);
2796 }
2797 $this->data['userFavoriteShopsProducts']=$userFavoriteShopsProducts ;
2798
2799 //echo "<pre>"; print_r($userListDetails); die;
2800 $this->data['heading'] = $this->config->item('email_title').' - Profile';
2801 $this->load->view("site/user/view_profile",$this->data);
2802 }
2803 }
2804
2805
2806 /**
2807 *
2808 * Load Purchase and Review
2809 *
2810 */
2811
2812 function purchase_review($pType='')
2813 {
2814 // echo "Tesss"; exit;
2815
2816 if ($this->checkLogin('U') == '')
2817 {
2818 $lg_login = addslashes(shopsy_lg('lg_login','You must login'));
2819 $this->setErrorMessage('error', $lg_login);
2820 redirect(base_url());
2821 }
2822
2823 $this->data['purchasestatus'] ='';
2824 $this->data['PublicProfile'] = $this->user_model->get_all_details(USERS,array('id'=>$this->checkLogin('U'),'status'=>'Active'));
2825 //$this->data['userPurchase'] = $userPurchase = $this->user_model->get_user_purchase_list($this->checkLogin('U'),'',"Paid");
2826 $this->data['userPurchase'] = $userPurchase = $this->user_model->get_user_purchase_list($this->checkLogin('U'),'',"");
2827 //echo $this->db->last_query();exit;
2828 // echo "<pre>"; print_r($userPurchase->result()); die;
2829
2830 if($this->input->get('query')!='')
2831 {
2832 $this->data['userPurchase']= $userPurchase=$this->user_model->get_user_purchase_list($this->checkLogin('U'),$this->input->get('query'));
2833 }
2834
2835 if($pType!='')
2836 {
2837 if($pType=='processing')
2838 {
2839 $condition ='Not received yet';
2840 $this->data['userPurchase']= $userPurchase=$this->user_model->get_user_purchase_list($this->checkLogin('U'),'',$condition);
2841 }
2842 else if($pType == 'received')
2843 {
2844 $condition = 'Product received';
2845 $this->data['userPurchase']= $userPurchase=$this->user_model->get_user_purchase_list($this->checkLogin('U'),'',$condition);
2846 }
2847 else if($pType=='cancelled')
2848 {
2849 $condition='Pending';
2850 $this->data['userPurchase']= $userPurchase=$this->user_model->get_user_purchase_Clist($this->checkLogin('U'),'',$condition);
2851 #echo $this->db->last_query();die;
2852 }
2853 #echo "<pre>";print_r($this->data['userPurchase']);die;
2854 //$this->data['userPurchase']= $userPurchase=$this->user_model->get_user_purchase_list($this->checkLogin('U'),'',$condition);
2855 $this->data['purchasestatus']='Cancelled';
2856 }
2857
2858 //********* Cash on Delivery Checking ****************
2859 if($pType=="cod")
2860 {
2861 $condition='COD';
2862 $this->data['userPurchase']= $userPurchase = $this->user_model->get_user_purchase_list1($this->checkLogin('U'),'',$condition);
2863 $this->data['purchasestatus']='Cash on Delivery';
2864 //$this->load->view("site/user/purchase_review",$this->data);
2865 }
2866 //********* Cash on Delivery Checking ends ****************
2867
2868 //********* Kreditplus Checking ****************
2869 if($pType=="kreditplus")
2870 {
2871 $condition='kreditplus';
2872 $this->data['userPurchase']= $userPurchase = $this->user_model->get_user_purchase_list1($this->checkLogin('U'),'', $condition);
2873 $this->data['purchasestatus']='Kreditplus';
2874 //$this->load->view("site/user/purchase_review",$this->data);
2875 }
2876 //********* Kreditplus Checking ends ****************
2877
2878 //********wire transfer checks starts****************
2879 if($pType=="wiretransfer")
2880 {
2881 $condition='wire_transfer';
2882 $this->data['userPurchase'] = $userPurchase =$this->user_model->get_user_purchase_list1($this->checkLogin('U'),'',$condition);
2883 $this->data['purchasestatus'] = 'Wire Transfer';
2884 }
2885 //********wire transfer checks ends****************//
2886
2887 if($pType == "westernunion")
2888 {
2889 $condition='western_union';
2890 $this->data['userPurchase']= $userPurchase=$this->user_model->get_user_purchase_list1($this->checkLogin('U'),'',$condition);
2891 $this->data['purchasestatus']='Western Union';
2892 }
2893
2894 //$this->data['purchaseProducts']= $purchaseProducts=$userPurchase->result();
2895 $purchaseProducts = $userPurchase->result();
2896
2897 //echo '<pre>';print_r($userPurchase->result(););exit;
2898
2899
2900 foreach($purchaseProducts as $key => $pro)
2901 {
2902 $review = $this->user_model->get_all_details(PRODUCT_FEEDBACK, array('voter_id'=>$pro->user_id,'seller_product_id'=>$pro->product_id,'deal_code'=>$pro->dealCodeNumber))->row('rating');
2903 if(empty($review))
2904 {
2905 $review = '';
2906 }
2907 //echo "<pre>"; print_r($review);
2908 $purchaseProducts[$key]->starrating = $review ;
2909
2910 $seourl = $this->user_model->get_all_details(PRODUCT,array('id'=>$pro->product_id))->row('seourl');
2911
2912 if(empty($seourl))
2913 {
2914 $seourl = '';
2915 }
2916
2917 $purchaseProducts[$key]->productSeourl = $seourl ;
2918
2919 }
2920
2921 //echo "xxx<pre>"; print_r($purchaseProducts); die;
2922
2923 $this->data['purchaseProducts']= $purchaseProducts;
2924
2925 $this->data['heading'] = $this->config->item('email_title').' - Purchases and Review';
2926
2927 $this->uri->segment(2)=='' ? $default_view='' : $default_view='_'.$this->uri->segment(2);
2928
2929 $this->load->view("site/user/purchase_review".$default_view,$this->data);
2930
2931 }
2932
2933 /**
2934 *
2935 * Load Account Shipping
2936 *
2937 */
2938 function account_shipping_address()
2939 {
2940 if ($this->checkLogin('U') == ''){
2941 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
2942 $this->setErrorMessage('error',$lg_login);
2943 redirect(base_url());
2944 }
2945 $this->data['shipping_address']=$this->user_model->get_all_details(SHIPPING_ADDRESS,array('user_id'=>$this->checkLogin('U')))->result_array();
2946 $this->data['country']=$this->user_model->get_all_details(COUNTRY_LIST,array(),array(array('field'=>'name','type'=>'asc')))->result_array();
2947 //echo $this->db->last_query();
2948 //echo "<pre>";print_r($data['country']->result_array());die;
2949
2950 $this->data['heading'] = $this->config->item('email_title').' - Shipping Address';
2951 $this->load->view("site/user/shipping_address",$this->data);
2952 }
2953
2954 function get_shipping_address($shippingAddressId) {
2955 $address = $this->user_model->get_all_details(SHIPPING_ADDRESS,array('id'=>$shippingAddressId))->result_array();
2956
2957 echo json_encode($address);
2958 }
2959
2960 /**
2961 *
2962 * Add Account Shipping Address
2963 *
2964 */
2965 function add_shipping_address()
2966 {
2967 // echo "<pre>";print_r($this->input->post());die;
2968 if ($this->checkLogin('U') == ''){
2969 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
2970 $this->setErrorMessage('error',$lg_login);
2971 redirect('settings/account-shipping-address');
2972 }
2973
2974 $country=trim(addslashes($this->input->post("country")));
2975 $full_name=trim(addslashes($this->input->post("name")));
2976 $address1=trim(addslashes($this->input->post("address1")));
2977 $address2=trim(addslashes($this->input->post("address2")));
2978 $city=trim(addslashes($this->input->post("city")));
2979 $kelurahan=trim(addslashes($this->input->post("kelurahan")));
2980 $kecamatan=trim(addslashes($this->input->post("kecamatan")));
2981 $province=trim(addslashes($this->input->post("province")));
2982 $city=trim(addslashes($this->input->post("city")));
2983 $postal_code=trim(addslashes($this->input->post("postal_code")));
2984 $phone=trim(addslashes($this->input->post("phone")));
2985
2986
2987 if($city != '' &&$full_name!="" && $address1!="" && $city!="" && $province!="" && $postal_code!="" && $phone!=""){
2988
2989 $dataArr = array(
2990 'user_id' => $this->checkLogin('U'),
2991 'full_name' => $full_name,
2992 'address1' => $address1,
2993 'address2' => $address2,
2994 'city' => $city,
2995 'kelurahan' => $kelurahan,
2996 // 'kecamatan' => $kecamatan,
2997 'state' => $province,
2998 'country' => $country,
2999 'postal_code' => $postal_code,
3000 'phone' => $phone,
3001 'district' => $kecamatan
3002 );
3003 $result=$this->user_model->get_all_details(SHIPPING_ADDRESS, $dataArr);
3004
3005 if($result->num_rows() > 0){
3006 $ship_add_alreadyexist=addslashes(shopsy_lg('lg_shipad_alreadyexist','Alamat pengiriman sudah ada'));
3007 $this->setErrorMessage('error',$ship_add_alreadyexist);
3008 redirect('settings/account-shipping-address');
3009 }
3010 $ship_address=addslashes(shopsy_lg('lg_ship_addr_added_sucesss','Alamat pengiriman berhasil ditambahkan'));
3011 $this->user_model->simple_insert(SHIPPING_ADDRESS,$dataArr);
3012 $this->setErrorMessage('success',$ship_address);
3013 redirect('settings/account-shipping-address');
3014 }
3015 else
3016 {
3017 if($this->lang->line('details_req_fields') != '') { $details_req_fields= stripslashes($this->lang->line('details_req_fields')); } else { $details_req_fields = "Enter details in required fields"; }
3018 $this->setErrorMessage('error',$details_req_fields);
3019 redirect('settings/account-shipping-address');
3020 }
3021 }
3022
3023 function edit_shipping_address()
3024 {
3025 $id = $this->input->post("shippingid");
3026 $country = trim(addslashes($this->input->post("country")));
3027 $full_name = trim(addslashes($this->input->post("name")));
3028 $address1 = trim(addslashes($this->input->post("address1")));
3029 $address2 = trim(addslashes($this->input->post("address2")));
3030 $city = trim(addslashes($this->input->post("city")));
3031 $kelurahan=trim(addslashes($this->input->post("kelurahan")));
3032 $kecamatan=trim(addslashes($this->input->post("kecamatan")));
3033 $province = trim(addslashes($this->input->post("province")));
3034 $postal_code = trim(addslashes($this->input->post("postal_code")));
3035 $phone = trim(addslashes($this->input->post("phone")));
3036
3037 if($id != '' && $city != '' && $full_name != "" && $address1 != "" && $province != "" && $postal_code != "" && $phone != ""){
3038
3039 $dataArr = array(
3040 'full_name' => $full_name,
3041 'address1' => $address1,
3042 'address2' => $address2,
3043 'city' => $city,
3044 // 'kecamatan' => $kecamatan,
3045 'kelurahan' => $kelurahan,
3046 'state' => $province,
3047 'country' => $country,
3048 'postal_code' => $postal_code,
3049 'phone' => $phone,
3050 'district' => $kecamatan
3051 );
3052
3053 $this->user_model->update_details(SHIPPING_ADDRESS, $dataArr, array('id' => $id));//var_dump($this->db->last_query());die;
3054 $ship_address = addslashes(shopsy_lg('lg_ship_addr_edit_sucesss','Alamat pengiriman berhasil diupdate'));
3055 $this->setErrorMessage('success',$ship_address);
3056 redirect('settings/account-shipping-address');
3057 }
3058 else
3059 {
3060 if($this->lang->line('details_req_fields') != '') {
3061 $details_req_fields= stripslashes($this->lang->line('details_req_fields'));
3062 } else {
3063 $details_req_fields = "Enter details in required fields";
3064 }
3065 $this->setErrorMessage('error',$details_req_fields);
3066 redirect('settings/account-shipping-address');
3067 }
3068 }
3069
3070
3071 /**
3072 *
3073 * Cart Load Shipping Address
3074 *
3075 */
3076 function cart_shipping_address()
3077 {
3078 if ($this->checkLogin('U') == ''){
3079 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
3080 $this->setErrorMessage('error',$lg_login);
3081 redirect(base_url()."login?redirect=cart");
3082 }
3083
3084 $this->data['country']=$this->user_model->get_all_details(COUNTRY_LIST,array(),array(array('field'=>'name','type'=>'asc')))->result_array();
3085 $this->data['heading'] = $this->config->item('email_title').' - Shipping Address';
3086 $this->load->view("site/user/cart_shipping_address", $this->data);
3087
3088 }
3089
3090 /**
3091 *
3092 * Add Cart Shipping Address
3093 *
3094 */
3095 function cart_add_shipping_address()
3096 {
3097 // echo "<pre>";print_r($this->input->post());die;
3098 if ($this->checkLogin('U') == ''){
3099 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
3100 $this->setErrorMessage('error',$lg_login);
3101 redirect('cart');
3102 }
3103
3104 $country=trim(addslashes($this->input->post("country")));
3105 $full_name=trim(addslashes($this->input->post("name")));
3106 $address1=trim(addslashes($this->input->post("address1")));
3107 $address2=trim(addslashes($this->input->post("address2")));
3108 $city=trim(addslashes($this->input->post("city")));
3109 $province=trim(addslashes($this->input->post("province")));
3110 $city=trim(addslashes($this->input->post("city")));
3111 $postal_code=trim(addslashes($this->input->post("postal_code")));
3112 $phone=trim(addslashes($this->input->post("phone")));
3113
3114 $kecamatan = trim(addslashes($this->input->post("kecamatan")));
3115 $kelurahan = trim(addslashes($this->input->post("kelurahan")));
3116
3117
3118 if($city != '' &&$full_name!="" && $address1!="" && $city!="" && $postal_code!="" && $phone!=""
3119 && $kecamatan!="" && $kelurahan!=""){
3120
3121 $dataArr=array('user_id'=>$this->checkLogin('U'),
3122 'full_name'=>$full_name,
3123 'address1'=>$address1,
3124 'address2'=>$address2,
3125 'city'=>$city,
3126 // 'kecamatan' => $kecamatan,
3127 'kelurahan' => $kelurahan,
3128 'state'=>$province,
3129 'country'=>$country,
3130 'postal_code'=>$postal_code,
3131 'phone'=>$phone,
3132 'district'=>$kecamatan,
3133 'kelurahan'=>$kelurahan);
3134
3135 $result=$this->user_model->get_all_details(SHIPPING_ADDRESS, $dataArr);
3136
3137 if($result->num_rows()>0){
3138 $ship_add_alreadyexist=addslashes(shopsy_lg('lg_shipad_alreadyexist','This address already exist'));
3139 $this->setErrorMessage('error',$ship_add_alreadyexist);
3140 redirect('settings/cart-shipping-address');
3141 }
3142 $ship_address=addslashes(shopsy_lg('lg_ship_addr_added_sucesss','Shipping address added successfully'));
3143 $this->user_model->simple_insert(SHIPPING_ADDRESS,$dataArr);
3144 $this->setErrorMessage('success',$ship_address);
3145 redirect('cart');
3146 }
3147 else
3148 {
3149 if($this->lang->line('details_req_fields') != '') { $details_req_fields= stripslashes($this->lang->line('details_req_fields')); } else { $details_req_fields = "Enter details in required fields"; }
3150 $this->setErrorMessage('error',$details_req_fields);
3151 redirect('settings/cart-shipping-address');
3152 }
3153 }
3154
3155 /**
3156 *
3157 * Remove Shipping Address user
3158 *
3159 */
3160 function remove_shipping_address($id)
3161 {
3162 if ($this->checkLogin('U') == ''){
3163 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
3164 $this->setErrorMessage('error',$lg_login);
3165 redirect(base_url());
3166 }
3167 //echo $id;die;
3168 $this->user_model->commonDelete(SHIPPING_ADDRESS,array('id'=>$id));
3169 $delete_ship_address=addslashes(shopsy_lg('lg_delete_ship_address','Shipping address deleted successfully'));
3170 $this->setErrorMessage('success',$delete_ship_address);
3171 redirect('settings/account-shipping-address');
3172 }
3173
3174 /**
3175 *
3176 * Remove Credit card options
3177 *
3178 */
3179 function remove_creadit_card($id)
3180 {
3181 if ($this->checkLogin('U') == ''){
3182 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
3183 $this->setErrorMessage('error',$lg_login);
3184 redirect('login');
3185 }
3186 //echo $id;die;
3187 $this->user_model->commonDelete(CREDITCARDS,array('user_id'=>$this->checkLogin('U')));
3188 $remove_card=addslashes(shopsy_lg('lg_remove_card','Your Credit Card Informations Removed successfully'));
3189 $this->setErrorMessage('success',$remove_card);
3190 redirect('settings/account-creditcard');
3191 }
3192
3193 /**
3194 *
3195 * Remove Account Shipping
3196 *
3197 */
3198 function remove_order($dealCodeNumber)
3199 {
3200 if ($this->checkLogin('U') == ''){
3201 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
3202 $this->setErrorMessage('error',$lg_login);
3203 redirect(base_url());
3204 }
3205 $this->user_model->commonDelete(USER_PAYMENT,array('dealCodeNumber'=>$dealCodeNumber));
3206 $this->setErrorMessage('success','Order deleted successfully');
3207 redirect('purchase-review');
3208 }
3209
3210 /**
3211 *
3212 * Load account email
3213 *
3214 */
3215 function account_email()
3216 {
3217 if ($this->checkLogin('U') == ''){
3218 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
3219 $this->setErrorMessage('error',$lg_login);
3220 redirect(base_url());
3221 }
3222 //$data['PublicProfile'] = $this->user_model->get_all_details(USERS,array('id'=>$this->checkLogin('U'),'status'=>'Active'));
3223 $this->data['heading'] = $this->config->item('email_title').' - Email Settings';
3224 $this->load->view("site/user/email",$this->data);
3225
3226 }
3227
3228 /**
3229 *
3230 * Load Remove Account
3231 *
3232 */
3233 function account_remove()
3234 {
3235 $this->form_validation->set_rules('password', 'Password', 'required');
3236 if ($this->checkLogin('U') == ''){
3237 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
3238 $this->setErrorMessage('error',$lg_login);
3239 redirect(base_url());
3240 }
3241 //echo 'xxx';die;
3242 $this->data['heading'] = $this->config->item('email_title').' - Remove Account';
3243 $this->load->view("site/user/account_remove",$this->data);
3244 }
3245
3246
3247 /**
3248 *
3249 * add follow to the user
3250 *
3251 */
3252
3253 public function add_follow(){
3254 #die;echo "<pre>";print_r($this->data['notification_emailArr']);die;
3255 $returnStr['status_code'] = 0;
3256 if ($this->checkLogin('U') != ''){
3257 $follow_id = $this->input->post('user_id');
3258
3259 $checkloginIDarr=$this->session->all_userdata();
3260 $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
3261 $userDetails = $this->user_model->get_all_details(USERS,array('id'=>$loggeduserID));
3262 #echo $this->data['userDetails']->row()->following;die;
3263 $followingListArr = explode(',', $userDetails->row()->following);
3264 if (!in_array($follow_id, $followingListArr)){
3265 $followingListArr[] = $follow_id;
3266 $newFollowingList = implode(',', $followingListArr);
3267 $followingCount = $userDetails->row()->following_count;
3268 $followingCount++;
3269 $dataArr = array('following'=>$newFollowingList,'following_count'=>$followingCount);
3270 $condition = array('id'=>$this->checkLogin('U'));
3271 $this->user_model->update_details(USERS,$dataArr,$condition);
3272 $followUserDetails = $this->user_model->get_all_details(USERS,array('id'=>$follow_id));
3273 if ($followUserDetails->num_rows() == 1){
3274 $followersListArr = explode(',', $followUserDetails->row()->followers);
3275 if (!in_array($this->checkLogin('U'), $followersListArr)){
3276 $followersListArr[] = $this->checkLogin('U');
3277 $newFollowersList = implode(',', $followersListArr);
3278 $followersCount = $followUserDetails->row()->followers_count;
3279 $followersCount++;
3280 $dataArr = array('followers'=>$newFollowersList,'followers_count'=>$followersCount);
3281 $condition = array('id'=>$follow_id);
3282 $this->user_model->update_details(USERS,$dataArr,$condition);
3283 }
3284 }
3285 $actArr = array('activity'=>'follow',
3286 'activity_id'=>$follow_id,
3287 'user_id' =>$loggeduserID,
3288 'activity_ip'=>$this->input->ip_address(),
3289 'created'=>date("Y-m-d H:i:s"));
3290 $this->user_model->simple_insert(NOTIFICATIONS,$actArr);
3291 $sent_email=$this->user_model->get_all_details(USERS,array('id'=>$follow_id));
3292 $noty_email_arr=explode(',',$sent_email->row()->notification_email);
3293 if(in_array('follow',$noty_email_arr)){
3294 //$query=$this->user_model->get_all_details(USERS, array('id'= $follow_id));
3295 $full_name=$sent_email->row()->full_name;
3296 $cfull_name=$userDetails->row()->full_name;
3297 $user_name=$userDetails->row()->user_name;
3298 $newsid='9';
3299 $template_values=$this->user_model->get_newsletter_template_details($newsid);
3300
3301 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo']);
3302 extract($adminnewstemplateArr);
3303 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
3304 $message .= '<!DOCTYPE HTML>
3305 <html>
3306 <head>
3307 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
3308 <meta name="viewport" content="width=device-width"/>
3309 <title>'.$template_values['news_subject'].'</title>
3310 <body>';
3311 include('./newsletter/registeration'.$newsid.'.php');
3312
3313 $message .= '</body>
3314 </html>';
3315
3316
3317 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
3318 $sender_email=$this->config->item('site_contact_mail');
3319
3320 $sender_name=$this->config->item('email_title');
3321 }else{
3322 $sender_name=$template_values['sender_name'];
3323 $sender_email=$template_values['sender_email'];
3324 }
3325 $email_values = array('mail_type'=>'html',
3326 'from_mail_id'=>$sender_email,
3327 'mail_name'=>$sender_name,
3328 'to_mail_id'=>$sent_email->row()->email,
3329 'subject_message'=>'Follows',
3330 'body_messages'=>$message
3331 );
3332
3333 //echo '<pre>'; print_r($email_values); die;
3334
3335 $email_send_to_common = $this->product_model->common_email_send($email_values);#die;
3336 }
3337 $message=$checkloginIDarr['shopsy_session_user_name'].' started following you on '.$this->config->item('email_title');
3338 $type='follow';
3339 $this->sendPushNotification($follow_id,$message,$type,array($follow_id));
3340 $returnStr['status_code'] = 1;
3341 }else {
3342 $returnStr['status_code'] = 1;
3343 }
3344 }
3345 echo json_encode($returnStr);
3346 }
3347
3348 /**
3349 *
3350 * delete follow to the user
3351 *
3352 */
3353 public function delete_follow(){
3354 $returnStr['status_code'] = 0;
3355 if ($this->checkLogin('U') != ''){
3356 $follow_id = $this->input->post('user_id');
3357 $checkloginIDarr=$this->session->all_userdata();
3358 $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
3359 $userDetails = $this->user_model->get_all_details(USERS,array('id'=>$loggeduserID));
3360 $followingListArr = explode(',', $userDetails->row()->following);
3361 if (in_array($follow_id,$followingListArr)){
3362 if(($key = array_search($follow_id, $followingListArr)) !== false) {
3363 unset($followingListArr[$key]);
3364 }
3365 $newFollowingList = @implode(',', $followingListArr);
3366 $followingCount = $userDetails->row()->following_count;
3367 $followingCount--;
3368 $dataArr = array('following'=>$newFollowingList,'following_count'=>$followingCount);
3369 $condition = array('id'=>$loggeduserID);
3370 $this->user_model->update_details(USERS,$dataArr,$condition);
3371 $followUserDetails = $this->user_model->get_all_details(USERS,array('id'=>$follow_id));
3372 if ($followUserDetails->num_rows() == 1){
3373 $followersListArr = explode(',', $followUserDetails->row()->followers);
3374 if (in_array($this->checkLogin('U'), $followersListArr)){
3375 if(($key = array_search($this->checkLogin('U'), $followersListArr)) !== false) {
3376 unset($followersListArr[$key]);
3377 }
3378 $newFollowersList = implode(',', $followersListArr);
3379 $followersCount = $followUserDetails->row()->followers_count;
3380 $followersCount--;
3381 $dataArr = array('followers'=>$newFollowersList,'followers_count'=>$followersCount);
3382 $condition = array('id'=>$follow_id);
3383 $this->user_model->update_details(USERS,$dataArr,$condition);
3384 }
3385 }
3386
3387 $actArr = array('activity'=>'unfollow',
3388 'activity_id'=>$follow_id,
3389 'user_id' =>$loggeduserID,
3390 'activity_ip'=>$this->input->ip_address(),
3391 'created'=>date("Y-m-d H:i:s"));
3392 $this->user_model->simple_insert(NOTIFICATIONS,$actArr);
3393 $returnStr['status_code'] = 1;
3394 }else {
3395 $returnStr['status_code'] = 1;
3396 }
3397 }
3398 echo json_encode($returnStr);
3399 }
3400
3401 /**
3402 *
3403 * Display the user option private or public
3404 *
3405 */
3406 public function display_user_added(){
3407 $username = urldecode($this->uri->segment(2,0));
3408 $userProfileDetails = $this->user_model->get_all_details(USERS,array('user_name'=>$username));
3409 if ($userProfileDetails->num_rows()==1){
3410 if ($userProfileDetails->row()->visibility == 'Only you' && $userProfileDetails->row()->id != $this->checkLogin('U')){
3411 $this->data['heading'] = $this->config->item('email_title').' - Profile';
3412 $this->load->view('site/user/display_user_profile_private',$this->data);
3413 }else {
3414 $this->data['heading'] = $username;
3415 $this->data['userProfileDetails'] = $userProfileDetails;
3416 $this->data['recentActivityDetails'] = $this->user_model->get_activity_details($userProfileDetails->row()->id);
3417 $this->data['addedProductDetails'] = $this->product_model->view_product_details(' where p.user_id='.$userProfileDetails->row()->id.' and p.status="Publish"');
3418 $this->data['notSellProducts'] = $this->product_model->view_notsell_product_details(' where p.user_id='.$userProfileDetails->row()->id.' and p.status="Publish"');
3419 $this->data['heading'] = $this->config->item('email_title').' - Profile';
3420 $this->load->view('site/user/display_user_added',$this->data);
3421 }
3422 }else {
3423 redirect(base_url());
3424 }
3425 }
3426
3427 /**
3428 *
3429 * Add the public or private option
3430 *
3431 */
3432 public function display_user_add(){
3433
3434 $this->data['heading'] =$this->config->item('meta_title').' - Add product';
3435 $userProfileDetailss = $this->seller_model->get_sellers_store_details();
3436 $attribute_Val = $this->product_attribute_model->view_attribute_details(PRODUCT_ATTRIBUTE,array('status'=>'Active'));
3437 $shipping = $this->seller_model->get_all_details(SHIPPING,array('status'=>'Active'));
3438 $this->data['userProfileDetailss'] = $userProfileDetailss;
3439 $this->data['shipping'] = $shipping;
3440 $this->data['attribute_Val'] = $attribute_Val;
3441 $this->load->view('site/user/display_user_add',$this->data);
3442
3443 }
3444 /* public function user_add(){
3445 echo "<pre>";print_r($_POST); die;
3446
3447 $userProfileDetailss = $this->seller_model->get_sellers_store_details();
3448 $this->data['userProfileDetailss'] = $userProfileDetailss;
3449 $this->load->view('site/user/display_user_add',$this->data);
3450
3451 }*/
3452
3453 /**
3454 *
3455 * Display the user lists
3456 *
3457 */
3458 public function display_user_lists(){
3459 $username = urldecode($this->uri->segment(2,0));
3460 $userProfileDetails = $this->user_model->get_all_details(USERS,array('user_name'=>$username));
3461 if ($userProfileDetails->num_rows()==1){
3462 if ($userProfileDetails->row()->visibility == 'Only you' && $userProfileDetails->row()->id != $this->checkLogin('U')){
3463 $this->load->view('site/user/display_user_profile_private',$this->data);
3464 }else {
3465 $this->data['heading'] = $username;
3466 $this->data['userProfileDetails'] = $userProfileDetails;
3467 $this->data['recentActivityDetails'] = $this->user_model->get_activity_details($userProfileDetails->row()->id);
3468 $this->data['listDetails'] = $this->product_model->get_all_details(LISTS_DETAILS,array('user_id'=>$userProfileDetails->row()->id));
3469 if ($this->data['listDetails']->num_rows()>0){
3470 foreach ($this->data['listDetails']->result() as $listDetailsRow){
3471 $this->data['listImg'][$listDetailsRow->id] = '';
3472 if ($listDetailsRow->product_id != ''){
3473 $pidArr = array_filter(explode(',', $listDetailsRow->product_id));
3474
3475 $productDetails = '';
3476 if (count($pidArr)>0){
3477 foreach ($pidArr as $pidRow){
3478 if ($pidRow!=''){
3479 $productDetails = $this->product_model->get_all_details(PRODUCT,array('seller_product_id'=>$pidRow,'status'=>'Publish'));
3480 if ($productDetails->num_rows()==0){
3481 $productDetails = $this->product_model->get_all_details(USER_PRODUCTS,array('seller_product_id'=>$pidRow,'status'=>'Publish'));
3482 }
3483 if ($productDetails->num_rows()==1)break;
3484 }
3485 }
3486 }
3487 if ($productDetails != '' && $productDetails->num_rows()==1){
3488 $this->data['listImg'][$listDetailsRow->id] = $productDetails->row()->image;
3489 }
3490 }
3491 }
3492 }
3493 $this->load->view('site/user/display_user_lists',$this->data);
3494 }
3495 }else {
3496 redirect(base_url());
3497 }
3498 }
3499
3500
3501 /**
3502 *
3503 * Display the user followings
3504 *
3505 */
3506 public function display_user_following(){
3507 $username = urldecode($this->uri->segment(2,0));
3508 $userProfileDetails = $this->user_model->get_all_details(USERS,array('user_name'=>$username));
3509 #echo "<pre>"; print_r($userProfileDetails->result_array());
3510 if ($userProfileDetails->num_rows()==1){
3511 if ($userProfileDetails->row()->visibility == 'Only you' && $userProfileDetails->row()->id != $this->checkLogin('U')){
3512 $this->load->view('site/user/following_list',$this->data);
3513 }else {
3514 $this->data['heading'] = $username;
3515 $this->data['userProfileDetails'] = $userProfileDetails;
3516 $this->data['recentActivityDetails'] = $this->user_model->get_activity_details($userProfileDetails->row()->id);
3517 $fieldsArr = array('*');
3518 $searchName = 'id';
3519 $searchArr = explode(',', $userProfileDetails->row()->following);
3520 $joinArr = array();
3521 $sortArr = array();
3522 $limit = '';
3523 $followingUserDetails = $this->product_model->get_fields_from_many(USERS,$fieldsArr,$searchName,$searchArr,$joinArr,$sortArr,$limit);
3524 $this->data['followingUserDetails'] = $followingUserDetails->result_array();
3525 if ($followingUserDetails->num_rows()>0){
3526 foreach ($followingUserDetails->result() as $followingUserRow){
3527 $this->data['followingUserfavDetails'][$followingUserRow->id] = $this->user_model->get_userfav_products($followingUserRow->id);
3528 $this->data['followingUserfavProdDetails'][$followingUserRow->id] = $this->user_model->get_userfav_products($followingUserRow->id)->result_array();
3529 }
3530 }
3531 #echo "<pre>"; print_r($this->data['followingUserDetails']);
3532 #echo "<pre>"; print_r($this->data['followingUserfavProdDetails']); die;
3533 $this->data['heading'] = $this->config->item('email_title').' - Following List';
3534 $this->load->view('site/user/following_list',$this->data);
3535 }
3536 }else {
3537 redirect(base_url());
3538 }
3539 }
3540
3541 /**
3542 *
3543 * Display the user followers
3544 *
3545 */
3546 public function display_user_followers(){
3547 $username = urldecode($this->uri->segment(2,0));
3548 $userProfileDetails = $this->user_model->get_all_details(USERS,array('user_name'=>$username));
3549 $this->data['userProfileDetails'] =$this->user_model->get_all_details(USERS,array('user_name'=>$username));
3550 #echo "<pre>"; print_r($this->data['userProfileDetails']); die;
3551 if ($userProfileDetails->num_rows()==1){
3552 if ($userProfileDetails->row()->visibility == 'Only you' && $userProfileDetails->row()->id != $this->checkLogin('U')){
3553 #$this->load->view('site/user/display_user_profile_private',$this->data);
3554 }else {
3555 $this->data['heading'] = $username;
3556 $this->data['userProfileDetails'] = $userProfileDetails;
3557 $this->data['recentActivityDetails'] = $this->user_model->get_activity_details($userProfileDetails->row()->id);
3558 $fieldsArr = array('*');
3559 $searchName = 'id';
3560 $searchArr = explode(',', $userProfileDetails->row()->followers);
3561 $joinArr = array();
3562 $sortArr = array();
3563 $limit = '';
3564 $followingUserDetails = $this->product_model->get_fields_from_many(USERS,$fieldsArr,$searchName,$searchArr,$joinArr,$sortArr,$limit);
3565 $this->data['followingUserDetails'] = $followingUserDetails->result_array();
3566 if ($followingUserDetails->num_rows()>0){
3567 foreach ($followingUserDetails->result() as $followingUserRow){
3568 $this->data['followingUserfavDetails'][$followingUserRow->id] = $this->user_model->get_userfav_products($followingUserRow->id);
3569 $this->data['followingUserfavProdDetails'][$followingUserRow->id] = $this->user_model->get_userfav_products($followingUserRow->id)->result_array();
3570
3571 }
3572 }
3573 #echo "<pre>"; print_r($this->data['followingUserfavProdDetails']);
3574 #echo "<pre>"; print_r($this->data['followingUserfavDetails']); #die;
3575 $this->data['heading'] = $this->config->item('email_title').' - Follower List';
3576 $this->load->view('site/user/followers_list',$this->data);
3577 }
3578 }else {
3579 redirect(base_url());
3580 }
3581 }
3582
3583 /**
3584 *
3585 * To Create a new list for user
3586 * param String $name
3587 *
3588 */
3589 public function add_list($name=''){
3590 if ($this->checkLogin('U')!=''){
3591 $username = urldecode($this->uri->segment(2,0));
3592 if($name==''){
3593 $name=$this->input->post('list');
3594 }else{
3595 $rdir=1;
3596 }
3597 $listConditionArr = array('name'=>$name,'user_id'=>$this->checkLogin('U'));
3598 if($this->input->post('ddl'))
3599 {
3600 $productId=$this->input->post('productId');
3601 $listArr = array('name'=>$name,'product_id'=>$productId.',','user_id'=>$this->checkLogin('U'),'product_count'=>1);
3602 }
3603 else
3604 {
3605 $listArr = array('name'=>$name,'user_id'=>$this->checkLogin('U'));
3606 }
3607 $listCheck = $this->user_model->get_all_details(LISTS_DETAILS,$listConditionArr);
3608 #print_r($listCheck);
3609 #echo "<pre>"; print_r($listConditionArr); die;
3610 if ($listCheck->num_rows()==0){
3611 $this->user_model->simple_insert(LISTS_DETAILS,$listArr);
3612 $this->setErrorMessage('success', shopsy_lg('lg_list','List').' '.$name.' '.shopsy_lg('lg_created_success','created successfully'));
3613 if($this->input->post('ddl')){ redirect('');}
3614 redirect('/people/'.$this->session->userdata('shopsy_session_user_name').'/favorites');
3615 }
3616 else
3617 {
3618 $this->setErrorMessage('error',$name.' '.shopsy_lg('lg_already_in_list','is already in you List'));
3619 if($rdir){
3620 redirect('/people/'.$this->session->userdata('shopsy_session_user_name').'/favorites');
3621 }
3622 redirect('/people/'.$this->session->userdata('shopsy_session_user_name').'/favorites');
3623 }
3624
3625 }
3626 else
3627 {
3628 $this->setErrorMessage('error','Login Required');
3629 redirect('login?redirect='.$this->input->post("redirect"));
3630 #redirect('login?action='.urlencode('site/user/add_list/'.$this->input->post('list')));
3631 }
3632 }
3633
3634 /**
3635 *
3636 * To update a list for user
3637 * param String $id
3638 *
3639 */
3640 public function update_list($id=''){
3641 if ($this->checkLogin('U')!=''){
3642 $username = urldecode($this->uri->segment(2,0));
3643 $listId=$list_name=$this->input->post('list_Id');
3644 $list_name=$this->input->post('list_name');
3645 $privacy_level=$this->input->post('privacy_level');
3646
3647 if ($listId!=''){
3648 $dataArr = array('name'=>$list_name,'privacy'=>$privacy_level);
3649 $condition = array('id'=>$listId);
3650 #echo "<pre>"; print_r($dataArr); print_r($condition); die;
3651 $this->user_model->update_details(LISTS_DETAILS,$dataArr,$condition);
3652
3653 $this->setErrorMessage('success',shopsy_lg('lg_list','List').' '.$list_name.' '.shopsy_lg('lg_update_success','Updated successfully'));
3654
3655 redirect('/people/'.$this->session->userdata('shopsy_session_user_name').'/favorites/list/'.$listId.'-'.$list_name);
3656 }
3657 }
3658 else
3659 {
3660 $this->setErrorMessage('error','Login Required');
3661 redirect('login');
3662 }
3663 }
3664
3665 /**
3666 *
3667 * To add the product to the list
3668 *
3669 */
3670 public function add_item_to_lists(){
3671 $returnStr['status_code'] = 0;
3672 if ($this->checkLogin('U')==''){
3673 $lg_login=addslashes(shopsy_lg('lg_login','You must login'));
3674 $returnStr['message'] =$lg_login;
3675 }else {
3676 $tid = $this->input->post('tid');
3677 $lid = $this->input->post('list_ids');
3678 $listDetails = $this->user_model->get_all_details(LISTS_DETAILS,array('id'=>$lid));
3679 if ($listDetails->num_rows()==1){
3680 $product_ids = explode(',', $listDetails->row()->product_id);
3681 if (!in_array($tid, $product_ids)){
3682 array_push($product_ids, $tid);
3683 }
3684 $new_product_ids = implode(',', $product_ids);
3685 $this->user_model->update_details(LISTS_DETAILS,array('product_id'=>$new_product_ids),array('id'=>$lid));
3686 $returnStr['status_code'] = 1;
3687 }
3688 }
3689 echo json_encode($returnStr);
3690 }
3691
3692 /**
3693 *
3694 * To remove the product from the list
3695 *
3696 */
3697 public function remove_item_from_lists(){
3698 $returnStr['status_code'] = 0;
3699 if ($this->checkLogin('U')==''){
3700 $returnStr['message'] = 'You must login';
3701 }else {
3702 $tid = $this->input->post('tid');
3703 $lid = $this->input->post('list_ids');
3704 $listDetails = $this->user_model->get_all_details(LISTS_DETAILS,array('id'=>$lid));
3705 if ($listDetails->num_rows()==1){
3706 $product_ids = explode(',', $listDetails->row()->product_id);
3707 if (in_array($tid, $product_ids)){
3708 if(($key = array_search($tid, $product_ids)) !== false) {
3709 unset($product_ids[$key]);
3710 }
3711 }
3712 $new_product_ids = implode(',', $product_ids);
3713 $this->user_model->update_details(LISTS_DETAILS,array('product_id'=>$new_product_ids),array('id'=>$lid));
3714 $returnStr['status_code'] = 1;
3715 }
3716 }
3717 echo json_encode($returnStr);
3718 }
3719
3720 /**
3721 *
3722 * To add the want tag
3723 *
3724 */
3725 public function add_want_tag(){
3726 $returnStr['status_code'] = 0;
3727 if ($this->checkLogin('U')==''){
3728 $returnStr['message'] = 'You must login';
3729 }else {
3730 $tid = $this->input->post('thing_id');
3731 $wantDetails = $this->user_model->get_all_details(WANTS_DETAILS,array('user_id'=>$this->checkLogin('U')));
3732 if ($wantDetails->num_rows()==1){
3733 $product_ids = explode(',', $wantDetails->row()->product_id);
3734 if (!in_array($tid, $product_ids)){
3735 array_push($product_ids, $tid);
3736 }
3737 $new_product_ids = implode(',', $product_ids);
3738 $this->user_model->update_details(WANTS_DETAILS,array('product_id'=>$new_product_ids),array('user_id'=>$this->checkLogin('U')));
3739 }else {
3740 $dataArr = array('user_id'=>$this->checkLogin('U'),'product_id'=>$tid);
3741 $this->user_model->simple_insert(WANTS_DETAILS,$dataArr);
3742 }
3743 $wantCount = $this->data['userDetails']->row()->want_count;
3744 if ($wantCount<=0 || $wantCount==''){
3745 $wantCount = 0;
3746 }
3747 $wantCount++;
3748 $dataArr = array('want_count'=>$wantCount);
3749 $ownProducts = explode(',', $this->data['userDetails']->row()->own_products);
3750 if (in_array($tid, $ownProducts)){
3751 if (($key = array_search($tid, $ownProducts)) !== false){
3752 unset($ownProducts[$key]);
3753 }
3754 $ownCount = $this->data['userDetails']->row()->own_count;
3755 $ownCount--;
3756 $dataArr['own_count'] = $ownCount;
3757 $dataArr['own_products'] = implode(',', $ownProducts);
3758 }
3759 $this->user_model->update_details(USERS,$dataArr,array('id'=>$this->checkLogin('U')));
3760 $returnStr['status_code'] = 1;
3761 }
3762 echo json_encode($returnStr);
3763 }
3764
3765 /**
3766 *
3767 * To delete the want tag
3768 *
3769 */
3770 public function delete_want_tag(){
3771 $returnStr['status_code'] = 0;
3772 if ($this->checkLogin('U')==''){
3773 $returnStr['message'] = 'You must login';
3774 }else {
3775 $tid = $this->input->post('thing_id');
3776 $wantDetails = $this->user_model->get_all_details(WANTS_DETAILS,array('user_id'=>$this->checkLogin('U')));
3777 if ($wantDetails->num_rows()==1){
3778 $product_ids = explode(',', $wantDetails->row()->product_id);
3779 if (in_array($tid, $product_ids)){
3780 if(($key = array_search($tid, $product_ids)) !== false) {
3781 unset($product_ids[$key]);
3782 }
3783 }
3784 $new_product_ids = implode(',', $product_ids);
3785 $this->user_model->update_details(WANTS_DETAILS,array('product_id'=>$new_product_ids),array('user_id'=>$this->checkLogin('U')));
3786 $wantCount = $this->data['userDetails']->row()->want_count;
3787 if ($wantCount<=0 || $wantCount==''){
3788 $wantCount = 1;
3789 }
3790 $wantCount--;
3791 $this->user_model->update_details(USERS,array('want_count'=>$wantCount),array('id'=>$this->checkLogin('U')));
3792 $returnStr['status_code'] = 1;
3793 }
3794 }
3795 echo json_encode($returnStr);
3796 }
3797
3798 /**
3799 *
3800 * To create a new list
3801 *
3802 */
3803 public function create_list(){
3804 $returnStr['status_code'] = 0;
3805 if ($this->checkLogin('U')==''){
3806 $returnStr['message'] = 'You must login';
3807 }else {
3808 $tid = $this->input->post('tid');
3809 $list_name = $this->input->post('list_name');
3810 $category_id = $this->input->post('category_id');
3811 $checkList = $this->user_model->get_all_details(LISTS_DETAILS,array('name'=>$list_name,'user_id'=>$this->checkLogin('U')));
3812 if ($checkList->num_rows() == 0){
3813 $dataArr = array('user_id'=>$this->checkLogin('U'),'name'=>$list_name,'product_id'=>$tid);
3814 if ($category_id != ''){
3815 $dataArr['category_id'] = $category_id;
3816 }
3817 $this->user_model->simple_insert(LISTS_DETAILS,$dataArr);
3818 $userDetails = $this->user_model->get_all_details(USERS,array('id'=>$this->checkLogin('U')));
3819 $listCount = $userDetails->row()->lists;
3820 if ($listCount<0 || $listCount == ''){
3821 $listCount = 0;
3822 }
3823 $listCount++;
3824 $this->user_model->update_details(USERS,array('lists'=>$listCount),array('id'=>$this->checkLogin('U')));
3825 $returnStr['list_id'] = $this->user_model->get_last_insert_id();
3826 $returnStr['new_list'] = 1;
3827 }else {
3828 $productArr = explode(',', $checkList->row()->product_id);
3829 if (!in_array($tid, $productArr)){
3830 array_push($productArr, $tid);
3831 }
3832 $product_id = implode(',', $productArr);
3833 $dataArr = array('product_id'=>$product_id);
3834 if ($category_id != ''){
3835 $dataArr['category_id'] = $category_id;
3836 }
3837 $this->user_model->update_details(LISTS_DETAILS,$dataArr,array('user_id'=>$this->checkLogin('U'),'name'=>$list_name));
3838 $returnStr['list_id'] = $checkList->row()->id;
3839 $returnStr['new_list'] = 0;
3840 }
3841 $returnStr['status_code'] = 1;
3842 }
3843 echo json_encode($returnStr);
3844 }
3845
3846 /**
3847 *
3848 * To search the particular user
3849 *
3850 */
3851 public function search_users(){
3852 $search_key = $this->input->post('term');
3853 $returnStr = array();
3854 if ($search_key != ''){
3855 $userList = $this->user_model->get_search_user_list($search_key,$this->checkLogin('U'));
3856 if ($userList->num_rows()>0){
3857 $i=0;
3858 foreach ($userList->result() as $userRow){
3859 $userArr['id'] = $userRow->id;
3860 $userArr['fullname'] = $userRow->full_name;
3861 $userArr['username'] = $userRow->user_name;
3862 if ($userRow->thumbnail != ''){
3863 $userArr['image_url'] = 'images/users/'.$userRow->thumbnail;
3864 }else {
3865 $userArr['image_url'] = 'images/users/user-thumb1.png';
3866 }
3867 array_push($returnStr, $userArr);
3868 $i++;
3869 }
3870 }
3871 }
3872 echo json_encode($returnStr);
3873 }
3874
3875 /**
3876 *
3877 * Seller Registration form
3878 *
3879 */
3880 public function seller_signup_form(){
3881
3882 if ($this->checkLogin('U')==''){
3883 redirect(base_url());
3884 }else {
3885 if ($this->data['userDetails']->row()->is_verified == 'No'){
3886 $this->setErrorMessage('error','Please confirm your email first');
3887 redirect(base_url());
3888 }
3889 else {
3890 $this->data['heading'] = 'Seller Signup';
3891 $this->load->view('site/user/seller_register',$this->data);
3892 }
3893 }
3894 }
3895
3896 /**
3897 *
3898 * To seller view form
3899 *
3900 */
3901 public function create_brand_form(){
3902 if ($this->checkLogin('U')==''){
3903 redirect(base_url());
3904 }else {
3905 $this->data['heading'] = 'Seller Signup';
3906 $this->load->view('site/user/seller_register',$this->data);
3907 }
3908 }
3909
3910
3911 /**
3912 *
3913 * Seller Registration form
3914 *
3915 */
3916 public function seller_signup(){
3917
3918 if ($this->checkLogin('U')==''){
3919 redirect(base_url());
3920 }else {
3921 if ($this->data['userDetails']->row()->is_verified == 'No'){
3922 $this->setErrorMessage('error','Please confirm your email first');
3923 redirect('create-brand');
3924// echo "<script>window.history.go(-1)/script>";
3925 }else {
3926 $dataArr = array(
3927 'request_status' => 'Pending'
3928 );
3929 $this->user_model->commonInsertUpdate(USERS,'update',array(),$dataArr,array('id'=>$this->checkLogin('U')));
3930 $this->setErrorMessage('success','Welcome onboard ! Our team is evaluating your request. We will contact you shortly');
3931 redirect(base_url());
3932 }
3933 }
3934 }
3935
3936 /*public function find_friends_twitter(){
3937 $returnStr['status_code'] = 1;
3938// $returnStr['url'] = base_url().'twfollows.php';
3939 $returnStr['url'] = 'https://api.twitter.com/oauth/authorize?oauth_token=395839017-A1lVlw1uWXwDnzPFQuOBGGypMxYHLP3nrEICkyIs';
3940 $returnStr['message'] = '';
3941 echo json_encode($returnStr);
3942 }*/
3943
3944
3945 /**
3946 *
3947 * View purchase details for user
3948 *
3949 */
3950 public function view_purchase(){
3951 if ($this->checkLogin('U') == ''){
3952 show_404();
3953 }else {
3954 $uid = $this->uri->segment(2,0);
3955 $dealCode = $this->uri->segment(3,0);
3956 if ($uid != $this->checkLogin('U')){
3957 #show_404();
3958 redirect('login');
3959 }else {
3960 $purchaseList = $this->user_model->get_purchase_list($uid,$dealCode);
3961 //echo '<pre>'; print_r($purchaseList->result()); die;
3962 $invoice = $this->get_invoice($purchaseList);
3963 echo $invoice;
3964 }
3965 }
3966 }
3967
3968 /**
3969 *
3970 * view purchase details for seller
3971 *
3972 */
3973 public function view_seller_purchase(){
3974 if ($this->checkLogin('U') == ''){
3975 show_404();
3976 }else {
3977 $uid = $this->uri->segment(2,0);
3978 $dealCode = $this->uri->segment(3,0);
3979 if ($uid != $this->checkLogin('U')){
3980 show_404();
3981 }else {
3982 $purchaseList = $this->user_model->get_seller_purchase_list($uid,$dealCode);
3983 $invoice = $this->get_invoice($purchaseList);
3984 echo $invoice;
3985 }
3986 }
3987 }
3988
3989 /**
3990 *
3991 * view order details for user
3992 *
3993 */
3994 public function view_order(){
3995 if ($this->checkLogin('U') == '' && $this->checkLogin('A') == '')
3996 {
3997 show_404();
3998 }
3999 else
4000 {
4001 $uid = $this->uri->segment(2,0);
4002 $dealCode = $this->uri->segment(3,0);
4003 /* if ($uid != $this->checkLogin('U')){
4004
4005 show_404();
4006 }else { */
4007 //$orderList = $this->user_model->get_user_purchase_list($uid,$dealCode);
4008 ##echo "<pre>"; print_r($orderList); die;
4009 $invoice = $this->get_invoice($uid,$dealCode);
4010 echo $invoice; die;
4011 //}
4012 }
4013 }
4014
4015 /**
4016 *
4017 * view order details for user
4018 *
4019 */
4020 public function view_order_apps(){
4021 // if ($this->checkLogin('U') == '' && $this->checkLogin('A') == '')
4022 // {
4023 // show_404();
4024 // }
4025 // else
4026 // {
4027 $uid = $this->uri->segment(2,0);
4028 $dealCode = $this->uri->segment(3,0);
4029 /* if ($uid != $this->checkLogin('U')){
4030
4031 show_404();
4032 }else { */
4033 //$orderList = $this->user_model->get_user_purchase_list($uid,$dealCode);
4034 ##echo "<pre>"; print_r($orderList); die;
4035 $invoice = $this->get_invoice($uid,$dealCode);
4036 echo $invoice; die;
4037 //}
4038 // }
4039 }
4040
4041 /**
4042 * [view_track description]
4043 * @return [type] [description]
4044 */
4045
4046 public function view_track(){
4047 if ($this->checkLogin('U') == '' && $this->checkLogin('A') == '')
4048 {
4049 show_404();
4050 }
4051 else
4052 {
4053 $code = $this->uri->segment(2,0);
4054 $curier = '';
4055 if(!empty($this->uri->segment(3,0))){
4056 $curier = $this->uri->segment(3,0);
4057 }
4058
4059 if($code==''){
4060 $p = '<p>Pelacakan tidak tersedia ...</p>';
4061 }
4062 elseif($curier =='safe')
4063 {
4064 // id div gmap = slideshow-sec
4065 $url = 'http://track.safelogistics.co.id/index.php/Home/searchresult';
4066 // what post fields?
4067 $fields = array('trackarea' => $code);
4068 // build the urlencoded data
4069 $postvars = http_build_query($fields);
4070 // open connection
4071 $ch = curl_init();
4072 // set the url, number of POST vars, POST data
4073 curl_setopt($ch, CURLOPT_URL, $url);
4074 curl_setopt($ch, CURLOPT_POST, count($fields));
4075 curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
4076
4077 // execute post
4078 $result = curl_exec($ch);
4079 echo '<script>
4080 $("#slideshow-sec").hide();
4081 $(".navbar.navbar-inverse.set-radius-zero .navbar-toggle").hide();
4082 $(".below-slideshow .head-line").html("Riwayat <span style=\"color:#F0AC4E;\">Pengiriman</span>");
4083
4084 $(document).attr("title", "Pasarwarga : Tracking Report");
4085 </script>';
4086
4087 // close connection
4088 curl_close($curl);
4089 }
4090 elseif($curier=='')
4091 {
4092 $p = '<p>Pelacakan tidak tersedia (Kode kurir tidak ada)...</p>';
4093 }
4094 else
4095 {
4096 $data = get_tracking($curier,$code);
4097 // echo '<pre>';print_r($data);die;
4098 }
4099
4100 // echo '<pre>';print_r($data);die;
4101 //==========Generante Layout
4102 if(count($data['header'])>0)
4103 {
4104 $p = '<div class="container tracking-inner">
4105 <div class="row">
4106 <div class="heading-tracking text-center">
4107 <p>'.$data['header']['status'].'</p>
4108 </div>
4109 <table class="table table-striped table-bordered table-hover order-report">
4110 <tbody>
4111 <tr>
4112 <td>Nomor resi</td>
4113 <td>'.$data['header']['waybill_number'].'</td>
4114 </tr>
4115 <tr>
4116 <td>Jasa Pengiriman</td>
4117 <td>'.$data['header']['courier_name'].'</td>
4118 </tr>
4119 <tr>
4120 <td>Tanggal pengiriman</td>
4121 <td>'.(($data['header']['waybill_date']!='')?date('d-m-Y',strtotime($data['header']['waybill_date'])):'-').'</td>
4122 </tr>
4123 <tr>
4124 <td>Nama pengirim</td>
4125 <td>'.$data['header']['shipper_name'].'</td>
4126 </tr>
4127 <tr>
4128 <td>Kota asal Pengirim</td>
4129 <td>'.$data['header']['origin'].'</td>
4130 </tr>
4131 <tr><td>Nama penerima</td>
4132 <td>'.$data['header']['receiver_name'].'</td>
4133 </tr>
4134 <tr>
4135 <td style="width: 250px;">Alamat penerima</td>
4136 <td>'.$data['header']['destination'].'</td>
4137 </tr>
4138 </tbody>
4139 </table>
4140 </div>
4141 </div>';
4142 }
4143 else
4144 {
4145 $p = '<p>Pelacakan tidak tersedia ...</p>';
4146 }
4147
4148 if(count($data['body'])>0) {
4149 $p .= '<div class="container tracking-inner">
4150 <div class="row">
4151 <h4 style="margin-bottom:30px;">Riwayat Pengiriman :</h4>
4152 <div class="timeline-centered">';
4153 }
4154
4155 for($i=0;$i<count($data['body']);$i++)
4156 {
4157 $p .= ' <div class="timeline-entry">
4158 <div class="timeline-entry-inner">
4159
4160 <time class="timeline-time">
4161 <span>
4162 '.date('d-m-Y',strtotime($data['body'][$i]['manifest_date'])).'
4163 </span>
4164 <span>
4165 '.date('H:m:s',strtotime($data['body'][$i]['manifest_time'])).'
4166 </span>
4167 </time>
4168 <div class="timeline-icon bg-success">
4169 <i class="fa fa-cube"></i>
4170 </div>
4171
4172 <div class="timeline-label">
4173 <h5 class="list-group-item-heading">
4174 <strong> '
4175 .$data['body'][$i]['manifest_description'].'
4176 </strong>
4177 </h5>
4178 </div>
4179 </div>
4180 </div>';
4181
4182 }
4183
4184 if(count($data['body'])>0) {
4185 $p .= ' </div>
4186 </div>
4187 </div>';
4188 }
4189
4190 $modal = ' <div class="modal-content">
4191 <div class="modal-header">
4192 <button type="button" class="close" data-dismiss="modal">×</button>
4193 <h4 class="modal-title">Tracking Report</h4>
4194 </div>
4195 <div style="margin-top:-15px;" class="modal-body">
4196 <p>'.$p.'</p>
4197 </div>
4198 <div class="modal-footer">
4199 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
4200 </div>
4201 </div>';
4202
4203 echo $modal;die;
4204 }
4205 }
4206
4207
4208 /**
4209 * [confirm_dp description]
4210 * @return [type] [description]
4211 */
4212 public function confirm_dp(){
4213 if ($this->checkLogin('U') == '' && $this->checkLogin('A') == '')
4214 {
4215 show_404();
4216 }
4217 else
4218 {
4219 // echo '<pre>';print_r(json_decode(PW_REK));die;
4220
4221 $code = $this->uri->segment(2,0);
4222 $check = "select *,c.bank_name
4223 from ".USER_PAYMENT." a
4224 JOIN pw_dp_payment b ON b.dealCodeNumber = a.dealCodeNumber
4225 LEFT JOIN pw_m_banks c ON c.id = b.from_bank_id
4226 where a.dealCodeNumber ='".$code."'
4227 GROUP BY a.dealCodeNumber";
4228 // die($check);
4229 $data = $this->db->query($check);
4230
4231 //==========Generante Layout
4232 $dp_scr = '';
4233 $upload_style = 'display: none';
4234 if($data->row()->file_upload!=''){
4235 $dp_scr = base_url().'images/user_details/DP/'.$data->row()->file_upload;
4236 $upload_style = '';
4237
4238 $path = $dp_scr;
4239 $ext = explode(".", $data->row()->file_upload);
4240 $type = pathinfo($path, PATHINFO_EXTENSION);
4241 $data = file_get_contents($path);
4242 $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
4243
4244 // echo $base64;die;
4245 }
4246
4247 $data = $this->db->query($check);
4248
4249 $data_bank = $this->db->query("SELECT * FROM pw_m_banks WHERE active='Active' ");
4250 // echo '<pre>';print_r($data_bank->result());die;
4251 $cmb_bank = '<select id="from_bank_id" name="from_bank_id" class="form-control" required>
4252 <option value="">--- Pilih Bank ---</option>';
4253 foreach ($data_bank->result() as $val) {
4254 // echo $val->bank_name.'<br>';
4255 $sel ='';
4256 if($val->id==$data->row()->from_bank_id){
4257 $sel = 'selected';
4258 }
4259 $cmb_bank .='<option value="'.$val->id.'" '.$sel.'>'.$val->bank_name.'</option>';
4260 }
4261 $cmb_bank .='</select>';
4262
4263
4264 $list_rek = json_decode(PW_REK);
4265 $cmb_rekTo = '<select id="to_rek" name="to_rek" class="form-control" required>
4266 <option value="">--- Pilih Bank ---</option>';
4267 foreach ($list_rek as $val) {
4268 $sel ='';
4269 if($val->REK==$data->row()->to_rek){
4270 $sel = 'selected';
4271 }
4272 $cmb_rekTo .='<option value="'.$val->REK.'" '.$sel.'>'.$val->BANK.' - '.$val->REK.' ('.$val->AN.')'.'</option>';
4273 }
4274 $cmb_rekTo .='</select>';
4275
4276
4277 $modal = ' <div class="modal-content">
4278 <div class="modal-header">
4279 <button type="button" class="close" data-dismiss="modal">×</button>
4280 <h4 class="modal-title">Konfirmasi DP</h4>
4281 </div>
4282 <div class="modal-body">
4283 <div class="container tracking-inner">
4284 <div class="row">
4285 <div class="heading-tracking text-center">
4286 <p>STATUS : '.$data->row()->dp_status.'</p>
4287 </div>';
4288
4289 if($data->row()->dp_status=="Admin Confirm"){
4290 $modal .='<fieldset disabled>';
4291 }
4292 $modal .='<form id="frm_dp" name="frm_dp" class="form-horizontal" method="POST" action="'.base_url().'site/user/go_confirm_dp" >
4293 <input type="hidden" name="dealCodeNumber" id="dealCodeNumber" value="'.$data->row()->dealCodeNumber.'">
4294 <input type="hidden" name="device" id="device" value="web">
4295 <table class="table table-striped table-bordered table-hover order-report">
4296 <tbody>
4297 <tr>
4298 <td>Telah Ditransfer dari rekening :</td>
4299 <td>
4300 <input class="form-group" type="text" name="from_rek" id="from_rek" value="'.$data->row()->from_rek.'" required>
4301 </td>
4302 </tr>
4303 <tr>
4304 <td>Rekening Atas Nama :</td>
4305 <td>
4306 <input type="text" name="from_name" id="from_name" value="'.$data->row()->from_name.'" required>
4307 </td>
4308 </tr>
4309 <tr>
4310 <td>Tanggal Transfer :</td>
4311 <td>
4312 <input type="text" name="transfer_date" id="transfer_date" value="'.$data->row()->transfer_date.'" required class="datepicker">
4313 <script>
4314 $(".datepicker").datepicker({
4315 dateFormat: "yy-mm-dd 00:00:00" ,
4316 autoclose: true
4317 });
4318 </script>
4319 </td>
4320 </tr>
4321 <tr>
4322 <td>Nama BANK :</td>
4323 <td>
4324 <div class="col-md-12" style="margin-left: -24px;">
4325 '.$cmb_bank.'
4326 </div>
4327 </td>
4328 </tr>
4329 <tr>
4330 <td>Ditransfer Ke Rekening : </td>
4331 <td>
4332 <div class="col-md-12" style="margin-left: -24px;">
4333 '.$cmb_rekTo.'
4334 </div>
4335 </td>
4336 </tr>
4337 <tr>
4338 <td><strong>Jumlah Yang Harus ditransfer :</strong></td>
4339 <td><strong>Rp. '.number_format($data->row()->dp_amount).'</strong></td>
4340 </tr>
4341 <tr>
4342 <td style="width: 250px;">Jumlah Yang ditransfer :</td>
4343 <td>
4344 <input type="text" name="transfer_amount" id="transfer_amount" value="'.$data->row()->transfer_amount.'" required>
4345 </td>
4346 </tr>
4347 </tbody>
4348 </table>
4349 Upload Bukti Transfer :
4350 <div class="input-field file-field">
4351 <div >
4352 <input type="file" name="file_upload_DP" id="file_upload_DP" class="checkout-lampiran__file" style="display:none;">
4353 <input type="hidden" id="blob_dp" name="blob_dp" value="'.$base64.'">
4354 <input type="hidden" id="extension_dp" name="extension_dp" value="'.$ext[count($ext)-1].'">
4355 <label for="file_upload_DP" class="btn red checkout-lampiran__btn">Browse</label>
4356 <input class="file-path validate checkout-lampiran__path" type="text" id="upload_DP" name="upload_DP"
4357 placeholder="Upload bukti transfer"
4358 readonly required>
4359 </div>
4360 <script>
4361 document.getElementById("file_upload_DP").onchange = function(evt) {
4362 filename = this.files[0].name.split(".");
4363 file_extension = filename[filename.length - 1];
4364 document.getElementById("extension_dp").value = file_extension;
4365
4366 ImageTools.resize(this.files[0],
4367 {
4368 //width: 500, // maximum width
4369 height: 300 // maximum height
4370 }, function(blob, didItResize)
4371 {
4372 document.getElementById("prev_dp").src = window.URL.createObjectURL(blob);
4373 document.getElementById("href_dp").href=window.URL.createObjectURL(blob);
4374 $("#div_ktp").show();
4375 var reader = new window.FileReader();
4376 reader.readAsDataURL(blob);
4377 reader.onloadend = function()
4378 {
4379 base64data = reader.result;
4380 document.getElementById("blob_dp").value = base64data;
4381 }
4382 });
4383
4384 };
4385 </script>';
4386
4387 $modal .='<br />
4388 <div id="div_ktp" name="div_ktp" style="'.$upload_style.'" title="Click to Zoom">
4389 <a id="href_dp" rel="example2" href="'.$dp_scr.'" data-lightbox="example-set">
4390 <img id="prev_dp" src="'.$dp_scr.'" height="100" style="cursor: zoom-in;border: solid;" >
4391 </a>
4392 </div>
4393 </div>
4394
4395 </form>';
4396 if($data->row()->dp_status!=="Admin Confirm"){
4397 $modal .='</fieldset>';
4398 }
4399 $modal .= '</div>
4400 </div>
4401 </div>
4402 <div class="modal-footer">';
4403 if($data->row()->dp_status!=="Admin Confirm"){
4404 $modal .='<button type="button" class="btn btn-success" onclick="go_submit()">Submit</button>';
4405 }
4406 $modal .='<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
4407 </div>
4408 </div>';
4409
4410 echo $modal;die;
4411 }
4412 }
4413
4414
4415 /**
4416 * [get_confirm_dp description]
4417 * @return [type] [description]
4418 */
4419 public function get_confirm_dp(){
4420 if ($this->checkLogin('U') == '' && $this->checkLogin('A') == '')
4421 {
4422 show_404();
4423 }
4424 else
4425 {
4426 $code = $this->uri->segment(2,0);
4427 $check = "select *,c.bank_name
4428 from ".USER_PAYMENT." a
4429 JOIN pw_dp_payment b ON b.dealCodeNumber = a.dealCodeNumber
4430 LEFT JOIN pw_m_banks c ON c.id = b.from_bank_id
4431 where a.dealCodeNumber ='".$code."'
4432 GROUP BY a.dealCodeNumber";
4433 // die($check);
4434 $data = $this->db->query($check);
4435 $dp_src = '';
4436 $upload_style = 'display: none';
4437 if($data->row()->file_upload!=''){
4438 $dp_src = base_url().'images/user_details/DP/'.$data->row()->file_upload;
4439 $upload_style = '';
4440
4441 $path = $dp_scr;
4442 $ext = explode(".", $data->row()->file_upload);
4443 }
4444
4445 $res = array("form_data"=>[
4446 "dealCodeNumber"=>$data->row()->dealCodeNumber,
4447 "from_rek"=>$data->row()->from_rek,
4448 "from_name"=>$data->row()->from_name,
4449 "transfer_date"=>$data->row()->transfer_date,
4450 "from_bank_id"=>$data->row()->from_bank_id,
4451 "to_rek"=>$data->row()->to_rek,
4452 "transfer_amount"=>$data->row()->transfer_amount,
4453 "file_upload_DP"=>$data->row()->file_upload_DP,
4454 "upload_DP"=>$data->row()->upload_DP,
4455 "txt_amount"=>'Rp. '.number_format($data->row()->dp_amount)
4456 ],
4457 "data"=>[
4458 "dp_src"=>$dp_src,
4459 "extension_dp"=>$ext[count($ext)-1],
4460 "upload_style"=>$upload_style,
4461 "dp_status"=>$data->row()->dp_status
4462 ]
4463 );
4464
4465 echo json_encode($res);die;
4466
4467 }
4468 }
4469
4470 /**
4471 * [go_confirm_dp description]
4472 * @return [type] [description]
4473 */
4474 public function go_confirm_dp(){
4475 if ($this->checkLogin('U') == '' && $this->checkLogin('A') == '')
4476 {
4477 show_404();
4478 }
4479 else
4480 {
4481 // echo '<pre>';print_r($this->input->post());die;
4482 $dealCodeNumber = $this->input->post('dealCodeNumber');
4483 $fileName = 'DP_'.$dealCodeNumber;
4484 $data = $this->input->post('blob_dp');
4485 $ext = $this->input->post('extension_dp');
4486
4487 $from_rek = $this->input->post('from_rek');
4488 $from_name = $this->input->post('from_name');
4489 $transfer_date = $this->input->post('transfer_date');
4490 $from_bank_id = $this->input->post('from_bank_id');
4491 $to_rek = $this->input->post('to_rek');
4492 $transfer_amount = $this->input->post('transfer_amount');
4493
4494 $dp_check = $this->db->query("SELECT * FROM pw_dp_payment
4495 WHERE dealCodeNumber='".$dealCodeNumber."' AND dp_status <> 'Admin Confirm' ");
4496 // echo $dp_check->num_rows();die;
4497 if($dp_check->num_rows() > 0) {
4498 $dataArr = array('from_rek'=>$from_rek,
4499 'from_name'=>$from_name,
4500 'transfer_date'=>$transfer_date,
4501 'from_bank_id'=>$from_bank_id,
4502 'to_rek'=>$to_rek,
4503 'transfer_amount'=>$transfer_amount,
4504 'dp_status'=>'User Confirm',
4505 'file_upload'=>$fileName.'.'.$ext,
4506 'update_by'=>$this->session->userdata('shopsy_session_user_name')
4507 );
4508
4509 $conditionArr = array('dealCodeNumber'=>$dealCodeNumber);
4510 if($this->user_model->update_details('pw_dp_payment',$dataArr,$conditionArr)){
4511 $this->setErrorMessage('success','Konfirmasi DP berhasil, order sudah dilanjutkan ke Penjual.');
4512 }
4513 else {
4514 $this->setErrorMessage('error','Gagal Update Konfirmasi DP.');
4515 }
4516 // echo $this->db->last_query();die;
4517
4518 }
4519 else {
4520 $this->setErrorMessage('error','Order ID not Found');
4521 }
4522
4523 if($data!=''){
4524 list($type, $data) = explode(';', $data);
4525 $file_data = explode(',', $data);
4526 $data = base64_decode($file_data[1]);
4527 file_put_contents('images/user_details/DP/'.$fileName.'.'.$ext, $data);
4528 }
4529
4530 if($this->input->post('device')=='web'){
4531 redirect(base_url().'purchase-review');
4532 }
4533
4534 if($this->input->post('device')=='mobile'){
4535 redirect(base_url().'mobile/purchase-review');
4536 }
4537
4538 }
4539 }
4540
4541 /**
4542 * [view_order_status description]
4543 * @return [type] [description]
4544 */
4545 public function view_order_status($id){
4546 if ($this->checkLogin('U') == '' && $this->checkLogin('A') == '')
4547 {
4548 show_404();
4549 }
4550 else
4551 {
4552 $q_status = "SELECT *,(SELECT x.st_name FROM pw_m_order_status x WHERE x.st_code = b.st_code) st_name
4553 FROM shopsy_user_payment a
4554 LEFT JOIN pw_order_status b ON b.dealCodenumber = a.dealCodeNumber
4555 WHERE a.dealCodeNumber = '".$id."'
4556 ORDER BY date_update desc
4557 ";
4558 $orderStatus = $this->db->query($q_status);
4559
4560 // echo $orderStatus->num_rows();die;
4561 $p = '<div class="container tracking-inner">
4562 <div class="row">
4563 <div class="timeline-centered">';
4564
4565 // echo $this->db->last_query();die;
4566 // $i=0;
4567 foreach ($orderStatus->result() as $row)
4568 {
4569 $st_name = (($row->st_name=='')?$row->status:$row->st_name);
4570
4571 // $list_st = array("A","R","WS","C1","CS","OS","AC","CAN","CV","PD","EXP");
4572
4573 if($row->status=='Pending') {
4574 $icon = 'fa-exclamation-circle';
4575 $tm_color = 'bg-danger';
4576 }
4577 elseif($row->status=='Approve') {
4578
4579 if($row->st_name=="") {
4580 $icon = 'fa-check';
4581 $tm_color = 'bg-success';
4582 }
4583 else {
4584 $list_st = array("R","AC","C1","CS","CAN","EXP");
4585 if (in_array($row->st_code, $list_st))
4586 {
4587 $icon = 'fa-exclamation-circle';
4588 $tm_color = 'bg-danger';
4589 }
4590
4591 $list_st_app = array("WS","OS","CV");
4592 if (in_array($row->st_code, $list_st_app))
4593 {
4594 $icon = 'fa-search';
4595 $tm_color = 'bg-warning';
4596 }
4597
4598 if ($row->st_code=='A')
4599 {
4600 $icon = 'fa-check';
4601 $tm_color = 'bg-success';
4602 }
4603 }
4604 }
4605 else
4606 {
4607 $icon = 'fa-exclamation-circle';
4608 $tm_color = 'bg-danger';
4609 }
4610
4611 $p .= ' <div class="timeline-entry">
4612 <div class="timeline-entry-inner">
4613 <time class="timeline-time" style="width: 100px;text-align: left;">
4614 <span>
4615 '.$st_name.'
4616 </span>
4617 <span>
4618 '.date('d-m-Y',strtotime( ($row->date_update!="")?$row->date_update:$row->modified )).'
4619 </span>
4620 </time>
4621 <div class="timeline-icon '.$tm_color.'">
4622 <i class="fal '.$icon.'"></i>
4623 </div>
4624
4625 <div class="timeline-label">
4626 <h5 class="list-group-item-heading">
4627 <strong>'.
4628 'Order Number : '.$row->dealCodeNumber.
4629 '</strong><br>
4630 Note : '.$row->st_reason.'
4631 </h5>
4632 </div>
4633 </div>
4634
4635 </div>';
4636
4637 }
4638
4639 $p .= ' </div>
4640 </div>
4641 </div>';
4642
4643 $modal = '<div class="modal-content">
4644 <div class="modal-header">
4645 <button type="button" class="close" data-dismiss="modal">×</button>
4646 <h4 class="modal-title">Order Status History</h4>
4647 </div>
4648 <div class="modal-body">
4649 <p>'.$p.'</p>
4650 </div>
4651 </div>';
4652
4653 echo $modal;die;
4654 }
4655 }
4656
4657 public function view_order_pre(){
4658
4659 if ($this->checkLogin('U') == '')
4660 {
4661 show_404();
4662 }
4663 else
4664 {
4665
4666 $uid = $this->uri->segment(2,0);
4667 $dealCode = $this->uri->segment(3,0);
4668 $check = "select * from ".USER_PAYMENT." where user_id=".$uid." and dealCodeNumber ='".$dealCode."' GROUP BY dealCodeNumber";
4669 $sell_id = $this->user_model->ExecuteQuery($check)->row()->sell_id;
4670 if ($uid == $this->checkLogin('U') || $sell_id == $this->checkLogin('U') ){
4671 $dealCode = $this->uri->segment(3,0);
4672 $check = "select * from ".USER_PAYMENT." where user_id=".$uid." and dealCodeNumber ='".$dealCode."' GROUP BY dealCodeNumber";
4673 $checkStatus = $this->user_model->ExecuteQuery($check)->first_row();
4674 $this->data['PublicProfile'] = $this->user_model->get_all_details(USERS,array('id'=>$this->checkLogin('U'),'status'=>'Active'));
4675 if(($checkStatus->payment_type == 'COD' || $checkStatus->payment_type == 'wire_transfer'|| $checkStatus->payment_type == 'western_union') && ($checkStatus->status == 'Pending'))
4676 {
4677 $status = "Pending";
4678 }
4679 else
4680 {
4681 $status = "Paid";
4682 }
4683
4684 $this->data['userPurchase']= $userPurchase=$this->user_model->get_user_purchase_list($uid,$dealCode, $status);
4685
4686 $purchaseProducts=$userPurchase->result();
4687
4688 foreach($purchaseProducts as $key => $pro)
4689 {
4690 $review = $this->user_model->get_all_details(PRODUCT_FEEDBACK,array('voter_id'=>$pro->user_id,'seller_product_id'=>$pro->product_id,'deal_code'=>$pro->dealCodeNumber))->row('rating');
4691 if(empty($review)){
4692 $review = '';
4693 }
4694 //echo "<pre>"; print_r($review);
4695 $purchaseProducts[$key]->starrating = $review ;
4696 }
4697
4698 //echo "<pre>"; print_r($purchaseProducts); die;
4699
4700 $this->data['purchaseProducts']= $purchaseProducts;
4701
4702 $this->data['buyerDetails'] = $buyerDetails = $this->user_model->get_all_details(USERS,array('id'=>$purchaseProducts[0]->user_id));
4703
4704 //echo "<pre>".$this->db->last_query(); print_r($buyerDetails->result()); die;
4705 $this->data['sellerDetails'] = $sellerDetails = $this->user_model->get_all_details(USERS,array('id'=>$purchaseProducts[0]->sell_id));
4706 $this->load->view("site/user/purchase_view", $this->data);
4707
4708 }
4709 else
4710 {
4711 show_404();
4712 }
4713
4714 }
4715 }
4716
4717 /**
4718 *
4719 * view order details for seller
4720 *
4721
4722 public function view_seller_order(){
4723 if ($this->checkLogin('U') == ''){
4724 show_404();
4725 }else {
4726 $uid = $this->uri->segment(2,0);
4727 $dealCode = $this->uri->segment(3,0);
4728 if ($uid != $this->checkLogin('U')){
4729 show_404();
4730 }else {
4731 $orderList = $this->user_model->get_seller_order_list($uid,$dealCode);
4732 $invoice = $this->get_invoice($orderList);
4733 echo $invoice;
4734 }
4735 }
4736 }
4737
4738 /**
4739 *
4740 * view invoice details for user
4741 * param String $userId
4742 * param String $randomid
4743 *
4744 */
4745 public function get_invoice($userid,$randomId){
4746 //DIE;
4747 $this->db->select( 'p.*,u.email,u.full_name,u.user_name,u.last_name,u.address,u.phone_no,u.postal_code,
4748 u.state,u.country,u.city,pd.product_type,pd.product_name,pd.image,pd.id as PrdID,pd.weight,
4749 pAr.attr_name,s.msg_to_buyers,s.msg_to_buyers_for_digiitem,s.seller_businessname,
4750 kp.*,p.dp_val,p.dp_amount ');
4751
4752 $this->db->from(USER_PAYMENT.' as p');
4753 $this->db->join(USERS.' as u' , 'p.user_id = u.id');
4754 $this->db->join(PRODUCT_EN.' as pd' , 'pd.id = p.product_id');
4755 $this->db->join(PRODUCT_ATTRIBUTE.' as pAr' , 'pAr.id = p.attribute_values','left');
4756 $this->db->join(SELLER.' as s ','pd.user_id = s.seller_id');
4757 $this->db->join('shopsy_billing_kreditplus'.' as kp ','kp.dealCodeNumber = p.dealCodeNumber','left');
4758 //LEFT JOIN shopsy_billing_kreditplus kp ON kp.dealCodeNumber = p.dealCodeNumber
4759 $this->db->where('p.user_id = "'.$userid.'" and p.dealCodeNumber="'.$randomId.'"');
4760 $PrdList = $this->db->get();
4761 // echo $this->db->last_query();
4762 //echo "<pre>";print_r($PrdList->result());die;
4763 $shipAddRess = $this->user_model->get_all_details(SHIPPING_ADDRESS,array( 'id' => $PrdList->row()->shippingid ));
4764
4765 // $text = $this->db->last_query();
4766 // file_put_contents('filename.php', print_r($text, true));
4767
4768 $BillAddRess = $this->user_model->get_all_details(BILLING_ADDRESS,array( 'id' => $PrdList->row()->billingid ));
4769 // $text = $this->db->last_query();
4770 // file_put_contents('filename.php', print_r($text, true));
4771 $sellerDetails = $this->user_model->get_all_details(USERS,array( 'id' => $PrdList->row()->sell_id ));
4772
4773 $enc_dealCodeNumber=strtr($this->encrypt->encode($PrdList->row()->dealCodeNumber), '+/=', '-.~');
4774 $enc_user_id=strtr($this->encrypt->encode($PrdList->row()->user_id), '+/=', '-.~');
4775
4776 $payment_name_array = $this->nicepay_model_api->getPaymentName($randomId);
4777
4778 $digital_item = 'Yes';
4779
4780 foreach($PrdList->result() as $userCartItems){
4781 if($userCartItems->digital_files == ''){
4782 $digital_item = 'No';
4783 break;
4784 }
4785 }
4786 $phyflg=0;$digflg=0;$phymsg="";$digmsg="";
4787 foreach($PrdList->result() as $userCartItems){
4788
4789 if($userCartItems->product_type == 'physical'){
4790 $phyflg = 1;
4791 $phymsg=$userCartItems->msg_to_buyers;
4792 }else{
4793 $digflg=1;
4794 $digmsg=$userCartItems->msg_to_buyers_for_digiitem;
4795 }
4796 }
4797
4798
4799 if($this->lang->line('discussion_order_id') != '') { $discussion_order_id = stripslashes($this->lang->line('discussion_order_id')); } else { $discussion_order_id = "Order Id'"; }
4800
4801 if($this->lang->line('discussion_order_date') != '') { $discussion_order_date = stripslashes($this->lang->line('discussion_order_date')); } else { $discussion_order_date = "Order Date'"; }
4802
4803 if($this->lang->line('shipp_add') != '') { $shipp_add = stripslashes($this->lang->line('shipp_add')); } else { $shipp_add = "Shipping Address'"; }
4804
4805 if($this->lang->line('user_full_name') != '') { $user_full_name = stripslashes($this->lang->line('user_full_name')); } else { $user_full_name= "Full Name'"; }
4806
4807 if($this->lang->line('shipping_address_comm') != '') { $shipping_address_comm = stripslashes($this->lang->line('shipping_address_comm')); } else { $shipping_address_comm = "Address'"; }
4808
4809
4810 if($this->lang->line('add2') != '') { $add2 = stripslashes($this->lang->line('add2')); } else { $add2 = "Address 2'"; }
4811
4812 if($this->lang->line('user_city') != '') { $user_city = stripslashes($this->lang->line('user_city')); } else { $user_city = "City'"; }
4813
4814 if($this->lang->line('header_country') != '') { $header_country = stripslashes($this->lang->line('header_country')); } else { $header_country = "Country'"; }
4815
4816 if($this->lang->line('checkout_state') != '') { $checkout_state = stripslashes($this->lang->line('checkout_state')); } else { $checkout_state = "State'"; }
4817
4818 if($this->lang->line('zip_code') != '') { $zip_code = stripslashes($this->lang->line('zip_code')); } else { $zip_code = "Zipcode'"; }
4819
4820 if($this->lang->line('user_phone_no') != '') { $user_phone_no = stripslashes($this->lang->line('user_phone_no')); } else { $user_phone_no = "Phone Number'"; }
4821
4822 if($this->lang->line('discussion_bag_items') != '') { $discussion_bag_items = stripslashes($this->lang->line('discussion_bag_items')); } else { $discussion_bag_items = "Bag Items"; }
4823
4824 if($this->lang->line('discussion_product_name') != '') { $discussion_product_name = stripslashes($this->lang->line('discussion_product_name')); } else { $discussion_product_name = "Product Name"; }
4825 if($this->lang->line('discussion_qty') != '') { $discussion_qty = stripslashes($this->lang->line('discussion_qty')); } else { $discussion_qty = "Qty"; }
4826
4827 if($this->lang->line('discussion_unit_price') != '') { $discussion_unit_price = stripslashes($this->lang->line('discussion_unit_price')); } else { $discussion_unit_price = "Unit Price"; }
4828
4829 if($this->lang->line('discussion_sub_total') != '') { $discussion_sub_total = stripslashes($this->lang->line('discussion_sub_total')); } else { $discussion_sub_total = "Sub Total"; }
4830
4831 if($this->lang->line('discussion_review') != '') { $discussion_review = stripslashes($this->lang->line('discussion_review')); } else { $discussion_review = "Review"; }
4832 if($this->lang->line('discussion_shipping_tax') != '') { $discussion_shipping_tax = stripslashes($this->lang->line('discussion_shipping_tax')); } else { $discussion_shipping_tax = "Shipping Tax"; }
4833
4834 if($this->lang->line('discussion_shipping_cost') != '') { $discussion_shipping_cost = stripslashes($this->lang->line('discussion_shipping_cost')); } else { $discussion_shipping_cost = "Shipping Cost"; }
4835
4836 if($this->lang->line('discussion_grand_total') != '') { $discussion_grand_total = stripslashes($this->lang->line('discussion_grand_total')); } else { $discussion_grand_total = "Grand Total"; }
4837
4838 if($this->lang->line('thnk_purchase') != '') { $thnk_purchase = stripslashes($this->lang->line('thnk_purchase')); } else { $thnk_purchase = ",thank you for your purchase."; }
4839
4840 if($this->lang->line('concerns_contact_us') != '') { $concerns_contact_us = stripslashes($this->lang->line('concerns_contact_us')); } else { $concerns_contact_us = "If you have any concerns please contact us."; }
4841
4842 if($this->lang->line('shop_billing') != '') { $shop_billing = stripslashes($this->lang->line('shop_billing')); } else { $shop_billing = "Billing Address"; }
4843
4844 $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4845<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4846 <title>Invoice</title>
4847 <head>
4848 <link href="https://fonts.googleapis.com/css?family=Fredericka+the+Great" rel="stylesheet" type="text/css">
4849 <link rel="shortcut icon" type="image/x-icon" href="https://www.pasarwarga.com/images/logo/logo-favicon.png">
4850
4851 <style>
4852 .stamp{
4853 width:550px;
4854 left:175px;
4855 top:43%;
4856 border-radius:5px;
4857 position:absolute;
4858 background: transparent;
4859 color: #f44336;
4860 font-size: 50px;
4861 text-transform: uppercase;
4862 animation-delay:1s;
4863 -webkit-animation-delay:0.5s;
4864 -webkit-animation-duration: 0.5s;
4865 animation-duration: 0.5s;
4866 opacity: 0.2;
4867 filter: alpha(opacity=50);
4868 z-index: 1;
4869 }
4870
4871 .stamped {
4872 position: absolute;
4873 top: 50%;
4874 left: 0;
4875 -webkit-transform: translateY(-50%);
4876 -ms-transform: translateY(-50%);
4877 font-family: "Fredericka the Great", cursive;
4878 transform: translateY(-50%);
4879 width: 90%;
4880 padding: .25em;
4881 color: #f44336;
4882 margin: 0;
4883 border-radius: 15px;
4884 box-shadow: 0 0 0 5px, inset 0 0 0 5px white, inset 0 0 0 8px, inset 0 0 0 400px white;
4885 mix-blend-mode: overlay;
4886 outline-offset: -1px;
4887 outline: solid 8px;
4888 -ms-transform: rotate(-20deg); /* IE 9 */
4889 -webkit-transform: rotate(-20deg); /* Chrome, Safari, Opera */
4890 transform: rotate(-20deg);
4891 text-transform: uppercase;
4892 text-align: center;
4893 }
4894
4895 @-webkit-keyframes pulse{
4896 0%{
4897 opacity: 0;
4898 }
4899 10%{
4900 opacity:.50;
4901 transform-origin: 50% 50%;
4902 transform: rotate(-2deg) scale(5);
4903 transition: all .3s cubic-bezier(0.6, 0.04, 0.98, 0.335);
4904 }
4905 100%{
4906 opacity:1;
4907 transform: rotate(-15deg) scale(1);
4908 }
4909 }
4910 </style>
4911 </head>
4912 <body style="margin: 0; position: relative; -webkit-print-color-adjust: exact">
4913 <div class="stamp">
4914 <p class="stamped">'.$PrdList->row()->status.'</p>
4915 </div>
4916<table cellspacing="0" cellpadding="0" class="container" style="width: 800px; color: #555; padding: 25px; z-index: 9; vertical-align: middle;">
4917 <tbody>
4918 <tr>
4919 <td>
4920 <table width="100%" cellspacing="0" cellpadding="0" style="padding-bottom: 20px;">
4921 <tbody>
4922 <tr style="margin-top: 10px; margin-bottom: 10px;">
4923 <td>
4924 <img src="'.base_url().'images/logo/logo-pw.png" alt="pasarwarga">
4925 </td>
4926 <td style="text-align: right; padding-right: 14px;">
4927 <a style="color: #555; font-size: 14px; text-decoration: none;" href="javascript:window.print()">
4928 <img src="'.base_url().'images/printer.png" alt="Print" style="vertical-align: middle;">
4929 <span style="padding-left: 5px;vertical-align: middle">Cetak</span>
4930 </a>
4931 </td>
4932 </tr>
4933 </tbody>
4934 </table>
4935
4936 <table width="100%" cellspacing="0" cellpadding="0" style="padding-bottom: 20px;">
4937 <tbody>
4938 <tr style="font-size: 16px; font-weight: 600;">
4939 <td style="padding-bottom: 15px;">
4940 <span>Order ID #'.$PrdList->row()->dealCodeNumber.'</span>
4941 </td>
4942 </tr>
4943
4944 <tr>
4945 <td style="padding-right: 15px;">
4946 <table width="100%" cellspacing="0" cellpadding="0">
4947 <tbody>
4948 <tr>
4949 <td>
4950 <table width="100%" cellspacing="0" cellpadding="0">
4951 <tbody>
4952 <tr>
4953 <td style="font-size: 14px; padding: 5px 0;">Detail Penjual:</td>
4954 </tr>
4955 </tbody>
4956 </table>
4957 </td>
4958 </tr>
4959
4960 <tr>
4961 <td>
4962 <table style="color: #f44336; font-size: 14px; padding-bottom: 5px;" width="100%" cellspacing="0" cellpadding="0">
4963 <tbody>
4964 <tr>
4965 <td>'.stripslashes($PrdList->row()->seller_businessname).'</td>
4966 </tr>
4967 </tbody>
4968 </table>
4969 </td>
4970 </tr>
4971 <tr>
4972 <td>
4973 <table style="font-size: 14px; padding-bottom: 5px;" width="100%" cellspacing="0" cellpadding="0">
4974 <tbody>
4975 <tr>
4976 <td width="150">Pembayaran</td>
4977 <td>: <img style="margin: -6px 0px;" src="'.base_url().'images/'.$PrdList->row()->payment_type.'.png"></td>
4978 <!-- <td>: '.$payment_name_array['name'].' <img style="margin: -6px 0px;" src="'.base_url().$payment_name_array['image_url'].'"></td> -->
4979 </tr>
4980 </tbody>
4981 </table>
4982 </td>
4983 </tr>
4984 <tr>
4985 <td>
4986 <table style="font-size: 14px; padding-bottom: 5px;" width="100%" cellspacing="0" cellpadding="0">
4987 <tbody>
4988 <tr>
4989 <td width="150">Tanggal Transaksi</td>
4990 <td>: '.date("F j, Y g:i a",strtotime($PrdList->row()->created)).'</td>
4991 </tr>
4992 </tbody>
4993 </table>
4994 </td>
4995 </tr>
4996 <tr>
4997 <td>
4998 <table style="font-size: 14px; padding-bottom: 5px;" width="100%" cellspacing="0" cellpadding="0">
4999 <tbody>
5000 <tr>
5001 <td width="150">Tanggal Diproses</td>
5002 <td>: '.
5003 (($PrdList->row()->POdate!='' && $PrdList->row()->POdate!='0000-00-00 00:00:00')?date("F j, Y g:i a",strtotime($PrdList->row()->POdate)):'-')
5004 .'</td>
5005 </tr>
5006 </tbody>
5007 </table>
5008 </td>
5009 </tr>
5010
5011 </tbody>
5012 </table>
5013 </td>
5014
5015 <td style="padding-left: 10px;vertical-align: text-top;">
5016 <table width="100%" cellspacing="0" cellpadding="0">
5017 <tbody>
5018 <tr>
5019 <td>
5020 <table width="100%" cellspacing="0" cellpadding="0">
5021 <tbody>
5022 <tr>
5023 <td style="font-size: 14px; padding: 5px 0;">Detail Pembeli:</td>
5024 </tr>
5025 </tbody>
5026 </table>
5027 </td>
5028 </tr>
5029
5030 <tr>
5031 <td>
5032 <table style="color: #f44336; font-size: 14px; padding-bottom: 5px;" width="100%" cellspacing="0" cellpadding="0">
5033 <tbody>
5034 <tr>
5035 <td>'.stripslashes($PrdList->row()->full_name).' '.stripslashes($PrdList->row()->last_name).'</td>
5036 </tr>
5037 </tbody>
5038 </table>
5039 </td>
5040 </tr>
5041 <tr>
5042 <td>
5043 <table style="font-size: 14px; padding-bottom: 5px;" width="100%" cellspacing="0" cellpadding="0">
5044 <tbody>
5045 <tr>
5046 <td>'.stripslashes($PrdList->row()->email).'</td>
5047 </tr>
5048 </tbody>
5049 </table>
5050 </td>
5051 </tr>
5052 <tr>
5053 <td>
5054 <table style="font-size: 14px; padding-bottom: 5px;" width="100%" cellspacing="0" cellpadding="0">
5055 <tbody>
5056 <tr>
5057 <td>'.stripslashes($PrdList->row()->phone_no).'</td>
5058 </tr>
5059 </tbody>
5060 </table>
5061 </td>
5062 </tr>
5063
5064 </tbody>
5065
5066 </table>
5067 </td>
5068 </tr>
5069 </tbody>
5070 </table>';
5071
5072 $disTotal =0; $shipCost = $grantTotal = 0;
5073 foreach ($PrdList->result() as $cartRow)
5074 {
5075 $InvImg = @explode(',',$cartRow->image);
5076 $unitPrice = $cartRow->price;
5077 $tenorPrice = $cartRow->tenor_val;
5078 $uTot = $unitPrice*$cartRow->quantity;
5079 if($cartRow->attribute_values != '')
5080 {
5081 $atr = '<br>'.$cartRow->attribute_values;
5082 }
5083 elseif($catRow->attribute_values !='')
5084 {
5085 $atr = '<br>'.$cartRow->attribute_values;
5086 }
5087 else
5088 {
5089 $atr = '';
5090 }
5091
5092 //echo '<pre>'; print_r($PrdList->row());exit;
5093
5094 $message.='<table style="width: 100%; padding: 0;" cellspacing="0" cellpadding="0">
5095 <tr>
5096 <td style="padding-right: 15px;padding-top: 20px;text-align:center;vertical-align: top;position: relative;">
5097 <img src="'.THUMBOR.'/100x100/smart/'.PRODUCTPATH.urlencode($InvImg[0]).'" alt="'.stripslashes($cartRow->product_name).'" width="100" />
5098 </td>
5099
5100 <td style="padding-right: 15px;">
5101 <table style="width: 100%; text-align: center; border-top: 1px solid #eee; border-bottom: 1px solid #eee; padding: 15px 0;" width="100%" cellspacing="0" cellpadding="0">
5102 <thead style="font-size: 14px;">
5103 <tr><th style="font-weight: 600; text-align: left; padding: 0 5px 10px 15px;">Nama Produk</th>
5104 <th style="width: 100px; font-weight: 600; padding: 0 5px 10px;" width="120">Jumlah Barang</th>
5105 <th style="width: 75px; font-weight: 600; padding: 0 5px 10px;" width="65">Berat</th>
5106 <th style="width: 125px; font-weight: 600; padding: 0 5px 10px;" width="115">Harga Barang</th>
5107 <th style="width: 125px; font-weight: 600; text-align: right; padding: 0 30px 10px 5px;" width="115">Subtotal</th>
5108 </tr>
5109 </thead>
5110 <tbody>';
5111
5112 $message.='<tr style="font-size: 14px;">
5113 <td style="text-align: left; color: #f44336;padding: 10px 5px 10px 15px;">'.stripslashes($cartRow->product_name).$atr.'</td>';
5114
5115 if($digital_item == 'No'){
5116 $message.='
5117 <td style="width: 100px; padding: 8px 5px;">'.strtoupper($cartRow->quantity).'</td>
5118 <td style="width: 75px; padding: 8px 5px;">'.(($PrdList->row()->weight)/1000).' kg </td>';
5119 }
5120 $message.='<td style="width: 125px; padding: 8px 5px;">'.$this->data['currencySymbol'].number_format($unitPrice * $this->data['currencyValue']).'</td>
5121 <td style="width: 125px; text-align: right; padding: 8px 30px 8px 5px;">'.$this->data['currencySymbol'].number_format($uTot * $this->data['currencyValue']).'</td>
5122 </tr>';
5123
5124 $grantTotal = $grantTotal + $uTot;
5125 $shipCost = $shipCost + $cartRow->shippingcost;
5126 $asuransi = $cartRow->biaya_asuransi;
5127 $adminFee = $cartRow->adminFee;
5128 }
5129 $private_total = $grantTotal - $PrdList->row()->discountAmount;
5130 $private_total = $private_total - $PrdList->row()->giftdiscountAmount;
5131 $private_total = $private_total + $PrdList->row()->tax + $shipCost + $asuransi + $adminFee - $PrdList->row()->dp_amount;
5132 $ship_total = $PrdList->row()->tax + $shipCost + $asuransi + $adminFee;
5133
5134 $message.='<tr style="font-size: 14px;">
5135 <td colspan="5" style="padding-bottom: 8px;">';
5136 if($PrdList->row()->note !=''){
5137 $message.='
5138 <table style="width: 100%;" width="100%" cellspacing="0" cellpadding="0">
5139 <tbody><tr>
5140 <td style="text-align: left; padding: 8px 15px 8px 15px;">
5141 <b style="font-weight: 600;">Catatan untuk penjual:<b>
5142 <p style="font-weight: 500; margin: 0; padding-top: 4px;">'.stripslashes($PrdList->row()->note).'</p>
5143 </b></b></td>
5144 </tr>
5145 </tbody></table>
5146 </td>
5147 </tr>';
5148 }
5149 $message.='
5150
5151 <tr style="font-size: 14px;">
5152 <td colspan="4" style="font-weight: 600; background-color: rgba(134, 131, 131, 0.17); border: solid 1px solid 1px rgba(103, 98, 98, 0.17); border-right: none; text-align: left; padding: 10px 5px 10px 15px;">Subtotal</td>
5153 <td style="width: 125px; font-weight: 600; background-color: rgba(134, 131, 131, 0.17); border: solid 1px solid 1px rgba(103, 98, 98, 0.17); border-left: none; text-align: right; padding: 8px 30px 8px 5px;">'.$this->data['currencySymbol'].number_format($grantTotal * $this->data['currencyValue']).'</td>
5154 </tr>';
5155
5156 if($PrdList->row()->discountAmount !='0.00'){
5157 $message.=' <tr style="font-size: 14px;">
5158 <td colspan="4" style="font-weight: 600; background-color: rgba(134, 131, 131, 0.17); border: solid 1px solid 1px rgba(103, 98, 98, 0.17); border-right: none; text-align: left; padding: 10px 5px 10px 15px;">Diskon</td>
5159 <td style="width: 125px; font-weight: 600; background-color: rgba(134, 131, 131, 0.17); border: solid 1px solid 1px rgba(103, 98, 98, 0.17); border-left: none; text-align: right; padding: 8px 30px 8px 5px;">'.$this->data['currencySymbol'].number_format($PrdList->row()->discountAmount * $this->data['currencyValue']).'</td>
5160 </tr>
5161 </tbody>
5162 </table>';
5163 }
5164 $dp = '';
5165 if($PrdList->row()->dp_val > 0){
5166 $dp = '<table width="100%" cellspacing="0" cellpadding="0" style="width: 100%; padding: 0 0 20px;">
5167 <tbody>
5168 <tr>
5169 <td valign="top" style="width: 100%; vertical-align: top; border: solid 1px rgba(103, 98, 98, 0.17);">
5170 <table width="100%" cellspacing="0" cellpadding="0" style="width: 100%; border-collapse: collapse;">
5171 <tbody style="font-size: 14px; font-weight; 600;">
5172 <tr>
5173 <td style="padding: 10px 5px 0px 15px; font-weight: 600; background-color: rgba(134, 131, 131, 0.17);">
5174 DP
5175 </td>
5176 <td style="padding: 10px 25px 0 0; font-weight: 600; background-color: rgba(134, 131, 131, 0.17); text-align: right; ">
5177 '.$PrdList->row()->dp_val.'%
5178 </td>
5179 </tr>
5180 <tr>
5181 <td style="padding: 10px 5px 10px 15px; font-weight: 600; background-color: rgba(134, 131, 131, 0.17);">
5182 Nominal DP
5183 </td>
5184 <td style="padding: 15px 25px 5px 0; font-weight: 600; background-color: rgba(134, 131, 131, 0.17); text-align: right; ">
5185 Rp. '.number_format($PrdList->row()->dp_amount).'
5186 </td>
5187 </tr>
5188 </tbody>
5189 </table>
5190 </td>
5191 </tr>
5192
5193 </tbody>
5194 </table>';
5195 }
5196
5197 $message.='<table style="width: 100%; text-align: center; padding: 15px 0;" width="100%" cellspacing="0" cellpadding="0">
5198 <tbody>
5199 <tr style="font-size: 14px;">
5200 <td style="font-weight: 600; text-align: left; padding: 8px 0 8px 15px;">'.$PrdList->row()->ship_type.'</td>
5201 <td style="width: 100px; padding: 8px 5px;" width="120"></td>
5202 <td style="width: 75px; padding: 8px 5px;" width="65">'.(($PrdList->row()->weight)/1000).' kg</td>
5203 <td style="width: 125px; padding: 8px 5px;" width="115"></td>
5204 <td style="width: 125px; text-align: right; padding: 8px 30px 8px 5px;" width="115">'.$this->data['currencySymbol'].number_format($shipCost * $this->data['currencyValue']).'</td>
5205 </tr>
5206
5207 <tr style="font-size: 14px;">
5208 <td style="font-weight: 600; text-align: left; padding: 8px 0 8px 15px;">Asuransi</td>
5209 <td style="width: 100px; padding: 8px 5px;" width="120"></td>
5210 <td style="width: 75px; padding: 8px 5px;" width="65">'.stripslashes($PrdList->row()->asuransi).'</td>
5211 <td style="width: 125px; padding: 8px 5px;" width="115"></td>
5212 <td style="width: 125px; text-align: right; padding: 8px 30px 8px 5px;" width="115">'.$this->data['currencySymbol'].number_format($asuransi * $this->data['currencyValue']).'</td>
5213 </tr>
5214
5215 <tr style="font-size: 14px;">
5216 <td style="font-weight: 600; text-align: left; padding: 8px 0 8px 15px;">Pajak</td>
5217 <td style="width: 100px; padding: 8px 5px;" width="120"></td>
5218 <td style="width: 75px; padding: 8px 5px;" width="65"></td>
5219 <td style="width: 125px; padding: 8px 5px;" width="115"></td>
5220 <td style="width: 125px; text-align: right; padding: 8px 30px 8px 5px;" width="115">'.$this->data['currencySymbol'].number_format($PrdList->row()->tax * $this->data['currencyValue']).'</td>
5221 </tr>
5222
5223 <tr style="font-size: 14px;">
5224 <td style="font-weight: 600; text-align: left; padding: 8px 0 8px 15px;">Admin Fee</td>
5225 <td style="width: 100px; padding: 8px 5px;" width="120"></td>
5226 <td style="width: 75px; padding: 8px 5px;" width="65"></td>
5227 <td style="width: 125px; padding: 8px 5px;" width="115"></td>
5228 <td style="width: 125px; text-align: right; padding: 8px 30px 8px 5px;" width="115">'.$this->data['currencySymbol'].number_format($adminFee * $this->data['currencyValue']).'</td>
5229 </tr>
5230
5231 <tr style="font-size: 14px;">
5232 <td colspan="4" style="font-weight: 600; background-color: rgba(134, 131, 131, 0.17); border: solid 1px solid 1px rgba(103, 98, 98, 0.17); border-right: none; text-align: left; padding: 10px 5px 10px 15px;">Shipping Total</td>
5233 <td style="width: 125px; font-weight: 600; background-color: rgba(134, 131, 131, 0.17); border: solid 1px solid 1px rgba(103, 98, 98, 0.17); border-left: none; text-align: right; padding: 8px 30px 8px 5px;">'.$this->data['currencySymbol'].number_format($ship_total * $this->data['currencyValue']).'</td>
5234 </tr>
5235 </tbody>
5236 </table>
5237 '.$dp.'
5238 <table width="100%" cellspacing="0" cellpadding="0" style="width: 100%; padding: 0 0 20px;">
5239 <tbody>
5240 <tr>
5241 <td valign="top" style="width: 100%; vertical-align: top; border: solid 1px rgba(103, 98, 98, 0.17);">
5242 <table width="100%" cellspacing="0" cellpadding="0" style="width: 100%; border-collapse: collapse;">
5243 <tbody style="font-size: 14px; font-weight; 600;">
5244 <tr>
5245 <td style="padding: 10px 5px 0px 15px; font-weight: 600; background-color: rgba(134, 131, 131, 0.17);">Total</td>
5246 <td style="padding: 10px 25px 0 0; font-weight: 600; background-color: rgba(134, 131, 131, 0.17); text-align: right; ">'.$this->data['currencySymbol'].number_format($private_total * $this->data['currencyValue']).'</td>
5247 </tr>
5248 <tr>
5249 <td style="padding: 10px 5px 10px 15px; font-weight: 600; background-color: rgba(134, 131, 131, 0.17);">Cicilan '.$PrdList->row()->tenor.' Bulan</td>
5250 <td style="padding: 15px 25px 5px 0; font-weight: 600; background-color: rgba(134, 131, 131, 0.17); text-align: right; ">'.$this->data['currencySymbol'].number_format($tenorPrice * $this->data['currencyValue']).'</td>
5251 </tr>
5252 </tbody>
5253 </table>
5254 </td>
5255 </tr>
5256
5257 </tbody>
5258 </table>
5259
5260
5261 <table width="100%" style="border-top: 1px dashed #eee;" border="0" cellspacing="0" cellpadding="0">';
5262 if($shipAddRess->row()->full_name!='')
5263 {
5264
5265 }
5266 else
5267 {
5268 $message.='<td></td>';
5269 }
5270 // echo '<pre>'; print_r($shipAddRess->row());exit;
5271 $message.='
5272 <table width="50%" border="0" cellpadding="0" cellspacing="0" style="padding-top: 15px;line-height:30px; text-transform: capitalize;">
5273 <tr>
5274 <td><span style="padding:5px 10px 5px 10px; font-size: 14px; font-weight: 600;">Detail Pengiriman :</span></td>
5275 </tr>
5276
5277 </table>
5278
5279 <table width="50%" border="0" cellpadding="0" cellspacing="0" style="font-size:14px;line-height:22px; padding-left: 10px; text-transform: capitalize;">
5280 <tr>
5281 <td><strong>'.stripslashes($shipAddRess->row()->full_name).'</strong></td>
5282 </tr>
5283 <tr>
5284 <td><strong>Alamat :</strong> '.stripslashes($shipAddRess->row()->address1).', <br>
5285 <strong>Kecamatan :</strong> '.stripslashes($shipAddRess->row()->district).', <br>
5286 <strong>Kelurahan :</strong> '.stripslashes($shipAddRess->row()->kelurahan).',</td>
5287 </tr>
5288 <tr>
5289 <td><strong>Kota :</strong> '.stripslashes($shipAddRess->row()->city).',<br>
5290 <strong>Kode Pos :</strong> '.stripslashes($shipAddRess->row()->postal_code).'<br></td>
5291 </tr>
5292 <tr>
5293 <td>'.stripslashes($shipAddRess->row()->phone).'</td>
5294 </tr>
5295 </table>
5296 </td>
5297 </tr>
5298 </table>
5299
5300 <table width="100%" cellspacing="0" cellpadding="0" style="padding-top: 80px;padding-bottom: 20px;">
5301 <tbody>
5302 <tr>
5303 <td style="padding-right: 15px;">
5304 <table width="100%" cellspacing="0" cellpadding="0">
5305 <tbody>
5306 <tr>
5307 <td>
5308 <table width="100%" style="font-size: 14px; line-height: 20px;" cellspacing="0" cellpadding="0">
5309 <tbody>
5310 <tr>
5311 <td>Terimakasih untuk pembelian Anda</td>
5312 </tr>
5313 <tr>
5314 <td>Apabila Anda memiliki pertanyaan</td>
5315 </tr>
5316 <tr>
5317 <td>Silahkan menghubungi customer service kami.</td>
5318 </tr>
5319 </tbody>
5320 </table>
5321 </td>
5322 </tr>
5323 </tbody>
5324 </table>
5325 </td>
5326
5327 <td style="padding-left: 10px;vertical-align: text-top;">
5328 <table width="100%" cellspacing="0" cellpadding="0">
5329 <tbody>
5330 <tr>
5331 <td style="text-align: right; padding-right: 14px; padding-bottom: 5px;">
5332 <a style="color: #555; font-size: 14px; text-decoration: none;" href="javascript:window.print()">
5333 <img src="'.base_url().'images/mail.png" alt="Print" style="vertical-align: middle;">
5334 <span style="padding-left: 5px; text-align: left; vertical-align: middle">cs@pasarwarga.com</span>
5335 </a>
5336 </td>
5337 </tr>
5338
5339 <tr>
5340 <td style="text-align: right; padding-right: 27px;">
5341 <a style="color: #555; font-size: 14px; text-decoration: none;" href="javascript:window.print()">
5342 <img src="'.base_url().'images/phone.png" alt="Print" style="vertical-align: middle;">
5343 <span style="padding-left: 5px; text-align: left; vertical-align: middle">+62 21 2708 1818</span>
5344 </a>
5345 </td>
5346 </tr>
5347
5348 </tbody>
5349
5350 </table>
5351 </td>
5352 </tr>
5353 </tbody>
5354 </table>
5355 </td>
5356 </tr>
5357 </table>
5358 </td>
5359 </tr>
5360 </tbody>
5361 </table>
5362 </body>
5363</html>';
5364 return $message;
5365 }
5366
5367 /**
5368 *
5369 * Change order status to user
5370 *
5371 */
5372 public function change_order_status(){
5373 if ($this->checkLogin('U') == ''){
5374 show_404();
5375 }else {
5376 $uid = $this->input->post('seller');
5377 if ($uid != $this->checkLogin('U')){
5378 show_404();
5379 }else {
5380 $returnStr['status_code'] = 0;
5381 $dealCode = $this->input->post('dealCode');
5382 $status = $this->input->post('value');
5383 $dataArr = array('shipping_status'=>$status);
5384 $conditionArr = array('dealCodeNumber'=>$dealCode,'sell_id'=>$uid);
5385 $this->user_model->update_details(PAYMENT,$dataArr,$conditionArr);
5386 $returnStr['status_code'] = 1;
5387 echo json_encode($returnStr);
5388 }
5389 }
5390 }
5391 /**
5392 *
5393 * Display the user list homes
5394 *
5395 */
5396 public function display_user_lists_home(){
5397 $lid = $this->uri->segment('4','0');
5398 $uname = $this->uri->segment('2','0');
5399 $this->data['user_profile_details'] = $userProfileDetails = $this->user_model->get_all_details(USERS,array('user_name'=>$uname));
5400 if ($userProfileDetails->row()->visibility == 'Only you' && $userProfileDetails->row()->id != $this->checkLogin('U')){
5401 $this->load->view('site/user/display_user_profile_private',$this->data);
5402 }else {
5403 $this->data['list_details'] = $list_details = $this->product_model->get_all_details(LISTS_DETAILS,array('id'=>$lid,'user_id'=>$this->data['user_profile_details']->row()->id));
5404 if ($this->data['list_details']->num_rows()==0){
5405 show_404();
5406 }else {
5407 $searchArr = array_filter(explode(',', $list_details->row()->product_id));
5408 if (count($searchArr)>0){
5409 $fieldsArr = array(PRODUCT.'.*',USERS.'.user_name',USERS.'.full_name');
5410 $condition = array(PRODUCT.'.status'=>'Publish');
5411 $joinArr1 = array('table'=>USERS,'on'=>USERS.'.id='.PRODUCT.'.user_id','type'=>'');
5412 $joinArr = array($joinArr1);
5413 $this->data['product_details'] = $product_details = $this->product_model->get_fields_from_many(PRODUCT,$fieldsArr,PRODUCT.'.seller_product_id',$searchArr,$joinArr,'','',$condition);
5414 $this->data['totalProducts'] = count($searchArr);
5415 $fieldsArr = array(USER_PRODUCTS.'.*',USERS.'.user_name',USERS.'.full_name');
5416 $condition = array(USER_PRODUCTS.'.status'=>'Publish');
5417 $joinArr1 = array('table'=>USERS,'on'=>USERS.'.id='.USER_PRODUCTS.'.user_id','type'=>'');
5418 $joinArr = array($joinArr1);
5419 $this->data['notsell_product_details'] = $this->product_model->get_fields_from_many(USER_PRODUCTS,$fieldsArr,USER_PRODUCTS.'.seller_product_id',$searchArr,$joinArr,'','',$condition);
5420 }else {
5421 $this->data['notsell_product_details'] = '';
5422 $this->data['product_details'] = '';
5423 $this->data['totalProducts'] = 0;
5424 }
5425 $this->load->view('site/user/user_list_home',$this->data);
5426 }
5427 }
5428 }
5429
5430 /**
5431 *
5432 * Display the user list followers
5433 *
5434 */
5435 public function display_user_lists_followers(){
5436 $lid = $this->uri->segment('4','0');
5437 $uname = $this->uri->segment('2','0');
5438 $this->data['user_profile_details'] = $userProfileDetails = $this->user_model->get_all_details(USERS,array('user_name'=>$uname));
5439 if ($userProfileDetails->row()->visibility == 'Only you' && $userProfileDetails->row()->id != $this->checkLogin('U')){
5440 $this->load->view('site/user/display_user_profile_private',$this->data);
5441 }else {
5442 $this->data['list_details'] = $list_details = $this->product_model->get_all_details(LISTS_DETAILS,array('id'=>$lid,'user_id'=>$this->data['user_profile_details']->row()->id));
5443 if ($this->data['list_details']->num_rows()==0){
5444 show_404();
5445 }else {
5446 $fieldsArr = '*';
5447 $searchArr = explode(',', $list_details->row()->followers);
5448 $this->data['user_details'] = $user_details = $this->product_model->get_fields_from_many(USERS,$fieldsArr,'id',$searchArr);
5449 if ($user_details->num_rows()>0){
5450 foreach ($user_details->result() as $userRow){
5451 $fieldsArr = array(PRODUCT_LIKES.'.*',PRODUCT.'.product_name',PRODUCT.'.image',PRODUCT.'.id as PID');
5452 $searchArr = array($userRow->id);
5453 $joinArr1 = array('table'=>PRODUCT,'on'=>PRODUCT_LIKES.'.product_id='.PRODUCT.'.seller_product_id','type'=>'');
5454 $joinArr = array($joinArr1);
5455 $sortArr1 = array('field'=>PRODUCT.'.created','type'=>'desc');
5456 $sortArr = array($sortArr1);
5457 $this->data['product_details'][$userRow->id] = $this->product_model->get_fields_from_many(PRODUCT_LIKES,$fieldsArr,PRODUCT_LIKES.'.user_id',$searchArr,$joinArr,$sortArr,'5');
5458 }
5459 }
5460 $fieldsArr = array(PRODUCT.'.*',USERS.'.user_name',USERS.'.full_name');
5461 $searchArr = array_filter(explode(',', $list_details->row()->product_id));
5462 if (count($searchArr)>0){
5463 $this->data['totalProducts'] = count($searchArr);
5464 }else {
5465 $this->data['totalProducts'] = 0;
5466 }
5467
5468 $this->load->view('site/user/user_list_followers',$this->data);
5469 }
5470 }
5471 }
5472
5473 /**
5474 *
5475 * Display the follow list
5476 *
5477 */
5478 public function follow_list(){
5479 $returnStr['status_code'] = 0;
5480 $lid = $this->input->post('lid');
5481 if ($this->checkLogin('U') != ''){
5482 $listDetails = $this->product_model->get_all_details(LISTS_DETAILS,array('id'=>$lid));
5483 $followersArr = explode(',', $listDetails->row()->followers);
5484 $followersCount = $listDetails->row()->followers_count;
5485 $oldDetails = explode(',', $this->data['userDetails']->row()->following_user_lists);
5486 if (!in_array($lid, $oldDetails)){
5487 array_push($oldDetails, $lid);
5488 }
5489 if (!in_array($this->checkLogin('U'), $followersArr)){
5490 array_push($followersArr, $this->checkLogin('U'));
5491 $followersCount++;
5492 }
5493 $this->product_model->update_details(USERS,array('following_user_lists'=>implode(',', $oldDetails)),array('id'=>$this->checkLogin('U')));
5494 $this->product_model->update_details(LISTS_DETAILS,array('followers'=>implode(',', $followersArr),'followers_count'=>$followersCount),array('id'=>$lid));
5495 $returnStr['status_code'] = 1;
5496 }
5497 echo json_encode($returnStr);
5498 }
5499
5500 /**
5501 *
5502 * To update the unfollow list
5503 *
5504 */
5505 public function unfollow_list(){
5506 $returnStr['status_code'] = 0;
5507 $lid = $this->input->post('lid');
5508 if ($this->checkLogin('U') != ''){
5509 $listDetails = $this->product_model->get_all_details(LISTS_DETAILS,array('id'=>$lid));
5510 $followersArr = explode(',', $listDetails->row()->followers);
5511 $followersCount = $listDetails->row()->followers_count;
5512 $oldDetails = explode(',', $this->data['userDetails']->row()->following_user_lists);
5513 if (in_array($lid, $oldDetails)){
5514 if ($key = array_search($lid, $oldDetails) !== false){
5515 unset($oldDetails[$key]);
5516 }
5517 }
5518 if (in_array($this->checkLogin('U'), $followersArr)){
5519 if ($key = array_search($this->checkLogin('U'), $followersArr) !== false){
5520 unset($followersArr[$key]);
5521 }
5522 $followersCount--;
5523 }
5524 $this->product_model->update_details(USERS,array('following_user_lists'=>implode(',', $oldDetails)),array('id'=>$this->checkLogin('U')));
5525 $this->product_model->update_details(LISTS_DETAILS,array('followers'=>implode(',', $followersArr),'followers_count'=>$followersCount),array('id'=>$lid));
5526 $returnStr['status_code'] = 1;
5527 }
5528 echo json_encode($returnStr);
5529 }
5530
5531 /**
5532 *
5533 * To edit the user lists
5534 *
5535 */
5536 public function edit_user_lists(){
5537 if ($this->checkLogin('U') == ''){
5538 redirect('login');
5539 }else {
5540 $lid = $this->uri->segment('4','0');
5541 $uname = $this->uri->segment('2','0');
5542 if ($uname != $this->data['userDetails']->row()->user_name){
5543 show_404();
5544 }else {
5545 $this->data['user_profile_details'] = $this->user_model->get_all_details(USERS,array('user_name'=>$uname));
5546 $this->data['list_details'] = $list_details = $this->product_model->get_all_details(LISTS_DETAILS,array('id'=>$lid,'user_id'=>$this->data['user_profile_details']->row()->id));
5547 if ($this->data['list_details']->num_rows()==0){
5548 show_404();
5549 }else {
5550 $this->data['list_category_details'] = $this->user_model->get_all_details(CATEGORY,array('id'=>$this->data['list_details']->row()->category_id));
5551 $this->data['heading'] = 'Edit List';
5552 $this->load->view('site/user/edit_user_list',$this->data);
5553 }
5554 }
5555 }
5556 }
5557
5558 /**
5559 *
5560 * To edit the user lists details
5561 *
5562 */
5563 public function edit_user_list_details(){
5564 if ($this->checkLogin('U') == ''){
5565 redirect('login');
5566 }else {
5567 $lid = $this->input->post('lid');
5568 $uid = $this->input->post('uid');
5569 if ($uid != $this->checkLogin('U')){
5570 show_404();
5571 }else {
5572 $list_title = $this->input->post('setting-title');
5573 $catID = $this->input->post('category');
5574 $duplicateCheck = $this->user_model->get_all_details(LISTS_DETAILS,array('user_id'=>$uid,'id !='=>$lid,'name'=>$list_title));
5575 if ($duplicateCheck->num_rows()>0){
5576 $this->setErrorMessage('error','List title already exists');
5577 echo '<script>window.history.go(-1);</script>';
5578 }else {
5579 if ($catID == ''){
5580 $catID = 0;
5581 }
5582 $this->user_model->update_details(LISTS_DETAILS,array('name'=>$list_title,'category_id'=>$catID),array('id'=>$lid,'user_id'=>$uid));
5583 $this->setErrorMessage('success','List updated successfully');
5584 echo '<script>window.history.go(-1);</script>';
5585 }
5586 }
5587 }
5588 }
5589
5590 /**
5591 *
5592 * To delete the user lists
5593 *
5594 */
5595 public function delete_user_list(){
5596 $returnStr['status_code'] = 0;
5597 if ($this->checkLogin('U')==''){
5598 $returnStr['message'] = 'Login required';
5599 }else {
5600 $lid = $this->input->post('lid');
5601 $uid = $this->input->post('uid');
5602 if ($uid != $this->checkLogin('U')){
5603 $returnStr['message'] = 'You can\'t delete other\'s list';
5604 }else {
5605 $list_details = $this->user_model->get_all_details(LISTS_DETAILS,array('id'=>$lid,'user_id'=>$uid));
5606 if ($list_details->num_rows() == 1){
5607 $followers_id = $list_details->row()->followers;
5608 if ($followers_id != ''){
5609 $searchArr = array_filter(explode(',', $followers_id));
5610 $fieldsArr = array('following_user_lists','id');
5611 $followersArr = $this->user_model->get_fields_from_many(USERS,$fieldsArr,'id',$searchArr);
5612 if ($followersArr->num_rows()>0){
5613 foreach ($followersArr->result() as $followersRow){
5614 $listArr = array_filter(explode(',', $followersRow->following_user_lists));
5615 if (in_array($lid, $listArr)){
5616 if (($key = array_search($lid, $listArr)) != false){
5617 unset($listArr[$key]);
5618 $this->user_model->update_details(USERS,array('following_user_lists'=>implode(',', $listArr)),array('id'=>$followersRow->id));
5619 }
5620 }
5621 }
5622 }
5623 }
5624 $this->user_model->commonDelete(LISTS_DETAILS,array('id'=>$lid,'user_id'=>$this->checkLogin('U')));
5625 $listCount = $this->data['userDetails']->row()->lists;
5626 $listCount--;
5627 if ($listCount == '' || $listCount < 0){
5628 $listCount = 0;
5629 }
5630 $this->user_model->update_details(USERS,array('lists'=>$listCount),array('id'=>$this->checkLogin('U')));
5631 $returnStr['url'] = base_url().'people/'.$this->data['userDetails']->row()->user_name.'/favorites';
5632 $list_delete=addslashes(shopsy_lg('lg_list_delete','List deleted successfully'));
5633
5634 $this->setErrorMessage('success',$list_delete);
5635 $returnStr['status_code'] = 1;
5636 }else {
5637 $returnStr['message'] = 'List not available';
5638 }
5639 }
5640 }
5641 echo json_encode($returnStr);
5642 }
5643
5644 /**
5645 *
5646 * To crop the images for user profile picture
5647 *
5648 */
5649 public function image_crop(){
5650 if($this->checkLogin('U') == ''){
5651 redirect('login');
5652 }else {
5653 $uid = $this->uri->segment(2,0);
5654 if ($uid != $this->checkLogin('U')){
5655 show_404();
5656 }else {
5657 $this->data['heading'] = 'Cropping Image';
5658 $this->load->view('site/user/crop_image',$this->data);
5659 }
5660 }
5661 }
5662
5663 /**
5664 *
5665 * To crop the images for user profile picture processing
5666 *
5667 */
5668 public function image_crop_process(){
5669 if($this->checkLogin('U') == ''){
5670 redirect('login');
5671 }else {
5672 $targ_w = $targ_h = 240;
5673 $jpeg_quality = 90;
5674
5675 $src = 'images/users/'.$this->data['userDetails']->row()->thumbnail;
5676 $ext = substr($src, strpos($src , '.')+1);
5677 if ($ext == 'png'){
5678 $jpgImg = imagecreatefrompng($src);
5679 imagejpeg($jpgImg, $src, 90);
5680 }
5681 $img_r = imagecreatefromjpeg($src);
5682 $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
5683
5684// list($width, $height) = getimagesize($src);
5685
5686 imagecopyresampled($dst_r,$img_r,0,0,$_POST['x1'],$_POST['y1'], $targ_w,$targ_h,$_POST['w'],$_POST['h']);
5687// imagecopyresized($dst_r,$img_r,0,0,$_POST['x1'],$_POST['y1'], $targ_w,$targ_h,$_POST['w'],$_POST['h']);
5688// imagecopyresized($dst_r, $img_r,0,0, $_POST['x1'],$_POST['y1'], $_POST['x2'],$_POST['y2'],1024,980);
5689// header('Content-type: image/jpeg');
5690 imagejpeg($dst_r,'images/users/'.$this->data['userDetails']->row()->thumbnail);
5691 $this->setErrorMessage('success','Profile photo changed successfully');
5692 redirect('settings');
5693 exit;
5694 }
5695 }
5696
5697 /**
5698 *
5699 * To send the notify mail to followers
5700 * param String $followUserDetails
5701 *
5702 */
5703 public function send_noty_mail($followUserDetails=array()){
5704 if (count($followUserDetails)>0){
5705 $emailNoty = explode(',', $followUserDetails[0]['email_notifications']);
5706 if (in_array('following', $emailNoty)){
5707 $newsid='7';
5708 $template_values=$this->product_model->get_newsletter_template_details($newsid);
5709 $adminnewstemplateArr=array('logo'=> $this->data['logo'],'meta_title'=>$this->config->item('meta_title'),'full_name'=>$followUserDetails[0]['full_name'],'cfull_name'=>$this->data['userDetails']->row()->full_name,'user_name'=>$this->data['userDetails']->row()->user_name);
5710 extract($adminnewstemplateArr);
5711 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
5712 $message .= '<!DOCTYPE HTML>
5713 <html>
5714 <head>
5715 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5716 <meta name="viewport" content="width=device-width"/>
5717 <title>'.$template_values['news_subject'].'</title><body>';
5718 include('./newsletter/registeration'.$newsid.'.php');
5719
5720 $message .= '</body>
5721 </html>';
5722
5723
5724 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
5725 $sender_email=$this->data['siteContactMail'];
5726 $sender_name=$this->data['siteTitle'];
5727 }else{
5728 $sender_name=$template_values['sender_name'];
5729 $sender_email=$template_values['sender_email'];
5730 }
5731
5732 $email_values = array('mail_type'=>'html',
5733 'from_mail_id'=>$sender_email,
5734 'mail_name'=>$sender_name,
5735 'to_mail_id'=>$followUserDetails[0]['email'],
5736 'subject_message'=>$subject,
5737 'body_messages'=>$message
5738 );
5739 $email_send_to_common = $this->product_model->common_email_send($email_values);
5740 }
5741 }
5742 }
5743
5744 /**
5745 *
5746 * To send the notify mails to followers
5747 * param String $followUserDetails
5748 *
5749 */
5750 public function send_noty_mails($followUserDetails=array()){
5751 if (count($followUserDetails)>0){
5752 $emailNoty = explode(',', $followUserDetails->email_notifications);
5753 if (in_array('following', $emailNoty)){
5754
5755 $newsid='9';
5756 $template_values=$this->product_model->get_newsletter_template_details($newsid);
5757 $adminnewstemplateArr=array('logo'=> $this->data['logo'],'meta_title'=>$this->config->item('meta_title'),'full_name'=>$followUserDetails[0]['full_name'],'cfull_name'=>$this->data['userDetails']->row()->full_name,'user_name'=>$this->data['userDetails']->row()->user_name);
5758 extract($adminnewstemplateArr);
5759 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
5760 $message .= '<!DOCTYPE HTML>
5761 <html>
5762 <head>
5763 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5764 <meta name="viewport" content="width=device-width"/>
5765 <title>'.$template_values['news_subject'].'</title><body>';
5766 include('./newsletter/registeration'.$newsid.'.php');
5767
5768 $message .= '</body>
5769 </html>';
5770
5771 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
5772 $sender_email=$this->data['siteContactMail'];
5773 $sender_name=$this->data['siteTitle'];
5774 }else{
5775 $sender_name=$template_values['sender_name'];
5776 $sender_email=$template_values['sender_email'];
5777 }
5778
5779 $email_values = array('mail_type'=>'html',
5780 'from_mail_id'=>$sender_email,
5781 'mail_name'=>$sender_name,
5782 'to_mail_id'=>$followUserDetails->email,
5783 'subject_message'=>$subject,
5784 'body_messages'=>$message
5785 );
5786 $email_send_to_common = $this->product_model->common_email_send($email_values);
5787 }
5788 }
5789 }
5790
5791 /**
5792 *
5793 * To display the order reviews for user
5794 *
5795 */
5796 public function order_review(){
5797 if ($this->checkLogin('U')==''){
5798 show_404();
5799 }else {
5800 $uid = $this->uri->segment(2,0);
5801 $sid = $this->uri->segment(3,0);
5802 $dealCode = $this->uri->segment(4,0);
5803 if ($uid == $this->checkLogin('U')){
5804 $view_mode = 'user';
5805 }else if ($sid == $this->checkLogin('U')){
5806 $view_mode = 'seller';
5807 }else {
5808 $view_mode = '';
5809 }
5810 if ($view_mode == ''){
5811 show_404();
5812 }else {
5813 if ($view_mode == 'seller'){
5814 $this->db->select('p.*,pAr.attr_name');
5815 $this->db->from(PAYMENT.' as p');
5816 $this->db->join(PRODUCT_ATTRIBUTE.' as pAr' , 'pAr.id = p.attribute_values','left');
5817 $this->db->where('p.sell_id = "'.$sid.'" and p.status = "Paid" and p.dealCodeNumber = "'.$dealCode.'"');
5818 $order_details = $this->db->get();
5819
5820 //$order_details = $this->user_model->get_all_details(PAYMENT,array('dealCodeNumber'=>$dealCode,'status'=>'Paid','sell_id'=>$sid));
5821 }else {
5822
5823 //$order_details = $this->user_model->get_all_details(PAYMENT,array('dealCodeNumber'=>$dealCode,'status'=>'Paid'));
5824 $this->db->select('p.*,pAr.attr_name');
5825 $this->db->from(PAYMENT.' as p');
5826 $this->db->join(PRODUCT_ATTRIBUTE.' as pAr' , 'pAr.id = p.attribute_values','left');
5827 $this->db->where("p.status = 'Paid' and p.dealCodeNumber = '".$dealCode."'");
5828 $order_details = $this->db->get();
5829
5830
5831 }
5832
5833 if ($order_details->num_rows()==0){
5834 show_404();
5835 }else {
5836 if ($view_mode == 'user'){
5837 $this->data['user_details'] = $this->data['userDetails'];
5838 $this->data['seller_details'] = $this->user_model->get_all_details(USERS,array('id'=>$sid));
5839 }elseif ($view_mode == 'seller'){
5840 $this->data['user_details'] = $this->user_model->get_all_details(USERS,array('id'=>$uid));
5841 $this->data['seller_details'] = $this->data['userDetails'];
5842 }
5843 foreach ($order_details->result() as $order_details_row){
5844 $this->data['prod_details'][$order_details_row->product_id] = $this->user_model->get_all_details(PRODUCT,array('id'=>$order_details_row->product_id));
5845 }
5846 $this->data['view_mode'] = $view_mode;
5847 $this->data['order_details'] = $order_details;
5848 $sortArr1 = array('field'=>'date','type'=>'desc');
5849 $sortArr = array($sortArr1);
5850 $this->data['order_comments'] = $this->user_model->get_all_details(REVIEW_COMMENTS,array('deal_code'=>$dealCode),$sortArr);
5851 $this->load->view('site/user/display_order_reviews',$this->data);
5852 }
5853 }
5854 }
5855 }
5856
5857 /**
5858 *
5859 * To display the order reviews for seller
5860 *
5861 */
5862 public function order_seller_review(){
5863 if ($this->checkLogin('U')==''){
5864 show_404();
5865 }else {
5866 $uid = $this->uri->segment(2,0);
5867 $sid = $this->uri->segment(3,0);
5868 $dealCode = $this->uri->segment(4,0);
5869 if ($uid == $this->checkLogin('U')){
5870 $view_mode = 'user';
5871 }else if ($sid == $this->checkLogin('U')){
5872 $view_mode = 'seller';
5873 }else {
5874 $view_mode = '';
5875 }
5876 if ($view_mode == ''){
5877 show_404();
5878 }else {
5879 if ($view_mode == 'seller'){
5880 $this->db->select('p.*');
5881 $this->db->from(USER_PAYMENT.' as p');
5882 $this->db->where('p.sell_id = "'.$sid.'" and p.status = "Paid" and p.dealCodeNumber = "'.$dealCode.'"');
5883 $order_details = $this->db->get();
5884
5885 //$order_details = $this->user_model->get_all_details(PAYMENT,array('dealCodeNumber'=>$dealCode,'status'=>'Paid','sell_id'=>$sid));
5886 }else {
5887
5888 //$order_details = $this->user_model->get_all_details(PAYMENT,array('dealCodeNumber'=>$dealCode,'status'=>'Paid'));
5889 $this->db->select('p.*');
5890 $this->db->from(USER_PAYMENT.' as p');
5891 $this->db->where("p.status = 'Paid' and p.dealCodeNumber = '".$dealCode."'");
5892 $order_details = $this->db->get();
5893
5894
5895 }
5896
5897 if ($order_details->num_rows()==0){
5898 show_404();
5899 }else {
5900 if ($view_mode == 'user'){
5901 $this->data['user_details'] = $this->data['userDetails'];
5902 $this->data['seller_details'] = $this->user_model->get_all_details(USERS,array('id'=>$sid));
5903 }elseif ($view_mode == 'seller'){
5904 $this->data['user_details'] = $this->user_model->get_all_details(USERS,array('id'=>$uid));
5905 $this->data['seller_details'] = $this->data['userDetails'];
5906 }
5907 foreach ($order_details->result() as $order_details_row){
5908 $this->data['prod_details'][$order_details_row->product_id] = $this->user_model->get_all_details(USER_PRODUCTS,array('id'=>$order_details_row->product_id));
5909 }
5910 $this->data['view_mode'] = $view_mode;
5911 $this->data['order_details'] = $order_details;
5912 $sortArr1 = array('field'=>'date','type'=>'desc');
5913 $sortArr = array($sortArr1);
5914 $this->data['order_comments'] = $this->user_model->get_all_details(REVIEW_COMMENTS,array('deal_code'=>$dealCode),$sortArr);
5915 $this->load->view('site/user/display_order_reviews',$this->data);
5916 }
5917 }
5918 }
5919 }
5920
5921
5922 /**
5923 *
5924 * Seller shop product settings
5925 *
5926 */
5927 public function shop_temp()
5928 {
5929 extract($_POST);
5930 if ($this->checkLogin('U')!=''){
5931
5932 $this->user_model->updateUserQuickTemp();
5933 $this->setErrorMessage('success','Shop Product Setup Updated Successfully');
5934 redirect('settings');
5935
5936 }else {
5937 $this->data['next'] = $this->input->get('next');
5938 //echo $this->data['next'];die;
5939 $this->data['heading'] = 'Sign in';
5940 $this->load->view('site/user/signup.php',$this->data);
5941 }
5942
5943 }
5944
5945
5946 /**
5947 *
5948 * To display the poost comments
5949 *
5950 */
5951 public function post_order_comment(){
5952 if ($this->checkLogin('U') != ''){
5953 $this->user_model->commonInsertUpdate(REVIEW_COMMENTS,'insert',array(),array(),'');
5954 }
5955 }
5956
5957 /**
5958 *
5959 * To change the received status
5960 *
5961 */
5962 public function change_received_status(){
5963 if ($this->checkLogin('U')!=''){
5964 $status = $this->input->post('status');
5965 $rid = $this->input->post('rid');
5966 $this->user_model->update_details(PAYMENT,array('received_status'=>$status),array('id'=>$rid));
5967 }
5968 }
5969
5970 /**
5971 *
5972 * To update the favorite status
5973 *
5974 */
5975 public function update_favorite_status(){
5976 if ($this->checkLogin('U')!=''){
5977 $status = $this->input->post('status');
5978 $rid = $this->input->post('rid');
5979 $this->user_model->commonDelete(FAVORITE,array('received_status'=>$status),array('id'=>$rid));
5980 }
5981 }
5982
5983 /**
5984 *
5985 * To insert the favorite status
5986 * param String $shopid
5987 * param String $type
5988 *
5989 */
5990
5991 public function insert_favorite_status($shopid='',$type=''){
5992 error_reporting(0);
5993 $returnStr['status_code'] = 0;
5994 if($shopid!=''){
5995 $rdir=1;
5996 }
5997 if ($this->checkLogin('U')!=''){
5998 $userid = $this->checkLogin('U');
5999 if($shopid==''){
6000 $shopid = $this->input->post('shopid');
6001 }
6002
6003 if($shopid == $this->checkLogin('U')){
6004 $returnStr['status_code'] = 2;
6005 echo json_encode($returnStr); die;
6006 }
6007
6008
6009 if($type==''){
6010 $type = $this->input->post('type');}
6011 if($type == 'Fresh'){
6012 $checkShopStaus = $this->user_model->get_all_details(FAVORITE,array('shop_id'=>$shopid,'user_id'=>$userid,'favorite'=>'Yes'));
6013 if ($checkShopStaus->num_rows() < 1){
6014 $dataArr = array('shop_id'=>$shopid,'user_id'=>$userid,'favorite'=>'Yes');
6015 $this->user_model->simple_insert(FAVORITE,$dataArr);
6016 # addding favorites shop count and add to activity table
6017 $checkShopLike = $this->user_model->get_all_details(FAVORITE,array('shop_id'=>$shopid));
6018 if ($checkShopLike->num_rows() > 0){
6019 $userDetails = $this->user_model->get_all_details(USERS,array('id'=>$shopid));
6020 if ($userDetails->num_rows()>0){
6021 $likes = $userDetails->row()->likes;
6022 $actArr = array(
6023 'activity_name' => 'favorite shop',
6024 'activity_id' => $shopid,
6025 'user_id' => $this->checkLogin('U'),
6026 'activity_time' =>time(),
6027 'activity_ip' => $this->input->ip_address()
6028 );
6029 // print_r($actArr);die;
6030 $checkShopStatus = $this->user_model->get_all_details(USER_ACTIVITY,array('activity_id'=>$shopid,'user_id'=>$this->checkLogin('U')));
6031 if ($checkShopStatus->num_rows() < 1){
6032 $this->user_model->simple_insert(USER_ACTIVITY,$actArr);
6033 }
6034 else
6035 {
6036 $this->user_model->commonDelete(USER_ACTIVITY,array('activity_id'=>$shopid,'user_id'=>$this->checkLogin('U')));
6037 $this->user_model->simple_insert(USER_ACTIVITY,$actArr);
6038 }
6039
6040 $this->user_model->commonDelete(NOTIFICATIONS,array('activity'=>'favorite shop','activity_id'=>$shopid,'user_id'=>$this->checkLogin('U')));
6041 $this->user_model->commonDelete(NOTIFICATIONS,array('activity'=>'unfavorite shop','activity_id'=>$shopid,'user_id'=>$this->checkLogin('U')));
6042 $actArr = array('activity'=>'favorite shop',
6043 'activity_id'=>$shopid,
6044 'user_id' =>$userid,
6045 'activity_ip'=>$this->input->ip_address(),
6046 'created'=>date("Y-m-d H:i:s"));
6047 $this->user_model->simple_insert(NOTIFICATIONS,$actArr);
6048
6049
6050 $likes++;
6051 $dataArr = array('likes'=>$likes);
6052 $condition = array('id'=>$shopid);
6053 $this->user_model->update_details(USERS,$dataArr,$condition);
6054 #$returnStr['status_code'] = 1;
6055 }
6056 }
6057 }
6058 //$seller_id_fav=$this->user_model->get_all_details(SELLER,array('id'=
6059 $sent_email=$this->user_model->get_all_details(USERS,array('id'=>$shopid));//,'fav_shop'=>'Yes'));
6060 $noty_email_arr=explode(',',$sent_email->row()->notification_email);
6061 if(in_array('fav_shop',$noty_email_arr)){
6062 //$query=$this->user_model->get_all_details(USERS, array('id'= $follow_id));
6063 $full_name=$sent_email->row()->full_name;
6064 $cfull_name=$this->data['userDetails']->row()->full_name;
6065 $user_name=$this->data['userDetails']->row()->user_name;
6066 $newsid='31';
6067 $template_values=$this->user_model->get_newsletter_template_details($newsid);
6068
6069 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo']);
6070 extract($adminnewstemplateArr);
6071 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
6072 $message .= '<!DOCTYPE HTML>
6073 <html>
6074 <head>
6075 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6076 <meta name="viewport" content="width=device-width"/>
6077 <title>'.$template_values['news_subject'].'</title>
6078 <body>';
6079 include('./newsletter/registeration'.$newsid.'.php');
6080
6081 $message .= '</body>
6082 </html>';
6083
6084
6085 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
6086 $sender_email=$this->config->item('site_contact_mail');
6087
6088 $sender_name=$this->config->item('email_title');
6089 }else{
6090 $sender_name=$template_values['sender_name'];
6091 $sender_email=$template_values['sender_email'];
6092 }
6093 $email_values = array('mail_type'=>'html',
6094 'from_mail_id'=>$sender_email,
6095 'mail_name'=>$sender_name,
6096 'to_mail_id'=>$sent_email->row()->email,
6097 'subject_message'=>'Shop favorite',
6098 'body_messages'=>$message
6099 );
6100
6101 //echo '<pre>'; print_r($email_values); die;
6102
6103 $email_send_to_common = $this->product_model->common_email_send($email_values);#die;
6104 }
6105 $add_shopfav_list=addslashes(shopsy_lg('lg_add_shopfav_list','This Shop Added to Your Favorite List!'));
6106 //$this->setErrorMessage('success',$add_shopfav_list);
6107 $returnStr['status_code'] = 1;
6108 /*Push Message Starts*/
6109 $message=$this->session->userdata('shopsy_session_user_name').' favorited your shop on '.$this->config->item('email_title');
6110 $type='favorite shop';
6111 $this->sendPushNotification($shopid,$message,$type,array($userid));
6112 /*Push Message Ends*/
6113 if($rdir){
6114 redirect('people/'.$this->session->userdata('shopsy_session_user_name').'/favorites/shop');
6115 }
6116 }else if($type == 'Old'){
6117 # Updating favorites shop count and update to activity table
6118 $checkShopLike = $this->user_model->get_all_details(FAVORITE,array('shop_id'=>$shopid));
6119 if ($checkShopLike->num_rows() > 0){
6120 $userDetails = $this->user_model->get_all_details(USERS,array('id'=>$shopid));
6121 if ($userDetails->num_rows()>0){
6122 $likes = $userDetails->row()->likes;
6123 $actArr = array(
6124 'activity_name' => 'Unfavorite shop',
6125 'activity_id' => $shopid,
6126 'user_id' => $this->checkLogin('U'),
6127 'activity_time' =>time(),
6128 'activity_ip' => $this->input->ip_address()
6129 );
6130 $condition = array('activity_id'=>$shopid,'user_id'=>$this->checkLogin('U'));
6131 $this->user_model->update_details(USER_ACTIVITY,$actArr,$condition);
6132 //print_r($this->user_model->db->last_query());
6133 $this->user_model->commonDelete(NOTIFICATIONS,array('activity'=>'favorite shop','activity_id'=>$shopid,'user_id'=>$this->checkLogin('U')));
6134 $this->user_model->commonDelete(NOTIFICATIONS,array('activity'=>'unfavorite shop','activity_id'=>$shopid,'user_id'=>$this->checkLogin('U')));
6135 $actArr = array('activity'=>'unfavorite shop',
6136 'activity_id'=>$shopid,
6137 'user_id' =>$userid,
6138 'activity_ip'=>$this->input->ip_address(),
6139 'created'=>date("Y-m-d H:i:s"));
6140 $this->user_model->simple_insert(NOTIFICATIONS,$actArr);
6141
6142 $likes--;
6143 $dataArr = array('likes'=>$likes);
6144 $condition = array('id'=>$shopid);
6145 $this->user_model->update_details(USERS,$dataArr,$condition);
6146 #$returnStr['status_code'] = 1;
6147 }
6148 $remove_shop =shopsy_lg('lg_remove_shop','This Shop Removed From Your Favorite List!');
6149 $this->user_model->fav_delete($userid,$shopid);
6150 //$this->setErrorMessage('success',$remove_shop);
6151 if($rdir){
6152 redirect('people/'.$this->session->userdata('shopsy_session_user_name').'/favorites/shop');
6153 }
6154
6155 }
6156 $returnStr['status_code'] = 1;
6157 }
6158 }
6159 else
6160 {
6161 $lg_login_reg_toadd_shopto_fav=addslashes(shopsy_lg('lg_login_reg_toadd_shopto_fav','Login Required for Adding this shop to your favorites'));
6162 $this->setErrorMessage('error',$lg_login_reg_toadd_shopto_fav);
6163 $returnStr['status_code'] = 0;
6164 $returnStr['next_url']=urlencode('site/user/insert_favorite_status/'.$this->input->post('shopid').'/'.$this->input->post('type'));
6165 }
6166 echo json_encode($returnStr);
6167 }
6168
6169
6170 /**
6171 *
6172 * To add the product favorite list
6173 * param String $pid
6174 * param String $type
6175 *
6176 */
6177 public function product_favorite_status($pid='',$type=''){
6178 // echo $pid.' '.$type;
6179 //error_reporting(0);
6180 $returnStr['status_code'] = 0;
6181 $rdir = 0;
6182 if($type!=''){
6183 $rdir = 1;
6184 }
6185 if ($this->checkLogin('U')!=''){
6186 $userid = $this->checkLogin('U');
6187 if($pid==''){
6188 $pid = $this->input->post('pid');
6189 }
6190 $productDetails = $this->user_model->get_all_details(PRODUCT,array('id'=>$pid));
6191 if($productDetails->row()->user_id == $this->checkLogin('U')){
6192 $returnStr['status_code'] = 2;
6193 //$this->setErrorMessage('error','You Can\t favorite your own item.');
6194 echo json_encode($returnStr); die;
6195 }
6196 if($type==''){
6197 $type = $this->input->post('type');
6198 }//echo $type;die;
6199 if($type == 'Fresh'){
6200 //echo "afdgf";die;
6201 $checkFavStatus = $this->user_model->get_all_details(FAVORITE,array('p_id'=>$pid,'user_id'=>$userid,'favorite'=>'Yes'));
6202 if ($checkFavStatus->num_rows() < 1){
6203
6204 $dataArr = array('p_id'=>$pid,'user_id'=>$userid,'favorite'=>'Yes');
6205 $this->user_model->simple_insert(FAVORITE,$dataArr);
6206
6207 # addding favorites count and add to activity table
6208 $checkProductLike = $this->user_model->get_all_details(FAVORITE,array('p_id'=>$pid));
6209 if ($checkProductLike->num_rows() > 0){
6210 if ($productDetails->num_rows()>0){
6211 $likes = $productDetails->row()->likes;
6212 $actArr = array(
6213 'activity_name' => 'favorite item',
6214 'activity_id' => $pid,
6215 'user_id' => $this->checkLogin('U'),
6216 'activity_time' =>time(),
6217 'activity_ip' => $this->input->ip_address()
6218 );
6219 $checkProductStatus = $this->user_model->get_all_details(USER_ACTIVITY,array('activity_id'=>$pid,'user_id'=>$this->checkLogin('U')));
6220 if ($checkProductStatus->num_rows() < 1){
6221 $this->user_model->simple_insert(USER_ACTIVITY,$actArr);
6222 }
6223 else
6224 {
6225 $this->user_model->commonDelete(USER_ACTIVITY,array('activity_id'=>$pid,'user_id'=>$this->checkLogin('U')));
6226 $this->user_model->simple_insert(USER_ACTIVITY,$actArr);
6227 }
6228
6229 $this->user_model->commonDelete(NOTIFICATIONS,array('activity'=>'favorite item','activity_id'=>$pid,'user_id'=>$this->checkLogin('U')));
6230 $this->user_model->commonDelete(NOTIFICATIONS,array('activity'=>'unfavorite item','activity_id'=>$pid,'user_id'=>$this->checkLogin('U')));
6231 $actArr = array('activity'=>'favorite item',
6232 'activity_id'=>$pid,
6233 'user_id' =>$userid,
6234 'activity_ip'=>$this->input->ip_address(),
6235 'created'=>date("Y-m-d H:i:s"));
6236 $this->user_model->simple_insert(NOTIFICATIONS,$actArr);
6237
6238 $likes++;
6239 $dataArr = array('likes'=>$likes);
6240 $condition = array('id'=>$pid);
6241 $this->user_model->update_details(PRODUCT,$dataArr,$condition);
6242 $returnStr['status_code'] = 1;
6243 $sent_email=$this->user_model->get_all_details(USERS,array('id'=>$shopid));//,'like'=>'Yes'));
6244 $noty_email_arr=explode(',',$sent_email->row()->notification_email);
6245 //echo $this->db->last_query();
6246 // print_r($sent_email->row());
6247 //print_r($noty_email_arr);
6248 if(in_array('like',$noty_email_arr)){
6249 $full_name=$sent_email->row()->full_name;
6250 #echo "<pre>";print_r($this->data['userDetails']);die;
6251 $user_name=$this->data['userDetails']->row()->full_name;
6252 $product_seo=$productDetails->row()->seourl;
6253
6254 $newsid='29';
6255
6256 $template_values=$this->user_model->get_newsletter_template_details($newsid);
6257
6258 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo'],'meta_title'=>$this->config->item('meta_title'));
6259 extract($adminnewstemplateArr);
6260 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
6261 $message .= '<!DOCTYPE HTML>
6262 <html>
6263 <head>
6264 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6265 <meta name="viewport" content="width=device-width"/>
6266 <title>'.$template_values['news_subject'].'</title>
6267 <body>';
6268 include('./newsletter/registeration'.$newsid.'.php');
6269
6270 $message .= '</body>
6271 </html>';
6272
6273
6274 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
6275 $sender_email=$this->config->item('site_contact_mail');
6276
6277 $sender_name=$this->config->item('email_title');
6278 }else{
6279 $sender_name=$template_values['sender_name'];
6280 $sender_email=$template_values['sender_email'];
6281 }
6282 $email_values = array('mail_type'=>'html',
6283 'from_mail_id'=>$sender_email,
6284 'mail_name'=>$sender_name,
6285 'to_mail_id'=>$sent_email->row()->email,
6286 'subject_message'=>'Favourite',
6287 'body_messages'=>$message
6288 );
6289
6290 //echo '<pre>'; print_r($email_values); die;
6291
6292 // $email_send_to_common = $this->product_model->common_email_send($email_values);#die;
6293 }
6294 }
6295 }
6296
6297 $favorite_list=$this->product_model->get_all_details(FAVORITE,array('p_id'=>$p_id));
6298 foreach($favorite_list->result() as $fav_list){
6299 #echo "<pre>";print_r($fav_list);#die;
6300 $sentfav_list=$this->product_model->get_all_details(USERS, array('id'=>$fav_list->user_id));//'like_of_like'=>'Yes'));
6301 //echo $this->db->last_query();
6302 //echo "<pre>";print_r($sentfav_list->row());die;
6303 if($sentfav_list->num_rows >0){
6304 $noty_email_arr=explode(',',$sentfav_list->row()->notification_email);
6305 #echo "<pre>";print_r($noty_email_arr);#die;
6306 if(in_array('lik_of_like',$noty_email_arr)){
6307 $full_name=$sentfav_list->row()->full_name;
6308 #echo "<pre>";print_r($this->data['userDetails']);die;
6309 $user_name=$this->data['userDetails']->row()->full_name;
6310 $product_seo=$productDetails->row()->seourl;
6311
6312 $newsid='30';
6313
6314 $template_values=$this->user_model->get_newsletter_template_details($newsid);
6315
6316 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo'],'meta_title'=>$this->config->item('meta_title'));
6317 extract($adminnewstemplateArr);
6318 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
6319 $message .= '<!DOCTYPE HTML>
6320 <html>
6321 <head>
6322 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6323 <meta name="viewport" content="width=device-width"/>
6324 <title>'.$template_values['news_subject'].'</title>
6325 <body>';
6326 $bp=base_url();
6327 #echo $bp;die;
6328 include_once('./newsletter/registeration'.$newsid.'.php');
6329
6330 $message .= '</body>
6331 </html>';
6332
6333
6334 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
6335 $sender_email=$this->config->item('site_contact_mail');
6336
6337 $sender_name=$this->config->item('email_title');
6338 }else{
6339 $sender_name=$template_values['sender_name'];
6340 $sender_email=$template_values['sender_email'];
6341 }
6342 $email_values = array('mail_type'=>'html',
6343 'from_mail_id'=>$sender_email,
6344 'mail_name'=>$sender_name,
6345 'to_mail_id'=>$sentfav_list->row()->email,
6346 'subject_message'=>'Favourite',
6347 'body_messages'=>$message
6348 );
6349
6350 #echo '<pre>'; print_r($email_values); die;
6351
6352 // $email_send_to_common = $this->product_model->common_email_send($email_values);#die;
6353 }
6354 }
6355
6356 }
6357 $shopid = $productDetails->row()->user_id;
6358 /*Push Message Starts*/
6359 $message=$this->session->userdata('shopsy_session_user_name').' favorited your item on '.$this->config->item('email_title');
6360 $type='favorite item';
6361 $this->sendPushNotification($shopid,$message,$type,array($pid));
6362 /*Push Message Ends*/
6363 // echo "finished";
6364 $returnStr['status_code'] = 1;
6365 $returnStr['fav'] = 1;
6366
6367 }
6368 if($this->lang->line('product_add_fav') != '') { $product_add_fav= stripslashes($this->lang->line('product_add_fav')); } else { $product_add_fav = "Product Added to Favorite List!"; }
6369 //$this->setErrorMessage('success',$product_add_fav);
6370 if($rdir){
6371 redirect('people/'.$this->session->userdata('shopsy_session_user_name').'/favorites/items-i-love');
6372 }
6373 }else if($type == 'Old'){
6374 $checkFavStatus = $this->user_model->get_all_details(FAVORITE,array('p_id'=>$pid,'user_id'=>$userid,'favorite'=>'Yes'));
6375 if ($checkFavStatus->num_rows() > 0){
6376 # Updating favorites count and update to activity table
6377 $checkProductLike = $this->user_model->get_all_details(FAVORITE,array('p_id'=>$pid));
6378
6379 if ($checkProductLike->num_rows() > 0){
6380 $productDetails = $this->user_model->get_all_details(PRODUCT,array('id'=>$pid));
6381 if ($productDetails->num_rows()>0){
6382 $likes = $productDetails->row()->likes;
6383 $actArr = array(
6384 'activity_name' => 'Unfavorite item',
6385 'activity_id' => $pid,
6386 'user_id' => $this->checkLogin('U'),
6387 'activity_time' =>time(),
6388 'activity_ip' => $this->input->ip_address()
6389 );
6390 $condition = array('activity_id'=>$pid,'user_id'=>$this->checkLogin('U'));
6391 $this->user_model->update_details(USER_ACTIVITY,$actArr,$condition);
6392
6393 $this->user_model->commonDelete(NOTIFICATIONS,array('activity'=>'favorite item','activity_id'=>$pid,'user_id'=>$this->checkLogin('U')));
6394 $this->user_model->commonDelete(NOTIFICATIONS,array('activity'=>'unfavorite item','activity_id'=>$pid,'user_id'=>$this->checkLogin('U')));
6395 $actArr = array('activity'=>'unfavorite item',
6396 'activity_id'=>$pid,
6397 'user_id' =>$userid,
6398 'activity_ip'=>$this->input->ip_address(),
6399 'created'=>date("Y-m-d H:i:s"));
6400 $this->user_model->simple_insert(NOTIFICATIONS,$actArr);
6401
6402 $likes--;
6403 $dataArr = array('likes'=>$likes);
6404 $condition = array('id'=>$pid);
6405 $this->user_model->update_details(PRODUCT,$dataArr,$condition);
6406 #$returnStr['status_code'] = 1;
6407 $returnStr['fav'] = 0;
6408 }
6409 $this->user_model->product_fav_delete($userid,$pid);
6410 if($this->lang->line('product_remove_fav') != '') { $product_remove_fav= stripslashes($this->lang->line('product_remove_fav')); } else { $product_remove_fav = "Product Removed from Favorite List!"; }
6411 //$this->setErrorMessage('success',$product_remove_fav);
6412 if($rdir){
6413 redirect('people/'.$this->session->userdata('shopsy_session_user_name').'/favorites/items-i-love');
6414 }
6415 }
6416 $returnStr['status_code'] = 1;
6417
6418 }
6419 $returnStr['status_code'] = 1;
6420 }
6421 }
6422 else
6423 {
6424 $login_required=addslashes(shopsy_lg('lg_login req to add this product','Login Required for Adding this product to your favorites'));
6425 $this->setErrorMessage('error',$login_required);
6426 $returnStr['status_code'] = 0;
6427 $returnStr['next_url'] =urlencode('site/user/product_favorite_status/'.$this->input->post('pid').'/'.$this->input->post('type'));
6428
6429 }
6430
6431
6432
6433 echo json_encode($returnStr);
6434 }
6435
6436 /**
6437 *
6438 * To view the people favorite list
6439 *
6440 */
6441 public function people_favorite_list(){
6442 if ($this->checkLogin('U')==''){
6443 redirect('login');
6444 }
6445 else
6446 {
6447 $curenUserId = $this->session->userdata('shopsy_session_user_id');
6448 $curenUserName = $this->session->userdata('shopsy_session_user_name');
6449
6450 $username = urldecode($this->uri->segment(1,0));
6451 $this->data['viewprofile'] = $this->user_model->get_all_details(USERS,array('user_name'=>$username,'status'=>'Active'));
6452 // echo $this->db->last_query();die;
6453 if($this->data['viewprofile']->num_rows()==0){
6454 redirect('login');
6455 }
6456
6457 if($curenUserId!=$this->data['viewprofile']->row()->id){
6458 redirect(base_url($curenUserName.'/wishlist'));
6459 }
6460
6461 $this->data['currUser']=$checkloginIDarr=$this->session->all_userdata();
6462 $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
6463 $username = urldecode($this->uri->segment(1,0));
6464 $userDetails= $this->user_model->get_all_details(USERS,array('user_name'=>$username))->result_array();
6465 $uid=$userDetails[0]['id'];
6466 $this->data['userProfileDetailsAll']=$userProfileDetailsAll = $this->user_model->get_all_details(USERS,array('id'=>$userDetails[0]['id'],'status'=>'Active'))->result_array();
6467 $this->data['userFavoriteItems']=$userFavoriteItems = $this->product_model->getFavoriteProduct($userDetails[0]['id'])->result_array();
6468 //echo $this->db->last_query();die;
6469 $this->data['userListDetails']=$userListDetails = $this->user_model->get_all_details(LISTS_DETAILS,array('user_id'=>$userDetails[0]['id']))->result_array();
6470 //echo "<pre>"; print_r($userListDetails); die;
6471
6472 $username = urldecode($this->uri->segment(1,0));
6473 $userProfileDetails = $this->data['userProfileDetails'] = $this->user_model->get_all_details(USERS,array('user_name'=>$username))->result_array();
6474
6475 $this->data['heading'] = $username.' Favorites on '.$this->config->item('email_title');
6476 $this->load->view('site/user/favorites',$this->data);
6477 }
6478
6479 }
6480
6481 /**
6482 *
6483 * To view the people favorite list and view the favorite list items
6484 *
6485 */
6486 public function people_favorite_list_itemsilove(){//die;
6487 #if ($this->checkLogin('U')!=''){
6488 $this->data['currUser']=$checkloginIDarr=$this->session->all_userdata();
6489 $this->data['loggeduserID']=$loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
6490 $username = urldecode($this->uri->segment(2,0));
6491 $userDetails= $this->user_model->get_all_details(USERS,array('user_name'=>$username))->result_array();
6492 $userDetails[0]['id'];
6493 $condition='';
6494 if($_GET['a']){
6495 $search_key=$_GET['a'];
6496 $condition="p.product_name LIKE '%".$search_key."%' and";
6497 }
6498 if($_GET['filter']){
6499 $condition="p.status='Publish' and p.quantity>2 and";
6500 }
6501 $this->data['userProfileDetails']=$userProfileDetails = $this->user_model->get_all_details(USERS,array('id'=>$userDetails[0]['id'],'status'=>'Active'))->result_array();
6502 $this->data['userFavoriteItems']=$userFavoriteItems = $this->product_model->getFavoriteProduct($userDetails[0]['id'],$condition,8,0)->result_array();
6503 #echo "<pre>"; print_r($userProfileDetails); print_r($userFavoriteItems); die;
6504 $this->data['heading'] = 'Items I love by '.$username.' on '.$this->config->item('email_title');
6505 $this->load->view('site/user/itemsilove',$this->data);
6506
6507 #}
6508
6509 }
6510
6511 /**
6512 *
6513 * To view the people favorite list
6514 *
6515 */
6516
6517 public function people_list_items(){
6518 #if ($this->checkLogin('U')!=''){
6519 $urlValArr=$this->uri->segment_array();
6520 $urlVal=explode('-',$urlValArr[count($urlValArr)]);
6521 $this->data['listId']=$listId=$urlVal[0];
6522 #$this->data['listName']=$listName=$urlVal[1];
6523 $listProduct=array();
6524 $this->data['listProductVal']=$listProductVal= $this->user_model->get_all_details(LISTS_DETAILS,array('id'=>$listId))->result_array();
6525 $this->data['listName']=$listName=$listProductVal[0]['name'];
6526 #echo '<pre>'; print_r($listProductVal); die;
6527 $products=explode(',',$listProductVal[0]['product_id']);
6528 for($i=0;$i<count($products);$i++)
6529 {
6530 $condition='';
6531 if($_GET['a']){
6532 $search_key=$_GET['a'];
6533 $condition="p.product_name LIKE '%".$search_key."%' and";
6534 }
6535 if($_GET['filter']){
6536 $condition="p.status='Publish' and p.quantity>0 and";
6537 }
6538 $listProduct=array_merge($listProduct,$this->product_model->get_list_product_details($products[$i],$condition)->result_array());
6539 #echo $this->db->last_query();
6540 }
6541 #die;
6542 $this->data['listProduct']=$listProduct;
6543 $checkloginIDarr=$this->session->all_userdata();
6544 $this->data['loggeduserID']= $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
6545 $username = urldecode($this->uri->segment(2,0));
6546 $userDetails= $this->user_model->get_all_details(USERS,array('user_name'=>$username))->result_array();
6547 $userDetails[0]['id'];
6548 $this->data['userProfileDetails']=$userProfileDetails = $this->user_model->get_all_details(USERS,array('id'=>$userDetails[0]['id'],'status'=>'Active'))->result_array();
6549 $this->data['heading'] = $urlVal[1].' by '.$username.' on '.$this->config->item('email_title');
6550 $this->load->view('site/user/favorites_list_items',$this->data);
6551
6552 #}
6553
6554 }
6555
6556 /**
6557 *
6558 * To view the people favorite shop list
6559 *
6560 */
6561 public function people_favorite_shoplist(){
6562 #if ($this->checkLogin('U')!=''){
6563 $this->data['currUser']=$checkloginIDarr=$this->session->all_userdata();
6564 $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
6565 $username = urldecode($this->uri->segment(2,0));
6566 $this->data['userDetails']=$userDetails= $this->user_model->get_all_details(USERS,array('user_name'=>$username))->result_array();
6567 #$userDetails[0]['id'];
6568 $this->data['userProfileDetails']=$userProfileDetails = $this->user_model->get_all_details(USERS,array('id'=>$userDetails[0]['id'],'status'=>'Active'))->result_array();
6569 $this->data['userFavoriteShops']=$userFavoriteShops = $this->product_model->getFavoriteShops($userDetails[0]['id'])->result_array();
6570 $userFavoriteShopsProducts=array();
6571 foreach($userFavoriteShops as $shops)
6572 {
6573 $condition="p.user_id=".$shops['seller_id']." GROUP BY p.id";
6574 $products=$this->product_model->get_product_from_favorite_shop($condition)->result_array();
6575 //echo $this->db->last_query(); die;
6576 $userFavoriteShopsProducts=array_merge($userFavoriteShopsProducts,$products);
6577 #echo "<pre>"; print_r($this->data["'shop_'".$shop_product.'"']);
6578 }
6579 $this->data['userFavoriteShopsProducts']=$userFavoriteShopsProducts ;
6580 #echo "<pre>"; print_r($userProfileDetails); print_r($userFavoriteShops); print_r($userFavoriteShopsProducts); die;
6581 $username = urldecode($this->uri->segment(2,0));
6582 $userProfileDetails =$this->data['userProfileDetails']= $this->user_model->get_all_details(USERS,array('user_name'=>$username));
6583 $this->data['heading'] = $username.'\'s Favorites on '.$this->config->item('email_title');
6584 $this->load->view('site/user/favorite_shop',$this->data);
6585
6586 #}
6587
6588 }
6589
6590 /**
6591 *
6592 * User AddEdit products to List
6593 *
6594 */
6595 public function user_addproducttolist(){
6596 if ($this->checkLogin('U')!=''){
6597 $listId=$this->input->post('listId');
6598 $prodId=$this->input->post('prodId');
6599 echo '/'.$listId; echo '/'.$prodId;
6600 $this->data['listProduct']=$listProduct = $this->user_model->get_all_details(LISTS_DETAILS,array('id'=>$listId))->result_array();
6601 $productArr=explode(',',$listProduct[0]['product_id']);
6602 if(in_array($prodId,$productArr))
6603 {
6604 $newproductlist=str_replace($prodId.',','',$listProduct[0]['product_id']);
6605 $productCount=$listProduct[0]['product_count']-1;
6606
6607 }
6608 else
6609 {
6610 $newproductlist=$listProduct[0]['product_id'].$prodId.','; $productCount=$listProduct[0]['product_count']+1;
6611 }
6612 $ur_list_updated=addslashes(shopsy_lg('lg_your list_updated','Your List has been updated'));
6613 //echo "<pre>"; print_r($listProduct); print_r($productArr); echo $newproductlist;echo '/'.$productCount; die;
6614 $this->user_model->update_details(LISTS_DETAILS,array('product_id'=>$newproductlist,'product_count'=>$productCount),array('id'=>$listId));
6615 $this->setErrorMessage('success',$ur_list_updated);
6616
6617 }
6618 }
6619
6620 /**
6621 *
6622 * update user favorite status
6623 * param Int $id
6624 *
6625 */
6626 public function update_user_favorite_status($id=''){
6627 if ($this->checkLogin('U')!=''){
6628 $username = urldecode($this->uri->segment(2,0));
6629
6630 $privacy_level=$this->input->post('privacy_level');
6631
6632 $dataArr = array('favorites_visibility'=>$privacy_level);
6633 $condition = array('id'=>$this->session->userdata('shopsy_session_user_id'));
6634 #echo "<pre>"; print_r($dataArr); print_r($condition); die;
6635 $this->user_model->update_details(USERS,$dataArr,$condition);
6636
6637 $list_updated_successfully=addslashes(shopsy_lg('lg_List_Updated_successfully','List Updated successfully'));
6638
6639 $this->setErrorMessage('success',$list_updated_successfully);
6640 redirect('/people/'.$this->session->userdata('shopsy_session_user_name').'/favorites/items-i-love');
6641
6642 }
6643 else
6644 {
6645 $this->setErrorMessage('error','Login Required');
6646 redirect('login');
6647 }
6648 }
6649
6650 /**
6651 *
6652 * update user favorite shop visibility
6653 * param Int $id
6654 *
6655 */
6656 public function update_user_favorite_shop_staus($id=''){
6657 if ($this->checkLogin('U')!=''){
6658 $username = urldecode($this->uri->segment(2,0));
6659
6660 $privacy_level=$this->input->post('privacy_level');
6661
6662 $dataArr = array('shop_visibility'=>$privacy_level);
6663 $condition = array('id'=>$this->session->userdata('shopsy_session_user_id'));
6664 #echo "<pre>"; print_r($dataArr); print_r($condition); die;
6665 $this->user_model->update_details(USERS,$dataArr,$condition);
6666 $shop_visiblity=addslashes(shopsy_lg('lg_your_shop_visible_changed','your shop visibilty changed successfully'));
6667
6668 $this->setErrorMessage('success', $shop_visiblity);
6669 redirect('/people/'.$this->session->userdata('shopsy_session_user_name').'/favorites/shop');
6670
6671 }
6672 else
6673 {
6674 $this->setErrorMessage('error','Login Required');
6675 redirect('login');
6676 }
6677 }
6678
6679 /**
6680 *
6681 * Contact Shop Owner Check product popup function
6682 *
6683 */
6684 public function contactshop(){
6685
6686 $usrId = $this->input->post('usrId');
6687 $orderId = $this->input->post('orderId');
6688
6689 $userPurchase=$this->user_model->get_user_purchase_list($usrId,$orderId);
6690 $purchaseProducts=$userPurchase->result();
6691 $UserVal = $this->user_model->get_all_details(USERS,array( 'id' => $this->data['common_user_id']));
6692
6693
6694 if($purchaseProducts[0]->thumbnail !=''){
6695 $srcVal = 'images/users/'.$purchaseProducts[0]->thumbnail;
6696
6697 }else{
6698 $srcVal = 'images/default_avat.png';
6699 }
6700 $datestring ="%M %d,%Y "; $time = $purchaseProducts[0]->inserttime;
6701 $transactionon=mdate($datestring,$time);
6702
6703 $popupVal = '<form name="contactshopowener" id="contactshopowener" method="post" action="site/user/purchasecontactshopowner">
6704 <div class="conversation">
6705 <div class="conversation_container">
6706 <h2 class="conversation_headline">New conversation with '.ucfirst($purchaseProducts[0]->full_name).' from '.ucfirst($purchaseProducts[0]->shopname).'</h2>
6707 <div class="conversation_thumb"><img width="75" height="75" src="'.$srcVal.'"></div>
6708 <div class="conversation_right">
6709
6710 <input class="conversation-subject" type="text" name="subject" placeholder="Subject" value="Re: Order #'.$purchaseProducts[0]->dealCodeNumber.' on '.$transactionon.'">
6711 <textarea class="conversation-textarea" rows="11" name="message_text" placeholder="Message text">Invoice: '.base_url().'view-order/'.$UserVal->row()->id.'/'.$purchaseProducts[0]->dealCodeNumber.'</textarea>
6712
6713 <input type="hidden" name="username" id="username" value="'.$UserVal->row()->full_name.'" >
6714 <input type="hidden" name="useremail" id="useremail" value="'.$UserVal->row()->email.'" >
6715 <input type="hidden" name="userid" id="userid" value="'.$UserVal->row()->id.'" >
6716 <input type="hidden" name="selleremail" id="selleremail" value="'.$purchaseProducts[0]->seller_email.'" >
6717 <input type="hidden" name="sellerid" id="sellerid" value="'.$purchaseProducts[0]->sell_id.'" >
6718 <input type="hidden" name="dealcode_number" id="dealcode_number" value="'.$purchaseProducts[0]->dealCodeNumber.'" >
6719 <input type="hidden" name="subject_name" id="subject_name" value="New conversation with '.ucfirst($purchaseProducts[0]->full_name).' from '.ucfirst($purchaseProducts[0]->shopname).'">
6720
6721 </div>
6722 <div class="modal-footer footer_tab_footer">
6723 <div class="btn-group">
6724 <input class="submit_btn" type="submit" value="send">
6725 <a class="btn btn-default submit_btn" data-dismiss="modal" id="report-cancel">Cancel</a>
6726 </div>
6727 </div>
6728
6729 </div>
6730 </div>
6731
6732
6733 </form>';
6734
6735 echo $popupVal;
6736
6737 return;
6738
6739 }
6740
6741 /**
6742 *
6743 * Contact Shop Owner Check product shop owners
6744 *
6745 */
6746 public function purchasecontactshopowner(){
6747 //echo "<pre>";print_r($this->input->post());die;
6748 $dataArr = array(
6749 'username'=>$this->input->post('username'),
6750 'useremail'=>$this->input->post('useremail'),
6751 'user_id'=>$this->input->post('userid'),
6752 'selleremail'=>$this->input->post('selleremail'),
6753 'sellerid'=>$this->input->post('sellerid'),
6754 'dealcode_number'=>$this->input->post('dealcode_number'),
6755 'description'=> strip_tags($this->input->post('message_text'))
6756 );
6757 $tid=time();
6758 //echo CONTACTSHOPSELLER." ".CONTACTPEOPLE;die;
6759 $this->user_model->simple_insert(CONTACTSHOPSELLER,$dataArr);
6760 //echo $this->db->last_query();
6761 $dataArry = array('sender_email'=>$this->input->post('useremail'),'sender_id'=>$this->input->post('userid'),'receiver_email'=>$this->input->post('selleremail'),'receiver_id'=>$this->input->post('sellerid'),'subject'=>strip_tags($this->input->post('subject')),'message'=>strip_tags($this->input->post('message_text')),'dataAdded'=>date('Y-m-d H:i:s'),'tid'=>$tid);
6762 $this->user_model->simple_insert(CONTACTPEOPLE,$dataArry);
6763 //echo $this->db->last_query();die;
6764 $actArr = array('activity'=>"message",
6765 'activity_id'=>$this->input->post('sellerid'),
6766 'user_id' =>$this->input->post('userid'),
6767 'activity_ip'=>$this->input->ip_address(),
6768 'created'=>date("Y-m-d H:i:s"),
6769 'comment_id'=>$tid);
6770 $this->user_model->simple_insert(NOTIFICATIONS,$actArr);
6771
6772 $receiver_id=$this->input->post('sellerid');
6773 $sender_id=$this->input->post('userid');
6774 /*Push Message Starts*/
6775 $message='You received a message from '.$this->input->post('username').' on '.$this->config->item('email_title');
6776 $type='contact';
6777 $this->sendPushNotification($receiver_id,$message,$type,array($tid,$sender_id));
6778 /*Push Message Ends*/
6779
6780
6781 $userid = $this->input->post('user_id');
6782 $dealcode_number = $this->input->post('dealcode_number');
6783 $userrname = $this->input->post('username');
6784 $description = $this->input->post('message_text');
6785 $selleremail = $this->input->post('selleremail');
6786 $email = $this->input->post('useremail');
6787 $sent_mail=$this->user_model->get_all_details(USERS,array('email'=>$selleremail));//,'fav_shop'=>'Yes'));
6788 //echo '<pre>'; print_r($sent_mail->result());
6789
6790 $noty_email_arr=explode(',',$sent_mail->row()->notification_email);
6791 if(in_array('msg',$noty_email_arr)){
6792 $newsid='17';
6793 $template_values=$this->user_model->get_newsletter_template_details($newsid);
6794
6795 if($dealcode_number!=''){
6796 $dealcode_number = '<p><strong>Order Id :</strong>'.$dealcode_number.'</p>';
6797 $ClickDetails = 'Click <a href="'.base_url().'view-order/'.$userid.'/'.$dealcode_number.'">here</a> to see order details';
6798 }
6799
6800 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
6801 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo']);
6802 extract($adminnewstemplateArr);
6803 //$ddd =htmlentities($template_values['news_descrip'],null,'UTF-8');
6804 $header .="Content-Type: text/plain; charset=ISO-8859-1\r\n";
6805
6806 $message .= '<!DOCTYPE HTML>
6807 <html>
6808 <head>
6809 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6810 <meta name="viewport" content="width=device-width"/><body>';
6811 include('./newsletter/registeration'.$newsid.'.php');
6812
6813 $message .= '</body>
6814 </html>';
6815
6816 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
6817 $sender_email=$this->data['siteContactMail'];
6818 $sender_name=$this->data['siteTitle'];
6819 }else{
6820 $sender_name=$template_values['sender_name'];
6821 $sender_email=$template_values['sender_email'];
6822 }
6823
6824 $email_values = array('mail_type'=>'html',
6825 'from_mail_id'=>$sender_email,
6826 'mail_name'=>$sender_name,
6827 'to_mail_id'=>$selleremail,
6828 'subject_message'=>$template_values['news_subject'],
6829 'body_messages'=>$message
6830 );
6831 //echo '<pre>'; print_r($email_values); die;
6832 $email_send_to_common = $this->user_model->common_email_send($email_values);
6833 $contact_shop_owner=addslashes(shopsy_lg('lg_contact_shop_owner','Berhasil Mengirim Pesan.'));
6834
6835 $this->setErrorMessage('success',$contact_shop_owner);
6836 }
6837 if($dealcode_number!=''){
6838 redirect('purchase-review');
6839 }else{
6840 //echo $_SERVER['HTTP_REFERER'];die;
6841
6842 if (isset($_SERVER['HTTP_REFERER']))
6843 {
6844 redirect($_SERVER['HTTP_REFERER']);
6845 }else{
6846 redirect(base_url());
6847 }
6848 }
6849
6850 }
6851
6852 /** Ask Question @product-detail
6853 *
6854 * Product Detail Page Contact Shop Owner
6855 *
6856 */
6857 public function prddetailaskQues(){
6858 $tid=time();
6859 // print_r($this->input->post()); die;
6860 $dataArr = array('username'=>$this->input->post('username'),
6861 'useremail'=>$this->input->post('useremail'),
6862 'user_id'=>$this->input->post('userid'),
6863 'selleremail'=>$this->input->post('selleremail'),
6864 'sellerid'=>$this->input->post('sellerid'),
6865 'product_id'=>$this->input->post('productid'),
6866 'product_name'=>$this->input->post('productname'),
6867 'description'=>$this->input->post('message_text'));
6868 $this->user_model->simple_insert(CONTACTSELLER, $dataArr);
6869
6870 $dataArry = array('sender_email'=>$this->input->post('useremail'),
6871 'sender_id'=>$this->input->post('userid'),
6872 'receiver_email'=>$this->input->post('selleremail'),
6873 'receiver_id'=>$this->input->post('sellerid'),
6874 'subject'=>$this->input->post('subject'),
6875 'message'=>$this->input->post('message_text'),
6876 'dataAdded'=>date('Y-m-d H:i:s'),
6877 'tid'=>$tid);
6878 $this->user_model->simple_insert(CONTACTPEOPLE,$dataArry);
6879
6880
6881 $actArr = array('activity'=>"question",
6882 'activity_id'=>$this->input->post('sellerid'),
6883 'user_id' =>$this->input->post('userid'),
6884 'activity_ip'=>$this->input->ip_address(),
6885 'created'=>date("Y-m-d H:i:s"),
6886 'comment_id'=>$tid);
6887 $this->user_model->simple_insert(NOTIFICATIONS, $actArr);
6888
6889 $receiver_id=$this->input->post('sellerid');
6890 $sender_id=$this->input->post('userid');
6891 /*Push Message Starts*/
6892 $message='You received a message from '.$this->input->post('username').' on '.$this->config->item('email_title');
6893 $type='contact';
6894 $this->sendPushNotification($receiver_id,$message,$type,array($tid,$sender_id));
6895 /*Push Message Ends*/
6896
6897 $productName = $this->input->post('productname');
6898 $userrname = $this->input->post('username');
6899 $description = $this->input->post('message_text');
6900 $email = $this->input->post('selleremail');
6901
6902 $newsid='15';
6903 $template_values=$this->user_model->get_newsletter_template_details($newsid);
6904
6905 $subject = 'From: '.$this->config->item('email_title').' - '.$template_values['news_subject'];
6906 $adminnewstemplateArr=array('email_title'=> $this->config->item('email_title'),'logo'=> $this->data['logo']);
6907 extract($adminnewstemplateArr);
6908 //$ddd =htmlentities($template_values['news_descrip'],null,'UTF-8');
6909 $header .="Content-Type: text/plain; charset=ISO-8859-1\r\n";
6910
6911 $message .= '<!DOCTYPE HTML>
6912 <html>
6913 <head>
6914 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6915 <meta name="viewport" content="width=device-width"/><body>';
6916 include('./newsletter/registeration'.$newsid.'.php');
6917
6918 $message .= '</body>
6919 </html>';
6920
6921 if($template_values['sender_name']=='' && $template_values['sender_email']==''){
6922 $sender_email=$this->data['siteContactMail'];
6923 $sender_name=$this->data['siteTitle'];
6924 }else{
6925 $sender_name=$template_values['sender_name'];
6926 $sender_email=$template_values['sender_email'];
6927 }
6928
6929 $email_values = array('mail_type'=>'html',
6930 'from_mail_id'=>$sender_email,
6931 'mail_name'=>$sender_name,
6932 'to_mail_id'=>$email,
6933 'subject_message'=>$template_values['news_subject'],
6934 'body_messages'=>$message
6935 );
6936 //echo '<pre>'; print_r($email_values); die;
6937 $email_send_to_common = $this->user_model->common_email_send($email_values);
6938
6939
6940
6941 $this->setErrorMessage('success','Berhasil Mengirim.');
6942 redirect('products/'.$this->input->post('productseourl'));
6943
6944 }
6945
6946 /**
6947 *
6948 * Make the review box to get the review
6949 *
6950 */
6951 public function makeReviewBox(){
6952
6953 if($this->lang->line('write_review') != '') { $rew= stripslashes($this->lang->line('write_review')); } else $rew= "Write a Review";
6954
6955 if($this->lang->line('review_by') != '') { $rewby= stripslashes($this->lang->line('review_by')); } else $rewby= "Reviewed by";
6956
6957 if($this->lang->line('msg_txt') != '') { $msg= stripslashes($this->lang->line('msg_txt')); } else $msg= "Message text";
6958 if($this->lang->line('msg_title') != '') { $msg1= stripslashes($this->lang->line('msg_title')); } else $msg1= "Message title";
6959
6960 if($this->lang->line('post_review') != '') { $post_review= stripslashes($this->lang->line('post_review')); } else $post_review= "Post your Review";
6961
6962 if($this->lang->line('user_cancel') != '') { $user_cancel= stripslashes($this->lang->line('user_cancel')); } else $user_cancel= "Cancel";
6963
6964 $userId = $this->input->post('userId');
6965 $product_id = $this->input->post('product_id');
6966 //print_r($product_id);die;
6967 $dealCode = $this->input->post('dealCode');
6968 $review = $this->user_model->get_all_details(PRODUCT_FEEDBACK, array('voter_id'=>$userId,'seller_product_id'=>$product_id,'deal_code'=>$dealCode))->row();
6969 $review_status = $this->user_model->get_all_details(PRODUCT_FEEDBACK, array('voter_id' => $userId, 'seller_product_id' => $product_id, 'deal_code'=>$dealCode));
6970 $UserVal = $this->user_model->get_all_details(USERS,array('id' => $userId));
6971 $ProdVal = $this->user_model->get_all_details(PRODUCT,array('id' => $product_id));
6972
6973
6974 if($UserVal->row()->thumbnail !=''){
6975 $revByImg = 'images/users/'.$UserVal->row()->thumbnail;
6976 }else{
6977 $revByImg = 'images/default_avat.png';
6978 }
6979
6980 if($ProdVal->row()->image !=''){
6981 $img=explode(',',$ProdVal->row()->image);
6982 $prdImg = 'images/product/thumb/'.$img[0];
6983 }else{
6984 $prdImg = 'images/dummyProductImage.jpg';
6985 }
6986
6987 if($review_status->num_rows == 0){
6988 $popupVal='
6989 <div style="background:#EAF7FD; margin:0px" class="sign_in_form">
6990 <form action="'.base_url().'site/user/feedback" method="post" onSubmit="return rattingValidation();" >
6991 <input type="hidden" value="" name="mode" />
6992 <div style="border:none;" class="sign_in_form-inner">
6993 <div style="float:left; width:93%;" class="sign_head">
6994 <div class="sign_text">
6995 <h2>'.$rew.'</h2>
6996 </div>
6997 </div>
6998 <div style="float:left; width:100%; background:#FFF;" class="sign-in-middle">
6999 <div style="float:left; width:20%" class="sign-in-middle-left">
7000
7001 <img style="height:60px ; margin: 21px 0 0 20px; width:60px" src="'.base_url().$prdImg.'" />
7002 </div>
7003 <div style="float:left; width:69%; padding:20px 0 0 0" class="sign-in-middle-right">
7004 <h3>'.$ProdVal->row()->product_name.'</h3>
7005 <!--<img src="'.base_url().'images/starrating.png" />-->
7006 <input type="radio" id="1" value="1" name="rating" style="display:none;">
7007 <label for="1" onClick="ratting_star(1)" class="star-active" id="r1"></label>
7008 <input type="radio" id="2" value="3" name="rating" style="display:none;">
7009 <label for="2" onClick="ratting_star(2)" class="star-active" id="r2"></label>
7010 <input type="radio" id="3" value="3" name="rating" style="display:none;">
7011 <label for="3" onClick="ratting_star(3)" class="star-active" id="r3"></label>
7012 <input type="radio" id="4" value="4" name="rating" style="display:none;">
7013 <label for="4" onClick="ratting_star(4)" class="star-active" id="r4"></label>
7014 <input type="radio" id="5" value="5" name="rating" style="display:none;" checked="checked">
7015 <label for="5" onclick="ratting_star(5)" class="star-active" id="r5"></label>
7016 <input type="hidden" value="'.$dealCode.'" name="deal_code" />
7017 <input type="hidden" value="'.$ProdVal->row()->id.'" name="product_id" />
7018 <input type="hidden" value="'.$ProdVal->row()->user_id.'" name="shop_id" />
7019 <input type="hidden" value="'.$UserVal->row()->id.'" name="user_id" />
7020 <br><input type="text" name="title" placeholder="'.$msg1.'">
7021 <textarea style="width:382px; margin:10px 0;" class="conversation-textarea" placeholder="'.$msg.'" name="description" rows="8" id="description"></textarea>
7022 <span id="descriptionErr" style="color:red;"></span><br>
7023 <img style="border-radius:60px; height:30px; width:30px" src="'.base_url().$revByImg.'" />
7024 <span style="color:#999; margin:0 3px 0 0">'.$rewby.'</span>
7025 <a href="'.base_url().'view-people/'.$UserVal->row()->user_name.'">'.ucfirst($UserVal->row()->full_name).'</a>
7026 </div>
7027 </div>
7028 </div>
7029 <div style="float:left; width:100%; border-top:1px solid #77B3CD; " class="popup-page-footer">
7030 <div class="popup_login" style="margin-bottom: 15px; margin-right: 15px; float: right; width: auto;">
7031 <input style="margin:0 10px 0 0" class="submit_btn" type="submit" value="'.$post_review.'">
7032 <input class="submit_btn" type="button" value="'.$user_cancel.'" onClick="javascript:$.colorbox.close();window.location.reload();">
7033 </div>
7034 </div>
7035 </form>
7036 </div>';
7037 }else{
7038 $ratting_value=round($review->rating);
7039 $RTT='';
7040 for($i=1;$i<=5;$i++){
7041 if($i<=$ratting_value){
7042 $RTT.='<input type="radio" id="'.$i.'" value="'.$i.'" name="rating" style="display:none;"';
7043 if($i==$ratting_value){
7044 $RTT.=' checked="checked"';
7045 }
7046 $RTT.='>
7047 <label for="'.$i.'" class="star-active" id="r'.$i.'"></label>';
7048 }else{
7049 $RTT.='<input type="radio" id="'.$i.'" value="'.$i.'" name="rating" style="display:none;">
7050 <label for="'.$i.'" class="star-inactive" id="r'.$i.'"></label>';
7051 }
7052 }
7053 $popupVal='
7054 <div style="background:#EAF7FD; margin:0px" class="sign_in_form">
7055 <form action="'.base_url().'site/user/feedback" method="post" onSubmit="return rattingValidation();" >
7056 <input type="hidden" value="'.$review->id.'" name="mode" />
7057 <div style="border:none;" class="sign_in_form-inner">
7058 <div style="float:left; width:93%;" class="sign_head">
7059 <div class="sign_text">
7060 <h2>View Your Review</h2>
7061 </div>
7062 </div>
7063 <div style="float:left; width:100%; background:#FFF;" class="sign-in-middle">
7064 <div style="float:left; width:20%" class="sign-in-middle-left">
7065
7066 <img style="height:60px ; margin: 21px 0 0 20px; width:60px" src="'.base_url().$prdImg.'" />
7067 </div>
7068 <div style="float:left; width:69%; padding:20px 0 0 0" class="sign-in-middle-right">
7069 <h3>'.$ProdVal->row()->product_name.'</h3>
7070 <!--<img src="'.base_url().'images/starrating.png" />-->
7071 '.$RTT.'
7072 <input type="hidden" value="'.$dealCode.'" name="deal_code" />
7073 <input type="hidden" value="'.$ProdVal->row()->id.'" name="product_id" />
7074 <input type="hidden" value="'.$ProdVal->row()->user_id.'" name="shop_id" />
7075 <input type="hidden" value="'.$UserVal->row()->id.'" name="user_id" />
7076 <input type="hidden" value="'.$UserVal->row()->rating.'" name="old_rating" />
7077 <input type="hidden" value="'.$review->description.'" name="old_msg"/>
7078 <br><br><input type="text" name="title" readonly value="'.$review->title.'" placeholder="'.$msg1.'">
7079 <textarea style="width:382px; margin:10px 0;" readonly class="conversation-textarea" placeholder="Message text" name="description" rows="8" id="description">'.$review->description.'</textarea>
7080 <span id="descriptionErr" style="color:red;"></span><br>
7081 <img style="border-radius:60px; height:30px; width:30px" src="'.base_url().$revByImg.'" />
7082 <span style="color:#999; margin:0 3px 0 0">Reviewd by</span>
7083 <a href="'.base_url().'view-order/'.$UserVal->row()->id.'">'.ucfirst($UserVal->row()->full_name).'</a>
7084 </div>
7085 </div>
7086 </div>
7087 <div style="float:left; width:100%; border-top:1px solid #77B3CD; " class="popup-page-footer">
7088 <div class="popup_login" style="margin-bottom: 15px; margin-right: 15px; float: right; width: auto;">
7089 <input class="submit_btn" type="button" value="Ok" onClick="javascript:$(\'#cboxClose\').trigger(\'click\');">
7090 </div>
7091 </div>
7092 </form>
7093 </div>';
7094 }
7095 echo $popupVal;
7096 return;
7097 }
7098
7099 /**
7100 *
7101 * To view the user activity
7102 *
7103 */
7104 public function activity(){
7105
7106
7107 if ($this->checkLogin('U')!=''){
7108 $this->data['currUser']=$checkloginIDarr=$this->session->all_userdata();
7109 $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
7110
7111 $newdata = array(
7112 'last_activity_visit' => time()
7113 );
7114 $condition = array('id' => $loggeduserID);
7115 $this->user_model->update_details(USERS,$newdata,$condition);
7116 /*
7117 $newArr = array(
7118 'view_action' => 'Seen'
7119 );
7120 $cond = array('user_id' => $loggeduserID);
7121 $this->user_model->update_details(USER_ACTIVITY,$newArr,$cond);
7122 */
7123
7124
7125 /*Get the user details*/
7126 $this->data['userProfileDetails']=$userProfileDetails= $this->user_model->get_all_details(USERS,array('id'=>$loggeduserID))->result_array();
7127 $userList=explode(',',$userProfileDetails[0]['following']);
7128 $userList[0]=$loggeduserID;$condition='';
7129 foreach($userList as $userIds){
7130 /*$this->data['userDetails']->$userIds=$userDetails->$userIds= $this->user_model->get_all_details(USER,array('id'=>$userIds))->result();
7131 $this->data['userActivity'][$userIds]=$userActivity[$userIds]= $this->user_model->get_all_details(USER_ACTIVITY,array('user_id'=>$userIds),array('field'=>'activity_time','type'=>'desc'))->result_array();*/
7132 $condition.="ua.user_id = ".$userIds." or ";
7133 }
7134 $len=strlen($condition);
7135 $condition=substr($condition,0,$len-4);
7136 $this->data['userActivity']=$userActivity= $this->user_model->get_activity($condition)->result_array();
7137 $this->data['heading'] = $this->config->item('email_title').'-Your Activity';
7138 /*get my shop products*/
7139 $myshopproductArr= $this->user_model->get_all_details(PRODUCT,array('user_id'=>$loggeduserID))->result_array();
7140 $prd='';
7141 foreach($myshopproductArr as $prdId){
7142 $prd.=$prdId['id'].',';
7143 }
7144 /*My Shop Activity*/
7145 $condition="ua.activity_id =".$loggeduserID." or FIND_IN_SET(ua.activity_id,'".rtrim($prd,',')."')";
7146 $this->data['myshopactivity']=$myshopactivity= $this->user_model->get_myshopactivity($condition)->result_array();
7147
7148 #print_r($userProfileDetails);
7149 $followersArr=explode(',',ltrim($userProfileDetails[0]['followers'],','));
7150 #print_r($followersArr);
7151 foreach($followersArr as $followersList){
7152 $this->data['userfollowersDetails'][$followersList]=$userfollowersDetails[$followersList]= $this->user_model->get_all_details(USERS,array('id'=>$followersList))->row();
7153 }
7154
7155 $this->data['heading'] = $this->config->item('email_title').'-Your Shop Activity';
7156 $this->load->view('site/user/activity',$this->data);
7157 }else{
7158 redirect('login');
7159 }
7160 }
7161
7162 /**
7163 *
7164 * To view the user interaction
7165 *
7166 */
7167 public function activity_interaction(){
7168 if ($this->checkLogin('U')!=''){
7169 $this->data['currUser']=$checkloginIDarr=$this->session->all_userdata();
7170 $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
7171 /*Get the user details*/
7172 $this->data['userProfileDetails']=$userProfileDetails= $this->user_model->get_all_details(USERS,array('id'=>$loggeduserID))->result_array();
7173 #print_r($userProfileDetails);
7174 $followersArr=explode(',',ltrim($userProfileDetails[0]['followers'],','));
7175 #print_r($followersArr);
7176 foreach($followersArr as $followersList){
7177 $this->data['userfollowersDetails'][$followersList]=$userfollowersDetails[$followersList]= $this->user_model->get_all_details(USERS,array('id'=>$followersList))->row();
7178 }
7179 #echo "<pre>";print_r($this->data['userfollowersDetails'][$followersList]);die;
7180 $this->data['heading'] = $this->config->item('email_title').'-Your Activity';
7181 $this->load->view('site/user/activity_interaction',$this->data);
7182 }else{
7183 redirect('login');
7184 }
7185 }
7186
7187 /**
7188 *
7189 * To view the shop activity for user
7190 *
7191 */
7192 public function activity_shop(){
7193 if ($this->checkLogin('U')!=''){
7194 $this->data['currUser']=$checkloginIDarr=$this->session->all_userdata();
7195 $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
7196 /*Get the user details*/
7197 $this->data['userProfileDetails']=$userProfileDetails= $this->user_model->get_all_details(USERS,array('id'=>$loggeduserID))->result_array();
7198 /*get my shop products*/
7199 $myshopproductArr= $this->user_model->get_all_details(PRODUCT,array('user_id'=>$loggeduserID))->result_array();
7200 $prd='';
7201 foreach($myshopproductArr as $prdId){
7202 $prd.=$prdId['id'].',';
7203 }
7204 /*My Shop Activity*/
7205 $condition="ua.activity_id =".$loggeduserID." or FIND_IN_SET(ua.activity_id,'".rtrim($prd,',')."')";
7206 $this->data['myshopactivity']=$myshopactivity= $this->user_model->get_myshopactivity($condition)->result_array();
7207
7208 $this->data['heading'] = $this->config->item('email_title').'-Your Shop Activity';
7209 $this->load->view('site/user/activity',$this->data);
7210 }else{
7211 redirect('login');
7212 }
7213 }
7214
7215 /**
7216 *
7217 * to view the category list
7218 *
7219 */
7220 public function category(){
7221 $this->data['MainCategoriesLists'] = $this->user_model->get_all_details(CATEGORY,array('rootID'=>'0','status'=>'Active'),array(array('field'=>'cat_name','type'=>'asc')));
7222 $this->data['heading'] =$this->config->item('email_title').' - Browse Shopping Categories';
7223 $this->load->view('site/list/category',$this->data);
7224 }
7225
7226
7227 /**
7228 *
7229 * Contact People to view the list
7230 *
7231 */
7232 public function contactpeople()
7233 {
7234 $tid=$this->input->post('tid');
7235
7236 $dataArr = array('sender_email'=>$this->input->post('sender_email'),
7237 'sender_id'=>$this->input->post('sender_id'),
7238 'receiver_email'=>$this->input->post('receiver_email'),
7239 'receiver_id'=>$this->input->post('receiver_id'),
7240 'subject'=>$this->input->post('subject'),
7241 'message'=>$this->input->post('message_text'),
7242 'dataAdded'=>date('Y-m-d H:i:s'),'tid'=>$tid);
7243 $this->user_model->simple_insert(CONTACTPEOPLE,$dataArr);
7244
7245 // Send message for new version @API
7246 $this->send_message_new_version($dataArr['sender_id'], $dataArr['receiver_id'], $dataArr['message']);
7247
7248 $actArr = array('activity'=>"message",
7249 'activity_id'=>$this->input->post('receiver_id'),
7250 'user_id' =>$this->input->post('sender_id'),
7251 'activity_ip'=>$this->input->ip_address(),
7252 'created'=>date("Y-m-d H:i:s"),
7253 'comment_id'=>$tid,
7254 'view_mode'=>'Yes');
7255
7256 $this->user_model->simple_insert(NOTIFICATIONS,$actArr);
7257 // echo $this->db->last_query();die;
7258
7259 $receiver_id=$this->input->post('receiver_id');
7260 $sender_id=$this->input->post('sender_id');
7261 /*Push Message Starts*/
7262 $message='You received a message from '.$this->input->post('current_user').' on '.$this->config->item('email_title');
7263 $type='message';
7264 // $this->sendPushNotification($receiver_id,$message,$type,array($tid,$sender_id));
7265 /*Push Message Ends*/
7266
7267 //echo $this->input->post('FromURL'); die;
7268 $this->setErrorMessage('success','Message Sent Successfully.');
7269
7270 if($this->input->post('FromURL')=='ContactUser'){
7271 redirect('shops/'.$this->input->post('current_user').'/contact-user');
7272 }
7273 if($this->input->post('FromURL')=='Conversation'){
7274 redirect($this->input->post('current_user').'/inbox/all/'.$tid);
7275 }
7276 redirect('view-people/'.$this->input->post('current_user'));
7277
7278 }
7279
7280 /**
7281 *
7282 * Send message for new version
7283 *
7284 */
7285 private function send_message_new_version($sender_id, $partner_id, $message)
7286 {
7287 $sender_data = $this->message_model_api->get_all_details(USERS, ['id'=>$sender_id])->row();
7288 $user_id = $sender_data->id;
7289 // $user_id = 164;
7290
7291 $user_partner = $this->message_model_api->get_all_details(USERS, ['id'=>$partner_id]);
7292 if($user_partner->num_rows() == 0)
7293 $this->returnValues('Tidak ada data partner.');
7294
7295 $input_data['message'] = $message;
7296 $input_data['partner']['user_id'] = $partner_id;
7297 $input_data['partner']['as_seller'] = false;
7298
7299 // DUMP INPUT DATA TO FILE
7300 // $text = $input_data;
7301 // file_put_contents('filename.php', print_r($text, true));
7302
7303 /*if(!isset($input_data['partner']['user_id']) && !isset($input_data['partner']['seller_id'])){
7304 $this->returnValues('Partner is required');
7305 }*/
7306
7307 /*if((is_null($input_data['partner']['user_id']) || $input_data['partner']['user_id'] == '')
7308 && (is_null($input_data['partner']['seller_id']) || $input_data['partner']['seller_id'] == '')){
7309 $this->returnValues('Partner is required');
7310 }*/
7311
7312 /*if(is_null($input_data['partner']['user_id']))
7313 $this->returnValues('Partner User ID is required');*/
7314
7315 // if(!is_null($input_data['partner']['user_id'])
7316 // && (is_null($input_data['partner']['seller_id']) || $input_data['partner']['seller_id'] == '')
7317 // && $input_data['partner']['as_seller'] == true){
7318 // $this->returnValues('Seller ID is required.');
7319 // }
7320
7321
7322 $input_data['product_id'] = NULL;
7323 if(isset($input_data['product_attachment']) && $input_data['product_attachment']['id'] > 0)
7324 $input_data['product_id'] = $input_data['product_attachment']['id'];
7325
7326 // print_r($validator->messages());die;
7327 /*if($validator_data->fails())
7328 $this->returnValues('Terjadi kesalahan input.', false, $validator_data->raw());*/
7329
7330 $is_seller = false;
7331 if($input_data['partner']['as_seller'] == false || $input_data['partner']['as_seller'] == 0 ){
7332 $is_seller = true;
7333 }
7334
7335 $dataToInsert['owner_id'] = $user_id;
7336 $dataToInsert['partner_id'] = $partner_id;
7337 $dataToInsert['message'] = $input_data['message'];
7338 $dataToInsert['link_attachment'] = NULL; //$input_data['link_attachment'];
7339 $dataToInsert['product_id'] = NULL;
7340 $dataToInsert['is_sender'] = 1;
7341 $dataToInsert['is_seller'] = $is_seller;
7342 $dataToInsert['created_at'] = date('Y-m-d H:i:s', now());
7343 // print_r($dataToInsert);die;
7344
7345 $this->message_model_api->simple_insert('shopsy_conversations', $dataToInsert);
7346 $last_message_id = $this->message_model_api->get_last_insert_id();
7347 // echo "$last_message_id";die;
7348
7349 $new_message_data = $this->message_model_api->getMessageDetail($last_message_id);
7350 $new_message = $new_message_data->row();
7351
7352 $newDataToInsert['owner_id'] = $new_message->partner_id;
7353 $newDataToInsert['partner_id'] = $new_message->owner_id;
7354 $newDataToInsert['message'] = $new_message->message;
7355 $newDataToInsert['link_attachment'] = $new_message->link_attachment;
7356 $newDataToInsert['product_id'] = $new_message->product_id;
7357 $newDataToInsert['is_sender'] = 0;
7358 $newDataToInsert['is_seller'] = $new_message->is_seller == 1 ? 0 : 1;
7359 $newDataToInsert['created_at'] = $new_message->created_at;
7360 // print_r($dataToInsert);die;
7361
7362 $this->message_model_api->simple_insert('shopsy_conversations', $newDataToInsert);
7363
7364 if(!is_null($user_partner->row()->device_token))
7365 {
7366 // echo $new_message->id;die;
7367 $partner_id = $new_message->owner_id;
7368 $is_sender = true;
7369 $user = $this->user_model_api->get_all_details(USERS, ['id'=>$partner_id])->row();
7370 $user_info = [
7371 'id'=>$user->id,
7372 'first_name'=>$user->full_name,
7373 'last_name'=>$user->last_name,
7374 "photo" => ($user->thumbnail !== '') ? base_url().USERIMAGEPATH.'thumb/'.$user->thumbnail : base_url().USERIMAGEPATH.'profile_pic.png',
7375 ];
7376 $seller_info = NULL;
7377 $seller_data = $this->user_model_api->get_all_details(SELLER, ['seller_id'=>$partner_id]);
7378 if($seller_data->num_rows() > 0){
7379 $seller_info = [
7380 'id'=> $seller_data->row()->id,
7381 'shop_name'=> $seller_data->row()->seller_businessname,
7382 'store_image'=> ($user->thumbnail !== '') ? base_url().USERIMAGEPATH.'thumb/'.$user->thumbnail : base_url().USERIMAGEPATH.'profile_pic.png',
7383 ];
7384 }
7385
7386 $is_seller = false;
7387 /*if($new_message->is_seller == 1){
7388
7389 if($seller_data->num_rows() > 0){
7390 $is_seller = true;
7391
7392 }
7393 }*/
7394
7395
7396 $partner = [
7397 'user_id'=>$user->id,
7398 'user'=>$user_info,
7399 'seller'=>$seller_info,
7400 'as_seller'=>$is_seller,
7401 'is_sender'=>$new_message->is_sender == 1 ? true : false,
7402 ];
7403
7404 /*if(is_null($seller_info)){
7405 unset($partner['seller']);
7406 }else{
7407 unset($partner['user']);
7408 }*/
7409
7410 $product_attachment = NULL;
7411 if(!is_null($new_message->product_id) && $new_message->product_id !=''){
7412 $product = $this->user_model_api->get_all_details(PRODUCT_EN, ['id'=>$new_message->product_id])->row();
7413 $imageThumb = explode(',', $product->image);
7414 $product_attachment = [
7415 'id'=>$product->id,
7416 'name'=>$product->product_name,
7417 'image'=> PRODUCTPATH.$imageThumb[0]
7418 ];
7419 }
7420
7421 $fitMessage['id'] = $new_message->id;
7422 $fitMessage['message'] = $new_message->message;
7423 $fitMessage['link_attachment'] = $new_message->link_attachment;
7424 $fitMessage['product_attachment'] = $product_attachment;
7425 $fitMessage['partner'] = $partner;
7426 $fitMessage['created_at'] = $new_message->created_at;
7427
7428 $notif_data = [
7429 'device_token' => $user_partner->row()->device_token,
7430 'title' => $sender_data->full_name.' '.$sender_data->last_name,
7431 'message' => $new_message->message,
7432 'data' => [
7433 'type'=> 'chat',
7434 'object_id'=> $last_message_id,
7435 'detail'=> (string) json_encode($fitMessage),
7436 // 'detail'=> $fitMessage,
7437 ]
7438 ];
7439
7440 $notif_result = json_decode(sendNotificationFCM($notif_data));
7441 // print_r($notif_result);die;
7442 }
7443
7444 // return $this->conversation_detail($user_partner->row()->id);
7445 // return $this->message_detail($last_message_id);
7446
7447
7448 }
7449
7450 /**
7451 *
7452 * Manage the registry product from the user
7453 *
7454 */
7455 public function user_manageRegistryProduct(){
7456 if ($this->checkLogin('U')!=''){
7457 $userId=$this->input->post('userId');
7458 $prodId=$this->input->post('prodId');
7459
7460 $registryProduct = $this->user_model->get_all_details(REGISTRY_LISTINGS,array('collection_id'=>$userId,'listing_id'=>$prodId))->result_array();
7461 if(empty($registryProduct)){
7462 $dataArr = array('collection_id'=>$userId,'listing_id'=>$prodId);
7463 $this->user_model->simple_insert(REGISTRY_LISTINGS,$dataArr);
7464
7465 $registryProduct1 = $this->user_model->get_all_details(REGISTRY_REQUEST,array('collection_id'=>$userId,'listing_id'=>$prodId));
7466 if($registryProduct1->num_rows()>0)
7467 {
7468 //$Sql="update shopsy_registry_requests set requested=requested+1 where collection_id='".$userId."' and listing_id='".$prodId."'";
7469 //$result=$this->category_model->ExecuteQuery($Sql);
7470 //$count1=$result->num_rows();
7471
7472 $newCnt = int($registryProduct1->row()->requested) + 1;
7473
7474 $dataArr1 = array('requested'=>$newCnt);
7475 $condition1 = array('collection_id' => $userId, 'listing_id'=> $prodId);
7476 $this->user_model->update_details(REGISTRY_REQUEST,$dataArr1,$condition1);
7477
7478
7479 }
7480 else
7481 {
7482 //$Sql="insert into shopsy_registry_requests(collection_id,listing_id) values('".$userId."','".$prodId."')";
7483 //$result=$this->category_model->ExecuteQuery($Sql);
7484
7485 $dataArr2 = array('collection_id' => $userId, 'listing_id'=> $prodId);
7486 $this->user_model->simple_insert(REGISTRY_REQUEST,$dataArr2);
7487
7488
7489
7490 }
7491
7492 }else{
7493 $this->user_model->commonDelete(REGISTRY_LISTINGS,array('collection_id'=>$userId,'listing_id'=>$prodId));
7494 $this->user_model->commonDelete(REGISTRY_REQUEST,array('collection_id'=>$userId,'listing_id'=>$prodId));
7495 }
7496 $ur_reg_updated=addslashes(shopsy_lg('lg_ur_reg_updated','Your Registry has been updated'));
7497
7498 $this->setErrorMessage('success',$ur_reg_updated);
7499 }
7500 }
7501
7502 /**
7503 *
7504 * To change the language
7505 *
7506 */
7507 public function language_change(){
7508 $language_code= $this->uri->segment('2');
7509 $selectedLangCode = $this->session->set_userdata('language_code',$language_code);
7510 redirect('');
7511 }
7512
7513
7514 /**
7515 *
7516 * To display the conversations
7517 *
7518 */
7519 public function display_conversations(){
7520 #echo "<pre>";print_r($this->input->post());die;
7521 if ($this->checkLogin('U')!='')
7522 {
7523 $this->data['heading'] =$this->config->item('email_title').' - Conversation';
7524
7525 if(isset($_GET['qv']))
7526 {
7527 $typev= $_GET['qv'];
7528 }
7529 else
7530 {
7531 $typev= 'all';
7532 }
7533
7534 #echo $this->db->last_query();die;
7535 $typev= 'all';
7536 $this->data['viewfolder'] =$typev;
7537 #$this->data['conversations'] = $this->user_model->get_conversation_details($this->checkLogin('U'),$typev);
7538 $this->data['conversations'] = $this->user_model->get_conversation_list($this->checkLogin('U'),$typev);
7539 // echo $this->db->last_query();die;
7540 #echo "<pre>"; print_r($this->data['conversations']->result()); die;
7541 $this->load->view('site/user/conversation',$this->data);
7542 }
7543 else
7544 {
7545 $this->setErrorMessage('error','Login Required');
7546 redirect('login');
7547 }
7548 }
7549
7550 /**
7551 *
7552 * To display the view messages
7553 *
7554 */
7555 public function view_message(){
7556
7557 if ($this->checkLogin('U')!='')
7558 {
7559 $msgid = '';
7560 if($this->uri->segment(4,0))
7561 {
7562 $msgid= $this->uri->segment(4,0);
7563 }
7564 $this->data['viewfolder'] =$this->uri->segment(3,0);
7565 $this->data['heading'] =$this->config->item('email_title').' - Conversation';
7566 if(isset($_GET['qv']))
7567 {
7568 $typev= $_GET['qv'];
7569 }
7570 else
7571 {
7572 $typev= 'all';
7573 }
7574
7575 #echo $this->db->last_query();die;
7576 $typev= 'all';
7577 $this->data['viewfolder'] =$typev;
7578 #$this->data['conversations'] = $this->user_model->get_conversation_details($this->checkLogin('U'),$typev);
7579 $this->data['conversations'] = $this->user_model->get_conversation_list($this->checkLogin('U'),$typev);
7580 #echo "<pre>"; print_r($this->data['conversations']->result()); die;
7581 $this->data['MessageDetail'] = $this->user_model->get_full_message_details($msgid);
7582 // echo $this->db->last_query();die;
7583 // $this->product_model->ExecuteQuery("UPDATE ".NOTIFICATIONS." SET `view_mode` = 'No' WHERE comment_id=".$msgid." AND (activity='favorite item' OR activity='unfavorite item' OR activity='message' OR activity='question')");
7584
7585 if($this->data['MessageDetail']->num_rows()<=0){
7586 $this->setErrorMessage('error','sorry! this conversation is not available.');
7587 redirect($this->uri->segment(2).'/inbox');
7588 }
7589
7590 /* update notification*/
7591 $dataArrw = array('view_count'=>$this->data['preview_item_detail'][0]['view_count']+1);
7592 $conditionw = array('seourl'=>$seourl);
7593 $this->product_model->update_details(PRODUCT,$dataArrw,$conditionw);
7594 if($this->checkLogin('U')!=""){
7595 $activity_id=$this->checkLogin('U');
7596 $this->product_model->ExecuteQuery("UPDATE ".NOTIFICATIONS." SET `view_mode` = 'No' WHERE activity_id=".$activity_id." AND (activity='message' OR activity='question') AND comment_id=".$msgid."");
7597 }
7598
7599 foreach($this->data['MessageDetail']->result() as $row){
7600 if($row->sender_id==$this->checkLogin('U')){
7601 $newdata=array('sender_status'=>'Read');
7602 $condition = array('id' => $row->id,'receiver_status !='=>'Trash');
7603 }else if($row->receiver_id==$this->checkLogin('U')){
7604 $newdata=array('receiver_status'=>'Read');
7605 $condition = array('id' => $row->id,'receiver_status !='=>'Trash');
7606 }
7607 $this->product_model->update_details(CONTACTPEOPLE,$newdata,$condition);
7608 //echo $this->db->last_query(); die;
7609 }
7610
7611 $this->data['heading'] =$this->config->item('email_title').' - Conversation';
7612 $this->load->view('site/user/view_conversation',$this->data);
7613 }else{
7614 $this->setErrorMessage('error','Login Required');
7615 redirect('login');
7616 }
7617 }
7618
7619 /**
7620 *
7621 * To upload teh ajax conversions
7622 *
7623 */
7624 public function ajax_conversation_action(){
7625 $MsgId=$this->input->post('MsgId');
7626 $UsrId=$this->input->post('UsrId');
7627 $folder=$this->input->post('folder');
7628 $actionTake=$this->input->post('actionTake');
7629 $chkMsgArr=@explode('|',rtrim($MsgId,'|'));
7630 $chgId='';
7631 foreach($chkMsgArr as $MsgId){
7632 $msgDetail = $this->user_model->get_all_details(CONTACTPEOPLE,array('id'=>$MsgId));
7633 // echo $this->db->last_query();die;
7634 if($msgDetail->row()->sender_id==$UsrId){
7635 $colstatus='sender_status';
7636 }else if($msgDetail->row()->receiver_id==$UsrId){
7637 $colstatus='receiver_status';
7638 }
7639 $actionTake='Trash';
7640 $newdata=array($colstatus=>$actionTake);
7641 $condition = array('tid' => $msgDetail->row()->tid);
7642 // $condition = '(sender_id='.$msgDetail->row()->sender_id.' AND receiver_id ='.$msgDetail->row()->receiver_id.')
7643 // OR(sender_id='.$msgDetail->row()->receiver_id.' AND receiver_id='.$msgDetail->row()->sender_id.')';
7644 if($this->user_model->update_details(CONTACTPEOPLE,$newdata,$condition)){
7645 $chgId=$chgId.$MsgId.'|';
7646 }
7647 // echo $this->db->last_query();die;
7648 }
7649 echo rtrim($chgId,'|');
7650 }
7651
7652 /**
7653 *
7654 * To add the ajax activity
7655 *
7656 */
7657 public function ajax_activity(){
7658 if ($this->checkLogin('U')!=''){
7659 $this->data['currUser']=$checkloginIDarr=$this->session->all_userdata();
7660 $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
7661 $datestring = "%Y-%m-%d %H:%i:%s";
7662 $time = time();
7663 $newdata = array(
7664 'last_activity_visit' => time()
7665 );
7666 $condition = array('id' => $loggeduserID);
7667 $this->user_model->update_details(USERS,$newdata,$condition);
7668 $this->data['userProfileDetails']=$userProfileDetails= $this->user_model->get_all_details(USERS,array('id'=>$loggeduserID))->result_array();
7669 $userList=explode(',',$userProfileDetails[0]['following']);
7670 $userList[0]=$loggeduserID;$condition='';
7671 foreach($userList as $userIds){
7672 $condition.="ua.user_id = ".$userIds." or ";
7673 }
7674 $len=strlen($condition);
7675 $condition=substr($condition,0,$len-4);
7676 $offset = is_numeric($_POST['offset']) ? $_POST['offset'] : die();
7677 $postnumbers = is_numeric($_POST['number']) ? $_POST['number'] : die();
7678 $this->data['userActivity']=$userActivity= $this->user_model->get_activity($condition,$postnumbers,$offset)->result_array();
7679 $this->data['heading'] = $this->config->item('email_title').'-Your Activity';
7680 $loginCheck = $this->checkLogin('U');
7681 if(!empty($userActivity)){
7682 //$content ='<ul id="activity-list">';
7683 $content ='';
7684 $hover=0; $s=0;$l=1;
7685 foreach($userActivity as $actFav){
7686 if($s<3 && $l<4){ $cls="small"; $s++; } else if($s>2 && $l<4){ $cls="large"; $l++;} else {$s=0;$l=1;}
7687
7688 $userProfileDetails= $this->user_model->get_all_details(USERS,array('id'=>$actFav['user_id']))->result_array();
7689 if($actFav['activity_name']=='Unfavorite item' || $actFav['activity_name']=='favorite item') {
7690 $hover++;
7691 $productDetail = $this->user_model->get_all_details(PRODUCT,array('id'=>$actFav['activity_id']))->row();
7692 $imgArr=explode(',',$productDetail->image);
7693 $content .='<li class="activity small-wid '.$cls.'">
7694 <div class="activity-desc">
7695 <div class="activity-avatar trigger-action-toolbox" data-source="hp_tastemaker">
7696 <a href="view-profile/'.$userProfileDetails[0]['user_name'].'" >';
7697 if($userProfileDetails[0]['thumbnail']!=''){ $profile_pic='users/thumb/'.$userProfileDetails[0]['thumbnail']; } else { $profile_pic='default_avat.png';}
7698 $content .='<img width="75" height="75" src="images/'.$profile_pic.'">
7699 </a>
7700 </div>
7701 <p class="activity-name">';
7702 if($userProfileDetails[0]['id']!=$loginCheck){ $content .= $userProfileDetails[0]['user_name']; } else { $content .= 'You';}
7703 $content .=' ';
7704 if($this->lang->line('favorited') != '') { $content .= stripslashes($this->lang->line('favorited')); } else {$content .= "favorited";}
7705 $content .=' ';
7706 $content .='<a class="member-name" href="products/'.$productDetail->seourl.'">';
7707 if($this->lang->line('user_thisitem') != '') { $content .=stripslashes($this->lang->line('user_thisitem')); } else $content .='"this item"';
7708 $content .='..</a>';
7709 $content .='</p>
7710 </div>
7711 <div class="activity-favorites full-wid">
7712 <a href="products/'.$productDetail->seourl.'" class="activity-full">
7713 <img alt="'.$productDetail->product_name.'" src="images/product/'.$imgArr[0].'">
7714 </a>
7715 </div>
7716 <div class="story-info clear">
7717 <div class="product-dtl">'.$productDetail->product_name.'</div>
7718 <div class="product_fv">';
7719 if($loginCheck !=''){
7720 if($productDetail->user_id==$loginCheck){
7721 $prod_list.='<a href="javascript:void(0);" onclick="return ownProductFav();">
7722 <input type="submit" value="" class="hoverfav_icon" />
7723 </a>';
7724 }else{
7725 $favArr = $this->product_model->getUserFavoriteProductDetails($productDetail->id);
7726 if(empty($favArr)){
7727 $content .='<a href="javascript:void(0);" onClick="return changeProductToFavourite(\''.$productDetail->id.'\',\'Fresh\');">
7728 <input type="submit" value="" class="hoverfav_icon" />
7729 </a>';
7730 } else {
7731 $content .='<a href="javascript:void(0);" onClick="return changeProductToFavourite(\''.$productDetail->id.'\',\'Old\');">
7732 <input type="submit" value="" class="hoverfav_icon1" />
7733 </a>';
7734 }}} else {
7735 $content .='<a href="login" class="reg-popup" >
7736 <input type="submit" value="" class="hoverfav_icon" />
7737 </a>';
7738 }
7739 $content .='<div class="hoverdrop2_icon">
7740 <a href="javascript:hoverView(\''.$hover.'\');">
7741 <div class="hover_lists" id="hoverlist'.$hover.'">
7742 <h2>Your Lists</h2>
7743 <div class="lists_check">';
7744 foreach($this->data['userLists'] as $Lists){
7745 $haveListIn = $this->user_model->check_list_products(stripslashes($productDetail->id),$Lists['id'])->num_rows();
7746 if($haveListIn>0){$chk='checked="checked"';}else{ $chk='';}
7747
7748 $content .='<input type="checkbox" class="check_box" onClick="return addproducttoList(\''.$Lists['id'].'\',\''.$productDetail->id.'\');" '.$chk.'/>';
7749 $content .='<label>'.$Lists['name'].'</label>';
7750 }
7751 $content .='</div>
7752 <div class="new_list">
7753 <form method="post" action="site/user/add_list">
7754 <input type="hidden" value="1" name="ddl" />
7755 <input type="hidden" value="'.$productDetail->id.'" name="productId" />
7756 <input type="text" placeholder="';
7757 if($this->lang->line('user_new_list') != '') {
7758 $content .=stripslashes($this->lang->line('user_new_list'));
7759 } else {
7760 $content .='New list';}
7761 $content .='" class="list_scroll" name="list" id="creat_list_'.$hover.'" />
7762 <input type="submit" value="';
7763 if($this->lang->line("user_add") != "") {
7764 $content .=stripslashes($this->lang->line('user_add'));
7765 } else{ $content .='Add'; }
7766 $content .='" class="primary-button" onclick="return validate_create_list(\''.$hover.'\');" />
7767 </form>
7768 </div>
7769 </div>
7770 </a>
7771 </div>
7772 </div>
7773 </div>
7774 </li> ';
7775 }else if($actFav['activity_name']=='Unfavorite shop' || $actFav['activity_name']=='favorite shop') {
7776
7777 $shopproductDetail = $this->user_model->getfavshops_activity($actFav['activity_id'])->result_array();
7778
7779 $content .='<li class="activity '.$cls.'">
7780 <div class="activity-desc">
7781 <div class="activity-avatar trigger-action-toolbox" data-source="hp_tastemaker">
7782 <a href="view-profile/'.$userProfileDetails[0]['user_name'].'" >';
7783 if($userProfileDetails[0]['thumbnail']!=''){ $profile_pic='users/thumb/'.$userProfileDetails[0]['thumbnail']; } else { $profile_pic='default_avat.png';}
7784 $content .='<img width="75" height="75" src="images/'.$profile_pic.'">
7785 </a>
7786 </div>
7787 <p class="activity-name">';
7788 if($userProfileDetails[0]['id']!=$loginCheck){ $content .=$userProfileDetails[0]['user_name']; } else { if($this->lang->line('user_you')!='') { $content .= stripslashes($this->lang->line('user_you')); } else $content .="You"; }
7789 $content .=' ';
7790 if($this->lang->line('favorited') != '') { $content .= stripslashes($this->lang->line('favorited')); } else $content .="favorited";
7791 $content .=' ';
7792 $content .='<a class="member-name" href="shop-section/'.$shopproductDetail[0]['shopurl'].'">';
7793 $content .=' ';
7794 if($this->lang->line('user_thisshop') != '') {
7795 $content .= stripslashes($this->lang->line('user_thisshop')); } else $content .= "this shop";
7796 $content .='</a>
7797 </p>
7798 </div>
7799 <div class="activity-favorites">';
7800 if(count($shopproductDetail)<4){$count=count($shopproductDetail); } else{ $count=4; } for($i=0;$i<$count;$i++){
7801 $content .='<a href="shop-section/'.$shopproductDetail[0]['shopurl'].'" class="favorite">';
7802 $imgArr=explode(',',$shopproductDetail[$i]['image']);
7803 $content .='<img width="170" height="135" alt="'.$shopproductDetail[$i]['product_name'].'" src="images/product/'.$imgArr[0].'">
7804 </a> ';
7805 }
7806 if($count!=4) {for($j=4-$count;$j<$count;$j++){
7807 $content .=' <a class="favorite">
7808 </a> ';
7809 } }
7810 $content .='</div>
7811 <div class="activity-link clear">
7812 <div class="activeright">
7813 <span class="newimages"></span>
7814 <p class="line-type">';
7815 if($this->lang->line('shop') != '') { $content .= stripslashes($this->lang->line('shop')); } else $content .= "SHOP";
7816 $content .='</p>
7817 <p><a class="name_line" href="shop-section/'.$shopproductDetail[0]['shopurl'].'">'.$shopproductDetail[0]['shopname'].'</a></p>
7818 </div>';
7819 if($loginCheck !=''){
7820 $favArr = $this->product_model->getUserFavoriteShopDetails($actFav['activity_id']);
7821 if(empty($favArr)){
7822 $content .='<a href="javascript:void(0);" onClick="return changeShopToFavourite(\''.$actFav['activity_id'].'\',\'Fresh\');">
7823 <input type="submit" value="" class="hoverfav_icon">
7824 </a>';
7825 } else {
7826 $content .='<a href="javascript:void(0);" onClick="return changeShopToFavourite(\''.$actFav['activity_id'].'\',\'Old\');">
7827 <input type="submit" value="" class="hoverfav_icon1">
7828 </a>';
7829 }} else {
7830 $content .='<input type="submit" value="" class="hoverfav_icon">';
7831 }
7832 $content .='</div>
7833 </li>';
7834 } }
7835 //$content .='</ul>';
7836 //$content .='</ul>';
7837 } else {
7838 $content ='';
7839 }
7840 echo $content;}else{
7841 redirect('login');
7842 }
7843 }
7844
7845 /**
7846 *
7847 * To add the shop activity for user using ajax
7848 *
7849 */
7850 public function ajax_activity_shop(){
7851 if ($this->checkLogin('U')!=''){
7852 $loginCheck = $this->checkLogin('U');
7853 $this->data['currUser']=$checkloginIDarr=$this->session->all_userdata();
7854 $loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
7855 $this->data['userProfileDetails']=$userProfileDetails= $this->user_model->get_all_details(USERS,array('id'=>$loggeduserID))->result_array();
7856 $myshopproductArr= $this->user_model->get_all_details(PRODUCT,array('user_id'=>$loggeduserID))->result_array();
7857 $prd='';
7858 foreach($myshopproductArr as $prdId){
7859 $prd.=$prdId['id'].',';
7860 }
7861 $condition="ua.activity_id =".$loggeduserID." or FIND_IN_SET(ua.activity_id,'".rtrim($prd,',')."')";
7862 $offset = is_numeric($_POST['offset']) ? $_POST['offset'] : die();
7863 $postnumbers = is_numeric($_POST['number']) ? $_POST['number'] : die();
7864 $this->data['myshopactivity']=$myshopactivity= $this->user_model->get_myshopactivity($condition,$postnumbers,$offset)->result_array();
7865
7866 $this->data['heading'] = $this->config->item('email_title').'-Your Shop Activity';
7867 if(!empty($myshopactivity)){
7868 $content ='<ul id="activity-list">';
7869 $hover=0; $s=0;$l=1; foreach($myshopactivity as $actFav){
7870 if($s<3 && $l<4){ $cls="small"; $s++; } else if($s>2 && $l<4){ $cls="large"; $l++;} else {$s=0;$l=1;}
7871 $userProfileDetails= $this->user_model->get_all_details(USERS,array('id'=>$actFav['user_id']))->result_array();
7872 if($actFav['activity_name']=='Unfavorite item' || $actFav['activity_name']=='favorite item') {
7873 $hover++;
7874 $productDetail = $this->user_model->get_all_details(PRODUCT,array('id'=>$actFav['activity_id']))->row();
7875 $imgArr=explode(',',$productDetail->image);
7876 $content .='<li class="activity small-wid '.$cls.'">
7877 <div class="activity-desc">
7878 <div class="activity-avatar trigger-action-toolbox" data-source="hp_tastemaker">
7879 <a href="view-profile/'.$userProfileDetails[0]['user_name'].'" >';
7880 if($userProfileDetails[0]['thumbnail']!=''){ $profile_pic='users/thumb/'.$userProfileDetails[0]['thumbnail']; } else { $profile_pic='default_avat.png';}
7881 $content .='<img width="75" height="75" src="images/'.$profile_pic.'">
7882 </a>
7883 </div>
7884 <p class="activity-name">';
7885 if($userProfileDetails[0]['id']!=$loginCheck){ $content .= $userProfileDetails[0]['user_name']; } else { $content .= 'You';}
7886 if($this->lang->line('favorited') != '') { $content .= stripslashes($this->lang->line('favorited')); } else $content .= "favorited";
7887 $content .='<a class="member-name" href="products/'.$productDetail->seourl.'"> your item..</a>
7888 </p>
7889 </div>
7890 <div class="activity-favorites full-wid">
7891 <a href="products/'.$productDetail->seourl.'" class="activity-full">
7892 <img alt="'.$productDetail->product_name.'" src="images/product/'.$imgArr[0].'">
7893 </a>
7894 </div>
7895 <div class="story-info clear">
7896 <div class="product-dtl">'.$productDetail->product_name.'</div>
7897 <div class="product_fv">';
7898 if($loginCheck !=''){
7899 if($productDetail->user_id==$loginCheck){
7900 $prod_list.='<a href="javascript:void(0);" onclick="return ownProductFav();">
7901 <input type="submit" value="" class="hoverfav_icon" />
7902 </a>';
7903 }else{
7904 $favArr = $this->product_model->getUserFavoriteProductDetails($productDetail->id);
7905 if(empty($favArr)){
7906 $content .='<a href="javascript:void(0);" onClick="return changeProductToFavourite(\''.$productDetail->id.'\',\'Fresh\');">
7907 <input type="submit" value="" class="hoverfav_icon" />
7908 </a>';
7909 } else {
7910 $content .='<a href="javascript:void(0);" onClick="return changeProductToFavourite(\''.$productDetail->id.'\',\'Old\');">
7911 <input type="submit" value="" class="hoverfav_icon1" />
7912 </a>';
7913 }}} else {
7914 $content .='<a href="login" class="reg-popup" >
7915 <input type="submit" value="" class="hoverfav_icon" />
7916 </a>';
7917 }
7918 $content .='<div class="hoverdrop2_icon">
7919 <a href="javascript:hoverView('.$hover.');">
7920 <div class="hover_lists" id="hoverlist'.$hover.'">
7921 <h2>';
7922 if($this->lang->line('user_your_lists') != '') { $content .= stripslashes($this->lang->line('user_your_lists')); } else $content .= "Your Lists"; $content .='</h2>
7923 <div class="lists_check">';
7924 foreach($this->data['userLists'] as $Lists){
7925 $haveListIn = $this->user_model->check_list_products(stripslashes($productDetail->id),$Lists['id'])->num_rows();
7926 if($haveListIn>0){$chk='checked="checked"';}else{ $chk='';}
7927
7928 $content .='<input type="checkbox" class="check_box" onClick="return addproducttoList(\''.$Lists['id'].'\',\''.$productDetail->id.'\');" '.$chk.'/>
7929 <label>'.$Lists["name"].'</label>';
7930 }
7931 $content .='</div>
7932 <div class="new_list">
7933 <form method="post" action="site/user/add_list">
7934 <input type="hidden" value="1" name="ddl" />
7935 <input type="hidden" value="'.$productDetail->id.'" name="productId" />
7936 <input type="text" placeholder="';if($this->lang->line('user_new_list') != '') { $content .= stripslashes($this->lang->line('user_new_list')); } else $content .= 'New list';$content .='" class="list_scroll" name="list" id="creat_list_'.$hover.'" />
7937 <input type="submit" value="';if($this->lang->line('user_add') != '') { $content .= stripslashes($this->lang->line('user_add')); } else $content .= 'Add'; $content .='" class="primary-button" onClick="return validate_create_list(\''.$hover.'\');" />
7938 </form>
7939 </div>
7940 </div>
7941 </a>
7942 </div>
7943 </div>
7944 </div>
7945 </li> ';
7946 }else if($actFav['activity_name']=='Unfavorite shop' || $actFav['activity_name']=='favorite shop') {
7947 $shopproductDetail = $this->user_model->getfavshops_activity($actFav['activity_id'])->result_array();
7948 $content .=' <li class="activity '.$cls.'">
7949 <div class="activity-desc">
7950 <div class="activity-avatar trigger-action-toolbox" data-source="hp_tastemaker">
7951 <a href="view-profile/'.$userProfileDetails[0]['user_name'].'" >';
7952 if($userProfileDetails[0]['thumbnail']!=''){ $profile_pic='users/thumb/'.$userProfileDetails[0]['thumbnail']; } else { $profile_pic='default_avat.png';}
7953 $content .=' <img width="75" height="75" src="images/'.$profile_pic.'">
7954 </a>
7955 </div>
7956 <p class="activity-name">';
7957 if($userProfileDetails[0]['id']!=$loginCheck){ $content .= $userProfileDetails[0]['user_name']; } else { $content .= 'You';}
7958 if($this->lang->line('favorited') != '') { $content .= stripslashes($this->lang->line('favorited')); } else $content .= "favorited";
7959 $content .='<a class="member-name" href="shop-section/'.$shopproductDetail[0]['shopurl'].'"> your shop.</a>
7960 </p>
7961 </div>
7962 <div class="activity-favorites">';
7963 if(count($shopproductDetail)<4){$count=count($shopproductDetail); } else{ $count=4; } for($i=0;$i<$count;$i++){
7964 $content .=' <a href="shop-section/'.$shopproductDetail[0]['shopurl'].'" class="favorite">';
7965 $imgArr=explode(',',$shopproductDetail[$i]['image']);
7966 $content .='<img width="170" height="135" alt="'.$shopproductDetail[$i]['product_name'].'" src="images/product/'.$imgArr[0].'">
7967 </a> ';
7968 }
7969 if($count!=4) {for($j=4-$count;$j<$count;$j++){
7970 $content .='<a class="favorite">
7971 </a> ';
7972 } }
7973 $content .='</div>
7974 <div class="activity-link clear">
7975 <div class="activeright">
7976 <span class="newimages"></span>
7977 <p class="line-type">';
7978 if($this->lang->line('shop') != '') { $content .= stripslashes($this->lang->line('shop')); } else $content .= "SHOP";
7979 $content .=' </p>
7980 <p><a class="name_line" href="shop-section/'.$shopproductDetail[0]['shopurl'].'">'.$shopproductDetail[0]['shopname'].'</a></p>
7981 </div>';
7982 if($loginCheck !=''){
7983 $favArr = $this->product_model->getUserFavoriteShopDetails($actFav['activity_id']);
7984 if(empty($favArr)){
7985 $content .='<a href="javascript:void(0);" onClick="return changeShopToFavourite(\''.$actFav['activity_id'].'\',\'Fresh\');">
7986 <input type="submit" value="" class="hoverfav_icon">
7987 </a>';
7988 } else {
7989 $content .='<a href="javascript:void(0);" onClick="return changeShopToFavourite(\''.$actFav['activity_id'].'\',\'Old\');">
7990 <input type="submit" value="" class="hoverfav_icon1">
7991 </a>';
7992 }} else {
7993 $content .='<input type="submit" value="" class="hoverfav_icon">';
7994 }
7995 $content .='</div>
7996 </li>';
7997 } }
7998 $content .='</ul> ';
7999 }else {
8000 $content ='';
8001 }
8002 echo $content;
8003 }else{
8004 redirect('login');
8005 }
8006 }
8007
8008 /**
8009 *
8010 * To add the item to favorite list using ajax
8011 *
8012 */
8013 public function ajax_people_favorite_list_itemsilove(){
8014 $loginCheck = $this->checkLogin('U');
8015 $this->data['currUser']=$checkloginIDarr=$this->session->all_userdata();
8016 $this->data['loggeduserID']=$loggeduserID=$checkloginIDarr['shopsy_session_user_id'];
8017 $username = urldecode($this->uri->segment(4,0));
8018 $userDetails= $this->user_model->get_all_details(USERS,array('user_name'=>$username))->result_array();
8019 $userDetails[0]['id'];
8020 $condition='';
8021 if($_GET['a']){
8022 $search_key=$_GET['a'];
8023 $condition="p.product_name LIKE '%".$search_key."%' and";
8024 }
8025 if($_GET['filter']){
8026 $condition="p.status='Publish' and p.quantity>2 and";
8027 }
8028 $this->data['userProfileDetails']=$userProfileDetails = $this->user_model->get_all_details(USERS,array('id'=>$userDetails[0]['id'],'status'=>'Active'))->result_array();
8029 $offset = is_numeric($_POST['offset']) ? $_POST['offset'] : die();
8030 $postnumbers = is_numeric($_POST['number']) ? $_POST['number'] : die();
8031 $this->data['userFavoriteItems']=$userFavoriteItems = $this->product_model->getFavoriteProduct($userDetails[0]['id'],$condition,$postnumbers,$offset)->result_array();
8032 $i=1; foreach($userFavoriteItems as $products){ $img=explode(',',$products['image']);
8033 $content .='<li>
8034 <div class="product_img">
8035 <div class="product_hide">
8036 <div class="product_fav">';
8037 if($loginCheck !=''){
8038 if($products['user_id']==$loginCheck){
8039 $prod_list.='<a href="javascript:void(0);" onclick="return ownProductFav();">
8040 <input type="submit" value="" class="hoverfav_icon" />
8041 </a>';
8042 }else{
8043 $favArr = $this->product_model->getUserFavoriteProductDetails(stripslashes($products['id']));
8044 if(empty($favArr)){
8045 $content .='<a href="javascript:void(0);" onClick="return changeProductToFavourite(\''.stripslashes($products['id']).'\',\'Fresh\');">
8046 <input type="submit" value="" class="hoverfav_icon" />
8047 </a>';
8048 } else {
8049 $content .='<a href="javascript:void(0);" onClick="return changeProductToFavourite(\''.stripslashes($products['id']).'\',\'Old\');">
8050 <input type="submit" value="" class="hoverfav_icon1" />
8051 </a>';
8052 }} }else {
8053 $content .='<a href="login" >
8054 <input type="submit" value="" class="hoverfav_icon" />
8055 </a>';
8056 }
8057 $content .='<div class="hoverdrop_icon">
8058 <a href="javascript:hoverView('.$i.');"> </a>
8059 <div class="hover_lists" id="hoverlist'.$i.'">
8060 <h2>';
8061 if($this->lang->line('user_your_lists') != '') { $content .=stripslashes($this->lang->line('user_your_lists')); } else $content .= 'Your Lists'; $content .='</h2>
8062 <div class="lists_check">';
8063 foreach($this->data['userLists'] as $Lists){
8064 $haveListIn = $this->user_model->check_list_products(stripslashes($products['id']),$Lists['id'])->num_rows();
8065 if($haveListIn>0){$chk='checked="checked"';}else{ $chk='';}
8066 $content .='<input type="checkbox" class="check_box" onClick="return addproducttoList(\''.$Lists['id'].'\',\''.stripslashes($products['id']).'\');" '.$chk.' />
8067 <label>'.$Lists['name'].'</label>';
8068 }
8069 if(!empty($userRegistry)){
8070 $haveRegisryIn = $this->user_model->check_registry_products($products['id'],$userRegistry->user_id)->num_rows();
8071 if($haveRegisryIn>0){$chk='checked="checked"';}else{ $chk='';}
8072 $content .='<input type="checkbox" class="check_box" onClick="return manageRegisrtyProduct(\''.$userRegistry->user_id.'\',\''.$products['id'].'\');" '.$chk.' />
8073 <label><span class="registry_icon"></span>';
8074 if($this->lang->line('prod_wedding') != '') { $content .= stripslashes($this->lang->line('prod_wedding')); } else $content .= 'Wedding Registry'; $content .='</label>';
8075 }
8076 $content .='</div>
8077 <div class="new_list">
8078 <form method="post" action="site/user/add_list">
8079 <input type="hidden" value="1" name="ddl" />
8080 <input type="hidden" value="'.$products['id'].'" name="productId" />
8081 <input type="text" placeholder="';if($this->lang->line('user_new_list') != '') { $content .= stripslashes($this->lang->line('user_new_list')); } else $content .= 'New list'; $content .='" class="list_scroll" name="list" id="creat_list_'.$i.'" />
8082 <input type="submit" value="';if($this->lang->line('user_add') != '') { $content .= stripslashes($this->lang->line('user_add')); } else $content .= 'Add'; $content .='" class="primary-button" onClick="return validate_create_list(\''.$i.'\');" />
8083 </form>
8084 </div>
8085 </div>
8086
8087 </div>
8088 </div>
8089 </div>
8090 <a href="products/'.$products['seourl'].'">
8091 <img src="images/product/'.$img[0].'" alt="Product-1" title="Product-1" />
8092 </a>
8093 </div>
8094 <div class="product_title"><a href="products/'.$products['seourl'].'">'.$products['product_name'].'</a></div>
8095 <div class="product_maker"><a href="shop-section/'.$products['seller_seourl'].'">'.$products['seller_businessname'].'</a></div>
8096 <div class="product_price">';
8097 if($products['price'] != 0.00) {
8098 $content .=' <span class="currency_value">'.$this->data['currencySymbol'].' '.number_format($this->data['currencyValue']*$products['price'],2).'</span>
8099 <span class="currency_code">';
8100 #if($this->lang->line('user_usd') != '') { $content .= stripslashes($this->lang->line('user_usd')); } else $content .= "USD";
8101 $content .=$this->data['currencyType'].' </span>';
8102 } else {
8103 $content .='<span class="currency_value">'.$this->data['currencySymbol'].' '.number_format($this->data['currencyValue']*$products['pricing'],2).'+'.'</span>
8104 <span class="currency_code">';
8105 #if($this->lang->line('user_usd') != '') { $content .= stripslashes($this->lang->line('user_usd')); } else $content .= "USD";
8106 $content .=$this->data['currencyType'].'</span>';
8107 }
8108 $content .='</div>
8109 </li>';
8110 $i++; }
8111 echo $content;
8112
8113
8114 }
8115
8116 /**
8117 *
8118 * To display the user invite list
8119 *
8120 */
8121 public function display_user_invite(){
8122
8123 $username = urldecode($this->uri->segment(2,0));
8124 $userProfileDetails = $this->user_model->get_all_details(USERS,array('user_name'=>$username));
8125 $this->data['userProfileDetails'] =$this->user_model->get_all_details(USERS,array('user_name'=>$username));
8126 if ($userProfileDetails->num_rows()==1){
8127 $this->data['heading'] = $this->config->item('email_title').' - Follower List';
8128 $this->load->view('site/user/invite_friends',$this->data);
8129
8130 }else {
8131 redirect(base_url());
8132 }
8133 }
8134
8135 /**
8136 *
8137 * To view the twitter login page
8138 *
8139 */
8140 public function twitter_update(){
8141
8142 $this->load->view('site/user/twitter_settings',$this->data);
8143 }
8144
8145
8146 /**
8147 *
8148 * To view the twitter signup page
8149 *
8150 */
8151 public function twitter_signup(){
8152
8153 $twitter_id = $this->session->userdata('social_login_unique_id');
8154 $twitter_images = $this->session->userdata('social_image_name');
8155
8156
8157 $unameArr = $this->config->item('unameArr');
8158 $fullname = $this->session->userdata('social_login_name');
8159 $lastname = '';
8160
8161 if($fullname==''){
8162 $fullname =stripslashes($this->session->userdata('screen_name').trim());
8163 }
8164
8165 $email = $this->input->post('pass_email');
8166 $pwd = md5($this->input->post('pass_password'));
8167 $Confirmpwd = $this->input->post('pass_confirm_password');
8168 $username = stripslashes($this->session->userdata('screen_name').trim());
8169
8170
8171 if (!preg_match('/^\w{1,}$/', trim($username))){
8172 $this->setErrorMessage('error','User name not valid');
8173 redirect('twitter-update');
8174 }
8175 elseif (in_array($username, $unameArr)){
8176 $this->setErrorMessage('error','User name already exists');
8177 redirect('twitter-update');
8178 }else {
8179 if (valid_email($email)){
8180 $condition = array('user_name'=>$username);
8181 $duplicateName = $this->user_model->get_all_details(USERS,$condition);
8182 if ($duplicateName->num_rows()>0){
8183 $this->setErrorMessage('error','User name already exists');
8184 redirect('twitter-update');
8185 }else {
8186 $condition = array('email'=>$email);
8187 $duplicateMail = $this->user_model->get_all_details(USERS,$condition);
8188 if ($duplicateMail->num_rows()>0){
8189 $this->setErrorMessage('error','Email id already exists');
8190 redirect('twitter-update');
8191 }else {
8192
8193 $time = time();
8194 $aff = $username.$time;
8195
8196 $dataArr = array('full_name'=>$fullname,'user_name'=>$username,'last_name'=>$lastname,'email'=>$email,'password'=>$pwd,'status'=>'Active','twitter_id'=>$twitter_id,'thumbnail'=>$twitter_images,'is_verified'=>'Yes','commision'=>$this->config->item('product_commission'),'affiliateId'=> $aff);
8197 $this->user_model->simple_insert(USERS,$dataArr);
8198
8199 $register_id = $this->db->insert_id();
8200
8201 $this->user_model->increaseUserCredits($register_id,$username,$email);
8202
8203 $checkUser = $this->user_model->get_all_details(USERS,array('email'=>$email));
8204
8205 $this->session->set_userdata('quick_user_name',$email);
8206 $userdata = array(
8207 'shopsy_session_user_id' => $checkUser->row()->id,
8208 'shopsy_session_user_name' => $checkUser->row()->user_name,
8209 'shopsy_session_full_name' => $checkUser->row()->full_name,
8210 'shopsy_session_last_name' => $checkUser->row()->last_name,
8211 'shopsy_session_user_email' => $checkUser->row()->email,
8212 'shopsy_session_user_confirm' => $checkUser->row()->is_verified,
8213 'userType'=>$checkUser->row()->group
8214 );
8215
8216 $this->session->set_userdata($userdata);
8217 $userDetails=$checkUser;
8218 $this->send_confirm_mail($userDetails);
8219 $this->setErrorMessage('success','Register and Login Successfully');
8220 redirect('wpconnect.php?un='.$username.'&pd='.$pwd.'&em='.$email);
8221
8222 }
8223 }
8224 }else {
8225 $this->setErrorMessage('error','Invalid email id');
8226 redirect('twitter-update');
8227 }
8228 }
8229
8230 }
8231
8232 public function resetPassword(){
8233
8234 // $id=$this->uri->segment(3);
8235 // $code=$this->uri->segment(2);
8236
8237 $data = $this->uri->segment(2);
8238 $data_verifiy = explode('#', base64_decode(strtr($data, '-_-', '+/=')));
8239 // echo '<pre>';print_r($data_verifiy);die;
8240 $id=$data_verifiy[1];
8241 $code=$data_verifiy[0];
8242
8243 $chkCode=$this->user_model->get_all_details(USERS,array('resetcode'=>$code,'resetstatus'=>'0','id'=>$id));
8244 // die($this->db->last_query());
8245 if($chkCode->num_rows()>0 ){
8246
8247 $currenttime=date('Y-m-d h:i:s');
8248 $password_time=$chkCode->row()->resettime;
8249
8250 // $time=date('Y-m-d h:i:s',strtotime('+1 hour',strtotime($password_time)));
8251
8252 $date1 = strtotime( date('Y-m-d',$password_time) );
8253 $date2 = strtotime( date('Y-m-d',$currenttime) );
8254
8255 // echo $date2.' - '.$date1;die;
8256
8257 // $datetime1 = new DateTime($time);
8258 // $datetime2 = new DateTime($currenttime);
8259
8260 // $datetime1->diff($datetime2);
8261
8262 // if($datetime2 > $datetime1){
8263 if($date2 > $date1){
8264 $this->setErrorMessage('Error','Link is Expired ! You cant reset your password');
8265 redirect('login');
8266 } else {
8267 $this->data['user_id']=$id;
8268 $this->data['heading'] = 'Password Reset';
8269 //echo "Not Expired";
8270 $this->load->view('site/user/password_reset',$this->data);
8271 }
8272 die;
8273 } else {
8274
8275 $this->setErrorMessage('Error','Link is invalid (or) Already Used ! You cant reset your password');
8276 redirect('login');
8277 }
8278 }
8279
8280 public function changePasssword(){
8281
8282 $user_id=$this->input->post('user_id');
8283 $password=md5($this->input->post('newPassword'));
8284 $this->user_model->update_details(USERS,array('password'=>$password,'resetstatus'=>'1'),array('id'=>$user_id));
8285 $this->setErrorMessage('success','Password Reset Successfull');
8286 redirect('');
8287 }
8288
8289 public function state_list_ajax($country_id=''){
8290 $state_list=$this->user_model->get_all_details(STATE_LIST, array('countryid'=>$country_id), [array('field'=>'name', 'type'=>'asc')]);
8291 $message = "";
8292 //echo $state_list->num_rows();
8293 if($state_list->num_rows()>0){
8294 $message ='<option value="Select">--- Pilih Provinsi ---</option>';
8295 foreach($state_list->result() as $row){
8296 $message.='<option data-id="'.$row->id.'" value="'.$row->name.'">'.$row->name.'</option>';
8297 }
8298
8299 }else{
8300 //echo "ASdf";
8301 $message = '<option value="Select">--- Provinsi tidak ada ---</option>';
8302 }
8303 echo $message;
8304 }
8305 public function district_list_ajax($country_id=''){
8306 $state_list=$this->user_model->get_all_details(DISTRICT_LIST, array('state_id'=>$country_id));
8307 $message = "";
8308 if($state_list->num_rows()>0){
8309 $message ='<option value="Select">--- Pilih Kota ---</option>';
8310 foreach($state_list->result() as $row){
8311 $message.='<option data-id="'.$row->id.'" value="'.$row->name.'">'.$row->name.'</option>';
8312 }
8313
8314 }else{
8315 $message = '<option value="Select">--- Provinsi tidak ada ---</option>';
8316 }
8317 echo $message;
8318 }
8319
8320/*Novis Add JNE*/
8321 public function get_JNE($desti='', $product_id='',$seller_id)
8322 {
8323 $seller_detail = $this->user_model->get_all_details(PRODUCT,array('id'=>$product_id) );
8324 $prod_detail = $this->user_model->get_all_details(PRODUCT,array('id'=>$product_id) );
8325
8326 //echo $his->db->last_query();
8327 //echo '<pre>';print_r($prod_detail->row());die;
8328
8329 $origin = $prod_detail->row()->provice;
8330 $weight = $prod_detail->row()->weight/1000;
8331
8332 $jne = jne_getPrice($origin,$desti,$weight);
8333
8334 //echo '<pre>';print_r($jne);exit;
8335 $res = '<option value="">--- Pilih Expedisi ---</option>';
8336 $res .= '<option value="GRATIS#0">GRATIS (Kurir Toko / Pickup)</option>';
8337 /*for($i=0;$i<count($jne->price);$i++)
8338 {
8339 if( $jne->price[$i]->service_display == 'REG' ||
8340 $jne->price[$i]->service_display == 'CTC' ||
8341 $jne->price[$i]->service_display == 'REG15')
8342 {
8343 //$jne_list[$x] = array('val'=>$i,'label' => 'JNE-REGULAR');
8344 $res .= '<option value="JNE-REGULAR#'.number_format($jne->price[$i]->price,0).'" >JNE-REGULAR(Rp. '.number_format($jne->price[$i]->price,0).')</option>';
8345 //$x++;
8346 }
8347 if( $jne->price[$i]->service_display == 'OKE' ||
8348 $jne->price[$i]->service_display == 'OKE15' ||
8349 $jne->price[$i]->service_display == 'CTCOKE')
8350 {
8351 //$jne_list[$x] = array('val'=>$i,'label' => 'JNE-OKE');
8352 $res .= '<option value="JNE-OKE#'.number_format($jne->price[$i]->price,0).'" >JNE-OKE(Rp. '.number_format($jne->price[$i]->price,0).')</option>';
8353 //$x++;
8354 }
8355 if( $jne->price[$i]->service_display == 'YES' ||
8356 $jne->price[$i]->service_display == 'YES15' ||
8357 $jne->price[$i]->service_display == 'CTCYES'
8358 )
8359 {
8360 //$jne_list[$x] = array('val'=>$i,'label' => 'JNE-YES');
8361 $res .= '<option value="JNE-YES#'.number_format($jne->price[$i]->price,0).'" >JNE-YES(Rp. '.number_format($jne->price[$i]->price,0).')</option>';
8362 //$x++;
8363 }
8364
8365 }*/
8366
8367 //echo $this->db->last_query();
8368
8369 echo $res;
8370 }
8371
8372/*Novis*/
8373 public function get_region_ajax($city='', $kecamatan='', $kelurahan='')
8374 {
8375 $this->db->select('branch_name');
8376 $this->db->from(shopsy_master_location);
8377 $this->db->where('city_id', $city);
8378 $this->db->where('kecamatan_id', $kecamatan);
8379 $this->db->where('kelurahan_id', $kelurahan);
8380 $this->db->group_by('branch_name');
8381
8382 $region = $this->db->get();
8383
8384 //echo $this->db->last_query();
8385
8386 $message = "";
8387
8388 if($region->num_rows()>0)
8389 {
8390 $message = $region->row()->branch_name;
8391 }
8392 else
8393 {
8394 $message = '';
8395 }
8396
8397 echo $message;
8398 }
8399
8400
8401 public function city_list_ajax($country_id=''){
8402 $state_list=$this->user_model->get_all_details(CITY_LIST,array('district_id'=>$country_id));
8403 //echo '<pre>';print_r($state_list->row());die;
8404 $message = "";
8405 if($state_list->num_rows()>0){
8406 $message ='<option value="Select">--- Pilih Kecamatan ---</option>';
8407 foreach($state_list->result() as $row){
8408 $message.='<option data-id="'.$row->id.'" value="'.$row->name.'">'.$row->name.'</option>';
8409 }
8410
8411 }else{
8412 $message = '<option value="Select">--- Kecamatan tidak ada ---</option>';
8413 }
8414 echo $message;
8415 }
8416
8417 public function kel_list_ajax($country_id=''){
8418 $state_list=$this->user_model->get_all_details(shopsy_kelurahan, array('city_id'=>$country_id));
8419 $message = "";
8420 if($state_list->num_rows()>0){
8421 $message ='<option value="Select">--- Pilih Kelurahan ---</option>';
8422 foreach($state_list->result() as $row){
8423 $message.='<option data-id="'.$row->id.'" value="'.$row->name.'">'.$row->name.'</option>';
8424 }
8425
8426 }else{
8427 $message = '<option value="Select">--- Kelurahan tidak ada ---</option>';
8428 }
8429 echo $message;
8430 }
8431
8432 public function after_login()
8433 {
8434 redirect('');
8435 }
8436
8437/*Novis was Here*/
8438//Provinsi
8439 public function branch_list_ajax($country_id='') {
8440 $this->db->select ( 'branch_id,branch_name' );
8441 $this->db->from ( shopsy_master_location );
8442 $this->db->where ( 'country_id', $country_id);
8443 $this->db->group_by ( "branch_name" );
8444 $this->db->order_by ( "branch_name" );
8445 $location_list = $this->db->get ();
8446
8447 //echo $this->db->last_query();
8448
8449 $message = "";
8450
8451 if($location_list->num_rows()>0) {
8452 $message ='<option value="Select">--- Pilih Regional ---</option>';
8453 foreach($location_list->result() as $row) {
8454 $message.='<option data-id="'.$row->branch_id.'" value="'.$row->branch_name.'">'.$row->branch_name.'</option>';
8455 }
8456
8457 }else{
8458 //echo "ASdf";
8459 $message = '<option value="Select">--- Regional tidak ada ---</option>';
8460 }
8461 echo $message;
8462 }
8463//Kota
8464 public function kota_list_ajax($province_id='')
8465 {
8466 $this->db->select ( 'city_id,city' );
8467 $this->db->from ( shopsy_master_location );
8468 $this->db->where ( 'country_id', $province_id);
8469 $this->db->group_by ( "city" );
8470 $this->db->order_by ( "city" );
8471 $location_list = $this->db->get ();
8472
8473 //echo $this->db->last_query();
8474
8475 $message = "";
8476
8477 if($location_list->num_rows()>0) {
8478 $message ='<option value="">--- Pilih Kota ---</option>';
8479 foreach($location_list->result() as $row) {
8480 $message.='<option data-id="'.$row->city_id.'" value="'.$row->city.'">'.$row->city.'</option> ';
8481 }
8482
8483 }else{
8484 //echo "ASdf";
8485 $message = '<option value="Select">--- Kota tidak ada ---</option>';
8486 }
8487 echo $message;
8488 }
8489
8490//Kota 2
8491 public function kota_list_ajax_2($branch_id='')
8492 {
8493 $this->db->select ( 'city_id, city' );
8494 $this->db->from ( shopsy_master_location );
8495 $this->db->where ( 'branch_id', $branch_id);
8496 $this->db->group_by ( "city" );
8497 $this->db->order_by ( "city" );
8498 $location_list = $this->db->get ();
8499
8500 // echo $this->db->last_query();
8501
8502 $message = "";
8503
8504 if($location_list->num_rows()>0) {
8505 $message ='<option value="Select">--- Pilih Kota ---</option>';
8506 foreach($location_list->result() as $row) {
8507 $message.='<option data-id="'.$row->city_id.'" value="'.$row->city.'">'.$row->city.'</option>';
8508 }
8509
8510 }else{
8511 //echo "ASdf";
8512 $message = '<option value="Select">--- Kota tidak ada ---</option>';
8513 }
8514 echo $message;
8515 }
8516
8517//Kecamtan
8518 public function kecamatan_list_ajax($kota_id='') {
8519 $this->db->select ( 'kecamatan_id,kecamatan' );
8520 $this->db->from ( shopsy_master_location );
8521 $this->db->where ( 'city_id', $kota_id);
8522 $this->db->group_by ( "kecamatan" );
8523 $this->db->order_by ( "kecamatan" );
8524 $location_list = $this->db->get ();
8525
8526 //echo $this->db->last_query();
8527
8528 $message = "";
8529
8530 if($location_list->num_rows()>0) {
8531 $message ='<option value="">--- Pilih Kecamatan ---</option>';
8532 foreach($location_list->result() as $row) {
8533 $message.='<option data-id="'.$row->kecamatan_id.'" value="'.$row->kecamatan.'">'.$row->kecamatan.'</option>';
8534 }
8535
8536 } else {
8537 //echo "ASdf";
8538 $message = '<option value="Select">--- Kecamatan tidak ada ---</option>';
8539 }
8540 echo $message;
8541 }
8542//Kelurahan
8543 public function kelurahan_list_ajax($kota_id='') {
8544 $this->db->select ( 'kelurahan_id,kelurahan' );
8545 $this->db->from ( shopsy_master_location );
8546 $this->db->where ( 'kecamatan_id', $kota_id);
8547 //$this->db->group_by ( "kecamatan" );
8548 $this->db->order_by ( "kecamatan" );
8549 $location_list = $this->db->get ();
8550
8551 //echo $this->db->last_query();
8552
8553 $message = "";
8554
8555 if($location_list->num_rows()>0) {
8556 $message ='<option value="">--- Pilih Kelurahan ---</option>';
8557 foreach($location_list->result() as $row) {
8558 $message.='<option data-id="'.$row->kelurahan_id.'" value="'.$row->kelurahan.'">'.$row->kelurahan.'</option>';
8559 }
8560
8561 } else {
8562 //echo "ASdf";
8563 $message = '<option value="Select">--- Kelurahan tidak ada ---</option>';
8564 }
8565 echo $message;
8566 }
8567//Zipcode
8568 public function zipcode_list_ajax($kel_id='') {
8569 $this->db->select ( 'zipcode' );
8570 $this->db->from ( shopsy_master_location );
8571 $this->db->where ( 'kelurahan_id', $kel_id);
8572 //$this->db->group_by ( "kecamatan" );
8573 $this->db->order_by ( "zipcode" );
8574 $location_list = $this->db->get ();
8575
8576 //echo $this->db->last_query();
8577
8578 $message = "";
8579
8580 if($location_list->num_rows()>0) {
8581 $message ='<option value="">--- Pilih Zipcode ---</option>';
8582 foreach($location_list->result() as $row) {
8583 $message.='<option data-id="'.$row->zipcode.'" value="'.$row->zipcode.'">'.$row->zipcode.'</option>';
8584 }
8585
8586 } else {
8587 //echo "ASdf";
8588 $message = '<option value="Select">--- Zipcode tidak ada ---</option>';
8589 }
8590 echo $message;
8591 }
8592
8593 /**
8594 * [autofill description]
8595 * @return [type] [description]
8596 */
8597 public function autofill() {
8598 // $res = $this->input->post('id').'-'.$this->input->post('tgl');
8599
8600 // $id = '3273114806890004';
8601 // $tgl = '1989-06-08';
8602
8603 $id = $this->input->post('id');
8604 #parsing NIK, for get birth date
8605 $get_tgl = substr($id, 6, 2);
8606 $tgl_lahir = ($get_tgl <= 31)?$get_tgl:'0'.substr($id, 7, 1);
8607
8608 $t['tgl'] = $tgl_lahir;
8609 $t['bulan'] = substr($id, 8, 2);
8610 $t['tahun'] = substr($id, 10, 2);
8611
8612 $tanggal_lahir = $t['tahun'].'-'.$t['bulan'].'-'.$t['tgl'];
8613
8614 // die( date('Y-m-d', strtotime($tanggal_lahir)) );
8615 #end of parsing
8616
8617 $tgl = date('Y-m-d', strtotime($tanggal_lahir));
8618
8619 $res = $this->getUserKP($id,$tgl);
8620
8621 // print_r($res);die;
8622 die(json_encode($res));
8623
8624 }
8625
8626 /**
8627 * [login_kreditmu description]
8628 * @return [type] [description]
8629 */
8630 public function login_kreditmu() {
8631 // $res = $this->input->post('id').'-'.$this->input->post('tgl');
8632 // $id = '3273114806890004';
8633 // $tgl = '1989-06-08';
8634 // echo '<pre>';print_r($this->input->post());
8635
8636 $id = $this->input->post('id');
8637 $tgl_lahir = $this->input->post('tgl_lahir');
8638
8639 $tgl = date('Y-m-d', strtotime($tgl_lahir));
8640
8641 $res = $this->getUserKP($id,$tgl);
8642 // echo $res['status'];die;
8643 if($res['status']!='0')
8644 {
8645 $dataArr=$res;//$this->input->post();
8646
8647 // echo '<pre>';print_r($dataArr);die;
8648 /*$dataArr array */
8649 // $this->session->set_flashdata('data_array', $dataArr);
8650 // echo '<pre>';print_r($this->session->flashdata('data_array'));die;
8651
8652 $res = base64_encode(json_encode($res));
8653 // var_dump(md5(json_encode($res)));die;
8654
8655 redirect("checkout/sellercart?info=".$res);
8656 }
8657 else
8658 {
8659 echo '<script>alert("'.$res['data'].'")</script>';
8660 // redirect("checkout/kreditmu");
8661 }
8662 // echo '<pre>';print_r($res);die;
8663 // die(json_encode($res));
8664
8665 }
8666
8667 /**
8668 * [login_kreditmu description]
8669 * @return [type] [description]
8670 */
8671 public function login_kreditmu_mobile() {
8672 // $res = $this->input->post('id').'-'.$this->input->post('tgl');
8673 // $id = '3273114806890004';
8674 // $tgl = '1989-06-08';
8675 // echo '<pre>';print_r($this->input->post());
8676
8677 $id = $this->input->post('id');
8678 $tgl_lahir = $this->input->post('tgl_lahir');
8679
8680 $tgl = date('Y-m-d', strtotime($tgl_lahir));
8681
8682 $res = $this->getUserKP($id,$tgl);
8683
8684 $dataArr=$res;//$this->input->post();
8685 // echo '<pre>';print_r($dataArr);die;
8686 /*$dataArr array */
8687 // $this->session->set_flashdata('data_array', $dataArr);
8688 $res = base64_encode(json_encode($res));
8689
8690 redirect("mobile/checkout/sellercart?info=".$res);
8691 // echo '<pre>';print_r($res);die;
8692 // die(json_encode($res));
8693
8694 }
8695
8696 public function testAPI(){
8697 $postdata = array(
8698 "shipping_cost" => 13000,
8699 "insurance_value" => ""
8700 );
8701
8702 $opts = array('http' =>
8703 array(
8704 'method' => 'POST',
8705 'header' =>"Content-Type: application/json\r\n".
8706 "Token:a2cf123afc531687c05ac16508c9849e\r\n",
8707 'content' => json_encode($postdata)
8708 )
8709 );
8710
8711 $context = stream_context_create($opts);
8712 $result = json_decode(file_get_contents('https://dev.pasarwarga.com/api/v2/kreditplus/tenor/30659', false, $context));
8713
8714 echo '<pre>';print_r($result);
8715 }
8716
8717 public function genQR(){
8718 echo $this->generateQR('Bibir','product');
8719 }
8720
8721 public function test_exp()
8722 {
8723 $key = 'AKe62df84bJ3d8e4b1hea2R45j11klsb';
8724 $key_harga = 'HR001188';
8725
8726 // BEKASI, TANGERANG, 0.85
8727
8728 $origin = 'BEKASI';
8729 $dest = 'TANGERANG';
8730 $w = '0.85';
8731
8732 $data = array(
8733 'cusName'=>'HR',
8734 'sendSiteCode' => $origin,
8735 'destAreaCode' => $dest,
8736 'weight' => $w
8737 );
8738
8739 $data_request = array(
8740 'data' => json_encode($data),
8741 'sign' => base64_encode(md5(json_encode($data).$key_harga)),
8742 );
8743
8744
8745 $opts = array('http' =>
8746 array(
8747 'method' => 'POST',
8748 'header' =>"Content-Type: application/x-www-form-urlencoded",
8749 'content' => http_build_query($data_request),
8750 'timeout' => 10
8751 )
8752 );
8753
8754 $context = stream_context_create($opts);
8755 $result = json_decode(file_get_contents('http://jk.jet.co.id:22230/jandt_track/inquiry.action', false, $context));
8756
8757 echo '<br><pre>';print_r($result);
8758 // echo '<br><pre>';print_r(json_decode($result->content));
8759
8760 if($result->is_success=='true'){
8761 // echo '<br><pre>';print_r(json_decode($result->content));
8762 $ressdata = json_decode($result->content);
8763 $responseData = [];
8764 for($i=0;$i<count($ressdata);$i++)
8765 {
8766 $responseData[] = array(
8767 "shipp_code"=>"jnt",
8768 "name"=>'J&T-'.$ressdata[$i]->name,
8769 "price"=>$ressdata[$i]->cost
8770 );
8771 }
8772
8773 echo '<br><pre>';print_r($responseData);
8774 }
8775 }
8776
8777}
8778
8779/* End of file user.php */
8780/* Location: ./application/controllers/site/user.php */