Пример #1
0
<?php

require_once CODE_ROOT . '/classes/patients.php';
$patients = new Patients();
if (empty($request_uri[2])) {
    $request_uri[2] = '';
}
if (empty($request_uri[3])) {
    $request_uri[3] = 0;
}
switch ($request_uri[2]) {
    case '':
        $patients->edit(0);
        $patients->_list();
        break;
    case 'add':
        $patients->edit(0);
        if ($patients->result['success'] === true) {
            header('Location: /patients/?filter=' . $patients->result['fio'] . ' ' . $patients->result['age']);
            die;
        }
        break;
    case 'edit':
        $urlData['id'] = (int) $request_uri[3];
        $patients->edit((int) $request_uri[3]);
        if (IS_AJAX === true && filter_input(INPUT_POST, 'action', FILTER_VALIDATE_INT) === 1) {
            $result = array('success' => $patients->result['success'], 'messages' => $patients->result['message']);
            echo json_encode($result);
            die;
        }
        break;