<?php

/* * ********************************************************************
  Copyright (C) FrontAccounting, LLC.
  Released under the terms of the GNU General Public License, GPL,
  as published by the Free Software Foundation, either version 3
  of the License, or (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 * ********************************************************************* */
$page_security = 'SA_GOODS_RETURN_FORM';
// ----------------------------------------------------------------
// $ Revision:	2.0 $
// Creator:	Janusz Dobrwolski
// date_:	2008-01-14
// Title:	Print Delivery Notes
// ----------------------------------------------------------------
$path_to_root = "..";

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 . "/includes/data_checks.inc");
include($path_to_root . "/modules/diligent/includes/form_db.inc");


print_form();

//----------------------------------------------------------------------------------------------------

function print_form() {
    global $path_to_root, $SysPrefs;

    include_once($path_to_root . "/modules/diligent/reporting/includes/ext_pdf_report.inc");

    $form_id = $_POST['PARAM_0'];
    $orientation = $_POST['PARAM_1'];

    $orientation = ($orientation ? 'L' : 'P');
    $dec = user_price_dec();

    //$cols = array(4, 60, 225, 300, 355, 515);
    $cols = array(4, 30,90, 300, 350, 420, 480, 515);

    // $headers in doctext.inc
    //$aligns = array('left',	'left',	'right', 'left', 'right', 'right', 'right');
    $aligns = array('left', 'left', 'left', 'center', 'center', 'left', 'left');
    $headers = array(_("No."),_("Item Code"), _("Item Description"), _("UOM"),
        _("QTY"),  _("Reason"), _("Notes"));
    $params = array();

    $cur = get_company_Pref('curr_default');

    $rep = new Ext_FrontReport(_('GOODS RETURN FORM'), "GoodsReturnForm", user_pagesize(), 9, $orientation);

    if ($orientation == 'L')
        recalculate_cols($cols);

    $rep->currency = $cur;
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);

    $form = get_form($form_id);
    $customer = get_customer($form['person_id']);
    $rep->formData = array("no"=>$form['id'],"date"=>$form['timestamp'],"debtor_no"=>$form['person_id'],
        "debtor_name"=>$customer['name'],"address"=>$customer['address'],"requestedby"=>$form['requestedby']);
    $rep->SetHeaderType('HeaderForm');
    $rep->NewPage();

    $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
    $rep->End();
}
