<?php
require_once("../../base/php/startSession.php");
require_once("../../base/php/classDatabase.php");
require_once("../../base/php/Functions.php");
require_once("../../base/php/Environnement.php");
require_once("../../base/php/WebAppLog.php");

require_once('./amfphp/services/CtiPmsiImportService.php');

$action = getPOST("action");
$id = getPOST("id");
$fileName = getPOST("fileName");
$fileData = $_FILES["fileData"];
$typeEts = getPOST("typeEts");

$CtiPmsiImportService = new CtiPmsiImportService();

switch ($action) {
  case 'get':
    $return = $CtiPmsiImportService->getMat2aImports();
    break;
  case 'delete':
    $return = $CtiPmsiImportService->deleteImport($id);
    break;
  case 'post':
    $return = $CtiPmsiImportService->uploadFile($fileName, $fileData, $typeEts);
    break;
  default:
    $return = array();
    break;
}

echo json_encode($return);
