Exemplo n.º 1
0
session_start();
$historyManager = new HistoryManager($pdo);
$projetManager = new ProjetManager($pdo);
//post input processing
$idProjet = htmlentities($_POST['idProjet']);
$idSociete = htmlentities($_POST['idSociete']);
$type = htmlentities($_POST['type']);
if (!empty($_POST['idProjet'])) {
    $id = htmlentities($_POST['id']);
    if (htmlentities($_POST['typeImmobiliere']) == "appartement") {
        $appartementManager = new AppartementManager($pdo);
        $appartementManager->delete($id);
    } else {
        if (htmlentities($_POST['typeImmobiliere']) == "local") {
            $locauxManager = new LocauxManager($pdo);
            $locauxManager->delete($id);
        } else {
            if (htmlentities($_POST['typeImmobiliere']) == "maison") {
                $maisonManager = new MaisonManager($pdo);
                $maisonManager->delete($id);
            } else {
                if (htmlentities($_POST['typeImmobiliere']) == "terrain") {
                    $terrainManager = new TerrainManager($pdo);
                    $terrainManager->delete($id);
                }
            }
        }
    }
    //add history data to db
    $createdBy = $_SESSION['userMerlaTrav']->login();
    $created = date('Y-m-d h:i:s');
            if ($action == "updateClient") {
                $idLocaux = $_POST['idLocaux'];
                $par = htmlentities($_POST['par']);
                $locauxManager->updatePar($par, $idLocaux);
                //add History data
                $createdBy = $_SESSION['userMerlaTrav']->login();
                $created = date('Y-m-d h:i:s');
                $history = new History(array('action' => "Modification Client", 'target' => "Table des locaux commerciaux", 'description' => "Modifier le client réservant du local commercial", 'created' => $created, 'createdBy' => $createdBy));
                //add it to db
                $historyManager->add($history);
                $actionMessage = "Opération Valide : Local Commercial Réservation Modifiée avec succès.";
                $typeMessage = "success";
            } else {
                if ($action == "delete") {
                    $idLocaux = $_POST['idLocaux'];
                    $locauxManager->delete($idLocaux);
                    //add History data
                    $createdBy = $_SESSION['userMerlaTrav']->login();
                    $created = date('Y-m-d h:i:s');
                    $history = new History(array('action' => "Suppression", 'target' => "Table des locaux commerciaux", 'description' => "Supprimer un local commercial", 'created' => $created, 'createdBy' => $createdBy));
                    //add it to db
                    $historyManager->add($history);
                    $actionMessage = "Opération Valide : Local Commercial Supprimé avec succès.";
                    $typeMessage = "success";
                }
            }
        }
    }
}
//Action Delete Processing End
$_SESSION['locaux-action-message'] = $actionMessage;