home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 90 / PIWD90.iso / pc / contents / ecommerce / software / osCommerce.exe / oscommerce-2.2ms2 / catalog / advanced_search.php < prev    next >
PHP Script  |  2003-06-05  |  10KB  |  247 lines

  1. <?php
  2. /*
  3.   $Id: advanced_search.php,v 1.50 2003/06/05 23:25:46 hpdl Exp $
  4.  
  5.   osCommerce, Open Source E-Commerce Solutions
  6.   http://www.oscommerce.com
  7.  
  8.   Copyright (c) 2003 osCommerce
  9.  
  10.   Released under the GNU General Public License
  11. */
  12.  
  13.   require('includes/application_top.php');
  14.  
  15.   require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);
  16.  
  17.   $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH));
  18. ?>
  19. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  20. <html <?php echo HTML_PARAMS; ?>>
  21. <head>
  22. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  23. <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
  24. <title><?php echo TITLE; ?></title>
  25. <link rel="stylesheet" type="text/css" href="stylesheet.css">
  26. <script language="javascript" src="includes/general.js"></script>
  27. <script language="javascript"><!--
  28. function check_form() {
  29.   var error_message = "<?php echo JS_ERROR; ?>";
  30.   var error_found = false;
  31.   var error_field;
  32.   var keywords = document.advanced_search.keywords.value;
  33.   var dfrom = document.advanced_search.dfrom.value;
  34.   var dto = document.advanced_search.dto.value;
  35.   var pfrom = document.advanced_search.pfrom.value;
  36.   var pto = document.advanced_search.pto.value;
  37.   var pfrom_float;
  38.   var pto_float;
  39.  
  40.   if ( ((keywords == '') || (keywords.length < 1)) && ((dfrom == '') || (dfrom == '<?php echo DOB_FORMAT_STRING; ?>') || (dfrom.length < 1)) && ((dto == '') || (dto == '<?php echo DOB_FORMAT_STRING; ?>') || (dto.length < 1)) && ((pfrom == '') || (pfrom.length < 1)) && ((pto == '') || (pto.length < 1)) ) {
  41.     error_message = error_message + "* <?php echo ERROR_AT_LEAST_ONE_INPUT; ?>\n";
  42.     error_field = document.advanced_search.keywords;
  43.     error_found = true;
  44.   }
  45.  
  46.   if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>')) {
  47.     if (!IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) {
  48.       error_message = error_message + "* <?php echo ERROR_INVALID_FROM_DATE; ?>\n";
  49.       error_field = document.advanced_search.dfrom;
  50.       error_found = true;
  51.     }
  52.   }
  53.  
  54.   if ((dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>')) {
  55.     if (!IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>')) {
  56.       error_message = error_message + "* <?php echo ERROR_INVALID_TO_DATE; ?>\n";
  57.       error_field = document.advanced_search.dto;
  58.       error_found = true;
  59.     }
  60.   }
  61.  
  62.   if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) && (dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>'))) {
  63.     if (!CheckDateRange(document.advanced_search.dfrom, document.advanced_search.dto)) {
  64.       error_message = error_message + "* <?php echo ERROR_TO_DATE_LESS_THAN_FROM_DATE; ?>\n";
  65.       error_field = document.advanced_search.dto;
  66.       error_found = true;
  67.     }
  68.   }
  69.  
  70.   if (pfrom.length > 0) {
  71.     pfrom_float = parseFloat(pfrom);
  72.     if (isNaN(pfrom_float)) {
  73.       error_message = error_message + "* <?php echo ERROR_PRICE_FROM_MUST_BE_NUM; ?>\n";
  74.       error_field = document.advanced_search.pfrom;
  75.       error_found = true;
  76.     }
  77.   } else {
  78.     pfrom_float = 0;
  79.   }
  80.  
  81.   if (pto.length > 0) {
  82.     pto_float = parseFloat(pto);
  83.     if (isNaN(pto_float)) {
  84.       error_message = error_message + "* <?php echo ERROR_PRICE_TO_MUST_BE_NUM; ?>\n";
  85.       error_field = document.advanced_search.pto;
  86.       error_found = true;
  87.     }
  88.   } else {
  89.     pto_float = 0;
  90.   }
  91.  
  92.   if ( (pfrom.length > 0) && (pto.length > 0) ) {
  93.     if ( (!isNaN(pfrom_float)) && (!isNaN(pto_float)) && (pto_float < pfrom_float) ) {
  94.       error_message = error_message + "* <?php echo ERROR_PRICE_TO_LESS_THAN_PRICE_FROM; ?>\n";
  95.       error_field = document.advanced_search.pto;
  96.       error_found = true;
  97.     }
  98.   }
  99.  
  100.   if (error_found == true) {
  101.     alert(error_message);
  102.     error_field.focus();
  103.     return false;
  104.   } else {
  105.     RemoveFormatString(document.advanced_search.dfrom, "<?php echo DOB_FORMAT_STRING; ?>");
  106.     RemoveFormatString(document.advanced_search.dto, "<?php echo DOB_FORMAT_STRING; ?>");
  107.     return true;
  108.   }
  109. }
  110.  
  111. function popupWindow(url) {
  112.   window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
  113. }
  114. //--></script>
  115. </head>
  116. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
  117. <!-- header //-->
  118. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  119. <!-- header_eof //-->
  120.  
  121. <!-- body //-->
  122. <table border="0" width="100%" cellspacing="3" cellpadding="3">
  123.   <tr>
  124.     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
  125. <!-- left_navigation //-->
  126. <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
  127. <!-- left_navigation_eof //-->
  128.     </table></td>
  129. <!-- body_text //-->
  130.     <td width="100%" valign="top"><?php echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get', 'onSubmit="return check_form(this);"') . tep_hide_session_id(); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
  131.       <tr>
  132.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  133.           <tr>
  134.             <td class="pageHeading"><?php echo HEADING_TITLE_1; ?></td>
  135.             <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_1, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  136.           </tr>
  137.         </table></td>
  138.       </tr>
  139.       <tr>
  140.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  141.       </tr>
  142. <?php
  143.   if ($messageStack->size('search') > 0) {
  144. ?>
  145.       <tr>
  146.         <td><?php echo $messageStack->output('search'); ?></td>
  147.       </tr>
  148.       <tr>
  149.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  150.       </tr>
  151. <?php
  152.   }
  153. ?>
  154.       <tr>
  155.         <td>
  156. <?php
  157.   $info_box_contents = array();
  158.   $info_box_contents[] = array('text' => HEADING_SEARCH_CRITERIA);
  159.  
  160.   new infoBoxHeading($info_box_contents, true, true);
  161.  
  162.   $info_box_contents = array();
  163.   $info_box_contents[] = array('text' => tep_draw_input_field('keywords', '', 'style="width: 100%"'));
  164.   $info_box_contents[] = array('align' => 'right', 'text' => tep_draw_checkbox_field('search_in_description', '1') . ' ' . TEXT_SEARCH_IN_DESCRIPTION);
  165.  
  166.   new infoBox($info_box_contents);
  167. ?>
  168.         </td>
  169.       </tr>
  170.       <tr>
  171.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  172.       </tr>
  173.       <tr>
  174.         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  175.           <tr>
  176.             <td class="smallText"><?php echo '<a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_POPUP_SEARCH_HELP) . '\')">' . TEXT_SEARCH_HELP_LINK . '</a>'; ?></td>
  177.             <td class="smallText" align="right"><?php echo tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH); ?></td>
  178.           </tr>
  179.         </table></td>
  180.       </tr>
  181.       <tr>
  182.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  183.       </tr>
  184.       <tr>
  185.         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  186.           <tr class="infoBoxContents">
  187.             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  188.               <tr>
  189.                 <td class="fieldKey"><?php echo ENTRY_CATEGORIES; ?></td>
  190.                 <td class="fieldValue"><?php echo tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))); ?></td>
  191.               </tr>
  192.               <tr>
  193.                 <td class="fieldKey"> </td>
  194.                 <td class="smallText"><?php echo tep_draw_checkbox_field('inc_subcat', '1', true) . ' ' . ENTRY_INCLUDE_SUBCATEGORIES; ?></td>
  195.               </tr>
  196.               <tr>
  197.                 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  198.               </tr>
  199.               <tr>
  200.                 <td class="fieldKey"><?php echo ENTRY_MANUFACTURERS; ?></td>
  201.                 <td class="fieldValue"><?php echo tep_draw_pull_down_menu('manufacturers_id', tep_get_manufacturers(array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS)))); ?></td>
  202.               </tr>
  203.               <tr>
  204.                 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  205.               </tr>
  206.               <tr>
  207.                 <td class="fieldKey"><?php echo ENTRY_PRICE_FROM; ?></td>
  208.                 <td class="fieldValue"><?php echo tep_draw_input_field('pfrom'); ?></td>
  209.               </tr>
  210.               <tr>
  211.                 <td class="fieldKey"><?php echo ENTRY_PRICE_TO; ?></td>
  212.                 <td class="fieldValue"><?php echo tep_draw_input_field('pto'); ?></td>
  213.               </tr>
  214.               <tr>
  215.                 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  216.               </tr>
  217.               <tr>
  218.                 <td class="fieldKey"><?php echo ENTRY_DATE_FROM; ?></td>
  219.                 <td class="fieldValue"><?php echo tep_draw_input_field('dfrom', DOB_FORMAT_STRING, 'onFocus="RemoveFormatString(this, \'' . DOB_FORMAT_STRING . '\')"'); ?></td>
  220.               </tr>
  221.               <tr>
  222.                 <td class="fieldKey"><?php echo ENTRY_DATE_TO; ?></td>
  223.                 <td class="fieldValue"><?php echo tep_draw_input_field('dto', DOB_FORMAT_STRING, 'onFocus="RemoveFormatString(this, \'' . DOB_FORMAT_STRING . '\')"'); ?></td>
  224.               </tr>
  225.             </table></td>
  226.           </tr>
  227.         </table></td>
  228.       </tr>
  229.     </table></form></td>
  230. <!-- body_text_eof //-->
  231.     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
  232. <!-- right_navigation //-->
  233. <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
  234. <!-- right_navigation_eof //-->
  235.     </table></td>
  236.   </tr>
  237. </table>
  238. <!-- body_eof //-->
  239.  
  240. <!-- footer //-->
  241. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  242. <!-- footer_eof //-->
  243. <br>
  244. </body>
  245. </html>
  246. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  247.