<?php
    ob_start();
	include("include/config.php");
	require_once "include/Database_functions.php";
	function dateDiff($start, $end) {
	  $start_ts = strtotime($start);
	  $end_ts = strtotime($end);
	  $diff = $end_ts - $start_ts;
	  return round($diff / 86400);
	}
	$vechno =  $_GET['vechno'];
	$start =  $_GET['start'];
	$finish =  $_GET['finish'];
	$date1 = date('Y-m-d',strtotime($start));
	$date2 = date('Y-m-d',strtotime($finish));
	
    //Get number of days deference between current date and given date.
    $datediff = dateDiff($date1,$date2);

	$vehicle = mysql_query("select * from cf_vehicle where id = $vechno");
	$rw = mysql_fetch_object($vehicle);
	$haulting_id = $rw->haulting_charge;
	
	$hault = mysql_query("select * from cf_hault where hault_id = $haulting_id");
	$rwhault = mysql_fetch_object($hault);
	$hault_amount = $rwhault->hault_amt;
	$totalhaultamount = 0;
	if($datediff>2){
	$haultdays = $datediff-2;
	$totalhaultamount = $hault_amount * $haultdays;
	}
	echo $totalhaultamount;
	
	
	?>
	