<?php
require_once (PATH_TABLES . "activity/ActivityEmailApprovalTable.php") ;
require_once (PATH_TABLES . "activity/ExpenseItemTable.php") ;
require_once (PATH_MODELS . "base/MasterBase.php") ;

class ActivityEmailApprovalClass extends MasterBase {
	function __construct($db) {
		$this->db 		= $db ;
		$this->tbl 		= ActivityEmailApprovalTable::C_TABLE ;
		$this->fldid 	= ActivityEmailApprovalTable::C_ID ;
		$this->fldid2 	= ActivityEmailApprovalTable::C_EMAIL_ID ;
		$this->flddesc 	= ActivityEmailApprovalTable::C_EMAIL_REMARKS ;
	}
	function __destruct() {
	}

	function deleteEmail($activity_id)
	{
		$sql=" DELETE FROM ".ActivityEmailApprovalTable::C_TABLE." WHERE ".ActivityEmailApprovalTable::C_ID." = ".$activity_id."";

		$this->db->executeSql($sql);
	}

	function updateContent($id,$datas) {
		$sql = "update " . $this->tbl . " set " ;
		$fs = "" ;
		$params = array() ;
		if (is_array($datas) && count($datas) > 0) {
			foreach ($datas as $data) {
				$sql .= $fs . $this->db->fieldParam($data['field']) ;
				$fs = ", " ;
				$params[] = $this->db->valueParam($data['field'],$data['value']) ;
			}
			$sql .= " where " . $this->db->fieldParam($this->fldid2) ;
			
			$params[] = $this->db->valueParam($this->fldid2,$id) ;
			return $this->db->updateRow($sql,$params) ;
		} else  {
			return false ;
		}
	}
}
?>