Пример #1
0
    $mt->description = $description;
    if (validateEdit($mt)) {
        $mt->save();
        FlashMessage::add('Am salvat descrierea.', 'info');
        util_redirect('tipuri-modele.php');
    } else {
        SmartyWrap::assign('editModelType', $mt);
    }
}
if ($editId) {
    // Load model type to be edited
    SmartyWrap::assign('editModelType', ModelType::get_by_id($editId));
}
if ($deleteId) {
    $mt = ModelType::get_by_id($deleteId);
    if (validateDelete($mt)) {
        FlashMessage::add("Am șters tipul de model '{$mt->code}'.", 'info');
        $mt->delete();
        util_redirect('tipuri-modele.php');
    }
}
// Load model type table data
$modelTypes = Model::factory('ModelType')->order_by_asc('code')->find_many();
$modelCounts = array();
$lexemCounts = array();
$canDelete = array();
foreach ($modelTypes as $mt) {
    $numLexems = Model::factory('LexemModel')->where('modelType', $mt->code)->count();
    $numDependants = Model::factory('ModelType')->where('canonical', $mt->code)->count();
    $modelCounts[] = Model::factory('FlexModel')->where('modelType', $mt->code)->count();
    $lexemCounts[] = $numLexems;
Пример #2
0
if (isset($_POST['hash'])) {
    if (isset($_GET['add'])) {
        $errors = validateAdd($_POST);
        if (count($errors) == 0) {
            addAppointment($_POST['teacher'], $_POST['parent'], $_POST['time']);
            addNotice($_POST['teacher'], $_POST['parent'], $_POST['time']);
            echo 'success';
        } else {
            echo '<div class="error"><ul>';
            foreach ($errors as $error) {
                echo '<li>' . $error . '</li>';
            }
            echo '</ul></div>';
        }
    } elseif (isset($_GET['delete'])) {
        $errors = validateDelete($_POST);
        if (count($errors) == 0) {
            deleteAppointment($_POST['teacher'], $_POST['parent'], $_POST['time']);
            deleteNotice($_POST['teacher'], $_POST['parent'], $_POST['time']);
            echo 'success';
        } else {
            echo '<div class="error"><ul>';
            foreach ($errors as $error) {
                echo '<li>' . $error . '</li>';
            }
            echo '</ul></div>';
        }
    }
} else {
    $teacher_id = $_GET['teacher'];
    $time = $_GET['time'];