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/ui/ui_input.inc");
15 include_once($path_to_root . "includes/data_checks.inc");
16 include_once($path_to_root . "gl/includes/gl_db.inc");
17 include_once($path_to_root . "sales/includes/db/sales_types_db.inc");
18 include_once($path_to_root . "inventory/includes/db/items_category_db.inc");
20 //----------------------------------------------------------------------------------------------------
22 // trial_inquiry_controls();
23 print_price_listing();
25 function fetch_items($category=0)
27 $sql = "SELECT ".TB_PREF."stock_master.stock_id, ".TB_PREF."stock_master.description AS name,
28 ".TB_PREF."stock_master.material_cost+".TB_PREF."stock_master.labour_cost+".TB_PREF."stock_master.overhead_cost AS Standardcost,
29 ".TB_PREF."stock_master.category_id,
30 ".TB_PREF."stock_category.description
31 FROM ".TB_PREF."stock_master,
32 ".TB_PREF."stock_category
33 WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id";
35 $sql .= " AND ".TB_PREF."stock_category.category_id = '$category'";
36 $sql .= " ORDER BY ".TB_PREF."stock_master.category_id,
37 ".TB_PREF."stock_master.stock_id";
39 return db_query($sql,"No transactions were returned");
41 //----------------------------------------------------------------------------------------------------
43 function print_price_listing()
45 global $comp_path, $path_to_root, $pic_height, $pic_width;
47 include_once($path_to_root . "reporting/includes/pdf_report.inc");
49 $currency = $_POST['PARAM_0'];
50 $category = $_POST['PARAM_1'];
51 $salestype = $_POST['PARAM_2'];
52 $pictures = $_POST['PARAM_3'];
53 $showGP = $_POST['PARAM_4'];
54 $comments = $_POST['PARAM_5'];
56 $dec = user_price_dec();
58 $home_curr = get_company_pref('curr_default');
59 if ($currency == reserved_words::get_all())
60 $currency = $home_curr;
61 $curr = get_currency($currency);
62 $curr_sel = $currency . " - " . $curr['currency'];
63 if ($category == reserved_words::get_all_numeric())
65 if ($salestype == reserved_words::get_all_numeric())
70 $cat = get_category_name($category);
74 $stype = get_sales_type_name($salestype);
80 $cols = array(0, 100, 385, 450, 515);
82 $headers = array(_('Category/Items'), _('Description'), _('Price'), _('GP %'));
84 $aligns = array('left', 'left', 'right', 'right');
86 $params = array( 0 => $comments,
87 1 => array('text' => _('Currency'), 'from' => $curr_sel, 'to' => ''),
88 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''),
89 3 => array('text' => _('Sales Type'), 'from' => $stype, 'to' => ''),
90 4 => array( 'text' => _('Show GP %'),'from' => $GP,'to' => ''));
93 $user_comp = user_company();
97 $rep = new FrontReport(_('Price Listing'), "PriceListing.pdf", user_pagesize());
100 $rep->Info($params, $cols, $headers, $aligns);
103 $result = fetch_items($category);
106 $_POST['sales_type_id'] = $salestype;
107 while ($myrow=db_fetch($result))
109 if ($catgor != $myrow['description'])
111 $rep->Line($rep->row - $rep->lineHeight);
114 $rep->TextCol(0, 3, $myrow['category_id'] . " - " . $myrow['description']);
115 $catgor = $myrow['description'];
120 $rep->TextCol(0, 1, $myrow['stock_id']);
121 $rep->TextCol(1, 2, $myrow['name']);
122 $price = get_price($myrow['stock_id'], $currency, $salestype);
123 $rep->TextCol(2, 3, number_format2($price, $dec));
126 $price2 = get_price($myrow['stock_id'], $home_curr, $salestype);
128 $disp = ($price2 - $myrow['Standardcost']) * 100 / $price2;
131 $rep->TextCol(3, 4, number_format2($disp, user_percent_dec()) . " %");
135 $image = $comp_path . '/'. $user_comp . "/images/" . $myrow['stock_id'] . ".jpg";
136 if (file_exists($image))
139 if ($rep->row - $pic_height < $rep->bottomMargin)
141 $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, $pic_width, $pic_height);
142 $rep->row -= $pic_height;
149 $rep->Line($rep->row - 4);