ps('title'),'description'=>ps('description'),'venue'=>ps('venue'),'address'=>ps('address'), 'event_date'=>ps('event_date'),'event_time'=>ps('event_time'),'end_date'=>ps('end_date')?:null, 'end_time'=>ps('end_time'),'cost'=>ps('cost'),'website'=>ps('website'),'contact_name'=>ps('contact_name'), 'contact_email'=>ps('contact_email'),'contact_phone'=>ps('contact_phone'), 'status'=>p('status','approved'),'is_featured'=>(int)p('is_featured',0)]; if (!$f['title'] || !$f['event_date']) { flash('Title and date required.','error'); go('/admin/events.php'); } if ($act === 'add') { qrun("INSERT INTO events(title,description,venue,address,event_date,event_time,end_date,end_time,cost,website,contact_name,contact_email,contact_phone,status,is_featured,submitted_by)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",array_merge(array_values($f),[uid()])); flash('Event added!','success'); } else { $id = (int)p('id'); qrun("UPDATE events SET title=?,description=?,venue=?,address=?,event_date=?,event_time=?,end_date=?,end_time=?,cost=?,website=?,contact_name=?,contact_email=?,contact_phone=?,status=?,is_featured=? WHERE id=?",array_merge(array_values($f),[$id])); flash('Event updated!','success'); } go('/admin/events.php'); } } $filter = gs('filter') ?: 'all'; $editId = iget('edit'); $editing = $editId ? qone("SELECT * FROM events WHERE id=?",[$editId]) : null; $where = match($filter) { 'pending'=>"WHERE status='pending'",'approved'=>"WHERE status='approved'", default=>"" }; $events = qall("SELECT e.*,u.username FROM events e LEFT JOIN users u ON u.id=e.submitted_by $where ORDER BY CASE status WHEN 'pending' THEN 0 ELSE 1 END,event_date DESC"); ?>
| TITLE | DATE | SUBMITTED BY | STATUS | FEATURED | ACTIONS |
|---|---|---|---|---|---|
| =fdate($ev['event_date'])?> | =e($ev['username']??'Admin')?> | 'badge-green','pending'=>'badge-gold','rejected'=>'badge-red']; ?>">=strtoupper($ev['status'])?> | =$ev['is_featured']?'★':'—'?> |