[ PHPXref.com ] [ Generated: Sun Jul 20 19:28:27 2008 ] [ PgMarket 2.2.3 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/shopping/ -> advanced_search.php (source)

   1  <?php
   2  // (C) 2000 Fabio Molinari <fabio.m@mclink.it>
   3  // (C) 2000-2002 Marco Pratesi <marco@pgmarket.net>
   4  
   5  include  ("../config.inc.php");
   6  include  ("../common.inc.php");
   7  
   8  $DOC_TITLE = "AdvancedSearch";
   9  include ($CFG["dirroot"] . "header.php");
  10  include ($CFG["libdir"] . $CFG["dbms"] . "_search_queries.inc.php");
  11  
  12  if (!isset($_GET["from_menu"])) {
  13  /* Form has been submitted, let's go searching. */
  14  
  15      if (!isset($_GET["page_number"])) {
  16          $page_number = 1;
  17  
  18          if (cvl($_GET["product_name_min"])
  19           && cvl($_GET["product_name_max"])
  20           && cvl($_GET["product_name_in"])
  21           && cvl($_GET["brand_id"], 1)
  22           && cvl($_GET["description_min"])
  23           && cvl($_GET["description_max"])
  24           && cvl($_GET["name_in"])
  25           && cvl($_GET["price_min"])
  26           && cvl($_GET["price_max"])
  27           && cvl($_GET["discount_min"])
  28           && cvl($_GET["discount_max"])
  29           && cvl($_GET["discqty_min"])
  30           && cvl($_GET["discqty_max"])
  31           && cvl($_GET["weight_min"])
  32           && cvl($_GET["weight_max"])
  33          ) {
  34              $errors["emptyform"] = true;
  35          } else {
  36              $PGM_SESSION["product_name_min"]    = nvl($_GET["product_name_min"], "");
  37              $PGM_SESSION["product_name_max"]    = nvl($_GET["product_name_max"], "");
  38              $PGM_SESSION["product_name_in"]    = nvl($_GET["product_name_in"], "");
  39              $PGM_SESSION["brand_id"]        = nvl($_GET["brand_id"], "");
  40              $PGM_SESSION["prod_concatenation"]    = nvl($_GET["prod_concatenation"], "");
  41              $PGM_SESSION["prod_case_sensitive"]    = nvl($_GET["prod_case_sensitive"], 0);
  42              $PGM_SESSION["description_min"]    = nvl($_GET["description_min"], "");
  43              $PGM_SESSION["description_max"]    = nvl($_GET["description_max"], "");
  44              $PGM_SESSION["name_in"]        = nvl($_GET["name_in"], "");
  45              $PGM_SESSION["desc_concatenation"]    = nvl($_GET["desc_concatenation"], "");
  46              $PGM_SESSION["desc_case_sensitive"]    = nvl($_GET["desc_case_sensitive"], 0);
  47              $PGM_SESSION["price_min"]        = nvl($_GET["price_min"], "");
  48              $PGM_SESSION["price_max"]        = nvl($_GET["price_max"], "");
  49              $PGM_SESSION["discount_min"]    = nvl($_GET["discount_min"], "");
  50              $PGM_SESSION["discount_max"]    = nvl($_GET["discount_max"], "");
  51              $PGM_SESSION["discqty_min"]        = nvl($_GET["discqty_min"], "");
  52              $PGM_SESSION["discqty_max"]        = nvl($_GET["discqty_max"], "");
  53              $PGM_SESSION["weight_min"]        = nvl($_GET["weight_min"], "");
  54              $PGM_SESSION["weight_max"]        = nvl($_GET["weight_max"], "");
  55              $errormsg = validate_advanced_search_form($PGM_SESSION, $errors);
  56          }
  57      } else {
  58          $page_number = max(1, abs(intval($_GET["page_number"])));
  59      }
  60  
  61      if (nvl($errormsg, "") == "" && !nvl($errors["emptyform"], false)) {
  62          $qid = new PGM_Sql();
  63          advanced_find_products($qid, $PGM_SESSION, $page_number, $result);
  64          $PGM_SESSION["goback"]["request_uri"] = stripsid(me() . "?" . $_SERVER["QUERY_STRING"]);
  65          if ($result["num_items"] > $PGM_SESSION["max_results"]) {
  66              $t = new Template();
  67              $t->set_file("page", "templates/" . $PGM_SESSION["lang"] . "/too_many_results.ihtml");
  68              $t->set_var("numresults", $result["num_items"]);
  69              $t->pparse("out", "page");
  70          } else {
  71              include  ("search_results.inc.php");
  72          }
  73          include ($CFG["dirroot"] . "footer.php");
  74          pgm_session_close($PGM_SESSION, $session_name);
  75          die;
  76      }
  77  }
  78  
  79  $t = new Template();
  80  $t->set_file("page", "templates/advanced_search_form.ihtml");
  81  include ($CFG["localelangdir"] . "global-common.inc.php");
  82  include ($CFG["localelangdir"] . "global-shopping.inc.php");
  83  //$t->set_var("wwwroot", $CFG["wwwroot"]);
  84  //$t->set_var("productswww", $CFG["productswww"]);
  85  $t->set_var("ME", $ME);
  86  if (empty($errors)) {
  87      $t->set_var("there_are_errors", "");
  88  }
  89  $t->set_var(array(
  90      "session_product_name_in"    => ov(nvl($PGM_SESSION["product_name_in"], "")),
  91      "session_prod_concatenation_or"    => nvl($PGM_SESSION["prod_concatenation"], "") == "AND" ? "" : "checked",
  92      "session_prod_concatenation_and"=> nvl($PGM_SESSION["prod_concatenation"], "") == "AND" ? "checked" : "",
  93      "session_prod_case_sensitive"    => nvl($PGM_SESSION["prod_case_sensitive"], 0) ? "checked" : "",
  94      "session_name_in"        => ov(nvl($PGM_SESSION["name_in"], "")),
  95      "session_desc_concatenation_or"    => nvl($PGM_SESSION["desc_concatenation"], "") == "AND" ? "" : "checked",
  96      "session_desc_concatenation_and"=> nvl($PGM_SESSION["desc_concatenation"], "") == "AND" ? "checked" : "",
  97      "session_desc_case_sensitive"    => nvl($PGM_SESSION["desc_case_sensitive"], 0) ? "checked" : "",
  98      "session_price_min"        => ov(nvl($PGM_SESSION["price_min"], "")),
  99      "errors_price_min"        => errmsg(nvl($errors["price_min"], "")),
 100      "session_price_max"        => ov(nvl($PGM_SESSION["price_max"], "")),
 101      "errors_price_max"        => errmsg(nvl($errors["price_max"], "")),
 102      "session_discount_min"        => ov(nvl($PGM_SESSION["discount_min"], "")),
 103      "errors_discount_min"        => errmsg(nvl($errors["discount_min"], "")),
 104      "session_discount_max"        => ov(nvl($PGM_SESSION["discount_max"], "")),
 105      "errors_discount_max"        => errmsg(nvl($errors["discount_max"], "")),
 106      "session_discqty_min"        => ov(nvl($PGM_SESSION["discqty_min"], "")),
 107      "errors_discqty_min"        => errmsg(nvl($errors["discqty_min"], "")),
 108      "session_discqty_max"        => ov(nvl($PGM_SESSION["discqty_max"], "")),
 109      "errors_discqty_max"        => errmsg(nvl($errors["discqty_max"], ""))
 110  ));
 111  $t->set_block("page", "brand_used", "brand_used_blck");
 112  $t->set_var("brand_used_blck", "");
 113  if ($CFG["brand_used"]) {
 114      $t->set_block("brand_used", "brand_row", "brand_rows");
 115      $t->set_var("brand_rows", "");
 116      $qid = new PGM_Sql();
 117      $qid->query("SELECT id, name FROM brands ORDER BY name");
 118      $PGM_SESSION["brands"] = array();
 119      $PGM_SESSION["brand_id"] = nvl($PGM_SESSION["brand_id"], 1);
 120      while ($qid->next_record()) {
 121          $t->set_var(array(
 122              "brand_id"    => $qid->f("id"),
 123              "session_brand_selected" => ($PGM_SESSION["brand_id"] == $qid->f("id")) ? "selected" : "",
 124              "brand_name"    => $qid->f("name")
 125          ));
 126          $t->parse("brand_rows", "brand_row", true);
 127      }
 128      $t->parse("brand_used_blck", "brand_used", true);
 129  }
 130  $t->set_block("page", "weight_used", "weight_used_blck");
 131  $t->set_var("weight_used_blck", "");
 132  if ($CFG["weight_used"]) {
 133      $t->set_var(array(
 134          "session_weight_min"    => ov(nvl($PGM_SESSION["weight_min"], "")),
 135          "errors_weight_min"    => errmsg(nvl($errors["weight_min"], "")),
 136          "session_weight_max"    => ov(nvl($PGM_SESSION["weight_max"], "")),
 137          "errors_weight_max"    => errmsg(nvl($errors["weight_max"], ""))
 138      ));
 139      $t->parse("weight_used_blck", "weight_used", true);
 140  }
 141  $t->pparse("out", "page");
 142  
 143  include ($CFG["dirroot"] . "footer.php");
 144  
 145  pgm_session_close($PGM_SESSION, $session_name);
 146  
 147  /* *******************************************************************
 148   * FUNCTIONS
 149   ****************************************************************** */
 150  
 151  function validate_advanced_search_form(&$frm, &$errors) {
 152      global $CFG;
 153      include ($CFG["libdir"] . "pgm_validate.inc.php");
 154  
 155      $errors = array();
 156      $errormsg = "";
 157  
 158  /*
 159      if(!empty($frm["product_name_min"])) {
 160          validate_product_name($frm["product_name_min"], $errors, $errormsg);
 161          if ($errors["product_name"]) $errors["product_name_min"] = true;
 162      }
 163      if(!empty($frm["product_name_max"])) {
 164          validate_product_name($frm["product_name_max"], $errors, $errormsg);
 165          if ($errors["product_name"]) $errors["product_name_max"] = true;
 166      }
 167      if(!empty($frm["description_min"])) {
 168          validate_product_description($frm["description_min"], $errors, $errormsg);
 169          if ($errors["product_description"]) $errors["description_min"] = true;
 170      }
 171      if(!empty($frm["description_max"])) {
 172          validate_product_description($frm["description_max"], $errors, $errormsg);
 173          if ($errors["product_description"]) $errors["description_max"] = true;
 174      }
 175  */
 176      if(!empty($frm["price_min"])) {
 177          validate_price($frm["price_min"], $errors, $errormsg);
 178          if (nvl($errors["price"], false)) $errors["price_min"] = true;
 179      }
 180      if(!empty($frm["price_max"])) {
 181          validate_price($frm["price_max"], $errors, $errormsg);
 182          if (nvl($errors["price"], false)) $errors["price_max"] = true;
 183      }
 184      if(!empty($frm["discount_min"])) {
 185          validate_searched_discount($frm["discount_min"], $errors, $errormsg);
 186          if (nvl($errors["discount"], false)) $errors["discount_min"] = true;
 187      }
 188      if(!empty($frm["discount_max"])) {
 189          validate_searched_discount($frm["discount_max"], $errors, $errormsg);
 190          if (nvl($errors["discount"], false)) $errors["discount_max"] = true;
 191      }
 192      if(!empty($frm["discqty_min"])) {
 193          validate_searched_discqty($frm["discqty_min"], $errors, $errormsg);
 194          if (nvl($errors["discqty"], false)) $errors["discqty_min"] = true;
 195      }
 196      if(!empty($frm["discqty_max"])) {
 197          validate_searched_discqty($frm["discqty_max"], $errors, $errormsg);
 198          if (nvl($errors["discqty"], false)) $errors["discqty_max"] = true;
 199      }
 200      if(!empty($frm["weight_min"])) {
 201          validate_weight($frm["weight_min"], $errors, $errormsg);
 202          if (nvl($errors["weight"], false)) $errors["weight_min"] = true;
 203      }
 204      if(!empty($frm["weight_max"])) {
 205          validate_weight($frm["weight_max"], $errors, $errormsg);
 206          if (nvl($errors["weight"], false)) $errors["weight_max"] = true;
 207      }
 208  
 209      return $errormsg;
 210  }
 211  
 212  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]