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

title

Body

[close]

/shopping/ -> product_details.php (source)

   1  <?php
   2  // (C) 2000-2002 Marco Pratesi <marco@pgmarket.net>
   3  // (C) 2000 Ying Zhang (ying@zippydesign.com)
   4  
   5  include  ("../config.inc.php");
   6  include  ("../common.inc.php");
   7  
   8  $id = nvl($_GET["id"], "");
   9  $product_id = nvl($_GET["product_id"], "");
  10  
  11  $qid = new PGM_Sql();
  12  if ($CFG["color_used"]) {
  13      $qid_col = new PGM_Sql();
  14  }
  15  
  16  if ($product_id != "") {
  17      if ($id != "") {    // category not specified
  18          $qid->query("SELECT category_id FROM products_categories WHERE product_id = '$product_id' AND category_id = '$id'");
  19          if (!($qid->num_rows())) {
  20              pgm_session_close($PGM_SESSION, $session_name);
  21              redirect($CFG["firstpage"]);
  22              die;
  23          }
  24      } else {
  25          $qid->query("SELECT category_id FROM products_categories WHERE product_id = '$product_id'");
  26          if ($qid->num_rows()) {
  27              $qid->next_record();
  28              $id = $qid->f("category_id");
  29          } else {
  30              pgm_session_close($PGM_SESSION, $session_name);
  31              redirect($CFG["firstpage"]);
  32              die;
  33          }
  34      }
  35  } else {
  36      pgm_session_close($PGM_SESSION, $session_name);
  37      redirect($CFG["firstpage"]);
  38      die;
  39  }
  40  
  41  //get_product_details($qid, $product_id);
  42  $qid->pgm_lang_join_query(
  43      $CFG["base_lang"],
  44      array("products p", "products_i18n l"),
  45      array(array("p.id", "l.product_id", 1, $PGM_SESSION["lang"])),
  46      array(array("l.name AS lname",  "l.extended_description AS lextended_description")),
  47      "p.id AS product_id, p.code, p.name AS name, p.price, p.discount, p.discqty, p.weight, p.extended_description, p.imagetype, p.imagewidth, p.imageheight, p.thumbwidth, p.thumbheight, b.name AS bname, i.iva",
  48      "brands b, iva i",
  49      "p.brand_id = b.id AND p.iva_id = i.id AND p.id = '$product_id'",
  50      "",
  51      array()
  52  );
  53  
  54  if ($qid->num_rows() > 0) {
  55      $qid->next_record();
  56      $prod = true;
  57  } else {
  58      $prod = false;
  59  }
  60  
  61  $DOC_TITLE = $prod ? "Product_Details" : "Product_Not_Found";
  62  
  63  include ($CFG["dirroot"] . "header.php");
  64  
  65  $t = new Template();
  66  $t->set_file("page", "templates/product_details.ihtml");
  67  include ($CFG["localelangdir"] . "global-common.inc.php");
  68  include ($CFG["localelangdir"] . "global-shopping.inc.php");
  69  $t->set_block("page", "product", "product_blck");
  70  $t->set_var(array("product_blck" => ""));
  71  $t->set_block("page", "noproduct", "noproduct_blck");
  72  $t->set_var(array("noproduct_blck" => ""));
  73  if ($prod) {
  74      build_category_path($id, $category_path);
  75      $t->set_var("category_path", $category_path);
  76  
  77      $t->set_block("product", "brand_used", "brand_used_blck");
  78      $t->set_var("brand_used_blck", "");
  79      $t->set_block("product", "user_discount_used", "user_discount_used_blck");
  80      $t->set_var("user_discount_used_blck", "");
  81      $t->set_block("product", "iva_used", "iva_used_blck");
  82      $t->set_var("iva_used_blck", "");
  83      $t->set_block("product", "discount_block", "discount_block_blck");
  84      $t->set_var("discount_block_blck", "");
  85          $t->set_block("discount_block", "discqty_block", "discqty_block_blck");
  86          $t->set_var("discqty_block_blck", "");
  87      $t->set_block("product", "weight_used", "weight_used_blck");
  88      $t->set_var("weight_used_blck", "");
  89      $t->set_block("product", "color_used", "color_used_blck");
  90      $t->set_var("color_used_blck", "");
  91      $t->set_block("product", "prodimage", "prodimage_blck");
  92      $t->set_var("prodimage_blck", "");
  93      $t->set_var(array(
  94          "category_id"        => $id,
  95          "product_id"        => $qid->f("product_id"),
  96          "product_code"        => $qid->f("code"),
  97          "name"            => ($qid->f("lname") != "") ? ov($qid->f("lname")) : ov($qid->f("name")),
  98          "fprice"        => formatted_price($qid->f("price")),
  99          "extended_description"    => ($qid->f("lextended_description") != "") ? ovwbr($qid->f("lextended_description")) : ovwbr($qid->f("extended_description")),
 100          "imagetype"        => $qid->f("imagetype"),
 101          "productitemcount"    => $PGM_SESSION["CART"]->get_product_qty($qid->f("product_id"))
 102      ));
 103      if ($CFG["brand_used"] && $qid->f("bname") != "") {
 104          $t->set_var("bname", ov($qid->f("bname")));
 105          $t->parse("brand_used_blck", "brand_used", true);
 106      }
 107      if ($CFG["user_discount_used"] && is_logged_in() && $PGM_SESSION["user"]["user_discount"] > 0) {
 108          $t->set_var(array(
 109              "user_discount"        => $PGM_SESSION["user"]["user_discount"],
 110              "discounted_price"    => formatted_price((1.0-$PGM_SESSION["user"]["user_discount"]/100.0)*$qid->f("price"))
 111          ));
 112          $t->parse("user_discount_used_blck", "user_discount_used", true);
 113      }
 114      if ($CFG["iva_used"]) {
 115          $t->set_var("iva", ov($qid->f("iva")));
 116          $t->parse("iva_used_blck", "iva_used", true);
 117      }
 118      if ($qid->f("discount") > 0) {
 119          $t->set_var("discount", $qid->f("discount"));
 120          if ($qid->f("discqty") > 1) {
 121              $t->set_var("discqty", $qid->f("discqty"));
 122              $t->parse("discqty_block_blck", "discqty_block", true);
 123          }
 124          $t->parse("discount_block_blck", "discount_block", true);
 125      }
 126      if ($CFG["weight_used"]) {
 127          $t->set_var("fweight", formatted_weight($qid->f("weight")));
 128          $t->parse("weight_used_blck", "weight_used", true);
 129      }
 130      if ($CFG["color_used"]) {
 131          $foobar = get_product_color_options($product_id, $color_options, 1);
 132          if ($foobar > 0) {
 133              $t->set_var("color_options", $color_options);
 134              $t->parse("color_used_blck", "color_used", true);
 135          }
 136      }
 137      if ($CFG["images_on_file_system"] && file_exists($CFG["productsdir"] . $qid->f("product_id") . "." . $qid->f("imagetype"))) {
 138          $t->set_var(array(
 139              "imagewidth"    => $qid->f("imagewidth"),
 140              "imageheight"   => $qid->f("imageheight")
 141          ));
 142          if (has_priv("admin")) {
 143              $t->set_var("imagesrc", $CFG["wwwroot"] . "admin/getimage.php?image=" . $qid->f("product_id") . "." . $qid->f("imagetype") . "&amp;type=" . $qid->f("imagetype"));
 144          } else {
 145              $t->set_var("imagesrc", $CFG["productswww"] . $qid->f("product_id") . "." . $qid->f("imagetype"));
 146          }
 147          $t->parse("prodimage_blck", "prodimage", true);
 148      } else if (!$CFG["images_on_file_system"] && $qid->f("imagetype") != "") {
 149          $t->set_var(array(
 150              "imagewidth"    => $qid->f("imagewidth"),
 151              "imageheight"   => $qid->f("imageheight")
 152          ));
 153          if (has_priv("admin")) {
 154              $t->set_var("imagesrc", $CFG["wwwroot"] . "admin/dbgetimage.php?id=" . $qid->f("product_id"));
 155          } else {
 156              $t->set_var("imagesrc", $CFG["wwwroot"] . "dbgetimage.php?id=" . $qid->f("product_id"));
 157          }
 158          $t->parse("prodimage_blck", "prodimage", true);
 159      }
 160      $t->parse("product_blck", "product", true);
 161  } else {
 162      $t->parse("noproduct_blck", "noproduct", true);
 163  }
 164  
 165  $t->pparse("out", "page");
 166  
 167  include ($CFG["dirroot"] . "footer.php");
 168  
 169  pgm_session_close($PGM_SESSION, $session_name);
 170  
 171  ?>


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