function cancle_account() { $redirect_to_home = FALSE; $user_id = $this->session->userdata("user_id"); $type_of_membership = $this->session->userdata("type_of_membership"); $answer = $this->input->post('ans'); if ($answer == 'tell_us') { $answer = $this->input->post('tell_us'); } $user_data = $this->user_model->get_user_by_id($user_id); $user_data = $this->user_model->get_user_by_id($user_id); if ($type_of_membership == 'FREE') { //Delete user $this->user_model->delete_user($user_id); //$this->session->set_flashdata('flash_mynl_tab', 'tab_4'); //Delete all schedule $this->schedule_model->delete_schedule_with_userid($user_id); //delete all subscribe $this->subscribe_model->delete_subscribe_with_userid($user_id); //delete Newsletter review with process $get_newsletter_ids = $this->newsletter_model->get_newsletter_review('', '', '', '', '', '', array("join_user_id"), array($user_id), ''); $this->newsletter_model->delete_newsletter_review_with_userid($user_id); for ($i = 0; $i < count($get_newsletter_ids); $i++) { $avg_rate = get_average_rate($get_newsletter_ids[$i]['join_newsletter_id']); $rate = array("ratings" => $avg_rate["avg_round"]); //add average rate $this->newsletter_model->update_newsletter($get_newsletter_ids[$i]['join_newsletter_id'], $rate); } $this->load->helper('email'); //load email library $this->load->library('email'); //read parameters from $_POST using input class // check is email addrress valid or no //First mail to user $user_email = $user_data[0]['primary_email']; $get_admin_detail = get_admin_detail(); if (valid_email($user_email)) { // compose email //common helper function for admin detail $this->email->from($get_admin_detail['email'], $get_admin_detail['name']); $this->email->to($user_email); $this->email->set_mailtype("html"); $this->email->subject('Your Free Account has been cancled from knewdog!'); $free_cancle_username = $user_data[0]['username']; //bhushan changes $session_lang = $this->session->userdata('language_shortcode'); $replace = array('{free_cancle_username}'); $with = array("{$free_cancle_username}"); $email_template_content_free_account = $this->email_template_model->get_email_template_by_id(8); if (isset($email_template_content_free_account[0]['description_' . $session_lang]) && !empty($email_template_content_free_account[0]['description_' . $session_lang])) { $cancellation_email_content_for_free = $email_template_content_free_account[0]['description_' . $session_lang]; $message = str_replace($replace, $with, $cancellation_email_content_for_free); $utf = "utf-8"; $content = "<html><meta charset='" . $utf . "'><body><div style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;'>{$message}</div></body></html>"; $this->email->message($content); } else { $cancellation_email_content_for_free = $email_template_content_free_account[0]['description_en']; $message = str_replace($replace, $with, $cancellation_email_content_for_free); $content = "<html><meta charset='" . $utf . "'><body><div style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;'>{$message}</div></body></html>"; $this->email->message($content); } //end changes // $message = $this->load->view('mail_templates/cancle_account_mail', $mail_data,true); // $this->email->message($message); // try send mail ant if not able print debug $this->email->send(); } $admin_email = $get_admin_detail['email']; if (valid_email($admin_email)) { // compose email $this->email->from($get_admin_detail['email'], $get_admin_detail['name']); $this->email->to($admin_email); $this->email->set_mailtype("html"); $this->email->subject('One Account has been cancled from knewdog!'); $mail_data['free_admin_cancle_account_type'] = get_type_of_membership_txt($type_of_membership); $mail_data['free_admin_cancle_answer'] = $answer; $mail_data['free_admin_cancle_user_email'] = $user_email; $mail_data['free_admin_cancle_username'] = $user_data[0]['username']; //bhushan changes $session_lang = $this->session->userdata('language_shortcode'); $replace = array('{free_admin_cancle_account_type}', '{free_admin_cancle_answer}', '{free_admin_cancle_username}', '{free_admin_cancle_user_email}'); $with = array("{$mail_data['free_admin_cancle_account_type']}", "{$mail_data['free_admin_cancle_answer']}", "{$mail_data['free_admin_cancle_username']}", "{$mail_data['free_admin_cancle_user_email']}"); $email_template_content_cancle_admin = $this->email_template_model->get_email_template_by_id(9); if (isset($email_template_content_cancle_admin[0]['description_' . $session_lang]) && !empty($email_template_content_cancle_admin[0]['description_' . $session_lang])) { $cancle_mail_free_account_admin = $email_template_content_cancle_admin[0]['description_' . $session_lang]; $message = str_replace($replace, $with, $cancle_mail_free_account_admin); $utf = "utf-8"; $content = "<html><meta charset='" . $utf . "'><body><div style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;'>{$message}</div></body></html>"; $this->email->message($content); } else { $cancle_mail_free_account_admin = $email_template_content_cancle_admin[0]['description_en']; $message = str_replace($replace, $with, $cancle_mail_free_account_admin); $content = "<html><meta charset='" . $utf . "'><body><div style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;'>{$message}</div></body></html>"; $this->email->message($content); } //end changes // try send mail ant if not able print debug $this->email->send(); } //Delete additional email $this->additional_email_model->delete_additional_email_by_userid($user_id); //Delete Invoice //$this->invoice_model->delete_invoice_by_userid($user_id); //Loged out if ($this->session->userdata('is_logged_in')) { $reuired_sessiondata = array('session_id' => $this->session->userdata('session_id'), 'ip_address' => $this->session->userdata('ip_address'), 'user_agent' => $this->session->userdata('user_agent'), 'last_activity' => $this->session->userdata('last_activity'), 'language_shortcode' => $this->session->userdata('language_shortcode')); $array_items = array('username' => '', 'user_id' => '', 'type_of_membership' => '', 'is_logged_in' => false); $this->session->unset_userdata($array_items); //$this->session->sess_destroy(); //set session required $this->session->set_userdata($reuired_sessiondata); $this->session->set_flashdata('flash_message', '<strong>' . _clang(WELL_DONE_YOUR_PROFILE) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-success'); $redirect_to_home = true; // redirect('home'); } } else { if ($type_of_membership == 'PRE1') { $array = array("type_of_membership" => 'FREE'); if (@$this->user_model->update_user($user_id, $array) == TRUE) { $this->session->set_flashdata('flash_message', '<strong>' . _clang(YOUR_PROFILE_RESET_TO) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-success'); $this->session->set_flashdata('flash_mynl_tab', 'tab_4'); //Delete all schedule //$this->schedule_model->delete_schedule_with_userid($user_id); //delete all subscribe //$this->subscribe_model->delete_subscribe_with_userid($user_id); //Moved to free user if ($this->session->userdata('is_logged_in')) { $this->session->unset_userdata(array('type_of_membership' => '')); $session = array('type_of_membership' => 'FREE'); //$this->session->set_userdata($session); } } else { $this->session->set_flashdata('flash_message', '<strong>' . _clang(OOPS_SOMETHING_WENT_WRONG) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-error'); $this->session->set_flashdata('flash_mynl_tab', 'tab_4'); } } else { if ($type_of_membership == 'PRE2') { $array = array("type_of_membership" => 'FREE'); if (@$this->user_model->update_user($user_id, $array) == TRUE) { $this->session->set_flashdata('flash_message', '<strong>' . _clang(YOUR_PROFILE_RESET_TO) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-success'); $this->session->set_flashdata('flash_mynl_tab', 'tab_4'); //Delete all schedule //$this->schedule_model->delete_schedule_with_userid($user_id); //delete all subscribe //$this->subscribe_model->delete_subscribe_with_userid($user_id); //Moved to free user if ($this->session->userdata('is_logged_in')) { $this->session->unset_userdata(array('type_of_membership' => '')); $session = array('type_of_membership' => 'FREE'); $this->session->set_userdata($session); } } else { $this->session->set_flashdata('flash_message', '<strong>' . _clang(OOPS_SOMETHING_WENT_WRONG) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-error'); $this->session->set_flashdata('flash_mynl_tab', 'tab_4'); } } } } //Sending mail if ($type_of_membership != 'FREE') { $this->load->helper('email'); //load email library $this->load->library('email'); //read parameters from $_POST using input class // check is email addrress valid or no //First mail to user $email = $user_data[0]['primary_email']; if (valid_email($email)) { // compose email // $get_admin_detail = // get_admin_detail(); //common helper function for admin detail $this->email->from($get_admin_detail['email'], $get_admin_detail['name']); $this->email->to($email); $this->email->set_mailtype("html"); $this->email->subject('Your Account has been cancled from knewdog!'); /* $message = '<style>p{margin-bottom:2px;}</style> <p>Your Password : '******'</p> <p>Thanks,<br/>KnewDog Team.</p>'; */ $invoice_data = $this->invoice_model->get_invoice_custome_query("select * from invoice where user_id = '" . $user_id . "' and payment_type like '" . $type_of_membership . "%' and date_to > curdate()"); $end_of_subscription = $invoice_data[0]["date_to"]; $start_of_subsription = $invoice_data[0]["date_from"]; $invoice_amount = $invoice_data[0]['amount'] * $invoice_data[0]['quantity']; $mail_data['cancle_amount'] = round(return_calculation($end_of_subscription, $start_of_subsription, $invoice_amount), 2); $mail_data['account_type'] = get_type_of_membership_txt($type_of_membership); $mail_data['cancle_username'] = $user_data[0]['username']; //bhushan changes $session_lang = $this->session->userdata('language_shortcode'); $replace = array('{account_type}', '{cancle_username}', '{cancle_amount}'); $with = array("{$mail_data['account_type']}", "{$mail_data['cancle_username']}", "{$mail_data['cancle_amount']}"); $email_template_content = $this->email_template_model->get_email_template_by_id(4); if (isset($email_template_content[0]['description_' . $session_lang]) && !empty($email_template_content[0]['description_' . $session_lang])) { $cancellation_email_content = $email_template_content[0]['description_' . $session_lang]; $message = str_replace($replace, $with, $cancellation_email_content); $utf = "utf-8"; $content = "<html><meta charset='" . $utf . "'><body><div style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;'>{$message}</div></body></html>"; $this->email->message($content); } else { $cancellation_email_content = $email_template_content[0]['description_en']; $message = str_replace($replace, $with, $cancellation_email_content); $content = "<html><meta charset='" . $utf . "'><body><div style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;'>{$message}</div></body></html>"; $this->email->message($content); } //end changes // $message = $this->load->view('mail_templates/cancle_account_mail', $mail_data,true); // $this->email->message($message); // try send mail ant if not able print debug $this->email->send(); } //second mail to admin $get_admin_detail = get_admin_detail(); //common helper function for admin detail $email = $get_admin_detail['email']; if (valid_email($email)) { // compose email $this->email->from($get_admin_detail['email'], $get_admin_detail['name']); $this->email->to($email); $this->email->set_mailtype("html"); $this->email->subject('One Account has been cancled from knewdog!'); $mail_data['account_type'] = get_type_of_membership_txt($type_of_membership); $mail_data['answer'] = $answer; $mail_data['user'] = $user_data[0]['username']; $mail_data['user_email'] = $user_data[0]['primary_email']; //$type_of_membership = $user_data[0]['type_of_membership']; //echo "select * from invoice where user_id = '".$user_id."' and payment_type like '".$type_of_membership."%' and date_to > curdate()"; $invoice_data = $this->invoice_model->get_invoice_custome_query("select * from invoice where user_id = '" . $user_id . "' and payment_type like '" . $type_of_membership . "%' and date_to > curdate()"); $end_of_subscription = $invoice_data[0]["date_to"]; $start_of_subsription = $invoice_data[0]["date_from"]; $invoice_amount = $invoice_data[0]['amount'] * $invoice_data[0]['quantity']; $mail_data['amount'] = round(return_calculation($end_of_subscription, $start_of_subsription, $invoice_amount), 2); //bhushan changes $session_lang = $this->session->userdata('language_shortcode'); $replace = array('{c_admin_account_type}', '{answer}', '{user}', '{user_email}', '{amount}'); $with = array("{$mail_data['account_type']}", "{$mail_data['answer']}", "{$mail_data['user']}", "{$mail_data['user_email']}", "{$mail_data['amount']}"); $email_template_content = $this->email_template_model->get_email_template_by_id(5); if (isset($email_template_content[0]['description_' . $session_lang]) && !empty($email_template_content[0]['description_' . $session_lang])) { $cancle_mail_account_admin = $email_template_content[0]['description_' . $session_lang]; $message = str_replace($replace, $with, $cancle_mail_account_admin); $utf = "utf-8"; $content = "<html><meta charset='" . $utf . "'><body><div style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;'>{$message}</div></body></html>"; $this->email->message($content); } else { $cancle_mail_account_admin = $email_template_content[0]['description_en']; $message = str_replace($replace, $with, $cancle_mail_account_admin); $content = "<html><meta charset='" . $utf . "'><body><div style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;'>{$message}</div></body></html>"; $this->email->message($content); } //end changes //echo '<pre>'; print_r($invoice_data); //echo print_r($mail_data); //die; // $message = $this->load->view('mail_templates/cancle_account_mail_admin', $mail_data,true); // $this->email->message($message); // try send mail ant if not able print debug $this->email->send(); } } //sending mail end if ($redirect_to_home == TRUE) { redirect('home'); } else { redirect('myknewdog'); } }
function cancle_account() { $user_id = $this->session->userdata("user_id"); $type_of_membership = $this->session->userdata("type_of_membership"); if ($type_of_membership == 'FREE') { //Delete user $this->user_model->delete_user($user_id); //$this->session->set_flashdata('flash_mynl_tab', 'tab_4'); //Delete all schedule $this->schedule_model->delete_schedule_with_userid($user_id); //delete all subscribe $this->subscribe_model->delete_subscribe_with_userid($user_id); //delete Newsletter review with process $get_newsletter_ids = $this->newsletter_model->get_newsletter_review('', '', '', '', '', '', array("join_user_id"), array($user_id)); $this->newsletter_model->delete_newsletter_review_with_userid($user_id); for ($i = 0; $i < count($get_newsletter_ids); $i++) { $avg_rate = get_average_rate($get_newsletter_ids[$i]['join_newsletter_id']); $rate = array("ratings" => $avg_rate["avg_round"]); //add average rate $this->newsletter_model->update_newsletter($get_newsletter_ids[$i]['join_newsletter_id'], $rate); } //Delete additional email $this->additional_email_model->delete_additional_email_by_userid($user_id); //Delete Invoice $this->invoice_model->delete_invoice_by_userid($user_id); //Loged out if ($this->session->userdata('is_logged_in')) { $reuired_sessiondata = array('session_id' => $this->session->userdata('session_id'), 'ip_address' => $this->session->userdata('ip_address'), 'user_agent' => $this->session->userdata('user_agent'), 'last_activity' => $this->session->userdata('last_activity'), 'language_shortcode' => $this->session->userdata('language_shortcode')); $array_items = array('username' => '', 'user_id' => '', 'type_of_membership' => '', 'is_logged_in' => false); $this->session->unset_userdata($array_items); //$this->session->sess_destroy(); //set session required $this->session->set_userdata($reuired_sessiondata); $this->session->set_flashdata('flash_message', '<strong>' . _clang(WELL_DONE_YOUR_PROFILE) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-success'); redirect('home'); } } else { if ($type_of_membership == 'PRE1') { $array = array("type_of_membership" => 'FREE'); if (@$this->user_model->update_user($user_id, $array) == TRUE) { $this->session->set_flashdata('flash_message', '<strong>' . _clang(YOUR_PROFILE_RESET_TO) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-success'); $this->session->set_flashdata('flash_mynl_tab', 'tab_4'); //Delete all schedule $this->schedule_model->delete_schedule_with_userid($user_id); //delete all subscribe $this->subscribe_model->delete_subscribe_with_userid($user_id); //Moved to free user if ($this->session->userdata('is_logged_in')) { $this->session->unset_userdata(array('type_of_membership' => '')); $session = array('type_of_membership' => 'FREE'); $this->session->set_userdata($session); } } else { $this->session->set_flashdata('flash_message', '<strong>' . _clang(OOPS_SOMETHING_WENT_WRONG) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-error'); $this->session->set_flashdata('flash_mynl_tab', 'tab_4'); } } else { if ($type_of_membership == 'PRE2') { $array = array("type_of_membership" => 'FREE'); if (@$this->user_model->update_user($user_id, $array) == TRUE) { $this->session->set_flashdata('flash_message', '<strong>' . _clang(YOUR_PROFILE_RESET_TO) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-success'); $this->session->set_flashdata('flash_mynl_tab', 'tab_4'); //Delete all schedule $this->schedule_model->delete_schedule_with_userid($user_id); //delete all subscribe $this->subscribe_model->delete_subscribe_with_userid($user_id); //Moved to free user if ($this->session->userdata('is_logged_in')) { $this->session->unset_userdata(array('type_of_membership' => '')); $session = array('type_of_membership' => 'FREE'); $this->session->set_userdata($session); } } else { $this->session->set_flashdata('flash_message', '<strong>' . _clang(OOPS_SOMETHING_WENT_WRONG) . '</strong>'); $this->session->set_flashdata('flash_class', 'alert-error'); $this->session->set_flashdata('flash_mynl_tab', 'tab_4'); } } } } redirect('myknewdog'); }
function deletereview() { $newsletter_id = $this->uri->segment(3); $newsletter_review_id = $this->uri->segment(4); $this->newsletter_model->delete_newsletter_review($newsletter_review_id); $this->session->set_flashdata('flash_class', 'alert-success'); $this->session->set_flashdata('flash_message', '<strong>' . _clang(WELL_DONE) . '</strong> ' . _clang(YOUR_REVIEW_DELETED_WITH) . ''); $avg_rate = get_average_rate($newsletter_id); $rate = array("ratings" => $avg_rate["avg_round"]); //add average rate $this->newsletter_model->update_newsletter($newsletter_id, $rate); redirect("newsletter/display-rate/" . $newsletter_id); }