<?php
/*
 * sqlFilterInOut
 * create filter in and out for questions
 * @return array
 * */
 
class sqlFilterInOut{
	public $AllArr;
	public $filtersArr;
	public $spre1;
	
	/*construct
	 * @param filterArr -> celotno polje iz baze
	 * @param spre1
	 * */
	public function __construct($AllArr, $spre1){
		$this->AllArr	= $AllArr;
		$this->spre1	= $spre1;
	}
	
	/*
	 * function: createFilterArray
	 * @patam AllArr
	 * @param arr
	 * */
	public function createFilterArray(){
		//Prečistimo array
		$AllArr = $this->AllArr;
		$arr = array();
		for ($item = 0;$item<sizeof($AllArr);$item++){
			//Preverjanje
			$goto	= $AllArr[$item]['goto'];
			$fil	= $AllArr[$item]['fil'];
			if($goto == '')$goto = false;
			if($fil == '') $fil	 = false;
			
			$AllArr[$item]['ime']=array(
				"ime" 	=> $AllArr[$item]['ime'],
				"goto"	=> $goto,
				"fil"	=> $fil
				);
			array_push(	$arr, $AllArr[$item]['ime']);
		}
		$this->filtersArr = $arr;
	}
	
	/*
	 * function cretateFilterArrayGoto
	 * samo za preskoke
	 * */
	public function createFilterArrayGoto(){
		$AllArr = $this->AllArr;
		$arr = array();
		for($item = 0; $item<sizeof($AllArr); $item++){
			$goto = $AllArr[$item]['goto'];
			if($goto == '') $goto = false;
			$br=array(
				"ime" 	=> $AllArr[$item]['ime'],
				"goto"	=> $goto,
				);
			array_push(	$arr, $AllArr[$item]['ime']);
			$arr[$AllArr[$item]['ime']] = $br; //defined key as ime
		}
		
		$this->filtersArr = $arr;
	}
	
	/*
	 * function: returnJsonArray
	 * @return array
	 * */
	public function returnJsonArray(){
		return $this->filtersArr;
	}
}
/*
	$input = array(
        'q1' =>array(1=>'q1==2->q4', 2=>'q1==1->q7'),
		'q2' =>array(1=>'Q2<2->Q4'),
		'q3' =>array(1=>'Q3==a->Q5'),
		'q4' =>array(1=>false),
		'q5' =>array(1=>'Q1==aa->Q7'),
		'q6' =>array(1=>false),
		'q7' =>array(1=>false),
		'q8' =>array(1=>false),
		'q9' =>array(1=>false),
		'q10' =>array(1=>'Q1==aa->Q3', 2=>'Q1==ab->Q3')
     );
    echo json_encode($input);
    /*
     * Pravila
     * 
     * */
     //echo json_encode($ArrReturn);
?>