<?php
/* * *******************************************************************************
* TES is a Time and Expense Management program developed by
* Initechs, LLC. Copyright (C) 2009 - 2010 Initechs LLC.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY INITECHS, INITECHS DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact Initechs headquarters at 1841 Piedmont Road, Suite 301,
* Marietta, GA, USA. or at email address hide@address.com
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display od the "Initechs" logo.
* If the display of the logo is not reasonably feasible for technical reasons,
* the Appropriate Legal Notices must display the words "Powered by Initechs".
* ****************************************************************************** */
$basedir = dirname(__FILE__) . '/..';
require_once("$basedir/baseclass/DBCommonFunctions.php");
require_once("$basedir/external_apps/html2pdf/html2fpdf.php");
function isUserRegistered() {
return (isset($_SESSION['userid']) and ($_SESSION['userid']) <> '') ? true : false;
}
function loggedInUserName() {
return isUserRegistered() ? $_SESSION['fullname'] : null;
}
function loggedUserID() {
return isUserRegistered() ? $_SESSION['userid'] : null;
}
function getUserAuthID() {
return isUserRegistered() ? $_SESSION['authid'] : null;
}
function getUserDateFormat() {
return isUserRegistered() ? strtolower($_SESSION['dateformat']) : 'mdy';
}
function getUserLanguage() {
return isUserRegistered() ? strtoupper($_SESSION['language']) : 'ENG';
}
function valid_email_address($email) {
if (preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,4}$/i', trim($email)))
return true;
else
return false;
}
function changeLiteral($literal) {
if (strtoupper(getUserLanguage()) == 'ENG')
return $literal;
if (isset($_SESSION['literal'][strtolower($literal)]))
return $_SESSION['literal'][strtolower($literal)];
else
return ('*' . $literal);
}
function getCompany() {
if (isset($_SESSION['company']))
return;
if (!class_exists('dbComObj')) {
class dbComObj extends DBCommonFunctions { }
}
$DbObj = new dbComObj();
$RowData = $DbObj->fetchRowByWhereClause("company", "uid = 1");
if ($RowData != null) {
$_SESSION['company']['company_id'] = $RowData['company_id'];
$_SESSION['company']['name'] = $RowData['name'];
$_SESSION['company']['address1'] = $RowData['address1'];
$_SESSION['company']['address2'] = $RowData['address2'];
$_SESSION['company']['city'] = $RowData['city'];
$_SESSION['company']['state'] = $RowData['state'];
$_SESSION['company']['postalcode'] = $RowData['postalcode'];
$_SESSION['company']['country'] = $RowData['country'];
$_SESSION['company']['logo'] = $RowData['logo'];
$_SESSION['company']['weekendday'] = $RowData['weekendday'];
$_SESSION['company']['language'] = $RowData['language'];
}
unset($DbObj);
}
function getMessage($msgid, $msgdta='') {
$language = getUSerLanguage();
$msgid = strtolower($msgid);
if (!class_exists('dbMsgObj')) {
class dbMsgObj extends DBCommonFunctions { }
}
$DbObj = new dbMsgObj();
$where = "language = '$language' and msgid = '$msgid'";
$RowData = $DbObj->fetchRowByWhereClause('messages', $where);
if ($RowData == null) {
$where = "language = 'ENG' and msgid = '$msgid'";
$RowData = $DbObj->fetchRowByWhereClause('messages', $where);
if ($RowData != null)
$RowData['msgdesc'] .= "<br />Technical Info: Message for $msgid in $language language is not set.";
}
unset($DbObj);
$msg = $RowData == null ? "Message is not set for message id = $msgid" : $RowData['msgdesc'] . $msgdta;
return ($msg);
}
class ReportFunctions {
public function ProjectCompanyAddress($projects_id) {
$CA = '';
$DbObj = new dbObj();
$query = "select accounts.name as name,
accounts.address1 as address1,
accounts.address2 as address2,
accounts.city as city,
accounts.state as state,
accounts.postalcode as postalcode
from projects, accounts
where projects.projects_id = '$projects_id'
and projects.billtoaccount_id = accounts.accounts_id
and projects.billtoaccount_id <> projects.accounts_id";
$dataset = $DbObj->getDatabyQuery($query);
if ($dataset[0] == null) {
$companyRec = $DbObj->getCompanyRec();
$CA['name'] = $companyRec['name'];
$CA['address1'] = $companyRec['address1'];
$CA['address2'] = $companyRec['address2'];
$CA['city'] = $companyRec['city'];
$CA['state'] = $companyRec['state'];
$CA['postalcode'] = $companyRec['postalcode'];
} else {
$CA['name'] = $dataset[0]['name'];
$CA['address1'] = $dataset[0]['address1'];
$CA['address2'] = $dataset[0]['address2'];
$CA['city'] = $dataset[0]['city'];
$CA['state'] = $dataset[0]['state'];
$CA['postalcode'] = $dataset[0]['postalcode'];
}
return $CA;
}
}
?>