blucollarguy Posted June 17, 2004 Share Posted June 17, 2004 <_< I am trying to get the contribution "Vendor e-mail" to work on MS2. I almost have it. A few problems are perplexing me. I am a php newbie, but I thinkk I have done pretty well. The point: to be able to enter all informatioin for all your vendors and be able to link them to their products individually, and them to be able to send them an e-mail with all the needed information for every order placed. Simple enough right? The problems: I have everything functional through Admin except for a few minor details. "Edit" and "Delete" won't do either. In fact, when clicking "edit" no information is pulled from the db. It is there. The "Delete" link is active, but does nothing to the db. I have taken the contibution and make many modifications. Using the "manufacterers" feature as a guide for me. Drop down to link to Vendor in "products" is there but no action to db. I have found many syntax changes that needed to be made to get most everything else to work, so I expect that this is the specific issue for these db problems. If I can get this last little bit working I will release this updated contribution. There are entries in the following files to support the "vendors" script page: filenames, databasetables, categories, and of course the language files. Here is the "vendors" script. (Is there a better way to post scripts?) Any help here will be greatly appreciated. I think a lot of people could get a lot of use out of this feature if I can get it working. Thansk for any help. vendors.php from catalog/admin/ <?php /* $Id: VENDORS.php,v 1.52 2003/03/22 02:44:55 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions ` http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); switch ($HTTP_GET_VARS['action']) { case 'insert': case 'save': $vendors_id = tep_db_prepare_input($HTTP_GET_VARS['vID']); $vendors_name = tep_db_prepare_input($HTTP_POST_VARS['vendors_name']); $vendors_email = tep_db_prepare_input($HTTP_POST_VARS['vendors_email']); $vendors_send_email = tep_db_prepare_input($HTTP_POST_VARS['vendors_send_email']); $vendors_phone1 = tep_db_prepare_input($HTTP_POST_VARS['vendors_phone1']); $sql_data_array = array('vendors_name' => $vendors_name, 'vendors_email' => $vendors_email, 'vendors_phone1' => $vendors_phone1, 'vendors_send_email' => $vendors_send_email); if ($HTTP_GET_VARS['action'] == 'insert') { $insert_sql_data = array('date_added' => 'now()'); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_VENDORS, $sql_data_array); $vendors_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_VENDORS, $sql_data_array, 'update', "vendors_id = '" . tep_db_input($vendors_id) . "'"); } // THIS WAS THE OLD CODE if ($vendors_image = new upload('vendors_image', DIR_FS_CATALOG_IMAGES)) { tep_db_query("update " . TABLE_VENDORS . " set vendors_image = '" . $vendors_image->filename . "' where vendors_id = '" . tep_db_input($vendors_id) . "'"); } // THIS IS CODE TAKEN FROM $Id vendors.php, v1.51 2003/01/29 // $vendors_image = tep_get_uploaded_file('vendors_image'); // $image_directory = tep_get_local_path(DIR_FS_CATALOG_IMAGES); // if (is_uploaded_file($vendors_image['tmp_name'])) { // if (!is_writeable($image_directory)) { // if (is_dir($image_directory)) { // $messageStack->add_session(sprintf(ERROR_DIRECTORY_NOT_WRITEABLE, $/image_directory), 'error'); // } else { // $messageStack->add_session(sprintf(ERROR_DIRECTORY_DOES_NOT_EXIST, $image_directory), 'error'); // } // } else { // tep_db_query("update " . TABLE_VENDORS . " set vendors_image = '" . $vendors_image['name'] . "' where vendors_id = '" . tep_db_input($vendors_id) . "'"); // tep_copy_uploaded_file($vendors_image, $image_directory); // } // } // END INSERT $languages = tep_get_languages(); for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { $vendors_url_array = $HTTP_POST_VARS['vendors_url']; $language_id = $languages[$i]['id']; $sql_data_array = array('vendors_url' => tep_db_prepare_input($vendors_url_array[$language_id])); if ($HTTP_GET_VARS['action'] == 'insert') { $insert_sql_data = array('vendors_id' => $vendors_id, 'languages_id' => $language_id); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_VENDORS_INFO, $sql_data_array); } elseif ($HTTP_GET_VARS['action'] == 'save') { tep_db_perform(TABLE_VENDORS_INFO, $sql_data_array, 'update', "vendors_id = '" . tep_db_input($vendors_id) . "' and languages_id = '" . $language_id . "'"); } } if (USE_CACHE == 'true') { tep_reset_cache_block('vendors'); } tep_redirect(tep_href_link(FILENAME_VENDORS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'vID=' . $vendors_id)); break; case 'deleteconfirm': $vendors_id = tep_db_prepare_input($HTTP_GET_VARS['vID']); if (isset($HTTP_POST_VARS['delete_image']) && ($HTTP_POST_VARS['delete_image'] == 'on')) { $vendor_query = tep_db_query("select vendors_image from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendors_id . "'"); $vendor = tep_db_fetch_array($vendor_query); $image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $vendor['vendors_image']; if (file_exists($image_location)) @unlink($image_location); } tep_db_query("delete from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendors_id . "'"); tep_db_query("delete from " . TABLE_VENDORS_INFO . " where vendors_id = '" . (int)$vendors_id . "'"); if (isset($HTTP_POST_VARS['delete_products']) && ($HTTP_POST_VARS['delete_products'] == 'on')) { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where vendors_id = '" . (int)$vendors_id . "'"); while ($products = tep_db_fetch_array($products_query)) { tep_remove_product($products['products_id']); } } else { tep_db_query("update " . TABLE_PRODUCTS . " set vendors_id = '' where vendors_id = '" . (int)$vendors_id . "'"); } if (USE_CACHE == 'true') { tep_reset_cache_block('vendors'); } tep_redirect(tep_href_link(FILENAME_VENDORS, '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_VENDORS; ?></td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_EMAIL; ?></td> <td class="dataTableHeadingContent"><?php echo TABLE_PHONE1; ?></td> <td class="dataTableHeadingContent"><?php echo TABLE_SEND_EMAIL; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> </tr> <?php $vendors_query_raw = "select vendors_id, vendors_name, vendors_email, vendors_phone1, vendors_image, date_added, last_modified, vendors_send_email from " . TABLE_VENDORS . " order by vendors_name"; $vendors_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $vendors_query_raw, $vendors_query_numrows); $vendors_query = tep_db_query($vendors_query_raw); while ($vendors = tep_db_fetch_array($vendors_query)) { if (((!$HTTP_GET_VARS['vID']) || (@$HTTP_GET_VARS['vID'] == $vendors['vendors_id'])) && (!$vINFO) && (substr($HTTP_GET_VARS['action'], 0, 3) != 'new')) { $vendors_products_query = tep_db_query("select count(*) as products_count from " . TABLE_PRODUCTS . " where vendors_id = '" . $vendors['vendors_id'] . "'"); $vendors_products = tep_db_fetch_array($vendors_products_query); $vInfo_array = array_merge($vendors, $vendors_products); $vInfo = new objectInfo($vInfo_array); } if ( (is_object($vINFO)) && ($vendors['vendors_id'] == $vINFO->vendors_id) ) { echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vendors['vendors_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_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vendors['vendors_id']) . '\'">' . "\n"; } ?> <td class="dataTableContent"><?php echo $vendors['vendors_name']; ?></td> <td class="dataTableContent"><?php echo $vendors['vendors_email']; ?></td> <td class="dataTableContent"><?php echo $vendors['vendors_phone1']; ?></td> <td class="dataTableContent"><?php echo $vendors['vendors_send_email']; ?></td> <td class="dataTableContent" align="right"><?php if ( (is_object($vINFO)) && ($vendors['vendors_id'] == $vINFO->vendors_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vendors['vendors_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 $vendors_split->display_count($vendors_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_VENDORS); ?></td> <td class="smallText" align="right"><?php echo $vendors_split->display_links($vendors_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_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vINFO->vendors_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_VENDOR . '</b>'); $contents = array('form' => tep_draw_form('vendors', FILENAME_VENDORS, 'action=insert', 'post', 'enctype="multipart/form-data"')); $contents[] = array('text' => TEXT_NEW_INTRO); $contents[] = array('text' => '<br>' . TEXT_VENDORS_NAME . '<br>' . tep_draw_input_field('vendors_name')); $contents[] = array('text' => '<br>' . TEXT_VENDORS_PHONE1 . '<br>' . tep_draw_input_field('vendors_phone1')); $contents[] = array('text' => '<br>' . TEXT_VENDORS_EMAIL . '<br>' . tep_draw_input_field('vendors_email')); $contents[] = array('text' => '<br>' . TEXT_VENDORS_SEND_EMAIL . '<br>' . tep_draw_input_field('vendors_send_email')); $contents[] = array('text' => '<br>' . TEXT_VENDORS_IMAGE . '<br>' . tep_draw_file_field('vendors_image')); $vendors_inputs_string = ''; $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $vendors_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('vendors_url[' . $languages[$i]['id'] . ']'); } $contents[] = array('text' => '<br>' . TEXT_VENDORS_URL . $vendors_inputs_string); $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $HTTP_GET_VARS['vID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); break; case 'edit': $heading[] = array('text' => '<b>' . TEXT_HEADING_EDIT_VENDOR . '</b>'); $contents = array('form' => tep_draw_form('vendors', FILENAME_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vINFO->vendors_id . '&action=save', 'post', 'enctype="multipart/form-data"')); $contents[] = array('text' => TEXT_EDIT_INTRO); $contents[] = array('text' => '<br>' . TEXT_VENDORS_NAME . '<br>' . tep_draw_input_field('vendors_name', $vINFO->vendors_name)); $contents[] = array('text' => '<br>' . TEXT_VENDORS_PHONE1 . '<br>' . tep_draw_input_field('vendors_phone1', $vINFO->vendors_phone1)); $contents[] = array('text' => '<br>' . TEXT_VENDORS_EMAIL . '<br>' . tep_draw_input_field('vendors_email', $vINFO->vendors_email)); $contents[] = array('text' => '<br>' . TEXT_VENDORS_SEND_EMAIL . '<br>' . tep_draw_input_field('vendors_send_email',$vINFO->vendors_send_email)); $contents[] = array('text' => '<br>' . TEXT_VENDORS_IMAGE . '<br>' . tep_draw_file_field('vendors_image') . '<br>' . $vINFO->vendors_image); $vendors_inputs_string = ''; $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $vendor_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('vendors_url[' . $languages[$i]['id'] . ']', tep_get_vendor_url($vInfo->vendors_id, $languages[$i]['id'])); } $contents[] = array('text' => '<br>' . TEXT_VENDORS_URL . $vendor_inputs_string); $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vInfo->vendors_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); break; case 'delete': $heading[] = array('text' => '<b>' . TEXT_HEADING_DELETE_VENDOR . '</b>'); $contents = array('form' => tep_draw_form('vendors', FILENAME_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vInfo->vendors_id . '&action=deleteconfirm')); $contents[] = array('text' => TEXT_DELETE_INTRO); $contents[] = array('text' => '<br><b>' . $vInfo->vendors_name . '</b>'); $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('delete_image', '', true) . ' ' . TEXT_DELETE_IMAGE); if ($vInfo->products_count > 0) { $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('delete_products') . ' ' . TEXT_DELETE_PRODUCTS); $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $vInfo->products_count)); } $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vInfo->vendors_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); break; default: if (isset($vInfo) && is_object($vInfo)) { $heading[] = array('text' => '<b>' . $vInfo->vendors_name . '</b>'); $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vInfo->vendors_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_VENDORS, 'page=' . $HTTP_GET_VARS['page'] . '&vID=' . $vInfo->vendors_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>'); $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($vInfo->date_added)); if (tep_not_null($vInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($vInfo->last_modified)); $contents[] = array('text' => '<br>' . tep_info_image($vInfo->vendors_image, $vInfo->vendors_name)); $contents[] = array('text' => '<br>' . TEXT_PRODUCTS . ' ' . $vInfo->products_count); } 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 Happy Coding! Craig Garrison Sr Anything worth having, is worth working for. Multi Vendor Shipping V1.1 Demo Catalog 3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout. Multi Vendor Shipping V1.1 Demo Admin login: [email protected] pass: mvs_demo MVS Thread: Multi-Vendor Shipping My contribs: Download Multi Vendor Shipping V1.1 Vendor Email Vendor Info in easypopulate EZ Price Updater And more to come! Link to comment Share on other sites More sharing options...
blucollarguy Posted June 19, 2004 Author Share Posted June 19, 2004 I have gotten most of this working and am working with a few kind folks on this through the following thread now; http://www.oscommerce.com/forums/index.php?act=ST&f=11&t=98505 Quote Happy Coding! Craig Garrison Sr Anything worth having, is worth working for. Multi Vendor Shipping V1.1 Demo Catalog 3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout. Multi Vendor Shipping V1.1 Demo Admin login: [email protected] pass: mvs_demo MVS Thread: Multi-Vendor Shipping My contribs: Download Multi Vendor Shipping V1.1 Vendor Email Vendor Info in easypopulate EZ Price Updater And more to come! 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.