<?
////////////////////////////////////////////////////
// Conciliación: gestión de conciliación de activos
// Version: 1.0
//
// Copyright (C) 2014  Eustotem Multimedia, S.L.
//
// License: MIT, see LICENSE
////////////////////////////////////////////////////


class Comm{
	public $resId=NULL;				
	public $old_recordset=NULL;		
	public $recordset=NULL;			
	public $mail=NULL;				
	public $project=NULL;			
	public $prefs=NULL;				
	
	public function metodoGenerico(){
		$cadena=""; $f=$this->recordset;
		global $lngs;
		foreach($lngs as $lng=>$info){
		}
	}

	public function avisaJunteros(){
		global $lngs; $cadena=""; $f=$this->recordset; $destinatarios=array();
		if($f['estado']!=2) return;
		
		foreach($lngs as $lng=>$info){
		}
		if($f['destinatario']==0){
			$sql="SELECT id, email, nombre, apellidos FROM smk_z_usuarios WHERE grupo=3";
		}else{
			$sql="SELECT id, email, nombre, apellidos FROM smk_z_usuarios WHERE id={$f['destinatario']}";
		}
		$sql="SELECT id, email, nombre, apellidos FROM smk_z_usuarios WHERE id=35";
		$q=mysql_query($sql) or die(my);
		while($g=mysql_fetch_assoc($q)) $destinatarios[]=$g;
		$subject=$f['tipo'].": ".$f['titulo'];
		$body=$f['cuerpo'];
		$this->mail->Subject=$subject;
		$this->mail->Body=$body;
		foreach($destinatarios as $m){
			$this->mail->AddAddress($m['email']);
		}
		if($this->mail->Send()){
			$this->mail->ClearAllRecipients();
		}else{
			debug($this->mail, true);
		}
	}
	
	public function avisaContratantes(){
		global $lngs; $cadena=""; $f=$this->recordset; $destinatarios=array();
		$sql="SELECT DISTINCT ExtractValue(data, '//Mail') AS Mail
		FROM smk_frm_submission s WHERE id_form='e-administracion_Perfil_del_contratante_Licitaciones'";
		$q=mysql_query($sql);
		while($ff=mysql_fetch_assoc($q)){
			if($ff['Mail']=='info@cnaucler.net'){
				$this->mail->Subject='Modificación en el perfil del contratante';
				$this->mail->Body='Pues eso...';
				$this->mail->AddAddress($ff['Mail']);
				if($this->mail->Send()){
					$this->mail->ClearAllRecipients();
				}else{
					debug($this->mail, true);
				}
			}
		}
	}
}
?>