Пример #1
0
function clean_user_themes($id)
{
    global $db_connections, $db, $installed_extensions;
    $theme = $installed_extensions[$id]['package'];
    $comp = user_company();
    foreach ($db_connections as $n => $conn) {
        $db = $_SESSION["wa_current_user"]->set_db_connection($n);
        $sql = "UPDATE {$conn['tbpref']}users SET theme='default' WHERE theme='{$theme}'";
        if (!db_query($sql, 'Cannot update user theme settings')) {
            return false;
        }
    }
    $db = $_SESSION["wa_current_user"]->set_db_connection($comp);
    $_SESSION['wa_current_user']->prefs->theme = 'default';
    return true;
}
Пример #2
0
	$security_headings = array(
			_("Inquiries"),
			_("Accountant"),
			_("System Administrator"),
	);

	$security_groups = array(
			array(1,2),
			array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,16),
			array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20),
	);
*/
//MySQL Backup and Restore Settings
if (isset($_SESSION["wa_current_user"])) {
    define("BACKUP_PATH", $comp_path . '/' . user_company() . "/backup/");
}
// static js files path
$js_path = $path_to_root . '/js/';
// standard external js scripts included in all files
$js_static = array('JsHttpRequest.js', 'behaviour.js', 'utils.js', 'inserts.js');
// additional js source included in header
$js_lib = $js_userlib = array();
/* 
	Display a dropdown select box for choosing Company to login if false.
	Show a blank editbox only if true where the Company NickName
	will have to be manually entered. This is when privacy is needed.
*/
$text_company_selection = false;
/*  Should FA hide menu items (Applications, Modules, and Actions) from the user if they don't have access to them? 
    0 for no       1 for yes
Пример #3
0
    $exts = get_company_extensions($comp);
    $result = true;
    foreach ($exts as $i => $ext) {
        if ($ext['package'] && $ext['active'] ^ check_value('Active' . $i)) {
            $activated = activate_hooks($ext['package'], $comp, !$ext['active']);
            // change active state
            if ($activated !== null) {
                $result &= $activated;
            }
            if ($activated || $activated === null) {
                $exts[$i]['active'] = check_value('Active' . $i);
            }
        }
    }
    write_extensions($exts, get_post('extset'));
    if (get_post('extset') == user_company()) {
        $installed_extensions = $exts;
    }
    if (!$result) {
        display_error(_('Status change for some extensions failed.'));
        $Ajax->activate('ext_tbl');
        // refresh settings display
    } else {
        display_notification(_('Current active extensions set has been saved.'));
    }
}
if ($id = find_submit('Update', false)) {
    install_extension($id);
}
if ($id = find_submit('Local', false)) {
    local_extension($id);
Пример #4
0
 * Handle unauthorized user action globally
 */
App::error(function (ASM\Foundation\Exceptions\UnauthorizedUserActionException $exception, $code) {
    if (Request::ajax()) {
        return ['error' => ['messages' => [$exception->getMessage()]]];
    }
    return is_null(\Request::header('referer')) ? Redirect::route('dashboard.index')->withInput()->withErrors([$exception->getMessage()]) : Redirect::back()->withInput()->withErrors([$exception->getMessage()]);
});
/**
 * Handle all validation errors globally
 */
App::error(function (ASM\Foundation\Exceptions\ValidationFailedException $exception, $code) {
    if (Request::ajax()) {
        return ['error' => ['fields' => $exception->getErrors(), 'messages' => $exception->getErrors()->all()]];
    }
    // The following line is to prevent errors related serializing objects (UploadedFile object to be exact)
    $inputs = Input::except('inputs');
    return is_null(\Request::header('referer')) ? Redirect::route('dashboard.index', [user_company()->code])->withInput($inputs)->withErrors([$exception->getMessage()]) : Redirect::back()->withInput($inputs)->withErrors($exception->getErrors());
});
/**
 * Handle all invalid login credentials globally
 */
App::error(function (ASM\Foundation\Exceptions\InvalidLoginCredentialsException $exception, $code) {
    return is_null(\Request::header('referer')) ? Redirect::route('dashboard.index')->withInput()->withErrors([$exception->getMessage()]) : Redirect::back()->withInput()->withErrors([$exception->getMessage()]);
});
/**
 * Handle general exceptions here
 */
App::error(function (Exception $exception, $code) {
    Log::error($exception);
});
Пример #5
0
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();
}
Пример #6
0
function display_company_edit($selected_id)
{
    global $def_coy, $db_connections, $tb_pref_counter;
    start_form();
    start_table(TABLESTYLE2);
    if ($selected_id != -1) {
        $conn = $db_connections[$selected_id];
        $_POST['name'] = $conn['name'];
        $_POST['host'] = $conn['host'];
        $_POST['dbuser'] = $conn['dbuser'];
        $_POST['dbpassword'] = $conn['dbpassword'];
        $_POST['dbname'] = $conn['dbname'];
        $_POST['tbpref'] = $conn['tbpref'];
        if ($selected_id == $def_coy) {
            $_POST['def'] = true;
        } else {
            $_POST['def'] = false;
        }
        $_POST['dbcreate'] = false;
        hidden('selected_id', $selected_id);
        hidden('tbpref', $_POST['tbpref']);
        hidden('dbpassword', $_POST['dbpassword']);
    } else {
        $_POST['tbpref'] = $tb_pref_counter . "_";
        // Insert the current settings as default
        $conn = $db_connections[user_company()];
        $_POST['name'] = '';
        $_POST['host'] = $conn['host'];
        $_POST['dbuser'] = $conn['dbuser'];
        $_POST['dbpassword'] = $conn['dbpassword'];
        $_POST['dbname'] = $conn['dbname'];
    }
    text_row_ex(_("Company"), 'name', 50);
    if ($selected_id == -1) {
        text_row_ex(_("Host"), 'host', 30, 60);
        text_row_ex(_("Database User"), 'dbuser', 30);
        text_row_ex(_("Database Password"), 'dbpassword', 30);
        text_row_ex(_("Database Name"), 'dbname', 30);
        yesno_list_row(_("Table Pref"), 'tbpref', 1, $_POST['tbpref'], _("None"), false);
    } else {
        label_row(_("Host"), $_POST['host']);
        label_row(_("Database User"), $_POST['dbuser']);
        label_row(_("Database Name"), $_POST['dbname']);
        label_row(_("Table Pref"), $_POST['tbpref']);
    }
    yesno_list_row(_("Default"), 'def', null, "", "", false);
    if ($selected_id == -1) {
        coa_list_row(_("Database Script"), 'coa');
        text_row_ex(_("New script Admin Password"), 'admpassword', 20);
    }
    end_table(1);
    submit_center('save', _("Save"));
    end_form();
}
Пример #7
0
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();
}
Пример #8
0
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();
}
Пример #9
0
<?php

$page_security = 11;
$path_to_root = "../..";
include $path_to_root . "/includes/session.inc";
page(tr("Items"));
include_once $path_to_root . "/includes/date_functions.inc";
include_once $path_to_root . "/includes/ui.inc";
include_once $path_to_root . "/includes/data_checks.inc";
include_once $path_to_root . "/inventory/includes/inventory_db.inc";
$user_comp = user_company();
if (isset($_GET['stock_id'])) {
    $stock_id = strtoupper($_GET['stock_id']);
} else {
    if (isset($_POST['stock_id'])) {
        $stock_id = strtoupper($_POST['stock_id']);
    }
}
if (isset($_GET['New']) || !isset($_POST['NewStockID'])) {
    $_POST['New'] = "1";
}
if (isset($_POST['SelectStockItem'])) {
    $_POST['NewStockID'] = $_POST['stock_id'];
    unset($_POST['New']);
}
check_db_has_stock_categories(tr("There are no item categories defined in the system. At least one item category is required to add a item."));
check_db_has_item_tax_types(tr("There are no item tax types defined in the system. At least one item tax type is required to add a item."));
function clear_data()
{
    unset($_POST['long_description']);
    unset($_POST['description']);
Пример #10
0
<?php

// session_start();
/* Print a report
 * repgen_print.php for PHP Report Generator
   Bauer, 5.2.2002
   Version 0.2
*/
// this has to be an own page, because otherwise we could not get Content-type application/pdf
$path_to_root = "../..";
$page_security = 'SA_REPORT_GENERATOR';
include_once $path_to_root . "/includes/session.inc";
add_access_extensions();
include_once $path_to_root . "/includes/date_functions.inc";
include_once $path_to_root . "/admin/db/company_db.inc";
include_once $path_to_root . "/includes/ui.inc";
require_once "includes/repgen.inc";
$id = $_GET['id'];
$file = $comp_path . '/' . user_company() . '/pdf_files/' . $id . '.pdf';
create_report($id, $file);
?>



Пример #11
0
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();
}
Пример #12
0
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();
}
Пример #13
0
<?php

$page_security = 10;
$path_to_root = "..";
include $path_to_root . "/includes/session.inc";
page(tr("Display Setup"));
include_once $path_to_root . "/includes/date_functions.inc";
include_once $path_to_root . "/includes/ui.inc";
include_once $path_to_root . "/admin/db/company_db.inc";
//-------------------------------------------------------------------------------------------------
if (isset($_POST['setprefs'])) {
    $theme = user_theme();
    set_user_prefs($_POST['prices'], $_POST['Quantities'], $_POST['Rates'], $_POST['Percent'], check_value('show_gl'), check_value('show_codes'), $_POST['date_format'], $_POST['date_sep'], $_POST['tho_sep'], $_POST['dec_sep'], $_POST['theme'], $_POST['page_size']);
    language::set_language($_POST['language']);
    flush_dir($comp_path . '/' . user_company() . '/js_cache');
    if (user_theme() != $theme) {
        reload_page("");
    }
    display_notification_centered(tr("Display settings have been updated."));
}
start_form();
start_table($table_style2);
table_section_title(tr("Decimal Places"));
text_row_ex(tr("Prices/Amounts:"), 'prices', 5, 5, user_price_dec());
text_row_ex(tr("Quantities:"), 'Quantities', 5, 5, user_qty_dec());
text_row_ex(tr("Exchange Rates:"), 'Rates', 5, 5, user_exrate_dec());
text_row_ex(tr("Percentages:"), 'Percent', 5, 5, user_percent_dec());
table_section_title(tr("Dateformat and Separators"));
dateformats_list_row(tr("Dateformat:"), "date_format", user_date_format());
dateseps_list_row(tr("Date Separator:"), "date_sep", user_date_sep());
/* The array $dateseps is set up in config.php for modifications
Пример #14
0
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();
}
Пример #15
0
}
//-----------------------------------------------------------------------------------------------
div_start('details');
start_table(TABLESTYLE2);
text_row(_("Role name:"), 'name', null, 20, 22);
text_row(_("Role description:"), 'description', null, 50, 52);
record_status_list_row(_("Current status:"), 'inactive');
end_table(1);
start_table(TABLESTYLE, "width=40%");
$k = $j = 0;
//row colour counter
$ext = $sec = $m = -1;
foreach (sort_areas($security_areas) as $area => $parms) {
    // system setup areas are accessable only for site admins i.e.
    // admins of first registered company
    if (user_company() && ($parms[0] & 0xff00) == SS_SADMIN) {
        continue;
    }
    $newsec = $parms[0] >> 8 & 0xff;
    $newext = $parms[0] >> 16;
    if ($newsec != $sec || $newext != $ext && $newsec > 99) {
        // features set selection
        $ext = $newext;
        $sec = $newsec;
        $m = $parms[0] & ~0xff;
        //			if(!isset($security_sections[$m]))
        //			 display_error(sprintf("Bad section %X:", $m));
        label_row($security_sections[$m] . ':', checkbox(null, 'Section' . $m, null, true, _("On/off set of features")), "class='tableheader2'", "class='tableheader'");
    }
    if (check_value('Section' . $m)) {
        alt_table_row_color($k);
Пример #16
0
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();
}