Advertisement
Guest User

CONTROLLER

a guest
Apr 5th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. function Email($data) {
  2.         $this->cart->destroy();
  3.         $this->load->model('barang');
  4.         $this->load->model('Cart');
  5.         $this->load->model('content');
  6.         $datacontent = $this->content->getDataContent();
  7.         $idPenjualan = array('Id'=>$data[0]['idPenjualan']);
  8.         $result = $this->Cart->getDataPenjualan($idPenjualan);
  9.         if($result[0]['transverVia']=='BCA') {
  10.             $result[0]['nomorRekening'] = $datacontent[0]['nomorRekening1'];
  11.             $result[0]['anBank'] = $datacontent[0]['anBank1'];
  12.         }
  13.         else if($result[0]['transverVia']=='BNI') {
  14.             $result[0]['nomorRekening'] = $datacontent[0]['nomorRekening2'];
  15.             $result[0]['anBank'] = $datacontent[0]['anBank2'];
  16.         }
  17.         else if($result[0]['transverVia']=='Mandiri') {
  18.             $result[0]['nomorRekening'] = $datacontent[0]['nomorRekening3'];
  19.             $result[0]['anBank'] = $datacontent[0]['anBank3'];
  20.         }
  21.         $dataPenjualan['Penjualan'] = $result;
  22.         $dataPenjualan['DetailPenjualan'] = $data;
  23.  
  24.         /*
  25.         echo "<pre>";
  26.         print_r($dataPenjualan);
  27.         echo "</pre>";
  28.         */
  29.         $dataEmail['dataPenjualan'] = $dataPenjualan;
  30.         //-----------------------------------------------//
  31.  
  32.        
  33.         $sender_email = "rizalubuntuuser@gmail.com";
  34.         $user_password = "";
  35.         //$receiver_email = "rizalubuntuuser@gmail.com";
  36.         $username = 'Rizal';
  37.         $subject = 'Republik Jaya Motor';
  38.         $message =  $this->load->view('email', $dataEmail, TRUE); ;
  39.        
  40.         $config['protocol'] = 'smtp';
  41.         $config['smtp_host'] = 'ssl://smtp.googlemail.com';
  42.         $config['smtp_port'] = 465;
  43.         $config['smtp_user'] = $sender_email;
  44.         $config['smtp_pass'] = $user_password;
  45.         $config['mailtype'] = 'html';
  46.         $config['charset']  = 'utf-8';
  47.             // Load email library and passing configured values to email library
  48.         $this->load->library('email', $config);
  49.         $this->email->set_newline("\r\n");
  50.             // Sender email address
  51.         $this->email->from($sender_email, $username);
  52.         // Receiver email address
  53.         $this->email->to($result[0]['email']);
  54.         // Subject of email
  55.         $this->email->subject($subject);
  56.         // Message in email
  57.         $this->email->message($message);
  58.  
  59.         if ($this->email->send()) {
  60.             echo 'Email Successfully Send !';
  61.             redirect('home');
  62.         } else {
  63.             echo '<p class="error_msg">Invalid Gmail Account or Password !</p>';
  64.         }
  65.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement