Customer.php 7.56 KB
<?php

defined('BASEPATH') OR exit('No direct script access allowed');
// For Amazon Simple Email Service
// Begin

/*use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'C:/Workspace/phpmailer/vendor/autoload.php';
echo "sdfs";exit();*/
// end

class Customer extends CI_Controller {
	public function __construct() {
	parent::__construct();		
		date_default_timezone_set("Asia/Kolkata");
		$this->load->model('Customer_model');	
		$this->load->helper('access');	
		if(!$this->session->userdata('logged_in')) { 
			redirect(base_url());
		}
		$class = $this->router->fetch_class();
        $method = $this->router->fetch_method();
        $r = check_access($class,$method);
        // $r);exit();
        if($r == false)
        {
            redirect(base_url().'welcome/error_404');
        }
    }

        public function test2(){
        	
        $data = '{"name":"Anju","email":"anju.techware@gmail.com","message" :"Hi Team"}';
        $this->load->library('email');
        $config = Array(
                'protocol' => 'smtp',
                'smtp_host' => 'ssl://in-v3.mailjet.com',
                'smtp_port' => 465,
                'smtp_user' => '5e7ae616f1b582180ca64a4d23c159eb', // change it to yours
                'smtp_pass' => '0961ab46deb93945831967ca63ba0438', // change it to yours
                'smtp_timeout'=>30,
                'mailtype' => 'html',
                'charset' => 'iso-8859-1',
                'wordwrap' => TRUE,
                'newline' => '\r\n'
                  
               );

         $this->email->initialize($config);// add this line

      $subject = 'New Mail';
      $name= $data->name;
      $mailTemplate=$data->message;

      $name = 'sadasdasd';
      $to = 'anju.techware@gmail.com';
      $subject = 'asdsadasd';
      $mailTemplate = 'test message';

        //$this->email->set_newline("\r\n");
        $this->email->from('mail@mailjet.com', $name);
        $this->email->to($to);
        $this->email->subject($subject);
        $this->email->message($mailTemplate);  
        echo $this->email->send();

        // $this->email->_response_code); //200 success


        $this->email->print_debugger();


    }
	public function mytest(){
        
		$mail = new PHPMailer(true); 

		try {
			//Server settings
			$mail->SMTPDebug = 2;                                 
			$mail->isSMTP();                                      
			$mail->Host = 'email-smtp.eu-west-1.amazonaws.com'; 
			$mail->SMTPAuth = true;                               
			$mail->Username = 'AKIAJSARUYNQ6JILLDEA';                 
			$mail->Password = 'AlGnHXKNoQRCrIqZzXUzdRPR94ENkLO3TXfSqIKBlpSA';                           
			$mail->SMTPSecure = 'tls';                            
			$mail->Port = 587;                                    

			//Recipients
			$mail->setFrom('nyhasinas@gmail.com', 'Ipakkie Mailer');
			// $mail->addAddress('rilakely@yahoo.com', 'Rila User');     // Add a recipient
$mail->addAddress('anju.techware@gmail.com', 'Anju User'); 
			//Content
			$mail->isHTML(true);                                  // Set email format to HTML
			$mail->Subject = 'Here is the subject11';
			$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
			$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

			$mail->send();
			//echo 'Message has been sent';
			//echo $mail->send();
			 $mail->print_debugger();
		} catch (Exception $e) {
			echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
		}		
    }
    
     public function view_customer(){

			  $template['page'] = "Customer/view-customers";
			  $template['page_title'] = "Customer Details";
			  $template['data'] = $this->Customer_model->get_customer();
			  //$template['verification']= $this->Customer_model->get_verification();
			  $this->load->view('template',$template);
	 }


	 public function edit_customer() {
		
		$template['page'] = 'Customer/edit-customer';
		$template['page_title'] = "Edit Customer";
		
		$id = $this->uri->segment(3);
		$template['data'] = $this->Customer_model->get_single_customer($id);
		if(!empty($template['data'])) {
		if($_POST) {
			$data = $_POST;
			unset($data['submit']);
			
			// if(isset($_FILES['image'])) {
			// 	$config = $this->set_upload_options();
			
			// 	$this->load->library('upload');
			// 	$this->upload->initialize($config);
				
			// 	if ( ! $this->upload->do_upload('image')) {
			// 		unset($data['image']);
			// 	}
			// 	else {
			// 		//$data['image'] = base_url().$config['upload_path']."/".$_FILES['image']['name'];
			// 		$upload_data = $this->upload->data();
			// 		$data['image'] = base_url().$config['upload_path']."/".$upload_data['file_name'];
			// 	}
			// }
			
			//$data['created_user'] = $this->session->userdata('logged_in')['id'];
			$result = $this->Customer_model->update_customer($data, $id);
		//	array_walk($data, "remove_html");
			$this->session->set_flashdata('message', array('message' => 'Customer Updated Successfully','class' => 'success'));
     		redirect(base_url().'customer/view_customer');
		}
		else {
   			$this->load->view('template', $template);
		}
		}
		
	}

		



     public function delete_customer(){		      
		  $id = $this->uri->segment(3);
		  $result= $this->Customer_model->customer_delete($id);
		  $this->session->set_flashdata('message', array('message' => 'Requested Customer Deleted Successfully','class' => 'success'));
	      redirect(base_url().'Customer/view_customer');
	 }		 		 	 
	public function customer_viewpopup() {  
		$id=$_POST['patientdetailsval'];
		
		$template['data'] = $this->Customer_model->view_popup_customer($id);
		  
		$this->load->view('Customer/customer-view-popup',$template);
	}

	public function upload_goverment(){
		$id = $this->uri->segment(3);
		$template['page']       = 'Customer/upload_govt_id';
        $template['page_title'] = "view offers";
        if(isset($_POST)){
        	if(!empty($_POST)){
        		$data = $_POST;
        		// $data);exit();

		       	if(!empty($_FILES)) {
		       	 //$data=$_POST;die;
		         	$fileName =$_FILES['file']['name'];
					$fileName = str_replace('%','a',$fileName);
					$fileName = 'tukkibi'.'_'.time().".".$fileName;
					$config = set_upload_options('./assets/uploads/profile_pic/'); 
		         	$config['file_name'] = $fileName;
		         	$this->load->library('upload', $config);
			        if (!$this->upload->do_upload('file')) {
			            $error = array('error' => $this->upload->display_errors('', '')); 
			            $res = array(
								"status"=> "error",
								"error"=> "Upload Error",
								"message"=> "Sorry! Promocode Image not uploaded".$error['error']
							);
			        }	
			        else { 				         	
			            $imagedata = $this->upload->data(); 
			           $data['image']= base_url().'/assets/uploads/profile_pic/'.$imagedata['file_name'];

			          
			           // $data['image']);
					}
					$data['user_id']=$id;
                    $result=$this->Customer_model->goverment_id_upload($data);
                    if($result){
                    	$this->session->set_flashdata('message', array('message' => 'Uploaded Goverment Id Successfully','class' => 'success'));
                    	redirect(base_url().'customer/view_customer');

                    }
					// $data);exit();
		      }
        	}
        }
 		
 		
        $this->load->view('template', $template);

	}

	function set_upload_options($path) {
	//upload an image options
	$config = array();
	$config['upload_path']   = $path; 
	$config['allowed_types'] = 'jpg|jpeg|png|gif'; 
	$config['max_size']      = 0; 
	$config['max_width']     = 0; 
	$config['max_height']    = 0; 
	return $config;
}



}