<?php
	include 'webroot/iso/_all_reports.php';
	include 'webroot/iso/my/html/f.php';
	
	
	
	class HomeController extends AppController {
	
		var $name = 'Home';
		var $uses = array();
		
		function  beforeFilter() {
			parent::beforeFilter();
			
			if(isset($_SESSION['Auth']['User']['id']) && $_SESSION['Auth']['User']['id'] > 0){
				$this->Auth->allow('index');
			}
		}
		
		
		function index(){
			/*
			$la_time = get_mailer_time_data();
			
			$l_tip_prog = get_item('select value from settings where name = "tipprog" ');
			
			$x = get_data('select id, name, redoslijed from reports where app_type = "'.$l_tip_prog.'" order by redoslijed ', 1);
			for($i = 0; $i < sizeof($x['id']); $i++){
				break;
				
				$l_sql = 'select mailer.id, mailer.creation_date, mailer.automatic, mailer.sent_to_owner, mailer.sent_to_accounting '.
					' from mailer '.
					' where mailer.report_id = '.$x['id'][$i].
					' and mailer_report_type_id = 2 '.
					' and mailer.creation_date = "'.$la_time['en']['last'].'" '.
					' and automatic = 1 '.
					' order by mailer.id desc limit 1 ';
					
				$y = get_data($l_sql, 0);
				
				if(empty($y['id'])){
					$l_rbr = 0;
				}else{
					$l_rbr = $y['id'];
				}
				$l_sent = create_accounting_report_and_send($l_rbr, $i, $x, $y, $la_time);
				if($l_sent == 1){
					break;
				}
				
				
				
				$l_sql = 'select mailer.id, mailer.creation_date, mailer.creation_time, mailer.automatic, mailer.sent_to_owner '.
					' from mailer '.
					' where mailer.report_id = '.$x['id'][$i].
					' and mailer_report_type_id = 1 '.
					' and mailer.creation_date = "'.$la_time['en']['today'].'" '.
					' and automatic = 1 '.
					' order by mailer.id desc limit 1 ';
				
				$y = get_data($l_sql, 0);
				
				if(empty($y['id'])){
					$l_rbr = 0;
				}else{
					$l_rbr = $y['id'];
				}
				$l_sent = create_owner_report_and_send($l_rbr, $i, $x, $y, $la_time);
				if($l_sent == 1){
					break;
				}
			}
			
			*/
		}
		
	
		function view($id = null) {
		}
	
		function add() {
		}
	
		function edit($id = null) {
		}
	
		function delete($id = null) {
		}
	}
?>