Ejemplo n.º 1
0
        return false;
    }
    return true;
}
if ($Mode == 'ADD_ITEM' && can_process()) {
    submitAuthor($_POST['fname'], $_POST['mname'], $_POST['lname'], $_POST['bdate'], $_POST['address'], $_POST['contact_number'], $_POST['email_address']);
    display_notification(_('New author has been added'));
    $Mode = 'RESET';
}
if ($Mode == 'UPDATE_ITEM' && can_process()) {
    submitAuthor($_POST['fname'], $_POST['mname'], $_POST['lname'], $_POST['bdate'], $_POST['address'], $_POST['contact_number'], $_POST['email_address'], $_POST['selected_id']);
    display_notification(_('Selected author has been updated'));
    $Mode = 'RESET';
}
if ($Mode == 'Delete') {
    deleteAuthor($selected_id);
    display_notification(_('Selected author has been deleted'));
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    unset($_POST);
}
$result = fetchAuthors();
start_form();
start_table(TABLESTYLE, "width=70%");
$th = array(_('Name'), _('Address'), _('Contact Number'), _('Email Address'), '', '');
table_header($th);
$k = 0;
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
Ejemplo n.º 2
0
         $author['res'] = false;
         echo json_encode($author);
         //echo $msg;
     } else {
         $author = insertAuthor($name, $surname);
         $author['res'] = true;
         echo json_encode($author);
         // insertAuthor($name, $surname);
     }
     break;
 case 'delete_author':
     $id_author = isset($_REQUEST['id_author']) ? $_REQUEST['id_author'] : '';
     //validazione del dato proveniente dal javascript... potrebbe essere modificato dal DOM
     if (!filter_var($id_author, FILTER_VALIDATE_INT) === false) {
         //int
         $author_deleted = deleteAuthor($id_author);
         if (!$author_deleted) {
             $author['res'] = false;
             $author['authorfree'] = "Impossibile cancellare autore perchè è associato ad un libro.";
             echo json_encode($author);
         } elseif ($author_deleted == 1) {
             $author['res'] = true;
             echo json_encode($author);
         } else {
             $author['res'] = false;
             echo json_encode($author);
         }
     } else {
         //not int
         $author['res'] = false;
         echo json_encode($author);