if(!empty($post['data_da'])){
$data_da = date_local_format_to_iso($post['data_da']);
}else{
$data_da ='2000/01/01';
}
if(!empty($post['data_a'])){
$data_a = date_local_format_to_iso($post['data_a']);
}else{
$data_a ='2100/01/01';
}
$array_query=[];
if(!empty($post['id_tipo_spesa'])){
$id_tipo_spesa = $post['id_tipo_spesa'];
$array_query ['id_tipo_spesa'] = $id_tipo_spesa;
}
if(!empty($post['id_tipo_pagamento'])){
$id_tipo_pagamento = $post['id_tipo_pagamento'];
$array_query ["id_tipo_pagamento"] = $id_tipo_pagamento;
}
if(!empty($post['id_autisti_interni'])){
$id_autisti_interni = $post['id_autisti_interni'];
$array_query ["id_autisti_interni"] = $id_autisti_interni;
}
if(!empty($post['id_mezzi'])){
$id_mezzi = $post['id_mezzi'];
$array_query ["id_mezzi"] = $id_mezzi;
}
if(!count($array_query)){
$array_query="id!=0";
}
$spese = $spese_model->where('data>=',$data_da)
->where('data<=',$data_a)
->where($array_query)
->findAll();
//log_message('debug',$spese_model->getLastQuery());
$record_totali =$spese_model->countAllResults();