<?php

function GetFilter($aFilterSearchArg) {
	//	echo "test -> ".$aFilterSearchArg." <- filter"; 
		if ($aFilterSearchArg) {
		
			$filters = json_decode($aFilterSearchArg);
        
	        ($filters->ime != null ? $filter[] = "v.firstname LIKE '%".$filters->ime."%'" : null);
	        ($filters->priimek != null ? $filter[] = "v.surname LIKE '%".$filters->priimek."%'" : null);
	        ($filters->naslov != null ? $filter[] = "v.address LIKE '%".$filters->naslov."%'" : null);
	        ($filters->postna_st != null ? $filter[] = "v.post_code = '".$filters->postna_st."'" : null);
	        ($filters->kraj != null ? $filter[] = "v.city LIKE '%".$filters->kraj."%'" : null);
	        ($filters->email != null ? $filter[] = "v.email LIKE '%".$filters->email."%'" : null);
	        ($filters->tel1 != null ? $filter[] = "v.phone1 = '".$filters->tel1."'" : null);
	        ($filters->tel2 != null ? $filter[] = "v.phone2 = '".$filters->tel2."'" : null);
	        ($filters->tp_team != null ? $filter[] = "p.presentation_team = '".$filters->tp_team."'" : null);
	        ($filters->tp_city != null ? $filter[] = "p.presentation_city = '".$filters->tp_city."'" : null);
	        ($filters->tp_date != null ? $filter[] = "p.presentation_date = '".$filters->tp_date."'" : null);
	        ($filters->tp_time != null ? $filter[] = "p.presentation_time = '".$filters->tp_time."'" : null);
	        ($filters->izdelek != null ? $filter[] = "v.article_id = '".$filters->izdelek."'" : null);
	        ($filters->order_article_amount != null ? $filter[] = "v.product_amount = '".$filters->order_article_amount."'" : null);
	        ($filters->order_article_price != null ? $filter[] = "v.product_price = '".$filters->order_article_price."'" : null);
	        ($filters->order_status != null ? $filter[] = "v.order_status = '".$filters->order_status."'" : null);
	        ($filters->dorder_date_from != null ? $filter[] = "v.DATE(v.order_date) >= STR_TO_DATE('".$filters->dorder_date_from."', '%d.%m.%Y')" : null);
	        ($filters->dorder_date_to != null ? $filter[] = "v.DATE(v.order_date) <= STR_TO_DATE('".$filters->dorder_date_to."', '%d.%m.%Y')" : null);
	        ($filters->d_ime != null ? $filter[] = "v.order_date LIKE '%".$filters->d_ime."%'" : null);
	        ($filters->d_priimek != null ? $filter[] = "v.delivery_surname LIKE '%".$filters->d_priimek."%'" : null);
	        ($filters->d_naslov != null ? $filter[] = "v.delivery_address LIKE '%".$filters->d_naslov."%'" : null);
	        ($filters->d_postna_st != null ? $filter[] = "v.delivery_post_code = '".$filters->d_postna_st."'" : null);
	        ($filters->d_kraj != null ? $filter[] = "v.delivery_city LIKE '%".$filters->d_kraj."%'" : null);
		} else {
			$filter[] = "1 = 1";
		}

	return $filter;
}

?>