skarra Posted December 29, 2002 Share Posted December 29, 2002 I am in the process of modifying the manufacturers module into something that will allow the administration panel to insert and modify retail outlets which in turn will be displayed on the Web site. I have started by trying to adapt the manufacturers administration files. Currently I can include new retailers but am unable to get the right-hand Panel to display so I can edit for delete the information. Apart from renaming certain things the only modifications to the file were to remove the links between manufacturers and certain products. Anyway this is the code by am currently using, if anyone can point out where I am going wrong I would be forever grateful. <?php /* $Id: retailers.php,v 1.47 2002/04/01 23:41:49 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2002 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); switch ($HTTP_GET_VARS['action']) { case 'insert': case 'save': $retailers_id = tep_db_prepare_input($HTTP_GET_VARS['rID']); $retailers_name = tep_db_prepare_input($HTTP_POST_VARS['retailers_name']); $sql_data_array = array('retailers_name' => $retailers_name); if ($HTTP_GET_VARS['action'] == 'insert') { $insert_sql_data = array('date_added' => 'now()'); $sql_data_array = tep_array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_RETAILERS, $sql_data_array); $retailers_id = tep_db_insert_id(); } elseif ($HTTP_GET_VARS['action'] == 'save') { $update_sql_data = array('last_modified' => 'now()'); $sql_data_array = tep_array_merge($sql_data_array, $update_sql_data); tep_db_perform(TABLE_RETAILERS, $sql_data_array, 'update', "retailers_id = '" . tep_db_input($retailers_id) . "'"); } if ($HTTP_POST_FILES['retailers_image']) { $uploaded_tmp_file = $HTTP_POST_FILES['retailers_image']['tmp_name']; $uploaded_file = basename($HTTP_POST_FILES['retailers_image']['name']); } elseif ($HTTP_POST_VARS['retailers_image']) { $uploaded_tmp_file = $HTTP_POST_VARS['retailers_image']; $uploaded_file = basename($HTTP_POST_VARS['retailers_image_name']); } else { $uploaded_tmp_file = $retailers_image; $uploaded_file = basename($retailers_image_name); } if ($uploaded_tmp_file != 'none') { if (tep_is_uploaded_file($uploaded_tmp_file)) { tep_db_query("update " . TABLE_RETAILERS . " set retailers_image = '" . $uploaded_file . "' where retailers_id = '" . tep_db_input($retailers_id) . "'"); $image_location = DIR_FS_CATALOG_IMAGES . $uploaded_file; if (file_exists($image_location)) @unlink($image_location); copy($uploaded_tmp_file, $image_location); } } $languages = tep_get_languages(); for ($i=0; $i<sizeof($languages); $i++) { $retailers_url_array = $HTTP_POST_VARS['retailers_url']; $language_id = $languages[$i]['id']; $sql_data_array = array('retailers_url' => tep_db_prepare_input($retailers_url_array[$language_id])); if ($HTTP_GET_VARS['action'] == 'insert') { $insert_sql_data = array('retailers_id' => $retailers_id, 'languages_id' => $language_id); $sql_data_array = tep_array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_RETAILERS_INFO, $sql_data_array); } elseif ($HTTP_GET_VARS['action'] == 'save') { tep_db_perform(TABLE_RETAILERS_INFO, $sql_data_array, 'update', "retailers_id = '" . tep_db_input($retailers_id) . "' and languages_id = '" . $language_id . "'"); } } tep_redirect(tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $retailers_id)); break; case 'deleteconfirm': $retailers_id = tep_db_prepare_input($HTTP_GET_VARS['rID']); if ($HTTP_POST_VARS['delete_image'] == 'on') { $retailer_query = tep_db_query("select retailers_image from " . TABLE_RETAILERS . " where retailers_id = '" . tep_db_input($retailers_id) . "'"); $retailer = tep_db_fetch_array($retailer_query); $image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $retailer['retailers_image']; if (file_exists($image_location)) @unlink($image_location); } tep_db_query("delete from " . TABLE_RETAILERS . " where retailers_id = '" . tep_db_input($retailers_id) . "'"); tep_db_query("delete from " . TABLE_RETAILERS_INFO . " where retailers_id = '" . tep_db_input($retailers_id) . "'"); if ($HTTP_POST_VARS['delete_products'] == 'on') { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where retailers_id = '" . tep_db_input($retailers_id) . "'"); while ($products = tep_db_fetch_array($products_query)) { tep_remove_product($products['products_id']); } } else { tep_db_query("update " . TABLE_PRODUCTS . " set retailers_id = '' where retailers_id = '" . tep_db_input($retailers_id) . "'"); } tep_redirect(tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'])); break; } ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <script language="javascript" src="includes/general.js"></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><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"><?php echo TABLE_HEADING_RETAILERS; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> </tr> <?php $retailers_query_raw = "select retailers_id, retailers_name, retailers_image, date_added, last_modified from " . TABLE_RETAILERS . " order by retailers_name"; $retailers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $retailers_query_raw, $retailers_query_numrows); $retailers_query = tep_db_query($retailers_query_raw); while ($retailers = tep_db_fetch_array($retailers_query)) { if (((!$HTTP_GET_VARS['rID']) || (@$HTTP_GET_VARS['rID'] == $retailers['retailers_id'])) && (!$mInfo) && (substr($HTTP_GET_VARS['action'], 0, 3) != 'new')) if ( (is_object($mInfo)) && ($retailers['retailers_id'] == $mInfo->retailers_id) ) { echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor='hand'" onclick="document.location.href='' . tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $retailers['retailers_id'] . '&action=edit') . ''">' . "n"; } else { echo ' <tr class="dataTableRow" onmouseover="this.className='dataTableRowOver';this.style.cursor='hand'" onmouseout="this.className='dataTableRow'" onclick="document.location.href='' . tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $retailers['retailers_id']) . ''">' . "n"; } ?> <td class="dataTableContent"><?php echo $retailers['retailers_name']; ?></td> <td class="dataTableContent" align="right"><?php if ( (is_object($mInfo)) && ($retailers['retailers_id'] == $mInfo->retailers_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $retailers['retailers_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> </tr> <?php } ?> <tr> <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" valign="top"><?php echo $retailers_split->display_count($retailers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_RETAILERS); ?></td> <td class="smallText" align="right"><?php echo $retailers_split->display_links($retailers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td> </tr> </table></td> </tr> <?php if (!$HTTP_GET_VARS['action'] == 'new') { ?> <tr> <td align="right" colspan="2" class="smallText"><?php echo '<a href="' . tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $mInfo->retailers_id . '&action=new') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td> </tr> <?php } ?> </table></td> <?php $heading = array(); $contents = array(); switch ($HTTP_GET_VARS['action']) { case 'new': $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_RETAILER . '</b>'); $contents = array('form' => tep_draw_form('retailers', FILENAME_RETAILERS, 'action=insert', 'post', 'enctype="multipart/form-data"')); $contents[] = array('text' => TEXT_NEW_INTRO); $contents[] = array('text' => '<br>' . TEXT_RETAILERS_NAME . '<br>' . tep_draw_input_field('retailers_name')); $contents[] = array('text' => '<br>' . TEXT_RETAILERS_IMAGE . '<br>' . tep_draw_file_field('retailers_image')); $retailer_inputs_string = ''; $languages = tep_get_languages(); for ($i=0; $i<sizeof($languages); $i++) { $retailer_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('retailers_url[' . $languages[$i]['id'] . ']'); } $contents[] = array('text' => '<br>' . TEXT_RETAILERS_URL . $retailer_inputs_string); $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $HTTP_GET_VARS['rID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); break; case 'edit': $heading[] = array('text' => '<b>' . TEXT_HEADING_EDIT_RETAILER . '</b>'); $contents = array('form' => tep_draw_form('retailers', FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $mInfo->retailers_id . '&action=save', 'post', 'enctype="multipart/form-data"')); $contents[] = array('text' => TEXT_EDIT_INTRO); $contents[] = array('text' => '<br>' . TEXT_RETAILERS_NAME . '<br>' . tep_draw_input_field('retailers_name', $mInfo->retailers_name)); $contents[] = array('text' => '<br>' . TEXT_RETAILERS_IMAGE . '<br>' . tep_draw_file_field('retailers_image') . '<br>' . $mInfo->retailers_image); $retailer_inputs_string = ''; $languages = tep_get_languages(); for ($i=0; $i<sizeof($languages); $i++) { $retailer_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('retailers_url[' . $languages[$i]['id'] . ']', tep_get_retailer_url($mInfo->retailers_id, $languages[$i]['id'])); } $contents[] = array('text' => '<br>' . TEXT_RETAILERS_URL . $retailer_inputs_string); $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $mInfo->retailers_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); break; case 'delete': $heading[] = array('text' => '<b>' . TEXT_HEADING_DELETE_RETAILER . '</b>'); $contents = array('form' => tep_draw_form('retailers', FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $mInfo->retailers_id . '&action=deleteconfirm')); $contents[] = array('text' => TEXT_DELETE_INTRO); $contents[] = array('text' => '<br><b>' . $mInfo->retailers_name . '</b>'); $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('delete_image', '', true) . ' ' . TEXT_DELETE_IMAGE); $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $mInfo->retailers_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); break; default: if (is_object($mInfo)) { $heading[] = array('text' => '<b>' . $mInfo->retailers_name . '</b>'); $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $mInfo->retailers_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_RETAILERS, 'page=' . $HTTP_GET_VARS['page'] . '&rID=' . $mInfo->retailers_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>'); $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($mInfo->date_added)); if (tep_not_null($mInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($mInfo->last_modified)); $contents[] = array('text' => '<br>' . tep_info_image($mInfo->retailers_image, $mInfo->retailers_name)); } 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> </table></td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> 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.