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

class Email_template extends CI_Controller {
var $role = array();
	public function __construct() {
		parent::__construct();
		date_default_timezone_set("Asia/Kolkata");
		$this->load->model('Template_model');
        $this->load->helper('generals_helper');
		if(!$this->session->userdata('logged_in')) {
			redirect(base_url());
$this->role = roleManagement();
          $role = roleManagement();
if(!array_key_exists('Template',$role)){
            redirect(base_url('Pages/privileagepage'));
        }


			
		}
	}
	
	public function index() {
		 // if(!in_array('List',$this->role['Template'])){
   //          redirect(base_url('Dashboard'));
   //      }
        $template['page'] = 'Email_template/notification';
		$template['menu'] = "Notification Templates";
		$template['smenu'] = "Change Notification Templates";
        $template['pTitle'] = "Notification Templates";
        $template['page_head'] = "Notification Templates";
        $template['pDescription'] = "Change Notification Templates";

		$template['notificationData'] = $this->Template_model->getNotifData();
		$this->load->view('template',$template);
	}

	public function changeNotifData(){
		$url = 'Email_template';
		$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
		if(!isset($_POST) || empty($_POST)){
			$this->session->set_flashdata('message',$flashMsg);
            redirect(base_url($url));
		}
	    
		
	    if(!isset($_POST['registration_mail']) || empty($_POST['registration_mail'])){
			unset($_POST['registration_mail']);
		}
		if(!isset($_POST['shopper_mail']) || empty($_POST['shopper_mail'])){
			unset($_POST['shopper_mail']);
		}
		

        $status = $this->Template_model->updateNotif($_POST);
 		if($status){
 			$flashMsg['class'] = 'success'; 
 			$flashMsg['message'] = 'Notification Templates Successfully Updated..!';
 		}
 		$this->session->set_flashdata('message',$flashMsg);
        redirect(base_url($url));
	}
}
?>