<?php
class Mflashreel extends Model
{
	function Mflashreel()
	{
		parent::Model();
	}
	
	function get_all(){
		$lang = $this->muser->user['lang'];
		
		$query = $this->db->from('reel_flash')->where('position > "0"')->where("lang",$lang)->orderby('position')->get();
		
		if($query->num_rows()==0){
			return false;
		}
		else{
			return $query->result();
		}
	}
	
	function get_allnext($nyelv = ""){
		$most = date('Y-m-d H:i:s',time());
		if($nyelv)
			$lang = $nyelv;
		else
			$lang = $this->muser->user['lang'];
		
		$query = $this->db->from('reel_flash')->where('position > "0"')->where('stop_date > "'.$most.'"')->where('start_date < "'.$most.'"')->where("lang",$lang)->orderby('position')->get();
		
		if($query->num_rows()==0){
			return false;
		}
		else{
			return $query->result();
		}
	}
	
	
	function get_row($id){
		$query = $this->db->from('reel_flash')->where('id',$id)->get();
		if($query->num_rows()!=1)
		{
			return false;
		}
		else
		{
			$query = $query->row();
			return $query;
		}
	}
	
	function newrow($uj){
		$lang = $this->muser->user['lang'];
		
		$query = " INSERT INTO `cadline2`.`reel_flash` VALUES( NULL, '".$lang."','".$uj->position."','".$uj->filename."', '".$uj->runtime."', '".$uj->link."', '".$uj->start."', '".$uj->stop."' )";
		
		$this->db->query($query);
	}
	
	function edit($uj,$id){
		$query = " UPDATE `cadline2`.`reel_flash` SET `position` = '".$uj->position."', `filename` = '".$uj->filename."', `runtime` = '".$uj->runtime."', `link` = '".$uj->link."', `start_date` = '".$uj->start."', `stop_date` = '".$uj->stop."' WHERE `id` = $id";
		
		$query = $this->db->query($query);
	}
	
	function del($id){
		$this->db->query(" UPDATE `cadline2`.`reel_flash` SET `position` = '0' WHERE id = $id;");
	}
	
}
?>