<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class App_utilities{
	function __construct(){
		$this->CI =& get_instance();	
	}
	
	function send($mensaje,$empresa){
		$config = Array(
			'protocol' => 'smtp',
			'smtp_host' => 'mail.smtp2go.com',
			'smtp_port' => 2525,
			'mailtype' => 'html',
			'smtp_user' => 'codigofashion.com',
			'smtp_pass' => 'nFUISUC61gku'
		);

		$this->CI->load->library('email',$config);
		$this->CI->email->set_newline("\r\n");
		$this->CI->email->from("cortes@codigofashion.com");
		
		$this->CI->email->to("omararper@gmail.com,stephanie@paparazzi.com.sv");
		//$this->CI->email->to("omararper@gmail.com");
        $this->CI->email->subject("Ventas ".$empresa." ".$this->fechaHoraElSalvador(date("Y-m-d"),1));
        
		$this->CI->email->message($mensaje);
		
		if($this->CI->email->send()){
		    return "Enviado";
		}else{
		    return "No Enviado";
		}
    }

    function fechaHoraElSalvador($timestamp,$type) {
		date_default_timezone_set('UTC');
		date_default_timezone_set("America/El_Salvador");
		$hora = strftime("%I:%M:%S %p", strtotime($timestamp));
		setlocale(LC_TIME, 'spanish');
		$fecha = utf8_encode(strftime("%A %d de %B del %Y", strtotime($timestamp)));
		$fecha_only = utf8_encode(strftime("%d de %B del %Y", strtotime($timestamp)));
		switch($type){
			case 0: return $fecha." a las ".$hora; break;
			case 1: return $fecha; break;
			case 2: return $hora; break;
			case 3: return $fecha_only; break;
		}
	}
}
?>