} elseif (file_exists('controller/' . $myClass . '.php')) {
        include 'controller/' . $myClass . '.php';
    }
}
spl_autoload_register("classLoad");
include 'config.php';
include 'lib/pagination.php';
//classes loading end
session_start();
if (isset($_SESSION['userMerlaTrav'])) {
    //les sources
    $projetManager = new ProjetManager($pdo);
    $caisseManager = new CaisseManager($pdo);
    $projets = $projetManager->getProjets();
    $caisses = $caisseManager->getCaissesGroupByMonth();
    $totalCaisse = $caisseManager->getTotalCaisseByType('Entree') - $caisseManager->getTotalCaisseByType('Sortie');
    $totalEntrees = $caisseManager->getTotalCaisseByType('Entree');
    $totalSorties = $caisseManager->getTotalCaisseByType('Sortie');
    ?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <meta charset="utf-8" />
    <title>ImmoERP - Management Application</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    //classes managers
    $usersManager = new UserManager($pdo);
    $mailsManager = new MailManager($pdo);
    $notesClientsManager = new NotesClientManager($pdo);
    $projetManager = new ProjetManager($pdo);
    $contratManager = new ContratManager($pdo);
    $clientManager = new ClientManager($pdo);
    $livraisonsManager = new LivraisonManager($pdo);
    $fournisseursManager = new FournisseurManager($pdo);
    $caisseManager = new CaisseManager($pdo);
    $caisseIaazaManager = new CaisseIaazaManager($pdo);
    $operationsManager = new OperationManager($pdo);
    $compteBancaire = new CompteBancaireManager($pdo);
    //classes and vars
    //users number
    $soldeCaisseAnnahda = $caisseManager->getTotalCaisseByType("Entree") - $caisseManager->getTotalCaisseByType("Sortie");
    $soldeCaisseIaaza = $caisseIaazaManager->getTotalCaisseByType("Entree") - $caisseIaazaManager->getTotalCaisseByType("Sortie");
    $projetNumber = $projetManager->getProjetsNumber();
    $usersNumber = $usersManager->getUsersNumber();
    $fournisseurNumber = $fournisseursManager->getFournisseurNumbers();
    $mailsNumberToday = $mailsManager->getMailsNumberToday();
    $mailsToday = $mailsManager->getMailsToday();
    $clientWeek = $clientManager->getClientsWeek();
    $clientNumberWeek = $clientManager->getClientsNumberWeek();
    $livraisonsNumber = $livraisonsManager->getLivraisonNumber();
    $livraisonsWeek = $livraisonsManager->getLivraisonsWeek();
    $livraisonsNumberWeek = $livraisonsManager->getLivraisonsNumberWeek();
    $operationsNumberWeek = $operationsManager->getOperationNumberWeek();
    ?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
 $caisses = "";
 $titreDocument = "";
 $totalCaisse = 0;
 $criteria = htmlentities($_POST['criteria']);
 if ($criteria == "parDate") {
     $dateFrom = htmlentities($_POST['dateFrom']);
     $dateTo = htmlentities($_POST['dateTo']);
     $type = htmlentities($_POST['type']);
     if ($type == "Toutes") {
         $caisses = $caisseManager->getCaissesByDates($dateFrom, $dateTo);
         $titreDocument = "Liste des opérations entre : " . date('d/m/Y', strtotime($dateFrom)) . ' - ' . date('d/m/Y', strtotime($dateTo));
         $totalCaisse = $caisseManager->getTotalCaisseByTypeByDate('Entree', $dateFrom, $dateTo) - $caisseManager->getTotalCaisseByTypeByDate('Sortie', $dateFrom, $dateTo);
     } else {
         $caisses = $caisseManager->getCaissesByDatesByType($dateFrom, $dateTo, $type);
         $titreDocument = "Liste des opérations d'" . $type . " entre : " . date('d/m/Y', strtotime($dateFrom)) . ' - ' . date('d/m/Y', strtotime($dateTo));
         $totalCaisse = $caisseManager->getTotalCaisseByType($type, $dateFrom, $dateTo);
     }
 } else {
     if ($criteria == "toutesCaisse") {
         $caisses = $caisseManager->getCaisses();
         $titreDocument = "Bilan de toutes les opérations de caisse";
         $totalCaisse = $caisseManager->getTotalCaisseByType('Entree') - $caisseManager->getTotalCaisseByType('Sortie');
         /*if ( isset($_POST['type']) ) {
               $type = htmlentities($_POST['type']);
               $caisses = $caisseManager->getCaissesByType($type);
               $titreDocument = "Liste des opérations de type : ".$type;
           }*/
     }
 }
 ob_start();
 ?>