Пример #1
0
if (!isset($status) || !isset($matricules)) {
    $response->statusChangeIndicatorImagePath = $errorIconPath;
    $response->statusChangeMessage = "Argument manquant";
    $response->hasError = true;
    print json_encode($response);
    return;
}
$response->selectedDemands = json_decode($matricules);
try {
    //$matricules = json_decode($matricules);
    $database = database::instance();
    $database->beginTransaction();
    $matricules = json_decode($matricules);
    foreach ($matricules as $matricule) {
        $demand = new demande($matricule);
        $sendSuccesful = $demand->getStatus()->changeStatusTo($status, $details, $sendMail, $includeDetails);
        if (!$sendSuccesful) {
            throw new Exception("Erreur d'envoi du message");
        }
        $demand->refreshStatus();
        $response->newStatus = util::cleanUTF8($demand->getStatus()->getName());
    }
    $database->commitTransaction();
    print json_encode($response);
} catch (Exception $e) {
    $response->statusChangeIndicatorImagePath = $errorIconPath;
    $response->statusChangeMessage = $e->getMessage();
    $response->hasError = true;
    $database->abortTransaction();
    print json_encode($response);
}