Tato123 Posted April 23, 2013 Report Share Posted April 23, 2013 Hi Guys, i need your help. I have create in event DB the table category I need in a template show the event with the category = for example 'Tour'. I modify the EventsData.class.php and i have insert this: public function get_category_events($category) { $query = "SELECT * FROM ".TABLE_PREFIX."events WHERE category ='$Tour' ORDER BY date DESC"; return DB::get_results($query); } also i modify the module /events.php in: public function get_event_category() { $id= DB::escape($_GET[id]); $this->set('event', EventsData::get_category_events($id)); $this->set('signups', EventsData::get_signups($id)); $this->show('events/events_tour.tpl'); and i create the TPL events_tour.tpl whit this code: ?> <h3><?php echo SITE_NAME; ?> Upcoming Events Tour</h3> <?php if(!$events) { echo 'No Upcoming Events'; } else { ?> <center> <table border="1px" width="80%"> <tr> <td width="10%"><b>Date:</b></td> <td width="48%"><b>Event:</b></td> <td width="17%"><b>Category:</b></td> <td width="25%"><div align="center"><b>Details/Signups</b></div></td> </tr> <?php foreach($events as $event) { if($event->active == '2') { continue; } echo '<tr><td>'.date('n/j/Y', strtotime($event->date)).'</td>'; echo '<td>'.$event->title.'</td>'; echo '<td>'.$event->category.'</td>'; echo '<td><a href="'.SITE_URL.'/index.php/events/get_event?id='.$event->id.'">Details/Signups</a></td></tr>'; } ?> </table> </center> <?php } ?> <h3><?php echo SITE_NAME; ?> Past Events</h3> <?php if(!$history) { echo 'No Past Events'; } else { ?> <center> <table border="1px" width="80%"> <tr> <td width="10%"><b>Date:</b></td> <td width="48%"><b>Event:</b></td> <td width="17%"><b>Category:</b></td> <td width="25%"><div align="center"><b>Details</b></div></td> </tr> <?php foreach($history as $event) { echo '<tr><td>'.date('n/j/Y', strtotime($event->date)).'</td>'; echo '<td>'.$event->title.'</td>'; echo '<td>'.$event->category.'</td>'; echo '<td><a href="'.SITE_URL.'/index.php/events/get_past_event?id='.$event->id.'">Details</a></td></tr>'; } ?> </table> </center> <?php } ?> <hr /> <a href="<?php echo url('/events/get_rankings'); ?>">Show Pilot Rankings For Events</a> Now, when i open the module my site show the events_tour.tpl but don't show any one record Can you help me? Quote Link to comment Share on other sites More sharing options...
Tato123 Posted April 25, 2013 Author Report Share Posted April 25, 2013 solved Quote Link to comment Share on other sites More sharing options...
SilviuJOR001 Posted May 7, 2013 Report Share Posted May 7, 2013 good idea, i would like categorized events on my VA also can you help me with the code? thank you Quote Link to comment Share on other sites More sharing options...
Tato123 Posted May 9, 2013 Author Report Share Posted May 9, 2013 You must before create a table in your dbase event named 'category' You mustadd in the the file: \core\common\EventsData.class.php with public function get_flyin_events() { $query = "SELECT * FROM ".TABLE_PREFIX."events WHERE category = 'Fly-In' AND date >= NOW() ORDER BY date ASC"; return DB::get_results($query); } where Fly-In is the name of category You must add in the file: \core\modules\Events\Events.php public function get_event_flyin() { $id= DB::escape ($_GET[id]); $this->set('events', EventsData::get_flyin_events()); $this->set('history', EventsData::get_flyin_past_events()); $this->show('events/events_cat.tpl'); } where get_flyin_events is the name of class definited before in EventsData.class.php now you must modify a the template file in \core\templates\events\events_cat.tpl in ?> <h3><?php echo SITE_NAME; ?> Upcoming Events - Fly - In</h3> <?php if(!$events) { echo 'No Upcoming Events'; } else { ?> <center> <table border="1px" width="80%"> <tr> <td width="10%"><b>Date:</b></td> <td width="48%"><b>Event:</b></td> <td width="17%"><b>Category:</b></td> <td width="25%"><b>Details/Signups</b></td> </tr> <?php foreach($events as $event) { if($event->active == '2') { continue; } echo '<tr><td>'.date('n/j/Y', strtotime($event->date)).'</td>'; echo '<td>'.$event->title.'</td>'; echo '<td>'.$event->category.'</td>'; echo '<td><a href="'.SITE_URL.'/index.php/events/get_event?id='.$event->id.'">Details/Signups</a></td></tr>'; } ?> </table> </center> <?php } ?> <h3><?php echo SITE_NAME; ?> Past Events</h3> <?php if(!$history) { echo 'No Past Events'; } else { ?> <center> <table border="1px" width="80%"> <tr> <td width="25%"><b>Date:</b></td> <td width="60%"><b>Event:</b></td> <td><b>Details</b></td> </tr> <?php foreach($history as $event) { echo '<tr><td>'.date('n/j/Y', strtotime($event->date)).'</td>'; echo '<td>'.$event->title.'</td>'; echo '<td><a href="'.SITE_URL.'/index.php/events/get_past_event?id='.$event->id.'">Details</a></td></tr>'; } ?> </table> </center> <?php } ?> <hr /> <a href="<?php echo url('/events/get_rankings'); ?>">Show Pilot Rankings For Events</a> Regards Quote Link to comment Share on other sites More sharing options...
SilviuJOR001 Posted May 9, 2013 Report Share Posted May 9, 2013 very much thanks Quote Link to comment Share on other sites More sharing options...
Ademar Andrade Posted June 6, 2013 Report Share Posted June 6, 2013 Hi guys! To add a category in mysql i added this to admin form (events_new_form.tpl) <input type="text" name="category" <?php if(isset($event)) {echo 'value="'.$event['category'].'"';} ?> the problem is when i submit a new event, the category dosent appear in my database. What is wrong? Reggards... Quote Link to comment Share on other sites More sharing options...
Tato123 Posted June 7, 2013 Author Report Share Posted June 7, 2013 Hi guys! To add a category in mysql i added this to admin form (events_new_form.tpl) <input type="text" name="category" <?php if(isset($event)) {echo 'value="'.$event['category'].'"';} ?> the problem is when i submit a new event, the category dosent appear in my database. What is wrong? Reggards... After: <tr> <td>Slot Interval (1 minute min)</td> <td><input type="text" name="interval" <?php if(isset($event)) {echo 'value="'.$event['interval'].'"';} else {echo 'value="1"';} ?> ></td> </tr> i insert this: <tr> <td>Category of Event?</td> <td> <select name="category"> <option value="Tour">Tour</option> <option value="Charter">Charter</option> <option value="Fly-In">Fly-In</option> <option value="Airline">Airline</option> <option value="Ivao Tour">Ivao Tour</option> <option value="Neuroflight">Neuroflight</option> <option value="Business">Business</option> <option value="F.E.F">F.E.F</option> <option value="Eli">Eli</option> </select> </td> </tr> Remember: the "category" table in your Dbase must be Varchar Regards Quote Link to comment Share on other sites More sharing options...
Ademar Andrade Posted June 7, 2013 Report Share Posted June 7, 2013 Still not working... Everything i did.... events_new_form.tpl <?php //simpilotgroup addon module for phpVMS virtual airline system // //simpilotgroup addon modules are licenced under the following license: //Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) //To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/ // //@author David Clark (simpilot) //@copyright Copyright (c) 2009-2010, David Clark //@license http://creativecommons.org/licenses/by-nc-sa/3.0/ $this->show('events/events_header.tpl'); if(isset($event)) {echo '<div id="error">All fields must be filled out</div>'; } ?> <h4>Create New Event</h4> <table width="80%"> <form name="eventform" action="<?php echo SITE_URL; ?>/admin/index.php/events_admin" method="post" enctype="multipart/form-data"> <tr> <td>New Event Title</td> <td><input type="text" name="title" <?php if(isset($event)) {echo 'value="'.$event['title'].'"';} ?> /></td> </tr> <tr> <td>New Event Description</td> <td><textarea name="description" rows="4" cols="40"><?php if(isset($event)) {echo $event['description'];} ?></textarea></td> </tr> <tr> <td>Link To Event Banner Image (Optional)<br />ex: http://www.mysite.com/pic.png</td> <td><input type="text" name="image" <?php if(isset($event)) {echo 'value="'.$event['image'].'"';} ?> ></td> </tr> <tr> <td>Scheduled Event Date</td> <td> <?php $months = range(1, 12); $days = range (1, 31); $years = range (date('Y'), 2015); echo "Month: <select name='month'>"; foreach ($months as $value) {echo '<option value="'.$value.'">'.$value.'</option>\n';} echo '</select>'; echo " Day: <select name='day'>"; foreach ($days as $value) {echo '<option value="'.$value.'">'.$value.'</option>\n';} echo '</select>'; echo " Year: <select name='year'>"; foreach ($years as $value) {echo '<option value="'.$value.'">'.$value.'</option>\n';} echo '</select>'; ?> </td> </tr> <tr> <td>Scheduled Event Time</td> <td> <?php $start = strtotime('0:00'); $end = strtotime('23:30'); echo '<select name="time">'; for ($i = $start; $i <= $end; $i += 1800) { echo '<option>' . date('H:i', $i).'</option>'; } echo '</select>'; ?> GMT </td> </tr> <tr> <td>Departure Airfield (icao)</td> <td><input type="text" name="dep" <?php if(isset($event)) {echo 'value="'.$event['dep'].'"';} ?> ></td> </tr> <tr> <td>Arrival Airfield (icao)</td> <td><input type="text" name="arr" <?php if(isset($event)) {echo 'value="'.$event['arr'].'"';} ?> ></td> </tr> <tr> <td>Airline Schedule #</td> <td><input type="text" name="schedule" <?php if(isset($event)) {echo 'value="'.$event['schedule'].'"';} ?> ></td> </tr> <tr> <td>Slot Limit (min 1)</td> <td><input type="text" name="limit" <?php if(isset($event)) {echo 'value="'.$event['limit'].'"';} else {echo 'value="1"';} ?> ></td> </tr> <tr> <td>Category of Event?</td> <td> <select name="category"> <option value="Tour">Tour</option> <option value="Fly-In">Fly-In</option> <option value="Ivao Tour">Ivao Tour</option> </select> </td> </tr> <tr> <td>Slot Interval (1 minute min)</td> <td><input type="text" name="interval" <?php if(isset($event)) {echo 'value="'.$event['interval'].'"';} else {echo 'value="1"';} ?> ></td> </tr> <tr> <td>Post Event as News Item?</td> <td> <select name="postnews"> <option value="1">Yes</option> <option value="2">No</option> </select> </td> </tr> <tr> <td>Active Event?<br />Inactive events will not show in public/pilot listings.</td> <td> <select name="active"> <option value="1">Yes</option> <option value="2">No</option> </select> </td> </tr> <tr> <td colspan="2"><input type="hidden" name="action" value="save_new_event" /><input type="submit" value="Save New Event"></td> </tr> </form> </table> Events.php <?php //simpilotgroup addon module for phpVMS virtual airline system // //simpilotgroup addon modules are licenced under the following license: //Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) //To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/ // //@author David Clark (simpilot) //@copyright Copyright (c) 2009-2010, David Clark //@license http://creativecommons.org/licenses/by-nc-sa/3.0/ class Events extends CodonModule { public function index() { $this->set('events', EventsData::get_upcoming_events()); $this->set('history', EventsData::get_past_events()); $this->show('events/events_index.tpl'); } public function get_event_flyin() { $id= DB::escape ($_GET[id]); $this->set('events', EventsData::get_flyin_events()); $this->set('history', EventsData::get_flyin_past_events()); $this->show('events/events_cat.tpl'); } public function get_event_tour() { $id= DB::escape ($_GET[id]); $this->set('events', EventsData::get_tour_events()); $this->set('history', EventsData::get_tour_past_events()); $this->show('events/events_index.tpl'); } public function get_event() { $id= DB::escape($_GET[id]); $this->set('event', EventsData::get_event($id)); $this->set('signups', EventsData::get_signups($id)); $this->show('events/events_event.tpl'); } public function get_past_event() { $id= DB::escape($_GET[id]); $this->set('event', EventsData::get_event($id)); $this->set('signups', EventsData::get_signups($id)); $this->show('events/events_past_event.tpl'); } public function signup() //admin { $eid = DB::escape($_GET[eid]); $pid = DB::escape($_GET[pid]); $time = DB::escape($_GET[time]); EventsData::event_signup($eid, $pid, $time); EventsData::add_ranking($pid); $this->set('event', EventsData::get_event($eid)); $this->set('signups', EventsData::get_signups($eid)); $this->show('events/events_event.tpl'); } public function remove_signup() //public { $id = $_GET[id]; $event = $_GET[event]; EventsData::remove_pilot_signup($id, $event); EventsData::subtract_ranking($id); $this->set('event', EventsData::get_event($event)); $this->set('signups', EventsData::get_signups($event)); $this->show('events/events_event.tpl'); } public function get_rankings() { $this->set('rankings', EventsData::get_rankings()); $this->show('events/events_rankings.tpl'); } } events_cat.tpl <h3><?php echo SITE_NAME; ?> Upcoming Events - Fly - In</h3> <?php if(!$events) { echo 'No Upcoming Events'; } else { ?> <center> <table border="1px" width="80%"> <tr> <td width="10%"><b>Date:</b></td> <td width="48%"><b>Event:</b></td> <td width="17%"><b>Category:</b></td> <td width="25%"><b>Details/Signups</b></td> </tr> <?php foreach($events as $event) { if($event->active == '2') { continue; } echo '<tr><td>'.date('n/j/Y', strtotime($event->date)).'</td>'; echo '<td>'.$event->title.'</td>'; echo '<td>'.$event->category.'</td>'; echo '<td><a href="'.SITE_URL.'/index.php/events/get_event?id='.$event->id.'">Details/Signups</a></td></tr>'; } ?> </table> </center> <?php } ?> <h3><?php echo SITE_NAME; ?> Past Events</h3> <?php if(!$history) { echo 'No Past Events'; } else { ?> <center> <table border="1px" width="80%"> <tr> <td width="25%"><b>Date:</b></td> <td width="60%"><b>Event:</b></td> <td><b>Details</b></td> </tr> <?php foreach($history as $event) { echo '<tr><td>'.date('n/j/Y', strtotime($event->date)).'</td>'; echo '<td>'.$event->title.'</td>'; echo '<td><a href="'.SITE_URL.'/index.php/events/get_past_event?id='.$event->id.'">Details</a></td></tr>'; } ?> </table> </center> <?php } ?> <hr /> <a href="<?php echo url('/events/get_rankings'); ?>">Show Pilot Rankings For Events</a> EventsData.class.php <?php //simpilotgroup addon module for phpVMS virtual airline system // //simpilotgroup addon modules are licenced under the following license: //Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) //To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/ // //@author David Clark (simpilot) //@copyright Copyright (c) 2009-2010, David Clark //@license http://creativecommons.org/licenses/by-nc-sa/3.0/ class EventsData extends CodonData { public function get_events() { $query = "SELECT * FROM ".TABLE_PREFIX."events ORDER BY date ASC"; return DB::get_results($query); } public function get_upcoming_events() { $query = "SELECT * FROM ".TABLE_PREFIX."events WHERE date >= NOW() ORDER BY date ASC"; return DB::get_results($query); } public function get_past_events() { $query = "SELECT * FROM ".TABLE_PREFIX."events WHERE date < NOW() ORDER BY date DESC"; return DB::get_results($query); } public function get_event($id) { $query = "SELECT * FROM ".TABLE_PREFIX."events WHERE id='$id'"; return DB::get_row($query); } public function get_signups($id)//probably dont need! { $query = "SELECT * FROM ".TABLE_PREFIX."events_signups WHERE event_id='$id' ORDER BY time ASC"; return DB::get_results($query); } public function save_new_event($date, $time, $title, $description, $image, $dep, $arr, $schedule, $slot_limit, $slot_interval, $active) { $query = "INSERT INTO ".TABLE_PREFIX."events (date, time, title, description, image, dep, arr, schedule, slot_limit, slot_interval, active) VALUES ('$date', '$time', '$title', '$description', '$image', '$dep', '$arr', '$schedule', '$slot_limit', '$slot_interval', '$active')"; DB::query($query); } public function save_edit_event($date, $time, $title, $description, $image, $dep, $arr, $schedule, $slot_limit, $slot_interval, $active, $id) { $query = "UPDATE ".TABLE_PREFIX."events SET date='$date', time='$time', title='$title', description='$description', image='$image', dep='$dep', arr='$arr', schedule='$schedule', slot_limit='$slot_limit', slot_interval='$slot_interval', active='$active' WHERE id='$id'"; DB::query($query); } public function event_signup($eid, $pid, $time) { $query = "INSERT INTO ".TABLE_PREFIX."events_signups (event_id, pilot_id, time) VALUES('$eid', '$pid', '$time')"; DB::query($query); } public function signup_time($eid, $time) { $query = "SELECT * FROM ".TABLE_PREFIX."events_signups WHERE event_id='$eid' AND time='$time'"; return DB::get_row($query); } public function check_signup($pid, $eid) { $query = "SELECT COUNT(*) AS total FROM ".TABLE_PREFIX."events_signups WHERE event_id='$eid' AND pilot_id='$pid'"; return DB::get_row($query); } public function remove_signup($id) { $query = "DELETE FROM ".TABLE_PREFIX."events_signups WHERE id='$id'"; DB::query($query); } public function remove_pilot_signup($id, $event) { $query = "DELETE FROM ".TABLE_PREFIX."events_signups WHERE pilot_id='$id' AND event_id='$event'"; DB::query($query); } public function delete_event($id) { $query = "DELETE FROM ".TABLE_PREFIX."events WHERE id='$id'"; DB::query($query); $query2 = "DELETE FROM ".TABLE_PREFIX."events_signups WHERE event_id='$id'"; DB::query($query2); } public function add_ranking($pilot_id) { $query = "SELECT * FROM ".TABLE_PREFIX."events_pilotranks WHERE pilot_id='$pilot_id'"; $data = DB::get_row($query); if(!$data) { $query2 = "INSERT INTO ".TABLE_PREFIX."events_pilotranks (pilot_id, ranking) VALUES ('$pilot_id', '1')"; DB::query($query2); } else { $ranking = $data->ranking + 1; $query3 = "UPDATE ".TABLE_PREFIX."events_pilotranks SET ranking='$ranking' WHERE pilot_id='$pilot_id'"; DB::query($query3); } } public function subtract_ranking($pilot_id) { $query = "SELECT * FROM ".TABLE_PREFIX."events_pilotranks WHERE pilot_id='$pilot_id'"; $data = DB::get_row($query); if($data->ranking <= '1') { $query2 = "DELETE FROM ".TABLE_PREFIX."events_pilotranks WHERE pilot_id='$pilot_id'"; DB::query($query2); } else { $ranking = $data->ranking - 1; $query3 = "UPDATE ".TABLE_PREFIX."events_pilotranks SET ranking='$ranking' WHERE pilot_id='$pilot_id'"; DB::query($query3); } } public function get_rankings() { $query = "SELECT * FROM ".TABLE_PREFIX."events_pilotranks ORDER BY ranking DESC"; return DB::get_results($query); } public function get_flyin_events() { $query = "SELECT * FROM ".TABLE_PREFIX."events WHERE category = 'Fly-In' AND date >= NOW() ORDER BY date ASC"; return DB::get_results($query); } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.