<?php

	
	$model['c'] = array(
		'id'		=> false
	);
	$model['l'] = array(
		'id'		=> false
	);
	$crud = new Crud("tbl_avto",$model);
	
	if (isset($REQUEST_URI[2]) && is_numeric($REQUEST_URI[2])) {
		if($REQUEST_URI[3] == 'delete') {
			$crud->delete($REQUEST_URI[2]);
		} elseif($REQUEST_URI[3] == 'deactivate') {
			$crud->deactivate($REQUEST_URI[2]);
		} elseif($REQUEST_URI[3] == 'activate') {
			$crud->deactivate($REQUEST_URI[2],'activate');
		} elseif($REQUEST_URI[3] == 'edit') {	//todo: RENDER FORM
			$crud->edit($REQUEST_URI[2]);
		}
	}
	if (isset($_POST) && !empty($_POST)) {
		
		//MANUALY DO THE VALIDATION AND INSERT/UPDATE
		$sql = "INSERT INTO tbl_pot SET 
				od = '{$_POST['f_od']}',
				do = '{$_POST['f_do']}',
				km = '{$_POST['f_km']}',
				teza = '{$_POST['f_teza']}'";
		$db->save($sql);
	}
	
	
	$crud->renderTable();
?>