function form($instance) { global $wpdb; $defaults = array('title' => 'Upcoming shows', 'limit' => 5, 'scope' => 'upcoming', 'show_tours' => 'no', 'group_artists' => 'no', 'artist_order' => 'alphabetical', 'artist' => '', 'tour' => '', 'venue' => '', 'show_feeds' => 'no', 'link_text' => ''); $instance = wp_parse_args($instance, $defaults); extract($instance); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $title; ?> " /> </label> </p> <p> <select style="width:100%;" id="<?php echo $this->get_field_id('scope'); ?> " name="<?php echo $this->get_field_name('scope'); ?> "> <option value="upcoming"<?php if ($scope == 'upcoming') { echo ' selected="selected"'; } ?> > <?php _e('Display upcoming shows', 'gigpress'); ?> </option> <option value="today"<?php if ($scope == 'today') { echo ' selected="selected"'; } ?> > <?php _e("Display today's shows", 'gigpress'); ?> </option> </select> </p> <p> <label for="<?php echo $this->get_field_id('limit'); ?> "><?php _e('Number of shows to list', 'gigpress'); ?> : <input style="width: 25px; text-align: center;" id="<?php echo $this->get_field_id('limit'); ?> " name="<?php echo $this->get_field_name('limit'); ?> " type="text" value="<?php echo $limit; ?> " /> </label> </p> <p> <label for="<?php echo $this->get_field_id('artist'); ?> "> <?php _e('Only display shows from this artist', 'gigpress'); ?> </label> <select style="width:100%;" id="<?php echo $this->get_field_id('artist'); ?> " name="<?php echo $this->get_field_name('artist'); ?> "> <option value="">--</option> <?php $artists = fetch_gigpress_artists(); if ($artists != FALSE) { foreach ($artists as $this_artist) { ?> <option value="<?php echo $this_artist->artist_id; ?> "<?php if ($artist == $this_artist->artist_id) { echo ' selected="selected"'; } ?> ><?php echo gigpress_db_out($this_artist->artist_name); ?> </option> <?php } } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('tour'); ?> "> <?php _e('Only display shows from this tour', 'gigpress'); ?> </label> <select style="width:100%;" id="<?php echo $this->get_field_id('tour'); ?> " name="<?php echo $this->get_field_name('tour'); ?> "> <option value="">--</option> <?php $tours = fetch_gigpress_tours(); if ($tours != FALSE) { foreach ($tours as $this_tour) { ?> <option value="<?php echo $this_tour->tour_id; ?> "<?php if ($tour == $this_tour->tour_id) { echo ' selected="selected"'; } ?> ><?php echo gigpress_db_out($this_tour->tour_name); ?> </option> <?php } } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('venue'); ?> "> <?php _e('Only display shows from this venue', 'gigpress'); ?> </label> <select style="width:100%;" id="<?php echo $this->get_field_id('venue'); ?> " name="<?php echo $this->get_field_name('venue'); ?> "> <option value="">--</option> <?php $venues = fetch_gigpress_venues(); if ($venues != FALSE) { foreach ($venues as $this_venue) { ?> <option value="<?php echo $this_venue->venue_id; ?> "<?php if ($venue == $this_venue->venue_id) { echo ' selected="selected"'; } ?> ><?php echo gigpress_db_out($this_venue->venue_name) . ' (' . gigpress_db_out($this_venue->venue_city) . ')'; ?> </option> <?php } } ?> </select> </p> <p> <label> <input id="<?php echo $this->get_field_id('group_artists'); ?> " name="<?php echo $this->get_field_name('group_artists'); ?> " type="checkbox" value="yes"<?php if ($group_artists == 'yes') { echo ' checked="checked"'; } ?> /> <?php _e('Group by artist', 'gigpress'); ?> <br /> <small><?php _e('Ignored when filtering by artist, tour, or venue.', 'gigpress'); ?> </small> </label> </p> <p> <select style="width:100%;" id="<?php echo $this->get_field_id('artist_order'); ?> " name="<?php echo $this->get_field_name('artist_order'); ?> "> <option value="alphabetical"<?php if ($artist_order == 'alphabetical') { echo ' selected="selected"'; } ?> > <?php _e("Order artists alphabetically", "gigpress"); ?> </option> <option value="custom"<?php if ($artist_order == 'custom') { echo ' selected="selected"'; } ?> > <?php _e("Order artists by custom order", "gigpress"); ?> </option> </select><br /> <small><?php _e('Ignored when not grouping by artist.', 'gigpress'); ?> </small> </p> <p> <label> <input id="<?php echo $this->get_field_id('show_tours'); ?> " name="<?php echo $this->get_field_name('show_tours'); ?> " type="checkbox" value="yes"<?php if ($show_tours == 'yes') { echo ' checked="checked"'; } ?> /> <?php _e('Group by tour', 'gigpress'); ?> </label> </p> <p> <label> <input id="<?php echo $this->get_field_id('show_feeds'); ?> " name="<?php echo $this->get_field_name('show_feeds'); ?> " type="checkbox" value="yes"<?php if ($show_feeds == 'yes') { echo ' checked="checked"'; } ?> /> <?php _e('Show RSS and iCal feeds', 'gigpress'); ?> </label> </p> <p> <label for="<?php echo $this->get_field_id('link_text'); ?> "><?php _e('Link text'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('link_text'); ?> " name="<?php echo $this->get_field_name('link_text'); ?> " type="text" value="<?php echo $link_text; ?> " /><br /> <small><?php _e('This phrase is used to link to the page specified in your GigPress settings. (Leave blank to disable this link.)', 'gigpress'); ?> </small> </label> </p> <?php }
function gigpress_add() { global $wpdb, $wp_locale; if (isset($_POST['gpaction']) && $_POST['gpaction'] == "add") { // This is for when we've just POST-ed a new show ... require_once 'handlers.php'; $result = gigpress_add_show(); } if (isset($_POST['gpaction']) && $_POST['gpaction'] == "update") { require_once 'handlers.php'; $result = gigpress_update_show(); } $gpo = get_option('gigpress_settings'); // If they're done with the welcome message, kill it if (isset($_GET['gpaction']) && $_GET['gpaction'] == "killwelcome") { $gpo['welcome'] = "no"; update_option('gigpress_settings', $gpo); $gpo = get_option('gigpress_settings'); } // If the welcome message is to be displayed, then do so if ($gpo['welcome'] == "yes") { ?> <div id="message" class="updated"> <p> <?php _e("<strong>Welcome to GigPress!</strong> Get started by adding your first show below. To display your shows, simply add the", "gigpress"); ?> [gigpress_shows] <?php _e("shortcode to any page or post.", "gigpress"); ?> <?php _e("Questions? Please check out the", "gigpress"); ?> <a href="http://gigpress.com/docs"><?php _e("documentation", "gigpress"); ?> </a> <?php _e("and", "gigpress"); ?> <a href="http://gigpress.com/faq"><?php _e("FAQ", "gigpress"); ?> </a> <?php _e("on the GigPress website. Enjoy!", "gigpress"); ?> <small>(<a href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=gigpress/gigpress.php&gpaction=killwelcome"><?php _e("Don't show this again", "gigpress"); ?> .</a>)</small> </p> </div> <?php } ?> <div class="wrap gigpress"> <?php // Setup months $gp_months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'); // Sanitize the show_id if we're editing or fixing errors $show_id = isset($_REQUEST['show_id']) ? $wpdb->prepare('%d', $_REQUEST['show_id']) : ''; // If the handler returned an array ($result), it means there were errors. // This takes precedence over any other conditionals below. if (is_array($result)) { $mm = $_POST['gp_mm']; $dd = $_POST['gp_dd']; $yy = $_POST['gp_yy']; $hh = $_POST['gp_hh']; $min = $_POST['gp_min']; $exp_mm = $_POST['exp_mm']; $exp_dd = $_POST['exp_dd']; $exp_yy = $_POST['exp_yy']; $show_multi = $_POST['show_multi']; $show_artist_id = $_POST['show_artist_id']; $show_venue_id = $_POST['show_venue_id']; $new_artist_name = gigpress_db_out($_POST['artist_name']); $new_venue_name = gigpress_db_out($_POST['venue_name']); $venue_address = gigpress_db_out($_POST['venue_address']); $new_venue_city = gigpress_db_out($_POST['venue_city']); $venue_country = gigpress_db_out($_POST['venue_country']); $venue_url = gigpress_db_out($_POST['venue_url']); $venue_phone = gigpress_db_out($_POST['venue_phone']); $new_tour_name = gigpress_db_out($_POST['tour_name']); $show_ages = gigpress_db_out($_POST['show_ages']); $show_tix_url = gigpress_db_out($_POST['show_tix_url']); $show_tix_phone = gigpress_db_out($_POST['show_tix_phone']); $show_notes = gigpress_db_out($_POST['show_notes']); $show_price = gigpress_db_out($_POST['show_price']); $show_tour_id = $_POST['show_tour_id']; $show_related = $_POST['show_related']; $show_related_title = gigpress_db_out($_POST['show_related_title']); $show_related_date = $_POST['show_related_date']; $show_status = $_POST['show_status']; $have_data = TRUE; } else { if (isset($_GET['gpaction']) && ($_GET['gpaction'] == "edit" || $_GET['gpaction'] == "copy")) { // We're about to edit an existing show ... // Load the previous show info into the edit form, and so forth $show_edit = $wpdb->get_results("\n\t\t\tSELECT * from " . GIGPRESS_SHOWS . " WHERE show_id = " . $show_id . " LIMIT 1\n\t\t\t"); if ($show_edit) { // We got the goods from the DB foreach ($show_edit as $show) { $show_date = explode('-', $show->show_date); $mm = $show_date[1]; $dd = $show_date[2]; $yy = $show_date[0]; $show_time = explode(':', $show->show_time); $hh = $show_time[0]; $min = $show_time[1]; $ss = $show_time[2]; if ($ss == "01") { $hh = "na"; $min = "na"; } $show_expire = explode('-', $show->show_expire); $exp_mm = $show_expire[1]; $exp_dd = $show_expire[2]; $exp_yy = $show_expire[0]; $show_multi = $show->show_multi; $show_artist_id = $show->show_artist_id; $show_venue_id = $show->show_venue_id; $show_ages = gigpress_db_out($show->show_ages); $show_tix_url = gigpress_db_out($show->show_tix_url); $show_tix_phone = gigpress_db_out($show->show_tix_phone); $show_notes = gigpress_db_out($show->show_notes); $show_price = gigpress_db_out($show->show_price); $show_tour_id = $show->show_tour_id; $show_related = $show->show_related; $show_related_title = $gpo['default_title']; $show_related_date = $gpo['related_date']; $show_status = $show->show_status; } $have_data = TRUE; } else { $have_data == FALSE; $load_error = '<div id="message" class="error fade"><p>' . __("Sorry, but we had trouble loading that show for editing.", "gigpress") . '</div>'; } } } if (!$have_data) { // We're adding a new show, so get the defaults $show_date = explode('-', $gpo['default_date']); $mm = $show_date[1]; $dd = $show_date[2]; $yy = $show_date[0]; $show_time = explode(':', $gpo['default_time']); $hh = $show_time[0]; $min = $show_time[1]; $ss = $show_time[2]; if ($ss == "01") { $hh = "na"; $min = "na"; } $show_expire = explode('-', $gpo['default_date']); $exp_mm = $show_expire[1]; $exp_dd = $show_expire[2]; $exp_yy = $show_expire[0]; $show_artist_id = $gpo['default_artist']; $show_tour_id = $gpo['default_tour']; $venue_country = $gpo['default_country']; $show_related_title = $gpo['default_title']; $show_related_date = $gpo['related_date']; } screen_icon('gigpress'); // We're editing a show if (isset($_GET['gpaction']) && $_GET['gpaction'] == "edit" && $show_edit || $result['editing'] == TRUE) { ?> <h2><?php _e("Edit this show", "gigpress"); ?> </h2> <form method="post" action="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=gigpress/gigpress.php"> <?php wp_nonce_field('gigpress-action'); ?> <input type="hidden" name="gpaction" value="update" /> <input type="hidden" name="show_id" value="<?php echo $show_id; ?> " /> <?php } else { // We're adding a new show ?> <h2><?php _e("Add a show", "gigpress"); ?> </h2> <?php if ($load_error) { echo $load_error; } ?> <form method="post" action="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=gigpress/gigpress.php"> <?php wp_nonce_field('gigpress-action'); ?> <input type="hidden" name="gpaction" value="add" /> <input type="hidden" name="show_status" value="active" /> <?php } ?> <table class="form-table gp-table" cellspacing="0"> <tbody> <tr> <th scope="row"><label for="gp_mm"><?php _e("Date", "gigpress"); ?> :<span class="gp-required">*</span></label></th> <td> <?php if ($result['show_date']) { echo '<span class="gigpress-error">'; } ?> <select name="gp_mm" id="gp_mm"> <?php foreach ($gp_months as $month) { ?> <option value="<?php echo $month; ?> "<?php if ($mm == $month) { ?> selected="selected"<?php } ?> > <?php echo $wp_locale->get_month($month); ?> </option> <?php } ?> </select> <select name="gp_dd" id="gp_dd"> <?php for ($i = 1; $i <= 31; $i++) { $i = $i < 10 ? '0' . $i : $i; echo '<option value="' . $i . '"'; if ($dd == $i) { echo ' selected="selected"'; } echo '>' . $i . '</option>'; } ?> </select> <select name="gp_yy" id="gp_yy"> <?php for ($i = 1900; $i <= 2050; $i++) { echo '<option value="' . $i . '"'; if ($yy == $i) { echo ' selected="selected"'; } echo '>' . $i . '</option>'; } ?> </select> <?php if ($result['show_date']) { echo '</span>'; } ?> <?php _e("at", "gigpress"); ?> <?php if ($gpo['alternate_clock'] == 1) { ?> <select name="gp_hh" id="gp_hh" class="twentyfour"> <option value="na"<?php if ($hh == "na") { echo ' selected="selected"'; } ?> >--</option> <option value="00"<?php if ($hh == "00") { echo ' selected="selected"'; } ?> >00</option> <option value="01"<?php if ($hh == "01") { echo ' selected="selected"'; } ?> >01</option> <option value="02"<?php if ($hh == "02") { echo ' selected="selected"'; } ?> >02</option> <option value="03"<?php if ($hh == "03") { echo ' selected="selected"'; } ?> >03</option> <option value="04"<?php if ($hh == "04") { echo ' selected="selected"'; } ?> >04</option> <option value="05"<?php if ($hh == "05") { echo ' selected="selected"'; } ?> >05</option> <option value="06"<?php if ($hh == "06") { echo ' selected="selected"'; } ?> >06</option> <option value="07"<?php if ($hh == "07") { echo ' selected="selected"'; } ?> >07</option> <option value="08"<?php if ($hh == "08") { echo ' selected="selected"'; } ?> >08</option> <option value="09"<?php if ($hh == "09") { echo ' selected="selected"'; } ?> >09</option> <option value="10"<?php if ($hh == "10") { echo ' selected="selected"'; } ?> >10</option> <option value="11"<?php if ($hh == "11") { echo ' selected="selected"'; } ?> >11</option> <option value="12"<?php if ($hh == "12") { echo ' selected="selected"'; } ?> >12</option> <option value="13"<?php if ($hh == "13") { echo ' selected="selected"'; } ?> >13</option> <option value="14"<?php if ($hh == "14") { echo ' selected="selected"'; } ?> >14</option> <option value="15"<?php if ($hh == "15") { echo ' selected="selected"'; } ?> >15</option> <option value="16"<?php if ($hh == "16") { echo ' selected="selected"'; } ?> >16</option> <option value="17"<?php if ($hh == "17") { echo ' selected="selected"'; } ?> >17</option> <option value="18"<?php if ($hh == "18") { echo ' selected="selected"'; } ?> >18</option> <option value="19"<?php if ($hh == "19") { echo ' selected="selected"'; } ?> >19</option> <option value="20"<?php if ($hh == "20") { echo ' selected="selected"'; } ?> >20</option> <option value="21"<?php if ($hh == "21") { echo ' selected="selected"'; } ?> >21</option> <option value="22"<?php if ($hh == "22") { echo ' selected="selected"'; } ?> >22</option> <option value="23"<?php if ($hh == "23") { echo ' selected="selected"'; } ?> >23</option> </select> <?php } else { ?> <select name="gp_hh" id="gp_hh" class="twelve"> <optgroup label="<?php _e("None", "gigpress"); ?> "> <option value="na"<?php if ($hh == "na") { echo ' selected="selected"'; } ?> >--</option> </optgroup> <optgroup id="am" label="AM"> <option value="00"<?php if ($hh == "00") { echo ' selected="selected"'; } ?> >12</option> <option value="01"<?php if ($hh == "01") { echo ' selected="selected"'; } ?> >01</option> <option value="02"<?php if ($hh == "02") { echo ' selected="selected"'; } ?> >02</option> <option value="03"<?php if ($hh == "03") { echo ' selected="selected"'; } ?> >03</option> <option value="04"<?php if ($hh == "04") { echo ' selected="selected"'; } ?> >04</option> <option value="05"<?php if ($hh == "05") { echo ' selected="selected"'; } ?> >05</option> <option value="06"<?php if ($hh == "06") { echo ' selected="selected"'; } ?> >06</option> <option value="07"<?php if ($hh == "07") { echo ' selected="selected"'; } ?> >07</option> <option value="08"<?php if ($hh == "08") { echo ' selected="selected"'; } ?> >08</option> <option value="09"<?php if ($hh == "09") { echo ' selected="selected"'; } ?> >09</option> <option value="10"<?php if ($hh == "10") { echo ' selected="selected"'; } ?> >10</option> <option value="11"<?php if ($hh == "11") { echo ' selected="selected"'; } ?> >11</option> </optgroup> <optgroup id="pm" label="PM"> <option value="12"<?php if ($hh == "12") { echo ' selected="selected"'; } ?> >12</option> <option value="13"<?php if ($hh == "13") { echo ' selected="selected"'; } ?> >01</option> <option value="14"<?php if ($hh == "14") { echo ' selected="selected"'; } ?> >02</option> <option value="15"<?php if ($hh == "15") { echo ' selected="selected"'; } ?> >03</option> <option value="16"<?php if ($hh == "16") { echo ' selected="selected"'; } ?> >04</option> <option value="17"<?php if ($hh == "17") { echo ' selected="selected"'; } ?> >05</option> <option value="18"<?php if ($hh == "18") { echo ' selected="selected"'; } ?> >06</option> <option value="19"<?php if ($hh == "19") { echo ' selected="selected"'; } ?> >07</option> <option value="20"<?php if ($hh == "20") { echo ' selected="selected"'; } ?> >08</option> <option value="21"<?php if ($hh == "21") { echo ' selected="selected"'; } ?> >09</option> <option value="22"<?php if ($hh == "22") { echo ' selected="selected"'; } ?> >10</option> <option value="23"<?php if ($hh == "23") { echo ' selected="selected"'; } ?> >11</option> </optgroup> </select> <?php } ?> <select name="gp_min" id="gp_min"> <option value="na"<?php if ($min == "na") { echo ' selected="selected"'; } ?> >--</option> <option value="00"<?php if ($min == "00") { echo ' selected="selected"'; } ?> >00</option> <option value="05"<?php if ($min == "05") { echo ' selected="selected"'; } ?> >05</option> <option value="10"<?php if ($min == "10") { echo ' selected="selected"'; } ?> >10</option> <option value="15"<?php if ($min == "15") { echo ' selected="selected"'; } ?> >15</option> <option value="20"<?php if ($min == "20") { echo ' selected="selected"'; } ?> >20</option> <option value="25"<?php if ($min == "25") { echo ' selected="selected"'; } ?> >25</option> <option value="30"<?php if ($min == "30") { echo ' selected="selected"'; } ?> >30</option> <option value="35"<?php if ($min == "35") { echo ' selected="selected"'; } ?> >35</option> <option value="40"<?php if ($min == "40") { echo ' selected="selected"'; } ?> >40</option> <option value="45"<?php if ($min == "45") { echo ' selected="selected"'; } ?> >45</option> <option value="50"<?php if ($min == "50") { echo ' selected="selected"'; } ?> >50</option> <option value="55"<?php if ($min == "55") { echo ' selected="selected"'; } ?> >55</option> </select> <span id="ampm"> </span> <p><span class="description"> <label><input type="checkbox" value="1"<?php if ($show_multi == 1) { echo ' checked="checked"'; } ?> id="show_multi" name="show_multi" /> <?php _e("This is a multi-day event", "gigpress"); ?> </label></span></p> </td> </tr> <!-- For multiple-day events --> <tr id="expire"<?php if ($show_multi != 1) { echo ' class="gigpress-inactive"'; } ?> > <th scope="row"><label for="exp_mm"><?php _e("End date", "gigpress"); ?> :</label></th> <td> <?php if ($result['expire_date']) { echo '<span class="gigpress-error">'; } ?> <select name="exp_mm" id="exp_mm"> <?php foreach ($gp_months as $month) { ?> <option value="<?php echo $month; ?> "<?php if ($exp_mm == $month) { ?> selected="selected"<?php } ?> > <?php echo $wp_locale->get_month($month); ?> </option> <?php } ?> </select> <select name="exp_dd" id="exp_dd"> <?php for ($i = 1; $i <= 31; $i++) { $i = $i < 10 ? '0' . $i : $i; echo '<option value="' . $i . '"'; if ($exp_dd == $i) { echo ' selected="selected"'; } echo '>' . $i . '</option>'; } ?> </select> <select name="exp_yy" id="exp_yy"> <?php for ($i = 1900; $i <= 2050; $i++) { echo '<option value="' . $i . '"'; if ($exp_yy == $i) { echo ' selected="selected"'; } echo '>' . $i . '</option>'; } ?> </select> <?php if ($result['expire_date']) { echo '</span>'; } ?> </td> </tr> <tr> <th scope="row"><label for="show_artist_id"><?php _e("Artist", "gigpress"); ?> :<span class="gp-required">*</span></label></th> <td> <select name="show_artist_id" id="show_artist_id" class="can-add-new"> <option value="new"<?php if ($show_artist_id == 'new') { echo ' selected="selected"'; } ?> ><?php _e("Add a new artist", "gigpress"); ?> </option> <option value="">------------------</option> <?php $artists = fetch_gigpress_artists(); if ($artists != FALSE) { foreach ($artists as $artist) { $artist_name = gigpress_db_out($artist->artist_name); echo "<option value=\"{$artist->artist_id}\""; if ($show_artist_id == $artist->artist_id) { echo ' selected="selected"'; } echo ">{$artist_name}</option>\n\t\t\t"; } } else { echo '<option value="0" selected="selected">' . __("No artists in the database", "gigpress") . '</option>'; } ?> </select> </td> </tr> </tbody> <tbody id="show_artist_id_new" class="gigpress-addition<?php if ($show_artist_id != 'new') { echo ' gigpress-inactive'; } ?> "> <tr> <th scope="row"><label for="artist_name"><?php _e("Artist name", "gigpress"); ?> :</label></th> <td><input type="text" size="48" name="artist_name" id="artist_name" value="<?php echo $new_artist_name; ?> "<?php if ($result['artist_name']) { echo ' class="gigpress-error"'; } ?> /></td> </tr> </tbody> <tbody> <tr> <th scope="row"><label for="show_venue_id"><?php _e("Venue", "gigpress"); ?> :<span class="gp-required">*</span></label></th> <td> <select name="show_venue_id" id="show_venue_id" class="can-add-new"> <option value="new"<?php if ($show_venue_id == 'new') { echo ' selected="selected"'; } ?> ><?php _e("Add a new venue", "gigpress"); ?> </option> <option value="">------------------</option> <option value=""<?php if (!$show_venue_id) { echo ' selected="selected"'; } ?> ><?php _e("Select a venue", "gigpress"); ?> </option> <option value="">------------------</option> <?php $venues = fetch_gigpress_venues(); if ($venues != FALSE) { foreach ($venues as $venue) { $venue_name = gigpress_db_out($venue->venue_name); $venue_city = gigpress_db_out($venue->venue_city); echo "<option value=\"{$venue->venue_id}\""; if ($show_venue_id == $venue->venue_id) { echo ' selected="selected"'; } echo ">{$venue_name} ({$venue_city})</option>\n\t\t\t"; } } else { echo "<option value=\"0\">" . __("No venues in the database", "gigpress") . "</option>/n/t/t/t"; } ?> </select> </td> </tr> </tbody> <tbody id="show_venue_id_new" class="gigpress-addition<?php if ($show_venue_id != 'new') { echo ' gigpress-inactive'; } ?> "> <tr> <th scope="row"><label for="venue_name"><?php _e("Venue name", "gigpress"); ?> :<span class="gp-required">*</span></label> </th> <td><input type="text" size="48" name="venue_name" id="venue_name" value="<?php echo $new_venue_name; ?> "<?php if ($result['venue_name']) { echo ' class="gigpress-error"'; } ?> /></td> </tr> <tr> <th scope="row"><label for="venue_city"><?php _e("Venue city", "gigpress"); ?> :<span class="gp-required">*</span></label></th> <td><input type="text" size="48" name="venue_city" id="venue_city" value="<?php echo $new_venue_city; ?> "<?php if ($result['venue_city']) { echo ' class="gigpress-error"'; } ?> class="required" /></td> </tr> <tr> <th scope="row"><label for="venue_address"><?php _e("Venue address", "gigpress"); ?> :</label></th> <td><input type="text" size="48" name="venue_address" id="venue_address" value="<?php echo $venue_address; ?> " /></td> </tr> <tr> <th scope="row"><label for="venue_country"><?php _e("Venue country", "gigpress"); ?> :</label></th> <td> <select name="venue_country" id="venue_country"> <?php global $gp_countries; foreach ($gp_countries as $code => $name) { $sel = $code == $venue_country ? ' selected="selected"' : ''; echo '<option value="' . $code . '"' . $sel . '>' . $name . '</option>'; } ?> </select> </td> </tr> <tr> <th scope="row"><label for="venue_url"><?php _e("Venue website", "gigpress"); ?> :</label></th> <td><input type="text" size="48" name="venue_url" id="venue_url" value="<?php echo $venue_url; ?> " /></td> </tr> <tr> <th scope="row"><label for="venue_phone"><?php _e("Venue phone", "gigpress"); ?> :</label></th> <td><input type="text" size="48" name="venue_phone" id="venue_phone" value="<?php echo $venue_phone; ?> " /></td> </tr> </tbody> <tbody> <?php if ($_GET['gpaction'] == 'edit' || $result['editing'] == TRUE) { ?> <tr> <th scope="row"><label for="show_status"><?php _e("Status", "gigpress"); ?> :</label></th> <td><select name="show_status" id="show_status"> <option value="active"<?php if ($show_status == 'active') { echo ' selected="selected"'; } ?> ><?php _e("Active", "gigpress"); ?> </option> <option value="soldout"<?php if ($show_status == 'soldout') { echo ' selected="selected"'; } ?> ><?php _e("Sold Out", "gigpress"); ?> </option> <option value="cancelled"<?php if ($show_status == 'cancelled') { echo ' selected="selected"'; } ?> ><?php _e("Cancelled", "gigpress"); ?> </option> </select> </td> </tr> <?php } ?> <tr> <th scope="row"><label for="show_ages"><?php _e("Admittance", "gigpress"); ?> :</label></th> <td><select name="show_ages" id="show_ages"> <option value="Not sure"<?php if ($show_ages == "Not sure") { echo ' selected="selected"'; } ?> ><?php _e("Not sure", "gigpress"); ?> </option> <?php $ages = explode('|', $gpo['age_restrictions']); foreach ($ages as $age) { $age = trim($age); $selected = $show_ages == $age ? ' selected="selected"' : ''; echo '<option value="' . $age . '"' . $selected . '>' . $age . '</option> '; } ?> </select> </td> </tr> <tr> <th scope="row"><label for="show_price"><?php _e("Price", "gigpress"); ?> :</label></th> <td><input type="text" size="10" name="show_price" id="show_price" value="<?php echo $show_price; ?> " /> <span class="description">(<?php _e("include currency symbol", "gigpress"); ?> )</span></td> </tr> <tr> <th scope="row"><label for="show_tix_url"><?php _e("Ticket URL", "gigpress"); ?> :</label></th> <td><input type="text" size="48" name="show_tix_url" id="show_tix_url" value="<?php echo $show_tix_url; ?> " /></td> </tr> <tr> <th scope="row"><label for="show_tix_phone"><?php _e("Ticket phone", "gigpress"); ?> :</label></th> <td><input type="text" size="48" name="show_tix_phone" id="show_tix_phone" value="<?php echo $show_tix_phone; ?> " /></td> </tr> <tr> <th scope="row"><label for="show_notes"><?php _e("Notes", "gigpress"); ?> :</label></th> <td> <textarea name="show_notes" id="show_notes" cols="45" rows="5"><?php echo $show_notes; ?> </textarea><br /> <span class="description"><?php _e("Use this space to list other bands, 'presented by' info, etc", "gigpress"); ?> </span> </td> </tr> <tr> <th scope="row"><label for="show_tour_id"><?php _e("Part of a tour?", "gigpress"); ?> </label></th> <td> <select name="show_tour_id" id="show_tour_id" class="can-add-new"> <option value="0"><?php _e("No", "gigpress"); ?> </option> <option value="0">------------------</option> <option value="new"<?php if ($show_tour_id == 'new') { echo ' selected="selected"'; } ?> ><?php _e("Add a new tour", "gigpress"); ?> </option> <option value="0">------------------</option> <?php $tours = fetch_gigpress_tours(); if ($tours != FALSE) { foreach ($tours as $tour) { $tour_name = gigpress_db_out($tour->tour_name); echo "<option value=\"{$tour->tour_id}\""; if ($show_tour_id == $tour->tour_id) { echo ' selected="selected"'; } echo ">{$tour_name}</option>\n\t\t\t"; } } else { echo "<option value=\"\">" . __("No tours in the database", "gigpress") . "</option>/n/t/t/t"; } ?> </select> </td> </tr> </tbody> <tbody id="show_tour_id_new" class="gigpress-addition<?php if ($show_tour_id != 'new') { echo ' gigpress-inactive'; } ?> "> <tr> <th scope="row"><label for="tour_name"><?php _e("Tour name", "gigpress"); ?> :</label></th> <td><input type="text" size="48" name="tour_name" id="tour_name" value="<?php echo $new_tour_name; ?> "<?php if ($result['tour_name']) { echo ' class="gigpress-error"'; } ?> /></td> </tr> </tbody> <tbody> <tr> <th scope="row"><label for="show_related"><?php _e("Related post", "gigpress"); ?> :</label></th> <td> <select name="show_related" id="show_related" class="can-add-new"> <option value="0"><?php _e("None", "gigpress"); ?> </option> <option value="0">------------------</option> <option value="new"<?php if ($_GET['gpaction'] != "edit" && $gpo['autocreate_post'] == "1") { echo ' selected="selected"'; } ?> ><?php _e("Add a new post", "gigpress"); ?> </option> <option value="0">------------------</option> <?php $entries = $wpdb->get_results("SELECT ID, post_title FROM " . $wpdb->prefix . "posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY ID DESC LIMIT 500", ARRAY_A); if ($entries != FALSE) { foreach ($entries as $entry) { ?> <option value="<?php echo $entry['ID']; ?> "<?php if ($entry['ID'] == $show_related) { echo ' selected="selected"'; $found_related = TRUE; } ?> ><?php echo gigpress_db_out($entry['post_title']); ?> </option> <?php } } ?> <?php if ($show_related != FALSE && !isset($found_related)) { $old_related = $wpdb->get_results("SELECT ID, post_title FROM " . $wpdb->prefix . "posts WHERE post_status = 'publish' AND post_type = 'post' AND ID = " . $wpdb->prepare('%d', $show_related) . " LIMIT 1", ARRAY_A); if ($old_related != FALSE) { foreach ($old_related as $entry) { ?> <option value="<?php echo $entry['ID']; ?> " selected="selected"><?php echo gigpress_db_out($entry['post_title']); ?> </option> <?php } } } ?> </select> </td> </tr> </tbody> <tbody id="show_related_new" class="gigpress-addition<?php if ($show_related != 'new' && $gpo['autocreate_post'] != "1") { echo ' gigpress-inactive'; } ?> "> <tr> <th scope="row"><label for="show_related_title"><?php _e("Related post title", "gigpress"); ?> :</label></th> <td><input type="text" size="48" name="show_related_title" id="show_related_title" value="<?php echo $show_related_title; ?> " /><br /> <span class="description"><?php _e("Available placeholders:", "gigpress"); ?> <code>%date%</code>, <code>%long_date%</code>, <code>%artist%</code>, <code>%city%</code>, <code>%venue%</code>.</span><br /> <label><input type="radio" name="show_related_date" value="now"<?php if ($show_related_date == 'now') { echo ' checked="checked"'; } ?> /> <?php _e('Publish now', 'gigpress'); ?> </label> <label><input type="radio" name="show_related_date" value="show"<?php if ($show_related_date == 'show') { echo ' checked="checked"'; } ?> /> <?php _e('Publish on show date', 'gigpress'); ?> </label> </td> </tr> </tbody> <tbody> <tr> <td> </td> <td> <?php if (isset($_GET['gpaction']) && $_GET['gpaction'] == "edit" || $result['editing'] == TRUE) { ?> <span class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e("Update show", "gigpress"); ?> " /></span> <?php _e("or", "gigpress"); ?> <a href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=gigpress-shows"><?php _e("cancel", "gigpress"); ?> </a> <?php } else { ?> <span class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e("Add show", "gigpress"); ?> " /></span> <?php } ?> </td> </tr> </tbody> </table> </form> </div> <?php unset($result); }
function gigpress_artists() { global $wpdb; if (isset($_POST['gpaction']) && $_POST['gpaction'] == "add") { require_once 'handlers.php'; $result = gigpress_add_artist(); } if (isset($_POST['gpaction']) && $_POST['gpaction'] == "update") { require_once 'handlers.php'; $result = gigpress_update_artist(); } if (isset($_GET['gpaction']) && $_GET['gpaction'] == "delete") { require_once 'handlers.php'; gigpress_delete_artist(); } if (isset($_GET['gpaction']) && $_GET['gpaction'] == "import-tours") { require_once 'handlers.php'; gigpress_map_tours_to_artists(); } $url_args = isset($_GET['gp-page']) ? '&gp-page=' . $_GET['gp-page'] : ''; ?> <div class="wrap gigpress gp-artists"> <?php screen_icon('gigpress'); ?> <h2><?php _e("Artists", "gigpress"); ?> </h2> <?php if (isset($_GET['gpaction']) && $_GET['gpaction'] == "edit" || is_array($result) && $result['editing'] == TRUE) { $artist_id = isset($_REQUEST['artist_id']) ? $wpdb->prepare('%d', $_REQUEST['artist_id']) : ''; $artist_name = gigpress_db_out($wpdb->get_var("SELECT artist_name from " . GIGPRESS_ARTISTS . " WHERE artist_id = " . $artist_id)); if ($artist_name) { $submit = '<span class="submit"><input type="submit" name="Submit" class="button-primary" value="' . __("Update artist", "gigpress") . '" /></span> ' . __("or", "gigpress") . ' <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=gigpress-artists' . $url_args . '">' . __("cancel", "gigpress") . '</a>'; ?> <h3><?php _e("Edit this artist", "gigpress"); ?> </h3> <form method="post" action="<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=gigpress-artists" . $url_args; ?> "> <input type="hidden" name="gpaction" value="update" /> <input type="hidden" name="artist_id" value="<?php echo $artist_id; ?> " /> <?php } else { ?> <div id="message" class="error fade"><p><?php _e("Sorry, but we had trouble loading that artist for editing.", "gigpress"); ?> </p></div> <h3><?php _e("Add an artist", "gigpress"); ?> </h3> <?php } } else { $artist_name = ''; $submit = '<span class="submit"><input type="submit" name="Submit" class="button-primary" value="' . __("Add artist", "gigpress") . '" /></span>'; ?> <h3><?php _e("Add an artist", "gigpress"); ?> </h3> <form method="post" action="<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=gigpress-artists" . $url_args; ?> "> <input type="hidden" name="gpaction" value="add" /> <?php } wp_nonce_field('gigpress-action'); ?> <table class="form-table gp-table"> <tr> <th scope="row"><label for="artist_name"><?php _e("Artist name", "gigpress"); ?> :</label></th> <td> <input name="artist_name" id="artist_name" type="text" size="48" value="<?php echo $artist_name; ?> " /> <?php echo $submit; ?> </td> </tr> </table> </form> <h3><?php _e("All artists", "gigpress"); ?> </h3> <div class="tablenav"> <div class="alignleft"><p><?php _e("Note that you cannot delete an artist while they have shows in the database.", "gigpress"); ?> </p></div> <?php $artists = fetch_gigpress_artists(); /* Removed pagination to allow for single-page AJAX reordering. Complaints might being it back? if($artists) { $pagination_args['page'] = 'gigpress-artists'; $pagination = gigpress_admin_pagination(count($artists), 20, $pagination_args); if($pagination) { $artists = array_slice($artists, $pagination['offset'], $pagination['records_per_page']); echo $pagination['output']; } } */ ?> </div> <table class="widefat"> <thead> <tr> <th scope="col" class="gp-tiny"> </th> <th scope="col" class="gp-tiny">ID</th> <th scope="col"><?php _e("Artist name", "gigpress"); ?> </th> <th scope="col" class="gp-centre"><?php _e("Number of shows", "gigpress"); ?> </th> <th class="gp-centre" scope="col"><?php _e("Actions", "gigpress"); ?> </th> </tr> </thead> <tbody class="gigpress-artist-sort"> <?php if ($artists) { foreach ($artists as $artist) { if ($n = $wpdb->get_var("SELECT count(*) FROM " . GIGPRESS_SHOWS . " WHERE show_artist_id = " . $artist->artist_id . " AND show_status != 'deleted'")) { $count = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=gigpress-shows&artist_id=' . $artist->artist_id . '">' . $n . '</a>'; } else { $count = 0; } ++$i; $style = $i % 2 ? '' : ' class="alternate"'; // Print out our rows. ?> <tr<?php echo $style; ?> id="artist_<?php echo $artist->artist_id; ?> "> <td class="gp-tiny"><img src="<?php echo WP_PLUGIN_URL; ?> /gigpress/images/sort.png" alt="" class="gp-sort-handle" /></td> <td class="gp-tiny"><?php echo $artist->artist_id; ?> </td> <td><?php echo wptexturize($artist->artist_name); ?> </td> <td class="gp-centre"><?php echo $count; ?> </td> <td class="gp-centre"> <a href="<?php echo get_bloginfo('wpurl') . '/wp-admin/admin.php?page=gigpress-artists&gpaction=edit&artist_id=' . $artist->artist_id . $url_args; ?> " class="edit"><?php _e("Edit", "gigpress"); ?> </a> <?php if (!$count) { ?> | <a href="<?php echo wp_nonce_url(get_bloginfo('wpurl') . '/wp-admin/admin.php?page=gigpress-artists&gpaction=delete&artist_id=' . $artist->artist_id . $url_args, 'gigpress-action'); ?> " class="delete"><?php _e("Delete", "gigpress"); ?> </a><?php } ?> </td> </tr> <?php } } else { // We don't have any artists, so let's say so ?> <tr><td colspan="5"><strong><?php _e("No artists in the database", "gigpress"); ?> </strong></td></tr> <?php } ?> </tbody> <tfoot> <tr> <th scope="col" class="gp-tiny"> </th> <th scope="col" class="gp-tiny">ID</th> <th scope="col"><?php _e("Artist name", "gigpress"); ?> </th> <th scope="col" class="gp-centre"><?php _e("Number of shows", "gigpress"); ?> </th> <th class="gp-centre" scope="col"><?php _e("Actions", "gigpress"); ?> </th> </tr> </tfoot> </table> <?php if ($pagination) { ?> <div class="tablenav"> <?php // echo $pagination['output']; ?> </div> <?php } ?> <div id="artist-sort-update"></div> </div> <?php }
function gigpress_import_export() { global $wpdb, $gpo; ?> <div class="wrap gigpress gp-options"> <?php screen_icon('gigpress'); ?> <h2><?php _e("Import/Export", "gigpress"); ?> </h2> <div class="gp-import-panel"> <h3>Import</h3> <p><?php _e("Upload a CSV (comma-separated values) file to import into your GigPress database.", "gigpress"); ?> <a href="http://gigpress.com/docs/#import"><strong><?php _e("Please review the formatting specifications to save yourself headaches!", "gigpress"); ?> </strong></a></p> <div class="form-wrap"> <form action="" enctype="multipart/form-data" method="POST"> <div> <?php wp_nonce_field('gigpress-action'); ?> <input type="hidden" name="gpaction" value="import" /> <input type="file" name="gp_import" /> <p> <label><input type="checkbox" name="include_related" value="y" /> <?php _e("Include Related Post associations?", "gigpress"); ?> </label> </p> <input type="submit" class="button" value="<?php _e("Upload CSV", "gigpress"); ?> " /> </div> </form> </div> <?php if (isset($_POST['gpaction']) && $_POST['gpaction'] == "import") { require_once 'handlers.php'; gigpress_import(); } ?> </div> <div class="gp-export-panel"> <h3>Export</h3> <p><?php _e("Download your complete show database as a CSV (comma-separated values) file, compatible with programs such as Microsoft Excel. This file is also suitable to import into another GigPress installation.", "gigpress"); ?> </p> <form action="admin-post.php" method="post"> <div> <?php wp_nonce_field('gigpress-action'); ?> <input type="hidden" name="action" value="gigpress_export" /> </div> <div style="margin-bottom:5px;"> <select name="artist_id"> <option value="-1"><?php _e("Export all artists", "gigpress"); ?> </option> <?php $artistdata = fetch_gigpress_artists(); if ($artistdata) { foreach ($artistdata as $artist) { echo '<option value="' . $artist->artist_id . '">' . gigpress_db_out($artist->artist_name) . '</option>'; } } else { echo '<option value="-1">' . __("No artists in the database", "gigpress") . '</option>'; } ?> </select> </div> <div style="margin-bottom:5px;"> <select name="tour_id"> <option value="-1"><?php _e("Export all tours", "gigpress"); ?> </option> <?php $tourdata = fetch_gigpress_tours(); if ($tourdata) { foreach ($tourdata as $tour) { echo '<option value="' . $tour->tour_id . '">' . gigpress_db_out($tour->tour_name) . '</option>'; } } else { echo '<option value="-1">' . __("No tours in the database", "gigpress") . '</option>'; } ?> </select> </div> <div style="margin-bottom:5px;"> <select name="scope"> <option value="-1"><?php _e("Export all dates", "gigpress"); ?> </option> <option value="upcoming"><?php _e("Export upcoming dates", "gigpress"); ?> </option> <option value="past"><?php _e("Export past dates", "gigpress"); ?> </option> </select> </div> <div> <input type="submit" value="<?php _e("Download CSV", "gigpress"); ?> " class="button-secondary" /> </div> </form> </div> </div> <?php }
function gigpress_admin_shows() { if (isset($_REQUEST['gpaction']) && $_REQUEST['gpaction'] == "delete") { require_once 'handlers.php'; gigpress_delete_show(); } if (isset($_GET['gpaction']) && $_GET['gpaction'] == "undo") { require_once 'handlers.php'; gigpress_undo('show'); } if (isset($_POST['gpaction']) && $_POST['gpaction'] == "update") { require_once 'handlers.php'; gigpress_update_show(); } if (isset($_GET['gpaction']) && $_GET['gpaction'] == "trash") { require_once 'handlers.php'; gigpress_empty_trash(); } global $wpdb, $gpo; // Checks for filtering and pagination $url_args = ''; $further_where = ''; $pagination_args = array(); switch ($_GET['scope']) { case 'upcoming': $condition = ">= '" . GIGPRESS_NOW . "'"; $url_args .= '&scope=upcoming'; $pagination_args['scope'] = 'upcoming'; break; case 'past': $condition = "< '" . GIGPRESS_NOW . "'"; $url_args .= '&scope=past'; $pagination_args['scope'] = 'past'; break; default: $condition = 'IS NOT NULL'; } global $current_user; get_currentuserinfo(); switch ($_GET['sort']) { case 'asc': $sort = 'ASC'; update_usermeta($current_user->ID, 'gigpress_sort', $sort); break; case 'desc': $sort = 'DESC'; update_usermeta($current_user->ID, 'gigpress_sort', $sort); break; } if (!isset($_GET['sort'])) { if (!($sort = get_usermeta($current_user->ID, 'gigpress_sort'))) { $sort = 'DESC'; update_usermeta($current_user->ID, 'gigpress_sort', $sort); } } if (isset($_GET['gp-page'])) { $url_args .= '&gp-page=' . $_GET['gp-page']; } if (isset($_GET['artist_id']) && $_GET['artist_id'] != '-1') { $further_where .= ' AND s.show_artist_id = ' . $wpdb->prepare('%d', $_GET['artist_id']) . ' '; $pagination_args['artist_id'] = $_GET['artist_id']; $url_args .= '&artist_id=' . $_GET['artist_id']; } if (isset($_GET['tour_id']) && $_GET['tour_id'] != '-1') { $further_where .= ' AND s.show_tour_id = ' . $wpdb->prepare('%d', $_GET['tour_id']) . ' '; $pagination_args['tour_id'] = $_GET['tour_id']; $url_args .= '&tour_id=' . $_GET['tour_id']; } if (isset($_GET['venue_id']) && $_GET['venue_id'] != '-1') { $further_where .= ' AND s.show_venue_id = ' . $wpdb->prepare('%d', $_GET['venue_id']) . ' '; $pagination_args['venue_id'] = $_GET['venue_id']; $url_args .= '&venue_id=' . $_GET['venue_id']; } // Build pagination $show_count = $wpdb->get_var("SELECT COUNT(*) FROM " . GIGPRESS_ARTISTS . " AS a, " . GIGPRESS_VENUES . " as v, " . GIGPRESS_SHOWS . " AS s LEFT JOIN " . GIGPRESS_TOURS . " AS t ON s.show_tour_id = t.tour_id WHERE show_expire " . $condition . " AND show_status != 'deleted' AND s.show_artist_id = a.artist_id AND s.show_venue_id = v.venue_id " . $further_where . "ORDER BY show_date " . $sort . ",show_time " . $sort); if ($show_count) { $pagination_args['page'] = 'gigpress-shows'; $pagination = gigpress_admin_pagination($show_count, 10, $pagination_args); } $limit = isset($_GET['gp-page']) ? $pagination['offset'] . ',' . $pagination['records_per_page'] : 10; // Build the query $shows = $wpdb->get_results("\n\t\tSELECT * FROM " . GIGPRESS_ARTISTS . " AS a, " . GIGPRESS_VENUES . " as v, " . GIGPRESS_SHOWS . " AS s LEFT JOIN " . GIGPRESS_TOURS . " AS t ON s.show_tour_id = t.tour_id WHERE show_expire " . $condition . " AND show_status != 'deleted' AND s.show_artist_id = a.artist_id AND s.show_venue_id = v.venue_id " . $further_where . "ORDER BY show_date " . $sort . ",show_expire " . $sort . ",show_time " . $sort . " LIMIT " . $limit); ?> <div class="wrap gigpress"> <?php screen_icon('gigpress'); ?> <h2><?php _e("Shows", "gigpress"); ?> </h2> <ul class="subsubsub"> <?php $all = $wpdb->get_var("SELECT COUNT(show_id) FROM " . GIGPRESS_SHOWS . " WHERE show_status != 'deleted'"); $upcoming = $wpdb->get_var("SELECT count(show_id) FROM " . GIGPRESS_SHOWS . " WHERE show_expire >= '" . GIGPRESS_NOW . "' AND show_status != 'deleted'"); $past = $wpdb->get_var("SELECT count(show_id) FROM " . GIGPRESS_SHOWS . " WHERE show_expire < '" . GIGPRESS_NOW . "' AND show_status != 'deleted'"); echo '<li><a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=gigpress-shows"'; if (!isset($_GET['scope'])) { echo ' class="current"'; } echo '>' . __("All", "gigpress") . '</a> <span class="count">(' . $all . ')</span> | </li>'; echo '<li><a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=gigpress-shows&scope=upcoming"'; if (isset($_GET['scope']) && $_GET['scope'] == 'upcoming') { echo ' class="current"'; } echo '>' . __("Upcoming", "gigpress") . '</a> <span class="count">(' . $upcoming . ')</span> | </li>'; echo '<li><a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=gigpress-shows&scope=past"'; if (isset($_GET['scope']) && $_GET['scope'] == 'past') { echo ' class="current"'; } echo '>' . __("Past", "gigpress") . '</a> <span class="count">(' . $past . ')</span></li>'; ?> </ul> <div class="tablenav"> <div class="alignleft"> <form action="" method="get"> <div> <input type="hidden" name="page" value="gigpress-shows" /> <?php if (isset($_GET['scope'])) { ?> <input type="hidden" name="scope" value="<?php echo $_GET['scope']; ?> " /> <?php } ?> <select name="artist_id"> <option value="-1"><?php _e("View all artists", "gigpress"); ?> </option> <?php $artistdata = fetch_gigpress_artists(); if ($artistdata) { foreach ($artistdata as $artist) { $selected = isset($_GET['artist_id']) && $_GET['artist_id'] == $artist->artist_id ? ' selected="selected"' : ''; echo '<option value="' . $artist->artist_id . '"' . $selected . '>' . gigpress_db_out($artist->artist_name) . '</option>'; } } else { echo '<option value="-1">' . __("No artists in the database", "gigpress") . '</option>'; } ?> </select> <select name="tour_id"> <option value="-1"><?php _e("View all tours", "gigpress"); ?> </option> <?php $tourdata = fetch_gigpress_tours(); if ($tourdata) { foreach ($tourdata as $tour) { $selected = isset($_GET['tour_id']) && $_GET['tour_id'] == $tour->tour_id ? ' selected="selected"' : ''; echo '<option value="' . $tour->tour_id . '"' . $selected . '>' . gigpress_db_out($tour->tour_name) . '</option>'; } } else { echo '<option value="-1">' . __("No tours in the database", "gigpress") . '</option>'; } ?> </select> <select name="venue_id"> <option value="-1"><?php _e("View all venues", "gigpress"); ?> </option> <?php $venuedata = fetch_gigpress_venues(); if ($venuedata) { foreach ($venuedata as $venue) { $selected = isset($_GET['venue_id']) && $_GET['venue_id'] == $venue->venue_id ? ' selected="selected"' : ''; echo '<option value="' . $venue->venue_id . '"' . $selected . '>' . gigpress_db_out($venue->venue_name) . '</option>'; } } else { echo '<option value="-1">' . __("No venues in the database", "gigpress") . '</option>'; } ?> </select> <select name="sort"> <option value="desc"<?php if ($sort == 'DESC') { echo ' selected="selected"'; } ?> ><?php _e("Descending", "gigpress"); ?> </option> <option value="asc"<?php if ($sort == 'ASC') { echo ' selected="selected"'; } ?> ><?php _e("Ascending", "gigpress"); ?> </option> </select> <input type="submit" value="Filter" class="button-secondary" /> </div> </form> </div> <?php if ($pagination) { echo $pagination['output']; } ?> <div class="clear"></div> </div> <form action="" method="post"> <?php wp_nonce_field('gigpress-action'); ?> <input type="hidden" name="gpaction" value="delete" /> <table class="widefat"> <thead> <tr> <th scope="col" class="column-cb check-column"><input type="checkbox" /></th> <th scope="col"><?php _e("Date", "gigpress"); ?> </th> <th scope="col"><?php _e("Artist", "gigpress"); ?> </th> <th scope="col"><?php _e("City", "gigpress"); ?> </th> <th scope="col"><?php _e("Venue", "gigpress"); ?> </th> <th scope="col"><?php _e("Country", "gigpress"); ?> </th> <th scope="col"><?php _e("Tour", "gigpress"); ?> </th> <th class="gp-centre" scope="col"><?php _e("Actions", "gigpress"); ?> </th> </tr> </thead> <tfoot> <tr> <th scope="col" class="column-cb check-column"><input type="checkbox" /></th> <th scope="col"><?php _e("Date", "gigpress"); ?> </th> <th scope="col"><?php _e("Artist", "gigpress"); ?> </th> <th scope="col"><?php _e("City", "gigpress"); ?> </th> <th scope="col"><?php _e("Venue", "gigpress"); ?> </th> <th scope="col"><?php _e("Country", "gigpress"); ?> </th> <th scope="col"><?php _e("Tour", "gigpress"); ?> </th> <th class="gp-centre" scope="col"><?php _e("Actions", "gigpress"); ?> </th> </tr> </tfoot> <tbody> <?php // Do we have dates? if ($shows != FALSE) { foreach ($shows as $show) { $showdata = gigpress_prepare($show, 'admin'); ?> <tr class="<?php echo 'gigpress-' . $showdata['status']; ?> "> <th scope="row" class="check-column"><input type="checkbox" name="show_id[]" value="<?php echo $show->show_id; ?> " /></th> <td><span class="gigpress-date"><?php echo $showdata['date']; if ($showdata['end_date']) { echo ' - ' . $showdata['end_date']; } ?> </span> </td> <td><?php echo $showdata['artist']; ?> </td> <td><?php echo $showdata['city']; ?> </td> <td><?php echo $showdata['venue']; if ($showdata['address']) { echo ' (' . $showdata['address'] . ')'; } ?> </td> <td><?php echo $showdata['country']; ?> </td> <td><?php echo $showdata['tour']; ?> </td> <td class="gp-centre"> <a href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=gigpress/gigpress.php&gpaction=edit&show_id=<?php echo $show->show_id; ?> " class="edit" title="<?php _e("Edit", "gigpress"); ?> "><?php _e("Edit", "gigpress"); ?> </a> | <a href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=gigpress/gigpress.php&gpaction=copy&show_id=<?php echo $show->show_id; ?> " class="edit" title="<?php _e("Copy", "gigpress"); ?> "><?php _e("Copy", "gigpress"); ?> </a> </td> </tr> <tr class="<?php echo 'alternate' . ' gigpress-' . $showdata['status']; ?> "> <td colspan="8"><small> <?php if ($showdata['time']) { echo $showdata['time'] . '. '; } if ($showdata['price']) { echo __("Price", "gigpress") . ': ' . $showdata['price'] . '. '; } if ($showdata['admittance']) { echo $showdata['admittance'] . '. '; } if ($showdata['ticket_link']) { echo $showdata['ticket_link'] . '. '; } if ($showdata['ticket_phone']) { echo __('Box office', "gigpress") . ': ' . $showdata['ticket_phone'] . '. '; } echo $showdata['notes'] . ' '; echo $showdata['related_edit']; ?> </small></td> </tr> <?php } // end foreach } else { // No results from the query ?> <tr><td colspan="8"><?php _e("Sorry, no shows to display based on your criteria.", "gigpress"); ?> </td></tr> <?php } ?> </tbody> </table> <div class="tablenav"> <div class="alignleft"> <input type="submit" value="<?php _e('Trash selected shows', 'gigpress'); ?> " class="button-secondary" /> <?php if ($tour_count = $wpdb->get_var("SELECT count(*) FROM " . GIGPRESS_TOURS . " WHERE tour_status = 'deleted'")) { $tours = $tour_count; } else { $tours = 0; } if ($show_count = $wpdb->get_var("SELECT count(*) FROM " . GIGPRESS_SHOWS . " WHERE show_status = 'deleted'")) { $shows = $show_count; } else { $shows = 0; } if ($tour_count || $show_count) { echo '<small>' . __("You have", "gigpress") . ' <strong>' . $shows . ' ' . __("shows", "gigpress") . '</strong> ' . __("and", "gigpress") . ' <strong>' . $tours . ' ' . __("tours", "gigpress") . '</strong> ' . __("in your trash", "gigpress") . '.'; if ($shows != 0 || $tours != 0) { echo ' <a href="' . wp_nonce_url(get_bloginfo('wpurl') . '/wp-admin/admin.php?page=gigpress-shows&gpaction=trash' . $url_args, 'gigpress-action') . '">' . __("Take out the trash now", "gigpress") . '</a>.'; } echo '</small>'; } ?> </div> <?php if ($pagination) { echo $pagination['output']; } ?> </div> </form> </div> <?php }