Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Event Listing for Oscommerce 2.3.4


shelby72

Recommended Posts

I have Oscommerce 2.3.4 BS and have installed the Event Listing for Oscommerce 2.3.4.  I would like to be able to sort the table in several different ways. I would like to be able to sort it by event title, start date, status, and last modified. Can someone please tell me how to change this.

 

<?php // Events Schedule version 2.1 admin side

  require('includes/application_top.php');

  $eID = (!empty($_GET['eID']) ? (int)$_GET['eID'] : 0 );
  $action = (!empty($_GET['action']) ? $_GET['action'] : '' );
    $page = (isset($_GET['page']) ? (int)$_GET['page'] : 1);
    if ($page < 1) $page = 1;

  $languages = tep_get_languages();

  switch($action) {
      ///////////////
      case 'setflag':
      ///////////////
         if(!empty($eID) && isset($_GET['flag']) && ($_GET['flag'] == '1' || $_GET['flag'] == '0'))
           { tep_db_query('update '.TABLE_EVENT_SCH.' set event_status = ' . (int)$_GET['flag'] . ' where event_id = ' . (int)$eID); }

         tep_redirect(tep_href_link('event_sch.php', 'page=' . $page . '&' . 'iID=' . $eID));
         break;

      //////////////
      case 'insert':
      case 'update':
      //////////////
         $error = false;
         $event_start_array = tep_db_prepare_input($_POST['event_start']);
         list($year, $month, $day) = explode('-', str_replace('/', '-', $event_start_array));
         if (($event_start_array == '') || !checkdate($month, $day, $year)) { // invalid date
           $error = true;
           $messageStack->add(ENTRY_EVENT_START . TEXT_DATE_ERROR, 'error');
         }
         $event_end_array = tep_db_prepare_input($_POST['event_end']);
         list($year, $month, $day) = explode('-', str_replace('/', '-', $event_end_array));
         if (($event_end_array == '') || !checkdate($month, $day, $year)) { // invalid date
           $error = true;
           $messageStack->add(ENTRY_EVENT_END . TEXT_DATE_ERROR, 'error');
         }
         if (!$error && ($event_end_array < $event_start_array)) { // if valid dates and end before beginning swap dates
           $tmp = $event_end_array;
           $event_end_array = $event_start_array;
           $event_start_array = $tmp;
         }
         $event_status = !empty($_POST['event_status']) ? '1' : '0';
         $event_title_array = $_POST['event_title'];
         $event_site_array = $_POST['event_site'];
         $event_desc_array = $_POST['event_desc'];
         foreach ($languages as $l) {
           $event_title_array[$l['id']] = tep_db_prepare_input($event_title_array[$l['id']]);
           if ($event_title_array[$l['id']] == '') { // event name may not be empty
             $error = true;
             $messageStack->add(ERROR_MISSING_ENTRY . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_LANGUAGES . $l['directory'] . '/images/' . $l['image'], $l['name']), 'error');
           }
           $event_site_array[$l['id']] = tep_db_prepare_input($event_site_array[$l['id']]);
           if (!empty($event_site_array[$l['id']])) {
             if (substr(strtolower($event_site_array[$l['id']]), 0, 4) != 'http') {
               $event_site_array[$l['id']] = 'http://' . $event_site_array[$l['id']];
             }
           }
           $event_desc_array[$l['id']] = tep_db_prepare_input($event_desc_array[$l['id']]);
         }

         if ($error) {
           $action = ($action == 'insert' ? 'new_event' : 'edit_event');
         } else {
           $sql_data_array = array('last_modified' => 'now()',
                                   'event_start' => $event_start_array,
                                   'event_end' => $event_end_array,
                                   'event_status' => $event_status);

           if ($action == 'insert') {
             tep_db_perform(TABLE_EVENT_SCH, $sql_data_array);
             $eID = tep_db_insert_id();
           } elseif ($action == 'update') {
             tep_db_perform(TABLE_EVENT_SCH, $sql_data_array, 'update', "event_id = '".(int)$eID."'");
           }

           foreach ($languages as $l) {
             $sql_data_array = array('event_title' => $event_title_array[$l['id']],
                                     'event_site' => $event_site_array[$l['id']],
                                     'event_desc' => $event_desc_array[$l['id']]);

             if ($action == 'insert') {
               $insert_sql_data = array('event_id' => (int)$eID,
                                        'language_id' => (int)$l['id']);
               $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
               tep_db_perform(TABLE_EVENT_SCH_DESCRIPTION, $sql_data_array);
             } elseif ($action == 'update') {
               tep_db_perform(TABLE_EVENT_SCH_DESCRIPTION, $sql_data_array, 'update', "event_id = '" . (int)$eID . "' and language_id = '" . (int)$l['id'] . "'");
             }
           }
           if ($action == 'insert') {
             $count = 0;
             $page = 1;
             $query = tep_db_query("select event_id from " . TABLE_EVENT_SCH . " order by event_start ASC");
             // find the page containing the new event
             while ($x = tep_db_fetch_array($query)) {
               $count++;
               if ($x['event_id'] == $eID) {
                 $page = ceil($count / MAX_DISPLAY_SEARCH_RESULTS);
                 break;
               }
             }
                     }
           tep_redirect(tep_href_link('event_sch.php', (isset($page) ? 'page='.$page.'&' : '') . 'eID=' . $eID));
         }
         break;

      /////////////////////
      case 'deleteconfirm':
      /////////////////////
         tep_db_query("delete from " . TABLE_EVENT_SCH . " where event_id = " . (int)$eID);
         tep_db_query("delete from " . TABLE_EVENT_SCH_DESCRIPTION . " where event_id = " . (int)$eID);

         tep_redirect(tep_href_link('event_sch.php', 'page=' . $page));
         break;
    }

  require('includes/template_top.php');   
?>
<script language="JavaScript">
<!--
  function showItem(id)
    {
      var item = document.getElementById(id);

      if (item)
        {
          if (!item.style.display || item.style.display == '' )
              item.style.display = 'none';
          else
              item.style.display = '';
        }
    }
//-->
</script>
<!-- body_text //-->
<h1 class="pageHeading"><?php echo HEADING_TITLE; ?></h1>
<?php
  if ($action == 'new_event' || $action == 'edit_event') {
      if ($action == 'new_event') {
        $event_info = array('status' => 1, 'start' => '', 'end' => '');
                foreach($languages as $l) {
          $event_info['title'][$l['id']] = '';
          $event_info['site'][$l['id']] = '';
          $event_info['desc'][$l['id']] = '';                    
                }
            } else {
        $event_info = array();
        $event_info_query = tep_db_query('select e.event_id, ed.language_id, e.event_start, e.event_end, ed.event_title, ed.event_site, ed.event_desc, e.last_modified, e.event_status from '.TABLE_EVENT_SCH.' e, '.TABLE_EVENT_SCH_DESCRIPTION.' ed where e.event_id = ed.event_id and e.event_id = '.(int)$eID);
        while ($event = tep_db_fetch_array($event_info_query)) {
          $event_info['status'] = $event['event_status'];
          $event_info['start'] = $event['event_start'];
          $event_info['end'] = $event['event_end'];
          $event_info['title'][$event['language_id']] = $event['event_title'];
          $event_info['site'][$event['language_id']] = $event['event_site'];
          $event_info['desc'][$event['language_id']] = $event['event_desc'];
        }
            }
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">
<?php
  echo tep_draw_form('new_event', 'event_sch.php', (empty($eID) ? 'action=insert' : 'action=update&eID='.$eID) ) . "\n";
?>
      <table border="0" width="100%" cellspacing="0" cellpadding="2">
        <tr>
          <td class="main" valign="top"><?php echo TITLE_STATUS;?></td>
          <td class="main" valign="top"><?php echo TEXT_ON.tep_draw_radio_field('event_status', '1', ($event_info['status'] ? true : false) ).'&nbsp;&nbsp;&nbsp;'.TEXT_OFF.tep_draw_radio_field('event_status', '0', ($event_info['status'] ? false : true) );?></td>
        </tr>
        <tr>
          <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5')?></td>
        </tr>
        <tr>
          <td class="main" valign="top"><?php echo ENTRY_EVENT_START . '<br />' . TEXT_DATE_FORMAT; ?></td>
          <td class="main" valign="top">
<?php echo tep_draw_input_field("event_start", (isset($event_start_array) ? $event_start_array : $event_info['start']), 'id="event_start"'); ?>
          </td>
        </tr>
        <tr>
          <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5')?></td>
        </tr>
        <tr>
          <td class="main" valign="top"><?php echo ENTRY_EVENT_END . '<br />' . TEXT_DATE_FORMAT; ?></td>
          <td class="main" valign="top">
<?php echo tep_draw_input_field("event_end", (isset($event_end_array) ? $event_end_array : $event_info['end']), 'id="event_end"'); ?>
          </td>
        </tr>
<?php foreach($languages as $l) { ?>
        <tr>
          <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5')?></td>
        </tr>
        <tr>
          <td class="main" valign="top"><?php echo TITLE_ADD_EVENT_TITLE;?></td>
          <td class="main" valign="top">
<?php
      echo '                            ' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_LANGUAGES . $l['directory'] . '/images/' . $l['image'], $l['name']) . tep_draw_input_field('event_title[' . $l['id'] . ']', (isset($event_title_array[$l['id']]) ? $event_title_array[$l['id']] : $event_info['title'][$l['id']]), 'size="72" maxlength="255"') . "\n";
?>
          </td>
        </tr>
        <tr>
          <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5')?></td>
        </tr>
        <tr>
          <td class="main" valign="top"><?php echo TITLE_ADD_EVENT_SITE;?></td>
          <td class="main" valign="top">
<?php
      echo '                            ' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_LANGUAGES . $l['directory'] . '/images/' . $l['image'], $l['name']) . tep_draw_input_field('event_site[' . $l['id'] . ']', (isset($event_site_array[$l['id']]) ? $event_site_array[$l['id']] : $event_info['site'][$l['id']]), 'size="72"') . "\n";
?>
          </td>
        </tr>
        <tr>
          <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5')?></td>
        </tr>
        <tr>
          <td class="main" valign="top"><?php echo TITLE_ADD_EVENT_DESC;?></td>
          <td class="main" valign="top">
<?php
      echo '                            ' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_LANGUAGES . $l['directory'] . '/images/' . $l['image'], $l['name'], '', '', 'valign="top"') . tep_draw_textarea_field_ckeditor('event_desc[' . $l['id'] . ']','soft','72','10', (isset($event_desc_array[$l['id']]) ? $event_desc_array[$l['id']] : $event_info['desc'][$l['id']])) . "\n";
?>
          </td>
        </tr>
<?php } ?>
        <tr>
          <td class="main" colspan="2"><?php echo tep_draw_button(IMAGE_SAVE, 'disk') . '&nbsp;' . tep_draw_button(IMAGE_CANCEL, 'cancel', tep_href_link('event_sch.php', tep_get_all_get_params(array('action'))));?></td>
        </tr>
      </table>
<script type="text/javascript">
$('#event_start').datepicker({
  dateFormat: 'yy-mm-dd',
  numberOfMonths: 3,
  showButtonPanel: true,
    minDate: -0,
    onClose: function( selectedDate ) {
    $( "#event_end" ).datepicker( "option", "minDate", selectedDate );
        if (document.getElementById('event_end').value == '') document.getElementById('event_end').value = document.getElementById('event_start').value;
  }
});
$('#event_end').datepicker({
  dateFormat: 'yy-mm-dd',
  numberOfMonths: 3,
  showButtonPanel: true,
    minDate: -0,
  onClose: function( selectedDate ) {
    $( "#event_start" ).datepicker( "option", "maxDate", selectedDate );
  }
});
</script>
      </form>
    </td>
  </tr>
<?php

    } elseif ($action == 'preview_event') {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
    <td class="main"><?php echo TEXT_CLICK_REVEAL; ?></td>
    <td class="main" align="right"><?php echo tep_draw_button(IMAGE_BACK, 'circle-arrow-w', tep_href_link('event_sch.php', tep_get_all_get_params(array('action')))); ?></td>
  </tr>
  <tr>
    <td class="main" style="padding-left:20px;"><?php
    foreach ($languages as $l) {
      echo tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_LANGUAGES . $l['directory'] . '/images/' . $l['image'], $l['name']) . '&nbsp;' . $l['name'];
              ?>
      <fieldset style="padding:3 3 5 18; border:1px solid #2B383A;">
        <table border="0" cellspacing="0" cellpadding="0">
<?php
      $event_query = tep_db_query('select e.event_id, e.event_start, e.event_end, ed.event_title, ed.event_site, ed.event_desc, e.last_modified, e.event_status from '.TABLE_EVENT_SCH.' e, '.TABLE_EVENT_SCH_DESCRIPTION.' ed where e.event_id = ed.event_id and e.event_status and ed.language_id = "' . $l['id'] . '" order by e.event_start ASC');

      while ($event = tep_db_fetch_array($event_query)) {
        if ($event['event_start'] == $event['event_end']) {
          $eventdates = tep_date_long($event['event_start']);
        } else {
          $eventdates = tep_date_long($event['event_start']) . ' &mdash; ' . tep_date_long($event['event_end']);
        }
?>
          <tr>
            <td  class="main"><strong style="cursor:pointer;" onclick="showItem('event_desc_<?php echo $event['event_id'] . '_' . $l['id'];?>')"><?php echo $eventdates;?></strong></td>
          </tr>
          <tr>
            <td  class="main"><strong style="cursor:pointer;" onclick="showItem('event_desc_<?php echo $event['event_id'] . '_' . $l['id'];?>')"><?php echo $event['event_title'];?></strong></td>
          </tr>
          <tr>
            <td class="main" style="display:none;" id="event_desc_<?php echo $event['event_id'] . '_' . $l['id'];?>"><?php echo $event['event_desc'];?></td>
          </tr>
          <tr>
            <td class="smallText"><?php echo TITLE_ADD_EVENT_SITE . ' ' . $event['event_site'] . '<br /><small>' . TEXT_LAST_UPDATED . $event['last_modified'];?></small></td>
          </tr>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10')?></td>
          </tr>
<?php

        }
?>
        </table>
      </fieldset>
      <br />
      <?php } // end foreach languages?>
    </td>
  </tr>
<?php
    } else { // list of events
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">
      <table border="0" width="100%" cellspacing="0" cellpadding="2">
        <tr class="dataTableHeadingRow">
          <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_EVENT_ID; ?></td>
          <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_EVENT; ?></td>
          <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_START; ?></td>
          <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_EVENT_STATUS; ?></td>
          <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_EVENT_LAST_MODIFIED; ?></td>
        </tr>
<?php
      $event_query_numrows = 0;
      $event_query_raw = "select e.event_id, e.event_start, e.event_end, ed.event_title, ed.event_site, ed.event_desc, e.last_modified, e.event_status from " . TABLE_EVENT_SCH . " e,  " . TABLE_EVENT_SCH_DESCRIPTION . " ed where e.event_id = ed.event_id and ed.language_id = " . (int)$languages_id . " order by e.event_start DESC";

      $event_split = new splitPageResults($page, MAX_DISPLAY_SEARCH_RESULTS, $event_query_raw, $event_query_numrows);

      $event_query = tep_db_query($event_query_raw);
      while ($event = tep_db_fetch_array($event_query))
        {
          if ((!isset($_GET['eID']) || (isset($_GET['eID']) && ($_GET['eID'] == $event['event_id']))) && !isset($eInfo))
            { $eInfo = new objectInfo($event); }

          if (isset($eInfo) && is_object($eInfo) && ($event['event_id'] == $eInfo->event_id))
            { echo '        <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link('event_sch.php', 'page=' . $page . '&eID=' . $event['event_id'] . '&action=edit_event') . '\'">' . "\n"; }
          else
            { echo '        <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link('event_sch.php', 'page=' . $page . '&eID=' . $event['event_id']) . '\'">' . "\n"; }

?>
          <td class="dataTableContent" align="center"><?php echo $event['event_id']; ?></td>
          <td class="dataTableContent" width="35%"><?php echo $event['event_title']; ?></td>
          <td class="dataTableContent"><?php echo tep_date_long($event['event_start']); ?></td>
          <td class="dataTableContent" align="center"><?php
          if ($event['event_status'] == '1')
            { echo tep_image( 'images/' . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '&nbsp;&nbsp;<a href="' . tep_href_link('event_sch.php', 'action=setflag&flag=0&eID=' . $event['event_id'] ) . '">' . tep_image( 'images/' . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>'; }
          else
            { echo '<a href="' . tep_href_link('event_sch.php', 'action=setflag&flag=1&eID=' . $event['event_id']) . '">' . tep_image( 'images/' . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>&nbsp;&nbsp;' . tep_image( 'images/' . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10); }

?></td>
          <td class="dataTableContent" align="center"><?php echo $event['last_modified']; ?></td>
        </tr>
<?php
        }
?>
        <tr>
          <td colspan="5">
            <table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="smallText" valign="top"><?php echo $event_split->display_count($event_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $page, TEXT_DISPLAY_NUMBER_OF_EVENTS); ?></td>
                <td class="smallText" align="right"><?php echo $event_split->display_links($event_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $page); ?></td>
              </tr>
           </table></td>
         </tr>
         <tr>
           <td align="right" colspan="5" class="smallText">
<?php

      echo "<br />\n";

      echo tep_draw_button(IMAGE_INSERT, 'plusthick', tep_href_link('event_sch.php', 'page='.$page.'&action=new_event')) . '&nbsp;&nbsp;';
      echo tep_draw_button(IMAGE_PREVIEW, 'image', tep_href_link('event_sch.php', 'page='.$page.'&action=preview_event&prevlang=' . $languages_id)) . "&nbsp;<br />\n";

?>
            </td>
          </tr>
        </table></td>
        <?php

      $heading = array();
      $contents = array();

      switch ($action) {
          //////////////
          case 'delete':
          //////////////
             $heading[] = array('text' => '<strong>' . sprintf(TEXT_HEADING_DELETE_INTRO, $eInfo->event_id) . '</strong>');

             $contents = array('form' => tep_draw_form('evsch', 'event_sch.php', 'page=' . $page . '&eID=' . $eInfo->event_id . '&action=deleteconfirm'));
             $contents[] = array('text' => '<br /><strong>'.TEXT_ETITLE.'</strong><br />' . $eInfo->event_title );
             $contents[] = array('text' => '<br /><strong>'.TEXT_EDESC.'</strong><br />' . $eInfo->event_desc );
             $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(IMAGE_DELETE, 'trash') . tep_draw_button(IMAGE_CANCEL, 'cancel', tep_href_link('event_sch.php', 'page=' . $page . '&eID=' . $eInfo->event_id)));
             break;

          ////////
          default:
          ////////
             if (isset($eInfo) && is_object($eInfo))
               {
                 $heading[] = array('text' => '<strong> #' . $eInfo->event_id . ' ' . $eInfo->event_title . '</strong>');

                 $contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_EDIT, 'pencil', tep_href_link('event_sch.php', 'page=' . $page . '&eID=' . $eInfo->event_id . '&action=edit_event')) . ' ' . tep_draw_button(IMAGE_DELETE, 'trash', tep_href_link('event_sch.php', 'page=' . $page . '&eID=' . $eInfo->event_id . '&action=delete')));
                 $contents[] = array('text' => '<br /><strong>' . TEXT_ETITLE . '</strong><br />' . $eInfo->event_title );
                 $contents[] = array('text' => '<br /><strong>' . TEXT_BEGINS . '</strong>' . $eInfo->event_start . '<br /><strong>' . TEXT_ENDS . '</strong>' . $eInfo->event_end);
                 $contents[] = array('text' => '<br /><strong>' . TEXT_EDESC . '</strong><br />' . $eInfo->event_desc );
                 $contents[] = array('text' => '<br /><strong>' . TITLE_ADD_EVENT_SITE . '</strong><br />' . $eInfo->event_site );
               }
             break;
      }

      if ((tep_not_null($heading)) && (tep_not_null($contents))) {
          echo '        <td width="25%" valign="top">' . "\n";
          $box = new box;
          echo $box->infoBox($heading, $contents);
          echo "        </td>\n";
      }

?>  </tr>
<?php

    }

?>
</table>
<!-- body_eof //-->
<?php
  require('includes/template_bottom.php');
  require('includes/application_bottom.php');
?>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...