0) || $action=='add') ticketdrum_event_edit(); elseif ($id>0 && $action=='delete_check') { ?>

0 && $action=='duplicate' && check_admin_referer('ticketdrum_duplicate_'.$id)) { global $wpdb; $source = $wpdb->get_row($wpdb->prepare("SELECT * FROM %i WHERE id=%d",TICKETDRUM_EVENTS_TABLE,$id),ARRAY_A); if ($source) { unset($source['id']); /* translators: %s: title of the event being duplicated */ $source['title'] = sprintf(__('%s (copy)','ticketdrum'),$source['title']); $source['status'] = 'draft'; $source['salt'] = ticketdrum_generate_password(20); $source['added'] = gmdate("Y-m-d H:i:s"); $wpdb->insert(TICKETDRUM_EVENTS_TABLE,$source); $new_event_id = $wpdb->insert_id; //Copy the event's ticket types too $source_tickets = $wpdb->get_results($wpdb->prepare("SELECT * FROM %i WHERE event_id=%d",TICKETDRUM_TICKETS_TABLE,$id),ARRAY_A); foreach ($source_tickets as $st) { unset($st['id']); $st['event_id'] = $new_event_id; $st['salt'] = ticketdrum_generate_password(20); $st['added'] = gmdate("Y-m-d H:i:s"); $wpdb->insert(TICKETDRUM_TICKETS_TABLE,$st); } /* translators: %s: number of ticket types copied */ echo '

'.esc_html(sprintf(_n('Event duplicated (as a draft) with %s ticket type.','Event duplicated (as a draft) with %s ticket types.',count($source_tickets),'ticketdrum'),number_format_i18n(count($source_tickets)))).' '.esc_html__('Edit the copy','ticketdrum').'

'; } ticketdrum_event_list(); } elseif ($id>0 && $action=='delete_confirmed' && check_admin_referer('ticketdrum_event_delete_'.$id)) { $wpdb->query($wpdb->prepare("DELETE FROM %i WHERE id=%d LIMIT 1",TICKETDRUM_EVENTS_TABLE,$id)); ticketdrum_event_list(); } else ticketdrum_event_list(); } function ticketdrum_event_list() { global $wpdb; ?>


__('draft','ticketdrum'),'active'=>__('active','ticketdrum'),'archived'=>__('archived','ticketdrum')]; $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM %i ORDER BY (end_datetime>=NOW()) DESC, CASE WHEN end_datetime>=NOW() THEN start_datetime END ASC, start_datetime DESC",TICKETDRUM_EVENTS_TABLE),ARRAY_A); ?> 0; $spaces_taken = $show_spaces?ticketdrum_calculate_spaces_taken($row['id']):''; ?>
   
'.(int)$spaces_taken.'/'.(int)$row['max_spaces_available'].''; ?> 0 && strtotime($row['end_datetime'])'.esc_html__('ended','ticketdrum').''; ?> ·
sanitize_text_field(wp_unslash($_POST['title'] ?? '')), 'start_datetime' => ticketdrum_normalise_datetime(sanitize_text_field(wp_unslash($_POST['start_datetime'] ?? ''))), 'end_datetime' => ticketdrum_normalise_datetime(sanitize_text_field(wp_unslash($_POST['end_datetime'] ?? ''))), 'description' => wp_kses_post(wp_unslash($_POST['description'] ?? '')), 'location' => sanitize_text_field(wp_unslash($_POST['location'] ?? '')), 'max_spaces_available' => sanitize_text_field(wp_unslash($_POST['max_spaces_available'] ?? '')), 'register_hide' => absint(wp_unslash($_POST['register_hide'] ?? 0)), 'register_override_url' => sanitize_text_field(wp_unslash($_POST['register_override_url'] ?? '')), 'register_override_text'=> sanitize_text_field(wp_unslash($_POST['register_override_text'] ?? '')), 'custom_fields' => sanitize_text_field(wp_unslash($_POST['custom_fields'] ?? '')), 'status' => sanitize_text_field(wp_unslash($_POST['status'] ?? '')), 'notification_emails' => sanitize_text_field(wp_unslash($_POST['notification_emails'] ?? '')), ]; if ($event_action=='update') { $wpdb->update(TICKETDRUM_EVENTS_TABLE,$event_fields,['ID'=>$id]); ticketdrum_waitlist_notify($id); //Capacity may have increased - tell anyone waiting } else { $event_fields['added'] = gmdate("Y-m-d H:i:s"); $event_fields['salt'] = ticketdrum_generate_password(20); $wpdb->insert(TICKETDRUM_EVENTS_TABLE,$event_fields); } } else if (isset($_POST['delete']) && check_admin_referer('ticketdrum_event_edit')) { $wpdb->query($wpdb->prepare("DELETE FROM %i WHERE id = %d", TICKETDRUM_EVENTS_TABLE, $id)); } else {//selecting value to update $events = $wpdb->get_results($wpdb->prepare("SELECT * from %i where id=%d", TICKETDRUM_EVENTS_TABLE, $id)); $thisevent = $events[0] ?? null; } //Adding a new event, or an id that no longer exists: render the form with empty values //rather than reading properties off nothing if (!isset($thisevent) || !$thisevent) $thisevent = (object)['id'=>0,'title'=>'','description'=>'','location'=>'','start_datetime'=>'','end_datetime'=>'', 'max_spaces_available'=>'','register_hide'=>0,'register_override_url'=>'','register_override_text'=>'', 'custom_fields'=>'','status'=>'draft','notification_emails'=>'','salt'=>'']; ?>

«

«
description, "description" );?>

TicketDrum'); ?>

id>0): ?>

[ticketdrum tickets id=id; ?>]



' class='button-primary'>

custom_fields!='' && json_decode($thisevent->custom_fields)!==null?wp_json_encode(json_decode($thisevent->custom_fields)):'{}').';','before'); ?>