<?php

require_once '../common/config/config.inc.php';
require_once SOURCE_ROOT . 'classes/class.sort.php';
require_once SOURCE_ROOT . 'classes/class.paging.php';
require_once SOURCE_ROOT . 'classes/class.tax_discount.php';
//	CREATING THE CLASS OBJECTS FOR INCLUDING CLASS FILES
$objPaging = new Paging();
$objTaxDiscount = new TaxDiscount();
$_SESSION['sessTaxRedirectUrl'] = '';
$_SESSION['sessTaxDiscountAdd'] = '';
if ($_SERVER['QUERY_STRING'] != '') {
    $_SESSION['sessTaxRedirectUrl'] = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
} else {
    $_SESSION['sessTaxRedirectUrl'] = $_SERVER['PHP_SELF'];
}
//	CREATING THE FIELDS ARRAYS TO SHOW & TABLE (IF JOIN OR OTHER CONDITION EXISTS) & A WHERE CONDITION
$arrTaxDiscountFlds = array('pkTaxDiscountID', 'TaxDiscountType', 'TaxDiscountName', 'TaxDiscountValue', 'TaxDiscountDateAdded', 'TaxDiscountDateModified', 'TaxDiscountStatus');
//	GET THE SEARCHING CONDITION ON THE SPECIFIC SEARCHING
$varSearchWhere = $objTaxDiscount->getSearchKeyWhere($_GET);
//applied the paging
$varPageStart = $objPaging->getPageStartLimit($_GET['page'], ADMIN_PAGE_RECORD_SIZE);
$varLimit = $varPageStart . ',' . ADMIN_PAGE_RECORD_SIZE;
$varTaxDiscountClm = 'pkTaxDiscountID';
$varSearchWhr = $varSearchWhere;
$NumberofRows = $objDatabase->getNumRows(TABLE_TAX_DISCOUNTS, $varTaxDiscountClm, $varSearchWhr);
$varNumberPages = $objPaging->calculateNumberofPages($NumberofRows, ADMIN_PAGE_RECORD_SIZE);
$arrTaxDiscountList = $objTaxDiscount->getTaxDiscountRecord(TABLE_TAX_DISCOUNTS, $arrTaxDiscountFlds, $varLimit, $varSearchWhr);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php

require_once '../common/config/config.inc.php';
require_once SOURCE_ROOT . 'components/class.validation.inc.php';
require_once SOURCE_ROOT . 'classes/class.tax_discount.php';
//	CREATING THE CLASS OBJECTS FOR INCLUDING CLASS FILES
$objTaxDiscount = new TaxDiscount();
if (isset($_POST['frmSubmitPress']) && $_POST['frmSubmitPress'] == 'Yes') {
    if (!isset($_POST['frmTaxDiscountID'])) {
        $bolAffectedID = $objTaxDiscount->addTaxDiscount($_POST);
        if (!$bolAffectedID) {
            $objCore->standardRedirect('tax_discount_frm_uil.php');
        } else {
            $objCore->standardRedirect($_SESSION['sessTaxRedirectUrl']);
        }
    } else {
        $bolAffectedID = $objTaxDiscount->editTaxDiscount($_POST);
        if (!$bolAffectedID) {
            $objCore->standardRedirect('tax_discount_frm_uil.php?taxDiscountID=' . $_POST['frmTaxDiscountID']);
        } else {
            $objCore->standardRedirect($_SESSION['sessTaxRedirectUrl']);
        }
    }
}
if (isset($_POST['frmChangeAction']) || $_SESSION['arrUpdateList']['frmChangeAction']) {
    if ($_POST['frmChangeAction'] == 'Delete' || $_POST['frmChangeAction'] == 'Active' || $_POST['frmChangeAction'] == 'Inactive') {
        $objTaxDiscount->updateTaxDiscount($_POST);
        $objCore->standardRedirect($_SESSION['sessTaxRedirectUrl']);
    }
}