Esempio n. 1
0
/*
 * Sending calls to the view
 * Call functions on {yourmodule}.controller.php
 */
switch ($_GET['fn']) {
    case 'book_list':
        echo book_list($_GET['row_id']);
        break;
    case 'book_list_pager':
        print book_list(NULL, $_GET['search'], $_GET['sort'], $_GET['page']);
        break;
    case 'book_list_sort':
        print book_list(NULL, $_GET['search'], $_GET['sort'], 1);
        break;
    case 'book_list_search':
        print book_list(NULL, $_GET['search']);
        break;
    case 'book_create_form':
        print book_create_form();
        break;
    case 'book_create_form_submit':
        print book_create_form_submit($_GET);
        break;
    case 'book_edit_form':
        print book_edit_form($_GET);
        break;
    case 'book_edit_form_submit':
        print book_edit_form_submit($_GET);
        break;
    case 'book_delete_form':
        print book_delete_form($_GET);
function book_edit_form_submit($data)
{
    $error = book_validate($data);
    if (!empty($error)) {
        return FALSE;
    } else {
        $book = new Book();
        $update = $book->update($data);
        if ($update['code'] == 200) {
            return book_list($data['id']);
        }
    }
}