function print_profit_and_loss_statement() { global $comp_path, $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $compare = $_REQUEST['PARAM_2']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_3']; $dimension2 = $_REQUEST['PARAM_4']; $graphics = $_REQUEST['PARAM_5']; $comments = $_REQUEST['PARAM_6']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_3']; $graphics = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { $graphics = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } } if ($graphics) { include_once $path_to_root . "reporting/includes/class.graphic.inc"; $pg = new graph(); } $dec = 0; $pdec = user_percent_dec(); $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(tr('Account'), tr('Account Name'), tr('Period'), tr('Accumulated'), tr('Achieved %')); $aligns = array('left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to)); } } if ($compare == 0 || $compare == 2) { $end = $to; if ($compare == 2) { $begin = $from; $headers[3] = tr('Budget'); } else { $begin = begin_fiscalyear(); } } elseif ($compare == 1) { $begin = add_months($from, -12); $end = add_months($to, -12); $headers[3] = tr('Period Y-1'); } $rep = new FrontReport(tr('Profit and Loss Statement'), "ProfitAndLoss.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $totalper = 0.0; $totalacc = 0.0; $classper = 0.0; $classacc = 0.0; $salesper = 0.0; $salesacc = 0.0; $accounts = get_gl_accounts_all(0); while ($account = db_fetch($accounts)) { $per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if ($compare == 2) { $acc_balance = get_budget_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } else { $acc_balance = get_gl_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } if (!$per_balance && !$acc_balance) { continue; } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $totalper = $totalacc = 0.0; $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->Font(); $salesper += $classper; $salesacc += $classacc; $classper = $classacc = 0.0; $rep->NewLine(3); $closeclass = false; } } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 5, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 5, $account['AccountTypeName']); $rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $per_balance *= -1; $acc_balance *= -1; $totalper += $per_balance; $totalacc += $acc_balance; $classper += $per_balance; $classacc += $acc_balance; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); $rep->TextCol(2, 3, number_format2($per_balance, $dec)); $rep->TextCol(3, 4, number_format2($acc_balance, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($per_balance, $acc_balance), $pdec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $calculateper = $salesper + $classper; $calculateacc = $salesacc + $classacc; $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->row -= $rep->lineHeight + 8; $rep->TextCol(0, 2, tr('Calculated Return')); $rep->TextCol(2, 3, number_format2($calculateper, $dec)); $rep->TextCol(3, 4, number_format2($calculateacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($calculateper, $calculateacc), $pdec)); if ($graphics) { $pg->x[] = tr('Calculated Return'); $pg->y[] = abs($calculateper); $pg->z[] = abs($calculateacc); } $rep->Font(); $rep->NewLine(); } } } $rep->Line($rep->row); if ($graphics) { global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = tr("Group"); $pg->axis_y = tr("Amount"); $pg->graphic_1 = $headers[2]; $pg->graphic_2 = $headers[3]; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf"; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function print_stock_check() { global $path_to_root, $pic_height; $category = $_POST['PARAM_0']; $location = $_POST['PARAM_1']; $pictures = $_POST['PARAM_2']; $check = $_POST['PARAM_3']; $shortage = $_POST['PARAM_4']; $no_zeros = $_POST['PARAM_5']; $like = $_POST['PARAM_6']; $comments = $_POST['PARAM_7']; $orientation = $_POST['PARAM_8']; $destination = $_POST['PARAM_9']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } if ($location == ALL_TEXT) { $location = 'all'; } if ($location == 'all') { $loc = _('All'); } else { $loc = get_location_name($location); } if ($shortage) { $short = _('Yes'); $available = _('Shortage'); } else { $short = _('No'); $available = _('Available'); } if ($no_zeros) { $nozeros = _('Yes'); } else { $nozeros = _('No'); } if ($check) { $cols = array(0, 75, 225, 250, 295, 345, 390, 445, 515); $headers = array(_('Stock ID'), _('Description'), _('UOM'), _('Quantity'), _('Check'), _('Demand'), $available, _('On Order')); $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right'); } else { $cols = array(0, 75, 225, 250, 315, 380, 445, 515); $headers = array(_('Stock ID'), _('Description'), _('UOM'), _('Quantity'), _('Demand'), $available, _('On Order')); $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right'); } $params = array(0 => $comments, 1 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => _('Location'), 'from' => $loc, 'to' => ''), 3 => array('text' => _('Only Shortage'), 'from' => $short, 'to' => ''), 4 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => '')); if ($pictures) { $user_comp = user_company(); } else { $user_comp = ""; } $rep = new FrontReport(_('Stock Check Sheets'), "StockCheckSheet", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($category, $location, $like); $catt = ''; while ($trans = db_fetch($res)) { if ($location == 'all') { $loc_code = ""; } else { $loc_code = $location; } $demandqty = get_demand_qty($trans['stock_id'], $loc_code); $demandqty += get_demand_asm_qty($trans['stock_id'], $loc_code); $onorder = get_on_porder_qty($trans['stock_id'], $loc_code); $flag = get_mb_flag($trans['stock_id']); if ($flag == 'M') { $onorder += get_on_worder_qty($trans['stock_id'], $loc_code); } if ($no_zeros && $trans['QtyOnHand'] == 0 && $demandqty == 0 && $onorder == 0) { continue; } if ($shortage && $trans['QtyOnHand'] - $demandqty >= 0) { continue; } if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->Line($rep->row - 2); $rep->NewLine(2, 3); } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 2, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } $rep->NewLine(); $dec = get_qty_dec($trans['stock_id']); $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1); $rep->TextCol(2, 3, $trans['units']); $rep->AmountCol(3, 4, $trans['QtyOnHand'], $dec); if ($check) { $rep->TextCol(4, 5, "_________"); $rep->AmountCol(5, 6, $demandqty, $dec); $rep->AmountCol(6, 7, $trans['QtyOnHand'] - $demandqty, $dec); $rep->AmountCol(7, 8, $onorder, $dec); } else { $rep->AmountCol(4, 5, $demandqty, $dec); $rep->AmountCol(5, 6, $trans['QtyOnHand'] - $demandqty, $dec); $rep->AmountCol(6, 7, $onorder, $dec); } if ($pictures) { $image = company_path() . '/images/' . item_img_name($trans['stock_id']) . '.jpg'; if (file_exists($image)) { $rep->NewLine(); if ($rep->row - $pic_height < $rep->bottomMargin) { $rep->NewPage(); } $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, 0, $pic_height); $rep->row -= $pic_height; $rep->NewLine(); } } } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function print_price_listing() { global $path_to_root, $pic_height, $pic_width; $currency = $_POST['PARAM_0']; $category = $_POST['PARAM_1']; $salestype = $_POST['PARAM_2']; $pictures = $_POST['PARAM_3']; $showGP = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $home_curr = get_company_pref('curr_default'); if ($currency == ALL_TEXT) { $currency = $home_curr; } $curr = get_currency($currency); $curr_sel = $currency . " - " . $curr['currency']; if ($category == ALL_NUMERIC) { $category = 0; } if ($salestype == ALL_NUMERIC) { $salestype = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } if ($salestype == 0) { $stype = _('All'); } else { $stype = get_sales_type_name($salestype); } if ($showGP == 0) { $GP = _('No'); } else { $GP = _('Yes'); } $cols = array(0, 100, 360, 385, 450, 515); $headers = array(_('Category/Items'), _('Description'), _('UOM'), _('Price'), _('GP %')); $aligns = array('left', 'left', 'left', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Currency'), 'from' => $curr_sel, 'to' => ''), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Sales Type'), 'from' => $stype, 'to' => ''), 4 => array('text' => _('Show GP %'), 'from' => $GP, 'to' => '')); if ($pictures) { $user_comp = user_company(); } else { $user_comp = ""; } $rep = new FrontReport(_('Price Listing'), "PriceListing", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $result = fetch_items($category); $catgor = ''; $_POST['sales_type_id'] = $salestype; while ($myrow = db_fetch($result)) { if ($catgor != $myrow['description']) { $rep->Line($rep->row - $rep->lineHeight); $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['category_id'] . " - " . $myrow['description']); $catgor = $myrow['description']; $rep->fontSize -= 2; $rep->NewLine(); } $rep->NewLine(); $rep->TextCol(0, 1, $myrow['stock_id']); $rep->TextCol(1, 2, $myrow['name']); $rep->TextCol(2, 3, $myrow['units']); $price = get_price($myrow['stock_id'], $currency, $salestype); $rep->AmountCol(3, 4, $price, $dec); if ($showGP) { $price2 = get_price($myrow['stock_id'], $home_curr, $salestype); if ($price2 != 0.0) { $disp = ($price2 - $myrow['Standardcost']) * 100 / $price2; } else { $disp = 0.0; } $rep->TextCol(4, 5, number_format2($disp, user_percent_dec()) . " %"); } if ($pictures) { $image = company_path() . "/images/" . item_img_name($myrow['stock_id']) . ".jpg"; if (file_exists($image)) { $rep->NewLine(); if ($rep->row - $pic_height < $rep->bottomMargin) { $rep->NewPage(); } $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, 0, $pic_height); $rep->row -= $pic_height; $rep->NewLine(); } } else { $rep->NewLine(0, 1); } } $rep->Line($rep->row - 4); $result = get_kits($category); $catgor = ''; while ($myrow = db_fetch($result)) { if ($catgor != $myrow['cat_name']) { if ($catgor == '') { $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, _("Sales Kits")); $rep->fontSize -= 2; } $rep->Line($rep->row - $rep->lineHeight); $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['cat_id'] . " - " . $myrow['cat_name']); $catgor = $myrow['cat_name']; $rep->fontSize -= 2; $rep->NewLine(); } $rep->NewLine(); $rep->TextCol(0, 1, $myrow['kit_code']); $rep->TextCol(1, 3, $myrow['kit_name']); $price = get_kit_price($myrow['kit_code'], $currency, $salestype); $rep->AmountCol(3, 4, $price, $dec); $rep->NewLine(0, 1); } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function print_aged_supplier_analysis() { global $path_to_root, $systypes_array; $to = $_POST['PARAM_0']; $fromsupp = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $show_all = $_POST['PARAM_3']; $summaryOnly = $_POST['PARAM_4']; $no_zeros = $_POST['PARAM_5']; $graphics = $_POST['PARAM_6']; $comments = $_POST['PARAM_7']; $orientation = $_POST['PARAM_8']; $destination = $_POST['PARAM_9']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($graphics) { include_once $path_to_root . "/reporting/includes/class.graphic.inc"; $pg = new graph(); } if ($fromsupp == ALL_TEXT) { $from = _('All'); } else { $from = get_supplier_name($fromsupp); } $dec = user_price_dec(); if ($summaryOnly == 1) { $summary = _('Summary Only'); } else { $summary = _('Detailed Report'); } if ($currency == ALL_TEXT) { $convert = true; $currency = _('Balances in Home Currency'); } else { $convert = false; } if ($no_zeros) { $nozeros = _('Yes'); } else { $nozeros = _('No'); } if ($show_all) { $show = _('Yes'); } else { $show = _('No'); } $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; $nowdue = "1-" . $PastDueDays1 . " " . _('Days'); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _('Days'); $pastdue2 = _('Over') . " " . $PastDueDays2 . " " . _('Days'); $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515); $headers = array(_('Supplier'), '', '', _('Current'), $nowdue, $pastdue1, $pastdue2, _('Total Balance')); $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => _('Supplier'), 'from' => $from, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => _('Type'), 'from' => $summary, 'to' => ''), 5 => array('text' => _('Show Also Allocated'), 'from' => $show, 'to' => ''), 6 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => '')); if ($convert) { $headers[2] = _('currency'); } $rep = new FrontReport(_('Aged Supplier Analysis'), "AgedSupplierAnalysis", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $total = array(); $total[0] = $total[1] = $total[2] = $total[3] = $total[4] = 0.0; $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; $nowdue = "1-" . $PastDueDays1 . " " . _('Days'); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _('Days'); $pastdue2 = _('Over') . " " . $PastDueDays2 . " " . _('Days'); $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM " . TB_PREF . "suppliers"; if ($fromsupp != ALL_TEXT) { $sql .= " WHERE supplier_id=" . db_escape($fromsupp); } $sql .= " ORDER BY supp_name"; $result = db_query($sql, "The suppliers could not be retrieved"); while ($myrow = db_fetch($result)) { if (!$convert && $currency != $myrow['curr_code']) { continue; } if ($convert) { $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to); } else { $rate = 1.0; } $supprec = get_supplier_details($myrow['supplier_id'], $to, $show_all); if (!$supprec) { continue; } $supprec['Balance'] *= $rate; $supprec['Due'] *= $rate; $supprec['Overdue1'] *= $rate; $supprec['Overdue2'] *= $rate; $str = array($supprec["Balance"] - $supprec["Due"], $supprec["Due"] - $supprec["Overdue1"], $supprec["Overdue1"] - $supprec["Overdue2"], $supprec["Overdue2"], $supprec["Balance"]); if ($no_zeros && floatcmp(array_sum($str), 0) == 0) { continue; } $rep->fontSize += 2; $rep->TextCol(0, 2, $myrow['name']); if ($convert) { $rep->TextCol(2, 3, $myrow['curr_code']); } $rep->fontSize -= 2; $total[0] += $supprec["Balance"] - $supprec["Due"]; $total[1] += $supprec["Due"] - $supprec["Overdue1"]; $total[2] += $supprec["Overdue1"] - $supprec["Overdue2"]; $total[3] += $supprec["Overdue2"]; $total[4] += $supprec["Balance"]; for ($i = 0; $i < count($str); $i++) { $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec); } $rep->NewLine(1, 2); if (!$summaryOnly) { $res = get_invoices($myrow['supplier_id'], $to, $show_all); if (db_num_rows($res) == 0) { continue; } $rep->Line($rep->row + 4); while ($trans = db_fetch($res)) { $rep->NewLine(1, 2); $rep->TextCol(0, 1, $systypes_array[$trans['type']], -2); $rep->TextCol(1, 2, $trans['reference'], -2); $rep->TextCol(2, 3, sql2date($trans['tran_date']), -2); foreach ($trans as $i => $value) { $trans[$i] *= $rate; } $str = array($trans["Balance"] - $trans["Due"], $trans["Due"] - $trans["Overdue1"], $trans["Overdue1"] - $trans["Overdue2"], $trans["Overdue2"], $trans["Balance"]); for ($i = 0; $i < count($str); $i++) { $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec); } } $rep->Line($rep->row - 8); $rep->NewLine(2); } } if ($summaryOnly) { $rep->Line($rep->row + 4); $rep->NewLine(); } $rep->fontSize += 2; $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; for ($i = 0; $i < count($total); $i++) { $rep->AmountCol($i + 3, $i + 4, $total[$i], $dec); if ($graphics && $i < count($total) - 1) { $pg->y[$i] = abs($total[$i]); } } $rep->Line($rep->row - 8); $rep->NewLine(); if ($graphics) { global $decseps, $graph_skin; $pg->x = array(_('Current'), $nowdue, $pastdue1, $pastdue2); $pg->title = $rep->title; $pg->axis_x = _("Days"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $to; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->NewPage(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function print_aged_supplier_analysis() { global $comp_path, $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $to = $_REQUEST['PARAM_0']; $fromsupp = $_REQUEST['PARAM_1']; $currency = $_REQUEST['PARAM_2']; $summaryOnly = $_REQUEST['PARAM_3']; $graphics = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; if ($graphics) { include_once $path_to_root . "reporting/includes/class.graphic.inc"; $pg = new graph(); } if ($fromsupp == reserved_words::get_all_numeric()) { $from = tr('All'); } else { $from = get_supplier_name($fromsupp); } $dec = user_price_dec(); if ($summaryOnly == 1) { $summary = tr('Summary Only'); } else { $summary = tr('Detailed Report'); } if ($currency == reserved_words::get_all()) { $convert = true; $currency = tr('Balances in Home Currency'); } else { $convert = false; } $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; $nowdue = "1-" . $PastDueDays1 . " " . tr('Days'); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . tr('Days'); $pastdue2 = tr('Over') . " " . $PastDueDays2 . " " . tr('Days'); $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515); $headers = array(tr('Supplier'), '', '', tr('Current'), $nowdue, $pastdue1, $pastdue2, tr('Total Balance')); $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Supplier'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => tr('Type'), 'from' => $summary, 'to' => '')); if ($convert) { $headers[2] = tr('currency'); } $rep = new FrontReport(tr('Aged Supplier Analysis'), "AgedSupplierAnalysis.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $total = array(); $total[0] = $total[1] = $total[2] = $total[3] = $total[4] = 0.0; $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; $nowdue = "1-" . $PastDueDays1 . " " . tr('Days'); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . tr('Days'); $pastdue2 = tr('Over') . " " . $PastDueDays2 . " " . tr('Days'); $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM suppliers "; if ($fromsupp != reserved_words::get_all_numeric()) { $sql .= "WHERE supplier_id={$fromsupp} "; } $sql .= "ORDER BY supp_name"; $result = db_query($sql, "The suppliers could not be retrieved"); while ($myrow = db_fetch($result)) { if (!$convert && $currency != $myrow['curr_code']) { continue; } $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['name']); if ($convert) { $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to); $rep->TextCol(2, 4, $myrow['curr_code']); } else { $rate = 1.0; } $rep->fontSize -= 2; $supprec = get_supplier_details($myrow['supplier_id'], $to); foreach ($supprec as $i => $value) { $supprec[$i] *= $rate; } $total[0] += $supprec["Balance"] - $supprec["Due"]; $total[1] += $supprec["Due"] - $supprec["Overdue1"]; $total[2] += $supprec["Overdue1"] - $supprec["Overdue2"]; $total[3] += $supprec["Overdue2"]; $total[4] += $supprec["Balance"]; $str = array(number_format2($supprec["Balance"] - $supprec["Due"], $dec), number_format2($supprec["Due"] - $supprec["Overdue1"], $dec), number_format2($supprec["Overdue1"] - $supprec["Overdue2"], $dec), number_format2($supprec["Overdue2"], $dec), number_format2($supprec["Balance"], $dec)); for ($i = 0; $i < count($str); $i++) { $rep->TextCol($i + 3, $i + 4, $str[$i]); } $rep->NewLine(1, 2); if (!$summaryOnly) { $res = get_invoices($myrow['supplier_id'], $to); if (db_num_rows($res) == 0) { continue; } $rep->Line($rep->row + 4); while ($trans = db_fetch($res)) { $rep->NewLine(1, 2); $rep->TextCol(0, 1, $trans['type_name'], -2); $rep->TextCol(1, 2, $trans['reference'], -2); $rep->TextCol(2, 3, sql2date($trans['tran_date']), -2); foreach ($trans as $i => $value) { $trans[$i] *= $rate; } $str = array(number_format2($trans["Balance"] - $trans["Due"], $dec), number_format2($trans["Due"] - $trans["Overdue1"], $dec), number_format2($trans["Overdue1"] - $trans["Overdue2"], $dec), number_format2($trans["Overdue2"], $dec), number_format2($trans["Balance"], $dec)); for ($i = 0; $i < count($str); $i++) { $rep->TextCol($i + 3, $i + 4, $str[$i]); } } $rep->Line($rep->row - 8); $rep->NewLine(2); } } if ($summaryOnly) { $rep->Line($rep->row + 4); $rep->NewLine(); } $rep->fontSize += 2; $rep->TextCol(0, 3, tr('Grand Total')); $rep->fontSize -= 2; for ($i = 0; $i < count($total); $i++) { $rep->TextCol($i + 3, $i + 4, number_format2($total[$i], $dec)); if ($graphics && $i < count($total) - 1) { $pg->y[$i] = abs($total[$i]); } } $rep->Line($rep->row - 8); if ($graphics) { global $decseps, $graph_skin; $pg->x = array(tr('Current'), $nowdue, $pastdue1, $pastdue2); $pg->title = $rep->title; $pg->axis_x = tr("Days"); $pg->axis_y = tr("Amount"); $pg->graphic_1 = $to; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf"; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function print_price_listing() { global $comp_path, $path_to_root, $pic_height, $pic_width; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $category = $_REQUEST['PARAM_0']; $salestype = $_REQUEST['PARAM_1']; $pictures = $_REQUEST['PARAM_2']; $showGP = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; $dec = user_price_dec(); if ($category == reserved_words::get_all_numeric()) { $category = 0; } if ($salestype == reserved_words::get_all_numeric()) { $salestype = 0; } if ($category == 0) { $cat = tr('All'); } else { $cat = get_category_name($category); } if ($salestype == 0) { $stype = tr('All'); } else { $stype = get_sales_type_name($salestype); } if ($showGP == 0) { $GP = tr('No'); } else { $GP = tr('Yes'); } $cols = array(0, 100, 385, 450, 515); $headers = array(tr('Category/Items'), tr('Description'), tr('Price'), tr('GP %')); $aligns = array('left', 'left', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Sales Type'), 'from' => $stype, 'to' => ''), 3 => array('text' => tr('Show GP %'), 'from' => $GP, 'to' => '')); if ($pictures) { $user_comp = user_company(); } else { $user_comp = ""; } $rep = new FrontReport(tr('Price Listing'), "PriceListing.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $result = fetch_prices($category, $salestype); $currcode = ''; $catgor = ''; while ($myrow = db_fetch($result)) { if ($currcode != $myrow['curr_abrev']) { $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['curr_abrev'] . " " . tr('Prices')); $currcode = $myrow['curr_abrev']; $rep->fontSize -= 2; $rep->NewLine(); } if ($catgor != $myrow['description']) { $rep->Line($rep->row - $rep->lineHeight); $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['category_id'] . " - " . $myrow['description']); $catgor = $myrow['description']; $rep->fontSize -= 2; $rep->NewLine(); } $rep->NewLine(); $rep->TextCol(0, 1, $myrow['stock_id']); $rep->TextCol(1, 2, $myrow['name']); $rep->TextCol(2, 3, number_format2($myrow['price'], $dec)); if ($showGP) { if ($myrow['price'] != 0.0) { $disp = ($myrow['price'] - $myrow['Standardcost']) * 100 / $myrow['price']; } else { $disp = 0.0; } $rep->TextCol(3, 4, number_format2($disp, user_percent_dec()) . " %"); } if ($pictures) { $image = $comp_path . '/' . $user_comp . "/images/" . $myrow['stock_id'] . ".jpg"; if (file_exists($image)) { $rep->NewLine(); if ($rep->row - $pic_height < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, $pic_width, $pic_height); $rep->row -= $pic_height; $rep->NewLine(); } } else { $rep->NewLine(0, 1); } } $rep->Line($rep->row - 4); $rep->End(); }
function print_sales_quotations() { global $path_to_root, $print_as_quote, $print_invoice_no, $no_zero_lines_amount, $print_item_images_on_quote, $pic_height; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $pictures = isset($print_item_images_on_quote) && $print_item_images_on_quote == 1; // If you want a larger image, then increase $pic_height f.i. // $pic_height += 25; $cols = array(4, 60, 225, 300, 325, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'right', 'left', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { $rep = new FrontReport(_("SALES QUOTATION"), "SalesQuotationBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { $myrow = get_sales_order_header($i, ST_SALESQUOTE); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); if ($print_invoice_no == 1) { $rep->filename = "SalesQuotation" . $i . ".pdf"; } else { $rep->filename = "SalesQuotation" . $myrow['reference'] . ".pdf"; } } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'order', $branch['debtor_no'], true); $rep->SetCommonData($myrow, $branch, $myrow, $baccount, ST_SALESQUOTE, $contacts); //$rep->headerFunc = 'Header2'; $rep->NewPage(); $result = get_sales_order_details($i, ST_SALESQUOTE); $SubTotal = 0; $items = $prices = array(); while ($myrow2 = db_fetch($result)) { $Net = round2((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"], user_price_dec()); $prices[] = $Net; $items[] = $myrow2['stk_code']; $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($myrow2["quantity"], get_qty_dec($myrow2['stk_code'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = ""; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->TextCol(0, 1, $myrow2['stk_code'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 2, $myrow2['description'], -2); $newrow = $rep->row; $rep->row = $oldrow; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { $rep->TextCol(2, 3, $DisplayQty, -2); $rep->TextCol(3, 4, $myrow2['units'], -2); $rep->TextCol(4, 5, $DisplayPrice, -2); $rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); } $rep->row = $newrow; if ($pictures) { $image = company_path() . "/images/" . item_img_name($myrow2['stk_code']) . ".jpg"; if (file_exists($image)) { //$rep->NewLine(); if ($rep->row - $pic_height < $rep->bottomMargin) { $rep->NewPage(); } $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, 0, $pic_height); $rep->row -= $pic_height; $rep->NewLine(); } } //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } if ($myrow['comments'] != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $myrow['comments'], -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($myrow["freight_cost"], $dec); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_SALESQUOTE; $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Shipping"), -2); $rep->TextCol(6, 7, $DisplayFreight, -2); $rep->NewLine(); $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); if ($myrow['tax_included'] == 0) { $rep->TextCol(3, 6, _("TOTAL ORDER EX VAT"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $rep->NewLine(); } $tax_items = get_tax_for_items($items, $prices, $myrow["freight_cost"], $myrow['tax_group_id'], $myrow['tax_included'], null); $first = true; foreach ($tax_items as $tax_item) { if ($tax_item['Value'] == 0) { continue; } $DisplayTax = number_format2($tax_item['Value'], $dec); $tax_type_name = $tax_item['tax_type_name']; if ($myrow['tax_included']) { if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) { if ($first) { $rep->TextCol(3, 6, _("Total Tax Excluded"), -2); $rep->TextCol(6, 7, number_format2($sign * $tax_item['net_amount'], $dec), -2); $rep->NewLine(); } $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); $first = false; } else { $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . " " . _("Amount") . ": " . $DisplayTax, -2); } } else { $SubTotal += $tax_item['Value']; $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL ORDER VAT INCL."), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($myrow["freight_cost"] + $SubTotal, ST_SALESQUOTE); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); if ($email == 1) { if ($print_invoice_no == 1) { $myrow['reference'] = $i; } $rep->End($email); } } if ($email == 0) { $rep->End(); } }
function print_balance_sheet() { global $comp_path, $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_2']; $dimension2 = $_REQUEST['PARAM_3']; $graphics = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_2']; $graphics = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } else { $graphics = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; } } if ($graphics) { include_once $path_to_root . "reporting/includes/class.graphic.inc"; $pg = new graph(); } $dec = 0; $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(tr('Account'), tr('Account Name'), tr('Open Balance'), tr('Period'), tr('Close Balance')); $aligns = array('left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to)); } } $rep = new FrontReport(tr('Balance Sheet'), "BalanceSheet.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $totalopen = 0.0; $totalperiod = 0.0; $totalclose = 0.0; $classopen = 0.0; $classperiod = 0.0; $classclose = 0.0; $assetsopen = 0.0; $assetsperiod = 0.0; $assetsclose = 0.0; $closeclass = false; $accounts = get_gl_accounts_all(1); while ($account = db_fetch($accounts)) { $prev_balance = get_gl_balance_from_to("", $from, $account["account_code"], $dimension, $dimension2); $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if (!$prev_balance && !$curr_balance) { continue; } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalopen, $dec)); $rep->TextCol(3, 4, number_format2($totalperiod, $dec)); $rep->TextCol(4, 5, number_format2($totalclose, $dec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalclose); } $totalopen = $totalperiod = $totalclose = 0.0; $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classopen, $dec)); $rep->TextCol(3, 4, number_format2($classperiod, $dec)); $rep->TextCol(4, 5, number_format2($classclose, $dec)); $rep->Font(); $assetsopen += $classopen; $assetsperiod += $classperiod; $assetsclose += $classclose; $classopen = $classperiod = $classclose = 0.0; $rep->NewLine(3); $closeclass = false; } } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 5, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 5, $account['AccountTypeName']); $rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $totalopen += $prev_balance; $totalperiod += $curr_balance; $totalclose = $totalopen + $totalperiod; $classopen += $prev_balance; $classperiod += $curr_balance; $classclose = $classopen + $classperiod; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); $rep->TextCol(2, 3, number_format2($prev_balance, $dec)); $rep->TextCol(3, 4, number_format2($curr_balance, $dec)); $rep->TextCol(4, 5, number_format2($curr_balance + $prev_balance, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalopen, $dec)); $rep->TextCol(3, 4, number_format2($totalperiod, $dec)); $rep->TextCol(4, 5, number_format2($totalclose, $dec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalclose); } $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $calculateopen = -$assetsopen - $classopen; $calculateperiod = -$assetsperiod - $classperiod; $calculateclose = -$assetsclose - $classclose; $rep->row -= 6; $rep->TextCol(0, 2, tr('Calculated Return')); $rep->TextCol(2, 3, number_format2($calculateopen, $dec)); $rep->TextCol(3, 4, number_format2($calculateperiod, $dec)); $rep->TextCol(4, 5, number_format2($calculateclose, $dec)); if ($graphics) { $pg->x[] = tr('Calculated Return'); $pg->y[] = abs($calculateclose); } $rep->row -= $rep->lineHeight + 4; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2(-$assetsopen, $dec)); $rep->TextCol(3, 4, number_format2(-$assetsperiod, $dec)); $rep->TextCol(4, 5, number_format2(-$assetsclose, $dec)); $rep->Font(); $rep->NewLine(); } } } $rep->Line($rep->row); if ($graphics) { global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = tr("Group"); $pg->axis_y = tr("Amount"); $pg->graphic_1 = $to; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf"; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function print_stock_check() { global $comp_path, $path_to_root, $pic_height, $pic_width; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $category = $_REQUEST['PARAM_0']; $location = $_REQUEST['PARAM_1']; $pictures = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; $dec = user_qty_dec(); if ($category == reserved_words::get_all_numeric()) { $category = 0; } if ($category == 0) { $cat = tr('All'); } else { $cat = get_category_name($category); } if ($location == reserved_words::get_all()) { $location = 'all'; } if ($location == 'all') { $loc = tr('All'); } else { $loc = $location; } $cols = array(0, 100, 305, 375, 445, 515); $headers = array(tr('Category'), tr('Description'), tr('Quantity'), tr('Demand'), tr('Difference')); $aligns = array('left', 'left', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Location'), 'from' => $loc, 'to' => '')); if ($pictures) { $user_comp = user_company(); } else { $user_comp = ""; } $rep = new FrontReport(tr('Stock Check Sheets'), "StockCheckSheet.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $res = getTransactions($category, $location); $catt = ''; while ($trans = db_fetch($res)) { if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->Line($rep->row - 2); $rep->NewLine(2, 3); } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 2, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } $demandqty = getDemandQty($trans['stock_id'], $trans['loc_code']); $demandqty += getDemandAsmQty($trans['stock_id'], $trans['loc_code']); $rep->NewLine(); $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, number_format2($trans['QtyOnHand'], $dec)); $rep->TextCol(3, 4, number_format2($demandqty, $dec)); $rep->TextCol(4, 5, number_format2($trans['QtyOnHand'] - $demandqty, $dec)); if ($pictures) { $image = $comp_path . '/' . $user_comp . '/images/' . $trans['stock_id'] . '.jpg'; if (file_exists($image)) { $rep->NewLine(); if ($rep->row - $height < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, $pic_width, $pic_height); $rep->row -= $pic_height; $rep->NewLine(); } } } $rep->Line($rep->row - 4); $rep->End(); }