4 // ----------------------------------------------------------------
8 // Title: price Listing
9 // ----------------------------------------------------------------
12 include_once($path_to_root . "includes/session.inc");
13 include_once($path_to_root . "includes/date_functions.inc");
14 include_once($path_to_root . "includes/data_checks.inc");
15 include_once($path_to_root . "gl/includes/gl_db.inc");
16 include_once($path_to_root . "sales/includes/db/sales_types_db.inc");
17 include_once($path_to_root . "inventory/includes/db/items_category_db.inc");
19 //----------------------------------------------------------------------------------------------------
21 // trial_inquiry_controls();
22 print_price_listing();
24 function fetch_prices($category=0, $salestype=0)
26 $sql = "SELECT ".TB_PREF."prices.sales_type_id,
27 ".TB_PREF."prices.stock_id,
28 ".TB_PREF."stock_master.description AS name,
29 ".TB_PREF."prices.curr_abrev,
30 ".TB_PREF."prices.price,
31 ".TB_PREF."sales_types.sales_type,
32 ".TB_PREF."stock_master.material_cost+".TB_PREF."stock_master.labour_cost+".TB_PREF."stock_master.overhead_cost AS Standardcost,
33 ".TB_PREF."stock_master.category_id,
34 ".TB_PREF."stock_category.description
35 FROM ".TB_PREF."stock_master,
36 ".TB_PREF."stock_category,
37 ".TB_PREF."sales_types,
39 WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."prices.stock_id
40 AND ".TB_PREF."prices.sales_type_id=".TB_PREF."sales_types.id
41 AND ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id";
43 $sql .= " AND ".TB_PREF."sales_types.id = '$salestype'";
45 $sql .= " AND ".TB_PREF."stock_category.category_id = '$category'";
46 $sql .= " ORDER BY ".TB_PREF."prices.curr_abrev,
47 ".TB_PREF."stock_master.category_id,
48 ".TB_PREF."stock_master.stock_id";
50 return db_query($sql,"No transactions were returned");
53 //----------------------------------------------------------------------------------------------------
55 function print_price_listing()
57 global $comp_path, $path_to_root, $pic_height, $pic_width;
59 include_once($path_to_root . "reporting/includes/pdf_report.inc");
61 $category = $_POST['PARAM_0'];
62 $salestype = $_POST['PARAM_1'];
63 $pictures = $_POST['PARAM_2'];
64 $showGP = $_POST['PARAM_3'];
65 $comments = $_POST['PARAM_4'];
67 $dec = user_price_dec();
69 if ($category == reserved_words::get_all_numeric())
71 if ($salestype == reserved_words::get_all_numeric())
76 $cat = get_category_name($category);
80 $stype = get_sales_type_name($salestype);
86 $cols = array(0, 100, 385, 450, 515);
88 $headers = array(_('Category/Items'), _('Description'), _('Price'), _('GP %'));
90 $aligns = array('left', 'left', 'right', 'right');
92 $params = array( 0 => $comments,
93 1 => array('text' => _('Category'), 'from' => $cat, 'to' => ''),
94 2 => array('text' => _('Sales Type'), 'from' => $stype, 'to' => ''),
95 3 => array( 'text' => _('Show GP %'),'from' => $GP,'to' => ''));
98 $user_comp = user_company();
102 $rep = new FrontReport(_('Price Listing'), "PriceListing.pdf", user_pagesize());
105 $rep->Info($params, $cols, $headers, $aligns);
108 $result = fetch_prices($category, $salestype);
113 while ($myrow=db_fetch($result))
115 if ($currcode != $myrow['curr_abrev'])
119 $rep->TextCol(0, 3, $myrow['curr_abrev'] . " " . _('Prices'));
120 $currcode = $myrow['curr_abrev'];
124 if ($catgor != $myrow['description'])
126 $rep->Line($rep->row - $rep->lineHeight);
129 $rep->TextCol(0, 3, $myrow['category_id'] . " - " . $myrow['description']);
130 $catgor = $myrow['description'];
135 $rep->TextCol(0, 1, $myrow['stock_id']);
136 $rep->TextCol(1, 2, $myrow['name']);
137 $rep->TextCol(2, 3, number_format2($myrow['price'], $dec));
140 if ($myrow['price'] != 0.0)
141 $disp = ($myrow['price'] - $myrow['Standardcost']) * 100 / $myrow['price'];
144 $rep->TextCol(3, 4, number_format2($disp, user_percent_dec()) . " %");
148 $image = $comp_path . '/'. $user_comp . "/images/" . $myrow['stock_id'] . ".jpg";
149 if (file_exists($image))
152 if ($rep->row - $pic_height < $rep->bottomMargin)
154 $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, $pic_width, $pic_height);
155 $rep->row -= $pic_height;
162 $rep->Line($rep->row - 4);