<?php 

include('include/auth.php');
$startdate=$_GET['sdateg3'];
$enddate=$_GET['edateg'];
$cargroup=$_GET['cargroup'];

	include('include/head.php');

                   
                    $sql11 = $db->query("SELECT * FROM jos8r_vikrentcar_categories WHERE jos8r_vikrentcar_categories.vtype='$cargroup'");
                    $rowcats = $sql11->fetch_row();
                                         
        
         $idgrp=$cargroup;
         $categorise=$cargroup.";".$idgrp.";";
         
 if ($idgrp==4){
     $car1=1;
     $car2=29;
     $car3=48;
     $car4=57;
     $car5=60;
     $car6=61;
     $car7=72;
     $car8=73;
    
 }
 elseif($idgrp==5){
     $car1=6;
     $car2=7;
     $car3=10;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 
 }
 elseif($idgrp==6){
     $car1=9;
     $car2=62;
     $car3=63;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 
 }
 elseif($idgrp==7){
     $car1=2;
     $car2=12;
     $car3=49;
     $car4=64;
     $car5=77;
     $car6=0;
     $car7=0;
     $car8=0;
  
 }
 elseif($idgrp==8){
     $car1=5;
     $car2=8;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==9){
     $car1=50;
     $car2=51;
     $car3=55;
     $car4=59;
     $car5=76;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==10){
     $car1=3;
     $car2=11;
     $car3=66;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==11){
     $car1=20;
     $car2=75;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==12){
     $car1=22;
     $car2=52;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==13){
     $car1=19;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==15){
     $car1=28;
     $car2=54;
     $car3=67;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==16){
     $car1=21;
     $car2=24;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==17){
     $car1=16;
     $car2=17;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==18){
     $car1=23;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==19){
     $car1=53;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==20){
     $car1=25;
     $car2=65;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==38){
     $car1=13;
     $car2=14;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==39){
     $car1=18;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==40){
     $car1=15;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==43){
     $car1=56;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==44){
     $car1=26;
     $car2=68;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 
 elseif($idgrp==21){
     $car1=41;
     $car2=42;
     $car3=69;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==22){
     $car1=0;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==23){
     $car1=45;
     $car2=46;
     $car3=70;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==25){
     $car1=30;
     $car2=31;
     $car3=47;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==26){
     $car1=33;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==27){
     $car1=32;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==28){
     $car1=36;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==29){
     $car1=34;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==30){
     $car1=40;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==31){
     $car1=35;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==32){
     $car1=43;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==33){
     $car1=44;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==34){
     $car1=71;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==35){
     $car1=39;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==36){
     $car1=38;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==37){
     $car1=37;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==41){
     $car1=39;
     $car2=38;
     $car3=37;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==42){
     $car1=46;
     $car2=45;
     $car3=69;
     $car4=42;
     $car5=70;
     $car6=41;
     $car7=0;
     $car8=0;
 }
 elseif($idgrp==45){
     $car1=74;
     $car2=0;
     $car3=0;
     $car4=0;
     $car5=0;
     $car6=0;
     $car7=0;
     $car8=0;
 }
 $resultcar = $db2->query("SELECT COUNT(*) FROM fleet WHERE (fleet.veh_id= '$car1' OR fleet.veh_id= '$car2' OR fleet.veh_id= '$car3'  OR fleet.veh_id= '$car4' OR fleet.veh_id= '$car5'  OR fleet.veh_id= '$car6'  OR fleet.veh_id= '$car7'  OR fleet.veh_id= '$car8') AND fleet.active=1");
         $rowc = $resultcar->fetch_row();
        $vtot=$rowc[0];	//lathos
 $car=$car1;
  $result1 = $db2->query("SELECT COUNT(DISTINCT id) FROM jostj_vikrentcar_orders WHERE (jostj_vikrentcar_orders.idcar=$car1 OR jostj_vikrentcar_orders.idcar=$car2 OR jostj_vikrentcar_orders.idcar=$car3 OR jostj_vikrentcar_orders.idcar=$car4 OR jostj_vikrentcar_orders.idcar=$car5 OR jostj_vikrentcar_orders.idcar=$car6 OR jostj_vikrentcar_orders.idcar=$car7 OR jostj_vikrentcar_orders.idcar=$car8) AND jostj_vikrentcar_orders.status!='cancelled' AND jostj_vikrentcar_orders.status!='standby' AND (($startdate BETWEEN ritiro AND consegna) OR ($enddate BETWEEN ritiro AND consegna))
  ");
$row1 = $result1->fetch_row();
    echo $vtot-$row1[0];
 //echo $car1;
                   ?>
     