예제 #1
0
             $value = (string) $_POST['val'];
             $allowEmpty = true;
             break;
         case 'attachment_required':
             $column = 'attachment_required';
             $value = (int) $_POST['val'];
             $allowEmpty = true;
             break;
         default:
             throw new Exception("Bad column name", 400);
     }
     // No value?
     if (!$allowEmpty && !$value) {
         throw new Exception("Bad value", 400);
     }
     if ($compta->modifierColonne($line['id'], $column, $value)) {
         $response = ['success' => true];
         // Done!
         header('Content-Type: application/json; charset=utf-8');
         header('HTTP/1.1 200 OK');
         die(json_encode($response));
     } else {
         throw new Exception("An error occurred", 409);
     }
 } catch (Exception $e) {
     switch ($e->getCode()) {
         case 404:
             $httpStatus = "Not Found";
             break;
         case 409:
             $httpStatus = "Conflict";