<?php



defined('BASEPATH') OR exit('No direct script access allowed');







class Template_email extends CI_Controller {







	public function __construct(){



        parent::__construct();		



        $this->load->model('M_template_email');



        $this->load->library('upload');



        $this->load->library('mailer');



    }



    private function send_mail($penerima,$pesan,$subjek){



    	



    	$template_email = $this->M_template_email->select_data_template_email()->row_array();







        $email_penerima = $penerima;



        



        $logo = base_url('assets/img/logo.png');



        // $attachment = $_FILES['attachment'];







        $content = $this->load->view('template_email/test/test_header_footer', array('pesan'=>$pesan,'logo'=>$logo,'template_email'=>$template_email), true); // Ambil isi file content.php dan masukan ke variabel $content



        $sendmail = array(



          'email_penerima'=>$email_penerima,



          'subjek'=>$subjek,



          'content'=>$content



          // 'attachment'=>$attachment



        );



        $send = $this->mailer->send($sendmail); 



        return $send;



     }



	public function ambil_header_footer()



	{



		$respon = $this->M_template_email->ambil_header_footer()->row_array();



		echo json_encode($respon);



	}



	public function update_header_footer()



	{



		$data["id_template_email"] = $this->input->post('id_template_email',TRUE);



		$data["header"] = $this->input->post('header',TRUE);



		$data["footer"] = $this->input->post('footer',TRUE);



		$respon = $this->M_template_email->update_header_footer($data);



		echo json_encode($respon);



	}



	public function test_header_footer()



	{



		$subjek = "Tes Header & Footer";



        $pesan = "--------- Pesan Disini --------";



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



	}



	public function update_adm_reg()



	{



		$data["id_template_email"] = $this->input->post('id_template_email',TRUE);



		$data["sjk_adm_reg"] = $this->input->post('sjk_adm_reg',TRUE);



		$data["msg_adm_reg"] = $this->input->post('msg_adm_reg',TRUE);



		$respon = $this->M_template_email->update_adm_reg($data);



		echo json_encode($respon);



	}



	public function test_adm_reg()



	{



		$data["sjk_adm_reg"] = $this->input->post('sjk_adm_reg',TRUE);



		$data["msg_adm_reg"] = $this->input->post('msg_adm_reg',TRUE);



		$subjek = $data["sjk_adm_reg"];



        $pesan = $data["msg_adm_reg"];



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



	}



	public function update_user_reg()



	{



		$data["id_template_email"] = $this->input->post('id_template_email_user',TRUE);



		$data["sjk_user_reg"] = $this->input->post('sjk_user_reg',TRUE);



		$data["msg_user_reg"] = $this->input->post('msg_user_reg',TRUE);



		$respon = $this->M_template_email->update_user_reg($data);



		echo json_encode($respon);



	}



	public function test_user_reg()



	{



		$subjek = $this->input->post('sjk_user_reg',TRUE);



        $pesan = $this->input->post('msg_user_reg',TRUE);



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



	}



	public function update_user_reg_acc()



	{



		$data["id_template_email"] = $this->input->post('id_template_email_user_acc',TRUE);



		$data["sjk_user_reg_acc"] = $this->input->post('sjk_user_reg_acc',TRUE);



		$data["msg_user_reg_acc"] = $this->input->post('msg_user_reg_acc',TRUE);



		$respon = $this->M_template_email->update_user_reg_acc($data);



		echo json_encode($respon);



	}



	public function test_user_reg_acc()



	{



		$subjek = $this->input->post('sjk_user_reg_acc',TRUE);



        $pesan = $this->input->post('msg_user_reg_acc',TRUE);



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



	}



	public function update_user_reg_rjk()



	{



		$data["id_template_email"] = $this->input->post('id_template_email_user_rjk',TRUE);



		$data["sjk_user_reg_rjk"] = $this->input->post('sjk_user_reg_rjk',TRUE);



		$data["msg_user_reg_rjk"] = $this->input->post('msg_user_reg_rjk',TRUE);



		$respon = $this->M_template_email->update_user_reg_rjk($data);



		echo json_encode($respon);



	}



	public function test_user_reg_rjk()



	{



		$subjek = $this->input->post('sjk_user_reg_rjk',TRUE);



        $pesan = $this->input->post('msg_user_reg_rjk',TRUE);



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



        



	}



	public function update_user_acc_pka()



	{



		$data["id_template_email"] = $this->input->post('id_template_email_user_acc_pka',TRUE);



		$data["sjk_user_acc_pka"] = $this->input->post('sjk_user_acc_pka',TRUE);



		$data["msg_user_acc_pka"] = $this->input->post('msg_user_acc_pka',TRUE);



		$respon = $this->M_template_email->update_user_acc_pka($data);



		echo json_encode($respon);



	}



	public function test_user_acc_pka()



	{



		$subjek = $this->input->post('sjk_user_acc_pka',TRUE);



        $pesan = $this->input->post('msg_user_acc_pka',TRUE);



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



        



	}



	public function update_user_rev_pka()



	{



		$data["id_template_email"] = $this->input->post('id_template_email_user_rev_pka',TRUE);



		$data["sjk_user_rev_pka"] = $this->input->post('sjk_user_rev_pka',TRUE);



		$data["msg_user_rev_pka"] = $this->input->post('msg_user_rev_pka',TRUE);



		$respon = $this->M_template_email->update_user_rev_pka($data);



		echo json_encode($respon);



	}



	public function test_user_rev_pka()



	{



		$subjek = $this->input->post('sjk_user_rev_pka',TRUE);



        $pesan = $this->input->post('msg_user_rev_pka',TRUE);



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



        



	}



	public function update_adm_send_ev_pka()



	{



		$data["id_template_email"] = $this->input->post('id_template_email_adm_send_ev_pka',TRUE);



		$data["sjk_adm_send_ev_pka"] = $this->input->post('sjk_adm_send_ev_pka',TRUE);



		$data["msg_adm_send_ev_pka"] = $this->input->post('msg_adm_send_ev_pka',TRUE);



		$respon = $this->M_template_email->update_adm_send_ev_pka($data);



		echo json_encode($respon);



	}



	public function test_adm_send_ev_pka()



	{



		$subjek = $this->input->post('sjk_adm_send_ev_pka',TRUE);



        $pesan = $this->input->post('msg_adm_send_ev_pka',TRUE);



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



        



	}



	public function update_user_rev_ev_pka()



	{



		$data["id_template_email"] = $this->input->post('id_template_email_user_rev_ev_pka',TRUE);



		$data["sjk_user_rev_ev_pka"] = $this->input->post('sjk_user_rev_ev_pka',TRUE);



		$data["msg_user_rev_ev_pka"] = $this->input->post('msg_user_rev_ev_pka',TRUE);



		$respon = $this->M_template_email->update_user_rev_ev_pka($data);



		echo json_encode($respon);



	}



	public function test_user_rev_ev_pka()



	{



		$subjek = $this->input->post('sjk_user_rev_ev_pka',TRUE);



        $pesan = $this->input->post('msg_user_rev_ev_pka',TRUE);



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



        



	}



	public function update_user_acc_ev_pka()



	{



		$data["id_template_email"] = $this->input->post('id_template_email_user_acc_ev_pka',TRUE);



		$data["sjk_user_acc_ev_pka"] = $this->input->post('sjk_user_acc_ev_pka',TRUE);



		$data["msg_user_acc_ev_pka"] = $this->input->post('msg_user_acc_ev_pka',TRUE);



		$respon = $this->M_template_email->update_user_acc_ev_pka($data);



		echo json_encode($respon);



	}



	public function test_user_acc_ev_pka()



	{



		$subjek = $this->input->post('sjk_user_acc_ev_pka',TRUE);



        $pesan = $this->input->post('msg_user_acc_ev_pka',TRUE);



        $mail = $this->M_template_email->ambil_email()->row_array();



        $send_mail = $this->send_mail($mail['email'],$pesan,$subjek);



        if ($send_mail['status'] == "Sukses") {



        	echo json_encode(true);



        }else{



        	echo json_encode(false);



        }



        



	}



}



