[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> manufacturers.php (source)

   1  <?php
   2  /*

   3  $Id: manufacturers.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    require ('includes/application_top.php');
  14  
  15    $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  16  
  17    if (tep_not_null($action)) {
  18      switch ($action) {
  19        case 'insert':
  20        case 'save':
  21          if (isset($HTTP_GET_VARS['mID'])) $manufacturers_id = tep_db_prepare_input($HTTP_GET_VARS['mID']);
  22          $manufacturers_name = tep_db_prepare_input($HTTP_POST_VARS['manufacturers_name']);
  23  
  24          $sql_data_array = array('manufacturers_name' => $manufacturers_name);
  25  
  26          if ($action == 'insert') {
  27            $insert_sql_data = array('date_added' => 'now()');
  28  
  29            $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  30  
  31            tep_db_perform(TABLE_MANUFACTURERS, $sql_data_array);
  32            $manufacturers_id = tep_db_insert_id();
  33          } elseif ($action == 'save') {
  34            $update_sql_data = array('last_modified' => 'now()');
  35  
  36            $sql_data_array = array_merge($sql_data_array, $update_sql_data);
  37  
  38            tep_db_perform(TABLE_MANUFACTURERS, $sql_data_array, 'update', "manufacturers_id = '" . (int)$manufacturers_id . "'");
  39          }
  40  
  41          if($_FILES['manufacturers_image']['name'] != '') {
  42            if ($manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES)) {
  43              tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . $manufacturers_image->filename . "' where manufacturers_id = '" . (int)$manufacturers_id . "'");
  44            }
  45          }
  46  
  47          $languages = tep_get_languages();
  48          for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
  49            $manufacturers_url_array = $HTTP_POST_VARS['manufacturers_url'];
  50            $language_id = $languages[$i]['id'];
  51  
  52            $sql_data_array = array('manufacturers_url' => tep_db_prepare_input($manufacturers_url_array[$language_id]));
  53  
  54            if ($action == 'insert') {
  55              $insert_sql_data = array('manufacturers_id' => $manufacturers_id,
  56                                       'languages_id' => $language_id);
  57  
  58              $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  59  
  60              tep_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array);
  61            } elseif ($action == 'save') {
  62              tep_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array, 'update', "manufacturers_id = '" . (int)$manufacturers_id . "' and languages_id = '" . (int)$language_id . "'");
  63            }
  64          }
  65  
  66          if (USE_CACHE == 'true') {
  67            tep_reset_cache_block('manufacturers');
  68          }
  69  
  70          tep_redirect(tep_href_link(FILENAME_MANUFACTURERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'mID=' . $manufacturers_id));
  71          break;
  72        case 'deleteconfirm':
  73          $manufacturers_id = tep_db_prepare_input($HTTP_GET_VARS['mID']);
  74  
  75          if (isset($HTTP_POST_VARS['delete_image']) && ($HTTP_POST_VARS['delete_image'] == 'on')) {
  76            $manufacturer_query = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$manufacturers_id . "'");
  77            $manufacturer = tep_db_fetch_array($manufacturer_query);
  78  
  79            $image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $manufacturer['manufacturers_image'];
  80  
  81            if (file_exists($image_location)) @unlink($image_location);
  82          }
  83  
  84          tep_db_query("delete from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$manufacturers_id . "'");
  85          tep_db_query("delete from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturers_id . "'");
  86  
  87          if (isset($HTTP_POST_VARS['delete_products']) && ($HTTP_POST_VARS['delete_products'] == 'on')) {
  88            $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = '" . (int)$manufacturers_id . "'");
  89            while ($products = tep_db_fetch_array($products_query)) {
  90              tep_remove_product($products['products_id']);
  91            }
  92          } else {
  93            tep_db_query("update " . TABLE_PRODUCTS . " set manufacturers_id = '' where manufacturers_id = '" . (int)$manufacturers_id . "'");
  94          }
  95  
  96          if (USE_CACHE == 'true') {
  97            tep_reset_cache_block('manufacturers');
  98          }
  99  
 100          tep_redirect(tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page']));
 101          break;
 102      }
 103    }
 104  ?>
 105  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 106  <html <?php echo HTML_PARAMS; ?>>
 107  <head>
 108  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 109  <title><?php echo TITLE; ?></title>
 110  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 111  <script language="javascript" src="includes/general.js"></script>
 112  </head>
 113  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
 114  <!-- header //-->
 115  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
 116  <!-- header_eof //-->
 117  
 118  <!-- body //-->
 119  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 120    <tr>
 121      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
 122  <!-- left_navigation //-->
 123  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
 124  <!-- left_navigation_eof //-->
 125      </table></td>
 126  <!-- body_text //-->
 127      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 128        <tr>
 129          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 130            <tr>
 131              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 132              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 133            </tr>
 134          </table></td>
 135        </tr>
 136        <tr>
 137          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 138            <tr>
 139              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 140                <tr class="dataTableHeadingRow">
 141                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_MANUFACTURERS; ?></td>
 142                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 143                </tr>
 144  <?php
 145    $manufacturers_query_raw = "select manufacturers_id, manufacturers_name, manufacturers_image, date_added, last_modified from " . TABLE_MANUFACTURERS . " order by manufacturers_name";
 146    $manufacturers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $manufacturers_query_raw, $manufacturers_query_numrows);
 147    $manufacturers_query = tep_db_query($manufacturers_query_raw);
 148    while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
 149      if ((!isset($HTTP_GET_VARS['mID']) || (isset($HTTP_GET_VARS['mID']) && ($HTTP_GET_VARS['mID'] == $manufacturers['manufacturers_id']))) && !isset($mInfo) && (substr($action, 0, 3) != 'new')) {
 150        $manufacturer_products_query = tep_db_query("select count(*) as products_count from " . TABLE_PRODUCTS . " where manufacturers_id = '" . (int)$manufacturers['manufacturers_id'] . "'");
 151        $manufacturer_products = tep_db_fetch_array($manufacturer_products_query);
 152  
 153        $mInfo_array = array_merge($manufacturers, $manufacturer_products);
 154        $mInfo = new objectInfo($mInfo_array);
 155      }
 156  
 157      if (isset($mInfo) && is_object($mInfo) && ($manufacturers['manufacturers_id'] == $mInfo->manufacturers_id)) {
 158        echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $manufacturers['manufacturers_id'] . '&action=edit') . '\'">' . "\n";
 159      } else {
 160        echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $manufacturers['manufacturers_id']) . '\'">' . "\n";
 161      }
 162  ?>
 163                  <td class="dataTableContent"><?php echo $manufacturers['manufacturers_name']; ?></td>
 164                  <td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($manufacturers['manufacturers_id'] == $mInfo->manufacturers_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $manufacturers['manufacturers_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 165                </tr>
 166  <?php
 167    }
 168  ?>
 169                <tr>
 170                  <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 171                    <tr>
 172                      <td class="smallText" valign="top"><?php echo $manufacturers_split->display_count($manufacturers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_MANUFACTURERS); ?></td>
 173                      <td class="smallText" align="right"><?php echo $manufacturers_split->display_links($manufacturers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
 174                    </tr>
 175                  </table></td>
 176                </tr>
 177  <?php
 178    if (empty($action)) {
 179  ?>
 180                <tr>
 181                  <td align="right" colspan="2" class="smallText"><?php echo '<a href="' . tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $mInfo->manufacturers_id . '&action=new') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
 182                </tr>
 183  <?php
 184    }
 185  ?>
 186              </table></td>
 187  <?php
 188    $heading = array();
 189    $contents = array();
 190  
 191    switch ($action) {
 192      case 'new':
 193        $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_MANUFACTURER . '</b>');
 194  
 195        $contents = array('form' => tep_draw_form('manufacturers', FILENAME_MANUFACTURERS, 'action=insert', 'post', 'enctype="multipart/form-data"'));
 196        $contents[] = array('text' => TEXT_NEW_INTRO);
 197        $contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_NAME . '<br>' . tep_draw_input_field('manufacturers_name'));
 198        $contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_IMAGE . '<br>' . tep_draw_file_field('manufacturers_image'));
 199  
 200        $manufacturer_inputs_string = '';
 201        $languages = tep_get_languages();
 202        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 203          $manufacturer_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('manufacturers_url[' . $languages[$i]['id'] . ']');
 204        }
 205  
 206        $contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_URL . $manufacturer_inputs_string);
 207        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $HTTP_GET_VARS['mID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 208        break;
 209      case 'edit':
 210        $heading[] = array('text' => '<b>' . TEXT_HEADING_EDIT_MANUFACTURER . '</b>');
 211  
 212        $contents = array('form' => tep_draw_form('manufacturers', FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $mInfo->manufacturers_id . '&action=save', 'post', 'enctype="multipart/form-data"'));
 213        $contents[] = array('text' => TEXT_EDIT_INTRO);
 214        $contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_NAME . '<br>' . tep_draw_input_field('manufacturers_name', $mInfo->manufacturers_name));
 215        $contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_IMAGE . '<br>' . tep_draw_file_field('manufacturers_image') . '<br>' . $mInfo->manufacturers_image);
 216  
 217        $manufacturer_inputs_string = '';
 218        $languages = tep_get_languages();
 219        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 220          $manufacturer_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('manufacturers_url[' . $languages[$i]['id'] . ']', tep_get_manufacturer_url($mInfo->manufacturers_id, $languages[$i]['id']));
 221        }
 222  
 223        $contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_URL . $manufacturer_inputs_string);
 224        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $mInfo->manufacturers_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 225        break;
 226      case 'delete':
 227        $heading[] = array('text' => '<b>' . TEXT_HEADING_DELETE_MANUFACTURER . '</b>');
 228  
 229        $contents = array('form' => tep_draw_form('manufacturers', FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $mInfo->manufacturers_id . '&action=deleteconfirm'));
 230        $contents[] = array('text' => TEXT_DELETE_INTRO);
 231        $contents[] = array('text' => '<br><b>' . $mInfo->manufacturers_name . '</b>');
 232        $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('delete_image', '', true) . ' ' . TEXT_DELETE_IMAGE);
 233  
 234        if ($mInfo->products_count > 0) {
 235          $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('delete_products') . ' ' . TEXT_DELETE_PRODUCTS);
 236          $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $mInfo->products_count));
 237        }
 238  
 239        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $mInfo->manufacturers_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 240        break;
 241      default:
 242        if (isset($mInfo) && is_object($mInfo)) {
 243          $heading[] = array('text' => '<b>' . $mInfo->manufacturers_name . '</b>');
 244  
 245          $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $mInfo->manufacturers_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_MANUFACTURERS, 'page=' . $HTTP_GET_VARS['page'] . '&mID=' . $mInfo->manufacturers_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
 246          $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($mInfo->date_added));
 247          if (tep_not_null($mInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($mInfo->last_modified));
 248          $contents[] = array('text' => '<br>' . tep_info_image($mInfo->manufacturers_image, $mInfo->manufacturers_name));
 249          $contents[] = array('text' => '<br>' . TEXT_PRODUCTS . ' ' . $mInfo->products_count);
 250        }
 251        break;
 252    }
 253  
 254    if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
 255      echo '            <td width="25%" valign="top">' . "\n";
 256  
 257      $box = new box;
 258      echo $box->infoBox($heading, $contents);
 259  
 260      echo '            </td>' . "\n";
 261    }
 262  ?>
 263            </tr>
 264          </table></td>
 265        </tr>
 266      </table></td>
 267  <!-- body_text_eof //-->
 268    </tr>
 269  </table>
 270  <!-- body_eof //-->
 271  
 272  <!-- footer //-->
 273  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
 274  <!-- footer_eof //-->
 275  <br>
 276  </body>
 277  </html>
 278  <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7